diff options
author | Ulrich Drepper <drepper@redhat.com> | 1999-06-08 14:43:39 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1999-06-08 14:43:39 +0000 |
commit | f535dd028f68e65f56f999aedbd397c3d0eb4845 (patch) | |
tree | 4b02cd654c4d769b9f87e4e09d49ec78e2a49b6e /grp/tst_fgetgrent.c | |
parent | f5508a15fd0d28806124e9b6e9fab6f99ac087a0 (diff) | |
download | glibc-f535dd028f68e65f56f999aedbd397c3d0eb4845.zip glibc-f535dd028f68e65f56f999aedbd397c3d0eb4845.tar.gz glibc-f535dd028f68e65f56f999aedbd397c3d0eb4845.tar.bz2 |
Update.
1999-06-08 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* grp/Makefile: Add rules for tst_fgetgrent.
* grp/tst_fgetgrent.c: Rewritten to read only one file.
* grp/tst_fgetgrent.sh: New file.
Diffstat (limited to 'grp/tst_fgetgrent.c')
-rw-r--r-- | grp/tst_fgetgrent.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/grp/tst_fgetgrent.c b/grp/tst_fgetgrent.c index e7cd0d9..a76eaab 100644 --- a/grp/tst_fgetgrent.c +++ b/grp/tst_fgetgrent.c @@ -19,6 +19,7 @@ #include <grp.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <sys/types.h> @@ -43,13 +44,13 @@ static void write_group (const char *filename, int pos) { FILE *f; - + f = fopen (filename, "w"); - fprintf (f, "one:x:0:one"); + fprintf (f, "one:x:1:one"); write_users (f, pos, 1); - fprintf (f, "two:x:1:two"); + fprintf (f, "two:x:2:two"); write_users (f, pos, 2); - fprintf (f, "three:x:2"); + fprintf (f, "three:x:3"); write_users (f, pos, 3); fclose (f); } @@ -63,7 +64,7 @@ test_entry (const char *name, gid_t gid, struct group *g) errors++; return; } - + if ((g->gr_gid == gid) && (strcmp (g->gr_name, name) == 0)) printf ("Ok: %s: %d\n", g->gr_name, g->gr_gid); else @@ -81,31 +82,36 @@ test_fgetgrent (const char *filename) struct group *g; FILE *f; - f = fopen (filename, "r"); + f = fopen (filename,"r"); g = fgetgrent (f); - test_entry ("one", 0, g); + test_entry ("one", 1, g); g = fgetgrent (f); - test_entry ("two", 1, g); + test_entry ("two", 2, g); g = fgetgrent (f); - test_entry ("three", 2, g); + test_entry ("three", 3, g); fclose (f); } - + int -main (void) +main (int argc, char *argv[]) { char *file = tmpnam (NULL); - int i; + int i = 0; + + if (argc > 1) + i = atoi (argv[1]); + if (i > 3) + i = 3; + if (i) + printf ("Large group is group: %d\n", i); + else + printf ("Not using a large group\n"); + write_group (file, i); + test_fgetgrent (file); - for (i = 0; i < 4; i++) - { - printf ("Pass %d\n", i); - write_group (file, i); - test_fgetgrent (file); - } remove (file); - + return (errors != 0); } |