OSDN Git Service

Add some additional pwd/grp tests, to prevent me from
authorEric Andersen <andersen@codepoet.org>
Sat, 1 Nov 2003 04:49:27 +0000 (04:49 -0000)
committerEric Andersen <andersen@codepoet.org>
Sat, 1 Nov 2003 04:49:27 +0000 (04:49 -0000)
breaking obvious things in the future.
 -Erik

test/pwd_grp/.cvsignore
test/pwd_grp/Makefile
test/pwd_grp/grcat.c [new file with mode: 0644]
test/pwd_grp/pwcat.c [new file with mode: 0644]

index 04680f5..208dd67 100644 (file)
@@ -8,4 +8,16 @@ test_pwd
 test_pwd.out
 test_pwd_glibc
 test_pwd_glibc.out
+pwcat
+pwcat.o
+pwcat.out
+pwcat_glibc
+pwcat_glibc.o
+pwcat_glibc.out
+grcat
+grcat.o
+grcat.out
+grcat_glibc
+grcat_glibc.o
+grcat_glibc.out
 
index f1f63b4..c424271 100644 (file)
@@ -22,7 +22,9 @@ include $(TESTDIR)/Rules.mak
 
 TARGETS=test_pwd test_pwd_glibc
 TARGETS+=test_grp test_grp_glibc
-TARGETS+=test_pwd_diff test_grp_diff
+TARGETS+=pwcat pwcat_glibc
+TARGETS+=grcat grcat_glibc
+TARGETS+=test_pwd_diff test_grp_diff pwcat_diff grcat_diff
 
 all: $(TARGETS)
 
@@ -70,6 +72,50 @@ test_grp_glibc: test_grp.c Makefile
        -./$@ 2>&1 >test_grp_glibc.out
        -@ echo " "
 
+pwcat: pwcat.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(CC)
+       -@ echo "-------"
+       -@ echo " "
+       -@ echo "Compiling vs uClibc: "
+       -@ echo " "
+       $(CC) $(CFLAGS) -c $< -o $@.o
+       $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+       $(STRIPTOOL) -x -R .note -R .comment $@
+       -./$@ 2>&1 >pwcat.out
+       -@ echo " "
+
+pwcat_glibc: pwcat.c Makefile
+       -@ echo "-------"
+       -@ echo " "
+       -@ echo "Compiling vs GNU libc: "
+       -@ echo " "
+       $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+       $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+       $(STRIPTOOL) -x -R .note -R .comment $@
+       -./$@ 2>&1 >pwcat_glibc.out
+       -@ echo " "
+
+grcat: grcat.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(CC)
+       -@ echo "-------"
+       -@ echo " "
+       -@ echo "Compiling vs uClibc: "
+       -@ echo " "
+       $(CC) $(CFLAGS) -c $< -o $@.o
+       $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+       $(STRIPTOOL) -x -R .note -R .comment $@
+       -./$@ 2>&1 >grcat.out
+       -@ echo " "
+
+grcat_glibc: grcat.c Makefile
+       -@ echo "-------"
+       -@ echo " "
+       -@ echo "Compiling vs GNU libc: "
+       -@ echo " "
+       $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o
+       $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@
+       $(STRIPTOOL) -x -R .note -R .comment $@
+       -./$@ 2>&1 >grcat_glibc.out
+       -@ echo " "
+
 test_pwd_diff: test_pwd_glibc test_pwd
        -@ echo "-------"
        -@ echo " "
@@ -86,6 +132,22 @@ test_grp_diff: test_grp_glibc test_grp
        -diff -u test_grp_glibc.out test_grp.out
        -@ echo " "
 
+pwcat_diff: pwcat_glibc pwcat
+       -@ echo "-------"
+       -@ echo " "
+       -@ echo "Diffing output: "
+       -@ echo " "
+       -diff -u pwcat_glibc.out pwcat.out
+       -@ echo " "
+
+grcat_diff: grcat_glibc grcat
+       -@ echo "-------"
+       -@ echo " "
+       -@ echo "Diffing output: "
+       -@ echo " "
+       -diff -u grcat_glibc.out grcat.out
+       -@ echo " "
+
 clean:
        $(RM) *.[oa] *~ core $(TARGETS) *.out
 
diff --git a/test/pwd_grp/grcat.c b/test/pwd_grp/grcat.c
new file mode 100644 (file)
index 0000000..8356714
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * grcat.c
+ *
+ * Generate a printable version of the group database
+ */
+/*
+ * Arnold Robbins, arnold@gnu.org, May 1993
+ * Public Domain
+ */
+
+/* For OS/2, do nothing. */
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined (STDC_HEADERS)
+#include <stdlib.h>
+#endif
+
+#ifndef HAVE_GETGRENT
+int main() { return 0; }
+#else
+#include <stdio.h>
+#include <grp.h>
+
+int
+main(argc, argv)
+int argc;
+char **argv;
+{
+    struct group *g;
+    int i;
+
+    while ((g = getgrent()) != NULL) {
+        printf("%s:%s:%ld:", g->gr_name, g->gr_passwd,
+                                     (long) g->gr_gid);
+        for (i = 0; g->gr_mem[i] != NULL; i++) {
+            printf("%s", g->gr_mem[i]);
+            if (g->gr_mem[i+1] != NULL)
+                putchar(',');
+        }
+        putchar('\n');
+    }
+    endgrent();
+    return 0;
+}
+#endif /* HAVE_GETGRENT */
diff --git a/test/pwd_grp/pwcat.c b/test/pwd_grp/pwcat.c
new file mode 100644 (file)
index 0000000..d6ad0b6
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * pwcat.c
+ *
+ * Generate a printable version of the password database
+ */
+/*
+ * Arnold Robbins, arnold@gnu.org, May 1993
+ * Public Domain
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <pwd.h>
+
+#if defined (STDC_HEADERS)
+#include <stdlib.h>
+#endif
+
+int
+main(argc, argv)
+int argc;
+char **argv;
+{
+    struct passwd *p;
+
+    while ((p = getpwent()) != NULL)
+        printf("%s:%s:%ld:%ld:%s:%s:%s\n",
+            p->pw_name, p->pw_passwd, (long) p->pw_uid,
+            (long) p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell);
+
+    endpwent();
+    return 0;
+}