diff options
author | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2016-10-28 20:29:21 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2016-10-28 20:31:55 +0200 |
commit | 99ef2719fb3d703fe38c4113cd7f5adec516dd3a (patch) | |
tree | 2c1f77cb41b60ccbf8faa77a3640491a3546b546 /test/misc | |
parent | 543308f6c46cf2edf8a524bc9c631e472570fe72 (diff) |
test: remove test suite
The test suite is now a developed in a separate git repository.
See here:
http://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng-test.git
The test suite should be just like every other software compiled
with the cross-toolchain. In the past strange problems where found
when the test suite got build in the toolchain creation step.
Diffstat (limited to 'test/misc')
-rw-r--r-- | test/misc/Makefile | 8 | ||||
-rw-r--r-- | test/misc/Makefile.in | 42 | ||||
-rw-r--r-- | test/misc/bug-glob1.c | 92 | ||||
-rw-r--r-- | test/misc/bug-glob2.c | 300 | ||||
-rw-r--r-- | test/misc/bug-readdir1.c | 37 | ||||
-rw-r--r-- | test/misc/dirent.c | 39 | ||||
-rw-r--r-- | test/misc/dirent64.c | 1 | ||||
-rw-r--r-- | test/misc/fdopen.c | 52 | ||||
-rw-r--r-- | test/misc/opendir-tst1.c | 95 | ||||
-rw-r--r-- | test/misc/outb.c | 9 | ||||
-rw-r--r-- | test/misc/popen.c | 47 | ||||
-rw-r--r-- | test/misc/seek.c | 82 | ||||
-rw-r--r-- | test/misc/sem.c | 45 | ||||
-rw-r--r-- | test/misc/stdarg.c | 23 | ||||
-rw-r--r-- | test/misc/tst-fnmatch.c | 443 | ||||
-rw-r--r-- | test/misc/tst-fnmatch.input | 754 | ||||
-rw-r--r-- | test/misc/tst-gnuglob.c | 446 | ||||
-rw-r--r-- | test/misc/tst-inotify.c | 65 | ||||
-rw-r--r-- | test/misc/tst-mkostemps.c | 159 | ||||
-rw-r--r-- | test/misc/tst-nftw.c | 57 | ||||
-rw-r--r-- | test/misc/tst-scandir.c | 23 | ||||
-rw-r--r-- | test/misc/tst-seekdir.c | 79 | ||||
-rw-r--r-- | test/misc/tst-statfs.c | 31 | ||||
-rw-r--r-- | test/misc/tst-statvfs.c | 26 | ||||
-rw-r--r-- | test/misc/tst-utmp.c | 423 | ||||
-rw-r--r-- | test/misc/tst-utmpx.c | 2 |
26 files changed, 0 insertions, 3380 deletions
diff --git a/test/misc/Makefile b/test/misc/Makefile deleted file mode 100644 index 09fa233a6..000000000 --- a/test/misc/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# uClibc misc tests -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - -top_builddir=../../ -top_srcdir=../../ -include ../Rules.mak --include Makefile.in -include ../Test.mak diff --git a/test/misc/Makefile.in b/test/misc/Makefile.in deleted file mode 100644 index 7d7bb1048..000000000 --- a/test/misc/Makefile.in +++ /dev/null @@ -1,42 +0,0 @@ -# uClibc misc tests -# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. - -TESTS_DISABLED := outb tst-fnmatch bug-glob1 tst-gnuglob - -ifeq ($(TARGET_avr32),y) -TESTS_DISABLED += tst-inotify -endif - -ifeq ($(UCLIBC_HAS_LFS),) -TESTS_DISABLED += dirent64 -TESTS_DISABLED += tst-statfs # assuming host has LFS on -endif -CFLAGS_dirent64 := -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 - -ifeq ($(UCLIBC_LINUX_SPECIFIC),) -TESTS_DISABLED += tst-inotify -endif - -ifeq ($(UCLIBC_HAS_GLOB),) -TESTS_DISABLED += bug-glob2 -endif - -ifeq ($(UCLIBC_HAS_UTMPX),) -TESTS_DISABLED += tst-utmpx -endif - -ifeq ($(UCLIBC_HAS_UTMP),) -TESTS_DISABLED += tst-utmp -endif - -DODIFF_dirent := 1 -DODIFF_dirent64 := 1 -DODIFF_tst-statfs := 1 -DODIFF_tst-statvfs := 1 - -OPTS_bug-glob1 := $(PWD) -OPTS_tst-fnmatch := < tst-fnmatch.input - -MNTENTS = / /sys /proc /dev -OPTS_tst-statfs := $(MNTENTS) -OPTS_tst-statvfs := $(MNTENTS) diff --git a/test/misc/bug-glob1.c b/test/misc/bug-glob1.c deleted file mode 100644 index 276983a0d..000000000 --- a/test/misc/bug-glob1.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Test case for globbing dangling symlink. By Ulrich Drepper. */ -#include <errno.h> -#include <error.h> -#include <glob.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - - -static void prepare (int argc, char *argv[]); -#define PREPARE prepare -static int do_test (void); -#define TEST_FUNCTION do_test () - -#include "../test-skeleton.c" - - -static char *fname; - -static void -prepare (int argc, char *argv[]) -{ - if (argc < 2) - error (EXIT_FAILURE, 0, "missing argument"); - - size_t len = strlen (argv[1]); - static const char ext[] = "globXXXXXX"; - fname = malloc (len + sizeof (ext)); - if (fname == NULL) - error (EXIT_FAILURE, errno, "cannot create temp file"); - again: - strcpy (stpcpy (fname, argv[1]), ext); - -/* fname = mktemp (fname); */ - close(mkstemp(fname)); - unlink(fname); - - if (fname == NULL || *fname == '\0') - error (EXIT_FAILURE, errno, "cannot create temp file name"); - if (symlink ("bug-glob1-does-not-exist", fname) != 0) - { - if (errno == EEXIST) - goto again; - - error (EXIT_FAILURE, errno, "cannot create symlink"); - } - add_temp_file (fname); -} - - -static int -do_test (void) -{ - glob_t gl; - int retval = 0; - int e; - - e = glob (fname, 0, NULL, &gl); - if (e == 0) - { - printf ("glob(\"%s\") succeeded when it should not have\n", fname); - retval = 1; - } - globfree (&gl); - - size_t fnamelen = strlen (fname); - char buf[fnamelen + 2]; - - strcpy (buf, fname); - buf[fnamelen - 1] = '?'; - e = glob (buf, 0, NULL, &gl); - if (e == 0) - { - printf ("glob(\"%s\") succeeded when it should not have\n", buf); - retval = 1; - } - globfree (&gl); - - strcpy (buf, fname); - buf[fnamelen] = '*'; - buf[fnamelen + 1] = '\0'; - e = glob (buf, 0, NULL, &gl); - if (e == 0) - { - printf ("glob(\"%s\") succeeded when it should not have\n", buf); - retval = 1; - } - globfree (&gl); - - return retval; -} diff --git a/test/misc/bug-glob2.c b/test/misc/bug-glob2.c deleted file mode 100644 index 069891b03..000000000 --- a/test/misc/bug-glob2.c +++ /dev/null @@ -1,300 +0,0 @@ -/* Test glob memory management. - for the filesystem access functions. - Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <dirent.h> -#include <glob.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <sys/stat.h> - -// #define DEBUG -#ifdef DEBUG -# define PRINTF(fmt, args...) \ - do \ - { \ - int save_errno = errno; \ - printf (fmt, ##args); \ - errno = save_errno; \ - } while (0) -#else -# define PRINTF(fmt, args...) -#endif - - -#ifdef GLOB_ALTDIRFUNC -static struct -{ - const char *name; - int level; - int type; - mode_t mode; -} filesystem[] = -{ - { ".", 1, DT_DIR, 0755 }, - { "..", 1, DT_DIR, 0755 }, - { "dir", 1, DT_DIR, 0755 }, - { ".", 2, DT_DIR, 0755 }, - { "..", 2, DT_DIR, 0755 }, - { "readable", 2, DT_DIR, 0755 }, - { ".", 3, DT_DIR, 0755 }, - { "..", 3, DT_DIR, 0755 }, - { "a", 3, DT_REG, 0644 }, - { "unreadable", 2, DT_DIR, 0111 }, - { ".", 3, DT_DIR, 0111 }, - { "..", 3, DT_DIR, 0755 }, - { "a", 3, DT_REG, 0644 }, - { "zz-readable", 2, DT_DIR, 0755 }, - { ".", 3, DT_DIR, 0755 }, - { "..", 3, DT_DIR, 0755 }, - { "a", 3, DT_REG, 0644 } -}; -#define nfiles (sizeof (filesystem) / sizeof (filesystem[0])) - - -typedef struct -{ - int level; - int idx; - struct dirent d; - char room_for_dirent[NAME_MAX]; -} my_DIR; - - -static long int -find_file (const char *s) -{ - int level = 1; - long int idx = 0; - - if (strcmp (s, ".") == 0) - return 0; - - if (s[0] == '.' && s[1] == '/') - s += 2; - - while (*s != '\0') - { - char *endp = strchrnul (s, '/'); - - PRINTF ("looking for %.*s, level %d\n", (int) (endp - s), s, level); - - while (idx < nfiles && filesystem[idx].level >= level) - { - if (filesystem[idx].level == level - && memcmp (s, filesystem[idx].name, endp - s) == 0 - && filesystem[idx].name[endp - s] == '\0') - break; - ++idx; - } - - if (idx == nfiles || filesystem[idx].level < level) - { - errno = ENOENT; - return -1; - } - - if (*endp == '\0') - return idx + 1; - - if (filesystem[idx].type != DT_DIR - && (idx + 1 >= nfiles - || filesystem[idx].level >= filesystem[idx + 1].level)) - { - errno = ENOTDIR; - return -1; - } - - ++idx; - - s = endp + 1; - ++level; - } - - errno = ENOENT; - return -1; -} - - -static void * -my_opendir (const char *s) -{ - long int idx = find_file (s); - my_DIR *dir; - - if (idx == -1) - { - PRINTF ("my_opendir(\"%s\") == NULL (%m)\n", s); - return NULL; - } - - if ((filesystem[idx].mode & 0400) == 0) - { - errno = EACCES; - PRINTF ("my_opendir(\"%s\") == NULL (%m)\n", s); - return NULL; - } - - dir = (my_DIR *) malloc (sizeof (my_DIR)); - if (dir == NULL) - { - printf ("cannot allocate directory handle: %m\n"); - exit (EXIT_FAILURE); - } - - dir->level = filesystem[idx].level; - dir->idx = idx; - - PRINTF ("my_opendir(\"%s\") == { level: %d, idx: %ld }\n", - s, filesystem[idx].level, idx); - - return dir; -} - - -static struct dirent * -my_readdir (void *gdir) -{ - my_DIR *dir = gdir; - - if (dir->idx == -1) - { - PRINTF ("my_readdir ({ level: %d, idx: %ld }) = NULL\n", - dir->level, (long int) dir->idx); - return NULL; - } - - while (dir->idx < nfiles && filesystem[dir->idx].level > dir->level) - ++dir->idx; - - if (dir->idx == nfiles || filesystem[dir->idx].level < dir->level) - { - dir->idx = -1; - PRINTF ("my_readdir ({ level: %d, idx: %ld }) = NULL\n", - dir->level, (long int) dir->idx); - return NULL; - } - - dir->d.d_ino = dir->idx; - -#ifdef _DIRENT_HAVE_D_TYPE - dir->d.d_type = filesystem[dir->idx].type; -#endif - - strcpy (dir->d.d_name, filesystem[dir->idx].name); - -#ifdef _DIRENT_HAVE_D_TYPE - PRINTF ("my_readdir ({ level: %d, idx: %ld }) = { d_ino: %ld, d_type: %d, d_name: \"%s\" }\n", - dir->level, (long int) dir->idx, dir->d.d_ino, dir->d.d_type, - dir->d.d_name); -#else - PRINTF ("my_readdir ({ level: %d, idx: %ld }) = { d_ino: %ld, d_name: \"%s\" }\n", - dir->level, (long int) dir->idx, dir->d.d_ino, - dir->d.d_name); -#endif - - ++dir->idx; - - return &dir->d; -} - - -static void -my_closedir (void *dir) -{ - PRINTF ("my_closedir ()\n"); - free (dir); -} - - -/* We use this function for lstat as well since we don't have any. */ -static int -my_stat (const char *name, struct stat *st) -{ - long int idx = find_file (name); - - if (idx == -1) - { - PRINTF ("my_stat (\"%s\", ...) = -1 (%m)\n", name); - return -1; - } - - memset (st, '\0', sizeof (*st)); - - if (filesystem[idx].type == DT_UNKNOWN) - st->st_mode = DTTOIF (idx + 1 < nfiles - && filesystem[idx].level < filesystem[idx + 1].level - ? DT_DIR : DT_REG) | filesystem[idx].mode; - else - st->st_mode = DTTOIF (filesystem[idx].type) | filesystem[idx].mode; - - PRINTF ("my_stat (\"%s\", { st_mode: %o }) = 0\n", name, st->st_mode); - - return 0; -} - - -static void -init_glob_altdirfuncs (glob_t *pglob) -{ - pglob->gl_closedir = my_closedir; - pglob->gl_readdir = my_readdir; - pglob->gl_opendir = my_opendir; - pglob->gl_lstat = my_stat; - pglob->gl_stat = my_stat; -} - - -static int -do_test (void) -{ - glob_t gl; - memset (&gl, 0, sizeof (gl)); - init_glob_altdirfuncs (&gl); - - if (glob ("dir/*able/*", GLOB_ERR | GLOB_ALTDIRFUNC, NULL, &gl) - != GLOB_ABORTED) - { - puts ("glob did not fail with GLOB_ABORTED"); - exit (EXIT_FAILURE); - } - - globfree (&gl); - - memset (&gl, 0, sizeof (gl)); - init_glob_altdirfuncs (&gl); - - gl.gl_offs = 3; - if (glob ("dir2/*", GLOB_DOOFFS, NULL, &gl) != GLOB_NOMATCH) - { - puts ("glob did not fail with GLOB_NOMATCH"); - exit (EXIT_FAILURE); - } - - globfree (&gl); - - return 0; -} -#else -static int do_test (void) { return 0; } -#endif - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" diff --git a/test/misc/bug-readdir1.c b/test/misc/bug-readdir1.c deleted file mode 100644 index a8594a82e..000000000 --- a/test/misc/bug-readdir1.c +++ /dev/null @@ -1,37 +0,0 @@ -#include <dirent.h> -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> - - -int -main (void) -{ - DIR *dirp; - struct dirent* ent; - - /* open a dir stream */ - dirp = opendir ("/tmp"); - if (dirp == NULL) - { - if (errno == ENOENT) - exit (0); - - perror ("opendir"); - exit (1); - } - - /* close the directory file descriptor, making it invalid */ - if (close (dirfd (dirp)) != 0) - { - puts ("could not close directory file descriptor"); - /* This is not an error. It is not guaranteed this is possible. */ - return 0; - } - - ent = readdir (dirp); - - return ent != NULL || errno != EBADF; -} diff --git a/test/misc/dirent.c b/test/misc/dirent.c deleted file mode 100644 index 491e3cf75..000000000 --- a/test/misc/dirent.c +++ /dev/null @@ -1,39 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <dirent.h> - -#define _DTIFY(DT) [DT] #DT -const char * const types[] = { - _DTIFY(DT_UNKNOWN), - _DTIFY(DT_FIFO), - _DTIFY(DT_CHR), - _DTIFY(DT_DIR), - _DTIFY(DT_BLK), - _DTIFY(DT_REG), - _DTIFY(DT_LNK), - _DTIFY(DT_SOCK), - _DTIFY(DT_WHT) -}; - -int main(int argc, char *argv[]) -{ - DIR *dirh; - struct dirent *de; - const char *mydir = (argc == 1 ? "/" : argv[1]); - - if ((dirh = opendir(mydir)) == NULL) { - perror("opendir"); - return 1; - } - - printf("readdir() says:\n"); - while ((de = readdir(dirh)) != NULL) - printf("\tdir entry %s: %s\n", types[de->d_type], de->d_name); - - closedir(dirh); - - return 0; -} diff --git a/test/misc/dirent64.c b/test/misc/dirent64.c deleted file mode 100644 index 26455ab68..000000000 --- a/test/misc/dirent64.c +++ /dev/null @@ -1 +0,0 @@ -#include "dirent.c" diff --git a/test/misc/fdopen.c b/test/misc/fdopen.c deleted file mode 100644 index 97e66de0a..000000000 --- a/test/misc/fdopen.c +++ /dev/null @@ -1,52 +0,0 @@ -/* Test for fdopen bugs. */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> - -#define assert(x) \ - if (!(x)) \ - { \ - fputs ("test failed: " #x "\n", stderr); \ - retval = 1; \ - goto the_end; \ - } - -int -main (int argc, char *argv[]) -{ - char name[256]; - FILE *fp = NULL; - int retval = 0; - int fd; - - /* hack to get a tempfile name w/out using tmpname() - * as that func causes a link time warning */ - sprintf(name, "%s-uClibc-test.XXXXXX", __FILE__); - fd = mkstemp(name); - close(fd); - - fp = fopen (name, "w"); - assert (fp != NULL) - assert (fputs ("foobar and baz", fp) > 0); - assert (fclose (fp) == 0); - fp = NULL; - - fd = open (name, O_RDWR|O_CREAT, 0660); - assert (fd != -1); - assert (lseek (fd, 5, SEEK_SET) == 5); - - fp = fdopen (fd, "a"); - assert (fp != NULL); - /* SuSv3 says that doing a fdopen() does not reset the file position, - * thus the '5' here is correct, not '14'. */ - assert (ftell (fp) == 5); - -the_end: - if (fp != NULL) - assert (fclose (fp) == 0); - unlink (name); - - return retval; -} diff --git a/test/misc/opendir-tst1.c b/test/misc/opendir-tst1.c deleted file mode 100644 index ffd785f80..000000000 --- a/test/misc/opendir-tst1.c +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright (C) 1998, 2000 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <dirent.h> -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <sys/stat.h> - -/* Name of the FIFO. */ -char tmpname[] = "fifoXXXXXX"; - - -/* Do the real work. */ -static int -real_test (void) -{ - DIR *dirp; - - /* This should not block for an FIFO. */ - dirp = opendir (tmpname); - - /* Successful. */ - if (dirp != NULL) - { - /* Oh, oh, how can this work? */ - fputs ("`opendir' succeeded on a FIFO???\n", stdout); - closedir (dirp); - return 1; - } - - if (errno != ENOTDIR) - { - fprintf (stdout, "`opendir' return error `%s' instead of `%s'\n", - strerror (errno), strerror (ENOTDIR)); - return 1; - } - - return 0; -} - - -static int -do_test (int argc, char *argv[]) -{ - int retval; - - retval = mkstemp(tmpname); - close(retval); - unlink(tmpname); - - /* Try to generate a FIFO. */ - if (mknod (tmpname, 0600 | S_IFIFO, 0) < 0) - { - perror ("mknod"); - /* We cannot make this an error. */ - return 0; - } - - retval = real_test (); - - remove (tmpname); - - return retval; -} - - -static void -do_cleanup (void) -{ - remove (tmpname); -} -#define CLEANUP_HANDLER do_cleanup () - - -/* Include the test skeleton. */ -#include "../test-skeleton.c" diff --git a/test/misc/outb.c b/test/misc/outb.c deleted file mode 100644 index bbe18eaec..000000000 --- a/test/misc/outb.c +++ /dev/null @@ -1,9 +0,0 @@ -#include <sys/io.h> - -int main(void) -{ - ioperm(0x340,0x342,1); - outb(0x340,0x0); - exit(0); -} - diff --git a/test/misc/popen.c b/test/misc/popen.c deleted file mode 100644 index 868b70eed..000000000 --- a/test/misc/popen.c +++ /dev/null @@ -1,47 +0,0 @@ -#include <unistd.h> -#include <stdio.h> -#include <errno.h> -#include <string.h> -#include <signal.h> - -#define TEST(r, f, x, m) ( \ -((r) = (f)) == (x) || \ -(printf(__FILE__ ":%d: %s failed (" m ")\n", __LINE__, #f, r, x), err++, 0) ) - -#define TEST_E(f) ( (errno = 0), (f) || \ -(printf(__FILE__ ":%d: %s failed (errno = %d)\n", __LINE__, #f, errno), err++, 0) ) - -#define TEST_S(s, x, m) ( \ -!strcmp((s),(x)) || \ -(printf(__FILE__ ":%d: [%s] != [%s] (%s)\n", __LINE__, s, x, m), err++, 0) ) - -static sig_atomic_t got_sig; - -static void handler(int sig) -{ - got_sig = 1; -} - -int main(void) -{ - int i; - char foo[6]; - char cmd[64]; - int err = 0; - FILE *f; - - TEST_E(f = popen("echo hello", "r")); - TEST_E(fgets(foo, sizeof foo, f)); - TEST_S(foo, "hello", "child process did not say hello"); - TEST(i, pclose(f), 0, "exit status %04x != %04x"); - - signal(SIGUSR1, handler); - snprintf(cmd, sizeof cmd, "read a ; test \"x$a\" = xhello && kill -USR1 %d", getpid()); - TEST_E(f = popen(cmd, "w")); - TEST_E(fputs("hello", f) >= 0); - TEST(i, pclose(f), 0, "exit status %04x != %04x"); - signal(SIGUSR1, SIG_DFL); - TEST(i, got_sig, 1, "child process did not send signal (%i!=%i)"); - - return err; -} diff --git a/test/misc/seek.c b/test/misc/seek.c deleted file mode 100644 index c5edb94c9..000000000 --- a/test/misc/seek.c +++ /dev/null @@ -1,82 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <assert.h> - -#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(*arr)) - -int main(void) -{ - struct { - off_t offset; - int whence; - } tests[] = { - { 0x00, SEEK_SET }, - { 0x01, SEEK_SET }, - { 0xFF, SEEK_SET } - }; - char buf[2000]; - off_t ret; - int i, fd; - FILE *fp; - int tmp; - - fd = open("lseek.out", O_RDWR|O_CREAT, 0600); - if (fd == -1) { - perror("open(lseek.out) failed"); - return 1; - } - unlink("lseek.out"); - fp = fdopen(fd, "rw"); - if (fp == NULL) { - perror("fopen(lseek.out) failed"); - return 1; - } - - memset(buf, 0xAB, sizeof(buf)); - ret = write(fd, buf, sizeof(buf)); - if (ret != sizeof(buf)) { - fprintf(stderr, "write() failed to write %zi bytes (wrote %li): ", sizeof(buf), (long)ret); - perror(""); - return 1; - } - - tmp = fseeko(fp, 1024, SEEK_SET); - assert(tmp == 0); - tmp = fseeko(fp, (off_t)-16, SEEK_CUR); - assert(tmp == 0); - ret = ftell(fp); - if (ret != (1024-16)) { - fprintf(stderr, "ftell() failed, we wanted pos %i but got %li: ", (1024-16), (long)ret); - perror(""); - return 1; - } - - for (i = 0; i < ARRAY_SIZE(tests); ++i) { - ret = lseek(fd, tests[i].offset, tests[i].whence); - if (ret != tests[i].offset) { - fprintf(stderr, "lseek(%li,%i) failed (wanted %li, got %li): ", (long)tests[i].offset, - tests[i].whence, (long)tests[i].offset, (long)ret); - perror(""); - return 1; - } - ret = fseek(fp, tests[i].offset, tests[i].whence); - if (ret != 0) { - fprintf(stderr, "fseek(%li,%i) failed (wanted 0, got %li): ", (long)tests[i].offset, - tests[i].whence, (long)ret); - perror(""); - return 1; - } - } - - fclose(fp); - close(fd); - - printf("Success!\n"); - - return 0; -} diff --git a/test/misc/sem.c b/test/misc/sem.c deleted file mode 100644 index 62a59b1e9..000000000 --- a/test/misc/sem.c +++ /dev/null @@ -1,45 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/ipc.h> -#include <sys/sem.h> - -int main(void) -{ - int k, r; - union semun { - int val; - struct semid_ds *buf; - unsigned short int *array; - struct seminfo *__buf; - } sd; - struct semid_ds sd_buf; - - k = semget(IPC_PRIVATE, 10, IPC_CREAT | 0666 ); - printf("semget(IPC_CREAT) = %d\n", k); - - if (k < 0) { - fprintf(stderr, "semget failed: %s\n", strerror(errno)); - return 1; - } - - sd.buf = &sd_buf; - r = semctl(k, 0, IPC_STAT, sd); - printf("semctl(k) = %d\n", r); - - if (r < 0) { - perror("semctl IPC_STAT failed"); - return 1; - } - - printf("sem_nsems = %lu\n", sd_buf.sem_nsems); - if (sd_buf.sem_nsems != 10) { - fprintf(stderr, "failed: incorrect sem_nsems!\n"); - return 1; - } - - printf("succeeded\n"); - - return 0; -} diff --git a/test/misc/stdarg.c b/test/misc/stdarg.c deleted file mode 100644 index 1566e0ce8..000000000 --- a/test/misc/stdarg.c +++ /dev/null @@ -1,23 +0,0 @@ -/* copied from rsync */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <stdarg.h> -static int foo(const char *format, ...) -{ - va_list ap; - size_t len; - char buf[5]; - - va_start(ap, format); - len = vsnprintf(0, 0, format, ap); - va_end(ap); - if (len != 5) return(1); - - if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) return(1); - - return(0); -} -int main(void) { return foo("hello"); } diff --git a/test/misc/tst-fnmatch.c b/test/misc/tst-fnmatch.c deleted file mode 100644 index e7d5324bb..000000000 --- a/test/misc/tst-fnmatch.c +++ /dev/null @@ -1,443 +0,0 @@ -/* Tests for fnmatch function. - Copyright (C) 2000, 2001 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <error.h> -#include <fnmatch.h> -#include <locale.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> -#include <sys/types.h> - - -static char *next_input (char **line, int first, int last); -static int convert_flags (const char *str); -static char *flag_output (int flags); -static char *escape (const char *str, size_t *reslenp, char **resbuf); - - -int str_isalpha(const char *str) -{ - size_t i = strlen(str); - while (i--) - if (isascii(str[i]) == 0) - return 0; - return 1; -} -int str_has_funk(const char *str, const char x) -{ - size_t i, max = strlen(str); - for (i=0; i+1<max; ++i) - if (str[i] == '[' && str[i+1] == x) - return 1; - return 0; -} - - -int -main (void) -{ - char *linebuf = NULL; - size_t linebuflen = 0; - int ntests = 0; - int nfailed = 0; - int nskipped = 0; - char *escinput = NULL; - size_t escinputlen = 0; - char *escpattern = NULL; - size_t escpatternlen = 0; - int nr = 0; - - /* Read lines from stdin with the following format: - - locale input-string match-string flags result - - where `result' is either 0 or 1. If the first character of a - string is '"' we read until the next '"' and handled escaped '"'. */ - while (! feof (stdin)) - { - ssize_t n = getline (&linebuf, &linebuflen, stdin); - char *cp; - const char *locale; - const char *input; - const char *pattern; - const char *result_str; - int result; - const char *flags; - int flags_val; - int fnmres; |