summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-09-21 05:25:52 +0000
committerEric Andersen <andersen@codepoet.org>2001-09-21 05:25:52 +0000
commit18660a34b0ec692fb54127131f9991be45e1bda8 (patch)
tree7ddff0df4082cfc2780342371adea5af5f9d02fe /test
parentaaaab475d7e67af362d4597c9d26553a0f80ae01 (diff)
Add in a simple vfork test
Diffstat (limited to 'test')
-rw-r--r--test/unistd/.cvsignore2
-rw-r--r--test/unistd/Makefile24
-rw-r--r--test/unistd/vfork.c60
3 files changed, 85 insertions, 1 deletions
diff --git a/test/unistd/.cvsignore b/test/unistd/.cvsignore
index 876aa8965..dad5c62bd 100644
--- a/test/unistd/.cvsignore
+++ b/test/unistd/.cvsignore
@@ -1,2 +1,4 @@
fork
fork_glibc
+vfork
+vfork_glibc
diff --git a/test/unistd/Makefile b/test/unistd/Makefile
index 49febf79a..faf716feb 100644
--- a/test/unistd/Makefile
+++ b/test/unistd/Makefile
@@ -3,7 +3,7 @@ include $(TESTDIR)/Rules.mak
-TARGETS=fork fork_glibc
+TARGETS=fork fork_glibc vfork vfork_glibc
all: $(TARGETS)
fork: fork.c ../testsuite.h Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(CC)
@@ -28,6 +28,28 @@ fork_glibc: fork.c ../testsuite.h Makefile
-./$@
-@ echo " "
+vfork: vfork.c ../testsuite.h 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 $@
+ ./$@
+ -@ echo " "
+
+vfork_glibc: vfork.c ../testsuite.h Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -./$@
+ -@ echo " "
+
clean:
rm -f *.[oa] *~ core $(TARGETS)
diff --git a/test/unistd/vfork.c b/test/unistd/vfork.c
new file mode 100644
index 000000000..73100e427
--- /dev/null
+++ b/test/unistd/vfork.c
@@ -0,0 +1,60 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * vfork test for uClibc
+ *
+ * Copyright (C) 1999,2000 by Lineo, inc. Written by Erik Andersen
+ * <andersen@lineo.com>, <andersee@debian.org>
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+int main(void)
+{
+ pid_t pid;
+ int status, wpid;
+
+ if ((pid = vfork()) == 0) {
+ printf("Hi. I'm the child process...\n");
+ execvp("/bin/ls",NULL);
+ _exit(0);
+ }
+
+ printf("Hello. I'm the parent process.\n");
+ while (1) {
+ wpid = wait(&status);
+ if (wpid > 0 && wpid != pid) {
+ continue;
+ }
+ if (wpid == pid)
+ break;
+ }
+
+ printf("Child process exited.\nGoodbye.\n");
+ return EXIT_SUCCESS;
+}
+
+/*
+Local Variables:
+c-file-style: "linux"
+c-basic-offset: 4
+tab-width: 4
+End:
+*/