summaryrefslogtreecommitdiff
path: root/grp
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-06-08 14:43:39 +0000
committerUlrich Drepper <drepper@redhat.com>1999-06-08 14:43:39 +0000
commitf535dd028f68e65f56f999aedbd397c3d0eb4845 (patch)
tree4b02cd654c4d769b9f87e4e09d49ec78e2a49b6e /grp
parentf5508a15fd0d28806124e9b6e9fab6f99ac087a0 (diff)
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')
-rw-r--r--grp/Makefile23
-rw-r--r--grp/tst_fgetgrent.c44
-rw-r--r--grp/tst_fgetgrent.sh42
3 files changed, 89 insertions, 20 deletions
diff --git a/grp/Makefile b/grp/Makefile
index 5ca4953177..c4274ed531 100644
--- a/grp/Makefile
+++ b/grp/Makefile
@@ -22,11 +22,20 @@
subdir := grp
headers := grp.h
+distribute := tst_fgetgrent.c tst_fgetgrent.sh
+
routines := fgetgrent initgroups setgroups \
getgrent getgrgid getgrnam putgrent \
getgrent_r getgrgid_r getgrnam_r fgetgrent_r
-tests := testgrp tst_fgetgrent
+include ../Makeconfig
+
+tests := testgrp
+
+ifeq (yes,$(build-shared))
+test-srcs := tst_fgetgrent
+endif
+
include ../Rules
@@ -42,3 +51,15 @@ CFLAGS-getgrgid_r.c = -DUSE_NSCD=1
CFLAGS-getgrnam_r.c = -DUSE_NSCD=1
endif
+
+ifeq (no,$(cross-compiling))
+# tst_fgetgrent currently only works with shared libraries
+ifeq (yes,$(build-shared))
+.PHONY: do-tst-fgetgrent
+tests: do-tst-fgetgrent
+do-tst-fgetgrent: $(objpfx)tst_fgetgrent
+ $(SHELL) -e tst_fgetgrent.sh $(common-objpfx) $(elf-objpfx) \
+ $(rtld-installed-name)
+
+endif
+endif
diff --git a/grp/tst_fgetgrent.c b/grp/tst_fgetgrent.c
index e7cd0d92b5..a76eaab022 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);
}
diff --git a/grp/tst_fgetgrent.sh b/grp/tst_fgetgrent.sh
new file mode 100644
index 0000000000..f47de5df48
--- /dev/null
+++ b/grp/tst_fgetgrent.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 1999 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1999.
+#
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public License as
+# published by the Free Software Foundation; either version 2 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
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with the GNU C Library; see the file COPYING.LIB. If
+# not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+common_objpfx=$1; shift
+elf_objpfx=$1; shift
+rtld_installed_name=$1; shift
+
+testout=${common_objpfx}/grp/tst_fgetgrent.out
+library_path=${common_objpfx}
+
+result=0
+
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}grp/tst_fgetgrent 0 > ${testout} || result=1
+
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}grp/tst_fgetgrent 1 >> ${testout} || result=1
+
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}grp/tst_fgetgrent 2 >> ${testout} || result=1
+
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}grp/tst_fgetgrent 3 >> ${testout} || result=1
+
+exit $result