Back to index

glibc  2.9
Classes | Functions | Variables
test-a64l.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <test-skeleton.c>

Go to the source code of this file.

Classes

struct  a64l_test

Functions

int do_test (int argc, char *argv[])
int do_test (int argc, char **argv)

Variables

static struct a64l_test []

Class Documentation

struct a64l_test

Definition at line 29 of file test-a64l.c.

Class Members
const char * base64
long int value

Function Documentation

int do_test ( int  argc,
char *  argv[] 
)

Definition at line 146 of file test-lfs.c.

{
  int ret;
  struct stat64 statbuf;

  ret = lseek64 (fd, TWO_GB+100, SEEK_SET);
  if (ret == -1 && errno == ENOSYS)
    {
      error (0, 0, "lseek64 is not supported.");
      exit (EXIT_SUCCESS);
    }
  if (ret == -1 && errno == EINVAL)
    {
      error (0, 0, "LFS seems not to be supported.");
      exit (EXIT_SUCCESS);
    }
  if (ret == -1)
    {
      error (0, errno, "lseek64 failed with error");
      exit (EXIT_FAILURE);
    }

  ret = write (fd, "Hello", 5);
  if (ret == -1 && errno == EFBIG)
    {
      error (0, 0, "LFS seems not to be supported.");
      exit (EXIT_SUCCESS);
    }

  if (ret == -1 && errno == ENOSPC)
    {
      error (0, 0, "Not enough space to write file.");
      exit (EXIT_SUCCESS);
    }

  if (ret != 5)
    error (EXIT_FAILURE, errno, "cannot write test string to large file");

  ret = close (fd);

  if (ret == -1)
    error (EXIT_FAILURE, errno, "error closing file");

  ret = stat64 (name, &statbuf);

  if (ret == -1 && (errno == ENOSYS || errno == EOVERFLOW))
    error (0, 0, "stat64 is not supported.");
  else if (ret == -1)
    error (EXIT_FAILURE, errno, "cannot stat file `%s'", name);
  else if (statbuf.st_size != (TWO_GB + 100 + 5))
    error (EXIT_FAILURE, 0, "stat reported size %lld instead of %lld.",
          (long long int) statbuf.st_size, (TWO_GB + 100 + 5));

  test_ftello ();

  return 0;
}
int do_test ( int  argc,
char **  argv 
)

Definition at line 51 of file test-a64l.c.

{
  const struct a64l_test *at;
  long int l;
  const char *s;
  int status = 0;

  for (at = tests; at->base64 != NULL; ++at)
    {
      printf ("a64l (\"%s\")", at->base64);
      l = a64l (at->base64);
      if (l == at->value)
       puts ("\tOK");
      else
       {
         printf ("\tBAD\n  returns %ld, expected %ld\n", l, at->value);
         status = 1;
       }
      printf ("l64a (%ld)", at->value);
      s = l64a (at->value);
      if (strcmp (s, at->base64) == 0)
       puts ("\tOK");
      else
       {
         printf ("\tBAD\n  returns \"%s\", expected \"%s\"\n", s, at->base64);
         status = 1;
       }
    }

  return status ? EXIT_FAILURE : EXIT_SUCCESS;
}

Here is the call graph for this function:


Variable Documentation

struct a64l_test[] [static]
Initial value:
  {
    { "./", 64 },
    { "", 0 },
    { "/", 1 },
    { "FT", 2001 },
    { "zzzzz1", 0xffffffff },
    { "zzzz1", 0x3ffffff },
    { "zzz1", 0xfffff },
    { "zz1", 0x3fff },
    { "z1", 0xff },
    { "1", 0x3 },
    { NULL, 0 }
  }

Definition at line 35 of file test-a64l.c.