Browse Source

Add in a simple vfork test

Eric Andersen 23 years ago
parent
commit
18660a34b0
3 changed files with 85 additions and 1 deletions
  1. 2 0
      test/unistd/.cvsignore
  2. 23 1
      test/unistd/Makefile
  3. 60 0
      test/unistd/vfork.c

+ 2 - 0
test/unistd/.cvsignore

@@ -1,2 +1,4 @@
 fork
 fork_glibc
+vfork
+vfork_glibc

+ 23 - 1
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)
 

+ 60 - 0
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:
+*/