Back to index

glibc  2.9
Defines | Functions | Variables
tst-getrlimit.c File Reference
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/resource.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define ntests   (sizeof (tests) / sizeof (tests[0]))
#define TEST_FUNCTION   do_test ()

Functions

static int do_test (void)

Variables

struct {
const char * name
int resource
bool required
tests []

Define Documentation

#define ntests   (sizeof (tests) / sizeof (tests[0]))

Definition at line 46 of file tst-getrlimit.c.

#define TEST_FUNCTION   do_test ()

Definition at line 111 of file tst-getrlimit.c.


Function Documentation

static int do_test ( void  ) [static]

Definition at line 50 of file tst-getrlimit.c.

{
  int status = 0;

  for (int i = 0; i < ntests; ++i)
    {
      bool this_ok = true;

      struct rlimit r;
      int res = getrlimit (tests[i].resource, &r);
      if (res == -1)
       {
         if (errno == EINVAL)
           {
             if (tests[i].required)
              {
                printf ("limit %s expectedly not available for getrlimit\n",
                       tests[i].name);
                status = 1;
                this_ok = false;
              }
           }
         else
           {
             printf ("getrlimit for %s returned unexpected error: %m\n",
                    tests[i].name);
             status = 1;
             this_ok = false;
           }
       }

      struct rlimit64 r64;
      res = getrlimit64 (tests[i].resource, &r64);
      if (res == -1)
       {
         if (errno == EINVAL)
           {
             if (tests[i].required)
              {
                printf ("limit %s expectedly not available for getrlimit64"
                       "\n", tests[i].name);
                status = 1;
                this_ok = false;
              }
           }
         else
           {
             printf ("getrlimit64 for %s returned unexpected error: %m\n",
                    tests[i].name);
             status = 1;
             this_ok = false;
           }
       }

      if (this_ok)
       printf ("limit %s OK\n", tests[i].name);
    }

  return status;
}

Here is the call graph for this function:


Variable Documentation

struct { ... } tests[] [static]