summaryrefslogtreecommitdiff
path: root/test/pwd_grp
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-11-01 04:49:27 +0000
committerEric Andersen <andersen@codepoet.org>2003-11-01 04:49:27 +0000
commitd8fe0f7534a6b52549992238c061e4e7a5b319ab (patch)
tree94d9406e4d7d9db435322a46aa3976553b9474c9 /test/pwd_grp
parentfabd08e8543c01b41f277eb2eb9f731c7b424c36 (diff)
Add some additional pwd/grp tests, to prevent me from
breaking obvious things in the future. -Erik
Diffstat (limited to 'test/pwd_grp')
-rw-r--r--test/pwd_grp/.cvsignore12
-rw-r--r--test/pwd_grp/Makefile64
-rw-r--r--test/pwd_grp/grcat.c47
-rw-r--r--test/pwd_grp/pwcat.c36
4 files changed, 158 insertions, 1 deletions
diff --git a/test/pwd_grp/.cvsignore b/test/pwd_grp/.cvsignore
index 04680f55a..208dd67ee 100644
--- a/test/pwd_grp/.cvsignore
+++ b/test/pwd_grp/.cvsignore
@@ -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
diff --git a/test/pwd_grp/Makefile b/test/pwd_grp/Makefile
index f1f63b406..c4242715d 100644
--- a/test/pwd_grp/Makefile
+++ b/test/pwd_grp/Makefile
@@ -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
index 000000000..835671422
--- /dev/null
+++ b/test/pwd_grp/grcat.c
@@ -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
index 000000000..d6ad0b64b
--- /dev/null
+++ b/test/pwd_grp/pwcat.c
@@ -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;
+}