Back to index

glibc  2.9
Defines | Functions | Variables
failtest.c File Reference
#include <dlfcn.h>
#include <stdio.h>

Go to the source code of this file.


#define TEST_ROUNDS   10


int main (void)
void foo (void)


static const char unknown [] = "a-file-with-this-name-does-not-exist"
static const char exists [] = ""

Define Documentation

#define TEST_ROUNDS   10

Definition at line 6 of file failtest.c.

Function Documentation

void foo ( void  )
int main ( void  )

Definition at line 14 of file failtest.c.

  int i;

  setvbuf (stdout, NULL, _IONBF, 0);

  for (i = 0; i < TEST_ROUNDS; ++i)
      void *dsc;

      printf ("Round %d: Try loading \"%s\"\n", i, unknown);

      dsc = dlopen (unknown, RTLD_NOW);
      if (dsc != NULL)
         printf ("We found a file of name \"%s\": this should not happen\n",
         return 1;

      printf ("Round %d: loading \"%s\" failed\n", i, unknown);

      /* Don't use `dlerror', just load an existing file.  */
      dsc = dlopen (exists, RTLD_NOW);
      if (dsc == NULL)
         printf ("Could not load \"%s\": %s\n", exists, dlerror ());
         return 1;

      printf ("Round %d: Loaded \"%s\"\n", i, exists);

      dlclose (dsc);

      printf ("Round %d: Unloaded \"%s\"\n", i, exists);

  return 0;

Here is the call graph for this function:

Variable Documentation

const char exists[] = "" [static]

Definition at line 10 of file failtest.c.

const char unknown[] = "a-file-with-this-name-does-not-exist" [static]

Definition at line 9 of file failtest.c.