Applied fixes by Paul J.Y. Lahaie to implement support for UCLinux
diff --git a/Makefile b/Makefile
index 09d5fb2..931d9c2 100644
--- a/Makefile
+++ b/Makefile
@@ -45,6 +45,23 @@
libltp.a:
@$(MAKE) -C lib $@
+uclinux: uclinux_libltp.a
+ #@$(MAKE) -C pan all
+ @$(MAKE) -C testcases uclinux
+ @$(MAKE) -C tools all
+ @echo
+ @echo "*******************************************************"
+ @echo "** You now need to do a make uclinux_install as root **"
+ @echo "*******************************************************"
+
+uclinux_install: uclinux
+ @$(MAKE) -C testcases uclinux_install
+ @$(MAKE) -C tools install
+ @./IDcheck.sh
+
+uclinux_libltp.a:
+ @$(MAKE) -C lib UCLINUX=1 libltp.a
+
menuconfig:
@./ltpmenu
diff --git a/include/test.h b/include/test.h
index 378b279..ba4b998 100644
--- a/include/test.h
+++ b/include/test.h
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*/
-/* $Id: test.h,v 1.8 2005/01/17 22:10:09 robbiew Exp $ */
+/* $Id: test.h,v 1.9 2005/07/11 22:28:09 robbiew Exp $ */
#ifndef __TEST_H__
#define __TEST_H__
@@ -189,6 +189,21 @@
#define USC_LOOP_DELAY "USC_LOOP_DELAY"
/*
+ * fork() can't be used on uClinux systems, so use FORK_OR_VFORK instead,
+ * which will run vfork() on uClinux.
+ * mmap() doesn't support MAP_PRIVATE on uClinux systems, so use
+ * MAP_PRIVATE_EXCEPT_UCLINUX instead, which will skip the option on uClinux.
+ * If MAP_PRIVATE really is required, the test can not be run on uClinux.
+ */
+#ifdef UCLINUX
+#define FORK_OR_VFORK vfork
+#define MAP_PRIVATE_EXCEPT_UCLINUX 0
+#else
+#define FORK_OR_VFORK fork
+#define MAP_PRIVATE_EXCEPT_UCLINUX MAP_PRIVATE
+#endif
+
+/*
* The following prototypes are needed to remove compile errors
* on IRIX systems when compiled with -n32 and -64.
*/
@@ -223,4 +238,8 @@
extern int tst_is_cwd_tmpfs();
extern int tst_cwd_has_free(int required_kib);
+/* self_exec.c functions */
+void maybe_run_child(void (*child)(), char *fmt, ...);
+int self_exec(char *argv0, char *fmt, ...);
+
#endif /* end of __TEST_H__ */
diff --git a/lib/Makefile b/lib/Makefile
index 818463f..ea21544 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -9,6 +9,7 @@
ifeq ($(shell uname -s),HP-UX)
CFLAGS+=-Ae -D_LARGEFILE64_SOURCE +DA1.1
endif
+CFLAGS+=$(if $(UCLINUX),-DUCLINUX)
LDFLAGS+=
TARGET=libltp.a
SRCS=$(wildcard *.c)
diff --git a/lib/parse_opts.c b/lib/parse_opts.c
index d0aef06..3a00584 100644
--- a/lib/parse_opts.c
+++ b/lib/parse_opts.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*/
-/* $Id: parse_opts.c,v 1.7 2005/01/04 21:00:29 mridge Exp $ */
+/* $Id: parse_opts.c,v 1.8 2005/07/11 22:28:09 robbiew Exp $ */
/**********************************************************
*
@@ -154,6 +154,10 @@
{ "p" , " -p Pause for SIGUSR1 before starting\n", NULL, NULL},
{ "P:", " -P x Pause for x seconds between iterations\n", NULL, NULL},
{ "t" , " -t Turn on syscall timing\n", NULL, NULL},
+#ifdef UCLINUX
+ { "C:", " -C ARG Run the child process with arguments ARG (for internal use)\n",
+ NULL, NULL},
+#endif
{NULL, NULL, NULL, NULL}};
void print_help(void (*user_help)());
@@ -189,6 +193,10 @@
#define OPT_delay 010
#define OPT_copies 020
+#ifdef UCLINUX
+/* Allocated and used in self_exec.c: */
+extern char *child_args; /* Arguments to child when -C is used */
+#endif
/**********************************************************************
* parse_opts:
@@ -297,6 +305,11 @@
print_help(uhf);
exit(0);
break;
+#ifdef UCLINUX
+ case 'C': /* Run child */
+ child_args = optarg;
+ break;
+#endif
default:
/* Check all the user specified options */
@@ -494,6 +507,7 @@
}
}
+#if !defined(UCLINUX)
if ( (ptr=getenv("USC_LP_SBRK")) != NULL ) {
if ( sscanf(ptr, "%i", &k) == 1 && k >= 0 ) {
STD_LP_sbrk=k;
@@ -502,6 +516,7 @@
STD_LP_sbrk);
}
}
+#endif /* if !defined(UCLINUX) */
if ( (ptr=getenv("USC_LP_RECFUN")) != NULL ) {
if ( sscanf(ptr, "%i", &k) == 1 && k >= 0 ) {
@@ -586,6 +601,7 @@
int
usc_global_setup_hook()
{
+#ifndef UCLINUX
int cnt;
/* temp variable to store old signal action to be restored after pause */
int (*_TMP_FUNC)(void);
@@ -617,6 +633,7 @@
signal(SIGUSR1, (void (*)())_TMP_FUNC);
}
+#if !defined(UCLINUX)
if ( STD_TP_sbrk || STD_LP_sbrk) {
STD_start_break=sbrk(0); /* get original sbreak size */
@@ -627,6 +644,9 @@
if ( Debug )
printf("after sbrk(%d)\n", STD_TP_sbrk);
}
+
+#endif /* if !defined(UCLINUX) */
+#endif
return 0;
}
@@ -766,11 +786,14 @@
usc_recressive_func(0, STD_LP_recfun, &STD_bigstack);
}
+#if !defined(UCLINUX)
+
if ( STD_LP_sbrk ) {
if ( Debug )
printf("about to do sbrk(%d)\n", STD_LP_sbrk);
sbrk(STD_LP_sbrk);
}
+#endif
if ( keepgoing )
diff --git a/lib/tlibio.c b/lib/tlibio.c
index db5a776..7a507b0 100644
--- a/lib/tlibio.c
+++ b/lib/tlibio.c
@@ -100,8 +100,10 @@
#include <string.h> /* bzero */
#endif
#if defined(linux) || defined(__sun) || defined(__hpux) || defined(_AIX)
+#ifndef UCLINUX
#include <aio.h>
#endif
+#endif
#include <stdlib.h> /* atoi, abs */
#include "tlibio.h" /* defines LIO* marcos */
diff --git a/lib/tst_res.c b/lib/tst_res.c
index 1c9534c..ab2bf6d 100644
--- a/lib/tst_res.c
+++ b/lib/tst_res.c
@@ -31,7 +31,7 @@
*/
-/* $Id: tst_res.c,v 1.1 2000/07/27 17:13:19 alaffin Exp $ */
+/* $Id: tst_res.c,v 1.2 2005/07/11 22:28:09 robbiew Exp $ */
/**********************************************************
*
@@ -567,7 +567,11 @@
int
tst_environ()
{
+#if defined UCLINUX && EMBED
+ FILE *fdopen;
+#else
FILE *fdopen();
+#endif
if ( (T_out = fdopen(dup(fileno(stdout)), "w")) == NULL )
return(-1);
diff --git a/testcases/Makefile b/testcases/Makefile
index 65bf7e8..b361e45 100644
--- a/testcases/Makefile
+++ b/testcases/Makefile
@@ -1,4 +1,5 @@
SUBDIRS = `ls */Makefile | sed "s/Makefile//g" | grep -v open`
+UCLINUX_SUBDIRS = kernel
all:
@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
@@ -7,6 +8,14 @@
mkdir -p bin
@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+uclinux:
+ @set -e; for i in $(UCLINUX_SUBDIRS); do $(MAKE) -C $$i uclinux; done
+
+uclinux_install:
+ mkdir -p bin
+ @set -e; for i in $(UCLINUX_SUBDIRS); \
+ do $(MAKE) -C $$i uclinux_install ; done
+
clean:
rm -rf bin/
@set -e; for i in $(SUBDIRS) ; do $(MAKE) -C $$i clean ; done
diff --git a/testcases/kernel/Makefile b/testcases/kernel/Makefile
index 3cb61db..7859f49 100644
--- a/testcases/kernel/Makefile
+++ b/testcases/kernel/Makefile
@@ -1,4 +1,5 @@
SUBDIRS = fs io ipc mem pty sched syscalls
+UCLINUX_SUBDIRS = syscalls
all:
@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i ; done
@@ -6,6 +7,12 @@
install:
@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i install ; done
+uclinux:
+ @set -e; for i in $(UCLINUX_SUBDIRS); do $(MAKE) -C $$i uclinux ; done
+
+uclinux_install:
+ @set -e; for i in $(UCLINUX_SUBDIRS); do $(MAKE) -C $$i uclinux_install ; done
+
clean:
@set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done
diff --git a/testcases/kernel/syscalls/Makefile b/testcases/kernel/syscalls/Makefile
index c4e01e3..c53d208 100644
--- a/testcases/kernel/syscalls/Makefile
+++ b/testcases/kernel/syscalls/Makefile
@@ -26,12 +26,15 @@
DEBUG_CFLAGS=-O
DEBUG_LDFLAGS=-s
CFLAGS+=-I../../include -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+=
+LOADLIBES+= $(if $(UCLINUX),-lc)
EXCLUDE_DIR=epoll
#
# Commented this out since there are directories here we don't want built by default
#
SUBDIR = `ls */Makefile | sed "s/Makefile//g" | grep -v epoll`
+UCLINUX_SUBDIR = `ls */Makefile | sed "s/Makefile//g" | grep -vE "^fork|epoll|capget|capset|chmod|chown|llseek|nftw|clone|profil"`
all:
@set -e; for i in lib $(SUBDIR); do \
@@ -43,6 +46,16 @@
$(MAKE) -C $$i install; \
done
+uclinux:
+ @set -e; for i in lib $(UCLINUX_SUBDIR); do \
+ $(MAKE) -C $$i UCLINUX=1 all; \
+ done
+
+uclinux_install:
+ @set -e; for i in lib $(UCLINUX_SUBDIR); do \
+ $(MAKE) -C $$i UCLINUX=1 all; \
+ done
+
clean:
@set -e; for i in lib $(SUBDIR); do \
$(MAKE) -C $$i clean; \
diff --git a/testcases/kernel/syscalls/abort/Makefile b/testcases/kernel/syscalls/abort/Makefile
index d1eaf54..7b07ae3 100644
--- a/testcases/kernel/syscalls/abort/Makefile
+++ b/testcases/kernel/syscalls/abort/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/abort/abort01.c b/testcases/kernel/syscalls/abort/abort01.c
index 73249e1..ecd5a74 100644
--- a/testcases/kernel/syscalls/abort/abort01.c
+++ b/testcases/kernel/syscalls/abort/abort01.c
@@ -71,6 +71,7 @@
void fail_exit();
void ok_exit();
int forkfail();
+void do_child();
/***** ** ** *****/
@@ -80,16 +81,32 @@
register int i;
int status, count, child, kidpid;
int core, sig, ex;
+ char *msg;
+
+ if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) != (char *)NULL){
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ }
+
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "");
+#endif
setup(); /* temp file is now open */
/*--------------------------------------------------------------*/
for (i=0; i < ITER; i++) {
- if ((kidpid = fork()) == 0) {
- abort();
- fprintf(temp, "\tchild - abort failed.\n");
- exit(0);
+ if ((kidpid = FORK_OR_VFORK()) == 0) {
+#ifdef UCLINUX
+ if (self_exec(argv[0], "")) {
+ terror("self_exec failed (may be OK if under stress)");
+ if (instress())
+ ok_exit();
+ forkfail();
+ }
+#else
+ do_child();
+#endif
}
if (kidpid < 0) {
terror("Fork failed (may be OK if under stress)");
@@ -148,6 +165,12 @@
}
/*--------------------------------------------------------------*/
+void do_child() {
+ abort();
+ fprintf(temp, "\tchild - abort failed.\n");
+ exit(0);
+}
+
/****** LTP Port *****/
int anyfail()
{
diff --git a/testcases/kernel/syscalls/accept/Makefile b/testcases/kernel/syscalls/accept/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/accept/Makefile
+++ b/testcases/kernel/syscalls/accept/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/access/Makefile b/testcases/kernel/syscalls/access/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/access/Makefile
+++ b/testcases/kernel/syscalls/access/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/access/access03.c b/testcases/kernel/syscalls/access/access03.c
index 0a3edea..1cad659 100644
--- a/testcases/kernel/syscalls/access/access03.c
+++ b/testcases/kernel/syscalls/access/access03.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: access03.c,v 1.2 2002/07/23 13:11:18 plars Exp $ */
+/* $Id: access03.c,v 1.3 2005/07/11 22:28:11 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -122,6 +122,8 @@
char * bad_addr = 0;
+#if !defined(UCLINUX)
+
int main(int ac, char **av)
{
int lc; /* loop counter */
@@ -473,6 +475,16 @@
return 0;
} /* End main */
+#else
+
+int main()
+{
+ tst_resm(TINFO,"access03 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
+
/***************************************************************
* setup() - performs all ONE TIME setup for this test.
***************************************************************/
@@ -488,7 +500,8 @@
/* make and change to a temporary directory */
tst_tmpdir();
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS,
+ 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/access/access05.c b/testcases/kernel/syscalls/access/access05.c
index b540f19..291ba24 100644
--- a/testcases/kernel/syscalls/access/access05.c
+++ b/testcases/kernel/syscalls/access/access05.c
@@ -105,10 +105,12 @@
int setup4(); /* setup() to test access() for EINVAL */
int longpath_setup(); /* setup function to test access() for ENAMETOOLONG */
+#if !defined(UCLINUX)
char *get_high_address(); /* function from ltp-lib */
+char High_address_node[64];
+#endif
char Longpathname[PATH_MAX+2];
-char High_address_node[64];
struct test_case_t { /* test case structure */
char *pathname;
@@ -121,7 +123,9 @@
{ TEST_FILE2, W_OK, "Write Access denied on file", EACCES, setup2 },
{ TEST_FILE3, X_OK, "Execute Access denied on file", EACCES, setup3 },
{ TEST_FILE4, INV_OK, "Access mode invalid", EINVAL, setup4 },
+#if !defined(UCLINUX)
{ High_address_node, R_OK, "Address beyond address space", EFAULT, no_setup },
+#endif
{ (char *)-1, R_OK, "Negative address", EFAULT, no_setup },
{ "", W_OK, "Pathname is empty", ENOENT, no_setup },
{ Longpathname, R_OK, "Pathname too long", ENAMETOOLONG, longpath_setup },
@@ -174,9 +178,11 @@
access_mode = Test_cases[ind].a_mode;
test_desc = Test_cases[ind].desc;
+#if !defined(UCLINUX)
if (file_name == High_address_node) {
file_name = get_high_address();
}
+#endif
/*
* Call access(2) to test different test conditions.
@@ -249,7 +255,8 @@
/* make a temp directory and cd to it */
tst_tmpdir();
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX| MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/acct/Makefile b/testcases/kernel/syscalls/acct/Makefile
index 3eae260..ec20258 100644
--- a/testcases/kernel/syscalls/acct/Makefile
+++ b/testcases/kernel/syscalls/acct/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/adjtimex/Makefile b/testcases/kernel/syscalls/adjtimex/Makefile
index 6729e34..0db7aa7 100644
--- a/testcases/kernel/syscalls/adjtimex/Makefile
+++ b/testcases/kernel/syscalls/adjtimex/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/adjtimex/adjtimex01.c b/testcases/kernel/syscalls/adjtimex/adjtimex01.c
index 7f5ba4b..ff18bd4 100644
--- a/testcases/kernel/syscalls/adjtimex/adjtimex01.c
+++ b/testcases/kernel/syscalls/adjtimex/adjtimex01.c
@@ -64,6 +64,11 @@
*
****************************************************************/
+#if defined UCLINUX && !__THROW
+/* workaround for libc bug causing failure in sys/timex.h */
+#define __THROW
+#endif
+
#include <errno.h>
#include <sys/timex.h>
#include "test.h"
diff --git a/testcases/kernel/syscalls/adjtimex/adjtimex02.c b/testcases/kernel/syscalls/adjtimex/adjtimex02.c
index ea95ad8..1a9e2ef 100644
--- a/testcases/kernel/syscalls/adjtimex/adjtimex02.c
+++ b/testcases/kernel/syscalls/adjtimex/adjtimex02.c
@@ -77,6 +77,11 @@
*
****************************************************************/
+#if defined UCLINUX && !__THROW
+/* workaround for libc bug causing failure in sys/timex.h */
+#define __THROW
+#endif
+
#include <errno.h>
#include <sys/timex.h>
#include <pwd.h>
diff --git a/testcases/kernel/syscalls/alarm/Makefile b/testcases/kernel/syscalls/alarm/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/alarm/Makefile
+++ b/testcases/kernel/syscalls/alarm/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/alarm/alarm03.c b/testcases/kernel/syscalls/alarm/alarm03.c
index 78c523e..8791098 100644
--- a/testcases/kernel/syscalls/alarm/alarm03.c
+++ b/testcases/kernel/syscalls/alarm/alarm03.c
@@ -29,7 +29,7 @@
*
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*/
-/* $Id: alarm03.c,v 1.5 2003/08/25 15:13:13 plars Exp $ */
+/* $Id: alarm03.c,v 1.6 2005/07/11 22:28:11 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -141,7 +141,7 @@
*/
TEST(alarm(100));
- switch ( fork()) {
+ switch ( FORK_OR_VFORK()) {
case -1:
tst_brkm(TBROK, cleanup, "fork failed, errno:%d %s",
errno, strerror(errno));
diff --git a/testcases/kernel/syscalls/alarm/alarm07.c b/testcases/kernel/syscalls/alarm/alarm07.c
index 27efe14..af0950e 100644
--- a/testcases/kernel/syscalls/alarm/alarm07.c
+++ b/testcases/kernel/syscalls/alarm/alarm07.c
@@ -112,7 +112,7 @@
TEST(alarm(time_sec));
/* Now, fork a child process */
- cpid = fork();
+ cpid = FORK_OR_VFORK();
if (cpid < 0) {
tst_resm(TFAIL, "fork() fails to create child, "
"errno:%d", errno);
diff --git a/testcases/kernel/syscalls/asyncio/Makefile b/testcases/kernel/syscalls/asyncio/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/asyncio/Makefile
+++ b/testcases/kernel/syscalls/asyncio/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/bind/Makefile b/testcases/kernel/syscalls/bind/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/bind/Makefile
+++ b/testcases/kernel/syscalls/bind/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/brk/Makefile b/testcases/kernel/syscalls/brk/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/brk/Makefile
+++ b/testcases/kernel/syscalls/brk/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/brk/brk01.c b/testcases/kernel/syscalls/brk/brk01.c
index 55185ef..cdaca21 100644
--- a/testcases/kernel/syscalls/brk/brk01.c
+++ b/testcases/kernel/syscalls/brk/brk01.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: brk01.c,v 1.1 2001/08/27 22:15:12 plars Exp $ */
+/* $Id: brk01.c,v 1.2 2005/07/11 22:28:12 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -127,6 +127,9 @@
/***********************************************************************
* MAIN
***********************************************************************/
+
+#if !defined(UCLINUX)
+
int
main(int ac, char **av)
{
@@ -324,6 +327,16 @@
} /* End setup() */
+#else
+
+int main()
+{
+ tst_resm(TINFO,"brk01 test is not available on UCLINUX");
+ return 0;
+}
+
+
+#endif /* if !defined(UCLINUX) */
/***************************************************************
* cleanup() - performs all ONE TIME cleanup for this test at
diff --git a/testcases/kernel/syscalls/capget/Makefile b/testcases/kernel/syscalls/capget/Makefile
index d1eaf54..7b07ae3 100644
--- a/testcases/kernel/syscalls/capget/Makefile
+++ b/testcases/kernel/syscalls/capget/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/capset/Makefile b/testcases/kernel/syscalls/capset/Makefile
index d1eaf54..7b07ae3 100644
--- a/testcases/kernel/syscalls/capset/Makefile
+++ b/testcases/kernel/syscalls/capset/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/capset/capset02.c b/testcases/kernel/syscalls/capset/capset02.c
index 3c7cd47..4524dee 100644
--- a/testcases/kernel/syscalls/capset/capset02.c
+++ b/testcases/kernel/syscalls/capset/capset02.c
@@ -100,7 +100,8 @@
static void setup();
static void cleanup();
-static void test_setup(int);
+static void test_setup(int, char *);
+static void child_func();
static pid_t child_pid = -1;
@@ -138,6 +139,10 @@
tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&child_func, "");
+#endif
+
/* perform global setup for test */
setup();
@@ -149,7 +154,7 @@
for (i = 0; i < TST_TOTAL; ++i) {
- test_setup(i);
+ test_setup(i, av[0]);
TEST(capset(test_cases[i].headerp,
test_cases[i].datap));
@@ -226,7 +231,7 @@
}
void
-test_setup(int i)
+test_setup(int i, char *argv0)
{
switch (i) {
@@ -255,14 +260,22 @@
* Note: this seems to have changed with recent kernels
* => create a child and try to set its capabilities
*/
- child_pid = fork();
+ child_pid = FORK_OR_VFORK();
switch(child_pid) {
case -1:
tst_resm(TBROK,"fork() failed: %s\n",strerror(errno));
cleanup();
break;
case 0:
+#ifdef UCLINUX
+ if (self_exec(argv0, "") < 0) {
+ tst_resm(TBROK,"self_exec() failed\n");
+ cleanup();
+ break;
+ }
+#else
child_func();
+#endif
break;
default:
signal(SIGCHLD,SIG_IGN);
diff --git a/testcases/kernel/syscalls/chdir/Makefile b/testcases/kernel/syscalls/chdir/Makefile
index 446354e..ce7ee6d 100644
--- a/testcases/kernel/syscalls/chdir/Makefile
+++ b/testcases/kernel/syscalls/chdir/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp -L.. -ltestsuite
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/chdir/chdir03.c b/testcases/kernel/syscalls/chdir/chdir03.c
index c973c25..6fa514c 100644
--- a/testcases/kernel/syscalls/chdir/chdir03.c
+++ b/testcases/kernel/syscalls/chdir/chdir03.c
@@ -101,7 +101,7 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
tst_brkm(TBROK, cleanup, "first fork failed");
}
@@ -119,7 +119,7 @@
}
wait(&status);
- if ((pid1 = fork()) < 0) {
+ if ((pid1 = FORK_OR_VFORK()) < 0) {
tst_brkm(TBROK, cleanup, "second fork failed");
}
diff --git a/testcases/kernel/syscalls/chdir/chdir04.c b/testcases/kernel/syscalls/chdir/chdir04.c
index 6da6236..c502fd8 100644
--- a/testcases/kernel/syscalls/chdir/chdir04.c
+++ b/testcases/kernel/syscalls/chdir/chdir04.c
@@ -168,7 +168,8 @@
/* make a temporary directory and cd to it */
tst_tmpdir();
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/chmod/Makefile b/testcases/kernel/syscalls/chmod/Makefile
index f5ca296..1464edf 100644
--- a/testcases/kernel/syscalls/chmod/Makefile
+++ b/testcases/kernel/syscalls/chmod/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -D_GNU_SOURCE
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LDLIBS+= -L../../../../lib -lltp
+LDLIBS+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard chmod*.c) change_owner.c
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/chmod/chmod06.c b/testcases/kernel/syscalls/chmod/chmod06.c
index 15cac64..95e91bb 100644
--- a/testcases/kernel/syscalls/chmod/chmod06.c
+++ b/testcases/kernel/syscalls/chmod/chmod06.c
@@ -262,7 +262,8 @@
/* Make a temp dir and cd to it */
tst_tmpdir();
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/chown/Makefile b/testcases/kernel/syscalls/chown/Makefile
index 927cd8f..2e31cd2 100644
--- a/testcases/kernel/syscalls/chown/Makefile
+++ b/testcases/kernel/syscalls/chown/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -Wall -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LDLIBS+= -L../../../../lib -lltp
+LDLIBS+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard chown*.c) change_owner.c
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/chown/chown04.c b/testcases/kernel/syscalls/chown/chown04.c
index 2968003..95ae279 100644
--- a/testcases/kernel/syscalls/chown/chown04.c
+++ b/testcases/kernel/syscalls/chown/chown04.c
@@ -263,7 +263,8 @@
/* Make a temp dir and cd to it */
tst_tmpdir();
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/chroot/Makefile b/testcases/kernel/syscalls/chroot/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/chroot/Makefile
+++ b/testcases/kernel/syscalls/chroot/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/chroot/chroot02.c b/testcases/kernel/syscalls/chroot/chroot02.c
index f8b54de..bccb322 100644
--- a/testcases/kernel/syscalls/chroot/chroot02.c
+++ b/testcases/kernel/syscalls/chroot/chroot02.c
@@ -85,7 +85,7 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "Could not fork");
}
diff --git a/testcases/kernel/syscalls/chroot/chroot03.c b/testcases/kernel/syscalls/chroot/chroot03.c
index ceef5d1..5f721e0 100644
--- a/testcases/kernel/syscalls/chroot/chroot03.c
+++ b/testcases/kernel/syscalls/chroot/chroot03.c
@@ -193,7 +193,8 @@
*/
(void)sprintf(good_dir, "%s.%d", good_dir, getpid());
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/clone/Makefile b/testcases/kernel/syscalls/clone/Makefile
index 7c7d51a..ed17c1b 100644
--- a/testcases/kernel/syscalls/clone/Makefile
+++ b/testcases/kernel/syscalls/clone/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/clone/clone01.c b/testcases/kernel/syscalls/clone/clone01.c
index 5a136aa..6c394cf 100644
--- a/testcases/kernel/syscalls/clone/clone01.c
+++ b/testcases/kernel/syscalls/clone/clone01.c
@@ -69,6 +69,11 @@
*
****************************************************************/
+#if defined UCLINUX && !__THROW
+/* workaround for libc bug */
+#define __THROW
+#endif
+
#include <errno.h>
#include <sched.h>
#include <sys/wait.h>
diff --git a/testcases/kernel/syscalls/clone/clone02.c b/testcases/kernel/syscalls/clone/clone02.c
index 61fe91d..296df26 100644
--- a/testcases/kernel/syscalls/clone/clone02.c
+++ b/testcases/kernel/syscalls/clone/clone02.c
@@ -91,6 +91,11 @@
*
****************************************************************/
+#if defined UCLINUX && !__THROW
+/* workaround for libc bug */
+#define __THROW
+#endif
+
#include <errno.h>
#include <sched.h>
#include <fcntl.h>
diff --git a/testcases/kernel/syscalls/clone/clone03.c b/testcases/kernel/syscalls/clone/clone03.c
index 2b4079a..cfe4d6b 100644
--- a/testcases/kernel/syscalls/clone/clone03.c
+++ b/testcases/kernel/syscalls/clone/clone03.c
@@ -67,6 +67,11 @@
*
****************************************************************/
+#if defined UCLINUX && !__THROW
+/* workaround for libc bug */
+#define __THROW
+#endif
+
#include <errno.h>
#include <sched.h>
#include "test.h"
diff --git a/testcases/kernel/syscalls/clone/clone04.c b/testcases/kernel/syscalls/clone/clone04.c
index 9d29c46..b5cdc6c 100644
--- a/testcases/kernel/syscalls/clone/clone04.c
+++ b/testcases/kernel/syscalls/clone/clone04.c
@@ -65,6 +65,12 @@
* -t : Turn on syscall timing.
*
*********************************************************************/
+
+#if defined UCLINUX && !__THROW
+/* workaround for libc bug */
+#define __THROW
+#endif
+
#include <sched.h>
#include <errno.h>
#include <sys/wait.h>
diff --git a/testcases/kernel/syscalls/clone/clone05.c b/testcases/kernel/syscalls/clone/clone05.c
index 66b1c1f..a9006c7 100644
--- a/testcases/kernel/syscalls/clone/clone05.c
+++ b/testcases/kernel/syscalls/clone/clone05.c
@@ -65,6 +65,11 @@
* -t : Turn on syscall timing.
****************************************************************/
+#if defined UCLINUX && !__THROW
+/* workaround for libc bug */
+#define __THROW
+#endif
+
#include <errno.h>
#include <sched.h>
#include <sys/wait.h>
diff --git a/testcases/kernel/syscalls/clone/clone06.c b/testcases/kernel/syscalls/clone/clone06.c
index 78f7433..79c0fdc 100644
--- a/testcases/kernel/syscalls/clone/clone06.c
+++ b/testcases/kernel/syscalls/clone/clone06.c
@@ -70,6 +70,11 @@
*
****************************************************************/
+#if defined UCLINUX && !__THROW
+/* workaround for libc bug */
+#define __THROW
+#endif
+
#include <errno.h>
#include <sched.h>
#include <sys/wait.h>
diff --git a/testcases/kernel/syscalls/clone/clone07.c b/testcases/kernel/syscalls/clone/clone07.c
index a0d3a6f..785f5a2 100644
--- a/testcases/kernel/syscalls/clone/clone07.c
+++ b/testcases/kernel/syscalls/clone/clone07.c
@@ -68,6 +68,11 @@
*
****************************************************************/
+#if defined UCLINUX && !__THROW
+/* workaround for libc bug */
+#define __THROW
+#endif
+
#include <errno.h>
#include <sched.h>
#include <sys/wait.h>
diff --git a/testcases/kernel/syscalls/close/Makefile b/testcases/kernel/syscalls/close/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/close/Makefile
+++ b/testcases/kernel/syscalls/close/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/confstr/Makefile b/testcases/kernel/syscalls/confstr/Makefile
index aeb42f4..2781633 100644
--- a/testcases/kernel/syscalls/confstr/Makefile
+++ b/testcases/kernel/syscalls/confstr/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/connect/Makefile b/testcases/kernel/syscalls/connect/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/connect/Makefile
+++ b/testcases/kernel/syscalls/connect/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/connect/connect01.c b/testcases/kernel/syscalls/connect/connect01.c
index 75648b7..c394535 100644
--- a/testcases/kernel/syscalls/connect/connect01.c
+++ b/testcases/kernel/syscalls/connect/connect01.c
@@ -60,9 +60,10 @@
int s, s2; /* socket descriptor */
struct sockaddr_in sin1, sin2, sin3, sin4;
+static int sfd; /* shared between start_server and do_child */
void setup(void), setup0(void), setup1(void), setup2(void),
- cleanup(void), cleanup0(void), cleanup1(void);
+ cleanup(void), cleanup0(void), cleanup1(void), do_child(void);
static pid_t start_server(struct sockaddr_in*);
@@ -108,6 +109,10 @@
extern int Tst_count;
+#ifdef UCLINUX
+static char *argv0;
+#endif
+
int
main(int argc, char *argv[])
{
@@ -121,6 +126,11 @@
tst_exit();
}
+#ifdef UCLINUX
+ argv0 = argv[0];
+ maybe_run_child(&do_child, "d", &sfd);
+#endif
+
/* set up expected errnos */
TEST_EXP_ENOS(exp_enos);
@@ -243,11 +253,8 @@
pid_t
start_server(struct sockaddr_in *sin0)
{
- struct sockaddr_in sin1 = *sin0, fsin;
- fd_set afds, rfds;
+ struct sockaddr_in sin1 = *sin0;
pid_t pid;
- int sfd, nfds, cc, fd;
- char c;
sfd = socket(PF_INET, SOCK_STREAM, 0);
if (sfd < 0) {
@@ -265,8 +272,13 @@
strerror(errno));
return -1;
}
- switch ((pid = fork())) {
+ switch ((pid = FORK_OR_VFORK())) {
case 0: /* child */
+#ifdef UCLINUX
+ self_exec(argv0, "d", sfd);
+#else
+ do_child();
+#endif
break;
case -1:
tst_brkm(TBROK, cleanup, "server fork failed: %s",
@@ -277,6 +289,17 @@
return pid;
}
+ return -1;
+}
+
+void
+do_child()
+{
+ struct sockaddr_in fsin;
+ fd_set afds, rfds;
+ int nfds, cc, fd;
+ char c;
+
FD_ZERO(&afds);
FD_SET(sfd, &afds);
diff --git a/testcases/kernel/syscalls/creat/Makefile b/testcases/kernel/syscalls/creat/Makefile
index d711407..0d602a1 100644
--- a/testcases/kernel/syscalls/creat/Makefile
+++ b/testcases/kernel/syscalls/creat/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp -L.. -ltestsuite
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/creat/creat04.c b/testcases/kernel/syscalls/creat/creat04.c
index fd79ab6..3f3a36c 100644
--- a/testcases/kernel/syscalls/creat/creat04.c
+++ b/testcases/kernel/syscalls/creat/creat04.c
@@ -111,7 +111,7 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() #1 failed");
}
@@ -135,7 +135,7 @@
tst_brkm(TBROK, cleanup, "child #1 failed");
}
- if ((pid1 = fork()) == -1) {
+ if ((pid1 = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() #2 failed");
}
diff --git a/testcases/kernel/syscalls/creat/creat06.c b/testcases/kernel/syscalls/creat/creat06.c
index 9afc278..b4797ec 100644
--- a/testcases/kernel/syscalls/creat/creat06.c
+++ b/testcases/kernel/syscalls/creat/creat06.c
@@ -219,7 +219,8 @@
tst_brkm(TBROK, cleanup, "couldn't create a test file");
}
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/creat/creat07.c b/testcases/kernel/syscalls/creat/creat07.c
index be472ae..c74dfac 100644
--- a/testcases/kernel/syscalls/creat/creat07.c
+++ b/testcases/kernel/syscalls/creat/creat07.c
@@ -109,7 +109,7 @@
* made to creat() an executable which is running.
*/
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() #1 failed");
}
@@ -120,7 +120,7 @@
exit(1);
}
- if ((pid2 = fork()) == -1) {
+ if ((pid2 = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() #2 failed");
}
diff --git a/testcases/kernel/syscalls/dup/Makefile b/testcases/kernel/syscalls/dup/Makefile
index 6ee6da4..734b97c 100644
--- a/testcases/kernel/syscalls/dup/Makefile
+++ b/testcases/kernel/syscalls/dup/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/dup2/Makefile b/testcases/kernel/syscalls/dup2/Makefile
index 6ee6da4..734b97c 100644
--- a/testcases/kernel/syscalls/dup2/Makefile
+++ b/testcases/kernel/syscalls/dup2/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/epoll/Makefile b/testcases/kernel/syscalls/epoll/Makefile
index 0750245..ad04e38 100644
--- a/testcases/kernel/syscalls/epoll/Makefile
+++ b/testcases/kernel/syscalls/epoll/Makefile
@@ -1,4 +1,5 @@
CFLAGS+= -Wall -O -g -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
@@ -14,6 +15,7 @@
LDLIBS+= -L../../../../lib -lltp
endif
+LDLIBS+= $(if $(UCLINUX),-lc)
TARGETS=CheckVer epoll-ltp
diff --git a/testcases/kernel/syscalls/epoll/epoll-ltp.c b/testcases/kernel/syscalls/epoll/epoll-ltp.c
index 8c12456..eee7b6b 100644
--- a/testcases/kernel/syscalls/epoll/epoll-ltp.c
+++ b/testcases/kernel/syscalls/epoll/epoll-ltp.c
@@ -139,7 +139,7 @@
int kid_status; \
\
tst_flush(); \
- kid_pid = fork(); \
+ kid_pid = FORK_OR_VFORK(); \
if (kid_pid == 0){
#define PROTECT_REGION_EXIT(errval) return (errval);
@@ -173,7 +173,7 @@
int kid_status; \
\
tst_flush(); \
- kid_pid = fork(); \
+ kid_pid = FORK_OR_VFORK(); \
if (kid_pid == 0){ /* Run the function */ \
return fn(epoll_fd); \
} else { \
diff --git a/testcases/kernel/syscalls/execl/Makefile b/testcases/kernel/syscalls/execl/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/execl/Makefile
+++ b/testcases/kernel/syscalls/execl/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/execl/execl01.c b/testcases/kernel/syscalls/execl/execl01.c
index 4b5203b..a8b6670 100644
--- a/testcases/kernel/syscalls/execl/execl01.c
+++ b/testcases/kernel/syscalls/execl/execl01.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: execl01.c,v 1.1 2001/08/27 22:15:13 plars Exp $ */
+/* $Id: execl01.c,v 1.2 2005/07/11 22:28:15 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -172,7 +172,7 @@
* TEST CASE:
* fork, then call execl from child
*/
- switch(pid=fork()) {
+ switch(pid=FORK_OR_VFORK()) {
case 0: /* CHILD - Call execl(2) */
execl("test", "test", NULL);
/* should not get here!! if we do, the parent will fail the Test Case */
diff --git a/testcases/kernel/syscalls/execle/Makefile b/testcases/kernel/syscalls/execle/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/execle/Makefile
+++ b/testcases/kernel/syscalls/execle/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/execle/execle01.c b/testcases/kernel/syscalls/execle/execle01.c
index 980f51e..65e4a24 100644
--- a/testcases/kernel/syscalls/execle/execle01.c
+++ b/testcases/kernel/syscalls/execle/execle01.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: execle01.c,v 1.2 2005/02/07 19:40:22 robbiew Exp $ */
+/* $Id: execle01.c,v 1.3 2005/07/11 22:28:16 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -171,7 +171,7 @@
* TEST CASE:
* fork, then call execle from child
*/
- switch(pid=fork()) {
+ switch(pid=FORK_OR_VFORK()) {
case 0: /* CHILD - Call execle(2) */
execle("test", "test", NULL, environ);
/* should not get here!! if we do, the parent will fail the Test Case */
diff --git a/testcases/kernel/syscalls/execlp/Makefile b/testcases/kernel/syscalls/execlp/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/execlp/Makefile
+++ b/testcases/kernel/syscalls/execlp/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/execlp/execlp01.c b/testcases/kernel/syscalls/execlp/execlp01.c
index b953a50..4f1e77d 100644
--- a/testcases/kernel/syscalls/execlp/execlp01.c
+++ b/testcases/kernel/syscalls/execlp/execlp01.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: execlp01.c,v 1.2 2005/02/07 19:40:33 robbiew Exp $ */
+/* $Id: execlp01.c,v 1.3 2005/07/11 22:28:16 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -170,7 +170,7 @@
* TEST CASE:
* fork, then call execlp from child
*/
- switch(pid=fork()) {
+ switch(pid=FORK_OR_VFORK()) {
case 0: /* CHILD - Call execlp(2) */
execlp("/usr/bin/test", "/usr/bin/test", NULL);
/* should not get here!! if we do, the parent will fail the Test Case */
diff --git a/testcases/kernel/syscalls/execv/Makefile b/testcases/kernel/syscalls/execv/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/execv/Makefile
+++ b/testcases/kernel/syscalls/execv/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/execv/execv01.c b/testcases/kernel/syscalls/execv/execv01.c
index 5281911..b5a8e94 100644
--- a/testcases/kernel/syscalls/execv/execv01.c
+++ b/testcases/kernel/syscalls/execv/execv01.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: execv01.c,v 1.1 2001/08/27 22:15:13 plars Exp $ */
+/* $Id: execv01.c,v 1.2 2005/07/11 22:28:16 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -171,7 +171,7 @@
* TEST CASE:
* fork, then call execv from child
*/
- switch(pid=fork()) {
+ switch(pid=FORK_OR_VFORK()) {
case 0: /* CHILD - Call execv(2) */
execv("/usr/bin/test", args);
/* should not get here!! if we do, the parent will fail the Test Case */
diff --git a/testcases/kernel/syscalls/execve/Makefile b/testcases/kernel/syscalls/execve/Makefile
index 15f9d40..5b561a0 100644
--- a/testcases/kernel/syscalls/execve/Makefile
+++ b/testcases/kernel/syscalls/execve/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp -L.. -ltestsuite
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/execve/execve01.c b/testcases/kernel/syscalls/execve/execve01.c
index 97bbf53..e192e72 100644
--- a/testcases/kernel/syscalls/execve/execve01.c
+++ b/testcases/kernel/syscalls/execve/execve01.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: execve01.c,v 1.1 2001/08/27 22:15:13 plars Exp $ */
+/* $Id: execve01.c,v 1.2 2005/07/11 22:28:16 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -172,7 +172,7 @@
* TEST CASE:
* fork, then call execve from child
*/
- switch(pid=fork()) {
+ switch(pid=FORK_OR_VFORK()) {
case 0: /* CHILD - Call execve(2) */
execve("/usr/bin/test", args, environ);
/* should not get here!! if we do, the parent will fail the Test Case */
diff --git a/testcases/kernel/syscalls/execve/execve02.c b/testcases/kernel/syscalls/execve/execve02.c
index 166746f..27269c1 100644
--- a/testcases/kernel/syscalls/execve/execve02.c
+++ b/testcases/kernel/syscalls/execve/execve02.c
@@ -115,7 +115,7 @@
"test file");
}
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
}
diff --git a/testcases/kernel/syscalls/execve/execve03.c b/testcases/kernel/syscalls/execve/execve03.c
index abefb85..1bbf7f2 100644
--- a/testcases/kernel/syscalls/execve/execve03.c
+++ b/testcases/kernel/syscalls/execve/execve03.c
@@ -233,7 +233,8 @@
tst_brkm(TBROK, cleanup, "close() failed");
}
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/execve/execve05.c b/testcases/kernel/syscalls/execve/execve05.c
index 10a8158..89fa4fa 100644
--- a/testcases/kernel/syscalls/execve/execve05.c
+++ b/testcases/kernel/syscalls/execve/execve05.c
@@ -60,6 +60,8 @@
void setup(void);
void cleanup(void);
void help(void);
+void do_child_1(void);
+void do_child_2(void);
int exp_enos[] = {ETXTBSY, 0};
@@ -77,7 +79,6 @@
{
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
- int fildes;
pid_t pid, pid1;
int e_code, status, retval=0;
char *argv[1], *env[1];
@@ -87,6 +88,10 @@
tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child_1, "nS", 1, &test_name);
+#endif
+
if (!Fflag) {
tst_resm(TWARN, "You must specify an executable file with "
"the -F option.");
@@ -109,20 +114,21 @@
* child process attempts to execve the executable opened
* by the first child process
*/
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork #1 failed");
}
if (pid == 0) { /* first child */
- if ((fildes = open(test_name, O_WRONLY)) == -1) {
- tst_brkm(TBROK, NULL, "open(2) failed");
- exit(1);
+#ifdef UCLINUX
+ if (self_exec(av[0], "nS", 1, test_name) < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed");
}
- sleep(10); /* let other child execve same file */
- exit(0);
+#else
+ do_child_1();
+#endif
}
- if ((pid1 = fork()) == -1) {
+ if ((pid1 = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork #2 failed");
}
@@ -204,3 +210,19 @@
/* exit with return code appropriate for results */
tst_exit();
}
+
+/*
+ * do_child_1()
+ */
+void
+do_child_1()
+{
+ int fildes;
+
+ if ((fildes = open(test_name, O_WRONLY)) == -1) {
+ tst_brkm(TBROK, NULL, "open(2) failed");
+ exit(1);
+ }
+ sleep(10); /* let other child execve same file */
+ exit(0);
+}
diff --git a/testcases/kernel/syscalls/execve/execve06.c b/testcases/kernel/syscalls/execve/execve06.c
index 4021df4..9c10392 100644
--- a/testcases/kernel/syscalls/execve/execve06.c
+++ b/testcases/kernel/syscalls/execve/execve06.c
@@ -138,7 +138,7 @@
sprintf(iter, "%d", iterations);
for (i = 0; i < count; i++) {
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0) {
perror("Fork failed");
exit(1);
@@ -158,7 +158,7 @@
#ifdef DEBUG
tst_resm(TINFO, "Main - started pid %d", pid);
#endif
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0) {
perror("Fork failed");
exit(1);
diff --git a/testcases/kernel/syscalls/execvp/Makefile b/testcases/kernel/syscalls/execvp/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/execvp/Makefile
+++ b/testcases/kernel/syscalls/execvp/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/execvp/execvp01.c b/testcases/kernel/syscalls/execvp/execvp01.c
index 8027a03..fda2baf 100644
--- a/testcases/kernel/syscalls/execvp/execvp01.c
+++ b/testcases/kernel/syscalls/execvp/execvp01.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: execvp01.c,v 1.1 2001/08/27 22:15:13 plars Exp $ */
+/* $Id: execvp01.c,v 1.2 2005/07/11 22:28:17 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -171,7 +171,7 @@
* TEST CASE:
* fork, then call execvp from child
*/
- switch(pid=fork()) {
+ switch(pid=FORK_OR_VFORK()) {
case 0: /* CHILD - Call execvp(2) */
execvp("/usr/bin/test", args);
/* should not get here!! if we do, the parent will fail the Test Case */
diff --git a/testcases/kernel/syscalls/exit/Makefile b/testcases/kernel/syscalls/exit/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/exit/Makefile
+++ b/testcases/kernel/syscalls/exit/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/exit/exit01.c b/testcases/kernel/syscalls/exit/exit01.c
index c2a22ca..b54afad 100644
--- a/testcases/kernel/syscalls/exit/exit01.c
+++ b/testcases/kernel/syscalls/exit/exit01.c
@@ -77,7 +77,7 @@
sig = 0;
exno = 1;
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork failed, errno=%d",
errno, strerror(errno));
}
diff --git a/testcases/kernel/syscalls/exit/exit02.c b/testcases/kernel/syscalls/exit/exit02.c
index 9f46023..2274356 100644
--- a/testcases/kernel/syscalls/exit/exit02.c
+++ b/testcases/kernel/syscalls/exit/exit02.c
@@ -99,7 +99,7 @@
exno = sig = 0;
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork failed, error no = %d",
errno, strerror(errno));
}
diff --git a/testcases/kernel/syscalls/fchdir/Makefile b/testcases/kernel/syscalls/fchdir/Makefile
index 15f9d40..5b561a0 100644
--- a/testcases/kernel/syscalls/fchdir/Makefile
+++ b/testcases/kernel/syscalls/fchdir/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp -L.. -ltestsuite
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/fchdir/fchdir03.c b/testcases/kernel/syscalls/fchdir/fchdir03.c
index 21b06e2..83d8f36 100644
--- a/testcases/kernel/syscalls/fchdir/fchdir03.c
+++ b/testcases/kernel/syscalls/fchdir/fchdir03.c
@@ -104,7 +104,7 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
tst_brkm(TBROK, cleanup, "fork failed");
}
diff --git a/testcases/kernel/syscalls/fchmod/Makefile b/testcases/kernel/syscalls/fchmod/Makefile
index f5447c0..93d844d 100644
--- a/testcases/kernel/syscalls/fchmod/Makefile
+++ b/testcases/kernel/syscalls/fchmod/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -D_GNU_SOURCE -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LDLIBS+= -L../../../../lib -lltp
+LDLIBS+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard fchmod*.c) change_owner.c
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/fchown/Makefile b/testcases/kernel/syscalls/fchown/Makefile
index 79ecc94..1f3ce18 100644
--- a/testcases/kernel/syscalls/fchown/Makefile
+++ b/testcases/kernel/syscalls/fchown/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LDLIBS+= -L../../../../lib -lltp
+LDLIBS+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard fchown*.c) change_owner.c
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/fcntl/Makefile b/testcases/kernel/syscalls/fcntl/Makefile
index e49508d..752050c 100644
--- a/testcases/kernel/syscalls/fcntl/Makefile
+++ b/testcases/kernel/syscalls/fcntl/Makefile
@@ -31,7 +31,9 @@
ifeq ($(shell uname -s),Linux)
CFLAGS+= -Wall
endif
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L$(TOP)/lib/$(CCPU) -L$(TOP)/lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/fcntl/fcntl07.c b/testcases/kernel/syscalls/fcntl/fcntl07.c
index 5790d8c..4bc59a6 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl07.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl07.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: fcntl07.c,v 1.5 2005/02/07 19:40:14 robbiew Exp $ */
+/* $Id: fcntl07.c,v 1.6 2005/07/11 22:28:18 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -379,7 +379,7 @@
printf("%s: fd = %d rc = %d status= %d, errno= %d\n", tcd, fd, rc, status, errno);
#endif
- switch(pid=fork()) {
+ switch(pid=FORK_OR_VFORK()) {
case -1:
return(-1);
case 0: /* child */
diff --git a/testcases/kernel/syscalls/fcntl/fcntl07B.c b/testcases/kernel/syscalls/fcntl/fcntl07B.c
index e6a395a..bad4170 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl07B.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl07B.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: fcntl07B.c,v 1.5 2005/02/07 19:40:14 robbiew Exp $ */
+/* $Id: fcntl07B.c,v 1.6 2005/07/11 22:28:18 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -377,7 +377,7 @@
printf("%s: fd = %d rc = %d status= %d, errno= %d\n", tcd, fd, rc, status, errno);
#endif
- switch(pid=fork()) {
+ switch(pid=FORK_OR_VFORK()) {
case -1:
return(-1);
case 0: /* child */
diff --git a/testcases/kernel/syscalls/fcntl/fcntl11.c b/testcases/kernel/syscalls/fcntl/fcntl11.c
index 21e76e9..4124d76 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl11.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl11.c
@@ -315,6 +315,11 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "ddddd", &parent_pipe[0],
+ &parent_pipe[1], &child_pipe[0], &child_pipe[1], &fd);
+#endif
+
setup(); /* global setup */
/* Check for looping state if -i option is given */
@@ -322,8 +327,16 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((child_pid = fork()) == 0) { /* parent */
+ if ((child_pid = FORK_OR_VFORK()) == 0) { /* parent */
+#ifdef UCLINUX
+ if (self_exec(av[0], "ddddd", parent_pipe[0], parent_pipe[1],
+ child_pipe[0], child_pipe[1], fd) < 0) {
+ tst_resm(TFAIL, "self_exec failed");
+ cleanup();
+ }
+#else
do_child();
+#endif
} else if (child_pid < 0) {
tst_resm(TFAIL, "Fork failed");
cleanup();
diff --git a/testcases/kernel/syscalls/fcntl/fcntl12.c b/testcases/kernel/syscalls/fcntl/fcntl12.c
index c168c1d..849c924 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl12.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl12.c
@@ -81,7 +81,7 @@
tst_resm(TINFO, "Test for errno EMFILE");
fail = 0;
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0) {
tst_resm(TFAIL, "Fork failed");
cleanup();
diff --git a/testcases/kernel/syscalls/fcntl/fcntl14.c b/testcases/kernel/syscalls/fcntl/fcntl14.c
index aa69177..9e623cf 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl14.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl14.c
@@ -546,6 +546,9 @@
int TST_TOTAL = 1; /* Total number of test cases */
extern int Tst_count; /* Test case counter */
+#ifdef UCLINUX
+static char *argv0; /* Set by main(), passed to self_exec() */
+#endif
/*
* cleanup()
@@ -619,6 +622,13 @@
}
}
+void do_usleep_child() {
+ usleep(100000); /* XXX how long is long enough? */
+ wake_parent();
+ exit(0);
+}
+
+
void dochild()
{ /* child process */
int rc;
@@ -744,14 +754,20 @@
* need some way to have fcntl() atomically unblock a
* signal and wait for the lock.)
*/
- pid = fork();
+ pid = FORK_OR_VFORK();
switch (pid) {
case -1:
tst_resm(TFAIL, "Fork failed");
break;
case 0: /* child */
- usleep(100000); /* XXX how long is long enough? */
- wake_parent();
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 1) < 0) {
+ tst_resm(TFAIL, "self_exec failed");
+ break;
+ }
+#else
+ do_usleep_child();
+#endif
break;
default:
@@ -849,8 +865,19 @@
fflush(stdout);
/* spawn a child process */
- if ((child = fork()) == 0) {
+ if ((child = FORK_OR_VFORK()) == 0) {
+#ifdef UCLINUX
+ if (self_exec(argv0, "nddddddddd", 2, thiscase->c_type,
+ thiscase->c_whence, thiscase->c_start,
+ thiscase->c_len, thiscase->c_flag,
+ thiscase->a_type, fd, test, parent) < 0) {
+ tst_resm(TFAIL, "self_exec failed");
+ cleanup();
+ /*NOTREACHED*/
+ }
+#else
dochild();
+#endif
}
if (child < 0) {
tst_resm(TFAIL, "Fork failed");
@@ -957,6 +984,18 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ argv0 = av[0];
+
+ maybe_run_child(&do_usleep_child, "n", 1);
+ thiscase = malloc(sizeof(testcase));
+
+ maybe_run_child(&dochild, "nddddddddd", 2, &thiscase->c_type,
+ &thiscase->c_whence, &thiscase->c_start,
+ &thiscase->c_len, &thiscase->c_flag, &thiscase->a_type,
+ &fd, &test, &parent);
+#endif
+
setup(); /* global setup */
/* Check for looping state if -i option is given */
@@ -1119,7 +1158,18 @@
/* spawn a child process */
if ((child = fork()) == 0) {
+#ifdef UCLINUX
+ if (self_exec(argv0, "nddddddddd", 2, thiscase->c_type,
+ thiscase->c_whence, thiscase->c_start,
+ thiscase->c_len, thiscase->c_flag,
+ thiscase->a_type, fd, test, parent) < 0) {
+ tst_resm(TFAIL, "self_exec failed");
+ cleanup();
+ /*NOTREACHED*/
+ }
+#else
dochild();
+#endif
}
if (child < 0) {
tst_resm(TFAIL, "Fork failed");
diff --git a/testcases/kernel/syscalls/fcntl/fcntl15.c b/testcases/kernel/syscalls/fcntl/fcntl15.c
index 4142401..bbcdfbe 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl15.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl15.c
@@ -75,6 +75,10 @@
static char tmpname[40];
struct flock flock;
+#ifdef UCLINUX
+static char* argv0; /* set by main, passed to self_exec */
+#endif
+
/*
* cleanup() - performs all ONE TIME cleanup for this test at
* completion or premature exit.
@@ -185,6 +189,15 @@
exit(0);
}
+#ifdef UCLINUX
+int uc_file_flag, uc_file_mode;
+
+void dochild1_uc()
+{
+ dochild1(uc_file_flag, uc_file_mode);
+}
+#endif
+
int dofork(int file_flag, int file_mode)
{
/* create child process */
@@ -195,7 +208,15 @@
/* child1 */
if (child1 == 0) {
+#ifdef UCLINUX
+ if (self_exec(argv0, "nddds", 1, file_flag, file_mode,
+ parent, tmpname) < 0) {
+ perror("self_exec failure");
+ return(1);
+ }
+#else
dochild1(file_flag, file_mode);
+#endif
} else {
/*
* need to wait for child1 to open, and lock the area of the
@@ -263,7 +284,7 @@
flock.l_whence = 0;
flock.l_start = 5L;
flock.l_len = 5L;
-
+
/* set lock on child file descriptor */
if ((fcntl(fd_C, F_SETLK, &flock)) >= 0) {
tst_resm(TFAIL, "second child2 lock succeeded should have "
@@ -533,6 +554,12 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&dochild1_uc, "nddds", 1, &uc_file_flag,
+ &uc_file_mode, &parent, tmpname);
+ argv0 = av[0];
+#endif
+
setup();
/* Check for looping state if -i option is given */
diff --git a/testcases/kernel/syscalls/fcntl/fcntl16.c b/testcases/kernel/syscalls/fcntl/fcntl16.c
index 37c4ced..bd97061 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl16.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl16.c
@@ -289,6 +289,10 @@
int TST_TOTAL = 1;
extern int Tst_count;
+#ifdef UCLINUX
+static char *argv0;
+#endif
+
/*
* cleanup - performs all the ONE TIME cleanup for this test at completion or
* premature exit
@@ -349,6 +353,16 @@
exit(0);
} /* end of child process */
+#ifdef UCLINUX
+static int kid_uc;
+
+void
+dochild_uc()
+{
+ dochild(kid_uc);
+}
+#endif
+
void
catch_alarm()
{
@@ -504,8 +518,16 @@
/* spawn child processes */
for (i = 0; i < 2; i++) {
if (thislock->type != IGNORED) {
- if ((child = fork()) == 0) {
+ if ((child = FORK_OR_VFORK()) == 0) {
+#ifdef UCLINUX
+ if (self_exec(argv0, "ddddd", i, parent,
+ test, thislock, fd) < 0) {
+ perror("self_exec failed");
+ return(1);
+ }
+#else
dochild(i);
+#endif
}
if (child < 0) {
perror("Fork failed");
@@ -656,6 +678,12 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(dochild_uc, "ddddd", &kid_uc, &parent, &test,
+ &thislock, &fd);
+ argv0 = av[0];
+#endif
+
setup(); /* global setup */
/* check looping state if -i option given */
diff --git a/testcases/kernel/syscalls/fcntl/fcntl17.c b/testcases/kernel/syscalls/fcntl/fcntl17.c
index 04c5b2c..7cfbf93 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl17.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl17.c
@@ -441,6 +441,24 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child1, "nddddddddd", 1, &file_fd,
+ &parent_pipe[0], &parent_pipe[1],
+ &child_pipe1[0], &child_pipe1[1],
+ &child_pipe2[0], &child_pipe2[1],
+ &child_pipe3[0], &child_pipe3[1]);
+ maybe_run_child(&do_child2, "nddddddddd", 2, &file_fd,
+ &parent_pipe[0], &parent_pipe[1],
+ &child_pipe1[0], &child_pipe1[1],
+ &child_pipe2[0], &child_pipe2[1],
+ &child_pipe3[0], &child_pipe3[1]);
+ maybe_run_child(&do_child3, "nddddddddd", 3, &file_fd,
+ &parent_pipe[0], &parent_pipe[1],
+ &child_pipe1[0], &child_pipe1[1],
+ &child_pipe2[0], &child_pipe2[1],
+ &child_pipe3[0], &child_pipe3[1]);
+#endif
+
if (setup()) { /* global testup */
tst_resm(TINFO, "setup failed");
cleanup();
@@ -453,8 +471,19 @@
Tst_count = 0;
tst_resm(TINFO, "Enter preparation phase");
- if ((child_pid1 = fork()) == 0) { /* first child */
+ if ((child_pid1 = FORK_OR_VFORK()) == 0) { /* first child */
+#ifdef UCLINUX
+ if (self_exec(av[0], "nddddddddd", 1, file_fd,
+ parent_pipe[0], parent_pipe[1],
+ child_pipe1[0], child_pipe1[1],
+ child_pipe2[0], child_pipe2[1],
+ child_pipe3[0], child_pipe3[1]) < 0) {
+ perror("self_exec failed, child 1");
+ cleanup();
+ }
+#else
do_child1();
+#endif
} else if (child_pid1 < 0) {
perror("Fork failed: child 1");
cleanup();
@@ -464,7 +493,18 @@
/* parent */
if ((child_pid2 = fork()) == 0) { /* second child */
+#ifdef UCLINUX
+ if (self_exec(av[0], "nddddddddd", 2, file_fd,
+ parent_pipe[0], parent_pipe[1],
+ child_pipe1[0], child_pipe1[1],
+ child_pipe2[0], child_pipe2[1],
+ child_pipe3[0], child_pipe3[1]) < 0) {
+ perror("self_exec failed, child 2");
+ cleanup();
+ }
+#else
do_child2();
+#endif
} else if (child_pid2 < 0) {
perror("Fork failed: child 2");
if ((kill(child_pid1, SIGKILL)) < 0) {
@@ -478,6 +518,18 @@
/* parent */
if ((child_pid3 = fork()) == 0) { /* third child */
+#ifdef UCLINUX
+ if (self_exec(av[0], "nddddddddd", 3, file_fd,
+ parent_pipe[0], parent_pipe[1],
+ child_pipe1[0], child_pipe1[1],
+ child_pipe2[0], child_pipe2[1],
+ child_pipe3[0], child_pipe3[1]) < 0) {
+ perror("self_exec failed, child 3");
+ cleanup();
+ }
+#else
+ do_child3();
+#endif
do_child3();
} else if (child_pid3 < 0) {
perror("Fork failed: child 3");
diff --git a/testcases/kernel/syscalls/fcntl/fcntl18.c b/testcases/kernel/syscalls/fcntl/fcntl18.c
index 131b6f8..f103a61 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl18.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl18.c
@@ -120,7 +120,7 @@
/* //block3: */
tst_resm(TINFO, "Enter block 3");
fail = 0;
- if ((pid = fork()) == 0) { /* child */
+ if ((pid = FORK_OR_VFORK()) == 0) { /* child */
fail = 0;
pass = getpwnam("nobody");
retval = setreuid(-1, pass->pw_uid);
diff --git a/testcases/kernel/syscalls/fcntl/fcntl19.c b/testcases/kernel/syscalls/fcntl/fcntl19.c
index 2ad1179..98453a4 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl19.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl19.c
@@ -322,6 +322,11 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "ddddd", &parent_pipe[0], &parent_pipe[1],
+ &child_pipe[0], &child_pipe[1], &fd);
+#endif
+
setup(); /* global setup */
/* Check for looping state if -i option is given */
@@ -329,8 +334,16 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((child_pid = fork()) == 0) { /* child */
+ if ((child_pid = FORK_OR_VFORK()) == 0) { /* child */
+#ifdef UCLINUX
+ if (self_exec(av[0], "ddddd", parent_pipe[0], parent_pipe[1],
+ child_pipe[0], child_pipe[1], fd) < 0) {
+ tst_resm(TFAIL, "self_exec failed");
+ cleanup();
+ }
+#else
do_child();
+#endif
} else if (child_pid < 0) {
tst_resm(TFAIL, "Fork failed");
cleanup();
diff --git a/testcases/kernel/syscalls/fcntl/fcntl20.c b/testcases/kernel/syscalls/fcntl/fcntl20.c
index 4ec679c..29d85b5 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl20.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl20.c
@@ -317,6 +317,11 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "ddddd", &parent_pipe[0], &parent_pipe[1],
+ &child_pipe[0], &child_pipe[1], &fd);
+#endif
+
setup(); /* global setup */
/* Check for looping state if -i option is given */
@@ -324,8 +329,16 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((child_pid = fork()) == 0) {
+ if ((child_pid = FORK_OR_VFORK()) == 0) { /* child */
+#ifdef UCLINUX
+ if (self_exec(av[0], "ddddd", parent_pipe[0], parent_pipe[1],
+ child_pipe[0], child_pipe[1], fd) < 0) {
+ tst_resm(TFAIL, "self_exec failed");
+ cleanup();
+ }
+#else
do_child();
+#endif
}
if (child_pid < 0) {
diff --git a/testcases/kernel/syscalls/fcntl/fcntl21.c b/testcases/kernel/syscalls/fcntl/fcntl21.c
index 851654f..063ae3e 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl21.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl21.c
@@ -319,6 +319,11 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "ddddd", &parent_pipe[0], &parent_pipe[1],
+ &child_pipe[0], &child_pipe[1], &fd);
+#endif
+
setup(); /* global setup */
/* Check for looping state if -i option is given */
@@ -326,8 +331,16 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((child_pid = fork()) == 0) {
+ if ((child_pid = FORK_OR_VFORK()) == 0) {
+#ifdef UCLINUX
+ if (self_exec(av[0], "ddddd", parent_pipe[0], parent_pipe[1],
+ child_pipe[0], child_pipe[1], fd) < 0) {
+ tst_resm(TFAIL, "self_exec failed");
+ cleanup();
+ }
+#else
do_child();
+#endif
}
if (child_pid < 0) {
tst_resm(TFAIL, "Fork failed");
diff --git a/testcases/kernel/syscalls/fcntl/fcntl22.c b/testcases/kernel/syscalls/fcntl/fcntl22.c
index 2699c37..d7216ac 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl22.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl22.c
@@ -125,7 +125,7 @@
Tst_count = 0;
/* duplicate process */
- if ((child_pid = fork()) == 0) {
+ if ((child_pid = FORK_OR_VFORK()) == 0) {
/* child */
/*
* Call fcntl(2) with F_SETLK argument on file
diff --git a/testcases/kernel/syscalls/fdatasync/Makefile b/testcases/kernel/syscalls/fdatasync/Makefile
index 23e660b..ba52850 100644
--- a/testcases/kernel/syscalls/fdatasync/Makefile
+++ b/testcases/kernel/syscalls/fdatasync/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/flock/Makefile b/testcases/kernel/syscalls/flock/Makefile
index 991b75e..f200ad8 100644
--- a/testcases/kernel/syscalls/flock/Makefile
+++ b/testcases/kernel/syscalls/flock/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -Wall -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LDLIBS+= -L../../../../lib -lltp
+LDLIBS+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/flock/flock03.c b/testcases/kernel/syscalls/flock/flock03.c
index 16e42e0..514af28 100644
--- a/testcases/kernel/syscalls/flock/flock03.c
+++ b/testcases/kernel/syscalls/flock/flock03.c
@@ -76,6 +76,12 @@
void cleanup(void);
void childfunc(int);
+#ifdef UCLINUX
+static int fd_uc;
+void childfunc_uc() {
+ childfunc(fd_uc);
+}
+#endif
char *TCID = "flock03"; /* Test program identifier */
int TST_TOTAL = 3; /* Total number of test cases */
@@ -98,6 +104,10 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ maybe_run_child(&childfunc_uc, "ds", &fd_uc, filename);
+#endif
+
setup();
/* The following loop checks looping state if -i option given */
@@ -117,13 +127,20 @@
if(pid == -1)
tst_brkm(TFAIL, cleanup, "fork() failed, errno %d",
errno);
- if(pid == 0)
+ if(pid == 0) {
+#ifdef UCLINUX
+ if (self_exec(argv[0], "ds", fd, filename) < 0)
+ tst_brkm(TFAIL, cleanup, "self_exec failed, "
+ "errno &d", errno);
+#else
childfunc(fd);
+#endif
+ }
TEST(flock(fd, LOCK_EX | LOCK_NB));
if(TEST_RETURN != 0)
tst_resm(TFAIL, "Parent: Initial attempt to flock() failed, "
- "errno %d",TEST_ERRNO);
+ "errno %d",TEST_ERRNO);
else
tst_resm(TPASS, "Parent: Initial attempt to flock() passed");
diff --git a/testcases/kernel/syscalls/flock/flock04.c b/testcases/kernel/syscalls/flock/flock04.c
index af35f66..f82b579 100644
--- a/testcases/kernel/syscalls/flock/flock04.c
+++ b/testcases/kernel/syscalls/flock/flock04.c
@@ -123,7 +123,7 @@
TEST(flock(fd,LOCK_SH));
if(TEST_RETURN == 0){
- pid = fork();
+ pid = FORK_OR_VFORK();
if(pid == 0){
fd1 = open(filename, O_RDONLY);
retval= flock(fd1,LOCK_SH|LOCK_NB);
@@ -135,7 +135,7 @@
tst_resm(TPASS, "flock() PASSED in acquiring shared lock on "
"Share Locked file");
}
- return 0;
+ exit(0);
}
else{
/* parent waiting */
@@ -145,7 +145,7 @@
/* Testing Exclusive lock on a Share Locked file */
- pid = fork();
+ pid = FORK_OR_VFORK();
if(pid == 0){
fd1 = open(filename, O_RDWR);
@@ -158,7 +158,7 @@
tst_resm(TFAIL, "flock() unexpectedly passed in acquiring exclusive lock on "
"Share Locked file");
}
- return 0;
+ exit(0);
}
else{
/* parent waiting */
diff --git a/testcases/kernel/syscalls/flock/flock05.c b/testcases/kernel/syscalls/flock/flock05.c
index fb6c4f1..2f6fff2 100644
--- a/testcases/kernel/syscalls/flock/flock05.c
+++ b/testcases/kernel/syscalls/flock/flock05.c
@@ -123,7 +123,7 @@
TEST(flock(fd,LOCK_EX));
if(TEST_RETURN == 0){
- pid = fork();
+ pid = FORK_OR_VFORK();
if(pid == 0){
fd1 = open(filename, O_RDWR);
retval= flock(fd1,LOCK_SH|LOCK_NB);
@@ -135,7 +135,7 @@
tst_resm(TFAIL, "flock() unexpectedly PASSED in acquiring shared lock on "
"an already exclusive locked file");
}
- return 0;
+ exit(0);
}
else{
/* parent waiting */
@@ -143,7 +143,7 @@
}
/* Testing Exclusive lock on a Exclusive Locked file */
- pid = fork();
+ pid = FORK_OR_VFORK();
if(pid == 0){
fd1 = open(filename, O_RDWR);
@@ -156,7 +156,7 @@
tst_resm(TFAIL, "flock() unexpectedly passed in acquiring exclusive lock on "
"an exclusive locked file");
}
- return 0;
+ exit(0);
}
else{
/* parent waiting */
diff --git a/testcases/kernel/syscalls/fmtmsg/Makefile b/testcases/kernel/syscalls/fmtmsg/Makefile
index 6ee6da4..734b97c 100644
--- a/testcases/kernel/syscalls/fmtmsg/Makefile
+++ b/testcases/kernel/syscalls/fmtmsg/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/fmtmsg/fmtmsg01.c b/testcases/kernel/syscalls/fmtmsg/fmtmsg01.c
index 622388f..c14afdc 100644
--- a/testcases/kernel/syscalls/fmtmsg/fmtmsg01.c
+++ b/testcases/kernel/syscalls/fmtmsg/fmtmsg01.c
@@ -38,7 +38,9 @@
#include <fcntl.h>
#include <ctype.h>
#include <stdio.h>
+#if !defined(UCLINUX)
#include <fmtmsg.h> /* interface definition */
+#endif
#include <string.h>
/***** LTP Port *****/
@@ -80,6 +82,8 @@
buf[i] = (char)NULL;
}
+#if !defined(UCLINUX)
+
/*--------------------------------------------------------------*/
int main(int argc, char *argv[])
{
@@ -255,5 +259,15 @@
return(0);
}
+#else
+
+int main()
+{
+ tst_resm(TINFO,"fmtmsg01 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
+
/***** ** ** *****/
diff --git a/testcases/kernel/syscalls/fork/Makefile b/testcases/kernel/syscalls/fork/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/fork/Makefile
+++ b/testcases/kernel/syscalls/fork/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/fpathconf/Makefile b/testcases/kernel/syscalls/fpathconf/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/fpathconf/Makefile
+++ b/testcases/kernel/syscalls/fpathconf/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/fstat/Makefile b/testcases/kernel/syscalls/fstat/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/fstat/Makefile
+++ b/testcases/kernel/syscalls/fstat/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/fstat/fstat05.c b/testcases/kernel/syscalls/fstat/fstat05.c
index 5e07b27..6dc08a9 100644
--- a/testcases/kernel/syscalls/fstat/fstat05.c
+++ b/testcases/kernel/syscalls/fstat/fstat05.c
@@ -129,6 +129,8 @@
int SIG_SEEN = sizeof(siglist)/sizeof(int);
+#if !defined(UCLINUX)
+
int
main(int ac, char **av)
{
@@ -196,6 +198,16 @@
return(0);
} /* End main */
+#else
+
+int main()
+{
+ tst_resm(TINFO,"fstat05 test not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
+
/*
* void
* setup(void) - performs all ONE TIME setup for this test.
diff --git a/testcases/kernel/syscalls/fstatfs/Makefile b/testcases/kernel/syscalls/fstatfs/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/fstatfs/Makefile
+++ b/testcases/kernel/syscalls/fstatfs/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/fsync/Makefile b/testcases/kernel/syscalls/fsync/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/fsync/Makefile
+++ b/testcases/kernel/syscalls/fsync/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/ftruncate/Makefile b/testcases/kernel/syscalls/ftruncate/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/ftruncate/Makefile
+++ b/testcases/kernel/syscalls/ftruncate/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/ftruncate/ftruncate04.c b/testcases/kernel/syscalls/ftruncate/ftruncate04.c
index f907568..e96cfbe 100644
--- a/testcases/kernel/syscalls/ftruncate/ftruncate04.c
+++ b/testcases/kernel/syscalls/ftruncate/ftruncate04.c
@@ -280,6 +280,10 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ maybe_run_child(&dochild, "dddd", filename, &recstart, &reclen, &ppid);
+#endif
+
local_flag = PASSED;
tst_tmpdir();
if (system("mount | grep `df . | grep -v Filesystem | awk {'print $1'}` | grep mand >/dev/null") != 0){
@@ -349,7 +353,7 @@
* record lock.
*/
recstart = RECLEN + rand()%(len - 3*RECLEN);
- if ((cpid = fork()) < 0) {
+ if ((cpid = FORK_OR_VFORK()) < 0) {
unlink(filename);
tst_resm(TINFO, "System resource may be too low, fork() malloc()"
" etc are likely to fail.\n");
@@ -358,7 +362,17 @@
tst_exit();
}
if (cpid == 0) {
+#ifdef UCLINUX
+ if (self_exec(av[0], "dddd", filename, recstart,
+ reclen, ppid) < -1) {
+ unlink(filename);
+ tst_resm(TBROK, "self_exec failed.\n");
+ tst_rmdir();
+ tst_exit();
+ }
+#else
dochild();
+#endif
/* never returns */
}
doparent();
diff --git a/testcases/kernel/syscalls/getcwd/Makefile b/testcases/kernel/syscalls/getcwd/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/getcwd/Makefile
+++ b/testcases/kernel/syscalls/getcwd/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getdents/Makefile b/testcases/kernel/syscalls/getdents/Makefile
index 15f9d40..5b561a0 100644
--- a/testcases/kernel/syscalls/getdents/Makefile
+++ b/testcases/kernel/syscalls/getdents/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp -L.. -ltestsuite
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getdomainname/Makefile b/testcases/kernel/syscalls/getdomainname/Makefile
index 7c7d51a..ed17c1b 100644
--- a/testcases/kernel/syscalls/getdomainname/Makefile
+++ b/testcases/kernel/syscalls/getdomainname/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getegid/Makefile b/testcases/kernel/syscalls/getegid/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/getegid/Makefile
+++ b/testcases/kernel/syscalls/getegid/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/geteuid/Makefile b/testcases/kernel/syscalls/geteuid/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/geteuid/Makefile
+++ b/testcases/kernel/syscalls/geteuid/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getgid/Makefile b/testcases/kernel/syscalls/getgid/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/getgid/Makefile
+++ b/testcases/kernel/syscalls/getgid/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getgroups/Makefile b/testcases/kernel/syscalls/getgroups/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/getgroups/Makefile
+++ b/testcases/kernel/syscalls/getgroups/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/gethostid/Makefile b/testcases/kernel/syscalls/gethostid/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/gethostid/Makefile
+++ b/testcases/kernel/syscalls/gethostid/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/gethostname/Makefile b/testcases/kernel/syscalls/gethostname/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/gethostname/Makefile
+++ b/testcases/kernel/syscalls/gethostname/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getitimer/Makefile b/testcases/kernel/syscalls/getitimer/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/getitimer/Makefile
+++ b/testcases/kernel/syscalls/getitimer/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getpeername/Makefile b/testcases/kernel/syscalls/getpeername/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/getpeername/Makefile
+++ b/testcases/kernel/syscalls/getpeername/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getpgid/Makefile b/testcases/kernel/syscalls/getpgid/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/getpgid/Makefile
+++ b/testcases/kernel/syscalls/getpgid/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getpgid/getpgid01.c b/testcases/kernel/syscalls/getpgid/getpgid01.c
index a070a87..ea2231f 100644
--- a/testcases/kernel/syscalls/getpgid/getpgid01.c
+++ b/testcases/kernel/syscalls/getpgid/getpgid01.c
@@ -79,7 +79,7 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((pgid_0 = fork()) < 0) {
+ if ((pgid_0 = FORK_OR_VFORK()) < 0) {
tst_brkm(TBROK, cleanup, "fork() failed");
}
if (pgid_0 > 0) { /* parent */
diff --git a/testcases/kernel/syscalls/getpgrp/Makefile b/testcases/kernel/syscalls/getpgrp/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/getpgrp/Makefile
+++ b/testcases/kernel/syscalls/getpgrp/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getpid/Makefile b/testcases/kernel/syscalls/getpid/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/getpid/Makefile
+++ b/testcases/kernel/syscalls/getpid/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getpid/getpid02.c b/testcases/kernel/syscalls/getpid/getpid02.c
index c54c4c2..3a61b04 100644
--- a/testcases/kernel/syscalls/getpid/getpid02.c
+++ b/testcases/kernel/syscalls/getpid/getpid02.c
@@ -120,7 +120,7 @@
*/
if (STD_FUNCTIONAL_TEST) {
/* Fork a child now */
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
tst_resm(TFAIL, "fork() failed to create child,"
" error=%d", TEST_ERRNO);
} else if (pid == 0) { /* Child process */
diff --git a/testcases/kernel/syscalls/getppid/Makefile b/testcases/kernel/syscalls/getppid/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/getppid/Makefile
+++ b/testcases/kernel/syscalls/getppid/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getppid/getppid02.c b/testcases/kernel/syscalls/getppid/getppid02.c
index 64087f7..b18031a 100644
--- a/testcases/kernel/syscalls/getppid/getppid02.c
+++ b/testcases/kernel/syscalls/getppid/getppid02.c
@@ -77,7 +77,7 @@
Tst_count = 0;
ppid = getpid();
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0) {
tst_brkm(TBROK, cleanup, "fork() failed");
}
diff --git a/testcases/kernel/syscalls/getpriority/Makefile b/testcases/kernel/syscalls/getpriority/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/getpriority/Makefile
+++ b/testcases/kernel/syscalls/getpriority/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getresgid/Makefile b/testcases/kernel/syscalls/getresgid/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/getresgid/Makefile
+++ b/testcases/kernel/syscalls/getresgid/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getresuid/Makefile b/testcases/kernel/syscalls/getresuid/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/getresuid/Makefile
+++ b/testcases/kernel/syscalls/getresuid/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getrlimit/Makefile b/testcases/kernel/syscalls/getrlimit/Makefile
index d1eaf54..7b07ae3 100644
--- a/testcases/kernel/syscalls/getrlimit/Makefile
+++ b/testcases/kernel/syscalls/getrlimit/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getrusage/Makefile b/testcases/kernel/syscalls/getrusage/Makefile
index d1eaf54..7b07ae3 100644
--- a/testcases/kernel/syscalls/getrusage/Makefile
+++ b/testcases/kernel/syscalls/getrusage/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getsid/Makefile b/testcases/kernel/syscalls/getsid/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/getsid/Makefile
+++ b/testcases/kernel/syscalls/getsid/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getsid/getsid01.c b/testcases/kernel/syscalls/getsid/getsid01.c
index c8fd6f5..4f4a7dc 100644
--- a/testcases/kernel/syscalls/getsid/getsid01.c
+++ b/testcases/kernel/syscalls/getsid/getsid01.c
@@ -106,7 +106,7 @@
/* save the return value in a global variable */
p_sid = TEST_RETURN;
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "could not fork");
}
diff --git a/testcases/kernel/syscalls/getsockname/Makefile b/testcases/kernel/syscalls/getsockname/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/getsockname/Makefile
+++ b/testcases/kernel/syscalls/getsockname/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getsockopt/Makefile b/testcases/kernel/syscalls/getsockopt/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/getsockopt/Makefile
+++ b/testcases/kernel/syscalls/getsockopt/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/gettimeofday/Makefile b/testcases/kernel/syscalls/gettimeofday/Makefile
index ecbdcec..1327292 100644
--- a/testcases/kernel/syscalls/gettimeofday/Makefile
+++ b/testcases/kernel/syscalls/gettimeofday/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the gettimeofday(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/getuid/Makefile b/testcases/kernel/syscalls/getuid/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/getuid/Makefile
+++ b/testcases/kernel/syscalls/getuid/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/ioctl/Makefile b/testcases/kernel/syscalls/ioctl/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/ioctl/Makefile
+++ b/testcases/kernel/syscalls/ioctl/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/ioctl/ioctl02.c b/testcases/kernel/syscalls/ioctl/ioctl02.c
index d595b4a..b4c1bc2 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl02.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl02.c
@@ -91,6 +91,9 @@
void setup(void);
void cleanup(void);
void help(void);
+void do_child(void);
+void do_child_uclinux(void);
+void sigterm_handler();
int Devflag = 0;
char *devname;
@@ -101,6 +104,8 @@
{NULL, NULL, NULL}
};
+void hack();
+
int main(int ac, char **av)
{
int lc; /* loop counter */
@@ -112,6 +117,10 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child_uclinux, "dS", &parentpid, &childtty);
+#endif
+
if (!Devflag) {
tst_resm(TWARN, "You must specify a tty device with "
"the -D option.");
@@ -132,17 +141,19 @@
parentpid = getpid();
- if ((childpid = fork()) < 0) {
+ if ((childpid = FORK_OR_VFORK()) < 0) {
tst_brkm(TBROK, cleanup, "fork() failed");
/*NOTREACHED*/
}
if (childpid == 0) { /* child */
- if ((childfd = do_child_setup()) < 0) {
- _exit(1);
+#ifdef UCLINUX
+ if (self_exec(av[0], "dS", parentpid, childtty) < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed");
}
- run_ctest();
- _exit(0);
+#else
+ do_child();
+#endif
}
/* parent */
@@ -202,6 +213,29 @@
return(0);
}
+void
+do_child() {
+ if ((childfd = do_child_setup()) < 0) {
+ _exit(1);
+ }
+ run_ctest();
+ _exit(0);
+}
+
+void
+do_child_uclinux()
+{
+ struct sigaction act;
+
+ /* Set up the signal handlers again */
+ act.sa_handler = (void *)sigterm_handler;
+ act.sa_flags = 0;
+ (void)sigaction(SIGTERM, &act, 0);
+
+ /* Run the normal child */
+ do_child();
+}
+
/*
* run_ptest() - setup the various termio structure values and issue
* the TCSETA ioctl call with the TEST macro.
@@ -260,7 +294,6 @@
int
run_ctest()
{
-
/*
* Wait till the parent has finished testing.
*/
diff --git a/testcases/kernel/syscalls/ioperm/Makefile b/testcases/kernel/syscalls/ioperm/Makefile
index d1eaf54..7b07ae3 100644
--- a/testcases/kernel/syscalls/ioperm/Makefile
+++ b/testcases/kernel/syscalls/ioperm/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/iopl/Makefile b/testcases/kernel/syscalls/iopl/Makefile
index d1eaf54..7b07ae3 100644
--- a/testcases/kernel/syscalls/iopl/Makefile
+++ b/testcases/kernel/syscalls/iopl/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/ipc/Makefile b/testcases/kernel/syscalls/ipc/Makefile
index 37ea753..6ac7cce 100644
--- a/testcases/kernel/syscalls/ipc/Makefile
+++ b/testcases/kernel/syscalls/ipc/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for ipc(2) test directory. #
#########################################################################
CFLAGS+=-I../../../../../include -g -Wall
+CFLAGS+=$(if $(UCLINUX),-DUCLINUX)
LOADLIBES+=-L../../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
IPCTESTS=msgctl msgget msgsnd msgrcv semget semctl semop shmat shmdt shmctl shmget
all: $& $(IPCTESTS)
diff --git a/testcases/kernel/syscalls/ipc/lib/Makefile b/testcases/kernel/syscalls/ipc/lib/Makefile
index 940c506..92898f7 100644
--- a/testcases/kernel/syscalls/ipc/lib/Makefile
+++ b/testcases/kernel/syscalls/ipc/lib/Makefile
@@ -25,6 +25,7 @@
OBJS=$(SRCS:.c=.o)
MAINS=../libipc.a
CFLAGS+=-I../../../../../include -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
all: ../libipc.a
diff --git a/testcases/kernel/syscalls/ipc/msgctl/Makefile b/testcases/kernel/syscalls/ipc/msgctl/Makefile
index ee5b5e1..3a88f84 100644
--- a/testcases/kernel/syscalls/ipc/msgctl/Makefile
+++ b/testcases/kernel/syscalls/ipc/msgctl/Makefile
@@ -23,7 +23,9 @@
SRCS=$(wildcard *.c)
MAINS=$(patsubst %.c,%,$(SRCS))
LOADLIBES+=-L../../../../../lib -lltp -L.. -lipc
+LOADLIBES+= $(if $(UCLINUX),-lc)
CFLAGS+=-I../lib -I../../../../../include -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
all: $& $(MAINS)
diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl05.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl05.c
index 8e5d6ed..153a918 100644
--- a/testcases/kernel/syscalls/ipc/msgctl/msgctl05.c
+++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl05.c
@@ -88,7 +88,7 @@
setup(); /* global setup */
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "could not fork");
}
diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl07.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl07.c
index c216926..e6d4cd9 100644
--- a/testcases/kernel/syscalls/ipc/msgctl/msgctl07.c
+++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl07.c
@@ -57,6 +57,8 @@
void setup();
void cleanup();
+void do_child_1();
+void do_child_2();
/*
* * * * These globals must be defined in the test.
@@ -66,6 +68,14 @@
int TST_TOTAL=1; /* Total number of test cases. */
extern int Tst_count; /* Test Case counter for tst_* routines */
+/* Used by main() and do_child_1(): */
+static int msqid;
+struct my_msgbuf {
+ long type;
+ char text[BYTES];
+} p1_msgp, p2_msgp, p3_msgp, c1_msgp, c2_msgp, c3_msgp;
+
+
/*--------------------------------------------------------------*/
int main(argc, argv)
@@ -73,14 +83,24 @@
char *argv[];
{
key_t key;
- int msqid, pid, size, status;
+ int pid, status;
int i, j, k;
- struct my_msgbuf {
- long type;
- char text[BYTES];
- } p1_msgp, p2_msgp, p3_msgp, c1_msgp, c2_msgp, c3_msgp;
sighandler_t alrm();
+#ifdef UCLINUX
+ char *msg;
+
+ /* parse standard options */
+ if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) !=
+ (char *)NULL){
+ tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+ }
+
+ maybe_run_child(&do_child_1, "ndd", 1, &msqid, &c1_msgp.type);
+ maybe_run_child(&do_child_2, "ndddd", 2, &msqid, &c1_msgp.type,
+ &c2_msgp.type, &c3_msgp.type);
+#endif
+
key = 2 * K;
if ((msqid = msgget(key, IPC_CREAT)) == -1)
{
@@ -89,30 +109,21 @@
}
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0) {
(void) msgctl(msqid, IPC_RMID, (struct msqid_ds *)NULL);
tst_resm(TFAIL, "\tFork failed (may be OK if under stress)");
tst_exit();
}
else if (pid == 0) {
- if ((size = msgrcv(msqid, &c1_msgp, BYTES, 0, 0)) == -1)
- {
- tst_resm(TFAIL, "msgrcv() failed errno = %d\n", errno);
- tst_exit();
+#ifdef UCLINUX
+ if (self_exec(argv[0], "ndd", 1, msqid, c1_msgp.type) < 0) {
+ tst_resm(TFAIL, "\tself_exec failed");
+ tst_exit();
}
- if (size != BYTES)
- {
- tst_resm(TFAIL, "error: received %d bytes expected %d\n", size, BYTES);
- tst_exit();
- }
- for (i=0; i<BYTES; i++)
- if (c1_msgp.text[i] != 'i')
- {
- tst_resm(TFAIL, "error: corrup message\n");
- tst_exit();
- }
- exit(0);
+#else
+ do_child_1();
+#endif
}
else {
struct sigaction act;
@@ -148,54 +159,22 @@
tst_exit();
}
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0) {
(void) msgctl(msqid, IPC_RMID, (struct msqid_ds *)NULL);
tst_resm(TFAIL, "\tFork failed (may be OK if under stress)");
tst_exit();
}
else if (pid == 0) {
- if ((size = msgrcv(msqid, &c3_msgp, BYTES, 3, 0)) == -1) {
- tst_resm(TFAIL, "msgrcv() failed errno = %d\n", errno);
- tst_exit();
+#ifdef UCLINUX
+ if (self_exec(argv[0], "ndddd", 1, msqid, c1_msgp.type,
+ c2_msgp.type, c3_msgp.type) < 0) {
+ tst_resm(TFAIL, "\tself_exec failed");
+ tst_exit();
}
- if (size != BYTES) {
- tst_resm(TFAIL, "error: received %d bytes expected %d\n", size, BYTES);
- tst_exit();
- }
- for (k=0; k<BYTES; k++)
- if (c3_msgp.text[k] != 'k') {
- tst_resm(TFAIL, "error: corrupt message\n");
- tst_exit();
- }
- if ((size = msgrcv(msqid, &c2_msgp, BYTES, 2, 0)) == -1) {
- tst_resm(TFAIL, "msgrcv() failed errno = %d\n", errno);
- tst_exit();
- }
- if (size != BYTES) {
- tst_resm(TFAIL, "error: received %d bytes expected %d\n", size, BYTES);
- tst_exit();
- }
- for (j=0; j<BYTES; j++)
- if (c2_msgp.text[j] != 'j') {
- tst_resm(TFAIL, "error: corrupt message\n");
- tst_exit();
- }
- if ((size = msgrcv(msqid, &c1_msgp, BYTES, 1, 0)) == -1) {
- tst_resm(TFAIL, "msgrcv() failed errno = %d\n", errno);
- tst_exit();
- }
- if (size != BYTES) {
- tst_resm(TFAIL, "error: received %d bytes expected %d\n", size, BYTES);
- tst_exit();
- }
- for (i=0; i<BYTES; i++)
- if (c1_msgp.text[i] != 'i') {
- tst_resm(TFAIL, "error: corrupt message\n");
- tst_exit();
- }
-
- exit(0);
+#else
+ do_child_2();
+#endif
}
else {
struct sigaction act;
@@ -278,6 +257,81 @@
return(0);
}
/*--------------------------------------------------------------*/
+
+void
+do_child_1()
+{
+ int i;
+ int size;
+
+ if ((size = msgrcv(msqid, &c1_msgp, BYTES, 0, 0)) == -1)
+ {
+ tst_resm(TFAIL, "msgrcv() failed errno = %d\n", errno);
+ tst_exit();
+ }
+ if (size != BYTES)
+ {
+ tst_resm(TFAIL, "error: received %d bytes expected %d\n", size, BYTES);
+ tst_exit();
+ }
+ for (i=0; i<BYTES; i++)
+ if (c1_msgp.text[i] != 'i')
+ {
+ tst_resm(TFAIL, "error: corrup message\n");
+ tst_exit();
+ }
+ exit(0);
+}
+
+void
+do_child_2()
+{
+ int i, j, k;
+ int size;
+
+ if ((size = msgrcv(msqid, &c3_msgp, BYTES, 3, 0)) == -1) {
+ tst_resm(TFAIL, "msgrcv() failed errno = %d\n", errno);
+ tst_exit();
+ }
+ if (size != BYTES) {
+ tst_resm(TFAIL, "error: received %d bytes expected %d\n", size, BYTES);
+ tst_exit();
+ }
+ for (k=0; k<BYTES; k++)
+ if (c3_msgp.text[k] != 'k') {
+ tst_resm(TFAIL, "error: corrupt message\n");
+ tst_exit();
+ }
+ if ((size = msgrcv(msqid, &c2_msgp, BYTES, 2, 0)) == -1) {
+ tst_resm(TFAIL, "msgrcv() failed errno = %d\n", errno);
+ tst_exit();
+ }
+ if (size != BYTES) {
+ tst_resm(TFAIL, "error: received %d bytes expected %d\n", size, BYTES);
+ tst_exit();
+ }
+ for (j=0; j<BYTES; j++)
+ if (c2_msgp.text[j] != 'j') {
+ tst_resm(TFAIL, "error: corrupt message\n");
+ tst_exit();
+ }
+ if ((size = msgrcv(msqid, &c1_msgp, BYTES, 1, 0)) == -1) {
+ tst_resm(TFAIL, "msgrcv() failed errno = %d\n", errno);
+ tst_exit();
+ }
+ if (size != BYTES) {
+ tst_resm(TFAIL, "error: received %d bytes expected %d\n", size, BYTES);
+ tst_exit();
+ }
+ for (i=0; i<BYTES; i++)
+ if (c1_msgp.text[i] != 'i') {
+ tst_resm(TFAIL, "error: corrupt message\n");
+ tst_exit();
+ }
+
+ exit(0);
+}
+
/***************************************************************
* setup() - performs all ONE TIME setup for this test.
****************************************************************/
diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl08.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl08.c
index 5f68caf..12324db 100644
--- a/testcases/kernel/syscalls/ipc/msgctl/msgctl08.c
+++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl08.c
@@ -90,6 +90,17 @@
int verify(register char *buf,char val, register int size,int child);
void sig_handler(); /* signal catching function */
int mykid;
+#ifdef UCLINUX
+static char *argv0;
+
+void do_child_1_uclinux();
+static key_t key_uclinux;
+static int i_uclinux;
+
+void do_child_2_uclinux();
+static int id_uclinux;
+static int child_process_uclinux;
+#endif
/*-----------------------------------------------------------------*/
int main(argc, argv)
@@ -100,6 +111,22 @@
int count, status;
struct sigaction act;
+#ifdef UCLINUX
+ char *msg; /* message returned from parse_opts */
+
+ argv0 = argv[0];
+
+ /* parse standard options */
+ if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) != (char *)NULL)
+ {
+ tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+ }
+
+ maybe_run_child(&do_child_1_uclinux, "ndd", 1, &key_uclinux, &i_uclinux);
+ maybe_run_child(&do_child_2_uclinux, "nddd", 2, &id_uclinux, &key_uclinux,
+ &child_process_uclinux);
+#endif
+
setup();
if (argc == 1 )
@@ -185,7 +212,7 @@
for (i = 0; i < nprocs; i++)
{
fflush(stdout);
- if ((pid = fork()) < 0)
+ if ((pid = FORK_OR_VFORK()) < 0)
{
tst_resm(TFAIL, "\tFork failed (may be OK if under stress)");
tst_exit();
@@ -193,8 +220,16 @@
/* Child does this */
if (pid == 0)
{
+#ifdef UCLINUX
+ if (self_exec(argv[0], "ndd", 1, keyarray[i], i) < 0)
+ {
+ tst_resm(TFAIL, "\tself_exec failed");
+ tst_exit();
+ }
+#else
procstat = 1;
exit( dotest(keyarray[i], i) );
+#endif
}
pidarray[i] = pid;
}
@@ -237,6 +272,21 @@
}
/*--------------------------------------------------------------------*/
+#ifdef UCLINUX
+void
+do_child_1_uclinux()
+{
+ procstat = 1;
+ exit(dotest(key_uclinux, i_uclinux));
+}
+
+void
+do_child_2_uclinux()
+{
+ exit(doreader(id_uclinux, key_uclinux % 255, child_process_uclinux));
+}
+#endif
+
int dotest(key, child_process)
key_t key;
int child_process;
@@ -254,7 +304,7 @@
sigrelse(SIGTERM);
fflush(stdout);
- if ((pid = fork()) < 0)
+ if ((pid = FORK_OR_VFORK()) < 0)
{
tst_resm(TWARN, "\tFork failed (may be OK if under stress)");
TEST(msgctl(tid, IPC_RMID, 0));
@@ -267,7 +317,20 @@
/* Child does this */
if (pid == 0)
{
+#ifdef UCLINUX
+ if (self_exec(argv0, "nddd", 2, id, key, child_process) < 0) {
+ tst_resm(TWARN, "self_exec failed");
+ TEST(msgctl(tid, IPC_RMID, 0));
+ if (TEST_RETURN < 0)
+ {
+ tst_resm(TFAIL, "\tMsgctl error in cleanup, "
+ "errno = %d\n", errno);
+ }
+ tst_exit();
+ }
+#else
exit( doreader(id, key % 255, child_process) );
+#endif
}
/* Parent does this */
mykid = pid;
diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl09.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl09.c
index 8f26bb9..0b59321 100644
--- a/testcases/kernel/syscalls/ipc/msgctl/msgctl09.c
+++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl09.c
@@ -93,6 +93,21 @@
int nprocs, nreps, nkids, MSGMNI;
int procstat;
void term(int);
+#ifdef UCLINUX
+static char *argv0;
+
+void do_child_1_uclinux();
+static key_t key_uclinux;
+static int i_uclinux;
+
+void do_child_2_uclinux();
+static int pid_uclinux;
+static int child_process_uclinux;
+
+void do_child_3_uclinux();
+static int rkid_uclinux;
+#endif
+void cleanup_msgqueue(int i, int tid);
/*-----------------------------------------------------------------*/
int main(argc, argv)
@@ -102,6 +117,24 @@
register int i, j, ok, pid;
int count, status;
+#ifdef UCLINUX
+ char *msg; /* message returned from parse_opts */
+
+ argv0 = argv[0];
+
+ /* parse standard options */
+ if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) != (char *)NULL)
+ {
+ tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+ }
+
+ maybe_run_child(&do_child_1_uclinux, "ndd", 1, &key_uclinux, &i_uclinux);
+ maybe_run_child(&do_child_2_uclinux, "nddd", 2, &key_uclinux,
+ &pid_uclinux, &child_process_uclinux);
+ maybe_run_child(&do_child_3_uclinux, "nddd", 3, &key_uclinux,
+ &rkid_uclinux, &child_process_uclinux);
+#endif
+
setup();
if (argc == 1 )
@@ -194,16 +227,24 @@
for (i = 0; i < nprocs; i++)
{
fflush(stdout);
- if ((pid = fork()) < 0)
+ if ((pid = FORK_OR_VFORK()) < 0)
{
- tst_resm(TFAIL, "\tFork failed (may be OK if under stress)");
- tst_exit();
+ tst_resm(TFAIL, "\tFork failed (may be OK if under stress)");
+ tst_exit();
}
/* Child does this */
if (pid == 0)
{
+#ifdef UCLINUX
+ if (self_exec(argv[0], "ndd", 1, keyarray[i], i) < 0)
+ {
+ tst_resm(TFAIL, "\tself_exec failed");
+ tst_exit();
+ }
+#else
procstat = 1;
exit( dotest(keyarray[i], i) );
+#endif
}
pidarray[i] = pid;
}
@@ -249,6 +290,53 @@
}
/*--------------------------------------------------------------------*/
+#ifdef UCLINUX
+void
+do_child_1_uclinux()
+{
+ procstat = 1;
+ exit(dotest(key_uclinux, i_uclinux));
+}
+
+void
+do_child_2_uclinux()
+{
+ procstat = 2;
+ exit(doreader(key_uclinux, pid_uclinux, child_process_uclinux));
+}
+
+void
+do_child_3_uclinux()
+{
+ procstat = 2;
+ exit(dowriter(key_uclinux, rkid_uclinux, child_process_uclinux));
+}
+#endif
+
+void
+cleanup_msgqueue(int i, int tid)
+{
+ /*
+ * Decrease the value of i by 1 because it
+ * is getting incremented even if the fork
+ * is failing.
+ */
+
+ i--;
+ /*
+ * Kill all children & free message queue.
+ */
+ for (; i >= 0; i--) {
+ (void)kill(rkidarray[i], SIGKILL);
+ (void)kill(wkidarray[i], SIGKILL);
+ }
+
+ if (msgctl(tid, IPC_RMID, 0) < 0) {
+ tst_resm(TFAIL, "\tMsgctl error in cleanup, errno = %d\n", errno);
+ tst_exit();
+ }
+}
+
int dotest(key, child_process)
key_t key;
int child_process;
@@ -270,41 +358,30 @@
for (i=0; i < nkids; i++)
{
fflush(stdout);
- if ((pid = fork()) < 0)
+ if ((pid = FORK_OR_VFORK()) < 0)
{
tst_resm(TWARN, "\tFork failure in first child of child group %d \n", child_process);
-
- /*
- * Decrease the value of i by 1 because it
- * is getting incremented even if the fork
- * is failing.
- */
-
- i--;
- /*
- * Kill all children & free message queue.
- */
- for (; i >= 0; i--) {
- (void)kill(rkidarray[i], SIGKILL);
- (void)kill(wkidarray[i], SIGKILL);
- }
-
- if (msgctl(tid, IPC_RMID, 0) < 0) {
- tst_resm(TFAIL, "\tMsgctl error in cleanup, errno = %d\n", errno);
- tst_exit();
- }
- tst_exit();
-
+ cleanup_msgqueue(i, tid);
+ tst_exit();
}
/* First child does this */
if (pid == 0)
{
+#ifdef UCLINUX
+ if (self_exec(argv0, "nddd", 2, key, getpid(),
+ child_process) < 0) {
+ tst_resm(TWARN, "self_exec failed");
+ cleanup_msgqueue(i, tid);
+ tst_exit();
+ }
+#else
procstat = 2;
exit( doreader( key, getpid(), child_process) );
+#endif
}
rkidarray[i] = pid;
fflush(stdout);
- if ((pid = fork()) < 0)
+ if ((pid = FORK_OR_VFORK()) < 0)
{
tst_resm(TWARN, "\tFork failure in first child of child group %d \n", child_process);
/*
@@ -312,32 +389,29 @@
*/
(void)kill(rkidarray[i], SIGKILL);
- /*
- * Decrease the value of i by 1 because it
- * is getting incremented even if the fork
- * is failing.
- */
-
- i--;
- /*
- * Kill all children & free message queue.
- */
- for (; i >= 0; i--) {
- (void)kill(rkidarray[i], SIGKILL);
- (void)kill(wkidarray[i], SIGKILL);
- }
- if (msgctl(tid, IPC_RMID, 0) < 0) {
- tst_resm(TFAIL, "\tMsgctl error in cleanup, errno = %d\n", errno);
- tst_exit();
- }
+ cleanup_msgqueue(i, tid);
tst_exit();
-
}
/* Second child does this */
if (pid == 0)
{
+#ifdef UCLINUX
+ if (self_exec(argv0, "nddd", 3, key, rkidarray[i],
+ child_process) < 0) {
+ tst_resm(TWARN, "\tFork failure in first child "
+ "of child group %d \n", child_process);
+ /*
+ * Kill the reader child process
+ */
+ (void)kill(rkidarray[i], SIGKILL);
+
+ cleanup_msgqueue(i, tid);
+ tst_exit();
+ }
+#else
procstat = 2;
exit( dowriter( key, rkidarray[i], child_process) );
+#endif
}
wkidarray[i] = pid;
}
diff --git a/testcases/kernel/syscalls/ipc/msgget/Makefile b/testcases/kernel/syscalls/ipc/msgget/Makefile
index 6f58ab9..6f2e56e 100644
--- a/testcases/kernel/syscalls/ipc/msgget/Makefile
+++ b/testcases/kernel/syscalls/ipc/msgget/Makefile
@@ -24,7 +24,9 @@
SRCS=$(MAINS:=.c)
OBJS=$(MAINS:=.o)
LOADLIBES+=-L../../../../../lib -lltp -L.. -lipc
+LOADLIBES+= $(if $(UCLINUX),-lc)
CFLAGS+=-I../lib -I../../../../../include -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
all: $& $(MAINS)
diff --git a/testcases/kernel/syscalls/ipc/msgrcv/Makefile b/testcases/kernel/syscalls/ipc/msgrcv/Makefile
index e379d7f..d5a011d 100644
--- a/testcases/kernel/syscalls/ipc/msgrcv/Makefile
+++ b/testcases/kernel/syscalls/ipc/msgrcv/Makefile
@@ -24,7 +24,9 @@
SRCS=$(MAINS:=.c)
OBJS=$(MAINS:=.o)
CFLAGS+=-I../lib -I../../../../../include -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+=-L../../../../../lib -lltp -L.. -lipc
+LOADLIBES+= $(if $(UCLINUX),-lc)
all: $& $(MAINS)
diff --git a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv01.c b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv01.c
index 1dfaaed..66c92d0 100644
--- a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv01.c
+++ b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv01.c
@@ -67,6 +67,7 @@
void cleanup(void);
void setup(void);
+void do_child(void);
char *TCID = "msgrcv01";
int TST_TOTAL = 1;
@@ -82,7 +83,7 @@
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
void check_functionality(void);
- int retval = 0, status, e_code;
+ int status, e_code;
/* parse standard options */
if ((msg =
@@ -90,6 +91,10 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "d", &msg_q_1);
+#endif
+
setup(); /* global setup */
/* The following loop checks looping state if -i option given */
@@ -102,38 +107,18 @@
* fork a child to read from the queue while the parent
* enqueues the message to be read.
*/
- if ((c_pid = fork()) == -1) {
+ if ((c_pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "could not fork");
}
if (c_pid == 0) { /* child */
- TEST(msgrcv(msg_q_1, &rcv_buf, MSGSIZE, 1, 0));
-
- if (TEST_RETURN == -1) {
- retval = 1;
- tst_resm(TFAIL, "%s call failed - errno = %d : %s",
- TCID, TEST_ERRNO, strerror(TEST_ERRNO));
- } else {
- if (STD_FUNCTIONAL_TEST) {
- /*
- * Build a new message and compare it
- * with the one received.
- */
- init_buf(&cmp_buf, MSGTYPE, MSGSIZE);
-
- if (strcmp(rcv_buf.mtext, cmp_buf.mtext) == 0) {
- tst_resm(TPASS,
- "message received = " "message sent");
- } else {
- retval = 1;
- tst_resm(TFAIL,
- "message received != " "message sent");
- }
- } else {
- tst_resm(TPASS, "call succeeded");
- }
+#ifdef UCLINUX
+ if (self_exec(av[0], "d", msg_q_1) < 0) {
+ tst_brkm(TBROK, cleanup, "could not self_exec");
}
- exit(retval);
+#else
+ do_child();
+#endif
} else { /* parent */
/* put the message on the queue */
if (msgsnd(msg_q_1, &snd_buf, MSGSIZE, 0) == -1) {
@@ -158,6 +143,43 @@
}
/*
+ * do_child()
+ */
+void
+do_child()
+{
+ int retval = 0;
+
+ TEST(msgrcv(msg_q_1, &rcv_buf, MSGSIZE, 1, 0));
+
+ if (TEST_RETURN == -1) {
+ retval = 1;
+ tst_resm(TFAIL, "%s call failed - errno = %d : %s",
+ TCID, TEST_ERRNO, strerror(TEST_ERRNO));
+ } else {
+ if (STD_FUNCTIONAL_TEST) {
+ /*
+ * Build a new message and compare it
+ * with the one received.
+ */
+ init_buf(&cmp_buf, MSGTYPE, MSGSIZE);
+
+ if (strcmp(rcv_buf.mtext, cmp_buf.mtext) == 0) {
+ tst_resm(TPASS,
+ "message received = " "message sent");
+ } else {
+ retval = 1;
+ tst_resm(TFAIL,
+ "message received != " "message sent");
+ }
+ } else {
+ tst_resm(TPASS, "call succeeded");
+ }
+ }
+ exit(retval);
+}
+
+/*
* setup() - performs all the ONE TIME setup for this test.
*/
void setup(void)
diff --git a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c
index 4d7fb56..ad15397 100644
--- a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c
+++ b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c
@@ -28,12 +28,12 @@
* create a message queue with read/write permissions
* loop if that option was specified
* fork a child who attempts to read a non-existent message with msgrcv()
- * parent sends a SIGHUP to the child, then exits
+ * parent sends a SIGHUP to the child, then waits for the child to complete
* check the errno value
* issue a PASS message if we get EINTR
* otherwise, the tests fails
* issue a FAIL message
- * call cleanup
+ * child exits, parent calls cleanup
*
* USAGE: <for command-line>
* msgrcv05 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
@@ -56,9 +56,16 @@
#include "ipcmsg.h"
+#include <sys/types.h>
+#include <sys/wait.h>
+
+void do_child(void);
void cleanup(void);
void setup(void);
void sighandler(int);
+#ifdef UCLINUX
+void do_child_uclinux(void);
+#endif
char *TCID = "msgrcv05";
int TST_TOTAL = 1;
@@ -81,6 +88,10 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child_uclinux, "d", &msg_q_1);
+#endif
+
setup(); /* global setup */
/* The following loop checks looping state if -i option given */
@@ -93,7 +104,7 @@
* fork a child that will attempt to read a non-existent
* message from the queue
*/
- if ((c_pid = fork()) == -1) {
+ if ((c_pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "could not fork");
}
@@ -102,7 +113,13 @@
* Attempt to read a message without IPC_NOWAIT.
* With no message to read, the child sleeps.
*/
- TEST(msgrcv(msg_q_1, &rcv_buf, MSGSIZE, 1, 0));
+#ifdef UCLINUX
+ if (self_exec(av[0], "d", msg_q_1) < 0) {
+ tst_brkm(TBROK, cleanup, "could not self_exec");
+ }
+#else
+ do_child();
+#endif
} else { /* parent */
usleep(250000);
@@ -111,30 +128,8 @@
tst_brkm(TBROK, cleanup, "kill failed");
}
- /* let the child carry on */
- exit(0);
+ waitpid(c_pid, NULL, 0);
}
-
-
- if (TEST_RETURN != -1) {
- tst_resm(TFAIL, "call succeeded when error expected");
- continue;
- }
-
- TEST_ERROR_LOG(TEST_ERRNO);
-
- switch(TEST_ERRNO) {
- case EINTR:
- tst_resm(TPASS, "expected failure - errno = "
- "%d : %s", TEST_ERRNO,
- strerror(TEST_ERRNO));
- break;
- default:
- tst_resm(TFAIL, "call failed with an "
- "unexpected error - %d : %s",
- TEST_ERRNO, strerror(TEST_ERRNO));
- break;
- }
}
cleanup();
@@ -144,6 +139,48 @@
}
/*
+ * do_child()
+ */
+void
+do_child()
+{
+ TEST(msgrcv(msg_q_1, &rcv_buf, MSGSIZE, 1, 0));
+
+ if (TEST_RETURN != -1) {
+ tst_resm(TFAIL, "call succeeded when error expected");
+ exit(-1);
+ }
+
+ TEST_ERROR_LOG(TEST_ERRNO);
+
+ switch(TEST_ERRNO) {
+ case EINTR:
+ tst_resm(TPASS, "expected failure - errno = %d : %s", TEST_ERRNO,
+ strerror(TEST_ERRNO));
+ break;
+ default:
+ tst_resm(TFAIL, "call failed with an unexpected error - %d : %s",
+ TEST_ERRNO, strerror(TEST_ERRNO));
+ break;
+ }
+
+ exit(0);
+}
+
+#ifdef UCLINUX
+/*
+ * do_child_uclinux() - capture signals again, then run do_child()
+ */
+void
+do_child_uclinux()
+{
+ tst_sig(FORK, sighandler, cleanup);
+
+ do_child();
+}
+#endif
+
+/*
* sighandler() - handle signals
*/
void
diff --git a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c
index 5f34c0e..e5a1f62 100644
--- a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c
+++ b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c
@@ -28,12 +28,13 @@
* loop if that option was specified
* create a message queue with read/write permissions
* fork a child who sleeps on an attempted read with msgrcv()
- * parent removes the queue then exits
+ * parent removes the queue then waits for child to complete
* check the errno value
* issue a PASS message if we get EIDRM
* otherwise, the tests fails
* issue a FAIL message
- * call cleanup
+ * child removes message queue if required
+ * parent callc cleanup
*
* USAGE: <for command-line>
* msgrcv06 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
@@ -56,9 +57,16 @@
#include "ipcmsg.h"
+#include <sys/types.h>
+#include <sys/wait.h>
+
+void do_child(void);
void cleanup(void);
void setup(void);
void sighandler(int);
+#ifdef UCLINUX
+void do_child_uclinux(void);
+#endif
char *TCID = "msgrcv06";
int TST_TOTAL = 1;
@@ -81,6 +89,10 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child_uclinux, "d", &msg_q_1);
+#endif
+
setup(); /* global setup */
/* The following loop checks looping state if -i option given */
@@ -105,7 +117,7 @@
* fork a child that will attempt to read a non-existent
* message from the queue
*/
- if ((c_pid = fork()) == -1) {
+ if ((c_pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "could not fork");
}
@@ -114,49 +126,76 @@
* Attempt to read a message without IPC_NOWAIT.
* With no message to read, the child sleeps.
*/
- TEST(msgrcv(msg_q_1, &rcv_buf, MSGSIZE, 1, 0));
-
+#ifdef UCLINUX
+ if (self_exec(av[0], "d", msg_q_1) < 0) {
+ tst_brkm(TBROK, cleanup, "could not self_exec");
+ }
+#else
+ do_child();
+#endif
} else { /* parent */
usleep(250000);
/* remove the queue */
rm_queue(msg_q_1);
- /* let the child carry on */
- exit(0);
+ waitpid(c_pid, NULL, 0);
}
-
- if (TEST_RETURN != -1) {
- tst_resm(TFAIL, "call succeeded when error expected");
- continue;
- }
-
- TEST_ERROR_LOG(TEST_ERRNO);
-
- switch(TEST_ERRNO) {
- case EIDRM:
- tst_resm(TPASS, "expected failure - errno = "
- "%d : %s", TEST_ERRNO,
- strerror(TEST_ERRNO));
-
- /* mark the queue as invalid as it was removed */
- msg_q_1 = -1;
- break;
- default:
- tst_resm(TFAIL, "call failed with an "
- "unexpected error - %d : %s",
- TEST_ERRNO, strerror(TEST_ERRNO));
- break;
- }
}
- cleanup();
-
/*NOTREACHED*/
return(0);
}
/*
+ * do_child()
+ */
+void
+do_child()
+{
+ TEST(msgrcv(msg_q_1, &rcv_buf, MSGSIZE, 1, 0));
+
+ if (TEST_RETURN != -1) {
+ tst_resm(TFAIL, "call succeeded when error expected");
+ exit(-1);
+ }
+
+ TEST_ERROR_LOG(TEST_ERRNO);
+
+ switch(TEST_ERRNO) {
+ case EIDRM:
+ tst_resm(TPASS, "expected failure - errno = %d : %s", TEST_ERRNO,
+ strerror(TEST_ERRNO));
+
+ /* mark the queue as invalid as it was removed */
+ msg_q_1 = -1;
+ break;
+ default:
+ tst_resm(TFAIL, "call failed with an unexpected error - %d : %s",
+ TEST_ERRNO, strerror(TEST_ERRNO));
+ break;
+ }
+
+ /* if it exists, remove the message queue that was created */
+ rm_queue(msg_q_1);
+
+ exit(0);
+}
+
+#ifdef UCLINUX
+/*
+ * do_child_uclinux() - capture signals again, then run do_child()
+ */
+void
+do_child_uclinux()
+{
+ tst_sig(FORK, sighandler, cleanup);
+
+ do_child();
+}
+#endif
+
+/*
* sighandler() - handle signals
*/
void
@@ -195,9 +234,6 @@
void
cleanup(void)
{
- /* if it exists, remove the message queue that was created */
- rm_queue(msg_q_1);
-
/* Remove the temporary directory */
tst_rmdir();
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/Makefile b/testcases/kernel/syscalls/ipc/msgsnd/Makefile
index c3832ea..c32c24b 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/Makefile
+++ b/testcases/kernel/syscalls/ipc/msgsnd/Makefile
@@ -24,7 +24,9 @@
SRCS=$(MAINS:=.c)
OBJS=$(MAINS:=.o)
CFLAGS+=-I../lib -I../../../../../include -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+=-L../../../../../lib -lltp -L.. -lipc
+LOADLIBES+= $(if $(UCLINUX),-lc)
all: $& $(MAINS)
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
index c1bb7ea..eb0bb71 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
@@ -31,13 +31,13 @@
* loop if that option was specified
* fork a child process
* child attempts to enqueue a message to the full queue and sleeps
- * parent sends a SIGHUP to the child then exits
+ * parent sends a SIGHUP to the child then waits for the child to complete
* child get a return from msgsnd()
* check the errno value
* issue a PASS message if we get EINTR
* otherwise, the tests fails
* issue a FAIL message
- * call cleanup
+ * child exits, parent calls cleanup
*
* USAGE: <for command-line>
* msgsnd05 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
@@ -60,9 +60,16 @@
#include "ipcmsg.h"
+#include <sys/types.h>
+#include <sys/wait.h>
+
+void do_child(void);
void cleanup(void);
void setup(void);
void sighandler(int);
+#ifdef UCLINUX
+void do_child_uclinux(void);
+#endif
char *TCID = "msgsnd05";
int TST_TOTAL = 1;
@@ -84,6 +91,10 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child_uclinux, "d", &msg_q_1);
+#endif
+
setup(); /* global setup */
/* The following loop checks looping state if -i option given */
@@ -96,7 +107,7 @@
* fork a child that will attempt to write a message
* to the queue without IPC_NOWAIT
*/
- if ((c_pid = fork()) == -1) {
+ if ((c_pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "could not fork");
}
@@ -105,8 +116,13 @@
* Attempt to write another message to the full queue.
* Without the IPC_NOWAIT flag, the child sleeps
*/
- TEST(msgsnd(msg_q_1, &msg_buf, MSGSIZE, 0));
-
+#ifdef UCLINUX
+ if (self_exec(av[0], "d", msg_q_1) < 0) {
+ tst_brkm(TBROK, cleanup, "could not self_exec");
+ }
+#else
+ do_child();
+#endif
} else { /* parent */
usleep(250000);
@@ -115,27 +131,7 @@
tst_brkm(TBROK, cleanup, "kill failed");
}
- /* let the child carry on */
- exit(0);
- }
-
- if (TEST_RETURN != -1) {
- tst_resm(TFAIL, "call succeeded when error expected");
- continue;
- }
-
- TEST_ERROR_LOG(TEST_ERRNO);
-
- switch(TEST_ERRNO) {
- case EINTR:
- tst_resm(TPASS, "expected failure - errno = %d : %s",
- TEST_ERRNO, strerror(TEST_ERRNO));
- break;
- default:
- tst_resm(TFAIL, "call failed with an "
- "unexpected error - %d : %s",
- TEST_ERRNO, strerror(TEST_ERRNO));
- break;
+ waitpid(c_pid, NULL, 0);
}
}
@@ -146,6 +142,51 @@
}
/*
+ * do_child()
+ */
+void
+do_child()
+{
+ TEST(msgsnd(msg_q_1, &msg_buf, MSGSIZE, 0));
+
+ if (TEST_RETURN != -1) {
+ tst_resm(TFAIL, "call succeeded when error expected");
+ exit(-1);
+ }
+
+ TEST_ERROR_LOG(TEST_ERRNO);
+
+ switch(TEST_ERRNO) {
+ case EINTR:
+ tst_resm(TPASS, "expected failure - errno = %d : %s",
+ TEST_ERRNO, strerror(TEST_ERRNO));
+ break;
+ default:
+ tst_resm(TFAIL, "call failed with an unexpected error - %d : %s",
+ TEST_ERRNO, strerror(TEST_ERRNO));
+ break;
+ }
+
+ exit(0);
+}
+
+#ifdef UCLINUX
+/*
+ * do_child_uclinux() - capture signals, initialize buffer, then run do_child()
+ */
+void
+do_child_uclinux()
+{
+ /* initialize the message buffer */
+ init_buf(&msg_buf, MSGTYPE, MSGSIZE);
+
+ tst_sig(FORK, sighandler, cleanup);
+
+ do_child();
+}
+#endif
+
+/*
* sighandler() - handle signals
*/
void
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
index a9bd144..b7ed964 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
@@ -63,6 +63,7 @@
void cleanup(void);
void setup(void);
+void do_child(void);
char *TCID = "msgsnd06";
int TST_TOTAL = 1;
@@ -78,7 +79,7 @@
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
pid_t c_pid;
- int retval = 0, status, e_code;
+ int status, e_code;
/* parse standard options */
if ((msg =
@@ -86,6 +87,10 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "d", &msg_q_1);
+#endif
+
setup(); /* global setup */
/* The following loop checks looping state if -i option given */
@@ -114,41 +119,18 @@
* fork a child that will attempt to write a message
* to the queue without IPC_NOWAIT
*/
- if ((c_pid = fork()) == -1) {
+ if ((c_pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "could not fork");
}
if (c_pid == 0) { /* child */
- /*
- * Attempt to write another message to the full queue.
- * Without the IPC_NOWAIT flag, the child sleeps
- */
- TEST(msgsnd(msg_q_1, &msg_buf, MSGSIZE, 0));
-
- if (TEST_RETURN != -1) {
- retval = 1;
- tst_resm(TFAIL, "call succeeded when error expected");
- continue;
+#ifdef UCLINUX
+ if (self_exec(av[0], "d", msg_q_1) < 0) {
+ tst_brkm(TBROK, cleanup, "could not self_exec");
}
-
- TEST_ERROR_LOG(TEST_ERRNO);
-
- switch (TEST_ERRNO) {
- case EIDRM:
- tst_resm(TPASS, "expected failure - errno = %d : %s",
- TEST_ERRNO, strerror(TEST_ERRNO));
-
- /* mark the queue as invalid as it was removed */
- msg_q_1 = -1;
- break;
- default:
- retval = 1;
- tst_resm(TFAIL, "call failed with an "
- "unexpected error - %d : %s",
- TEST_ERRNO, strerror(TEST_ERRNO));
- break;
- }
- exit(retval);
+#else
+ do_child();
+#endif
} else { /* parent */
sleep(1);
/* remove the queue */
@@ -171,6 +153,50 @@
}
/*
+ * do_child()
+ */
+void
+do_child()
+{
+ int retval = 0;
+
+#ifdef UCLINUX
+ /* initialize the message buffer */
+ init_buf(&msg_buf, MSGTYPE, MSGSIZE);
+#endif
+
+ /*
+ * Attempt to write another message to the full queue.
+ * Without the IPC_NOWAIT flag, the child sleeps
+ */
+ TEST(msgsnd(msg_q_1, &msg_buf, MSGSIZE, 0));
+
+ if (TEST_RETURN != -1) {
+ retval = 1;
+ tst_resm(TFAIL, "call succeeded when error expected");
+ exit(retval);
+ }
+
+ TEST_ERROR_LOG(TEST_ERRNO);
+
+ switch (TEST_ERRNO) {
+ case EIDRM:
+ tst_resm(TPASS, "expected failure - errno = %d : %s",
+ TEST_ERRNO, strerror(TEST_ERRNO));
+
+ /* mark the queue as invalid as it was removed */
+ msg_q_1 = -1;
+ break;
+ default:
+ retval = 1;
+ tst_resm(TFAIL, "call failed with an unexpected error - %d : %s",
+ TEST_ERRNO, strerror(TEST_ERRNO));
+ break;
+ }
+ exit(retval);
+}
+
+/*
* setup() - performs all the ONE TIME setup for this test.
*/
void setup(void)
diff --git a/testcases/kernel/syscalls/ipc/semctl/Makefile b/testcases/kernel/syscalls/ipc/semctl/Makefile
index f02cd76..1b7c5c7 100644
--- a/testcases/kernel/syscalls/ipc/semctl/Makefile
+++ b/testcases/kernel/syscalls/ipc/semctl/Makefile
@@ -22,7 +22,9 @@
SRCS=$(wildcard *.c)
MAINS=$(patsubst %.c,%,$(SRCS))
CFLAGS+=-I../lib -I../../../../../include -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+=-L../../../../../lib -lltp -L.. -lipc
+LOADLIBES+= $(if $(UCLINUX),-lc)
all: $& $(MAINS)
diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl01.c b/testcases/kernel/syscalls/ipc/semctl/semctl01.c
index 724956e..a424db4 100644
--- a/testcases/kernel/syscalls/ipc/semctl/semctl01.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl01.c
@@ -78,6 +78,8 @@
void sall_setup(void), func_sall(void);
void func_sval(void);
void func_rmid(void);
+void child_cnt(void);
+void child_pid(void);
struct semid_ds buf;
unsigned short array[PSEMS];
@@ -92,6 +94,10 @@
int pid_arr[NCHILD];
+#ifdef UCLINUX
+static char *argv0;
+#endif
+
struct test_case_t {
int semnum; /* the primitive semaphore to use */
int cmd; /* the command to test */
@@ -131,6 +137,12 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ argv0 = av[0];
+ maybe_run_child(&child_pid, "nd", 1, &sem_id_1);
+ maybe_run_child(&child_cnt, "ndd", 2, &sem_id_1, &sops.sem_op);
+#endif
+
setup(); /* global setup */
/* The following loop checks looping state if -i option given */
@@ -322,22 +334,20 @@
for (i=0; i<NCHILD; i++) {
/* fork five children to wait */
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork failed in cnt_setup");
}
if (pid == 0) { /* child */
- /*
- * Do a semop that will cause the child to sleep.
- * The child process will be killed in the func_ncnt
- * routine which should cause an error to be return
- * by the semop() call.
- */
- if (semop(sem_id_1, &sops, 1) != -1) {
- tst_resm(TBROK, "semop succeeded - cnt_setup");
+#ifdef UCLINUX
+ if (self_exec(argv0, "ndd", 2, sem_id_1,
+ sops.sem_op) < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed "
+ "in cnt_setup");
}
- exit(0);
-
+#else
+ child_cnt();
+#endif
} else { /* parent */
/* take a quick nap so that commands execute orderly */
usleep(50000);
@@ -348,6 +358,24 @@
}
}
+void
+child_cnt()
+{
+ sops.sem_num = SEM4;
+ sops.sem_flg = 0;
+
+ /*
+ * Do a semop that will cause the child to sleep.
+ * The child process will be killed in the func_ncnt
+ * routine which should cause an error to be return
+ * by the semop() call.
+ */
+ if (semop(sem_id_1, &sops, 1) != -1) {
+ tst_resm(TBROK, "semop succeeded - cnt_setup");
+ }
+ exit(0);
+}
+
/*
* func_cnt() - check the functionality of the GETNCNT and GETZCNT commands
* with semctl()
@@ -371,27 +399,22 @@
{
int pid;
- sops.sem_num = SEM2; /* semaphore to change */
- sops.sem_op = ONE; /* operation is to increment semaphore */
- sops.sem_flg = 0;
-
/*
* Fork a child to do a semop that will pass.
*/
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork failed in pid_setup()");
}
-
+
if (pid == 0) { /* child */
-
- /*
- * Do a semop that will increment the semaphore.
- */
- if (semop(sem_id_1, &sops, 1) == -1) {
- tst_resm(TBROK, "semop failed - pid_setup");
+#ifdef UCLINUX
+ if (self_exec(argv0, "nd", 1, sem_id_1) < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed "
+ "in pid_setup()");
}
- exit(0);
-
+#else
+ child_pid();
+#endif
} else { /* parent */
/* take a quick nap so that commands execute orderly */
usleep(50000);
@@ -400,6 +423,22 @@
}
}
+void
+child_pid()
+{
+ sops.sem_num = SEM2; /* semaphore to change */
+ sops.sem_op = ONE; /* operation is to increment semaphore */
+ sops.sem_flg = 0;
+
+ /*
+ * Do a semop that will increment the semaphore.
+ */
+ if (semop(sem_id_1, &sops, 1) == -1) {
+ tst_resm(TBROK, "semop failed - pid_setup");
+ }
+ exit(0);
+}
+
/*
* func_pid() - check the functionality of the GETPID command with semctl()
*/
diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl04.c b/testcases/kernel/syscalls/ipc/semctl/semctl04.c
index 149502e..316701f 100644
--- a/testcases/kernel/syscalls/ipc/semctl/semctl04.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl04.c
@@ -88,7 +88,7 @@
setup(); /* global setup */
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "could not fork");
}
diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl06.c b/testcases/kernel/syscalls/ipc/semctl/semctl06.c
index e6475c5..dd920a6 100644
--- a/testcases/kernel/syscalls/ipc/semctl/semctl06.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl06.c
@@ -41,6 +41,11 @@
#define DEBUG 0
+#ifdef UCLINUX
+#define _GNU_SOURCE /* for asprintf */
+#include <stdio.h>
+#endif
+
#include <sys/types.h> /* needed for test */
#include <sys/ipc.h> /* needed for test */
#include <sys/sem.h> /* needed for test */
@@ -93,6 +98,13 @@
static void dosemas(int id);
static void dotest(key_t key);
+#ifdef UCLINUX
+static char *argv0;
+
+void do_child();
+static int id_uclinux;
+static char *maxsemstring;
+#endif
/*--------------------------------------------------------------*/
/*ARGSUSED*/
@@ -102,6 +114,16 @@
register int i, j, ok, pid;
int count, child, status, nwait;
+#ifdef UCLINUX
+ char *msg;
+ if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) != (char *)NULL){
+ tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+ }
+
+ argv0 = argv[0];
+ maybe_run_child(&do_child, "dS", &id_uclinux, &maxsemstring);
+#endif
+
prog = argv[0];
nwait = 0;
setup();
@@ -133,7 +155,7 @@
}
for (i = 0; i < NPROCS; i++) {
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
tst_resm(TFAIL, "\tFork failed (may be OK if under stress)");
tst_exit();
}
@@ -211,11 +233,28 @@
}
for (i = 0; i < NKIDS; i++) {
- if ((pid = fork()) < 0) {
- tst_resm(TFAIL, "\tfork failed");
+ if ((pid = FORK_OR_VFORK()) < 0) {
+ tst_resm(TFAIL, "\tfork failed");
}
if (pid == 0) {
+#ifdef UCLINUX
+ int j;
+ maxsemstring = "";
+ for (j = 0; j < NSEMS; j++) {
+ if (asprintf(&maxsemstring, "%s%s%d",
+ maxsemstring, (j ? ":" : ""),
+ maxsemvals[j]) < 0) {
+ tst_resm(TBROK, "Could not serialize "
+ "maxsemvals");
+ tst_exit();
+ }
+ }
+ if (self_exec(argv0, "dS", id, maxsemstring) < 0) {
+ tst_resm(TFAIL, "\tself_exec failed");
+ }
+#else
dosemas(id);
+#endif
}
if (pid > 0) {
kidarray[i] = pid;
@@ -277,6 +316,32 @@
exit(1);
}
+#ifdef UCLINUX
+void
+do_child()
+{
+ int i;
+ char *tok;
+ char *endptr;
+
+ tok = strtok(maxsemstring, ":");
+ for (i = 0; i < NSEMS; i++) {
+ if (strlen(tok) == 0) {
+ tst_resm(TBROK, "Invalid argument to -C option");
+ tst_exit();
+ }
+
+ maxsemvals[i] = strtol(tok, &endptr, 10);
+ if (*endptr != '\0') {
+ tst_resm(TBROK, "Invalid argument to -C option");
+ tst_exit();
+ }
+ tok = strtok(NULL, ":");
+ }
+
+ dosemas(id_uclinux);
+}
+#endif
static void
dosemas(int id)
@@ -286,6 +351,9 @@
srand(getpid());
for (i = 0; i < NREPS; i++) {
for (j = 0; j < NSEMS; j++) {
+ semops[j].sem_num = j;
+ semops[j].sem_flg = SEM_UNDO;
+
do {
semops[j].sem_op =
( - /*CASTOK*/(short)(rand() % (maxsemvals[j]/2)));
diff --git a/testcases/kernel/syscalls/ipc/semget/Makefile b/testcases/kernel/syscalls/ipc/semget/Makefile
index 1307f5f..fc13c7e 100644
--- a/testcases/kernel/syscalls/ipc/semget/Makefile
+++ b/testcases/kernel/syscalls/ipc/semget/Makefile
@@ -24,7 +24,9 @@
SRCS=$(MAINS:=.c)
OBJS=$(MAINS:=.o)
CFLAGS+=-I../../../../../include -Wall -g
+CFLAGS+=$(if $(UCLINUX),-DUCLINUX)
LOADLIBES+=-L../../../../../lib -lltp -L.. -lipc
+LOADLIBES+= $(if $(UCLINUX),-lc)
all: $& $(MAINS)
diff --git a/testcases/kernel/syscalls/ipc/semop/Makefile b/testcases/kernel/syscalls/ipc/semop/Makefile
index 966e003..9c2d01f 100644
--- a/testcases/kernel/syscalls/ipc/semop/Makefile
+++ b/testcases/kernel/syscalls/ipc/semop/Makefile
@@ -24,7 +24,9 @@
SRCS=$(MAINS:=.c)
OBJS=$(MAINS:=.o)
CFLAGS+=-I../lib -I../../../../../include -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+=-L../../../../../lib -lltp -L.. -lipc
+LOADLIBES+= $(if $(UCLINUX),-lc)
all: $& $(MAINS)
diff --git a/testcases/kernel/syscalls/ipc/semop/semop05.c b/testcases/kernel/syscalls/ipc/semop/semop05.c
index aea3951..ea35029 100644
--- a/testcases/kernel/syscalls/ipc/semop/semop05.c
+++ b/testcases/kernel/syscalls/ipc/semop/semop05.c
@@ -92,6 +92,11 @@
{{0}, -1, 0, 5, EINTR}
};
+#ifdef UCLINUX
+void do_child_uclinux();
+static int i_uclinux;
+#endif
+
int main(int ac, char **av)
{
int lc; /* loop counter */
@@ -105,6 +110,10 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child_uclinux, "dd", &i_uclinux, &sem_id_1);
+#endif
+
setup(); /* global setup */
/* The following loop checks looping state if -i option given */
@@ -131,7 +140,14 @@
}
if (pid == 0) { /* child */
+#ifdef UCLINUX
+ if (self_exec(av[0], "dd", i, sem_id_1) < 0) {
+ tst_brkm(TBROK, cleanup,
+ "could not self_exec");
+ }
+#else
do_child(i);
+#endif
} else { /* parent */
usleep(250000);
@@ -153,7 +169,6 @@
/* let the child carry on */
waitpid(pid,NULL,0);
- exit(0);
}
/*
@@ -191,19 +206,44 @@
if (TEST_RETURN != -1) {
tst_resm(TFAIL, "call succeeded when error expected");
- return;
+ exit(-1);
}
TEST_ERROR_LOG(TEST_ERRNO);
if (TEST_ERRNO == TC[i].error) {
- tst_resm(TPASS, "expected failure - errno = %d" " : %s", TEST_ERRNO, strerror(TEST_ERRNO));
+ tst_resm(TPASS, "expected failure - errno = %d"
+ " : %s", TEST_ERRNO, strerror(TEST_ERRNO));
} else {
tst_resm(TFAIL, "unexpected error - "
"%d : %s", TEST_ERRNO, strerror(TEST_ERRNO));
}
+
+ exit(0);
}
+#ifdef UCLINUX
+/*
+ * do_child_uclinux() - capture signals, re-initialize s_buf then call do_child
+ * with the appropriate argument
+ */
+void
+do_child_uclinux()
+{
+ int i = i_uclinux;
+
+ /* capture signals */
+ tst_sig(FORK, sighandler, cleanup);
+
+ /* initialize the s_buf buffer */
+ s_buf.sem_op = TC[i].op;
+ s_buf.sem_flg = TC[i].flg;
+ s_buf.sem_num = TC[i].num;
+
+ do_child(i);
+}
+#endif
+
/*
* sighandler() - handle signals
*/
diff --git a/testcases/kernel/syscalls/ipc/shmat/Makefile b/testcases/kernel/syscalls/ipc/shmat/Makefile
index 226ca61..22c0721 100644
--- a/testcases/kernel/syscalls/ipc/shmat/Makefile
+++ b/testcases/kernel/syscalls/ipc/shmat/Makefile
@@ -24,7 +24,9 @@
SRCS=$(MAINS:=.c)
OBJS=$(MAINS:=.o)
CFLAGS+=-I../lib -I../../../../../include -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+=-L../../../../../lib -lltp -L.. -lipc
+LOADLIBES+= $(if $(UCLINUX),-lc)
all: $& $(MAINS)
diff --git a/testcases/kernel/syscalls/ipc/shmat/shmat03.c b/testcases/kernel/syscalls/ipc/shmat/shmat03.c
index 034ffda..2d9f36b 100644
--- a/testcases/kernel/syscalls/ipc/shmat/shmat03.c
+++ b/testcases/kernel/syscalls/ipc/shmat/shmat03.c
@@ -84,7 +84,7 @@
setup(); /* global setup */
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "could not fork");
}
diff --git a/testcases/kernel/syscalls/ipc/shmctl/Makefile b/testcases/kernel/syscalls/ipc/shmctl/Makefile
index c1af973..72797b0 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/Makefile
+++ b/testcases/kernel/syscalls/ipc/shmctl/Makefile
@@ -24,7 +24,9 @@
SRCS=$(MAINS:=.c)
OBJS=$(MAINS:=.o)
CFLAGS+=-I ../lib -I../../../../../include -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+=-L../../../../../lib -lltp -L.. -lipc
+LOADLIBES+= $(if $(UCLINUX),-lc)
all: $& $(MAINS)
diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
index f763943..09fe61b 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
@@ -62,7 +62,11 @@
#include "ipcshm.h"
char *TCID = "shmctl01";
+#ifndef UCLINUX
int TST_TOTAL = 4;
+#else
+int TST_TOTAL = 3;
+#endif
extern int Tst_count;
int shm_id_1 = -1;
@@ -96,6 +100,9 @@
/* Check routine for IPC_RMID */
void func_rmid(void);
+/* Child function */
+void do_child(void);
+
struct test_case_t {
int cmd; /* the command to test */
void (*func_test)(); /* the test function */
@@ -104,7 +111,11 @@
{IPC_STAT, func_stat, stat_setup},
+#ifndef UCLINUX
+ /* The second test is not applicable to uClinux; shared memory segments
+ are detached on exec(), so cannot be passed to uClinux children. */
{IPC_STAT, func_stat, stat_setup},
+#endif
{IPC_SET, func_set, set_setup},
@@ -113,6 +124,12 @@
#define NEWMODE 0066
+#ifdef UCLINUX
+static char *argv0;
+#endif
+
+static int stat_i; /* Shared between do_child and stat_setup */
+
int main(int ac, char **av)
{
int lc; /* loop counter */
@@ -125,6 +142,11 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ argv0 = av[0];
+ maybe_run_child(do_child, "ddd", &stat_i, &stat_time, &shm_id_1);
+#endif
+
setup(); /* global setup */
/* The following loop checks looping state if -i option given */
@@ -227,8 +249,7 @@
void
stat_setup()
{
- int i, rval;
- void *test, *set_shmat();
+ void *set_shmat();
pid_t pid;
/*
@@ -245,34 +266,24 @@
set_shared = set_shmat();
}
- for (i=0; i<N_ATTACH; i++) {
+ for (stat_i=0; stat_i<N_ATTACH; stat_i++) {
if ((pid = fork()) == -1) {
tst_brkm(TBROK, cleanup, "could not fork");
}
if (pid == 0) { /* child */
-
- if (stat_time == FIRST) {
- test = set_shmat();
- } else {
- test = set_shared;
+#ifdef UCLINUX
+ if (self_exec(argv0, "ddd", stat_i, stat_time,
+ shm_id_1) < 0) {
+ tst_brkm(TBROK, cleanup, "could not self_exec");
}
-
- /* do an assignement for fun */
- *(int *)test = i;
-
- /* pause until we get a signal from stat_cleanup() */
- rval = pause();
-
- /* now we're back - detach the memory and exit */
- if (shmdt(test) == -1) {
- tst_resm(TBROK, "shmdt() failed - %d", errno);
- }
- tst_exit();
+#else
+ do_child();
+#endif
} else { /* parent */
/* save the child's pid for cleanup later */
- pid_arr[i] = pid;
+ pid_arr[stat_i] = pid;
}
}
/* sleep briefly to ensure correct execution order */
@@ -280,6 +291,34 @@
}
/*
+ * do_child
+ */
+void
+do_child()
+{
+ int rval;
+ void *test;
+
+ if (stat_time == FIRST) {
+ test = set_shmat();
+ } else {
+ test = set_shared;
+ }
+
+ /* do an assignement for fun */
+ *(int *)test = stat_i;
+
+ /* pause until we get a signal from stat_cleanup() */
+ rval = pause();
+
+ /* now we're back - detach the memory and exit */
+ if (shmdt(test) == -1) {
+ tst_resm(TBROK, "shmdt() failed - %d", errno);
+ }
+ tst_exit();
+}
+
+/*
* func_stat() - check the functionality of the IPC_STAT command with shmctl()
* by looking at the pid of the creator, the segement size,
* the number of attaches and the mode.
diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl03.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl03.c
index f5f7ed9..ce2fe4b 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl03.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl03.c
@@ -103,7 +103,7 @@
setup(); /* global setup */
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "could not fork");
}
diff --git a/testcases/kernel/syscalls/ipc/shmdt/Makefile b/testcases/kernel/syscalls/ipc/shmdt/Makefile
index e043466..92bf83b 100644
--- a/testcases/kernel/syscalls/ipc/shmdt/Makefile
+++ b/testcases/kernel/syscalls/ipc/shmdt/Makefile
@@ -24,7 +24,9 @@
SRCS=$(MAINS:=.c)
OBJS=$(MAINS:=.o)
CFLAGS+=-I../lib -I../../../../../include -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+=-L../../../../../lib -lltp -L.. -lipc
+LOADLIBES+= $(if $(UCLINUX),-lc)
all: $& $(MAINS)
diff --git a/testcases/kernel/syscalls/ipc/shmget/Makefile b/testcases/kernel/syscalls/ipc/shmget/Makefile
index 63b7846..9517e86 100644
--- a/testcases/kernel/syscalls/ipc/shmget/Makefile
+++ b/testcases/kernel/syscalls/ipc/shmget/Makefile
@@ -24,7 +24,9 @@
SRCS=$(MAINS:=.c)
OBJS=$(MAINS:=.o)
CFLAGS+=-I../lib -I../../../../../include -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+=-L../../../../../lib -lltp -L.. -lipc
+LOADLIBES+= $(if $(UCLINUX),-lc)
all: $& $(MAINS)
diff --git a/testcases/kernel/syscalls/ipc/shmget/shmget05.c b/testcases/kernel/syscalls/ipc/shmget/shmget05.c
index 0f3d5fb..8be6b74 100644
--- a/testcases/kernel/syscalls/ipc/shmget/shmget05.c
+++ b/testcases/kernel/syscalls/ipc/shmget/shmget05.c
@@ -84,7 +84,7 @@
setup(); /* global setup */
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "could not fork");
}
diff --git a/testcases/kernel/syscalls/kill/Makefile b/testcases/kernel/syscalls/kill/Makefile
index cc90624..28e9dc9 100644
--- a/testcases/kernel/syscalls/kill/Makefile
+++ b/testcases/kernel/syscalls/kill/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall -D_GNU_SOURCE
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp -L.. -ltestsuite -L../ipc -lipc
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/kill/kill01.c b/testcases/kernel/syscalls/kill/kill01.c
index 5099ebc..2586aec 100644
--- a/testcases/kernel/syscalls/kill/kill01.c
+++ b/testcases/kernel/syscalls/kill/kill01.c
@@ -64,6 +64,7 @@
void cleanup(void);
void setup(void);
+void do_child(void);
char *TCID= "kill01";
int TST_TOTAL = 1;
@@ -84,6 +85,10 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "");
+#endif
+
setup(); /* global setup */
/* The following loop checks looping state if -i option given */
@@ -93,13 +98,17 @@
Tst_count = 0;
status = 1;
exno = 1;
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0) {
tst_brkm(TBROK, cleanup, "Fork of child failed");
} else if (pid == 0) {
- pause();
- /*NOTREACHED*/
- exit(exno);
+#ifdef UCLINUX
+ if (self_exec(av[0], "") < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec of child failed");
+ }
+#else
+ do_child();
+#endif
} else {
TEST(kill(pid, TEST_SIG));
waitpid(pid, &status, 0);
@@ -121,7 +130,8 @@
tst_resm(TPASS, "received expected signal %d",
nsig);
} else {
- tst_resm(TFAIL, "expected signal %d received %d" ,TEST_SIG,nsig);
+ tst_resm(TFAIL, "expected signal %d received %d",
+ TEST_SIG,nsig);
}
} else {
tst_resm(TPASS, "call succeeded");
@@ -133,6 +143,18 @@
return(0);
}
+/*
+ * do_child()
+ */
+void
+do_child()
+{
+ int exno = 1;
+
+ pause();
+ /*NOTREACHED*/
+ exit(exno);
+}
/*
* setup() - performs all ONE TIME setup for this test
diff --git a/testcases/kernel/syscalls/kill/kill02.c b/testcases/kernel/syscalls/kill/kill02.c
index 1f50360..b41adaf 100644
--- a/testcases/kernel/syscalls/kill/kill02.c
+++ b/testcases/kernel/syscalls/kill/kill02.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: kill02.c,v 1.3 2005/06/15 15:47:04 robbiew Exp $ */
+/* $Id: kill02.c,v 1.4 2005/07/11 22:28:29 robbiew Exp $ */
/***********************************************************************************
OS Test - Silicon Graphics, Inc.
@@ -210,6 +210,12 @@
int exp_enos[]={0}; /* Array of expected errnos */
+#ifdef UCLINUX
+static char *argv0;
+void childA_rout_uclinux();
+void childB_rout_uclinux();
+#endif
+
/***********************************************************************
* MAIN
***********************************************************************/
@@ -232,6 +238,19 @@
tst_exit();
}
+#ifdef UCLINUX
+ /***************************************************************
+ * Save av[0], run child if needed
+ ***************************************************************/
+ argv0 = av[0];
+
+ maybe_run_child(&childA_rout_uclinux, "nd", 1, &pipeA_fd[1]);
+ maybe_run_child(&childB_rout_uclinux, "nd", 2, &pipeB_fd[1]);
+ maybe_run_child(&child1_rout, "ndddddd", 3, &pipe1_fd[1], &pipe2_fd[1],
+ &pipeA_fd[0], &pipeA_fd[1], &pipeB_fd[0], &pipeB_fd[1]);
+ maybe_run_child(&child2_rout, "nd", 4, &pipe2_fd[1]);
+#endif
+
/***************************************************************
* perform global setup for test
***************************************************************/
@@ -245,12 +264,12 @@
/* reset Tst_count in case we are looping. */
Tst_count=0;
- if ((pid1 = fork()) > 0)
+ if ((pid1 = FORK_OR_VFORK()) > 0)
{
/*
* This is the parent, fork again to create child 2.
*/
- if ((pid2 = fork()) > 0) {
+ if ((pid2 = FORK_OR_VFORK()) > 0) {
/*
* This is the parent.
*/
@@ -260,7 +279,17 @@
/*
* This is child 2.
*/
+#ifdef UCLINUX
+ if (self_exec(argv0, "nd", 4, pipe2_fd[1]) < 0) {
+ if (kill(pid1,SIGKILL) == -1 && errno != ESRCH) {
+ tst_resm(TWARN,"Child process may not have been killed.");
+ }
+ (void) sprintf(mesg,SYS_FAIL,"fork",errno,strerror(errno));
+ tst_brkm(TBROK,cleanup,mesg);
+ }
+#else
(void) child2_rout();
+#endif
}
else {
/*
@@ -278,7 +307,15 @@
/*
* This is child 1.
*/
+#ifdef UCLINUX
+ if (self_exec(argv0, "ndddddd", 3, pipe1_fd[1], pipe2_fd[1],
+ pipeA_fd[0], pipeA_fd[1], pipeB_fd[0], pipeB_fd[1]) < 0) {
+ (void) sprintf(mesg,SYS_FAIL,"self_exec",errno, strerror(errno));
+ tst_brkm(TBROK,cleanup,mesg);
+ }
+#else
(void) child1_rout();
+#endif
}
else {
/*
@@ -467,17 +504,25 @@
(void) write(pipe1_fd[1],CHAR_SET_FAILED,1);
exit(0);
}
-
/*
* Create children A & B.
*/
- if ((pidA = fork()) > 0) {
+ if ((pidA = FORK_OR_VFORK()) > 0) {
/*
* This is the parent(child1), fork again to create child B.
*/
- if ((pidB = fork()) == 0) {
+ if ((pidB = FORK_OR_VFORK()) == 0) {
/* This is child B. */
+#ifdef UCLINUX
+ if (self_exec(argv0, "nd", 2, pipeB_fd[1]) < 0) {
+ (void) sprintf(mesg,SYS_FAIL,"self_exec",errno,strerror(errno));
+ tst_brkm(TBROK,NULL,mesg);
+ (void) write(pipe1_fd[1],CHAR_SET_FAILED,1);
+ exit(0);
+ }
+#else
(void) childB_rout();
+#endif
}
else if (pidB == -1) {
@@ -495,7 +540,16 @@
else if (pidA == 0) {
/* This is child A. */
+#ifdef UCLINUX
+ if (self_exec(argv0, "nd", 1, pipeA_fd[1]) < 0) {
+ (void) sprintf(mesg,SYS_FAIL,"self_exec",errno,strerror(errno));
+ tst_brkm(TBROK,NULL,mesg);
+ (void) write(pipe1_fd[1],CHAR_SET_FAILED,1);
+ exit(0);
+ }
+#else
(void) childA_rout();
+#endif
}
@@ -625,6 +679,24 @@
exit(0);
} /*End of childA_rout*/
+#ifdef UCLINUX
+/*******************************************************************************
+ * This is the routine for child A after self_exec
+ ******************************************************************************/
+void childA_rout_uclinux()
+{
+ /* Setup the signal handler again */
+ if (signal(SIGUSR1,usr1_rout) == SIG_ERR)
+ {
+ tst_brkm(TBROK,NULL,"Could not set to catch the childrens signal.");
+ (void) write(pipeA_fd[1],CHAR_SET_FAILED,1);
+ exit(0);
+ }
+
+ childA_rout();
+}
+#endif
+
/*******************************************************************************
* This is the routine for child B, which should not receive the parents signal.
******************************************************************************/
@@ -648,6 +720,25 @@
exit(0);
}
+
+#ifdef UCLINUX
+/*******************************************************************************
+ * This is the routine for child B after self_exec
+ ******************************************************************************/
+void childB_rout_uclinux()
+{
+ /* Setup the signal handler again */
+ if (signal(SIGUSR1,usr1_rout) == SIG_ERR)
+ {
+ tst_brkm(TBROK,NULL,"Could not set to catch the childrens signal.");
+ (void) write(pipeB_fd[1],CHAR_SET_FAILED,1);
+ exit(0);
+ }
+
+ childB_rout();
+}
+#endif
+
/*******************************************************************************
* This routine sets up the interprocess communication pipes, signal handling,
diff --git a/testcases/kernel/syscalls/kill/kill03.c b/testcases/kernel/syscalls/kill/kill03.c
index 6c9d928..25360f3 100644
--- a/testcases/kernel/syscalls/kill/kill03.c
+++ b/testcases/kernel/syscalls/kill/kill03.c
@@ -64,6 +64,7 @@
void cleanup(void);
void setup(void);
+void do_child(void);
char *TCID= "kill03";
int TST_TOTAL = 1;
@@ -86,6 +87,10 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "");
+#endif
+
setup(); /* global setup */
TEST_EXP_ENOS(exp_enos);
@@ -97,13 +102,17 @@
Tst_count = 0;
status = 1;
exno = 1;
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0) {
tst_brkm(TBROK, cleanup, "Fork of child failed");
} else if (pid == 0) {
- pause();
- /*NOTREACHED*/
- exit(exno);
+#ifdef UCLINUX
+ if (self_exec(av[0], "") < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec of child failed");
+ }
+#else
+ do_child();
+#endif
} else {
TEST(kill(pid, TEST_SIG));
kill(pid, SIGKILL);
@@ -141,6 +150,18 @@
return(0);
}
+/*
+ * do_child()
+ */
+void
+do_child()
+{
+ int exno = 1;
+
+ pause();
+ /*NOTREACHED*/
+ exit(exno);
+}
/*
* setup() - performs all ONE TIME setup for this test
diff --git a/testcases/kernel/syscalls/kill/kill04.c b/testcases/kernel/syscalls/kill/kill04.c
index a4f7533..6330c7e 100644
--- a/testcases/kernel/syscalls/kill/kill04.c
+++ b/testcases/kernel/syscalls/kill/kill04.c
@@ -64,6 +64,7 @@
void cleanup(void);
void setup(void);
+void do_child(void);
char *TCID= "kill04";
int TST_TOTAL = 1;
@@ -86,6 +87,10 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "");
+#endif
+
setup(); /* global setup */
TEST_EXP_ENOS(exp_enos);
@@ -97,21 +102,30 @@
Tst_count = 0;
status = 1;
exno = 1;
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0) {
tst_brkm(TBROK, cleanup, "Fork failed");
} else if (pid == 0) {
- pause();
- /*NOTREACHED*/
- exit(exno);
+#ifdef UCLINUX
+ if (self_exec(av[0], "") < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec of child failed");
+ }
+#else
+ do_child();
+#endif
} else {
- fake_pid = fork();
+ fake_pid = FORK_OR_VFORK();
if (fake_pid < 0) {
tst_brkm(TBROK, cleanup, "Second fork failed");
} else if (fake_pid == 0) {
- pause();
- /*NOTREACHED*/
- exit(exno);
+#ifdef UCLINUX
+ if (self_exec(av[0], "") < 0) {
+ tst_brkm(TBROK, cleanup, "second self_exec "
+ "of child failed");
+ }
+#else
+ do_child();
+#endif
}
kill(fake_pid, TEST_SIG);
waitpid(fake_pid, &fake_status, 0);
@@ -152,6 +166,18 @@
return(0);
}
+/*
+ * do_child()
+ */
+void
+do_child()
+{
+ int exno = 1;
+
+ pause();
+ /*NOTREACHED*/
+ exit(exno);
+}
/*
* setup() - performs all ONE TIME setup for this test
diff --git a/testcases/kernel/syscalls/kill/kill05.c b/testcases/kernel/syscalls/kill/kill05.c
index 318b8d0..511e5f0 100644
--- a/testcases/kernel/syscalls/kill/kill05.c
+++ b/testcases/kernel/syscalls/kill/kill05.c
@@ -77,6 +77,7 @@
void cleanup(void);
void setup(void);
+void do_child(void);
char *TCID= "kill05";
int TST_TOTAL = 1;
@@ -95,7 +96,7 @@
{
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
- pid_t pid1, my_pid;
+ pid_t pid1;
int status;
char user1name[] = "nobody";
@@ -110,6 +111,10 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "");
+#endif
+
setup(); /* global setup */
ltpuser1 = my_getpwnam(user1name);
@@ -130,7 +135,7 @@
* different from this one.
*/
- pid1 = fork();
+ pid1 = FORK_OR_VFORK();
if (pid1 < 0) {
tst_brkm(TBROK, cleanup, "Fork failed");
@@ -140,14 +145,13 @@
if (setreuid(ltpuser1->pw_uid, ltpuser1->pw_uid) == -1){
tst_resm(TWARN, "setreuid failed in child");
}
- my_pid = getpid();
- while(1) {
- if (*flag == 1) {
- exit(0);
- } else {
- sleep (1);
- }
+#ifdef UCLINUX
+ if (self_exec(av[0], "") < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec of child failed");
}
+#else
+ do_child();
+#endif
} else { /* parent */
if (setreuid(ltpuser2->pw_uid,ltpuser2->pw_uid) == -1) {
tst_resm(TWARN, "seteuid failed in child");
@@ -192,6 +196,23 @@
return(0);
}
+/*
+ * do_child()
+ */
+void
+do_child()
+{
+ pid_t my_pid;
+
+ my_pid = getpid();
+ while(1) {
+ if (*flag == 1) {
+ exit(0);
+ } else {
+ sleep (1);
+ }
+ }
+}
/*
* setup() - performs all ONE TIME setup for this test
diff --git a/testcases/kernel/syscalls/kill/kill06.c b/testcases/kernel/syscalls/kill/kill06.c
index 8f26e40..c8c1858 100644
--- a/testcases/kernel/syscalls/kill/kill06.c
+++ b/testcases/kernel/syscalls/kill/kill06.c
@@ -65,6 +65,7 @@
void cleanup(void);
void setup(void);
+void do_child(void);
char *TCID= "kill06";
int TST_TOTAL = 1;
@@ -85,6 +86,10 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "");
+#endif
+
setup(); /* global setup */
/* The following loop checks looping state if -i option given */
@@ -98,21 +103,25 @@
/* Fork a process and set the process group so that */
/* it is different from this one. Fork 5 more children. */
- pid1 = fork();
+ pid1 = FORK_OR_VFORK();
if (pid1 < 0) {
tst_brkm(TBROK, cleanup, "Fork of first child failed");
} else if (pid1 == 0) {
setpgrp();
for (i = 0; i < 5; i++) {
- pid2 = fork();
+ pid2 = FORK_OR_VFORK();
if (pid2 < 0) {
tst_brkm(TBROK, cleanup, "Fork failed");
} else if (pid2 == 0) {
- sleep(299);
- /*NOTREACHED*/
- tst_resm(TINFO, "%d never recieved a"
- " signal", getpid());
- exit(exno);
+#ifdef UCLINUX
+ if (self_exec(av[0], "") < 0) {
+ tst_brkm(TBROK, cleanup,
+ "self_exec of "
+ "child failed");
+ }
+#else
+ do_child();
+#endif
}
}
/* Kill all processes in this process group */
@@ -154,6 +163,19 @@
return(0);
}
+/*
+ * do_child()
+ */
+void
+do_child()
+{
+ int exno = 1;
+
+ sleep(299);
+ /*NOTREACHED*/
+ tst_resm(TINFO, "%d never recieved a" " signal", getpid());
+ exit(exno);
+}
/*
* setup() - performs all ONE TIME setup for this test
diff --git a/testcases/kernel/syscalls/kill/kill07.c b/testcases/kernel/syscalls/kill/kill07.c
index 359ae5c..f99e35b 100644
--- a/testcases/kernel/syscalls/kill/kill07.c
+++ b/testcases/kernel/syscalls/kill/kill07.c
@@ -71,6 +71,7 @@
void cleanup(void);
void setup(void);
void sighandler(int sig);
+void do_child(void);
char *TCID= "kill07";
int TST_TOTAL = 1;
@@ -97,6 +98,10 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "");
+#endif
+
setup(); /* global setup */
/* The following loop checks looping state if -i option given */
@@ -126,15 +131,17 @@
/* setup the signal handler */
ret = sigaction(TEST_SIG, &my_act, &old_act);
-
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0) {
tst_brkm(TBROK, cleanup, "Fork of child failed");
} else if (pid == 0) {
- sleep(300);
- /*NOTREACHED*/
- tst_resm(TINFO, "Child never recieved a signal");
- exit(exno);
+#ifdef UCLINUX
+ if (self_exec(av[0], "") < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec of child failed");
+ }
+#else
+ do_child();
+#endif
} else {
/* sighandler should not catch this signal */
/* if it does flag will be set to 1 */
@@ -196,6 +203,20 @@
}
/*
+ * do_child()
+ */
+void
+do_child()
+{
+ int exno = 1;
+
+ sleep(300);
+ /*NOTREACHED*/
+ tst_resm(TINFO, "Child never recieved a signal");
+ exit(exno);
+}
+
+/*
* setup() - performs all ONE TIME setup for this test
*/
void
diff --git a/testcases/kernel/syscalls/kill/kill08.c b/testcases/kernel/syscalls/kill/kill08.c
index 0b3e7df..e5ed74b 100644
--- a/testcases/kernel/syscalls/kill/kill08.c
+++ b/testcases/kernel/syscalls/kill/kill08.c
@@ -65,6 +65,7 @@
void cleanup(void);
void setup(void);
+void do_child(void);
char *TCID= "kill08";
int TST_TOTAL = 1;
@@ -85,6 +86,10 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "");
+#endif
+
setup(); /* global setup */
/* The following loop checks looping state if -i option given */
@@ -98,7 +103,7 @@
/* Fork a process and set the process group so that */
/* it is different from this one. Fork 5 more children. */
- pid1 = fork();
+ pid1 = FORK_OR_VFORK();
if (pid1 < 0) {
tst_brkm(TBROK, cleanup, "Fork of first child failed");
} else if (pid1 == 0) {
@@ -108,9 +113,15 @@
if (pid2 < 0) {
tst_brkm(TBROK, cleanup, "Fork failed");
} else if (pid2 == 0) {
- pause();
- /*NOTREACHED*/
- exit(exno);
+#ifdef UCLINUX
+ if (self_exec(av[0], "") < 0) {
+ tst_brkm(TBROK, cleanup,
+ "self_exec of "
+ "child failed");
+ }
+#else
+ do_child();
+#endif
}
}
/* Kill all processes in this process group */
@@ -150,6 +161,18 @@
return(0);
}
+/*
+ * do_child()
+ */
+void
+do_child()
+{
+ int exno = 1;
+
+ pause();
+ /*NOTREACHED*/
+ exit(exno);
+}
/*
* setup() - performs all ONE TIME setup for this test
diff --git a/testcases/kernel/syscalls/kill/kill09.c b/testcases/kernel/syscalls/kill/kill09.c
index 8e5951d..ce6faca 100644
--- a/testcases/kernel/syscalls/kill/kill09.c
+++ b/testcases/kernel/syscalls/kill/kill09.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: kill09.c,v 1.3 2003/10/01 15:31:32 robbiew Exp $ */
+/* $Id: kill09.c,v 1.4 2005/07/11 22:28:29 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -122,8 +122,7 @@
void setup();
void cleanup();
void alarm_handler(int sig);
-
-
+void do_child();
char *TCID="kill09"; /* Test program identifier. */
@@ -147,6 +146,10 @@
tst_exit();
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "");
+#endif
+
/***************************************************************
* perform global setup for test
***************************************************************/
@@ -163,7 +166,7 @@
/* make a child process so we can kill it */
/* If we cannot fork => we cannot test kill, so break and exit */
- if ((fork_pid=fork()) == -1) {
+ if ((fork_pid=FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup,
"fork() Failure. errno=%d : %s",
errno, strerror(errno));
@@ -171,14 +174,13 @@
if (fork_pid == 0) {
/* CHILD */
- /*
- * Setup alarm signal if we don't get the signal to prevent this process
- * from hanging around forever.
- */
- signal(SIGALRM, alarm_handler);
- alarm(20);
- pause();
- exit(1);
+#ifdef UCLINUX
+ if (self_exec(av[0], "") < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec of child failed");
+ }
+#else
+ do_child();
+#endif
}
/* PARENT */
@@ -219,6 +221,22 @@
} /* End main */
/***************************************************************
+ * do_child()
+ ***************************************************************/
+void
+do_child()
+{
+ /*
+ * Setup alarm signal if we don't get the signal to prevent this process
+ * from hanging around forever.
+ */
+ signal(SIGALRM, alarm_handler);
+ alarm(20);
+ pause();
+ exit(1);
+}
+
+/***************************************************************
* setup() - performs all ONE TIME setup for this test.
***************************************************************/
void
diff --git a/testcases/kernel/syscalls/kill/kill11.c b/testcases/kernel/syscalls/kill/kill11.c
index f75b6b1..c6b03fc 100644
--- a/testcases/kernel/syscalls/kill/kill11.c
+++ b/testcases/kernel/syscalls/kill/kill11.c
@@ -58,6 +58,7 @@
FILE *temp;
int TST_TOTAL = 1;
extern int Tst_count;
+static int sig;
int anyfail();
int blenter();
@@ -65,6 +66,7 @@
void terror();
void fail_exit();
int forkfail();
+void do_child();
/***** ** ** *****/
@@ -74,12 +76,11 @@
/*--------------------------------------------------------------------*/
-int main() /***** BEGINNING OF MAIN. *****/
+int main(int argc, char **argv) /***** BEGINNING OF MAIN. *****/
{
- register int i;
int core;
int pid, npid;
- int sig, nsig, exno, nexno, status;
+ int nsig, exno, nexno, status;
/*SIGIOT is 6, but since linux doesn't have SIGEMT, just using
SIGIOT for place filling */
int signum[14];
@@ -90,6 +91,19 @@
signum[7]=SIGIOT; signum[8]=SIGFPE; signum[9]=SIGKILL;
signum[10]=SIGBUS; signum[11]=SIGSEGV; signum[12]=SIGSYS;
signum[13]=SIGPIPE; signum[14]=SIGALRM;
+
+#ifdef UCLINUX
+ char *msg;
+
+ /* parse standard options */
+ if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) != (char *)NULL){
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ }
+
+ maybe_run_child(&do_child, "dd", &temp, &sig);
+#endif
+
+
setup();
// tempdir(); /* move to new directory */
/*--------------------------------------------------------------------*/
@@ -111,7 +125,7 @@
fail_exit();
}
fflush(temp);
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0) {
forkfail();
@@ -122,11 +136,16 @@
* parent process a chance to kill it.
*/
if (pid == 0) {
- for (i=0; i < 180; i++)
- sleep(1);
- fprintf(temp, "\tChild missed sig %d\n", sig);
- fflush(temp);
- _exit(exno);
+#ifdef UCLINUX
+ if (self_exec(argv[0], "dd", temp, sig) < 0) {
+ tst_resm(TBROK, "self_exec FAILED - "
+ "terminating test.");
+ tst_exit();
+ return(0);
+ }
+#else
+ do_child();
+#endif
}
/*
@@ -216,8 +235,18 @@
return(0);
}
-
-
+void
+do_child()
+{
+ register int i;
+ int exno = 1;
+
+ for (i=0; i < 180; i++)
+ sleep(1);
+ fprintf(temp, "\tChild missed sig %d\n", sig);
+ fflush(temp);
+ _exit(exno);
+}
void setup()
{
diff --git a/testcases/kernel/syscalls/kill/kill12.c b/testcases/kernel/syscalls/kill/kill12.c
index 54bab01..2deafb9 100644
--- a/testcases/kernel/syscalls/kill/kill12.c
+++ b/testcases/kernel/syscalls/kill/kill12.c
@@ -64,6 +64,7 @@
FILE *temp;
int TST_TOTAL = 1;
extern int Tst_count;
+static int sig;
int anyfail();
int blenter();
@@ -73,6 +74,7 @@
void fail_exit();
void ok_exit();
int forkfail();
+void do_child();
/***** ** ** *****/
@@ -81,14 +83,25 @@
int chflag;
/*--------------------------------------------------------------------*/
-int main() /***** BEGINNING OF MAIN. *****/
+int main(int argc, char **argv) /***** BEGINNING OF MAIN. *****/
{
int pid, npid;
- int sig, nsig, exno, nexno, status;
+ int nsig, exno, nexno, status;
int ret_val = 0;
int core;
void chsig();
+#ifdef UCLINUX
+ char *msg;
+
+ /* parse standard options */
+ if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) != (char *)NULL){
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ }
+
+ maybe_run_child(&do_child, "dd", &temp, &sig);
+#endif
+
setup();
//tempdir(); /* move to new directory */ 12/20/2003
/*--------------------------------------------------------------------*/
@@ -105,18 +118,22 @@
fflush(temp);
chflag = 0;
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0) {
forkfail();
}
if (pid == 0) {
- sigset(sig, SIG_IGN); /* set to ignore signal */
- kill(getppid(), SIGCLD); /* tell parent we are ready */
- while (!chflag)
- sleep(1); /* wait for parent */
-
- exit(exno);
+#ifdef UCLINUX
+ if (self_exec(argv[0], "dd", temp, sig) < 0) {
+ tst_resm(TBROK, "self_exec FAILED - "
+ "terminating test.");
+ tst_exit();
+ return(0);
+ }
+#else
+ do_child();
+#endif
} else {
//fprintf(temp, "Testing signal %d\n", sig);
@@ -212,6 +229,25 @@
return(0);
}
+void
+do_child()
+{
+ int exno = 1;
+
+#ifdef UCLINUX
+ if (sigset(SIGCLD, chsig) == SIG_ERR) {
+ fprintf(temp, "\tsigset failed, errno = %d\n", errno);
+ fail_exit();
+ }
+#endif
+
+ sigset(sig, SIG_IGN); /* set to ignore signal */
+ kill(getppid(), SIGCLD); /* tell parent we are ready */
+ while (!chflag)
+ sleep(1); /* wait for parent */
+
+ exit(exno);
+}
void setup()
{
diff --git a/testcases/kernel/syscalls/lchown/Makefile b/testcases/kernel/syscalls/lchown/Makefile
index 5bada4e..ca85606 100644
--- a/testcases/kernel/syscalls/lchown/Makefile
+++ b/testcases/kernel/syscalls/lchown/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/lchown/lchown02.c b/testcases/kernel/syscalls/lchown/lchown02.c
index b574783..5c9b541 100644
--- a/testcases/kernel/syscalls/lchown/lchown02.c
+++ b/testcases/kernel/syscalls/lchown/lchown02.c
@@ -283,7 +283,8 @@
tst_brkm(TBROK, cleanup, "chmod() failed");
}
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/lib/Makefile b/testcases/kernel/syscalls/lib/Makefile
index c12b08e..04a7a60 100644
--- a/testcases/kernel/syscalls/lib/Makefile
+++ b/testcases/kernel/syscalls/lib/Makefile
@@ -23,6 +23,7 @@
###########################################################################
DIR=lib
CFLAGS+=-I../../../../include -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
SRC=libtestsuite.c
OBJS=$(SRC:.c=.o)
MAINS=../libtestsuite.a
diff --git a/testcases/kernel/syscalls/link/Makefile b/testcases/kernel/syscalls/link/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/link/Makefile
+++ b/testcases/kernel/syscalls/link/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/link/link04.c b/testcases/kernel/syscalls/link/link04.c
index 8a07162..0ec64cf 100644
--- a/testcases/kernel/syscalls/link/link04.c
+++ b/testcases/kernel/syscalls/link/link04.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: link04.c,v 1.2 2002/07/23 13:11:18 plars Exp $ */
+/* $Id: link04.c,v 1.3 2005/07/11 22:28:30 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -140,7 +140,9 @@
int filepath_setup();
int filepath2_setup();
char Longpathname[PATH_MAX+2];
+#if !defined(UCLINUX)
char High_address[64];
+#endif
int dir_setup();
struct test_case_t {
@@ -171,9 +173,10 @@
{ Longpathname, "pathname too long", "nefile", "nefile",
ENAMETOOLONG, longpath_setup, no_setup },
-
+#if !defined(UCLINUX)
{ High_address, "address beyond address space", "nefile", "nefile",
EFAULT, no_setup, no_setup },
+#endif
{ (char *)-1, "negative address", "nefile", "nefile",
EFAULT, no_setup, no_setup },
@@ -191,10 +194,10 @@
{ "regfile", "regfile", Longpathname, "pathname too long",
ENAMETOOLONG, no_setup, longpath_setup },
-
+#if !defined(UCLINUX)
{ "regfile", "regfile", High_address, "address beyond address space",
EFAULT, no_setup, no_setup },
-
+#endif
{ "regfile", "regfile", (char *)-1, "negative address",
EFAULT, no_setup, no_setup},
@@ -247,11 +250,13 @@
fname2 = Test_cases[ind].file2;
desc2 = Test_cases[ind].desc2;
+#if !defined(UCLINUX)
if ( fname1 == High_address )
fname1 = get_high_address();
if ( fname2 == High_address )
fname2 = get_high_address();
+#endif
/*
* Call link(2)
@@ -306,7 +311,8 @@
/* make a temp directory and cd to it */
tst_tmpdir();
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/listen/Makefile b/testcases/kernel/syscalls/listen/Makefile
index 8aba9d6..4fd3d3e 100644
--- a/testcases/kernel/syscalls/listen/Makefile
+++ b/testcases/kernel/syscalls/listen/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp -Wall
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/llseek/Makefile b/testcases/kernel/syscalls/llseek/Makefile
index 8ce81e6..37eee4e 100644
--- a/testcases/kernel/syscalls/llseek/Makefile
+++ b/testcases/kernel/syscalls/llseek/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -D_GNU_SOURCE -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/lseek/Makefile b/testcases/kernel/syscalls/lseek/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/lseek/Makefile
+++ b/testcases/kernel/syscalls/lseek/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/lstat/Makefile b/testcases/kernel/syscalls/lstat/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/lstat/Makefile
+++ b/testcases/kernel/syscalls/lstat/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/lstat/lstat02.c b/testcases/kernel/syscalls/lstat/lstat02.c
index 3f7f9bd..71f22e2 100644
--- a/testcases/kernel/syscalls/lstat/lstat02.c
+++ b/testcases/kernel/syscalls/lstat/lstat02.c
@@ -103,7 +103,10 @@
int longpath_setup(); /* setup function to test chmod for ENAMETOOLONG */
char Longpathname[PATH_MAX+2];
+
+#if !defined(UCLINUX)
char High_address_node[64];
+#endif /* if !defined(UCLINUX) */
struct test_case_t { /* test case struct. to hold ref. test cond's*/
char *pathname;
@@ -112,7 +115,9 @@
int (*setupfunc)();
} Test_cases[] = {
{ SFILE1, "No Search permissions to process", EACCES, setup1 },
+#if !defined(UCLINUX)
{ High_address_node, "Address beyond address space", EFAULT, no_setup },
+#endif
{ (char *)-1, "Negative address", EFAULT, no_setup },
{ Longpathname, "Pathname too long", ENAMETOOLONG, longpath_setup },
{ "", "Pathname is empty", ENOENT, no_setup },
@@ -168,9 +173,11 @@
file_name = Test_cases[ind].pathname;
test_desc = Test_cases[ind].desc;
+#if !defined(UCLINUX)
if (file_name == High_address_node) {
file_name = (char *)get_high_address();
}
+#endif
/*
* Call lstat(2) to test different test conditions.
@@ -241,7 +248,8 @@
/* Make a temp dir and cd to it */
tst_tmpdir();
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/madvise/Makefile b/testcases/kernel/syscalls/madvise/Makefile
index 3eae260..ec20258 100644
--- a/testcases/kernel/syscalls/madvise/Makefile
+++ b/testcases/kernel/syscalls/madvise/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/madvise/madvise02.c b/testcases/kernel/syscalls/madvise/madvise02.c
index 303d266..566762e 100644
--- a/testcases/kernel/syscalls/madvise/madvise02.c
+++ b/testcases/kernel/syscalls/madvise/madvise02.c
@@ -207,6 +207,7 @@
TEST(madvise(file,stat.st_size,1212));
check_and_print(EINVAL);
+#if !defined(UCLINUX)
/* Test Case 3 */
if(mlock((void *)file,stat.st_size)<0) {
tst_brkm(TBROK, cleanup, "Error in getting memory "
@@ -220,6 +221,7 @@
tst_brkm(TBROK, cleanup, "Error %d in munmap : %s",
errno, strerror(errno));
}
+#endif /* if !defined(UCLINUX) */
/* Test Case 4 */
if ((file = (char *) mmap (NULL, stat.st_size, PROT_READ, MAP_SHARED, fd, 0)) == (char *)-1) {
diff --git a/testcases/kernel/syscalls/mallopt/Makefile b/testcases/kernel/syscalls/mallopt/Makefile
index 3eae260..ec20258 100644
--- a/testcases/kernel/syscalls/mallopt/Makefile
+++ b/testcases/kernel/syscalls/mallopt/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/mallopt/mallopt01.c b/testcases/kernel/syscalls/mallopt/mallopt01.c
index 615b80d..10e108b 100644
--- a/testcases/kernel/syscalls/mallopt/mallopt01.c
+++ b/testcases/kernel/syscalls/mallopt/mallopt01.c
@@ -57,6 +57,8 @@
/***** * * *****/
struct mallinfo info;
+#if !defined(UCLINUX)
+
/*--------------------------------------------------------------*/
int main (int argc, char *argv[])
{
@@ -134,6 +136,14 @@
fprintf(temp, "mallinfo.keepcost = %d\n", info.keepcost);
}
+#else
+int main()
+{
+ tst_resm(TINFO,"mallopt01 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
diff --git a/testcases/kernel/syscalls/memcmp/Makefile b/testcases/kernel/syscalls/memcmp/Makefile
index 3eae260..ec20258 100644
--- a/testcases/kernel/syscalls/memcmp/Makefile
+++ b/testcases/kernel/syscalls/memcmp/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/memcpy/Makefile b/testcases/kernel/syscalls/memcpy/Makefile
index 3eae260..ec20258 100644
--- a/testcases/kernel/syscalls/memcpy/Makefile
+++ b/testcases/kernel/syscalls/memcpy/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/memset/Makefile b/testcases/kernel/syscalls/memset/Makefile
index 3eae260..ec20258 100644
--- a/testcases/kernel/syscalls/memset/Makefile
+++ b/testcases/kernel/syscalls/memset/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/mincore/Makefile b/testcases/kernel/syscalls/mincore/Makefile
index 3eae260..ec20258 100644
--- a/testcases/kernel/syscalls/mincore/Makefile
+++ b/testcases/kernel/syscalls/mincore/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/mincore/mincore01.c b/testcases/kernel/syscalls/mincore/mincore01.c
index 3f2e71d..d3263b4 100644
--- a/testcases/kernel/syscalls/mincore/mincore01.c
+++ b/testcases/kernel/syscalls/mincore/mincore01.c
@@ -89,6 +89,8 @@
static int global_len = 0;
static int file_desc = 0;
+#if !defined(UCLINUX)
+
static struct test_case_t {
char *addr;
int len;
@@ -276,3 +278,13 @@
/* exit with return code appropriate for results */
tst_exit();
}
+
+#else
+
+int main()
+{
+ tst_resm(TINFO,"mincore01 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
diff --git a/testcases/kernel/syscalls/mincore/mincore02.c b/testcases/kernel/syscalls/mincore/mincore02.c
index 13b96bb..4ea9516 100644
--- a/testcases/kernel/syscalls/mincore/mincore02.c
+++ b/testcases/kernel/syscalls/mincore/mincore02.c
@@ -75,6 +75,8 @@
static int num_pages = 4; /* four pages are used in this test */
static char * vec=NULL;
+#if !defined(UCLINUX)
+
static char tmpfilename[] = "fooXXXXXX";
/* Extern Global Functions */
@@ -200,3 +202,13 @@
cleanup();
return 0;
}
+
+#else
+
+int main()
+{
+ tst_resm(TINFO,"mincore02 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
diff --git a/testcases/kernel/syscalls/mkdir/Makefile b/testcases/kernel/syscalls/mkdir/Makefile
index 15f9d40..5b561a0 100644
--- a/testcases/kernel/syscalls/mkdir/Makefile
+++ b/testcases/kernel/syscalls/mkdir/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp -L.. -ltestsuite
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/mkdir/mkdir01.c b/testcases/kernel/syscalls/mkdir/mkdir01.c
index b0db10d..ccb9717 100644
--- a/testcases/kernel/syscalls/mkdir/mkdir01.c
+++ b/testcases/kernel/syscalls/mkdir/mkdir01.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: mkdir01.c,v 1.2 2002/07/23 13:11:18 plars Exp $ */
+/* $Id: mkdir01.c,v 1.3 2005/07/11 22:28:47 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -117,7 +117,9 @@
void cleanup();
+#if !defined(UCLINUX)
char *get_high_address();
+#endif
char *TCID="mkdir01"; /* Test program identifier. */
int TST_TOTAL=2; /* Total number of test cases. */
@@ -187,7 +189,7 @@
}
}
-
+#if !defined(UCLINUX)
/*
* TEST CASE: 2
* mkdir() call with pointer above allocated address space.
@@ -218,6 +220,7 @@
}
}
+#endif /* if !defined(UCLINUX) */
} /* End for TEST_LOOPING */
@@ -244,7 +247,8 @@
/* Create a temporary directory and make it current. */
tst_tmpdir();
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/mkdir/mkdir02.c b/testcases/kernel/syscalls/mkdir/mkdir02.c
index cd39579..7b15c9b 100644
--- a/testcases/kernel/syscalls/mkdir/mkdir02.c
+++ b/testcases/kernel/syscalls/mkdir/mkdir02.c
@@ -134,7 +134,7 @@
ltpuser1 = my_getpwnam(user1name);
sprintf(tstdir1, "tstdir1.%d", getpid());
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
tst_brkm(TFAIL, cleanup, "fork() failed");
/* NOTREACHED */
}
@@ -209,7 +209,7 @@
ltpuser2 = my_getpwnam(user2name);
sprintf(tstdir2, "%s/tstdir2.%d", tstdir1, getpid());
- if ((pid1 = fork()) < 0) {
+ if ((pid1 = FORK_OR_VFORK()) < 0) {
perror("fork failed");
tst_brkm(TFAIL, cleanup, "fork() failed");
/* NOTREACHED */
diff --git a/testcases/kernel/syscalls/mkdir/mkdir03.c b/testcases/kernel/syscalls/mkdir/mkdir03.c
index a16da1e..a3f39ae 100644
--- a/testcases/kernel/syscalls/mkdir/mkdir03.c
+++ b/testcases/kernel/syscalls/mkdir/mkdir03.c
@@ -271,7 +271,8 @@
/* Create a temporary directory and make it current. */
tst_tmpdir();
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/mkdir/mkdir04.c b/testcases/kernel/syscalls/mkdir/mkdir04.c
index 070cbae..fd42a03 100644
--- a/testcases/kernel/syscalls/mkdir/mkdir04.c
+++ b/testcases/kernel/syscalls/mkdir/mkdir04.c
@@ -135,7 +135,7 @@
sprintf(tstdir1, "tstdir1.%d", getpid());
ltpuser1 = my_getpwnam(user1name);
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
tst_brkm(TBROK, cleanup, "fork #1 failed");
/*NOTREACHED*/
}
@@ -172,7 +172,7 @@
sprintf(tstdir2, "%s/tst",tstdir1);
ltpuser2 = my_getpwnam(user2name);
- if ((pid1 = fork()) < 0) {
+ if ((pid1 = FORK_OR_VFORK()) < 0) {
tst_brkm(TBROK, cleanup, "fork #2 failed");
/*NOTREACHED*/
}
diff --git a/testcases/kernel/syscalls/mkdir/mkdir09.c b/testcases/kernel/syscalls/mkdir/mkdir09.c
index a89e053..0ab4dcc 100644
--- a/testcases/kernel/syscalls/mkdir/mkdir09.c
+++ b/testcases/kernel/syscalls/mkdir/mkdir09.c
@@ -100,6 +100,14 @@
void setup();
void cleanup();
+#ifdef UCLINUX
+static char *argv0;
+void dochild1_uclinux();
+void dochild2_uclinux();
+void dochild3_uclinux();
+static int group_uclinux;
+#endif
+
/*--------------------------------------------------------------*/
/*--------------------------------------------------------------*/
/*--------------------------------------------------------------*/
@@ -109,6 +117,20 @@
{
int c;
+#ifdef UCLINUX
+ char *msg;
+
+ /* parse standard options */
+ if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) != (char *)NULL){
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ }
+
+ argv0 = argv[0];
+ maybe_run_child(&dochild1_uclinux, "nd", 1, &nfiles);
+ maybe_run_child(&dochild2_uclinux, "n", 2);
+ maybe_run_child(&dochild3_uclinux, "nd", 3, &group_uclinux);
+#endif
+
setup();
/* Set up to catch SIGTERM signal */
@@ -329,7 +351,7 @@
{
int pid;
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0)
{
@@ -343,13 +365,37 @@
switch(children%NCHILD)
{
case 0:
+#ifdef UCLINUX
+ if (self_exec(argv0, "nd", 1, nfiles) < 0) {
+ massmurder();
+ tst_brkm(TBROK, cleanup, "\tself_exec failed");
+ tst_exit();
+ }
+#else
dochild1(); /* create existing directories */
+#endif
break; /* so lint won't complain */
case 1:
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 2) < 0) {
+ massmurder();
+ tst_brkm(TBROK, cleanup, "\tself_exec failed");
+ tst_exit();
+ }
+#else
dochild2(); /* remove nonexistant directories */
+#endif
break;
case 2:
+#ifdef UCLINUX
+ if (self_exec(argv0, "nd", 3, group) < 0) {
+ massmurder();
+ tst_brkm(TBROK, cleanup, "\tself_exec failed");
+ tst_exit();
+ }
+#else
dochild3(group); /* create/delete directories */
+#endif
break;
default:
tst_brkm(TFAIL, cleanup, "\tTest not inplemented for child %d .\n", child);
@@ -427,6 +473,21 @@
exit(0);
}
+#ifdef UCLINUX
+void dochild1_uclinux()
+{
+ /* Set up to catch SIGTERM signal */
+ if (signal(SIGTERM, term) == SIG_ERR)
+ {
+ tst_brkm(TFAIL, cleanup, "\tError setting up SIGTERM signal, ERRNO = %d\n",
+ errno);
+ tst_exit();
+ }
+
+ dochild1();
+}
+#endif
+
int dochild2()
{
/* Child routine which attempts to remove directories from the
@@ -464,6 +525,21 @@
return(0);
}
+#ifdef UCLINUX
+void dochild2_uclinux()
+{
+ /* Set up to catch SIGTERM signal */
+ if (signal(SIGTERM, term) == SIG_ERR)
+ {
+ tst_brkm(TFAIL, cleanup, "\tError setting up SIGTERM signal, ERRNO = %d\n",
+ errno);
+ tst_exit();
+ }
+
+ dochild2();
+}
+#endif
+
int dochild3(group)
int group;
{
@@ -510,6 +586,22 @@
}
exit(0);
}
+
+#ifdef UCLINUX
+void dochild3_uclinux()
+{
+ /* Set up to catch SIGTERM signal */
+ if (signal(SIGTERM, term) == SIG_ERR)
+ {
+ tst_brkm(TFAIL, cleanup, "\tError setting up SIGTERM signal, ERRNO = %d\n",
+ errno);
+ tst_exit();
+ }
+
+ dochild3(group_uclinux);
+}
+#endif
+
int massmurder()
{
register int j;
diff --git a/testcases/kernel/syscalls/mknod/Makefile b/testcases/kernel/syscalls/mknod/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/mknod/Makefile
+++ b/testcases/kernel/syscalls/mknod/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/mknod/mknod06.c b/testcases/kernel/syscalls/mknod/mknod06.c
index 1fdd957..9650b98 100644
--- a/testcases/kernel/syscalls/mknod/mknod06.c
+++ b/testcases/kernel/syscalls/mknod/mknod06.c
@@ -103,7 +103,9 @@
int (*setupfunc)();
} Test_cases[] = {
{ "tnode_1", "Specified node already exists", EEXIST, setup1 },
+#if !defined(UCLINUX)
{ High_address_node, "Address beyond address space", EFAULT, no_setup },
+#endif
{ (char *)-1, "Negative address", EFAULT, no_setup },
{ "testdir_2/tnode_2", "Non-existent file", ENOENT, no_setup },
{ "", "Pathname is empty", ENOENT, no_setup },
@@ -115,8 +117,12 @@
char *TCID="mknod06"; /* Test program identifier. */
int TST_TOTAL = 7; /* Total number of test cases. */
extern int Tst_count; /* Test Case counter for tst_* routines */
+#if !defined(UCLINUX)
extern char *get_high_address();
int exp_enos[]={EEXIST, EFAULT, ENOENT, ENAMETOOLONG, ENOTDIR, 0};
+#else
+int exp_enos[]={EEXIST, ENOENT, ENAMETOOLONG, ENOTDIR, 0};
+#endif
char * bad_addr = 0;
@@ -157,9 +163,11 @@
node_name = Test_cases[ind].pathname;
test_desc = Test_cases[ind].desc;
+#if !defined(UCLINUX)
if (node_name == High_address_node) {
node_name = get_high_address();
}
+#endif
/*
* Call mknod(2) to test different test conditions.
@@ -228,7 +236,8 @@
/* Make a temp dir and cd to it */
tst_tmpdir();
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/mlock/Makefile b/testcases/kernel/syscalls/mlock/Makefile
index 991b75e..f200ad8 100644
--- a/testcases/kernel/syscalls/mlock/Makefile
+++ b/testcases/kernel/syscalls/mlock/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -Wall -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LDLIBS+= -L../../../../lib -lltp
+LDLIBS+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/mlock/mlock01.c b/testcases/kernel/syscalls/mlock/mlock01.c
index 3ef71c3..9dcb16c 100644
--- a/testcases/kernel/syscalls/mlock/mlock01.c
+++ b/testcases/kernel/syscalls/mlock/mlock01.c
@@ -79,6 +79,8 @@
{&addr1, 1024 * 1024 * 10, setup1}
};
+#if !defined(UCLINUX)
+
/***********************************************************************
* Main
***********************************************************************/
@@ -141,6 +143,16 @@
return 0;
} /* End main */
+#else
+
+int main()
+{
+ tst_resm(TINFO,"mlock01 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
+
/***************************************************************
* setup() - performs all ONE TIME setup for this test.
***************************************************************/
diff --git a/testcases/kernel/syscalls/mlock/mlock02.c b/testcases/kernel/syscalls/mlock/mlock02.c
index 7e93d12..ddd569a 100644
--- a/testcases/kernel/syscalls/mlock/mlock02.c
+++ b/testcases/kernel/syscalls/mlock/mlock02.c
@@ -76,6 +76,8 @@
{&addr1, 1024, ENOMEM, setup1}
};
+#if !defined(UCLINUX)
+
/***********************************************************************
* Main
***********************************************************************/
@@ -148,6 +150,16 @@
return 0;
} /* End main */
+#else
+
+int main()
+{
+ tst_resm(TINFO,"mlock02 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
+
/***************************************************************
* setup() - performs all ONE TIME setup for this test.
***************************************************************/
diff --git a/testcases/kernel/syscalls/mlockall/Makefile b/testcases/kernel/syscalls/mlockall/Makefile
index c07fc84..5de1fab 100644
--- a/testcases/kernel/syscalls/mlockall/Makefile
+++ b/testcases/kernel/syscalls/mlockall/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -Wall -O -g -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/mlockall/mlockall01.c b/testcases/kernel/syscalls/mlockall/mlockall01.c
index 6ec381c..938e697 100644
--- a/testcases/kernel/syscalls/mlockall/mlockall01.c
+++ b/testcases/kernel/syscalls/mlockall/mlockall01.c
@@ -79,6 +79,7 @@
int exp_enos[] = { 0 };
+#if !defined(UCLINUX)
struct test_case_t {
int flag;
@@ -138,6 +139,16 @@
return 0;
} /* End main */
+#else
+
+int main()
+{
+ tst_resm(TINFO,"mlockall01 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif
+
/*
* setup() - performs all ONE TIME setup for this test.
*/
diff --git a/testcases/kernel/syscalls/mlockall/mlockall02.c b/testcases/kernel/syscalls/mlockall/mlockall02.c
index bdbaee4..dc702c1 100644
--- a/testcases/kernel/syscalls/mlockall/mlockall02.c
+++ b/testcases/kernel/syscalls/mlockall/mlockall02.c
@@ -1,262 +1,274 @@
-/*
- * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- */
-/**************************************************************************
- *
- * TEST IDENTIFIER : mlockall02
- *
- * EXECUTED BY : root / superuser
- *
- * TEST TITLE : Test for checking basic error conditions for
- * mlockall(2)
- *
- * TEST CASE TOTAL : 3
- *
- * AUTHOR : Nirmala Devi Dhanasekar <nirmala.devi@wipro.com>
- *
- * SIGNALS
- * Uses SIGUSR1 to pause before test if option set.
- * (See the parse_opts(3) man page).
- *
- * DESCRIPTION
- * Check for basic errors returned by mount(2) system call.
- *
- * Verify that mount(2) returns -1 and sets errno to
- *
- * 1) ENOMEM - If process exceed maximum number of locked pages.
- * 2) EPERM - If not super user
- * 3) EINVAL - Unknown flags were specified.
- *
- * Setup:
- * Setup signal handling.
- * Pause for SIGUSR1 if option specified.
- *
- * Test:
- * Loop if the proper options are given.
- * Do necessary setup for each test.
- * Execute system call
- * Check return code, if system call failed and errno == expected errno
- * Issue sys call passed with expected return value and errno.
- * Otherwise,
- * Issue sys call failed to produce expected error.
- * Do cleanup for each test.
- *
- * Cleanup:
- * Print errno log and/or timing stats if options given
- *
- * USAGE: <for command-line>
- * mlockall02 [-c n] [-e] [-i n] [-I x] [-p x] [-t]
- * where,
- * -c n : Run n copies concurrently
- * -e : Turn on errno logging.
- * -h : Show this help screen
- * -i n : Execute test n times.
- * -I x : Execute test for x seconds.
- * -p : Pause for SIGUSR1 before starting
- * -P x : Pause for x seconds between iterations.
- * -t : Turn on syscall timing.
- *
- * RESTRICTIONS
- * Test must run as root.
- *****************************************************************************/
-#include <errno.h>
-#include <unistd.h>
-#include <pwd.h>
-#include <sys/mman.h>
-#include "test.h"
-#include "usctest.h"
-#include <sys/resource.h>
-
-void setup();
-int setup_test(int);
-void cleanup_test(int);
-void cleanup();
-
-char *TCID = "mlockall02"; /* Test program identifier. */
-int TST_TOTAL = 3; /* Total number of test cases. */
-extern int Tst_count; /* TestCase counter for tst_* routine */
-
-int exp_enos[] = { ENOMEM, EPERM, EINVAL, 0 };
-
-
-struct test_case_t {
- int flag; /* flag value */
- int error; /* error description */
- char *edesc; /* Expected error no */
-} TC[] = {
- {MCL_CURRENT, ENOMEM, "Process exceeds max locked pages" },
- {MCL_CURRENT, EPERM, "Not a superuser" },
- {0, EINVAL, "Unknown flag" }
-};
-
-int main(int ac, char **av)
-{
- int lc, i; /* loop counter */
- char *msg; /* message returned from parse_opts */
-
- if ((msg = parse_opts(ac, av, NULL, NULL)) != (char *) NULL) {
- tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
- tst_exit();
- }
-
- /* perform global setup for test */
- setup();
-
-
- /* check looping state */
- for (lc = 0; TEST_LOOPING(lc); lc++) {
-
- /* reset Tst_count in case we are looping. */
- Tst_count = 0;
-
- for (i = 0; i < TST_TOTAL; i++) {
-
- if (setup_test(i)) {
- tst_resm(TFAIL, "mlockall() Failed while setup "
- "for checking error %s", TC[i].edesc);
- continue;
- }
-
- TEST(mlockall(TC[i].flag));
-
- /* check return code */
- if (TEST_RETURN == -1) {
- TEST_ERROR_LOG(TEST_ERRNO);
- if (TEST_ERRNO != TC[i].error)
- tst_brkm(TFAIL, cleanup,
- "mlock() Failed with wrong "
- "errno, expected errno=%s, "
- "got errno=%d : %s",
- TC[i].edesc, TEST_ERRNO,
- strerror(TEST_ERRNO));
- else
- tst_resm(TPASS,
- "expected failure - errno "
- "= %d : %s",
- TEST_ERRNO,
- strerror(TEST_ERRNO));
- } else {
- if (i <= 1)
- tst_resm(TCONF,
- "mlockall02 did not FAIL as expected."
- "This may be okay if you are running Red Hat"
- " Enterprise Linux 3 (RHEL)");
- else
- tst_brkm(TFAIL, cleanup,
- "mlock() Failed, expected "
- "return value=-1, got %d",
- TEST_RETURN);
- }
- cleanup_test(i);
- }
- } /* End for TEST_LOOPING */
-
- /* cleanup and exit */
- cleanup();
-
- return 0;
-} /* End main */
-
-/*
- * setup() - performs all ONE TIME setup for this test.
- */
-void setup()
-{
- /* capture signals */
- tst_sig(FORK, DEF_HANDLER, cleanup);
-
- /* set the expected errnos... */
- TEST_EXP_ENOS(exp_enos);
-
- TEST_PAUSE;
-
- return;
-}
-
-int setup_test(int i)
-{
- struct rlimit rl;
- char nobody_uid[] = "nobody";
- struct passwd *ltpuser;
-
- switch(i) {
- case 0:
- rl.rlim_max = 10; rl.rlim_cur = 7;
-
- if (setrlimit(RLIMIT_MEMLOCK, &rl) != 0)
- {
- tst_resm(TWARN, "setrlimit failed to set the "
- "resource for RLIMIT_MEMLOCK to check "
- "for mlockall error %s\n", TC[i].edesc);
- return 1;
- }
- return 0;
- case 1:
- ltpuser = getpwnam(nobody_uid);
- if (seteuid(ltpuser->pw_uid) == -1) {
- tst_brkm(TBROK, cleanup,"seteuid() failed to "
- "change euid to %d errno = %d : %s",
- ltpuser->pw_uid, TEST_ERRNO,
- strerror(TEST_ERRNO));
- return 1;
- }
- return 0;
- }
- return 0;
-}
-
-void cleanup_test(int i)
-{
- struct rlimit rl;
-
- switch(i) {
- case 0:
- rl.rlim_max = -1; rl.rlim_cur = -1;
-
- if (setrlimit(RLIMIT_MEMLOCK, &rl) != 0)
- {
- tst_brkm(TFAIL, cleanup,
- "setrlimit failed to reset the "
- "resource for RLIMIT_MEMLOCK while "
- "checking for mlockall error %s\n",
- TC[i].edesc);
- }
- return;
- case 1:
- if (seteuid(0) == -1) {
- tst_brkm(TBROK, cleanup,"seteuid() failed to "
- "change euid to %d errno = %d : %s",
- 0, TEST_ERRNO, strerror(TEST_ERRNO));
- }
- return;
-
- }
-}
-
-
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- * completion or premature exit.
- */
-void cleanup()
-{
- TEST_CLEANUP;
-
- /* exit with return code appropriate for results */
- tst_exit();
-
- return;
-}
+/*
+ * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ *
+ */
+/**************************************************************************
+ *
+ * TEST IDENTIFIER : mlockall02
+ *
+ * EXECUTED BY : root / superuser
+ *
+ * TEST TITLE : Test for checking basic error conditions for
+ * mlockall(2)
+ *
+ * TEST CASE TOTAL : 3
+ *
+ * AUTHOR : Nirmala Devi Dhanasekar <nirmala.devi@wipro.com>
+ *
+ * SIGNALS
+ * Uses SIGUSR1 to pause before test if option set.
+ * (See the parse_opts(3) man page).
+ *
+ * DESCRIPTION
+ * Check for basic errors returned by mount(2) system call.
+ *
+ * Verify that mount(2) returns -1 and sets errno to
+ *
+ * 1) ENOMEM - If process exceed maximum number of locked pages.
+ * 2) EPERM - If not super user
+ * 3) EINVAL - Unknown flags were specified.
+ *
+ * Setup:
+ * Setup signal handling.
+ * Pause for SIGUSR1 if option specified.
+ *
+ * Test:
+ * Loop if the proper options are given.
+ * Do necessary setup for each test.
+ * Execute system call
+ * Check return code, if system call failed and errno == expected errno
+ * Issue sys call passed with expected return value and errno.
+ * Otherwise,
+ * Issue sys call failed to produce expected error.
+ * Do cleanup for each test.
+ *
+ * Cleanup:
+ * Print errno log and/or timing stats if options given
+ *
+ * USAGE: <for command-line>
+ * mlockall02 [-c n] [-e] [-i n] [-I x] [-p x] [-t]
+ * where,
+ * -c n : Run n copies concurrently
+ * -e : Turn on errno logging.
+ * -h : Show this help screen
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -p : Pause for SIGUSR1 before starting
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ *
+ * RESTRICTIONS
+ * Test must run as root.
+ *****************************************************************************/
+#include <errno.h>
+#include <unistd.h>
+#include <pwd.h>
+#include <sys/mman.h>
+#include "test.h"
+#include "usctest.h"
+#include <sys/resource.h>
+
+void setup();
+int setup_test(int);
+void cleanup_test(int);
+void cleanup();
+
+char *TCID = "mlockall02"; /* Test program identifier. */
+int TST_TOTAL = 3; /* Total number of test cases. */
+extern int Tst_count; /* TestCase counter for tst_* routine */
+
+int exp_enos[] = { ENOMEM, EPERM, EINVAL, 0 };
+
+
+struct test_case_t {
+ int flag; /* flag value */
+ int error; /* error description */
+ char *edesc; /* Expected error no */
+} TC[] = {
+ {MCL_CURRENT, ENOMEM, "Process exceeds max locked pages" },
+ {MCL_CURRENT, EPERM, "Not a superuser" },
+ {0, EINVAL, "Unknown flag" }
+};
+
+#if !defined(UCLINUX)
+
+int main(int ac, char **av)
+{
+ int lc, i; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+
+ if ((msg = parse_opts(ac, av, NULL, NULL)) != (char *) NULL) {
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ tst_exit();
+ }
+
+ /* perform global setup for test */
+ setup();
+
+
+ /* check looping state */
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+
+ /* reset Tst_count in case we are looping. */
+ Tst_count = 0;
+
+ for (i = 0; i < TST_TOTAL; i++) {
+
+ if (setup_test(i)) {
+ tst_resm(TFAIL, "mlockall() Failed while setup "
+ "for checking error %s", TC[i].edesc);
+ continue;
+ }
+
+ TEST(mlockall(TC[i].flag));
+
+ /* check return code */
+ if (TEST_RETURN == -1) {
+ TEST_ERROR_LOG(TEST_ERRNO);
+ if (TEST_ERRNO != TC[i].error)
+ tst_brkm(TFAIL, cleanup,
+ "mlock() Failed with wrong "
+ "errno, expected errno=%s, "
+ "got errno=%d : %s",
+ TC[i].edesc, TEST_ERRNO,
+ strerror(TEST_ERRNO));
+ else
+ tst_resm(TPASS,
+ "expected failure - errno "
+ "= %d : %s",
+ TEST_ERRNO,
+ strerror(TEST_ERRNO));
+ } else {
+ if (i <= 1)
+ tst_resm(TCONF,
+ "mlockall02 did not FAIL as expected."
+ "This may be okay if you are running Red Hat"
+ " Enterprise Linux 3 (RHEL)");
+ else
+ tst_brkm(TFAIL, cleanup,
+ "mlock() Failed, expected "
+ "return value=-1, got %d",
+ TEST_RETURN);
+ }
+ cleanup_test(i);
+ }
+ } /* End for TEST_LOOPING */
+
+ /* cleanup and exit */
+ cleanup();
+
+ return 0;
+} /* End main */
+
+/*
+ * setup() - performs all ONE TIME setup for this test.
+ */
+void setup()
+{
+ /* capture signals */
+ tst_sig(FORK, DEF_HANDLER, cleanup);
+
+ /* set the expected errnos... */
+ TEST_EXP_ENOS(exp_enos);
+
+ TEST_PAUSE;
+
+ return;
+}
+
+int setup_test(int i)
+{
+ struct rlimit rl;
+ char nobody_uid[] = "nobody";
+ struct passwd *ltpuser;
+
+ switch(i) {
+ case 0:
+ rl.rlim_max = 10; rl.rlim_cur = 7;
+
+ if (setrlimit(RLIMIT_MEMLOCK, &rl) != 0)
+ {
+ tst_resm(TWARN, "setrlimit failed to set the "
+ "resource for RLIMIT_MEMLOCK to check "
+ "for mlockall error %s\n", TC[i].edesc);
+ return 1;
+ }
+ return 0;
+ case 1:
+ ltpuser = getpwnam(nobody_uid);
+ if (seteuid(ltpuser->pw_uid) == -1) {
+ tst_brkm(TBROK, cleanup,"seteuid() failed to "
+ "change euid to %d errno = %d : %s",
+ ltpuser->pw_uid, TEST_ERRNO,
+ strerror(TEST_ERRNO));
+ return 1;
+ }
+ return 0;
+ }
+ return 0;
+}
+
+void cleanup_test(int i)
+{
+ struct rlimit rl;
+
+ switch(i) {
+ case 0:
+ rl.rlim_max = -1; rl.rlim_cur = -1;
+
+ if (setrlimit(RLIMIT_MEMLOCK, &rl) != 0)
+ {
+ tst_brkm(TFAIL, cleanup,
+ "setrlimit failed to reset the "
+ "resource for RLIMIT_MEMLOCK while "
+ "checking for mlockall error %s\n",
+ TC[i].edesc);
+ }
+ return;
+ case 1:
+ if (seteuid(0) == -1) {
+ tst_brkm(TBROK, cleanup,"seteuid() failed to "
+ "change euid to %d errno = %d : %s",
+ 0, TEST_ERRNO, strerror(TEST_ERRNO));
+ }
+ return;
+
+ }
+}
+
+
+/*
+ * cleanup() - performs all ONE TIME cleanup for this test at
+ * completion or premature exit.
+ */
+void cleanup()
+{
+ TEST_CLEANUP;
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+
+ return;
+}
+
+#else
+
+int main()
+{
+ tst_resm(TINFO,"mlockall02 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
diff --git a/testcases/kernel/syscalls/mlockall/mlockall03.c b/testcases/kernel/syscalls/mlockall/mlockall03.c
index f306da7..3a51216 100644
--- a/testcases/kernel/syscalls/mlockall/mlockall03.c
+++ b/testcases/kernel/syscalls/mlockall/mlockall03.c
@@ -93,6 +93,8 @@
int TST_TOTAL = 3; /* Total number of test cases. */
extern int Tst_count; /* TestCase counter for tst_* routine */
+#if !defined(UCLINUX)
+
char *ref_release = "2.6.8\0";
int exp_enos[] = { ENOMEM, EPERM, EINVAL, 0 };
@@ -306,6 +308,16 @@
}
}
+#else
+
+int main()
+{
+ tst_resm(TINFO,"mlockall03 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX)
+
/*
* cleanup() - performs all ONE TIME cleanup for this test at
diff --git a/testcases/kernel/syscalls/mmap/Makefile b/testcases/kernel/syscalls/mmap/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/mmap/Makefile
+++ b/testcases/kernel/syscalls/mmap/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/modify_ldt/Makefile b/testcases/kernel/syscalls/modify_ldt/Makefile
index 47150cb..cce0fd2 100644
--- a/testcases/kernel/syscalls/modify_ldt/Makefile
+++ b/testcases/kernel/syscalls/modify_ldt/Makefile
@@ -27,8 +27,10 @@
else
CFLAGS+=-I../../../../include -g -Wall -DMODIFY_LDT_SPECIALCASE
endif
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c b/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c
index c1bbaaf..105abe0 100644
--- a/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c
+++ b/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c
@@ -146,7 +146,7 @@
/*NOTREACHED*/
}
- if ((pid = fork()) == 0) {
+ if ((pid = FORK_OR_VFORK()) == 0) {
val = read_segment(0);
exit(1);
}
diff --git a/testcases/kernel/syscalls/mount/Makefile b/testcases/kernel/syscalls/mount/Makefile
index b51c409..f02516b 100644
--- a/testcases/kernel/syscalls/mount/Makefile
+++ b/testcases/kernel/syscalls/mount/Makefile
@@ -19,7 +19,9 @@
# description : make(1) description file for the mount(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -D_GNU_SOURCE -Wall -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LDLIBS+= -L../../../../lib -lltp
+LDLIBS+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard mount*.c) setuid_test.c
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/mprotect/Makefile b/testcases/kernel/syscalls/mprotect/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/mprotect/Makefile
+++ b/testcases/kernel/syscalls/mprotect/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/mprotect/mprotect02.c b/testcases/kernel/syscalls/mprotect/mprotect02.c
index d3b90e1..09ccc7f 100644
--- a/testcases/kernel/syscalls/mprotect/mprotect02.c
+++ b/testcases/kernel/syscalls/mprotect/mprotect02.c
@@ -112,7 +112,7 @@
/*NOTREACHED*/
}
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() #1 failed");
}
@@ -142,7 +142,7 @@
if (TEST_RETURN != -1) {
if (STD_FUNCTIONAL_TEST) {
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup,
"fork() #2 failed");
}
diff --git a/testcases/kernel/syscalls/mprotect/mprotect03.c b/testcases/kernel/syscalls/mprotect/mprotect03.c
index ee3d75f..496da8d 100644
--- a/testcases/kernel/syscalls/mprotect/mprotect03.c
+++ b/testcases/kernel/syscalls/mprotect/mprotect03.c
@@ -122,7 +122,7 @@
if (TEST_RETURN != -1) {
if (STD_FUNCTIONAL_TEST) {
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork failed");
}
diff --git a/testcases/kernel/syscalls/mremap/Makefile b/testcases/kernel/syscalls/mremap/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/mremap/Makefile
+++ b/testcases/kernel/syscalls/mremap/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/mremap/mremap03.c b/testcases/kernel/syscalls/mremap/mremap03.c
index 7f766a5..28a6a2b 100644
--- a/testcases/kernel/syscalls/mremap/mremap03.c
+++ b/testcases/kernel/syscalls/mremap/mremap03.c
@@ -94,6 +94,7 @@
void setup(); /* Main setup function of test */
void cleanup(); /* cleanup function for the test */
+#if !defined(UCLINUX)
int
main(int ac, char **av)
{
@@ -214,3 +215,13 @@
/* Exit the program */
tst_exit();
}
+
+#else
+
+int main()
+{
+ tst_resm(TINFO,"mremap03 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
diff --git a/testcases/kernel/syscalls/msync/Makefile b/testcases/kernel/syscalls/msync/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/msync/Makefile
+++ b/testcases/kernel/syscalls/msync/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/msync/msync05.c b/testcases/kernel/syscalls/msync/msync05.c
index 6e27bb2..4ca33f5 100644
--- a/testcases/kernel/syscalls/msync/msync05.c
+++ b/testcases/kernel/syscalls/msync/msync05.c
@@ -81,6 +81,7 @@
void setup(); /* Main setup function of test */
void cleanup(); /* cleanup function for the test */
+#if !defined(UCLINUX)
int
main(int ac, char **av)
{
@@ -187,3 +188,13 @@
/* exit with return code appropriate for results */
tst_exit();
}
+
+#else
+
+int main()
+{
+ tst_resm(TINFO,"msync05 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
diff --git a/testcases/kernel/syscalls/munlock/Makefile b/testcases/kernel/syscalls/munlock/Makefile
index 991b75e..a8a1b0f 100644
--- a/testcases/kernel/syscalls/munlock/Makefile
+++ b/testcases/kernel/syscalls/munlock/Makefile
@@ -1,4 +1,4 @@
-#
+#
# Copyright (c) International Business Machines Corp., 2001
#
# This program is free software; you can redistribute it and/or modify
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -Wall -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LDLIBS+= -L../../../../lib -lltp
+LDLIBS+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/munlock/munlock02.c b/testcases/kernel/syscalls/munlock/munlock02.c
index a33dc4d..1c9f827 100644
--- a/testcases/kernel/syscalls/munlock/munlock02.c
+++ b/testcases/kernel/syscalls/munlock/munlock02.c
@@ -96,6 +96,8 @@
{NULL, 0, ENOMEM, "address range out of address space" },
};
+#if !defined(UCLINUX)
+
int main(int ac, char **av)
{
int lc, i; /* loop counter */
@@ -166,7 +168,8 @@
TEST_EXP_ENOS(exp_enos);
TC[0].len = 8 * getpagesize();
- address = mmap(0, TC[0].len, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ address = mmap(0, TC[0].len, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (address == MAP_FAILED)
tst_brkm(TFAIL, cleanup, "mmap_failed");
memset(address, 0x20, TC[0].len);
@@ -190,6 +193,16 @@
return;
}
+#else
+
+int main()
+{
+ tst_resm(TINFO,"munlock02 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
+
/*
* cleanup() - performs all ONE TIME cleanup for this test at
* completion or premature exit.
diff --git a/testcases/kernel/syscalls/munlockall/Makefile b/testcases/kernel/syscalls/munlockall/Makefile
index 6729e34..0db7aa7 100644
--- a/testcases/kernel/syscalls/munlockall/Makefile
+++ b/testcases/kernel/syscalls/munlockall/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/munlockall/munlockall01.c b/testcases/kernel/syscalls/munlockall/munlockall01.c
index 0f55649..5e0b90d 100644
--- a/testcases/kernel/syscalls/munlockall/munlockall01.c
+++ b/testcases/kernel/syscalls/munlockall/munlockall01.c
@@ -74,6 +74,8 @@
extern int Tst_count; /* TestCase counter for tst_* routine */
int exp_enos[] = { 0 };
+#if !defined(UCLINUX)
+
int main(int ac, char **av)
{
int lc; /* loop counter */
@@ -115,6 +117,16 @@
return 0;
} /* End main */
+#else
+
+int main()
+{
+ tst_resm(TINFO,"munlockall01 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
+
/* setup() - performs all ONE TIME setup for this test. */
void setup()
diff --git a/testcases/kernel/syscalls/munlockall/munlockall02.c b/testcases/kernel/syscalls/munlockall/munlockall02.c
index c5d6313..82c2554 100644
--- a/testcases/kernel/syscalls/munlockall/munlockall02.c
+++ b/testcases/kernel/syscalls/munlockall/munlockall02.c
@@ -83,6 +83,8 @@
static char nobody_uid[]="nobody";
struct passwd *ltpuser;
+#if !defined(UCLINUX)
+
int main(int ac, char **av)
{
int lc; /* loop counter */
@@ -158,6 +160,16 @@
TEST_PAUSE;
}
+#else
+
+int main()
+{
+ tst_resm(TINFO,"munlockall02 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
+
/*
* cleanup() - performs all ONE TIME cleanup for this test at
* completion or premature exit.
diff --git a/testcases/kernel/syscalls/munmap/Makefile b/testcases/kernel/syscalls/munmap/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/munmap/Makefile
+++ b/testcases/kernel/syscalls/munmap/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/nanosleep/Makefile b/testcases/kernel/syscalls/nanosleep/Makefile
index 9be5f57..8eacc90 100644
--- a/testcases/kernel/syscalls/nanosleep/Makefile
+++ b/testcases/kernel/syscalls/nanosleep/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -D_GNU_SOURCE -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/nanosleep/nanosleep01.c b/testcases/kernel/syscalls/nanosleep/nanosleep01.c
index 118e52d..6fc620e 100644
--- a/testcases/kernel/syscalls/nanosleep/nanosleep01.c
+++ b/testcases/kernel/syscalls/nanosleep/nanosleep01.c
@@ -115,7 +115,7 @@
* time specified by timespec struct element
* time_t tv_sec.
*/
- cpid = fork();
+ cpid = FORK_OR_VFORK();
if (cpid == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
}
diff --git a/testcases/kernel/syscalls/nanosleep/nanosleep02.c b/testcases/kernel/syscalls/nanosleep/nanosleep02.c
index eb94f25..ee33f00 100644
--- a/testcases/kernel/syscalls/nanosleep/nanosleep02.c
+++ b/testcases/kernel/syscalls/nanosleep/nanosleep02.c
@@ -86,6 +86,7 @@
struct timespec timereq; /* time struct. buffer for nanosleep() */
struct timespec timerem; /* time struct. buffer for nanosleep() */
+void do_child(); /* Child process */
void setup(); /* Main setup function of test */
void cleanup(); /* cleanup function for the test */
void sig_handler(); /* signal catching function */
@@ -108,8 +109,6 @@
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
pid_t cpid; /* Child process id */
- struct timeval otime; /* time before child execution suspended */
- struct timeval ntime; /* time after child resumes execution */
int status; /* child exit status */
/* Parse standard options given to run the test. */
@@ -118,6 +117,11 @@
tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "dddd", &timereq.tv_sec, &timereq.tv_nsec,
+ &timerem.tv_sec, &timerem.tv_nsec);
+#endif
+
/* Perform global setup for test */
setup();
@@ -131,89 +135,21 @@
* Creat a child process and suspend its
* execution using nanosleep()
*/
- if ((cpid = fork()) == -1) {
+ if ((cpid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup,
"fork() failed to create child process");
}
if (cpid == 0) { /* Child process */
- unsigned long req, rem, before, after, elapsed; /* usec */
-
- /* Note down the current time */
- gettimeofday(&otime, NULL);
- /*
- * Call nanosleep() to suspend child process
- * for specified time 'tv_sec'.
- * Call should return before suspending execution
- * for the specified time due to receipt of signal
- * from Parent.
- */
- TEST(nanosleep(&timereq, &timerem));
-
- /* time after child resumes execution */
- gettimeofday(&ntime, NULL);
-
- /*
- * Check whether the remaining sleep of child updated
- * in 'timerem' structure.
- * The time remaining should be equal to the
- * Total time for sleep - time spent on sleep bfr signal
- */
- req = timereq.tv_sec * 1000000 + timereq.tv_nsec / 1000;
- rem = timerem.tv_sec * 1000000 + timerem.tv_nsec / 1000;
- before = otime.tv_sec * 1000000 + otime.tv_usec;
- after = ntime.tv_sec * 1000000 + ntime.tv_usec;
- elapsed = after - before;
-
- if (rem - (req - elapsed) > USEC_PRECISION) {
- tst_resm(TFAIL, "Remaining sleep time %lu usec doesn't "
- "match with the expected %lu usec time",
- rem, (req - elapsed));
- exit(1);
+#ifdef UCLINUX
+ if (self_exec(av[0], "dddd",
+ timereq.tv_sec, timereq.tv_nsec,
+ timerem.tv_sec, timerem.tv_nsec) < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed");
}
-
- /* Record the time before suspension */
- gettimeofday(&otime, NULL);
-
- /*
- * Invoke nanosleep() again to suspend child
- * for the specified sleep time specified by
- * 'timereq' structure.
- */
- TEST(nanosleep(&timereq, &timerem));
-
- /* Record the time after suspension */
- gettimeofday(&ntime, NULL);
-
- /* check return code of nanosleep() */
- if (TEST_RETURN == -1) {
- tst_resm(TFAIL,
- "nanosleep() Failed, errno=%d : %s",
- TEST_ERRNO, strerror(TEST_ERRNO));
- exit(1);
- }
-
- /*
- * Perform functional verification if test
- * executed without (-f) option.
- */
- if (STD_FUNCTIONAL_TEST) {
- /*
- * Verify whether child execution was
- * actually suspended for the remaining
- * sleep time specified by 'timerem'
- * structure.
- */
- if ((ntime.tv_sec - otime.tv_sec) != timereq.tv_sec) {
- tst_resm(TFAIL, "Child execution not "
- "suspended for %d seconds",
- timereq.tv_sec);
- exit(1);
- }
- } else {
- tst_resm(TPASS, "call succeeded");
- exit(0);
- }
+#else
+ do_child();
+#endif
}
/* wait for child to time slot for execution */
@@ -244,6 +180,92 @@
} /* End main */
/*
+ * do_child()
+ */
+void
+do_child()
+{
+ unsigned long req, rem, before, after, elapsed; /* usec */
+ struct timeval otime; /* time before child execution suspended */
+ struct timeval ntime; /* time after child resumes execution */
+
+ /* Note down the current time */
+ gettimeofday(&otime, NULL);
+ /*
+ * Call nanosleep() to suspend child process
+ * for specified time 'tv_sec'.
+ * Call should return before suspending execution
+ * for the specified time due to receipt of signal
+ * from Parent.
+ */
+ TEST(nanosleep(&timereq, &timerem));
+ /* time after child resumes execution */
+ gettimeofday(&ntime, NULL);
+
+ /*
+ * Check whether the remaining sleep of child updated
+ * in 'timerem' structure.
+ * The time remaining should be equal to the
+ * Total time for sleep - time spent on sleep bfr signal
+ */
+ req = timereq.tv_sec * 1000000 + timereq.tv_nsec / 1000;
+ rem = timerem.tv_sec * 1000000 + timerem.tv_nsec / 1000;
+ before = otime.tv_sec * 1000000 + otime.tv_usec;
+ after = ntime.tv_sec * 1000000 + ntime.tv_usec;
+ elapsed = after - before;
+
+ if (rem - (req - elapsed) > USEC_PRECISION) {
+ tst_resm(TFAIL, "Remaining sleep time %lu usec doesn't "
+ "match with the expected %lu usec time",
+ rem, (req - elapsed));
+ exit(1);
+ }
+
+ /* Record the time before suspension */
+ gettimeofday(&otime, NULL);
+
+ /*
+ * Invoke nanosleep() again to suspend child
+ * for the specified sleep time specified by
+ * 'timereq' structure.
+ */
+ TEST(nanosleep(&timereq, &timerem));
+
+ /* Record the time after suspension */
+ gettimeofday(&ntime, NULL);
+
+ /* check return code of nanosleep() */
+ if (TEST_RETURN == -1) {
+ tst_resm(TFAIL,
+ "nanosleep() Failed, errno=%d : %s",
+ TEST_ERRNO, strerror(TEST_ERRNO));
+ exit(1);
+ }
+
+ /*
+ * Perform functional verification if test
+ * executed without (-f) option.
+ */
+ if (STD_FUNCTIONAL_TEST) {
+ /*
+ * Verify whether child execution was
+ * actually suspended for the remaining
+ * sleep time specified by 'timerem'
+ * structure.
+ */
+ if ((ntime.tv_sec - otime.tv_sec) != timereq.tv_sec) {
+ tst_resm(TFAIL, "Child execution not "
+ "suspended for %d seconds",
+ timereq.tv_sec);
+ exit(1);
+ }
+ } else {
+ tst_resm(TPASS, "call succeeded");
+ exit(0);
+ }
+}
+
+/*
* setup() - performs all ONE TIME setup for this test.
* Setup signal handler to catch the interrupt signal sent by parent
* to child process.
diff --git a/testcases/kernel/syscalls/nanosleep/nanosleep03.c b/testcases/kernel/syscalls/nanosleep/nanosleep03.c
index 75b1c00..bfd6de4 100644
--- a/testcases/kernel/syscalls/nanosleep/nanosleep03.c
+++ b/testcases/kernel/syscalls/nanosleep/nanosleep03.c
@@ -75,9 +75,12 @@
extern int Tst_count; /* Test Case counter for tst_* routines */
struct timespec timereq; /* time struct. buffer for nanosleep() */
+struct timespec timerem; /* time struct. buffer for nanosleep() */
+
int exp_enos[]={EINTR, 0};
+void do_child(); /* Child process */
void setup(); /* Main setup function of test */
void cleanup(); /* cleanup function for the test */
void sig_handler(); /* signal catching function */
@@ -85,7 +88,6 @@
int
main(int ac, char **av)
{
- struct timespec timerem;/* time struct. buffer for nanosleep() */
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
pid_t cpid; /* Child process id */
@@ -97,6 +99,11 @@
tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "dddd", &timereq.tv_sec, &timereq.tv_nsec,
+ &timerem.tv_sec, &timerem.tv_nsec);
+#endif
+
/* Perform global setup for test */
setup();
@@ -117,36 +124,15 @@
}
if (cpid == 0) { /* Child process */
- /*
- * Call nanosleep() to suspend child process
- * for specified time 'tv_sec'.
- * Call should return before suspending execution
- * for the specified time due to receipt of signal
- * from Parent.
- */
- TEST(nanosleep(&timereq, &timerem));
-
- /* check return code of nanosleep() */
- if (TEST_RETURN == -1) {
-
- TEST_ERROR_LOG(TEST_ERRNO);
-
- /* Check for expected errno is set */
- if (TEST_ERRNO != EINTR) {
- tst_resm(TFAIL, "nanosleep() failed, "
- "got errno:%d, expected errno"
- ":%d", TEST_ERRNO, EINTR);
- exit(1);
- }
- } else {
- tst_resm(TFAIL, "nanosleep() returns %d, "
- "expected -1, errno:%d",
- TEST_RETURN, EINTR);
- exit(1);
+#ifdef UCLINUX
+ if (self_exec(av[0], "dddd",
+ timereq.tv_sec, timereq.tv_nsec,
+ timerem.tv_sec, timerem.tv_nsec) < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed");
}
-
- /* Everything is fine, exit normally */
- exit(0);
+#else
+ do_child();
+#endif
}
/* wait for child to time slot for execution */
@@ -177,6 +163,44 @@
} /* End main */
/*
+ * do_child()
+ */
+void
+do_child()
+{
+ /*
+ * Call nanosleep() to suspend child process
+ * for specified time 'tv_sec'.
+ * Call should return before suspending execution
+ * for the specified time due to receipt of signal
+ * from Parent.
+ */
+ TEST(nanosleep(&timereq, &timerem));
+
+ /* check return code of nanosleep() */
+ if (TEST_RETURN == -1) {
+
+ TEST_ERROR_LOG(TEST_ERRNO);
+
+ /* Check for expected errno is set */
+ if (TEST_ERRNO != EINTR) {
+ tst_resm(TFAIL, "nanosleep() failed, "
+ "got errno:%d, expected errno"
+ ":%d", TEST_ERRNO, EINTR);
+ exit(1);
+ }
+ } else {
+ tst_resm(TFAIL, "nanosleep() returns %d, "
+ "expected -1, errno:%d",
+ TEST_RETURN, EINTR);
+ exit(1);
+ }
+
+ /* Everything is fine, exit normally */
+ exit(0);
+}
+
+/*
* setup() - performs all ONE TIME setup for this test.
* Setup signal handler to catch the interrupt signal sent by parent
* to child process.
diff --git a/testcases/kernel/syscalls/nanosleep/nanosleep04.c b/testcases/kernel/syscalls/nanosleep/nanosleep04.c
index ae8d3cf..e869401 100644
--- a/testcases/kernel/syscalls/nanosleep/nanosleep04.c
+++ b/testcases/kernel/syscalls/nanosleep/nanosleep04.c
@@ -111,7 +111,7 @@
* Creat a child process and suspend its
* execution using nanosleep()
*/
- if ((cpid = fork()) == -1) {
+ if ((cpid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup,
"fork() fails to create child process");
}
diff --git a/testcases/kernel/syscalls/nftw/Makefile b/testcases/kernel/syscalls/nftw/Makefile
index 6a0cf08..e1d20ad 100644
--- a/testcases/kernel/syscalls/nftw/Makefile
+++ b/testcases/kernel/syscalls/nftw/Makefile
@@ -16,6 +16,7 @@
LINT = lint
CFLAGS+= -Wall -g -ansi -O -DLINUX -D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
SRCS1 = nftw.c tools.c test_func.c test.c lib.c
OBJS1 = nftw.o tools.o test_func.o test.o lib.o
SRCS2 = nftw64.c tools64.c test_func64.c test64.c lib64.c
diff --git a/testcases/kernel/syscalls/nice/Makefile b/testcases/kernel/syscalls/nice/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/nice/Makefile
+++ b/testcases/kernel/syscalls/nice/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/open/Makefile b/testcases/kernel/syscalls/open/Makefile
index 15f9d40..5b561a0 100644
--- a/testcases/kernel/syscalls/open/Makefile
+++ b/testcases/kernel/syscalls/open/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp -L.. -ltestsuite
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/open/open05.c b/testcases/kernel/syscalls/open/open05.c
index 8d82811..b81be02 100644
--- a/testcases/kernel/syscalls/open/open05.c
+++ b/testcases/kernel/syscalls/open/open05.c
@@ -90,7 +90,7 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
/*NOTREACHED*/
}
diff --git a/testcases/kernel/syscalls/open/open08.c b/testcases/kernel/syscalls/open/open08.c
index aa691a0..59f9856 100644
--- a/testcases/kernel/syscalls/open/open08.c
+++ b/testcases/kernel/syscalls/open/open08.c
@@ -184,7 +184,8 @@
}
close(fildes);
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/paging/Makefile b/testcases/kernel/syscalls/paging/Makefile
index 3eae260..ec20258 100644
--- a/testcases/kernel/syscalls/paging/Makefile
+++ b/testcases/kernel/syscalls/paging/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/pathconf/Makefile b/testcases/kernel/syscalls/pathconf/Makefile
index 446354e..ce7ee6d 100644
--- a/testcases/kernel/syscalls/pathconf/Makefile
+++ b/testcases/kernel/syscalls/pathconf/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp -L.. -ltestsuite
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/pause/Makefile b/testcases/kernel/syscalls/pause/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/pause/Makefile
+++ b/testcases/kernel/syscalls/pause/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/pause/pause02.c b/testcases/kernel/syscalls/pause/pause02.c
index eb55ffb..087ade3 100644
--- a/testcases/kernel/syscalls/pause/pause02.c
+++ b/testcases/kernel/syscalls/pause/pause02.c
@@ -77,11 +77,16 @@
int exp_enos[]={EINTR, 0};
pid_t cpid; /* child process id */
+void do_child(); /* Function to run in child process */
void setup(); /* Main setup function of test */
void cleanup(); /* cleanup function for the test */
void sig_handle(int sig); /* signal handler for SIGINT */
void kill_handle(int sig); /* sends SIGKILL for child */
+#ifdef UCLINUX
+void do_child_uclinux(); /* Setup SIGINT handler then do_child() */
+#endif
+
int
main(int ac, char **av)
{
@@ -96,6 +101,10 @@
tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child_uclinux, "");
+#endif
+
/* Perform global setup for test */
setup();
@@ -114,27 +123,13 @@
}
if (cpid == 0) { /* Child process */
- /* Suspend the child using pause() */
- TEST(pause());
-
- /*
- * Child resumes execution after receipt of
- * interrupt signal sent by the parent.
- */
- TEST_ERROR_LOG(TEST_ERRNO);
- if ((TEST_RETURN == -1) && (TEST_ERRNO == EINTR)) {
- /* pause returned */
- tst_resm(TPASS, "Functionality of pause() "
- "is correct");
- } else {
- tst_resm(TFAIL, "pause() returned %d, error=%d",
- TEST_RETURN, TEST_ERRNO);
+#ifdef UCLINUX
+ if (self_exec(av[0], "") < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed");
}
- if (TEST_RETURN == -1) {
- exit(TEST_ERRNO);
- } else {
- exit(-1);
- }
+#else
+ do_child();
+#endif
}
/* Parent process */
@@ -188,6 +183,50 @@
} /* End main */
/*
+ * do_child()
+ */
+void
+do_child()
+{
+ /* Suspend the child using pause() */
+ TEST(pause());
+
+ /*
+ * Child resumes execution after receipt of
+ * interrupt signal sent by the parent.
+ */
+ TEST_ERROR_LOG(TEST_ERRNO);
+ if ((TEST_RETURN == -1) && (TEST_ERRNO == EINTR)) {
+ /* pause returned */
+ tst_resm(TPASS, "Functionality of pause() "
+ "is correct");
+ } else {
+ tst_resm(TFAIL, "pause() returned %d, error=%d",
+ TEST_RETURN, TEST_ERRNO);
+ }
+ if (TEST_RETURN == -1) {
+ exit(TEST_ERRNO);
+ } else {
+ exit(-1);
+ }
+}
+
+/*
+ * do_child_uclinux()
+ */
+void
+do_child_uclinux()
+{
+ /* Catch SIGINT */
+ if (signal(SIGINT, sig_handle) == SIG_ERR) {
+ tst_brkm(TBROK, cleanup,
+ "signal() fails to catch SIGINT");
+ }
+
+ do_child();
+}
+
+/*
* setup() - performs all ONE TIME setup for this test.
* Set the signal handler to catch SIGINT signal.
*/
diff --git a/testcases/kernel/syscalls/pause/pause03.c b/testcases/kernel/syscalls/pause/pause03.c
index 8276461..03d8909 100644
--- a/testcases/kernel/syscalls/pause/pause03.c
+++ b/testcases/kernel/syscalls/pause/pause03.c
@@ -77,6 +77,7 @@
int TST_TOTAL=1; /* Total number of test cases. */
extern int Tst_count; /* Test Case counter for tst_* routines */
+void do_child(); /* Function to run in child process */
void setup(); /* Main setup function of test */
void cleanup(); /* cleanup function for the test */
void sig_handle(int sig); /* signal handler for SIGCLD */
@@ -95,6 +96,10 @@
tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "");
+#endif
+
/* Perform global setup for test */
setup();
@@ -110,14 +115,13 @@
}
if (cpid == 0) { /* Child process */
- /* Suspend the child using pause() */
- TEST(pause());
-
- /* print the message if pause() returned */
- tst_resm(TFAIL, "Unexpected return from pause()");
- /* Loop infinitely */
- while (1)
- ;
+#ifdef UCLINUX
+ if (self_exec(av[0], "") < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed");
+ }
+#else
+ do_child();
+#endif
}
/* Parent process */
@@ -185,6 +189,22 @@
} /* End main */
/*
+ * do_child()
+ */
+void
+do_child()
+{
+ /* Suspend the child using pause() */
+ TEST(pause());
+
+ /* print the message if pause() returned */
+ tst_resm(TFAIL, "Unexpected return from pause()");
+ /* Loop infinitely */
+ while (1)
+ ;
+}
+
+/*
* setup() - performs all ONE TIME setup for this test.
* Setup signal handler to catch SIGCLD signal.
*/
diff --git a/testcases/kernel/syscalls/personality/Makefile b/testcases/kernel/syscalls/personality/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/personality/Makefile
+++ b/testcases/kernel/syscalls/personality/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/pipe/Makefile b/testcases/kernel/syscalls/pipe/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/pipe/Makefile
+++ b/testcases/kernel/syscalls/pipe/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/pipe/pipe02.c b/testcases/kernel/syscalls/pipe/pipe02.c
index c62a10c..d4cbc53 100644
--- a/testcases/kernel/syscalls/pipe/pipe02.c
+++ b/testcases/kernel/syscalls/pipe/pipe02.c
@@ -61,6 +61,7 @@
int usrsig;
+void do_child(void);
void setup(void);
void cleanup(void);
void catch_usr2(int);
@@ -76,11 +77,12 @@
return n;
}
+int pp[2]; /* pipe descriptor */
+
int main(int ac, char **av)
{
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
- int pp[2]; /* pipe descriptor */
char rbuf[BUFSIZ], wbuf[BUFSIZ];
int pid, ret, len, rlen, status;
int sig = 0;
@@ -93,6 +95,10 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "dd", &pp[0], &pp[1]);
+#endif
+
setup();
for (lc = 0; TEST_LOOPING(lc); lc++) {
@@ -108,24 +114,19 @@
strcpy(wbuf, "abcd\0");
len = strlen(wbuf);
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0)
tst_brkm(TFAIL, cleanup, "fork() failed, errno %d",
errno);
if (pid == 0) {
/* CHILD */
- if (signal(SIGUSR2, catch_usr2) == SIG_ERR)
- tst_resm(TWARN, "signal setup for SIGUSR2 "
- "failed");
- if (signal(SIGPIPE, SIG_DFL) == SIG_ERR)
- tst_resm(TWARN, "signal setup for SIGPIPE "
- "failed");
- close(pp[0]); /* close read end of pipe */
- write(pp[1], wbuf, len);
- while(!usrsig)
- sleep(1);
- write(pp[1], wbuf, len);
- exit(1);
+#ifdef UCLINUX
+ if (self_exec(av[0], "dd", pp[0], pp[1]) < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed");
+ }
+#else
+ do_child();
+#endif
} else {
/* PARENT */
close(pp[1]); /* close write end of pipe */
@@ -159,6 +160,32 @@
}
/*
+ * do_child()
+ */
+void
+do_child()
+{
+ char wbuf[BUFSIZ];
+ int len;
+
+ strcpy(wbuf, "abcd\0");
+ len = strlen(wbuf);
+
+ if (signal(SIGUSR2, catch_usr2) == SIG_ERR)
+ tst_resm(TWARN, "signal setup for SIGUSR2 "
+ "failed");
+ if (signal(SIGPIPE, SIG_DFL) == SIG_ERR)
+ tst_resm(TWARN, "signal setup for SIGPIPE "
+ "failed");
+ close(pp[0]); /* close read end of pipe */
+ write(pp[1], wbuf, len);
+ while(!usrsig)
+ sleep(1);
+ write(pp[1], wbuf, len);
+ exit(1);
+}
+
+/*
* setup() - performs all ONE TIME setup for this test.
*/
void
diff --git a/testcases/kernel/syscalls/pipe/pipe04.c b/testcases/kernel/syscalls/pipe/pipe04.c
index d5857ca..d3e49d0 100644
--- a/testcases/kernel/syscalls/pipe/pipe04.c
+++ b/testcases/kernel/syscalls/pipe/pipe04.c
@@ -93,6 +93,11 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ maybe_run_child(&c1func, "ndd", 1, &fildes[0], &fildes[1]);
+ maybe_run_child(&c2func, "ndd", 2, &fildes[0], &fildes[1]);
+#endif
+
setup();
for (lc = 0; TEST_LOOPING(lc); lc++) {
@@ -104,16 +109,28 @@
tst_brkm(TBROK, cleanup, "pipe() failed - errno %d",
errno);
- if ((c1pid = fork()) == -1)
+ if ((c1pid = FORK_OR_VFORK()) == -1)
tst_brkm(TBROK, cleanup, "fork() failed - "
"errno %d", errno);
if (c1pid == 0)
+#ifdef UCLINUX
+ if (self_exec(av[0], "ndd", 1, fildes[0], fildes[1]) < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed");
+ }
+#else
c1func();
- if((c2pid = fork()) == -1)
+#endif
+ if((c2pid = FORK_OR_VFORK()) == -1)
tst_brkm(TBROK, cleanup, "fork() failed - "
"errno %d", errno);
if (c2pid == 0)
+#ifdef UCLINUX
+ if (self_exec(av[0], "ndd", 2, fildes[0], fildes[1]) < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed");
+ }
+#else
c2func();
+#endif
/* PARENT */
if (close(fildes[1]) == -1)
diff --git a/testcases/kernel/syscalls/pipe/pipe09.c b/testcases/kernel/syscalls/pipe/pipe09.c
index 962e4fd..7bedeca 100644
--- a/testcases/kernel/syscalls/pipe/pipe09.c
+++ b/testcases/kernel/syscalls/pipe/pipe09.c
@@ -110,7 +110,7 @@
continue;
}
- if ((fork_1 = fork()) == -1) {
+ if ((fork_1 = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() #1 failed");
/*NOTREACHED*/
}
@@ -139,7 +139,7 @@
"wait status %d, errno = %d", wtstatus, errno);
}
- if ((fork_2 = fork()) == -1) {
+ if ((fork_2 = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() #2 failed");
/*NOTREACHED*/
}
diff --git a/testcases/kernel/syscalls/pipe/pipe10.c b/testcases/kernel/syscalls/pipe/pipe10.c
index 693e262..641139e 100644
--- a/testcases/kernel/syscalls/pipe/pipe10.c
+++ b/testcases/kernel/syscalls/pipe/pipe10.c
@@ -116,7 +116,7 @@
tst_brkm(TBROK, cleanup, "write to pipe failed");
}
- forkstat = fork();
+ forkstat = FORK_OR_VFORK();
if (forkstat == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
diff --git a/testcases/kernel/syscalls/pipe/pipe11.c b/testcases/kernel/syscalls/pipe/pipe11.c
index ded87a6..ca59f48 100644
--- a/testcases/kernel/syscalls/pipe/pipe11.c
+++ b/testcases/kernel/syscalls/pipe/pipe11.c
@@ -58,6 +58,8 @@
int TST_TOTAL = 1;
extern int Tst_count;
+void do_child(void);
+void do_child_uclinux(void);
void setup(void);
void cleanup(void);
@@ -70,6 +72,7 @@
int szcharbuf; /* size of char buf */
int pipewrcnt; /* chars written to pipe */
char *wrbuf, *rdbuf;
+int fd[2]; /* fds for pipe read/write */
ssize_t safe_read(int fd, void *buf, size_t count)
{
@@ -87,10 +90,9 @@
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
- int fd[2]; /* fds for pipe read/write */
int i;
int fork_ret, status;
- int nread, written; /* no of chars read and written */
+ int written; /* no of chars read and written */
/* parse standard options */
if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
@@ -98,6 +100,11 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child_uclinux, "ddddd", &fd[0], &fd[1], &kidid,
+ &ncperchild, &szcharbuf);
+#endif
+
setup();
for (lc = 0; TEST_LOOPING(lc); lc++) {
@@ -124,7 +131,7 @@
refork:
++kidid;
- fork_ret = fork();
+ fork_ret = FORK_OR_VFORK();
if (fork_ret < 0) {
tst_brkm(TBROK, cleanup, "fork() failed");
@@ -136,22 +143,15 @@
}
if (fork_ret == 0) { /* child */
- if (close(fd[1])) {
- tst_resm(TINFO, "child %d " "could not close "
- "pipe", kidid);
- exit(0);
+#ifdef UCLINUX
+ if (self_exec(av[0], "ddddd", fd[0], fd[1], kidid,
+ ncperchild, szcharbuf) < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed");
+ /*NOTREACHED*/
}
- nread = safe_read(fd[0], rdbuf, ncperchild);
- if (nread == ncperchild) {
- tst_resm(TINFO, "child %d " "got %d chars",
- kidid, nread);
- exit(0);
- } else {
- tst_resm(TFAIL, "child %d did not receive "
- "expected no of characters, got %d "
- "characters", kidid, nread);
- exit(1);
- }
+#else
+ do_child();
+#endif
}
/* parent */
@@ -175,6 +175,44 @@
}
/*
+ * do_child()
+ */
+void
+do_child()
+{
+ int nread;
+
+ if (close(fd[1])) {
+ tst_resm(TINFO, "child %d " "could not close pipe", kidid);
+ exit(0);
+ }
+ nread = safe_read(fd[0], rdbuf, ncperchild);
+ if (nread == ncperchild) {
+ tst_resm(TINFO, "child %d " "got %d chars", kidid, nread);
+ exit(0);
+ } else {
+ tst_resm(TFAIL, "child %d did not receive expected no of "
+ "characters, got %d characters", kidid, nread);
+ exit(1);
+ }
+}
+
+/*
+ * do_child_uclinux() - as above, but mallocs rdbuf first
+ */
+void
+do_child_uclinux()
+{
+ if ((rdbuf = (char *)malloc(szcharbuf)) == (char *)0) {
+ tst_brkm(TBROK, cleanup, "malloc of rdbuf failed");
+ /*NOTREACHED*/
+ }
+
+ do_child();
+}
+
+
+/*
* setup() - performs all ONE TIME setup for this test.
*/
void
diff --git a/testcases/kernel/syscalls/poll/Makefile b/testcases/kernel/syscalls/poll/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/poll/Makefile
+++ b/testcases/kernel/syscalls/poll/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/poll/poll01.c b/testcases/kernel/syscalls/poll/poll01.c
index ae5957a..a37ef66 100644
--- a/testcases/kernel/syscalls/poll/poll01.c
+++ b/testcases/kernel/syscalls/poll/poll01.c
@@ -133,7 +133,7 @@
length=sizeof(write_buf);
/* Fork child process */
- if ((cpid = fork()) == -1) {
+ if ((cpid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
}
diff --git a/testcases/kernel/syscalls/prctl/Makefile b/testcases/kernel/syscalls/prctl/Makefile
index 23e660b..ba52850 100644
--- a/testcases/kernel/syscalls/prctl/Makefile
+++ b/testcases/kernel/syscalls/prctl/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/pread/Makefile b/testcases/kernel/syscalls/pread/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/pread/Makefile
+++ b/testcases/kernel/syscalls/pread/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/profil/Makefile b/testcases/kernel/syscalls/profil/Makefile
index 3eae260..ec20258 100644
--- a/testcases/kernel/syscalls/profil/Makefile
+++ b/testcases/kernel/syscalls/profil/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/ptrace/Makefile b/testcases/kernel/syscalls/ptrace/Makefile
index 23e660b..ba52850 100644
--- a/testcases/kernel/syscalls/ptrace/Makefile
+++ b/testcases/kernel/syscalls/ptrace/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/ptrace/ptrace01.c b/testcases/kernel/syscalls/ptrace/ptrace01.c
index c3f9c16..2998f1c 100644
--- a/testcases/kernel/syscalls/ptrace/ptrace01.c
+++ b/testcases/kernel/syscalls/ptrace/ptrace01.c
@@ -95,6 +95,7 @@
#include "test.h"
#include "usctest.h"
+static void do_child(void);
static void setup(void);
static void cleanup(void);
static void child_handler();
@@ -104,6 +105,7 @@
char *TCID = "ptrace01"; /* Test program identifier. */
extern int Tst_count; /* Test Case counter for tst_* routines */
+static int i; /* loop test case counter, shared with do_child */
int TST_TOTAL = 2;
@@ -111,12 +113,11 @@
main(int ac, char **av)
{
- int lc, i; /* loop counter */
+ int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
pid_t child_pid;
int status;
struct sigaction parent_act;
- struct sigaction child_act;
/* parse standard options */
if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL))
@@ -124,6 +125,10 @@
tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "d", &i);
+#endif
+
/* perform global setup for test */
setup();
@@ -149,7 +154,7 @@
}
}
- switch (child_pid = fork()) {
+ switch (child_pid = FORK_OR_VFORK()) {
case -1:
/* fork() failed */
@@ -158,35 +163,15 @@
case 0:
/* Child */
+#ifdef UCLINUX
+ if (self_exec(av[0], "d", i) < 0) {
+ tst_resm(TFAIL, "self_exec failed");
+ continue;
+ }
+#else
+ do_child();
+#endif
- /* Setup signal handler for child */
- if (i == 0) {
- child_act.sa_handler = SIG_IGN;
- } else {
- child_act.sa_handler = child_handler;
- }
- child_act.sa_flags = SA_RESTART;
-
- if ((sigaction(SIGUSR2, &child_act, NULL))
- == -1) {
- tst_resm(TWARN, "sigaction() failed"
- " in child");
- exit(1);
- }
-
- if ((ptrace(PTRACE_TRACEME, 0, 0 ,0)) == -1) {
- tst_resm(TWARN, "ptrace() failed in"
- " child");
- exit(1);
- }
- /* ensure that child bypasses signal handler */
- if ((kill(getpid(), SIGUSR2)) == -1) {
- tst_resm(TWARN, "kill() failed in"
- " child");
- exit(1);
- }
- exit(1);
-
default:
/* Parent */
if ((waitpid(child_pid, &status, 0)) < 0) {
@@ -240,6 +225,37 @@
}/* End main */
+/* do_child() */
+void
+do_child()
+{
+ struct sigaction child_act;
+
+ /* Setup signal handler for child */
+ if (i == 0) {
+ child_act.sa_handler = SIG_IGN;
+ } else {
+ child_act.sa_handler = child_handler;
+ }
+ child_act.sa_flags = SA_RESTART;
+
+ if ((sigaction(SIGUSR2, &child_act, NULL)) == -1) {
+ tst_resm(TWARN, "sigaction() failed in child");
+ exit(1);
+ }
+
+ if ((ptrace(PTRACE_TRACEME, 0, 0 ,0)) == -1) {
+ tst_resm(TWARN, "ptrace() failed in child");
+ exit(1);
+ }
+ /* ensure that child bypasses signal handler */
+ if ((kill(getpid(), SIGUSR2)) == -1) {
+ tst_resm(TWARN, "kill() failed in child");
+ exit(1);
+ }
+ exit(1);
+}
+
/* setup() - performs all ONE TIME setup for this test */
void
setup()
diff --git a/testcases/kernel/syscalls/ptrace/ptrace02.c b/testcases/kernel/syscalls/ptrace/ptrace02.c
index 13483df..d7d475a 100644
--- a/testcases/kernel/syscalls/ptrace/ptrace02.c
+++ b/testcases/kernel/syscalls/ptrace/ptrace02.c
@@ -95,6 +95,7 @@
#include "test.h"
#include "usctest.h"
+static void do_child(void);
static void setup(void);
static void cleanup(void);
static void child_handler();
@@ -104,6 +105,7 @@
char *TCID = "ptrace02"; /* Test program identifier. */
extern int Tst_count; /* Test Case counter for tst_* routines */
+static int i; /* loop test case counter, shared with do_child */
int TST_TOTAL = 2;
@@ -111,12 +113,11 @@
main(int ac, char **av)
{
- int lc, i; /* loop counter */
+ int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
pid_t child_pid;
int status;
struct sigaction parent_act;
- struct sigaction child_act;
/* parse standard options */
if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL))
@@ -124,6 +125,10 @@
tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "d", &i);
+#endif
+
/* perform global setup for test */
setup();
@@ -149,7 +154,7 @@
}
}
- switch (child_pid = fork()) {
+ switch (child_pid = FORK_OR_VFORK()) {
case -1:
/* fork() failed */
@@ -158,35 +163,14 @@
case 0:
/* Child */
-
- /* Setup signal handler for child */
- if (i == 0) {
- child_act.sa_handler = SIG_IGN;
- } else {
- child_act.sa_handler = child_handler;
+#ifdef UCLINUX
+ if (self_exec(av[0], "d", i) < 0) {
+ tst_resm(TFAIL, "self_exec failed");
+ continue;
}
- child_act.sa_flags = SA_RESTART;
-
- if ((sigaction(SIGUSR2, &child_act, NULL))
- == -1) {
- tst_resm(TWARN, "sigaction() failed"
- " in child");
- exit(1);
- }
-
- if ((ptrace(PTRACE_TRACEME, 0, 0 ,0)) == -1) {
- tst_resm(TWARN, "ptrace() failed in"
- " child");
- exit(1);
- }
-
- /* ensure that child bypasses signal handler */
- if ((kill(getpid(), SIGUSR2)) == -1) {
- tst_resm(TWARN, "kill() failed in"
- " child");
- exit(1);
- }
- exit(1);
+#else
+ do_child();
+#endif
default:
/* Parent */
@@ -242,6 +226,38 @@
}/* End main */
+/* do_child() */
+void
+do_child()
+{
+ struct sigaction child_act;
+
+ /* Setup signal handler for child */
+ if (i == 0) {
+ child_act.sa_handler = SIG_IGN;
+ } else {
+ child_act.sa_handler = child_handler;
+ }
+ child_act.sa_flags = SA_RESTART;
+
+ if ((sigaction(SIGUSR2, &child_act, NULL)) == -1) {
+ tst_resm(TWARN, "sigaction() failed in child");
+ exit(1);
+ }
+
+ if ((ptrace(PTRACE_TRACEME, 0, 0 ,0)) == -1) {
+ tst_resm(TWARN, "ptrace() failed in child");
+ exit(1);
+ }
+
+ /* ensure that child bypasses signal handler */
+ if ((kill(getpid(), SIGUSR2)) == -1) {
+ tst_resm(TWARN, "kill() failed in child");
+ exit(1);
+ }
+ exit(1);
+}
+
/* setup() - performs all ONE TIME setup for this test */
void
setup()
diff --git a/testcases/kernel/syscalls/pwrite/Makefile b/testcases/kernel/syscalls/pwrite/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/pwrite/Makefile
+++ b/testcases/kernel/syscalls/pwrite/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/pwrite/pwrite03.c b/testcases/kernel/syscalls/pwrite/pwrite03.c
index 8c94fb8..03a0e22 100644
--- a/testcases/kernel/syscalls/pwrite/pwrite03.c
+++ b/testcases/kernel/syscalls/pwrite/pwrite03.c
@@ -90,6 +90,8 @@
int exp_enos[] = {EFAULT,0};
+#if !defined(UCLINUX)
+
int
main(int ac, char **av)
{
@@ -158,6 +160,16 @@
return(0);
} /* End main */
+#else
+
+int main()
+{
+ tst_resm(TINFO,"pwrite03 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
+
/*
* setup() - performs all ONE TIME setup for this test.
diff --git a/testcases/kernel/syscalls/read/Makefile b/testcases/kernel/syscalls/read/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/read/Makefile
+++ b/testcases/kernel/syscalls/read/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/read/read02.c b/testcases/kernel/syscalls/read/read02.c
index 58d90f4..c1c914e 100644
--- a/testcases/kernel/syscalls/read/read02.c
+++ b/testcases/kernel/syscalls/read/read02.c
@@ -182,7 +182,8 @@
tst_brkm(TBROK, cleanup, "open of fd3 (temp file) failed");
}
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/readdir/Makefile b/testcases/kernel/syscalls/readdir/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/readdir/Makefile
+++ b/testcases/kernel/syscalls/readdir/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/readlink/Makefile b/testcases/kernel/syscalls/readlink/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/readlink/Makefile
+++ b/testcases/kernel/syscalls/readlink/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/readlink/readlink04.c b/testcases/kernel/syscalls/readlink/readlink04.c
index 91c0aa0..1d16ed0 100644
--- a/testcases/kernel/syscalls/readlink/readlink04.c
+++ b/testcases/kernel/syscalls/readlink/readlink04.c
@@ -236,7 +236,7 @@
cargv[2] = symfile_path;
cargv[3] = NULL;
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork failed");
}
diff --git a/testcases/kernel/syscalls/readv/Makefile b/testcases/kernel/syscalls/readv/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/readv/Makefile
+++ b/testcases/kernel/syscalls/readv/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/readv/readv02.c b/testcases/kernel/syscalls/readv/readv02.c
index ce66ee2..ae0492c 100644
--- a/testcases/kernel/syscalls/readv/readv02.c
+++ b/testcases/kernel/syscalls/readv/readv02.c
@@ -232,7 +232,8 @@
fd[1] = -1; /* Invalid file descriptor */
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/reboot/Makefile b/testcases/kernel/syscalls/reboot/Makefile
index 6729e34..0db7aa7 100644
--- a/testcases/kernel/syscalls/reboot/Makefile
+++ b/testcases/kernel/syscalls/reboot/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/recv/Makefile b/testcases/kernel/syscalls/recv/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/recv/Makefile
+++ b/testcases/kernel/syscalls/recv/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/recv/recv01.c b/testcases/kernel/syscalls/recv/recv01.c
index c30ac7a..4feabe1 100644
--- a/testcases/kernel/syscalls/recv/recv01.c
+++ b/testcases/kernel/syscalls/recv/recv01.c
@@ -61,8 +61,9 @@
char buf[1024];
int s; /* socket descriptor */
struct sockaddr_in sin1, sin2, sin3, sin4;
+static int sfd; /* shared between do_child and start_server */
-void setup(void), setup0(void), setup1(void),
+void do_child(void), setup(void), setup0(void), setup1(void),
cleanup(void), cleanup0(void), cleanup1(void);
pid_t start_server(struct sockaddr_in *);
@@ -95,6 +96,10 @@
extern int Tst_count;
+#ifdef UCLINUX
+static char *argv0;
+#endif
+
int
main(int argc, char *argv[])
{
@@ -107,6 +112,11 @@
tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ argv0 = argv[0];
+ maybe_run_child(&do_child, "d", &sfd);
+#endif
+
setup();
TEST_EXP_ENOS(exp_enos);
@@ -222,10 +232,8 @@
pid_t
start_server(struct sockaddr_in *sin0)
{
- struct sockaddr_in sin1 = *sin0, fsin;
- fd_set afds, rfds;
+ struct sockaddr_in sin1 = *sin0;
pid_t pid;
- int sfd, nfds, cc, fd;
sfd = socket(PF_INET, SOCK_STREAM, 0);
if (sfd < 0) {
@@ -243,8 +251,15 @@
strerror(errno));
return -1;
}
- switch ((pid = fork())) {
+ switch ((pid = FORK_OR_VFORK())) {
case 0: /* child */
+#ifdef UCLINUX
+ if (self_exec(argv0, "d", sfd) < 0) {
+ tst_brkm(TBROK, cleanup, "server self_exec failed");
+ }
+#else
+ do_child();
+#endif
break;
case -1:
tst_brkm(TBROK, cleanup, "server fork failed: %s",
@@ -255,6 +270,17 @@
return pid;
}
+ /*NOTREACHED*/
+ exit(1);
+}
+
+void
+do_child()
+{
+ struct sockaddr_in fsin;
+ fd_set afds, rfds;
+ int nfds, cc, fd;
+
FD_ZERO(&afds);
FD_SET(sfd, &afds);
diff --git a/testcases/kernel/syscalls/recvfrom/Makefile b/testcases/kernel/syscalls/recvfrom/Makefile
index d90584d..51645b2 100644
--- a/testcases/kernel/syscalls/recvfrom/Makefile
+++ b/testcases/kernel/syscalls/recvfrom/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -Wall -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/recvfrom/recvfrom01.c b/testcases/kernel/syscalls/recvfrom/recvfrom01.c
index 4ae60dc..f5ed530 100644
--- a/testcases/kernel/syscalls/recvfrom/recvfrom01.c
+++ b/testcases/kernel/syscalls/recvfrom/recvfrom01.c
@@ -61,8 +61,10 @@
char buf[1024];
int s; /* socket descriptor */
struct sockaddr_in sin1, from;
+static int sfd; /* shared between do_child and start_server */
socklen_t fromlen;
+void do_child(void);
void setup(void);
void setup0(void);
void setup1(void);
@@ -118,6 +120,10 @@
extern int Tst_count;
+#ifdef UCLINUX
+static char *argv0;
+#endif
+
int
main(int argc, char *argv[])
{
@@ -130,6 +136,11 @@
tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ argv0 = argv[0];
+ maybe_run_child(&do_child, "d", &sfd);
+#endif
+
setup();
TEST_EXP_ENOS(exp_enos);
@@ -251,10 +262,8 @@
pid_t
start_server(struct sockaddr_in *sin0)
{
- struct sockaddr_in sin1 = *sin0, fsin;
- fd_set afds, rfds;
+ struct sockaddr_in sin1 = *sin0;
pid_t pid;
- int sfd, nfds, cc, fd;
sfd = socket(PF_INET, SOCK_STREAM, 0);
if (sfd < 0) {
@@ -274,6 +283,13 @@
}
switch ((pid = fork())) {
case 0: /* child */
+#ifdef UCLINUX
+ if (self_exec(argv0, "d", sfd) < 0) {
+ tst_brkm(TBROK, cleanup, "server self_exec failed");
+ }
+#else
+ do_child();
+#endif
break;
case -1:
tst_brkm(TBROK, cleanup, "server fork failed: %s",
@@ -284,6 +300,17 @@
return pid;
}
+ /*NOTREACHED*/
+ exit(1);
+}
+
+void
+do_child()
+{
+ struct sockaddr_in fsin;
+ fd_set afds, rfds;
+ int nfds, cc, fd;
+
FD_ZERO(&afds);
FD_SET(sfd, &afds);
diff --git a/testcases/kernel/syscalls/recvmsg/Makefile b/testcases/kernel/syscalls/recvmsg/Makefile
index d90584d..51645b2 100644
--- a/testcases/kernel/syscalls/recvmsg/Makefile
+++ b/testcases/kernel/syscalls/recvmsg/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -Wall -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/recvmsg/recvmsg01.c b/testcases/kernel/syscalls/recvmsg/recvmsg01.c
index 160b6b1..36204d5 100644
--- a/testcases/kernel/syscalls/recvmsg/recvmsg01.c
+++ b/testcases/kernel/syscalls/recvmsg/recvmsg01.c
@@ -84,6 +84,8 @@
struct cmsghdr *control = 0;
int controllen = 0;
struct iovec iov[1];
+static int sfd; /* shared between do_child and start_server */
+static int ufd; /* shared between do_child and start_server */
void setup(void);
void setup0(void);
@@ -95,6 +97,7 @@
void cleanup0(void);
void cleanup1(void);
void cleanup2(void);
+void do_child(void);
void sender(int);
pid_t start_server(struct sockaddr_in *, struct sockaddr_un *);
@@ -169,6 +172,10 @@
extern int Tst_count;
+#ifdef UCLINUX
+static char *argv0;
+#endif
+
int
main(int argc, char *argv[])
{
@@ -181,6 +188,11 @@
tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ argv0 = argv[0];
+ maybe_run_child(&do_child, "dd", &sfd, &ufd);
+#endif
+
setup();
TEST_EXP_ENOS(exp_enos);
@@ -364,11 +376,7 @@
pid_t
start_server(struct sockaddr_in *ssin, struct sockaddr_un *ssun)
{
- struct sockaddr_in fsin;
- struct sockaddr_un fsun;
- fd_set afds, rfds;
pid_t pid;
- int sfd, nfds, cc, fd, ufd;
/* set up inet socket */
sfd = socket(PF_INET, SOCK_STREAM, 0);
@@ -407,6 +415,13 @@
switch ((pid = fork())) {
case 0: /* child */
+#ifdef UCLINUX
+ if (self_exec(argv0, "dd", sfd, ufd) < 0) {
+ tst_brkm(TBROK, cleanup, "server self_exec failed");
+ }
+#else
+ do_child();
+#endif
break;
case -1:
tst_brkm(TBROK, cleanup, "server fork failed: %s",
@@ -417,6 +432,18 @@
(void) close(ufd);
return pid;
}
+ /*NOTREACHED*/
+ exit(1);
+}
+
+void
+do_child()
+{
+ struct sockaddr_in fsin;
+ struct sockaddr_un fsun;
+ fd_set afds, rfds;
+ int nfds, cc, fd;
+
FD_ZERO(&afds);
FD_SET(sfd, &afds);
diff --git a/testcases/kernel/syscalls/rename/Makefile b/testcases/kernel/syscalls/rename/Makefile
index 15f9d40..5b561a0 100644
--- a/testcases/kernel/syscalls/rename/Makefile
+++ b/testcases/kernel/syscalls/rename/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp -L.. -ltestsuite
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/rename/rename08.c b/testcases/kernel/syscalls/rename/rename08.c
index e2a9f24..c8e0375 100644
--- a/testcases/kernel/syscalls/rename/rename08.c
+++ b/testcases/kernel/syscalls/rename/rename08.c
@@ -186,7 +186,8 @@
do_file_setup(fname);
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/rename/rename09.c b/testcases/kernel/syscalls/rename/rename09.c
index 82d9ce2..3997058 100644
--- a/testcases/kernel/syscalls/rename/rename09.c
+++ b/testcases/kernel/syscalls/rename/rename09.c
@@ -133,7 +133,7 @@
/* reset Tst_count in case we are looping. */
Tst_count=0;
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() #1 failed");
/*NOTREACHED*/
}
@@ -172,7 +172,7 @@
"up conditions for the test");
}
- if ((pid1 = fork()) == -1) {
+ if ((pid1 = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() #2 failed");
/*NOTREACHED*/
}
diff --git a/testcases/kernel/syscalls/rename/rename12.c b/testcases/kernel/syscalls/rename/rename12.c
index f8b3db2..1b77c42 100644
--- a/testcases/kernel/syscalls/rename/rename12.c
+++ b/testcases/kernel/syscalls/rename/rename12.c
@@ -133,7 +133,7 @@
* or effective uid
*/
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
/*NOTREACHED*/
}
diff --git a/testcases/kernel/syscalls/rename/rename14.c b/testcases/kernel/syscalls/rename/rename14.c
index 579cd90..1a9dad6 100644
--- a/testcases/kernel/syscalls/rename/rename14.c
+++ b/testcases/kernel/syscalls/rename/rename14.c
@@ -76,6 +76,18 @@
void dochild1();
void dochild2();
+#ifdef UCLINUX
+ char *msg; /* message returned from parse_opts */
+
+ /* Parse standard options given to run the test. */
+ msg = parse_opts(argc, argv, (option_t *)NULL, NULL);
+ if (msg != (char *)NULL) {
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ }
+
+ maybe_run_child(&dochild1, "n", 1);
+ maybe_run_child(&dochild2, "n", 2);
+#endif
sigemptyset(&set);
act.sa_handler = (void(*)())term;
act.sa_mask = set;
@@ -97,17 +109,22 @@
tst_tmpdir();
/*--------------------------------------------------------------*/
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0) {
tst_resm(TBROK,"fork() returned %d\n", pid);
tst_exit();
}
if (pid == 0) {
+#ifdef UCLINUX
+ if (self_exec(argv[0], "n", 1) < 0) {
+ tst_resm(TBROK,"self_exec failed");
+ }
+#else
dochild1();
- exit(0);
+#endif
}
kidpid[0] = pid;
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid < 0) {
(void)kill(kidpid[0], SIGTERM);
(void)unlink("./rename14");
@@ -115,8 +132,13 @@
tst_exit();
}
if (pid == 0) {
+#ifdef UCLINUX
+ if (self_exec(argv[0], "n", 1) < 0) {
+ tst_resm(TBROK,"self_exec failed");
+ }
+#else
dochild2();
- exit(0);
+#endif
}
kidpid[1] = pid;
diff --git a/testcases/kernel/syscalls/rmdir/Makefile b/testcases/kernel/syscalls/rmdir/Makefile
index 15f9d40..5b561a0 100644
--- a/testcases/kernel/syscalls/rmdir/Makefile
+++ b/testcases/kernel/syscalls/rmdir/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp -L.. -ltestsuite
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/rmdir/rmdir02.c b/testcases/kernel/syscalls/rmdir/rmdir02.c
index b77c375..4d6dc92 100644
--- a/testcases/kernel/syscalls/rmdir/rmdir02.c
+++ b/testcases/kernel/syscalls/rmdir/rmdir02.c
@@ -350,7 +350,8 @@
/* Create a temporary directory and make it current. */
tst_tmpdir();
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/rmdir/rmdir03.c b/testcases/kernel/syscalls/rmdir/rmdir03.c
index fbe9fbd..9eab027 100644
--- a/testcases/kernel/syscalls/rmdir/rmdir03.c
+++ b/testcases/kernel/syscalls/rmdir/rmdir03.c
@@ -74,6 +74,8 @@
#include "test.h"
#include "usctest.h"
+void dochild1();
+void dochild2();
void setup();
void cleanup();
extern struct passwd * my_getpwnam(char *);
@@ -99,9 +101,8 @@
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
pid_t pid;
- struct passwd *nobody;
struct stat buf1;
- int retval=0, e_code, status, status2;
+ int e_code, status, status2;
/*
* parse standard options
@@ -110,6 +111,11 @@
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&dochild1, "ns", 1, tstdir2);
+ maybe_run_child(&dochild2, "ns", 2, tstdir4);
+#endif
+
/*
* perform global setup for test
*/
@@ -163,47 +169,19 @@
"Could not create directory %s", tstdir2);
}
- nobody = my_getpwnam(user1name);
-
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
/*NOTREACHED*/
}
if (pid == 0) { /* first child */
- /* set to nobody */
- if (seteuid(nobody->pw_uid) == -1) {
- retval=1;
- tst_brkm(TBROK, cleanup, "setreuid failed to "
- "set effective uid to %d",
- nobody->pw_uid);
- /*NOTREACHED*/
- }
-
- /* rmdir tstdir2 */
- TEST(rmdir(tstdir2));
-
- if (TEST_ERRNO) {
- TEST_ERROR_LOG(TEST_ERRNO);
+#ifdef UCLINUX
+ if (self_exec(av[0], "ns", 1, tstdir2) < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed");
}
-
- if (TEST_RETURN != -1) {
- retval=1;
- tst_resm(TFAIL, "call succeeded unexpectedly");
- } else if ((TEST_ERRNO != EPERM)&&(TEST_ERRNO != EACCES)) {
- retval=1;
- tst_resm(TFAIL, "Expected EPERM or EACCES, got %d",
- TEST_ERRNO);
- } else {
- tst_resm(TPASS, "rmdir() produced EPERM or EACCES");
- }
-
- if (seteuid(0) == -1) {
- retval=1;
- tst_brkm(TBROK, cleanup, "seteuid(0) failed");
- }
- exit(retval);
- /* END of child 1 (test1) */
+#else
+ dochild1();
+#endif
}
/* Parent */
@@ -227,38 +205,13 @@
}
if (pid == 0) { /* child */
- /* set to nobody */
- if (seteuid(nobody->pw_uid) == -1) {
- retval = 1;
- tst_brkm(TBROK, cleanup, "setreuid failed to "
- "set effective uid to %d",
- nobody->pw_uid);
- /*NOTREACHED*/
+#ifdef UCLINUX
+ if (self_exec(av[0], "ns", 2, tstdir4) < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed");
}
-
- /* rmdir tstdir4*/
- TEST(rmdir(tstdir4));
-
- if (TEST_ERRNO) {
- TEST_ERROR_LOG(TEST_ERRNO);
- }
-
- if (TEST_RETURN != -1) {
- retval = 1;
- tst_resm(TFAIL, "call succeeded unexpectedly");
- } else if (TEST_ERRNO != EACCES) {
- retval = 1;
- tst_resm(TFAIL, "Expected EACCES got %d",
- TEST_ERRNO);
- } else {
- tst_resm(TPASS, "rmdir() produced EACCES");
- }
-
- if (seteuid(0) == -1) {
- retval = 1;
- tst_brkm(TBROK, cleanup, "seteuid(0) failed");
- }
- exit(retval);
+#else
+ dochild2();
+#endif
} else { /* parent */
/* wait for the child to finish */
wait(&status);
@@ -297,6 +250,89 @@
} /* End main */
/*
+ * dochild1()
+ */
+void
+dochild1()
+{
+ int retval = 0;
+ struct passwd *nobody = my_getpwnam(user1name);
+
+ /* set to nobody */
+ if (seteuid(nobody->pw_uid) == -1) {
+ retval=1;
+ tst_brkm(TBROK, cleanup, "setreuid failed to "
+ "set effective uid to %d", nobody->pw_uid);
+ /*NOTREACHED*/
+ }
+
+ /* rmdir tstdir2 */
+ TEST(rmdir(tstdir2));
+
+ if (TEST_ERRNO) {
+ TEST_ERROR_LOG(TEST_ERRNO);
+ }
+
+ if (TEST_RETURN != -1) {
+ retval=1;
+ tst_resm(TFAIL, "call succeeded unexpectedly");
+ } else if ((TEST_ERRNO != EPERM)&&(TEST_ERRNO != EACCES)) {
+ retval=1;
+ tst_resm(TFAIL, "Expected EPERM or EACCES, got %d", TEST_ERRNO);
+ } else {
+ tst_resm(TPASS, "rmdir() produced EPERM or EACCES");
+ }
+
+ if (seteuid(0) == -1) {
+ retval=1;
+ tst_brkm(TBROK, cleanup, "seteuid(0) failed");
+ }
+ exit(retval);
+ /* END of child 1 (test1) */
+}
+
+/*
+ * dochild1()
+ */
+void
+dochild2()
+{
+ int retval = 0;
+ struct passwd *nobody = my_getpwnam(user1name);
+
+ /* set to nobody */
+ if (seteuid(nobody->pw_uid) == -1) {
+ retval = 1;
+ tst_brkm(TBROK, cleanup, "setreuid failed to "
+ "set effective uid to %d", nobody->pw_uid);
+ /*NOTREACHED*/
+ }
+
+ /* rmdir tstdir4*/
+ TEST(rmdir(tstdir4));
+
+ if (TEST_ERRNO) {
+ TEST_ERROR_LOG(TEST_ERRNO);
+ }
+
+ if (TEST_RETURN != -1) {
+ retval = 1;
+ tst_resm(TFAIL, "call succeeded unexpectedly");
+ } else if (TEST_ERRNO != EACCES) {
+ retval = 1;
+ tst_resm(TFAIL, "Expected EACCES got %d", TEST_ERRNO);
+ } else {
+ tst_resm(TPASS, "rmdir() produced EACCES");
+ }
+
+ if (seteuid(0) == -1) {
+ retval = 1;
+ tst_brkm(TBROK, cleanup, "seteuid(0) failed");
+ }
+ exit(retval);
+}
+
+/*
* setup() - performs all ONE TIME setup for this test.
*/
void
diff --git a/testcases/kernel/syscalls/rmdir/rmdir05.c b/testcases/kernel/syscalls/rmdir/rmdir05.c
index afa78ff..a9025bc 100644
--- a/testcases/kernel/syscalls/rmdir/rmdir05.c
+++ b/testcases/kernel/syscalls/rmdir/rmdir05.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: rmdir05.c,v 1.2 2002/07/23 13:11:19 plars Exp $ */
+/* $Id: rmdir05.c,v 1.3 2005/07/11 22:28:56 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -107,10 +107,14 @@
void cleanup();
+#if !defined(UCLINUX)
extern char *get_high_address();
+int TST_TOTAL=6;
+#else
+int TST_TOTAL=5;
+#endif
char *TCID="rmdir05"; /* Test program identifier. */
-int TST_TOTAL=6; /* Total number of test cases. */
extern int Tst_count; /* Test Case counter for tst_* routines. */
struct stat stat_buf; /* Stat buffer used for verification. */
char dir_name[256]; /* Array to hold directory name. */
@@ -304,7 +308,8 @@
tst_resm(TFAIL,"rmdir() - path argument points below the minimum allocated address space succeeded unexpectedly.");
}
}
-
+
+#if !defined(UCLINUX)
/*
* TEST CASE: 5
* path argument points above the maximum allocated address space
@@ -333,7 +338,8 @@
} else {
tst_resm(TFAIL,"rmdir() - path argument points above the maximum allocated address space succeeded unexpectedly.");
}
- }
+ }
+#endif
/*
* TEST CASE: 6
@@ -414,7 +420,8 @@
/* Create a unique directory name. */
sprintf(dir_name,"./dir_%d",getpid());
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/sbrk/Makefile b/testcases/kernel/syscalls/sbrk/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/sbrk/Makefile
+++ b/testcases/kernel/syscalls/sbrk/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sbrk/sbrk01.c b/testcases/kernel/syscalls/sbrk/sbrk01.c
index 11d46b7..ab92c63 100644
--- a/testcases/kernel/syscalls/sbrk/sbrk01.c
+++ b/testcases/kernel/syscalls/sbrk/sbrk01.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: sbrk01.c,v 1.2 2002/06/12 17:43:17 plars Exp $ */
+/* $Id: sbrk01.c,v 1.3 2005/07/11 22:28:56 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -129,6 +129,8 @@
int Increment; /* Amount to make change size by */
+#if !defined(UCLINUX)
+
int
main(int ac, char **av)
{
@@ -223,6 +225,16 @@
return 0;
} /* End main */
+#else
+
+int main()
+{
+ tst_resm(TINFO,"sbrk01 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX) */
+
/***************************************************************
* setup() - performs all ONE TIME setup for this test.
***************************************************************/
diff --git a/testcases/kernel/syscalls/sched_get_priority_max/Makefile b/testcases/kernel/syscalls/sched_get_priority_max/Makefile
index 6729e34..0db7aa7 100644
--- a/testcases/kernel/syscalls/sched_get_priority_max/Makefile
+++ b/testcases/kernel/syscalls/sched_get_priority_max/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sched_get_priority_min/Makefile b/testcases/kernel/syscalls/sched_get_priority_min/Makefile
index 44a677f..f1b0226 100644
--- a/testcases/kernel/syscalls/sched_get_priority_min/Makefile
+++ b/testcases/kernel/syscalls/sched_get_priority_min/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -Wall -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sched_getparam/Makefile b/testcases/kernel/syscalls/sched_getparam/Makefile
index 44a677f..f1b0226 100644
--- a/testcases/kernel/syscalls/sched_getparam/Makefile
+++ b/testcases/kernel/syscalls/sched_getparam/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -Wall -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sched_getparam/sched_getparam02.c b/testcases/kernel/syscalls/sched_getparam/sched_getparam02.c
index edc0d73..902f368 100644
--- a/testcases/kernel/syscalls/sched_getparam/sched_getparam02.c
+++ b/testcases/kernel/syscalls/sched_getparam/sched_getparam02.c
@@ -110,7 +110,7 @@
/* reset Tst_count in case we are looping. */
Tst_count = 0;
- switch(child_pid = fork()) {
+ switch(child_pid = FORK_OR_VFORK()) {
case -1:
/* fork() failed */
diff --git a/testcases/kernel/syscalls/sched_getscheduler/Makefile b/testcases/kernel/syscalls/sched_getscheduler/Makefile
index d90584d..51645b2 100644
--- a/testcases/kernel/syscalls/sched_getscheduler/Makefile
+++ b/testcases/kernel/syscalls/sched_getscheduler/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -Wall -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/Makefile b/testcases/kernel/syscalls/sched_rr_get_interval/Makefile
index 6729e34..0db7aa7 100644
--- a/testcases/kernel/syscalls/sched_rr_get_interval/Makefile
+++ b/testcases/kernel/syscalls/sched_rr_get_interval/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sched_setparam/Makefile b/testcases/kernel/syscalls/sched_setparam/Makefile
index 44a677f..f1b0226 100644
--- a/testcases/kernel/syscalls/sched_setparam/Makefile
+++ b/testcases/kernel/syscalls/sched_setparam/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -Wall -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sched_setscheduler/Makefile b/testcases/kernel/syscalls/sched_setscheduler/Makefile
index 15f9d40..5b561a0 100644
--- a/testcases/kernel/syscalls/sched_setscheduler/Makefile
+++ b/testcases/kernel/syscalls/sched_setscheduler/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp -L.. -ltestsuite
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler02.c b/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler02.c
index 898ec94..43afae7 100644
--- a/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler02.c
+++ b/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler02.c
@@ -94,7 +94,7 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork failed");
}
diff --git a/testcases/kernel/syscalls/sched_yield/Makefile b/testcases/kernel/syscalls/sched_yield/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/sched_yield/Makefile
+++ b/testcases/kernel/syscalls/sched_yield/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/select/Makefile b/testcases/kernel/syscalls/select/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/select/Makefile
+++ b/testcases/kernel/syscalls/select/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/send/Makefile b/testcases/kernel/syscalls/send/Makefile
index 52f4b97..ead9fb1 100644
--- a/testcases/kernel/syscalls/send/Makefile
+++ b/testcases/kernel/syscalls/send/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/send/send01.c b/testcases/kernel/syscalls/send/send01.c
index fd9940b..3c5a8f2 100644
--- a/testcases/kernel/syscalls/send/send01.c
+++ b/testcases/kernel/syscalls/send/send01.c
@@ -61,9 +61,10 @@
char buf[1024], bigbuf[128*1024];
int s; /* socket descriptor */
struct sockaddr_in sin1;
+static int sfd; /* shared between do_child and start_server */
void setup(void), setup0(void), setup1(void), setup2(void),
- cleanup(void), cleanup0(void), cleanup1(void);
+ do_child(void), cleanup(void), cleanup0(void), cleanup1(void);
struct test_case_t { /* test case structure */
int domain; /* PF_INET, PF_UNIX, ... */
@@ -98,13 +99,15 @@
extern int Tst_count;
+#ifdef UCLINUX
+static char *argv0;
+#endif
+
pid_t
start_server(struct sockaddr_in *sin0)
{
- struct sockaddr_in sin1 = *sin0, fsin;
- fd_set afds, rfds;
+ struct sockaddr_in sin1 = *sin0;
pid_t pid;
- int sfd, nfds, cc, fd;
sfd = socket(PF_INET, SOCK_STREAM, 0);
if (sfd < 0) {
@@ -122,8 +125,15 @@
strerror(errno));
return -1;
}
- switch ((pid = fork())) {
+ switch ((pid = FORK_OR_VFORK())) {
case 0: /* child */
+#ifdef UCLINUX
+ if (self_exec(argv0, "d", sfd) < 0) {
+ tst_brkm(TBROK, cleanup, "server self_exec failed");
+ }
+#else
+ do_child();
+#endif
break;
case -1:
tst_brkm(TBROK, cleanup, "server fork failed: %s",
@@ -134,6 +144,17 @@
return pid;
}
+ /*NOTREACHED*/
+ exit(1);
+}
+
+void
+do_child()
+{
+ fd_set afds, rfds;
+ int nfds, cc, fd;
+ struct sockaddr_in fsin;
+
FD_ZERO(&afds);
FD_SET(sfd, &afds);
@@ -181,6 +202,11 @@
tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ argv0 = av[0];
+ maybe_run_child(&do_child, "d", &sfd);
+#endif
+
setup();
TEST_EXP_ENOS(exp_enos);
diff --git a/testcases/kernel/syscalls/sendfile/Makefile b/testcases/kernel/syscalls/sendfile/Makefile
index 8d67e35..9f54fe8 100644
--- a/testcases/kernel/syscalls/sendfile/Makefile
+++ b/testcases/kernel/syscalls/sendfile/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the sendfile(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LDLIBS+= -L../../../../lib -lltp
+LDLIBS+= $(if $(UCLINUX),-lc)
DIR=sendfile
MAINS=sendfile02 sendfile03
diff --git a/testcases/kernel/syscalls/sendfile/sendfile02.c b/testcases/kernel/syscalls/sendfile/sendfile02.c
index 08ad3ae..62b4cd8 100644
--- a/testcases/kernel/syscalls/sendfile/sendfile02.c
+++ b/testcases/kernel/syscalls/sendfile/sendfile02.c
@@ -66,8 +66,10 @@
int out_fd;
pid_t child_pid;
static int sockfd, s;
+static struct sockaddr_in sin1; /* shared between do_child and create_server */
void cleanup(void);
+void do_child(void);
void setup(void);
int create_server(void);
@@ -82,6 +84,10 @@
{ "Test sendfile(2) with offset in the middle of file", 6, 20 }
};
+#ifdef UCLINUX
+static char* argv0;
+#endif
+
void do_sendfile(off_t offset, int i)
{
int in_fd;
@@ -134,6 +140,23 @@
}
/*
+ * do_child
+ */
+void
+do_child()
+{
+ int lc;
+ int length;
+ char rbuf[4096];
+
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+ length = sizeof(sin1);
+ recvfrom(sockfd, rbuf, 4096, 0, (struct sockaddr*)&sin1, &length);
+ }
+ exit(0);
+}
+
+/*
* setup() - performs all ONE TIME setup for this test.
*/
void
@@ -187,10 +210,6 @@
}
int create_server(void) {
- int lc;
- int length;
- char rbuf[4096];
- struct sockaddr_in sin1;
static int count=0;
sockfd = socket(PF_INET, SOCK_DGRAM, 0);
@@ -207,18 +226,22 @@
strerror(errno));
return -1;
}
- child_pid = fork();
+ child_pid = FORK_OR_VFORK();
if(child_pid < 0) {
tst_brkm(TBROK, cleanup, "client/server fork failed: %s",
strerror(errno));
return -1;
}
- if(!child_pid) {
- for (lc = 0; TEST_LOOPING(lc); lc++) {
- length = sizeof(sin1);
- recvfrom(sockfd, rbuf, 4096, 0, (struct sockaddr*)&sin1, &length);
+ if(!child_pid) { /* child */
+#ifdef UCLINUX
+ if(self_exec(argv0, "") < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed");
+ return -1;
+
}
- exit(0);
+#else
+ do_child();
+#endif
}
s = socket(PF_INET, SOCK_DGRAM, 0);
@@ -247,6 +270,11 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ argv0 = av[0];
+ maybe_run_child(&do_child, "");
+#endif
+
setup();
/*
diff --git a/testcases/kernel/syscalls/sendmsg/Makefile b/testcases/kernel/syscalls/sendmsg/Makefile
index bf45aa0..a89bf0f 100644
--- a/testcases/kernel/syscalls/sendmsg/Makefile
+++ b/testcases/kernel/syscalls/sendmsg/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the sendmsg(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sendmsg/sendmsg01.c b/testcases/kernel/syscalls/sendmsg/sendmsg01.c
index 4ec460d..2021b93 100644
--- a/testcases/kernel/syscalls/sendmsg/sendmsg01.c
+++ b/testcases/kernel/syscalls/sendmsg/sendmsg01.c
@@ -89,10 +89,13 @@
struct cmsghdr *control = 0;
int controllen = 0;
struct iovec iov[1];
+static int sfd; /* shared between do_child and start_server */
+static int ufd; /* shared between do_child and start_server */
void setup(void), setup0(void), setup1(void), setup2(void), setup3(void),
setup4(void), setup5(void), setup6(void), setup7(void), setup8(void),
- cleanup(void), cleanup0(void), cleanup1(void), cleanup4(void);
+ cleanup(void), cleanup0(void), cleanup1(void), cleanup4(void),
+ do_child(void);
struct test_case_t { /* test case structure */
int domain; /* PF_INET, PF_UNIX, ... */
@@ -185,6 +188,10 @@
extern int Tst_count;
+#ifdef UCLINUX
+static char *argv0;
+#endif
+
int
main(int argc, char *argv[])
{
@@ -197,6 +204,12 @@
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
tst_exit();
}
+
+#ifdef UCLINUX
+ argv0 = argv[0];
+ maybe_run_child(&do_child, "dd", &sfd, &ufd);
+#endif
+
setup();
TEST_EXP_ENOS(exp_enos);
@@ -248,11 +261,8 @@
pid_t
start_server(struct sockaddr_in *sin0, struct sockaddr_un *sun0)
{
- struct sockaddr_in sin1 = *sin0, fsin;
- struct sockaddr_un fsun;
- fd_set afds, rfds;
+ struct sockaddr_in sin1 = *sin0;
pid_t pid;
- int sfd, nfds, cc, fd, ufd;
/* set up inet socket */
sfd = socket(PF_INET, SOCK_STREAM, 0);
@@ -284,8 +294,15 @@
return -1;
}
- switch ((pid = fork())) {
+ switch ((pid = FORK_OR_VFORK())) {
case 0: /* child */
+#ifdef UCLINUX
+ if (self_exec(argv0, "dd", sfd, ufd) < 0) {
+ tst_brkm(TBROK, cleanup, "server self_exec failed");
+ }
+#else
+ do_child();
+#endif
break;
case -1:
tst_brkm(TBROK, cleanup, "server fork failed: %s",
@@ -297,6 +314,18 @@
return pid;
}
+ /*NOTREACHED*/
+ exit(1);
+}
+
+void
+do_child()
+{
+ struct sockaddr_in fsin;
+ struct sockaddr_un fsun;
+ fd_set afds, rfds;
+ int nfds, cc, fd;
+
FD_ZERO(&afds);
FD_SET(sfd, &afds);
FD_SET(ufd, &afds);
diff --git a/testcases/kernel/syscalls/sendto/Makefile b/testcases/kernel/syscalls/sendto/Makefile
index c678975..539b9d2 100644
--- a/testcases/kernel/syscalls/sendto/Makefile
+++ b/testcases/kernel/syscalls/sendto/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the sendto(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sendto/sendto01.c b/testcases/kernel/syscalls/sendto/sendto01.c
index fae5d7e..874de12 100644
--- a/testcases/kernel/syscalls/sendto/sendto01.c
+++ b/testcases/kernel/syscalls/sendto/sendto01.c
@@ -62,9 +62,10 @@
char buf[1024], bigbuf[128*1024];
int s; /* socket descriptor */
struct sockaddr_in sin1, sin2;
+static int sfd; /* shared between do_child and start_server */
void setup(void), setup0(void), setup1(void), setup2(void), setup3(void),
- cleanup(void), cleanup0(void), cleanup1(void);
+ do_child(void), cleanup(void), cleanup0(void), cleanup1(void);
struct test_case_t { /* test case structure */
int domain; /* PF_INET, PF_UNIX, ... */
@@ -112,13 +113,15 @@
extern int Tst_count;
+#ifdef UCLINUX
+static char *argv0;
+#endif
+
pid_t
start_server(struct sockaddr_in *sin0)
{
- struct sockaddr_in sin1 = *sin0, fsin;
- fd_set afds, rfds;
+ struct sockaddr_in sin1 = *sin0;
pid_t pid;
- int sfd, nfds, cc, fd;
sfd = socket(PF_INET, SOCK_STREAM, 0);
if (sfd < 0) {
@@ -136,8 +139,15 @@
strerror(errno));
return -1;
}
- switch ((pid = fork())) {
+ switch ((pid = FORK_OR_VFORK())) {
case 0: /* child */
+#ifdef UCLINUX
+ if (self_exec(argv0, "d", sfd) < 0) {
+ tst_brkm(TBROK, cleanup, "server self_exec failed");
+ }
+#else
+ do_child();
+#endif
break;
case -1:
tst_brkm(TBROK, cleanup, "server fork failed: %s",
@@ -148,6 +158,17 @@
return pid;
}
+ /*NOTREACHED*/
+ exit(1);
+}
+
+void
+do_child()
+{
+ struct sockaddr_in fsin;
+ fd_set afds, rfds;
+ int nfds, cc, fd;
+
FD_ZERO(&afds);
FD_SET(sfd, &afds);
@@ -195,6 +216,11 @@
tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ argv0 = av[0];
+ maybe_run_child(&do_child, "d", &sfd);
+#endif
+
setup();
TEST_EXP_ENOS(exp_enos);
diff --git a/testcases/kernel/syscalls/setdomainname/Makefile b/testcases/kernel/syscalls/setdomainname/Makefile
index 6729e34..0db7aa7 100644
--- a/testcases/kernel/syscalls/setdomainname/Makefile
+++ b/testcases/kernel/syscalls/setdomainname/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setegid/Makefile b/testcases/kernel/syscalls/setegid/Makefile
index 8724023..4a97ba5 100644
--- a/testcases/kernel/syscalls/setegid/Makefile
+++ b/testcases/kernel/syscalls/setegid/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setfsgid/Makefile b/testcases/kernel/syscalls/setfsgid/Makefile
index 660daaa..421d78f 100644
--- a/testcases/kernel/syscalls/setfsgid/Makefile
+++ b/testcases/kernel/syscalls/setfsgid/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the setfsgid(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setfsuid/Makefile b/testcases/kernel/syscalls/setfsuid/Makefile
index 38e7f0f..c23e419 100644
--- a/testcases/kernel/syscalls/setfsuid/Makefile
+++ b/testcases/kernel/syscalls/setfsuid/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the setfsuid(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setgid/Makefile b/testcases/kernel/syscalls/setgid/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/setgid/Makefile
+++ b/testcases/kernel/syscalls/setgid/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setgroups/Makefile b/testcases/kernel/syscalls/setgroups/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/setgroups/Makefile
+++ b/testcases/kernel/syscalls/setgroups/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setgroups/setgroups04.c b/testcases/kernel/syscalls/setgroups/setgroups04.c
index 2c3f80b..93c436a 100644
--- a/testcases/kernel/syscalls/setgroups/setgroups04.c
+++ b/testcases/kernel/syscalls/setgroups/setgroups04.c
@@ -80,6 +80,8 @@
void setup(); /* setup function for the test */
void cleanup(); /* cleanup function for the test */
+#if !defined(UCLINUX)
+
int
main(int ac, char **av)
{
@@ -145,6 +147,16 @@
return(0);
}
+#else
+
+int main()
+{
+ tst_resm(TINFO,"setgroups04 test is not available on UCLINUX");
+ return 0;
+}
+
+#endif /* if !defined(UCLINUX)
+
/*
* setup()
*/
diff --git a/testcases/kernel/syscalls/sethostname/Makefile b/testcases/kernel/syscalls/sethostname/Makefile
index eea5fac..b2bdf26 100644
--- a/testcases/kernel/syscalls/sethostname/Makefile
+++ b/testcases/kernel/syscalls/sethostname/Makefile
@@ -21,7 +21,9 @@
# description : make(1) description file for the send(2) tests. #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setitimer/Makefile b/testcases/kernel/syscalls/setitimer/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/setitimer/Makefile
+++ b/testcases/kernel/syscalls/setitimer/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setpgid/Makefile b/testcases/kernel/syscalls/setpgid/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/setpgid/Makefile
+++ b/testcases/kernel/syscalls/setpgid/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setpgid/setpgid01.c b/testcases/kernel/syscalls/setpgid/setpgid01.c
index fe66b6f..47db4fd 100644
--- a/testcases/kernel/syscalls/setpgid/setpgid01.c
+++ b/testcases/kernel/syscalls/setpgid/setpgid01.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: setpgid01.c,v 1.1 2001/08/27 22:15:15 plars Exp $ */
+/* $Id: setpgid01.c,v 1.2 2005/07/11 22:29:01 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -208,7 +208,7 @@
pid=getpid();
if (pgid == pid) {
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() in setup() failed - errno %d",
errno);
}
diff --git a/testcases/kernel/syscalls/setpgid/setpgid03.c b/testcases/kernel/syscalls/setpgid/setpgid03.c
index ab27a84..a923d9b 100644
--- a/testcases/kernel/syscalls/setpgid/setpgid03.c
+++ b/testcases/kernel/syscalls/setpgid/setpgid03.c
@@ -48,6 +48,7 @@
int TST_TOTAL = 1;
extern int Tst_count;
+void do_child(void);
void setup(void);
void cleanup(void);
@@ -67,6 +68,10 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "");
+#endif
+
/*
* perform global setup for the test
*/
@@ -80,19 +85,18 @@
//test1:
/* sid of the calling process is not same */
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
}
if (pid == 0) { /* child */
- exno = 0;
- if (setsid() < 0) {
- tst_resm(TFAIL, "setsid failed, errno "
- ":%d", errno);
- exno = 1;
+#ifdef UCLINUX
+ if (self_exec(av[0], "") < 0) {
+ tst_brkm(TBROK, cleanup, "self_exec failed");
}
- sleep(2);
- exit(exno);
+#else
+ do_child();
+#endif
} else { /* parent */
sleep(1);
rval = setpgid(pid, getppid());
@@ -129,7 +133,7 @@
* Value of pid matches the pid of the child process and
* the child process has exec successfully. Error
*/
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_resm(TFAIL, "Fork failed");
tst_exit();
}
@@ -164,6 +168,22 @@
}
/*
+ * do_child()
+ */
+void
+do_child()
+{
+ int exno = 0;
+
+ if (setsid() < 0) {
+ tst_resm(TFAIL, "setsid failed, errno :%d", errno);
+ exno = 1;
+ }
+ sleep(2);
+ exit(exno);
+}
+
+/*
* setup()
* performs all ONE TIME setup for this test
*/
diff --git a/testcases/kernel/syscalls/setpgrp/Makefile b/testcases/kernel/syscalls/setpgrp/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/setpgrp/Makefile
+++ b/testcases/kernel/syscalls/setpgrp/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setpgrp/setpgrp01.c b/testcases/kernel/syscalls/setpgrp/setpgrp01.c
index 50f9a10..3d406bd 100644
--- a/testcases/kernel/syscalls/setpgrp/setpgrp01.c
+++ b/testcases/kernel/syscalls/setpgrp/setpgrp01.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: setpgrp01.c,v 1.1 2001/08/27 22:15:15 plars Exp $ */
+/* $Id: setpgrp01.c,v 1.2 2005/07/11 22:29:02 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -210,7 +210,7 @@
*/
if (getpgrp() == getpid()) {
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() in setup() failed - errno %d",
errno);
}
diff --git a/testcases/kernel/syscalls/setpgrp/setpgrp02.c b/testcases/kernel/syscalls/setpgrp/setpgrp02.c
index 31da405..115ff5f 100644
--- a/testcases/kernel/syscalls/setpgrp/setpgrp02.c
+++ b/testcases/kernel/syscalls/setpgrp/setpgrp02.c
@@ -78,7 +78,7 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
}
diff --git a/testcases/kernel/syscalls/setpriority/Makefile b/testcases/kernel/syscalls/setpriority/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/setpriority/Makefile
+++ b/testcases/kernel/syscalls/setpriority/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setregid/Makefile b/testcases/kernel/syscalls/setregid/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/setregid/Makefile
+++ b/testcases/kernel/syscalls/setregid/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setregid/setregid03.c b/testcases/kernel/syscalls/setregid/setregid03.c
index 81819c6..4cea2a4 100644
--- a/testcases/kernel/syscalls/setregid/setregid03.c
+++ b/testcases/kernel/syscalls/setregid/setregid03.c
@@ -153,7 +153,7 @@
/*NOTREACHED*/
}
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork failed");
/*NOTREACHED*/
} else if (pid == 0) { /* child */
diff --git a/testcases/kernel/syscalls/setresgid/Makefile b/testcases/kernel/syscalls/setresgid/Makefile
index d1eaf54..7b07ae3 100644
--- a/testcases/kernel/syscalls/setresgid/Makefile
+++ b/testcases/kernel/syscalls/setresgid/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall -g
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setresuid/Makefile b/testcases/kernel/syscalls/setresuid/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/setresuid/Makefile
+++ b/testcases/kernel/syscalls/setresuid/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setresuid/setresuid02.c b/testcases/kernel/syscalls/setresuid/setresuid02.c
index 2464437..9223ef1 100644
--- a/testcases/kernel/syscalls/setresuid/setresuid02.c
+++ b/testcases/kernel/syscalls/setresuid/setresuid02.c
@@ -139,7 +139,7 @@
/*NOTREACHED*/
}
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork failed");
/*NOTREACHED*/
} else if (pid == 0) { /* child */
diff --git a/testcases/kernel/syscalls/setresuid/setresuid03.c b/testcases/kernel/syscalls/setresuid/setresuid03.c
index c34f5a9..a7635d8 100644
--- a/testcases/kernel/syscalls/setresuid/setresuid03.c
+++ b/testcases/kernel/syscalls/setresuid/setresuid03.c
@@ -149,7 +149,7 @@
/*NOTREACHED*/
}
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork failed");
/*NOTREACHED*/
} else if (pid == 0) { /* child */
diff --git a/testcases/kernel/syscalls/setreuid/Makefile b/testcases/kernel/syscalls/setreuid/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/setreuid/Makefile
+++ b/testcases/kernel/syscalls/setreuid/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setreuid/setreuid04.c b/testcases/kernel/syscalls/setreuid/setreuid04.c
index 719c717..5379ba1 100644
--- a/testcases/kernel/syscalls/setreuid/setreuid04.c
+++ b/testcases/kernel/syscalls/setreuid/setreuid04.c
@@ -127,7 +127,7 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork failed");
/*NOTREACHED*/
} else if (pid == 0) { /* child */
diff --git a/testcases/kernel/syscalls/setreuid/setreuid05.c b/testcases/kernel/syscalls/setreuid/setreuid05.c
index 4586b80..f8f0fc2 100644
--- a/testcases/kernel/syscalls/setreuid/setreuid05.c
+++ b/testcases/kernel/syscalls/setreuid/setreuid05.c
@@ -141,7 +141,7 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork failed");
/*NOTREACHED*/
} else if (pid == 0) { /* child */
diff --git a/testcases/kernel/syscalls/setrlimit/Makefile b/testcases/kernel/syscalls/setrlimit/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/setrlimit/Makefile
+++ b/testcases/kernel/syscalls/setrlimit/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit01.c b/testcases/kernel/syscalls/setrlimit/setrlimit01.c
index e259bc0..8f664e2 100644
--- a/testcases/kernel/syscalls/setrlimit/setrlimit01.c
+++ b/testcases/kernel/syscalls/setrlimit/setrlimit01.c
@@ -170,7 +170,7 @@
* output will be saved to the logfile (instead of stdout)
* when the testcase (parent) is run from the driver.
*/
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
}
@@ -253,7 +253,7 @@
}
for (i = 0; i < 20; i++) {
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
if (errno != EAGAIN) {
tst_resm(TWARN, "Expected EAGAIN got %d",
errno);
@@ -292,7 +292,7 @@
return;
}
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
}
diff --git a/testcases/kernel/syscalls/setrlimit/setrlimit03.c b/testcases/kernel/syscalls/setrlimit/setrlimit03.c
index 856dd2b..082f8a2 100644
--- a/testcases/kernel/syscalls/setrlimit/setrlimit03.c
+++ b/testcases/kernel/syscalls/setrlimit/setrlimit03.c
@@ -51,7 +51,9 @@
int TST_TOTAL = 1;
extern int Tst_count;
+#if !defined(NR_OPEN)
long NR_OPEN;
+#endif
void setup();
void cleanup();
@@ -117,8 +119,10 @@
tst_brkm(TBROK, tst_exit, "must run test as root");
}
+#if !defined(NR_OPEN)
/* Define NR_OPEN */
NR_OPEN = 1024*1024; //Taken from definition in /usr/include/linux/fs.h
+#endif
/* capture signals */
tst_sig(FORK, DEF_HANDLER, cleanup);
diff --git a/testcases/kernel/syscalls/setsid/Makefile b/testcases/kernel/syscalls/setsid/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/setsid/Makefile
+++ b/testcases/kernel/syscalls/setsid/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setsid/setsid01.c b/testcases/kernel/syscalls/setsid/setsid01.c
index e9c1ba6..8f1cb23 100644
--- a/testcases/kernel/syscalls/setsid/setsid01.c
+++ b/testcases/kernel/syscalls/setsid/setsid01.c
@@ -51,13 +51,19 @@
int TST_TOTAL = 1;
extern int Tst_count;
+#ifdef UCLINUX
+static char *argv0;
+#endif
+
+void do_child_1(void);
+void do_child_2(void);
void setup(void);
void cleanup(void);
int main(int ac, char **av)
{
int pid;
- int retval, fail = 0;
+ int fail = 0;
int ret, status;
int exno = 0;
@@ -70,6 +76,13 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ argv0 = av[0];
+
+ maybe_run_child(&do_child_1, "n", 1);
+ maybe_run_child(&do_child_2, "n", 2);
+#endif
+
/*
* perform global setup for the test
*/
@@ -86,61 +99,22 @@
* and then it attached itself to another process
* group and tries to setsid
*/
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid == 0) {
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_resm(TFAIL, "Fork failed");
tst_exit();
}
if (pid == 0) {
- sleep(1);
- exno = 0;
-
- if (setpgid(0, 0) < 0) {
- perror("setpgid");
- exno = 1;
- }
-
- if ((pid = fork()) == -1) {
- tst_resm(TFAIL, "Fork failed");
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 1) < 0) {
+ tst_resm(TFAIL, "self_exec failed");
tst_exit();
}
- if (pid == 0) {
- for (;;);
- } else {
- retval = setpgid(0, getppid());
- if (retval < 0) {
- tst_resm(TFAIL, "setpgid "
- "failed, errno :%d",
- errno);
- exno = 2;
- }
-
- retval = setsid();
-
- if (errno == EPERM) {
- tst_resm(TPASS, "setsid "
- "SUCCESS to set "
- "errno to EPERM");
- } else {
- tst_resm(TFAIL, "setsid "
- "failed, expected %d,"
- "return %d", -1,
- errno);
- exno = 3;
- }
- kill(pid, SIGKILL);
- if ((ret = wait(&status)) > 0) {
- tst_resm(TINFO, "Test {%d} "
- "exited status 0x%-x",
- ret, status);
- if (status != 9) {
- exno = 4;
- }
- }
- }
- exit(exno);
+#else
+ do_child_1();
+#endif
} else {
if (setpgid(0, 0) < 0) {
perror("setpgid(parent) failed");
@@ -178,6 +152,74 @@
}
/*
+ * do_child_1()
+ */
+void
+do_child_1()
+{
+ int exno = 0;
+ int retval, ret, status;
+ int pid;
+
+ sleep(1);
+
+ if (setpgid(0, 0) < 0) {
+ perror("setpgid");
+ exno = 1;
+ }
+
+ if ((pid = FORK_OR_VFORK()) == -1) {
+ tst_resm(TFAIL, "Fork failed");
+ tst_exit();
+ }
+ if (pid == 0) {
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 2) < 0) {
+ tst_resm(TFAIL, "self_exec failed");
+ tst_exit();
+ }
+#else
+ do_child_2();
+#endif
+ } else {
+ retval = setpgid(0, getppid());
+ if (retval < 0) {
+ tst_resm(TFAIL, "setpgid failed, errno :%d", errno);
+ exno = 2;
+ }
+
+ retval = setsid();
+
+ if (errno == EPERM) {
+ tst_resm(TPASS, "setsid SUCCESS to set "
+ "errno to EPERM");
+ } else {
+ tst_resm(TFAIL, "setsid failed, expected %d,"
+ "return %d", -1, errno);
+ exno = 3;
+ }
+ kill(pid, SIGKILL);
+ if ((ret = wait(&status)) > 0) {
+ tst_resm(TINFO, "Test {%d} exited status 0x%-x",
+ ret, status);
+ if (status != 9) {
+ exno = 4;
+ }
+ }
+ }
+ exit(exno);
+}
+
+/*
+ * do_child_2()
+ */
+void
+do_child_2()
+{
+ for (;;);
+}
+
+/*
* setup() - performs all ONE TIME setup for this test
*/
void
diff --git a/testcases/kernel/syscalls/setsockopt/Makefile b/testcases/kernel/syscalls/setsockopt/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/setsockopt/Makefile
+++ b/testcases/kernel/syscalls/setsockopt/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/settimeofday/Makefile b/testcases/kernel/syscalls/settimeofday/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/settimeofday/Makefile
+++ b/testcases/kernel/syscalls/settimeofday/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/setuid/Makefile b/testcases/kernel/syscalls/setuid/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/setuid/Makefile
+++ b/testcases/kernel/syscalls/setuid/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sigaction/Makefile b/testcases/kernel/syscalls/sigaction/Makefile
index 18839a7..372102c 100644
--- a/testcases/kernel/syscalls/sigaction/Makefile
+++ b/testcases/kernel/syscalls/sigaction/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -DGLIBC_SIGACTION_BUG=1 -Wall -D_GNU_SOURCE
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sigaltstack/Makefile b/testcases/kernel/syscalls/sigaltstack/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/sigaltstack/Makefile
+++ b/testcases/kernel/syscalls/sigaltstack/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sighold/Makefile b/testcases/kernel/syscalls/sighold/Makefile
index 60a5478..6a3c09e 100644
--- a/testcases/kernel/syscalls/sighold/Makefile
+++ b/testcases/kernel/syscalls/sighold/Makefile
@@ -21,7 +21,9 @@
###########################################################################
CFLAGS+= -I../../../../include -D_GNU_SOURCE
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sighold/sighold02.c b/testcases/kernel/syscalls/sighold/sighold02.c
index 04b025f..0032b01 100644
--- a/testcases/kernel/syscalls/sighold/sighold02.c
+++ b/testcases/kernel/syscalls/sighold/sighold02.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: sighold02.c,v 1.4 2003/09/25 15:44:20 robbiew Exp $ */
+/* $Id: sighold02.c,v 1.5 2005/07/11 22:29:05 robbiew Exp $ */
/*****************************************************************************
* OS Test - Silicon Graphics, Inc. Eagan, Minnesota
*
@@ -143,6 +143,7 @@
struct tblock rtimes;
} p_p;
+void do_child();
void setup();
void cleanup();
static void getout();
@@ -163,12 +164,9 @@
main(int ac, char **av)
{
int term_stat; /* child return status */
- int rv; /* function return value */
int sig; /* current signal */
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
- int cnt;
-
/***************************************************************
* parse standard options, and exit if there is an error
@@ -178,6 +176,10 @@
tst_exit();
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "dd", &CHILDSWRITEFD, &CHILDSREADFD);
+#endif
+
/***************************************************************
* perform global setup for test
***************************************************************/
@@ -196,7 +198,7 @@
/*
* fork off a child process
*/
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
(void) sprintf(mesg, "fork() failed. error:%d %s.",
errno, strerror(errno));
tst_brkm(TBROK, cleanup, mesg);
@@ -315,90 +317,14 @@
* CHILD PROCESS - set up to catch signals.
*/
- p_p.result=TPASS;
-
- /* set up signal handlers for the signals */
- if (setup_sigs() < 0) {
- p_p.result=TBROK;
- strcpy(p_p.mesg, mesg);
-
- } else {
- /* all set up to catch signals, now hold them */
-
- for (cnt=0, sig = 1; sig < NUMSIGS; sig++) {
- if ((sig == 41) && !CRAYT3E && !SGI) {
- sig = 42; /* skip over SIGPEFAILURE for non-CRAYT3E systems */
- }
- if ((sig != SIGCLD) && (sig != SIGKILL) &&
- (sig != SIGALRM) && (sig != SIGSTOP)
-#ifdef SIGNOBDM
- && (sig != SIGNOBDM )
+#ifdef UCLINUX
+ if (self_exec(av[0], "dd", CHILDSWRITEFD, CHILDSREADFD) < 0) {
+ (void) sprintf(mesg, "self_exec failed");
+ tst_brkm(TBROK, cleanup, mesg);
+ }
+#else
+ do_child();
#endif
- && (sig != SIGCANCEL) && (sig != SIGTIMER)
- ) {
-
- cnt++;
- TEST( sighold(sig) );
- rv = TEST_RETURN;
- if (rv != 0) {
- /* THEY say sighold ALWAYS returns 0 */
- p_p.result=TFAIL;
- (void) sprintf(p_p.mesg,
- "sighold(%d) failed, rv:%d, errno:%d",
- sig, rv, errno);
- break;
- }
- }
- }
- if ( STD_TIMING_ON ) {
- p_p.rtimes = tblock;
- }
- if ( p_p.result == TPASS ) {
- sprintf(p_p.mesg,
- "Sighold called without error for %d of %d signals",
- cnt, NUMSIGS-1);
- }
- }
-
- /*
- * write to parent (if not READY, parent will BROK) and
- * wait for parent to send signals. The timeout clock is set so
- * that we will not wait forever - if sighold() did its job, we
- * will not receive the signals. If sighold() blew it we will
- * catch a signal and the interrupt handler will exit(1).
- */
-#if debug
-printf("child: %d writing to parent fd:%d\n", getpid(), CHILDSWRITEFD);
-#endif
- if (write_pipe(CHILDSWRITEFD) < 0 || p_p.result != TPASS ) {
- exit(2);
- }
-
- /*
- * Read pipe from parent, that will tell us that all signals were sent
- */
- if ( read_pipe(CHILDSREADFD, 0) != 0 ) {
- p_p.result = TBROK;
- strcpy(p_p.mesg, mesg);
- }
- else if ( signals_received[0] == '\0' ) {
- p_p.result = TPASS;
- strcpy(p_p.mesg, "No signals trapped after being sent by parent");
- }
- else {
- p_p.result = TFAIL;
- sprintf(p_p.mesg, "signals received: %s", signals_received);
- }
-
- if (write_pipe(CHILDSWRITEFD) < 0 ) {
- exit(2);
- }
-
- /* exit back to parent */
- if ( p_p.result == TPASS )
- exit(0);
- else
- exit(1);
}
}
cleanup();
@@ -407,6 +333,103 @@
}
/*****************************************************************************
+ * do_child()
+ ****************************************************************************/
+
+void
+do_child()
+{
+ int rv; /* function return value */
+ int sig; /* current signal */
+ int cnt;
+
+ p_p.result=TPASS;
+
+ /* set up signal handlers for the signals */
+ if (setup_sigs() < 0) {
+ p_p.result=TBROK;
+ strcpy(p_p.mesg, mesg);
+
+ } else {
+ /* all set up to catch signals, now hold them */
+
+ for (cnt=0, sig = 1; sig < NUMSIGS; sig++) {
+ if ((sig == 41) && !CRAYT3E && !SGI) {
+ sig = 42; /* skip over SIGPEFAILURE for non-CRAYT3E systems */
+ }
+ if ((sig != SIGCLD) && (sig != SIGKILL) &&
+ (sig != SIGALRM) && (sig != SIGSTOP)
+#ifdef SIGNOBDM
+ && (sig != SIGNOBDM )
+#endif
+ && (sig != SIGCANCEL) && (sig != SIGTIMER)
+ ) {
+
+ cnt++;
+ TEST( sighold(sig) );
+ rv = TEST_RETURN;
+ if (rv != 0) {
+ /* THEY say sighold ALWAYS returns 0 */
+ p_p.result=TFAIL;
+ (void) sprintf(p_p.mesg,
+ "sighold(%d) failed, rv:%d, errno:%d",
+ sig, rv, errno);
+ break;
+ }
+ }
+ }
+ if ( STD_TIMING_ON ) {
+ p_p.rtimes = tblock;
+ }
+ if ( p_p.result == TPASS ) {
+ sprintf(p_p.mesg,
+ "Sighold called without error for %d of %d signals",
+ cnt, NUMSIGS-1);
+ }
+ }
+
+ /*
+ * write to parent (if not READY, parent will BROK) and
+ * wait for parent to send signals. The timeout clock is set so
+ * that we will not wait forever - if sighold() did its job, we
+ * will not receive the signals. If sighold() blew it we will
+ * catch a signal and the interrupt handler will exit(1).
+ */
+#if debug
+ printf("child: %d writing to parent fd:%d\n", getpid(), CHILDSWRITEFD);
+#endif
+ if (write_pipe(CHILDSWRITEFD) < 0 || p_p.result != TPASS ) {
+ exit(2);
+ }
+
+ /*
+ * Read pipe from parent, that will tell us that all signals were sent
+ */
+ if ( read_pipe(CHILDSREADFD, 0) != 0 ) {
+ p_p.result = TBROK;
+ strcpy(p_p.mesg, mesg);
+ }
+ else if ( signals_received[0] == '\0' ) {
+ p_p.result = TPASS;
+ strcpy(p_p.mesg, "No signals trapped after being sent by parent");
+ }
+ else {
+ p_p.result = TFAIL;
+ sprintf(p_p.mesg, "signals received: %s", signals_received);
+ }
+
+ if (write_pipe(CHILDSWRITEFD) < 0 ) {
+ exit(2);
+ }
+
+ /* exit back to parent */
+ if ( p_p.result == TPASS )
+ exit(0);
+ else
+ exit(1);
+}
+
+/*****************************************************************************
* read_pipe() : read data from pipe and return in buf. If an error occurs
* put message in mesg and return NULL. Note: this routine sets a
* timeout signal in case the pipe is blocked.
diff --git a/testcases/kernel/syscalls/signal/Makefile b/testcases/kernel/syscalls/signal/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/signal/Makefile
+++ b/testcases/kernel/syscalls/signal/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/signal/signal01.c b/testcases/kernel/syscalls/signal/signal01.c
index 4e6beaf..96568c7 100644
--- a/testcases/kernel/syscalls/signal/signal01.c
+++ b/testcases/kernel/syscalls/signal/signal01.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: signal01.c,v 1.4 2003/03/04 18:34:09 robbiew Exp $ */
+/* $Id: signal01.c,v 1.5 2005/07/11 22:29:05 robbiew Exp $ */
/***********************************************************************************
*
* OS Test - Silicon Graphics, Inc. Eagan, Minnesota
@@ -172,8 +172,12 @@
void setup();
void cleanup();
void do_test();
+void do_child();
void sigdfl_test();
void update_timings();
+void p_timeout_handler();
+void c_timeout_handler();
+void catchsig();
#if defined(linux)
# define SIG_PF sig_t /* This might need to be sighandler_t on some systems */
@@ -211,11 +215,19 @@
extern int Tst_count; /* count of test items completed */
int Pid; /* Return value from fork. */
+static int fd1[2]; /* ipc fd, shared between do_test and do_child */
typedef void (*sighandler_t)(int);
sighandler_t Tret;
+#ifdef UCLINUX
+static char* argv0;
+
+void do_child_uclinux();
+static int test_case_uclinux;
+#endif
+
/***********************************************************************
* M A I N
***********************************************************************/
@@ -235,6 +247,11 @@
tst_exit();
}
+#ifdef UCLINUX
+ argv0 = argv[0];
+ maybe_run_child(&do_child_uclinux, "dd", &test_case_uclinux, &fd1[1]);
+#endif
+
/***************************************************************
* perform global setup for test
***************************************************************/
@@ -282,12 +299,7 @@
{
int term_stat; /* Termination status of the child returned to */
/* the parent. */
- char string[30];
- int fd1[2]; /* ipc */
int rd_sz; /* size of read */
- void p_timeout_handler();
- void c_timeout_handler();
- void catchsig();
Tst_count = tst_count;
@@ -318,7 +330,7 @@
return;
}
- if ((Pid = fork()) > 0) { /* parent */
+ if ((Pid = FORK_OR_VFORK()) > 0) { /* parent */
signal(SIGALRM, p_timeout_handler);
@@ -445,70 +457,19 @@
* This is the child.
* Set up to ignore/catch SIGKILL and check the return values.
*/
- errno=0;
- if ( test_case == IGNORE_TEST ) {
- exit_val = SIG_IGNORED;
- strcpy(string, "signal(SIGKILL, SIG_IGN)");
-
- Tret=signal(SIGKILL, SIG_IGN);
- TEST_ERRNO=errno;
+#ifdef UCLINUX
+ if (self_exec(argv0, "dd", test_case, fd1[1]) < 0) {
+ sprintf(mesg, "self_exec failed.");
+ tst_resm(TBROK,mesg);
+ tst_resm(TBROK,mesg);
+ close(fd1[0]);
+ close(fd1[1]);
+ return;
}
- else {
- exit_val = SIG_NOT_CAUGHT;
- strcpy(string, "signal(SIGKILL, catchsig)");
- Tret=signal(SIGKILL, catchsig);
- TEST_ERRNO=errno;
- }
- Ipc_info.timings=tblock;
-
- if ( Tret == SIG_ERR ) {
- if ( TEST_ERRNO == EINVAL ) {
- sprintf(Ipc_info.mesg, "%s ret:%p SIG_ERR (%ld) as expected",
- string, Tret, (long)SIG_ERR);
- Ipc_info.status = PASS_FLAG;
- }
- else {
- sprintf(Ipc_info.mesg,
- "%s ret:%p, errno:%d expected ret:%ld, errno:%d",
- string, Tret, TEST_ERRNO, (long)SIG_ERR, EINVAL);
- Ipc_info.status = FAIL_FLAG;
- }
-
- write(fd1[1], (char *)&Ipc_info, sizeof(Ipc_info));
- }
- else {
- /*
- * The child was not allowed to set the signal to
- * be ignored and errno was correct.
- */
- sprintf(Ipc_info.mesg,
- "%s ret:%p, errno:%d expected ret:%ld, errno:%d",
- string, Tret, TEST_ERRNO, (long)SIG_ERR, EINVAL);
- Ipc_info.status = FAIL_FLAG;
- write(fd1[1], (char *)&Ipc_info, sizeof(Ipc_info));
- }
-
- /*
- * tell parent we are ready - setup by child is done
- */
- Ipc_info.status = GO_FLAG;
- write(fd1[1], (char *)&Ipc_info, sizeof(Ipc_info));
-
- /*
- * Set the alarm to wake up from the pause below if
- * the parents signal is ignored.
- */
- signal(SIGALRM, p_timeout_handler);
- alarm(TIMEOUT);
-
- /*
- * Pause until the parent sends a signal or until alarm is received.
- */
- pause();
-
- exit(exit_val);
-
-
+#else
+ do_child(test_case);
+#endif
+
} /* End of child. */
else {
/*
@@ -523,10 +484,93 @@
close(fd1[1]);
return;
}
-
} /* End of do_test. */
/***********************************************************************
+ * do_child()
+ ***********************************************************************/
+void
+do_child(test_case)
+int test_case;
+{
+ char string[30];
+
+ errno=0;
+ if ( test_case == IGNORE_TEST ) {
+ exit_val = SIG_IGNORED;
+ strcpy(string, "signal(SIGKILL, SIG_IGN)");
+
+ Tret=signal(SIGKILL, SIG_IGN);
+ TEST_ERRNO=errno;
+ }
+ else {
+ exit_val = SIG_NOT_CAUGHT;
+ strcpy(string, "signal(SIGKILL, catchsig)");
+ Tret=signal(SIGKILL, catchsig);
+ TEST_ERRNO=errno;
+ }
+ Ipc_info.timings=tblock;
+
+ if ( Tret == SIG_ERR ) {
+ if ( TEST_ERRNO == EINVAL ) {
+ sprintf(Ipc_info.mesg, "%s ret:%p SIG_ERR (%ld) as expected",
+ string, Tret, (long)SIG_ERR);
+ Ipc_info.status = PASS_FLAG;
+ }
+ else {
+ sprintf(Ipc_info.mesg,
+ "%s ret:%p, errno:%d expected ret:%ld, errno:%d",
+ string, Tret, TEST_ERRNO, (long)SIG_ERR, EINVAL);
+ Ipc_info.status = FAIL_FLAG;
+ }
+
+ write(fd1[1], (char *)&Ipc_info, sizeof(Ipc_info));
+ }
+ else {
+ /*
+ * The child was not allowed to set the signal to
+ * be ignored and errno was correct.
+ */
+ sprintf(Ipc_info.mesg,
+ "%s ret:%p, errno:%d expected ret:%ld, errno:%d",
+ string, Tret, TEST_ERRNO, (long)SIG_ERR, EINVAL);
+ Ipc_info.status = FAIL_FLAG;
+ write(fd1[1], (char *)&Ipc_info, sizeof(Ipc_info));
+ }
+
+ /*
+ * tell parent we are ready - setup by child is done
+ */
+ Ipc_info.status = GO_FLAG;
+ write(fd1[1], (char *)&Ipc_info, sizeof(Ipc_info));
+
+ /*
+ * Set the alarm to wake up from the pause below if
+ * the parents signal is ignored.
+ */
+ signal(SIGALRM, p_timeout_handler);
+ alarm(TIMEOUT);
+
+ /*
+ * Pause until the parent sends a signal or until alarm is received.
+ */
+ pause();
+
+ exit(exit_val);
+} /* End of do_child */
+
+#ifdef UCLINUX
+/***********************************************************************
+ * do_child_uclinux(): call do_child with the global used to store test_case
+ ***********************************************************************/
+void
+do_child_uclinux()
+{
+ do_child(test_case_uclinux);
+} /* End of do_child_uclinux */
+#endif
+
+/***********************************************************************
* sigdfl_test - test for attempt to set SIGKILL to default
***********************************************************************/
void
diff --git a/testcases/kernel/syscalls/sigpending/Makefile b/testcases/kernel/syscalls/sigpending/Makefile
index 6539711..a282bc6 100644
--- a/testcases/kernel/syscalls/sigpending/Makefile
+++ b/testcases/kernel/syscalls/sigpending/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -Wall -I../../../../include -D _GNU_SOURCE
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LDLIBS+= -L../../../../lib -lltp
+LDLIBS+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sigprocmask/Makefile b/testcases/kernel/syscalls/sigprocmask/Makefile
index 267d783..13b49e8 100644
--- a/testcases/kernel/syscalls/sigprocmask/Makefile
+++ b/testcases/kernel/syscalls/sigprocmask/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sigrelse/Makefile b/testcases/kernel/syscalls/sigrelse/Makefile
index 5486300..a47444b 100644
--- a/testcases/kernel/syscalls/sigrelse/Makefile
+++ b/testcases/kernel/syscalls/sigrelse/Makefile
@@ -20,8 +20,10 @@
# name of file : Makefile #
###########################################################################
export CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sigrelse/sigrelse01.c b/testcases/kernel/syscalls/sigrelse/sigrelse01.c
index 9e74d5f..a618ab9 100644
--- a/testcases/kernel/syscalls/sigrelse/sigrelse01.c
+++ b/testcases/kernel/syscalls/sigrelse/sigrelse01.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: sigrelse01.c,v 1.5 2004/01/20 07:07:12 robbiew Exp $ */
+/* $Id: sigrelse01.c,v 1.6 2005/07/11 22:29:05 robbiew Exp $ */
/*****************************************************************************
* OS Test - Silicon Graphics, Inc. Eagan, Minnesota
*
@@ -201,6 +201,10 @@
tst_exit();
}
+#ifdef UCLINUX
+ maybe_run_child(&child, "dd", &pipe_fd[1], &pipe_fd2[0]);
+#endif
+
/*
* perform global setup for test
*/
@@ -226,7 +230,14 @@
parent();
} else {
+#ifdef UCLINUX
+ if (self_exec(argv[0], "dd", pipe_fd[1], pipe_fd2[0]) < 0) {
+ (void) sprintf(mesg, "self_exec failed");
+ tst_brkm(TBROK, cleanup, mesg);
+ }
+#else
child();
+#endif
}
} /* End for TEST_LOOPING */
diff --git a/testcases/kernel/syscalls/sigsuspend/Makefile b/testcases/kernel/syscalls/sigsuspend/Makefile
index 267d783..13b49e8 100644
--- a/testcases/kernel/syscalls/sigsuspend/Makefile
+++ b/testcases/kernel/syscalls/sigsuspend/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/socket/Makefile b/testcases/kernel/syscalls/socket/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/socket/Makefile
+++ b/testcases/kernel/syscalls/socket/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/socketcall/Makefile b/testcases/kernel/syscalls/socketcall/Makefile
index 3eae260..ec20258 100644
--- a/testcases/kernel/syscalls/socketcall/Makefile
+++ b/testcases/kernel/syscalls/socketcall/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/socketpair/Makefile b/testcases/kernel/syscalls/socketpair/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/socketpair/Makefile
+++ b/testcases/kernel/syscalls/socketpair/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sockioctl/Makefile b/testcases/kernel/syscalls/sockioctl/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/sockioctl/Makefile
+++ b/testcases/kernel/syscalls/sockioctl/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/stat/Makefile b/testcases/kernel/syscalls/stat/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/stat/Makefile
+++ b/testcases/kernel/syscalls/stat/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/stat/stat03.c b/testcases/kernel/syscalls/stat/stat03.c
index 748a2d4..c7a3687 100644
--- a/testcases/kernel/syscalls/stat/stat03.c
+++ b/testcases/kernel/syscalls/stat/stat03.c
@@ -113,7 +113,9 @@
int (*setupfunc)();
} Test_cases[] = {
{ TEST_FILE1, "No Search permissions to process", EACCES, setup1 },
+#if !defined(UCLINUX)
{ High_address_node, "Address beyond address space", EFAULT, no_setup },
+#endif
{ (char *)-1, "Negative address", EFAULT, no_setup },
{ Longpathname, "Pathname too long", ENAMETOOLONG, longpath_setup },
{ "", "Pathname is empty", ENOENT, no_setup },
@@ -122,9 +124,17 @@
};
char *TCID="stat03"; /* Test program identifier. */
+#if !defined(UCLINUX)
int TST_TOTAL = 6; /* Total number of test cases. */
+#else
+int TST_TOTAL = 5;
+#endif
extern int Tst_count; /* Test Case counter for tst_* routines */
+#if !defined(UCLINUX)
int exp_enos[]={EACCES, EFAULT, ENAMETOOLONG, ENOENT, ENOTDIR, 0};
+#else
+int exp_enos[]={EACCES, ENAMETOOLONG, ENOENT, ENOTDIR, 0};
+#endif
char * bad_addr = 0;
@@ -167,9 +177,11 @@
file_name = Test_cases[ind].pathname;
test_desc = Test_cases[ind].desc;
+#if !defined(UCLINUX)
if (file_name == High_address_node) {
file_name = (char *)get_high_address();
}
+#endif
/*
* Call stat(2) to test different test conditions.
@@ -250,7 +262,8 @@
/* Make a temp dir and cd to it */
tst_tmpdir();
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/stat/stat06.c b/testcases/kernel/syscalls/stat/stat06.c
index 0fe60d2..03f4b9f 100644
--- a/testcases/kernel/syscalls/stat/stat06.c
+++ b/testcases/kernel/syscalls/stat/stat06.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: stat06.c,v 1.3 2003/10/30 22:03:42 robbiew Exp $ */
+/* $Id: stat06.c,v 1.4 2005/07/11 22:29:06 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -134,12 +134,14 @@
char * bad_addr = 0;
+#if !defined(UCLINUX)
int high_address_setup();
+char High_address[64];
+#endif
int longpath_setup();
int no_setup();
int filepath_setup();
char Longpathname[PATH_MAX+2];
-char High_address[64];
struct stat statbuf;
jmp_buf sig11_recover;
void sig11_handler(int sig);
@@ -158,7 +160,9 @@
{ "file/file", &statbuf, "path contains a regular file",
ENOTDIR, filepath_setup },
{ Longpathname, &statbuf, "pathname too long", ENAMETOOLONG, longpath_setup },
+#if !defined(UCLINUX)
{ High_address, &statbuf, "address beyond address space", EFAULT, high_address_setup },
+#endif
{ (char *)-1, &statbuf, "negative address", EFAULT, no_setup },
{ NULL, NULL, NULL, 0, no_setup }
};
@@ -279,7 +283,8 @@
/* make a temp directory and cd to it */
tst_tmpdir();
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
@@ -323,6 +328,8 @@
return 0;
}
+#if !defined(UCLINUX)
+
/******************************************************************
* high_address_setup() - generates an address that should cause a segfault
******************************************************************/
@@ -341,6 +348,7 @@
return 0;
}
+#endif
/******************************************************************
* longpath_setup() - creates a filename that is too long
diff --git a/testcases/kernel/syscalls/statfs/Makefile b/testcases/kernel/syscalls/statfs/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/statfs/Makefile
+++ b/testcases/kernel/syscalls/statfs/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/statfs/statfs02.c b/testcases/kernel/syscalls/statfs/statfs02.c
index aac9c7f..b93e375 100644
--- a/testcases/kernel/syscalls/statfs/statfs02.c
+++ b/testcases/kernel/syscalls/statfs/statfs02.c
@@ -178,7 +178,8 @@
sprintf(good_dir, "%s.statfs.%d", good_dir, getpid());
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/stime/Makefile b/testcases/kernel/syscalls/stime/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/stime/Makefile
+++ b/testcases/kernel/syscalls/stime/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/string/Makefile b/testcases/kernel/syscalls/string/Makefile
index 3eae260..ec20258 100644
--- a/testcases/kernel/syscalls/string/Makefile
+++ b/testcases/kernel/syscalls/string/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/swapoff/Makefile b/testcases/kernel/syscalls/swapoff/Makefile
index 3eae260..ec20258 100644
--- a/testcases/kernel/syscalls/swapoff/Makefile
+++ b/testcases/kernel/syscalls/swapoff/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/swapon/Makefile b/testcases/kernel/syscalls/swapon/Makefile
index 9ef59d6..40f38ba 100644
--- a/testcases/kernel/syscalls/swapon/Makefile
+++ b/testcases/kernel/syscalls/swapon/Makefile
@@ -25,8 +25,10 @@
else
export CFLAGS+=-I../../../../include -g -Wall -DOLDER_DISTRO_RELEASE
endif
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/swapon/swapon02.c b/testcases/kernel/syscalls/swapon/swapon02.c
index 8e1650b..d0cb84c 100644
--- a/testcases/kernel/syscalls/swapon/swapon02.c
+++ b/testcases/kernel/syscalls/swapon/swapon02.c
@@ -325,7 +325,7 @@
count = 40;
}
- pid=fork();
+ pid=FORK_OR_VFORK();
if (pid == 0) {
/*create and turn on remaining swapfiles*/
for (j = 0; j < swapfiles; j++) {
diff --git a/testcases/kernel/syscalls/symlink/Makefile b/testcases/kernel/syscalls/symlink/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/symlink/Makefile
+++ b/testcases/kernel/syscalls/symlink/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/symlink/symlink03.c b/testcases/kernel/syscalls/symlink/symlink03.c
index d263507..0aca6aa 100644
--- a/testcases/kernel/syscalls/symlink/symlink03.c
+++ b/testcases/kernel/syscalls/symlink/symlink03.c
@@ -125,7 +125,9 @@
} Test_cases[] = {
{ TEST_FILE1, SYM_FILE1, "No Search permissions to process", EACCES, setup1 },
{ TEST_FILE2, SYM_FILE2, "Specified symlink already exists", EEXIST, setup2 },
+#if !defined(UCLINUX)
{ TESTFILE, High_address_node, "Address beyond address space", EFAULT, no_setup },
+#endif
{ TESTFILE, (char *)-1, "Negative address", EFAULT, no_setup },
{ TESTFILE, Longpathname, "Symlink path too long", ENAMETOOLONG, longpath_setup },
{ TESTFILE, "", "Symlink Pathname is empty", ENOENT, no_setup },
@@ -175,10 +177,11 @@
test_file = Test_cases[ind].file;
sym_file = Test_cases[ind].link;
test_desc = Test_cases[ind].desc;
-
+#if !defined(UCLINUX)
if (sym_file == High_address_node) {
sym_file = (char *)get_high_address();
}
+#endif
/*
* Call symlink(2) to test different test conditions.
* verify that it fails with -1 return value and sets
@@ -258,7 +261,8 @@
/* make a temp directory and cd to it */
tst_tmpdir();
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/sync/Makefile b/testcases/kernel/syscalls/sync/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/sync/Makefile
+++ b/testcases/kernel/syscalls/sync/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/syscall/Makefile b/testcases/kernel/syscalls/syscall/Makefile
index 3eae260..ec20258 100644
--- a/testcases/kernel/syscalls/syscall/Makefile
+++ b/testcases/kernel/syscalls/syscall/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sysconf/Makefile b/testcases/kernel/syscalls/sysconf/Makefile
index 3eae260..ec20258 100644
--- a/testcases/kernel/syscalls/sysconf/Makefile
+++ b/testcases/kernel/syscalls/sysconf/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -O -g -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sysctl/Makefile b/testcases/kernel/syscalls/sysctl/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/sysctl/Makefile
+++ b/testcases/kernel/syscalls/sysctl/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sysctl/sysctl03.c b/testcases/kernel/syscalls/sysctl/sysctl03.c
index e039020..6f20167 100644
--- a/testcases/kernel/syscalls/sysctl/sysctl03.c
+++ b/testcases/kernel/syscalls/sysctl/sysctl03.c
@@ -139,7 +139,7 @@
"seteuid() failed, errno %d", errno);
}
- if ((pid = fork()) == -1) {
+ if ((pid = FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
}
diff --git a/testcases/kernel/syscalls/sysfs/Makefile b/testcases/kernel/syscalls/sysfs/Makefile
index 991b75e..f200ad8 100644
--- a/testcases/kernel/syscalls/sysfs/Makefile
+++ b/testcases/kernel/syscalls/sysfs/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -Wall -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LDLIBS+= -L../../../../lib -lltp
+LDLIBS+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/sysfs/sysfs06.c b/testcases/kernel/syscalls/sysfs/sysfs06.c
index 672ac45..dde7be4 100644
--- a/testcases/kernel/syscalls/sysfs/sysfs06.c
+++ b/testcases/kernel/syscalls/sysfs/sysfs06.c
@@ -171,7 +171,8 @@
/* Pause if that option was specified */
TEST_PAUSE;
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/sysinfo/Makefile b/testcases/kernel/syscalls/sysinfo/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/sysinfo/Makefile
+++ b/testcases/kernel/syscalls/sysinfo/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/syslog/Makefile b/testcases/kernel/syscalls/syslog/Makefile
index 97122a8..af00a32 100644
--- a/testcases/kernel/syscalls/syslog/Makefile
+++ b/testcases/kernel/syscalls/syslog/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
LDFLAGS=
SRCS=$(wildcard *.c)
diff --git a/testcases/kernel/syscalls/time/Makefile b/testcases/kernel/syscalls/time/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/time/Makefile
+++ b/testcases/kernel/syscalls/time/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/times/Makefile b/testcases/kernel/syscalls/times/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/times/Makefile
+++ b/testcases/kernel/syscalls/times/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/times/times03.c b/testcases/kernel/syscalls/times/times03.c
index 85b8761..e8a660c 100644
--- a/testcases/kernel/syscalls/times/times03.c
+++ b/testcases/kernel/syscalls/times/times03.c
@@ -130,7 +130,7 @@
fail=1;
}
- pid2 = fork();
+ pid2 = FORK_OR_VFORK();
if (pid2 < 0) {
tst_brkm(TFAIL, cleanup, "Fork failed");
/*NOTREACHED*/
diff --git a/testcases/kernel/syscalls/truncate/Makefile b/testcases/kernel/syscalls/truncate/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/truncate/Makefile
+++ b/testcases/kernel/syscalls/truncate/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/truncate/truncate03.c b/testcases/kernel/syscalls/truncate/truncate03.c
index 730659a..43bbf3f 100644
--- a/testcases/kernel/syscalls/truncate/truncate03.c
+++ b/testcases/kernel/syscalls/truncate/truncate03.c
@@ -124,7 +124,9 @@
} Test_cases[] = {
{ TEST_FILE1, "No Search permissions to process", EACCES, setup1 },
{ TEST_FILE2, "Path contains regular file", ENOTDIR, setup2 },
+#if !defined(UCLINUX)
{ High_address_node, "Address beyond address space", EFAULT, no_setup},
+#endif
{ (char *)-1, "Negative address", EFAULT, no_setup },
{ Longpathname, "Pathname too long", ENAMETOOLONG, longpath_setup },
{ "", "Pathname is empty", ENOENT, no_setup },
@@ -168,9 +170,11 @@
file_name = Test_cases[ind].pathname;
test_desc = Test_cases[ind].desc;
+#if !defined(UCLINUX)
if (file_name == High_address_node) {
file_name = (char *)get_high_address();
}
+#endif
/*
* Call truncate(2) to test different test conditions.
@@ -286,7 +290,8 @@
/*NOTREACHED*/
}
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
tst_brkm(TBROK, cleanup, "mmap failed");
}
diff --git a/testcases/kernel/syscalls/ulimit/Makefile b/testcases/kernel/syscalls/ulimit/Makefile
index 6729e34..0db7aa7 100644
--- a/testcases/kernel/syscalls/ulimit/Makefile
+++ b/testcases/kernel/syscalls/ulimit/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/umask/Makefile b/testcases/kernel/syscalls/umask/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/umask/Makefile
+++ b/testcases/kernel/syscalls/umask/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/umount/Makefile b/testcases/kernel/syscalls/umount/Makefile
index 6729e34..0db7aa7 100644
--- a/testcases/kernel/syscalls/umount/Makefile
+++ b/testcases/kernel/syscalls/umount/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/uname/Makefile b/testcases/kernel/syscalls/uname/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/uname/Makefile
+++ b/testcases/kernel/syscalls/uname/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/unlink/Makefile b/testcases/kernel/syscalls/unlink/Makefile
index 6729e34..0db7aa7 100644
--- a/testcases/kernel/syscalls/unlink/Makefile
+++ b/testcases/kernel/syscalls/unlink/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/unlink/unlink07.c b/testcases/kernel/syscalls/unlink/unlink07.c
index 59b83b9..cae2a33 100644
--- a/testcases/kernel/syscalls/unlink/unlink07.c
+++ b/testcases/kernel/syscalls/unlink/unlink07.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: unlink07.c,v 1.2 2002/07/23 13:11:22 plars Exp $ */
+/* $Id: unlink07.c,v 1.3 2005/07/11 22:29:11 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -151,10 +151,14 @@
{ "", "path is empty string", ENOENT, no_setup},
{ "nefile/file", "path contains a non-existent file",
ENOENT, no_setup },
+#if !defined(UCLINUX)
{ High_address, "address beyond address space", EFAULT, no_setup },
+#endif
{ "file/file", "path contains a regular file",
ENOTDIR, filepath_setup },
+#if !defined(UCLINUX)
{ High_address, "address beyond address space", EFAULT, no_setup },
+#endif
{ Longpathname, "pathname too long", ENAMETOOLONG, longpath_setup },
{ (char *)-1, "negative address", EFAULT, no_setup },
{ NULL, NULL, 0, no_setup }
@@ -203,9 +207,10 @@
fname = Test_cases[ind].pathname;
desc = Test_cases[ind].desc;
+#if !defined(UCLINUX)
if ( fname == High_address )
fname = get_high_address();
-
+#endif
/*
* Call unlink(2)
*/
diff --git a/testcases/kernel/syscalls/ustat/Makefile b/testcases/kernel/syscalls/ustat/Makefile
index 6729e34..0db7aa7 100644
--- a/testcases/kernel/syscalls/ustat/Makefile
+++ b/testcases/kernel/syscalls/ustat/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/utime/Makefile b/testcases/kernel/syscalls/utime/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/utime/Makefile
+++ b/testcases/kernel/syscalls/utime/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/utime/utime03.c b/testcases/kernel/syscalls/utime/utime03.c
index bb01c02..e520fcc 100644
--- a/testcases/kernel/syscalls/utime/utime03.c
+++ b/testcases/kernel/syscalls/utime/utime03.c
@@ -134,7 +134,7 @@
/* set the expected errnos... */
TEST_EXP_ENOS(exp_enos);
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
diff --git a/testcases/kernel/syscalls/utime/utime06.c b/testcases/kernel/syscalls/utime/utime06.c
index fe96e0f..9dc06b1 100644
--- a/testcases/kernel/syscalls/utime/utime06.c
+++ b/testcases/kernel/syscalls/utime/utime06.c
@@ -148,7 +148,7 @@
/* set the expected errnos... */
TEST_EXP_ENOS(exp_enos);
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
diff --git a/testcases/kernel/syscalls/vfork/Makefile b/testcases/kernel/syscalls/vfork/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/vfork/Makefile
+++ b/testcases/kernel/syscalls/vfork/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/vhangup/Makefile b/testcases/kernel/syscalls/vhangup/Makefile
index acb4a66..7c31ab1 100644
--- a/testcases/kernel/syscalls/vhangup/Makefile
+++ b/testcases/kernel/syscalls/vhangup/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp -L.. -ltestsuite
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/vhangup/vhangup01.c b/testcases/kernel/syscalls/vhangup/vhangup01.c
index f959c5d..f99749b 100644
--- a/testcases/kernel/syscalls/vhangup/vhangup01.c
+++ b/testcases/kernel/syscalls/vhangup/vhangup01.c
@@ -88,7 +88,7 @@
nobody = my_getpwnam(user1name);
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
tst_brkm(TFAIL, cleanup, "fork failed");
/*NOTREACHED*/
} else if (pid > 0) { /* parent */
diff --git a/testcases/kernel/syscalls/vhangup/vhangup02.c b/testcases/kernel/syscalls/vhangup/vhangup02.c
index 2eaebe9..a3e1e91 100644
--- a/testcases/kernel/syscalls/vhangup/vhangup02.c
+++ b/testcases/kernel/syscalls/vhangup/vhangup02.c
@@ -80,7 +80,7 @@
fail = 0;
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
tst_brkm(TFAIL, cleanup, "fork failed");
/*NOTREACHED*/
} else if (pid > 0) { /* parent */
diff --git a/testcases/kernel/syscalls/wait/Makefile b/testcases/kernel/syscalls/wait/Makefile
index 6729e34..0db7aa7 100644
--- a/testcases/kernel/syscalls/wait/Makefile
+++ b/testcases/kernel/syscalls/wait/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/wait/wait02.c b/testcases/kernel/syscalls/wait/wait02.c
index d70a1cf..58fd5d9 100644
--- a/testcases/kernel/syscalls/wait/wait02.c
+++ b/testcases/kernel/syscalls/wait/wait02.c
@@ -30,7 +30,7 @@
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/
*
*/
-/* $Id: wait02.c,v 1.1 2001/08/27 22:15:15 plars Exp $ */
+/* $Id: wait02.c,v 1.2 2005/07/11 22:29:12 robbiew Exp $ */
/**********************************************************
*
* OS Test - Silicon Graphics, Inc.
@@ -161,7 +161,7 @@
Tst_count=0;
/* create a child to wait for */
- if ((fork_pid=fork()) == -1) {
+ if ((fork_pid=FORK_OR_VFORK()) == -1) {
tst_brkm(TBROK, cleanup, "fork() Failure. errno=%d : %s", errno, strerror(errno));
} else if (fork_pid == 0) {
/* Child, sleep a second then exit */
diff --git a/testcases/kernel/syscalls/wait4/Makefile b/testcases/kernel/syscalls/wait4/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/wait4/Makefile
+++ b/testcases/kernel/syscalls/wait4/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/wait4/wait401.c b/testcases/kernel/syscalls/wait4/wait401.c
index 82c8430..ba642fd 100644
--- a/testcases/kernel/syscalls/wait4/wait401.c
+++ b/testcases/kernel/syscalls/wait4/wait401.c
@@ -101,7 +101,7 @@
tst_brkm(TBROK, cleanup, "malloc() failed");
}
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
diff --git a/testcases/kernel/syscalls/wait4/wait402.c b/testcases/kernel/syscalls/wait4/wait402.c
index 82811b7..23d566f 100644
--- a/testcases/kernel/syscalls/wait4/wait402.c
+++ b/testcases/kernel/syscalls/wait4/wait402.c
@@ -125,7 +125,7 @@
tst_brkm(TBROK, cleanup, "malloc() failed");
}
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid == -1) {
tst_brkm(TBROK, cleanup, "fork() failed");
diff --git a/testcases/kernel/syscalls/waitpid/Makefile b/testcases/kernel/syscalls/waitpid/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/waitpid/Makefile
+++ b/testcases/kernel/syscalls/waitpid/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/waitpid/waitpid01.c b/testcases/kernel/syscalls/waitpid/waitpid01.c
index 92a0be4..c9d7861 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid01.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid01.c
@@ -85,7 +85,7 @@
exno = 1;
sig = 14;
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
tst_brkm(TFAIL, cleanup, "Fork Failed");
} else if (pid == 0) {
alarm(2);
diff --git a/testcases/kernel/syscalls/waitpid/waitpid02.c b/testcases/kernel/syscalls/waitpid/waitpid02.c
index dfd731b..dfc1624 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid02.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid02.c
@@ -57,6 +57,7 @@
#include <test.h>
#include <usctest.h>
+void do_child(void);
void setup(void);
void cleanup(void);
@@ -81,6 +82,10 @@
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "");
+#endif
+
setup();
/* check for looping state if -i option is given */
@@ -91,13 +96,15 @@
exno = 1;
sig = SIGFPE;
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid == 0) {
- while(1)
- usleep(10);
-
- exit(exno);
+#ifdef UCLINUX
+ self_exec(argv[0], "");
+ /* No fork() error check is done so don't check here */
+#else
+ do_child();
+#endif
} else {
kill(pid, sig);
errno = 0;
@@ -156,6 +163,20 @@
}
/*
+ * do_child()
+ */
+void
+do_child()
+{
+ int exno = 1;
+
+ while(1)
+ usleep(10);
+
+ exit(exno);
+}
+
+/*
* setup()
* performs all ONE TIME setup for this test
*/
diff --git a/testcases/kernel/syscalls/waitpid/waitpid03.c b/testcases/kernel/syscalls/waitpid/waitpid03.c
index b09cee0..34d77b3 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid03.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid03.c
@@ -56,6 +56,7 @@
#include <test.h>
#include <usctest.h>
+void do_child(int);
void setup(void);
void cleanup(void);
@@ -68,6 +69,11 @@
int flag, condition_number;
#define FAILED 1
+#ifdef UCLINUX
+void do_child_uclinux(void);
+static int ikids_uclinux;
+#endif
+
int main(int argc, char **argv)
{
int lc; /* loop counter */
@@ -83,6 +89,10 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child, "d", &ikids_uclinux);
+#endif
+
setup();
/* check for looping state if -i option is given */
@@ -102,17 +112,21 @@
}
while (++ikids < MAXUPRC) {
- if ((pid[ikids] = fork()) > 0) {
+ if ((pid[ikids] = FORK_OR_VFORK()) > 0) {
if (DEBUG)
tst_resm(TINFO, "child # %d", ikids);
} else if (pid[ikids] == -1) {
tst_resm(TFAIL, "cannot open fork #%d",
ikids);
} else {
- if (DEBUG)
- tst_resm(TINFO, "child:%d", ikids);
- pause();
- exit(0);
+#ifdef UCLINUX
+ if (self_exec(argv[0], "d", ikids) < 0) {
+ tst_resm(TFAIL, "cannot self_exec #%d",
+ ikids);
+ }
+#else
+ do_child(ikids);
+#endif
}
}
@@ -155,6 +169,30 @@
}
/*
+ * do_child()
+ */
+void
+do_child(int ikids)
+{
+ if (DEBUG)
+ tst_resm(TINFO, "child:%d", ikids);
+ pause();
+ exit(0);
+}
+
+#ifdef UCLINUX
+/*
+ * do_child_uclinux()
+ * run do_child with the appropriate ikids variable
+ */
+void
+do_child_uclinux()
+{
+ do_child(ikids_uclinux);
+}
+#endif
+
+/*
* setup()
* performs all ONE TIME setup for this test
*/
diff --git a/testcases/kernel/syscalls/waitpid/waitpid04.c b/testcases/kernel/syscalls/waitpid/waitpid04.c
index 7e2a5cf..8205e7a 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid04.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid04.c
@@ -102,7 +102,7 @@
}
}
- if (fork() == 0) {
+ if (FORK_OR_VFORK() == 0) {
exit(0);
}
pid = 1;
diff --git a/testcases/kernel/syscalls/waitpid/waitpid05.c b/testcases/kernel/syscalls/waitpid/waitpid05.c
index 01a4be6..14e19a5 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid05.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid05.c
@@ -62,6 +62,7 @@
#include <test.h>
#include <usctest.h>
+void do_child(int);
void setup(void);
void cleanup(void);
@@ -72,6 +73,11 @@
int flag;
#define FAILED 1
+#ifdef UCLINUX
+void do_child_uclinux(void);
+static int sig_uclinux;
+#endif
+
int main(int ac, char **av)
{
int pid, npid, sig, nsig;
@@ -87,6 +93,10 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ maybe_run_child(&do_child_uclinux, "d", &sig_uclinux);
+#endif
+
setup();
/* check for looping state if -i option is given */
@@ -111,15 +121,16 @@
}
/*Initialize signal to its default action*/
signal(sig,SIG_DFL);
- pid = fork();
+ pid = FORK_OR_VFORK();
if (pid == 0) {
- pid = getpid();
- if (kill(pid, sig) == -1) {
- tst_resm(TFAIL, "kill error: kill "
- "unsuccessful");
- exit(exno);
- }
+#ifdef UCLINUX
+ self_exec(av[0], "d", sig);
+ /* No fork() error check is done so don't */
+ /* do an error check here */
+#else
+ do_child(sig);
+#endif
} else {
errno = 0;
while (((npid = waitpid(pid, &status, 0)) !=
@@ -211,6 +222,33 @@
}
/*
+ * do_child()
+ */
+void
+do_child(int sig)
+{
+ int exno = 1;
+ int pid = getpid();
+
+ if (kill(pid, sig) == -1) {
+ tst_resm(TFAIL, "kill error: kill unsuccessful");
+ exit(exno);
+ }
+}
+
+#ifdef UCLINUX
+/*
+ * do_child_uclinux()
+ * run do_child with the appropriate sig variable
+ */
+void
+do_child_uclinux()
+{
+ do_child(sig_uclinux);
+}
+#endif
+
+/*
* setup()
* performs all ONE TIME setup for this test
*/
diff --git a/testcases/kernel/syscalls/waitpid/waitpid06.c b/testcases/kernel/syscalls/waitpid/waitpid06.c
index 8083a86..7cfcfea 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid06.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid06.c
@@ -52,6 +52,8 @@
#include <test.h>
#include <usctest.h>
+void setup_sigint(void);
+void do_child_1(void);
void setup(void);
void cleanup(void);
@@ -67,16 +69,18 @@
#define FAILED 1
#define MAXKIDS 8
+#ifdef UCLINUX
+static char *argv0;
+void do_child_2_uclinux(void);
+#endif
+
int main(int argc, char **argv)
{
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
- int kid_count, fork_kid_pid[MAXKIDS];
- int wait_kid_pid[MAXKIDS], ret_val, status;
- int i, j, k, found;
int fail = 0;
- int group1, group2;
int pid;
+ int status;
/* parse standard options */
if ((msg = parse_opts(argc, argv, (option_t *)NULL, NULL)) !=
@@ -86,6 +90,13 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ argv0 = argv[0];
+
+ maybe_run_child(&do_child_1, "n", 1);
+ maybe_run_child(&do_child_2_uclinux, "n", 2);
+#endif
+
setup();
/* check looping state if -i option is given */
@@ -93,7 +104,7 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
tst_resm(TINFO, "Fork Failed, may be OK under stress");
exit(pid);
} else if (pid == 0) {
@@ -102,114 +113,14 @@
* Set up to catch SIGINT. The kids will wait till a
* SIGINT has been received before they proceed.
*/
- if ((sig_t)signal(SIGINT, inthandlr) == SIG_ERR ) {
- tst_resm(TFAIL, "signal SIGINT failed. "
- "errno = %d", errno);
- exit(-1);
+#ifdef UCLINUX
+ if (self_exec(argv[0], "n", 1) < 0) {
+ tst_resm(TINFO, "self_exec failed");
+ exit(pid);
}
-
- group1 = getpgrp();
- for (kid_count = 0; kid_count < MAXKIDS; kid_count++) {
- if (kid_count == (MAXKIDS / 2)) {
- group2 = setpgrp();
- }
- intintr = 0;
- ret_val = fork();
- if (ret_val == 0) { /* child */
- do_exit();
- /*NOTREACHED*/
- } else if (ret_val < 0) {
- tst_resm(TFAIL, "Fork kid %d failed. "
- "errno = %d", kid_count,
- errno);
- exit(ret_val);
- }
-
- /* parent */
- fork_kid_pid[kid_count] = ret_val;
- }
-
- /* Now send all the kids a SIGINT to tell them to
- * proceed
- */
- for (i = 0; i < MAXKIDS; i++) {
- if (kill(fork_kid_pid[i], SIGINT) < 0) {
- tst_resm(TFAIL, "Kill of child %d "
- "failed, errno = %d", i, errno);
- exit(-1);
- }
- }
-
- /*
- * Wait till all kids have terminated. Stash away their
- * pid's in an array.
- */
- kid_count = 0;
- errno = 0;
- while (((ret_val = waitpid(-1, &status, 0)) != -1) ||
- (errno == EINTR)) {
- if (ret_val == -1) {
- continue;
- }
-
- if (!WIFEXITED(status)) {
- tst_resm(TFAIL, "Child %d did not exit "
- "normally", ret_val);
- flag = FAILED;
- } else {
- if (WEXITSTATUS(status) != 3) {
- tst_resm(TFAIL, "Child %d"
- "exited with wrong "
- "status", ret_val);
- tst_resm(TFAIL, "Expected 3 "
- "got %d ",
- WEXITSTATUS(status));
- flag = FAILED;
- }
- }
- wait_kid_pid[kid_count++] = ret_val;
- }
-
- /*
- * Check that for every entry in the fork_kid_pid array,
- * there is a matching pid in the wait_kid_pid array. If
- * not, it's an error.
- */
- for (i = 0; i < kid_count; i++) {
- found = 0;
- for (j = 0; j < MAXKIDS; j++) {
- if (fork_kid_pid[j] == wait_kid_pid[i]){
- found = 1;
- break;
- }
- }
-
- if (!found) {
- tst_resm(TFAIL, "Did not find a "
- "wait_kid_pid for the "
- "fork_kid_pid of %d",
- fork_kid_pid[j]);
- for (k = 0; k < MAXKIDS; k++) {
- tst_resm(TFAIL,
- "fork_kid_pid[%d] = "
- "%d", k,
- fork_kid_pid[k]);
- }
- for (k = 0; k < kid_count; k++) {
- tst_resm(TFAIL,
- "wait_kid_pid[%d] = "
- "%d", k,
- wait_kid_pid[k]);
- }
- flag = FAILED;
- }
- }
-
- if (flag) {
- exit(1);
- } else {
- exit(0);
- }
+#else
+ do_child_1();
+#endif
} else { /* parent */
fail = 0;
waitpid(pid, &status, 0);
@@ -232,6 +143,168 @@
}
/*
+ * setup_sigint()
+ * Sets up a SIGINT handler
+ */
+void
+setup_sigint(void)
+{
+ if ((sig_t)signal(SIGINT, inthandlr) == SIG_ERR ) {
+ tst_resm(TFAIL, "signal SIGINT failed. "
+ "errno = %d", errno);
+ exit(-1);
+ }
+}
+
+/*
+ * do_child_1()
+ */
+void
+do_child_1(void)
+{
+ int kid_count, fork_kid_pid[MAXKIDS];
+ int ret_val;
+ int i, j, k, found;
+ int group1, group2;
+ int wait_kid_pid[MAXKIDS], status;
+
+ setup_sigint();
+
+ group1 = getpgrp();
+ for (kid_count = 0; kid_count < MAXKIDS; kid_count++) {
+ if (kid_count == (MAXKIDS / 2)) {
+ group2 = setpgrp();
+ }
+ intintr = 0;
+ ret_val = FORK_OR_VFORK();
+ if (ret_val == 0) { /* child */
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 2) < 0) {
+ tst_resm(TFAIL, "Fork kid %d failed. "
+ "errno = %d", kid_count,
+ errno);
+ exit(ret_val);
+ }
+#else
+ do_exit();
+#endif
+ /*NOTREACHED*/
+ } else if (ret_val < 0) {
+ tst_resm(TFAIL, "Fork kid %d failed. "
+ "errno = %d", kid_count,
+ errno);
+ exit(ret_val);
+ }
+
+ /* parent */
+ fork_kid_pid[kid_count] = ret_val;
+ }
+
+#ifdef UCLINUX
+ /* Give the kids a chance to setup SIGINT again, since this is
+ * cleared by exec().
+ */
+ sleep(3);
+#endif
+
+ /* Now send all the kids a SIGINT to tell them to
+ * proceed
+ */
+ for (i = 0; i < MAXKIDS; i++) {
+ if (kill(fork_kid_pid[i], SIGINT) < 0) {
+ tst_resm(TFAIL, "Kill of child %d "
+ "failed, errno = %d", i, errno);
+ exit(-1);
+ }
+ }
+
+ /*
+ * Wait till all kids have terminated. Stash away their
+ * pid's in an array.
+ */
+ kid_count = 0;
+ errno = 0;
+ while (((ret_val = waitpid(-1, &status, 0)) != -1) ||
+ (errno == EINTR)) {
+ if (ret_val == -1) {
+ continue;
+ }
+
+ if (!WIFEXITED(status)) {
+ tst_resm(TFAIL, "Child %d did not exit "
+ "normally", ret_val);
+ flag = FAILED;
+ printf("status: %d\n", status);
+ } else {
+ if (WEXITSTATUS(status) != 3) {
+ tst_resm(TFAIL, "Child %d"
+ "exited with wrong "
+ "status", ret_val);
+ tst_resm(TFAIL, "Expected 3 "
+ "got %d ",
+ WEXITSTATUS(status));
+ flag = FAILED;
+ }
+ }
+ wait_kid_pid[kid_count++] = ret_val;
+ }
+
+ /*
+ * Check that for every entry in the fork_kid_pid array,
+ * there is a matching pid in the wait_kid_pid array. If
+ * not, it's an error.
+ */
+ for (i = 0; i < kid_count; i++) {
+ found = 0;
+ for (j = 0; j < MAXKIDS; j++) {
+ if (fork_kid_pid[j] == wait_kid_pid[i]){
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found) {
+ tst_resm(TFAIL, "Did not find a "
+ "wait_kid_pid for the "
+ "fork_kid_pid of %d",
+ fork_kid_pid[j]);
+ for (k = 0; k < MAXKIDS; k++) {
+ tst_resm(TFAIL,
+ "fork_kid_pid[%d] = "
+ "%d", k,
+ fork_kid_pid[k]);
+ }
+ for (k = 0; k < kid_count; k++) {
+ tst_resm(TFAIL,
+ "wait_kid_pid[%d] = "
+ "%d", k,
+ wait_kid_pid[k]);
+ }
+ flag = FAILED;
+ }
+ }
+
+ if (flag) {
+ exit(1);
+ } else {
+ exit(0);
+ }
+}
+
+#ifdef UCLINUX
+/*
+ * do_child_2_uclinux()
+ * sets up sigint handler again, then calls the normal child 2 function
+ */
+void
+do_child_2_uclinux(void)
+{
+ setup_sigint();
+ do_exit();
+}
+#endif
+
+/*
* setup()
* performs all ONE TIME setup for this test
*/
diff --git a/testcases/kernel/syscalls/waitpid/waitpid07.c b/testcases/kernel/syscalls/waitpid/waitpid07.c
index 426733f..efde2cc 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid07.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid07.c
@@ -52,6 +52,8 @@
#include <test.h>
#include <usctest.h>
+void setup_sigint(void);
+void do_child_1(void);
void setup(void);
void cleanup(void);
@@ -67,16 +69,18 @@
#define FAILED 1
#define MAXKIDS 8
+#ifdef UCLINUX
+static char *argv0;
+void do_child_2_uclinux(void);
+#endif
+
int main(int argc, char **argv)
{
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
- int kid_count, fork_kid_pid[MAXKIDS];
- int wait_kid_pid[MAXKIDS], ret_val;
- int status, i, j, k, found;
+ int status;
int fail = 0;
- int group1, group2;
int pid;
/* parse standard options */
@@ -87,6 +91,13 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ argv0 = argv[0];
+
+ maybe_run_child(&do_child_1, "n", 1);
+ maybe_run_child(&do_child_2_uclinux, "n", 2);
+#endif
+
setup();
/* check for looping state if -i option is given */
@@ -94,7 +105,7 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
tst_resm(TFAIL, "Fork Failed, may be OK under stress");
tst_exit();
} else if (pid == 0) {
@@ -104,124 +115,14 @@
* Set up to catch SIGINT. The kids will wait till a
* SIGINT has been received before they proceed.
*/
- if (signal(SIGINT, inthandlr) == SIG_ERR) {
- tst_resm(TFAIL, "signal SIGINT failed, "
- "errno = %d", errno);
- tst_exit();
+#ifdef UCLINUX
+ if (self_exec(argv[0], "n", 1) < 0) {
+ tst_resm(TINFO, "self_exec failed");
+ exit(pid);
}
-
- group1 = getpgrp();
-
- for (kid_count = 0; kid_count < MAXKIDS; kid_count++) {
- if (kid_count == (MAXKIDS / 2)) {
- group2 = setpgrp();
- }
-
- intintr = 0;
- ret_val = fork();
- if (ret_val == 0) {
- do_exit();
- }
-
- if (ret_val < 0) {
- tst_resm(TFAIL, "Fork kid %d failed. "
- "errno = %d", kid_count, errno);
- tst_exit();
- }
-
- /* parent */
- fork_kid_pid[kid_count] = ret_val;
- }
-
- /* Check that waitpid with WNOHANG returns zero */
- if ((ret_val = waitpid(-1, &status, WNOHANG)) != 0) {
- tst_resm(TFAIL, "Waitpid returned wrong value");
- tst_resm(TFAIL, "Expected 0 got %d",
- ret_val);
- flag = FAILED;
- }
-
- /* Now send all the kids a SIGINT to tell them to
- * proceed
- */
- for (i = 0; i < MAXKIDS; i++) {
- if (kill(fork_kid_pid[i], SIGINT) < 0) {
- tst_resm(TFAIL, "Kill of child %d "
- "failed, errno = %d", i, errno);
- tst_exit();
- }
- }
-
- /*
- * Wait till all kids have terminated. Stash away their
- * pid's in an array.
- */
- kid_count = 0;
- errno = 0;
- while (((ret_val = waitpid(-1, &status, WNOHANG)) != -1)
- || (errno == EINTR)) {
- if ((ret_val == -1) || (ret_val == 0)) {
- continue;
- }
-
- if (!WIFEXITED(status)) {
- tst_resm(TFAIL, "Child %d did not exit "
- "normally", ret_val);
- flag = FAILED;
- } else {
- if (WEXITSTATUS(status) != 3) {
- tst_resm(TFAIL, "Child %d "
- "exited with wrong "
- "status", ret_val);
- tst_resm(TFAIL, "Expected 3 "
- "got %d ",
- WEXITSTATUS(status));
- flag = FAILED;
- }
- }
- wait_kid_pid[kid_count++] = ret_val;
- }
-
- /*
- * Check that for every entry in the fork_kid_pid array,
- * there is a matching pid in the wait_kid_pid array. If
- * not, it's an error.
- */
- for (i = 0; i < kid_count; i++) {
- found = 0;
- for (j = 0; j < MAXKIDS; j++) {
- if (fork_kid_pid[j] == wait_kid_pid[i]){
- found = 1;
- break;
- }
- }
-
- if (!found) {
- tst_resm(TFAIL, "Did not find a "
- "wait_kid_pid for the "
- "fork_kid_pid of %d",
- fork_kid_pid[j]);
- for (k = 0; k < MAXKIDS; k++) {
- tst_resm(TFAIL,
- "fork_kid_pid[%d] = "
- "%d", k,
- fork_kid_pid[k]);
- }
- for (k = 0; k < kid_count; k++) {
- tst_resm(TFAIL,
- "wait_kid_pid[%d] = "
- "%d", k,
- wait_kid_pid[k]);
- }
- flag = FAILED;
- }
- }
-
- if (flag) {
- exit(1);
- } else {
- exit(0);
- }
+#else
+ do_child_1();
+#endif
} else { /* parent */
fail = 0;
waitpid(pid, &status, 0);
@@ -244,6 +145,178 @@
}
/*
+ * setup_sigint()
+ * Sets up a SIGINT handler
+ */
+void
+setup_sigint(void)
+{
+ if ((sig_t)signal(SIGINT, inthandlr) == SIG_ERR ) {
+ tst_resm(TFAIL, "signal SIGINT failed. "
+ "errno = %d", errno);
+ exit(-1);
+ }
+}
+
+/*
+ * do_child_1()
+ */
+void
+do_child_1(void)
+{
+ int kid_count, fork_kid_pid[MAXKIDS];
+ int ret_val;
+ int i, j, k, found;
+ int group1, group2;
+ int wait_kid_pid[MAXKIDS], status;
+
+ setup_sigint();
+
+ group1 = getpgrp();
+
+ for (kid_count = 0; kid_count < MAXKIDS; kid_count++) {
+ if (kid_count == (MAXKIDS / 2)) {
+ group2 = setpgrp();
+ }
+
+ intintr = 0;
+ ret_val = FORK_OR_VFORK();
+ if (ret_val == 0) {
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 2) < 0) {
+ tst_resm(TFAIL, "Fork kid %d failed. "
+ "errno = %d", kid_count,
+ errno);
+ exit(ret_val);
+ }
+#else
+ do_exit();
+#endif
+ /*NOTREACHED*/
+ }
+
+ if (ret_val < 0) {
+ tst_resm(TFAIL, "Fork kid %d failed. "
+ "errno = %d", kid_count, errno);
+ tst_exit();
+ }
+
+ /* parent */
+ fork_kid_pid[kid_count] = ret_val;
+ }
+
+ /* Check that waitpid with WNOHANG returns zero */
+ if ((ret_val = waitpid(-1, &status, WNOHANG)) != 0) {
+ tst_resm(TFAIL, "Waitpid returned wrong value");
+ tst_resm(TFAIL, "Expected 0 got %d",
+ ret_val);
+ flag = FAILED;
+ }
+
+#ifdef UCLINUX
+ /* Give the kids a chance to setup SIGINT again, since this is
+ * cleared by exec().
+ */
+ sleep(3);
+#endif
+
+ /* Now send all the kids a SIGINT to tell them to
+ * proceed
+ */
+ for (i = 0; i < MAXKIDS; i++) {
+ if (kill(fork_kid_pid[i], SIGINT) < 0) {
+ tst_resm(TFAIL, "Kill of child %d "
+ "failed, errno = %d", i, errno);
+ tst_exit();
+ }
+ }
+
+ /*
+ * Wait till all kids have terminated. Stash away their
+ * pid's in an array.
+ */
+ kid_count = 0;
+ errno = 0;
+ while (((ret_val = waitpid(-1, &status, WNOHANG)) != -1)
+ || (errno == EINTR)) {
+ if ((ret_val == -1) || (ret_val == 0)) {
+ continue;
+ }
+
+ if (!WIFEXITED(status)) {
+ tst_resm(TFAIL, "Child %d did not exit "
+ "normally", ret_val);
+ flag = FAILED;
+ } else {
+ if (WEXITSTATUS(status) != 3) {
+ tst_resm(TFAIL, "Child %d "
+ "exited with wrong "
+ "status", ret_val);
+ tst_resm(TFAIL, "Expected 3 "
+ "got %d ",
+ WEXITSTATUS(status));
+ flag = FAILED;
+ }
+ }
+ wait_kid_pid[kid_count++] = ret_val;
+ }
+
+ /*
+ * Check that for every entry in the fork_kid_pid array,
+ * there is a matching pid in the wait_kid_pid array. If
+ * not, it's an error.
+ */
+ for (i = 0; i < kid_count; i++) {
+ found = 0;
+ for (j = 0; j < MAXKIDS; j++) {
+ if (fork_kid_pid[j] == wait_kid_pid[i]){
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found) {
+ tst_resm(TFAIL, "Did not find a "
+ "wait_kid_pid for the "
+ "fork_kid_pid of %d",
+ fork_kid_pid[j]);
+ for (k = 0; k < MAXKIDS; k++) {
+ tst_resm(TFAIL,
+ "fork_kid_pid[%d] = "
+ "%d", k,
+ fork_kid_pid[k]);
+ }
+ for (k = 0; k < kid_count; k++) {
+ tst_resm(TFAIL,
+ "wait_kid_pid[%d] = "
+ "%d", k,
+ wait_kid_pid[k]);
+ }
+ flag = FAILED;
+ }
+ }
+
+ if (flag) {
+ exit(1);
+ } else {
+ exit(0);
+ }
+}
+
+#ifdef UCLINUX
+/*
+ * do_child_2_uclinux()
+ * sets up sigint handler again, then calls the normal child 2 function
+ */
+void
+do_child_2_uclinux(void)
+{
+ setup_sigint();
+ do_exit();
+}
+#endif
+
+/*
* setup()
* performs all ONE TIME setup for this test
*/
diff --git a/testcases/kernel/syscalls/waitpid/waitpid08.c b/testcases/kernel/syscalls/waitpid/waitpid08.c
index ba73f4b..73337cb 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid08.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid08.c
@@ -55,6 +55,8 @@
void inthandlr();
void do_exit();
+void setup_sigint(void);
+void do_child_1(void);
void setup(void);
void cleanup(void);
@@ -67,15 +69,17 @@
#define MAXKIDS 8
+#ifdef UCLINUX
+static char *argv0;
+void do_child_2_uclinux(void);
+#endif
+
int main(int argc, char **argv)
{
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
- int kid_count, ret_val, status;
- int i, j, k, found;
- int group1, group2;
- int fork_kid_pid[MAXKIDS], wait_kid_pid[MAXKIDS];
+ int status;
int pid;
/* parse standard options */
@@ -86,6 +90,13 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ argv0 = argv[0];
+
+ maybe_run_child(&do_child_1, "n", 1);
+ maybe_run_child(&do_child_2_uclinux, "n", 2);
+#endif
+
setup();
/* check for looping state if -i option is given */
@@ -93,7 +104,7 @@
/* reset Tst_count in case we are looping */
Tst_count = 0;
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
tst_resm(TFAIL, "Fork Failed, may be OK under stress");
tst_exit();
} else if (pid == 0) {
@@ -103,155 +114,14 @@
* The kids will wait till a SIGINT has been received
* before they proceed.
*/
- if ((sig_t)signal(SIGINT, inthandlr) == SIG_ERR) {
- tst_resm(TBROK, "signal SIGINT failed, errno "
- "= %d", errno);
- exit(-1);
+#ifdef UCLINUX
+ if (self_exec(argv[0], "n", 1) < 0) {
+ tst_resm(TINFO, "self_exec failed");
+ exit(pid);
}
-
- group1 = getpgrp();
-
- for (kid_count = 0; kid_count < MAXKIDS; kid_count++) {
- if (kid_count == (MAXKIDS / 2)) {
- group2 = setpgrp();
- }
-
- intintr = 0;
- ret_val = fork();
- if (ret_val == 0) {
- do_exit();
- }
-
- if (ret_val < 0) {
- tst_resm(TFAIL, "Fork kid %d failed. "
- "errno = %d", kid_count, errno);
- exit(ret_val);
- }
-
- /* parent */
- fork_kid_pid[kid_count] = ret_val;
- }
-
- /* Check that waitpid with WNOHANG|WUNTRACED returns
- * zero
- */
- if ((ret_val = waitpid(-1, &status, WNOHANG |
- WUNTRACED)) != 0) {
- tst_resm(TFAIL, "Waitpid returned wrong value");
- tst_resm(TFAIL, "Expected 0 got %d", ret_val);
- fail = 1;
- }
-
- /* Now send all the kids a SIGINT to tell them to
- * proceed
- */
- for (i = 0; i < MAXKIDS; i++) {
- if (kill(fork_kid_pid[i], SIGINT) < 0) {
- tst_resm(TFAIL, "Kill of child %d "
- "failed, errno = %d", i, errno);
- tst_exit();
- /*NOTREACHED*/
- }
- }
-
- /*
- * Wait till all kids have terminated. Stash away their
- * pid's in an array.
- */
- kid_count = 0;
- errno = 0;
- while (((ret_val = waitpid(-1, &status, WUNTRACED)) !=
- -1) || (errno == EINTR)) {
- if (ret_val == -1) {
- continue;
- }
-
- if (!WIFEXITED(status)) {
- if (!WIFSTOPPED(status)) {
- tst_resm(TFAIL, "Child %d did "
- "not stopped", ret_val);
- fail = 1;
- } else {
- if (WSTOPSIG(status) !=
- SIGSTOP) {
- tst_resm(TFAIL,
- "Child %d "
- "exited with "
- "wrong status",
- ret_val);
- tst_resm(TFAIL,
- "Expected "
- "SIGSTOP got %d",
- WSTOPSIG(status
- ));
- fail = 1;
- }
- }
- if (kill(ret_val, SIGCONT) < 0) {
- tst_resm(TFAIL, "Kill of child "
- "%d failed, errno = %d",
- ret_val, errno);
- fail = 1;
- }
- }
- wait_kid_pid[kid_count++] = ret_val;
- }
-
- /*
- * Check that for every entry in the fork_kid_pid array,
- * there is a matching pid in the wait_kid_pid array. If
- * not, it's an error.
- */
- for (i = 0; i < kid_count; i++) {
- found = 0;
- for (j = 0; j < MAXKIDS; j++) {
- if (fork_kid_pid[j] == wait_kid_pid[i]) {
- found = 1;
- break;
- }
- }
- if (!found) {
- tst_resm(TFAIL,
- "Did not find a wait_kid_pid "
- "for the fork_kid_pid of %d",
- fork_kid_pid[j]);
- for (k = 0; k < MAXKIDS; k++) {
- tst_resm(TFAIL,
- "fork_kid_pid[%d] = "
- "%d", k,
- fork_kid_pid[k]);
- }
- for (k = 0; k < kid_count; k++) {
- tst_resm(TFAIL,
- "wait_kid_pid[%d] = "
- "%d", k,
- wait_kid_pid[k]);
- }
- fail = 1;
- }
- }
-
- /*
- * Check that waitpid(WUNTRACED) returns -1 when no
- * stopped children
- */
- if ((ret_val = waitpid(-1, &status, WUNTRACED)) != -1) {
- tst_resm(TFAIL,
- "Waitpid returned wrong value.");
- tst_resm(TFAIL, "Expected -1 got %d from "
- "waitpid(WUNTRACED)", ret_val);
- fail = 1;
- }
-
- if (errno != ECHILD) {
- tst_resm(TFAIL,
- "Waitpid returned wrong errno.");
- tst_resm(TFAIL,
- "Expected ECHILD got %d", errno);
- fail = 1;
- }
-
- exit(fail);
+#else
+ do_child_1();
+#endif
} else { /* parent */
fail = 0;
waitpid(pid, &status, 0);
@@ -273,6 +143,208 @@
}
/*
+ * setup_sigint()
+ * Sets up a SIGINT handler
+ */
+void
+setup_sigint(void)
+{
+ if ((sig_t)signal(SIGINT, inthandlr) == SIG_ERR ) {
+ tst_resm(TFAIL, "signal SIGINT failed. "
+ "errno = %d", errno);
+ exit(-1);
+ }
+}
+
+/*
+ * do_child_1()
+ */
+void
+do_child_1(void)
+{
+ int kid_count, fork_kid_pid[MAXKIDS];
+ int ret_val;
+ int i, j, k, found;
+ int group1, group2;
+ int wait_kid_pid[MAXKIDS], status;
+
+ setup_sigint();
+
+ group1 = getpgrp();
+
+ for (kid_count = 0; kid_count < MAXKIDS; kid_count++) {
+ if (kid_count == (MAXKIDS / 2)) {
+ group2 = setpgrp();
+ }
+
+ intintr = 0;
+ ret_val = FORK_OR_VFORK();
+ if (ret_val == 0) {
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 2) < 0) {
+ tst_resm(TFAIL, "Fork kid %d failed. "
+ "errno = %d", kid_count,
+ errno);
+ exit(ret_val);
+ }
+#else
+ do_exit();
+#endif
+ }
+
+ if (ret_val < 0) {
+ tst_resm(TFAIL, "Fork kid %d failed. "
+ "errno = %d", kid_count, errno);
+ exit(ret_val);
+ }
+
+ /* parent */
+ fork_kid_pid[kid_count] = ret_val;
+ }
+
+ /* Check that waitpid with WNOHANG|WUNTRACED returns
+ * zero
+ */
+ if ((ret_val = waitpid(-1, &status, WNOHANG |
+ WUNTRACED)) != 0) {
+ tst_resm(TFAIL, "Waitpid returned wrong value");
+ tst_resm(TFAIL, "Expected 0 got %d", ret_val);
+ fail = 1;
+ }
+
+#ifdef UCLINUX
+ /* Give the kids a chance to setup SIGINT again, since this is
+ * cleared by exec().
+ */
+ sleep(3);
+#endif
+
+ /* Now send all the kids a SIGINT to tell them to
+ * proceed
+ */
+ for (i = 0; i < MAXKIDS; i++) {
+ if (kill(fork_kid_pid[i], SIGINT) < 0) {
+ tst_resm(TFAIL, "Kill of child %d "
+ "failed, errno = %d", i, errno);
+ tst_exit();
+ /*NOTREACHED*/
+ }
+ }
+
+ /*
+ * Wait till all kids have terminated. Stash away their
+ * pid's in an array.
+ */
+ kid_count = 0;
+ errno = 0;
+ while (((ret_val = waitpid(-1, &status, WUNTRACED)) !=
+ -1) || (errno == EINTR)) {
+ if (ret_val == -1) {
+ continue;
+ }
+
+ if (!WIFEXITED(status)) {
+ if (!WIFSTOPPED(status)) {
+ tst_resm(TFAIL, "Child %d did "
+ "not stopped", ret_val);
+ fail = 1;
+ } else {
+ if (WSTOPSIG(status) !=
+ SIGSTOP) {
+ tst_resm(TFAIL,
+ "Child %d "
+ "exited with "
+ "wrong status",
+ ret_val);
+ tst_resm(TFAIL,
+ "Expected "
+ "SIGSTOP got %d",
+ WSTOPSIG(status
+ ));
+ fail = 1;
+ }
+ }
+ if (kill(ret_val, SIGCONT) < 0) {
+ tst_resm(TFAIL, "Kill of child "
+ "%d failed, errno = %d",
+ ret_val, errno);
+ fail = 1;
+ }
+ }
+ wait_kid_pid[kid_count++] = ret_val;
+ }
+
+ /*
+ * Check that for every entry in the fork_kid_pid array,
+ * there is a matching pid in the wait_kid_pid array. If
+ * not, it's an error.
+ */
+ for (i = 0; i < kid_count; i++) {
+ found = 0;
+ for (j = 0; j < MAXKIDS; j++) {
+ if (fork_kid_pid[j] == wait_kid_pid[i]) {
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ tst_resm(TFAIL,
+ "Did not find a wait_kid_pid "
+ "for the fork_kid_pid of %d",
+ fork_kid_pid[j]);
+ for (k = 0; k < MAXKIDS; k++) {
+ tst_resm(TFAIL,
+ "fork_kid_pid[%d] = "
+ "%d", k,
+ fork_kid_pid[k]);
+ }
+ for (k = 0; k < kid_count; k++) {
+ tst_resm(TFAIL,
+ "wait_kid_pid[%d] = "
+ "%d", k,
+ wait_kid_pid[k]);
+ }
+ fail = 1;
+ }
+ }
+
+ /*
+ * Check that waitpid(WUNTRACED) returns -1 when no
+ * stopped children
+ */
+ if ((ret_val = waitpid(-1, &status, WUNTRACED)) != -1) {
+ tst_resm(TFAIL,
+ "Waitpid returned wrong value.");
+ tst_resm(TFAIL, "Expected -1 got %d from "
+ "waitpid(WUNTRACED)", ret_val);
+ fail = 1;
+ }
+
+ if (errno != ECHILD) {
+ tst_resm(TFAIL,
+ "Waitpid returned wrong errno.");
+ tst_resm(TFAIL,
+ "Expected ECHILD got %d", errno);
+ fail = 1;
+ }
+
+ exit(fail);
+}
+
+#ifdef UCLINUX
+/*
+ * do_child_2_uclinux()
+ * sets up sigint handler again, then calls the normal child 2 function
+ */
+void
+do_child_2_uclinux(void)
+{
+ setup_sigint();
+ do_exit();
+}
+#endif
+
+/*
* setup()
* performs all ONE TIME setup for this test
*/
diff --git a/testcases/kernel/syscalls/waitpid/waitpid09.c b/testcases/kernel/syscalls/waitpid/waitpid09.c
index 50b7670..fa29abf 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid09.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid09.c
@@ -77,7 +77,10 @@
void cleanup(void);
void inthandlr();
void do_exit();
-
+void setup_sigint();
+#ifdef UCLINUX
+void do_exit_uclinux();
+#endif
int main(int argc, char **argv)
{
@@ -94,9 +97,13 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ maybe_run_child(&do_exit_uclinux, "");
+#endif
+
setup();
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
tst_brkm(TFAIL, cleanup, "Fork Failed");
/*NOTREACHED*/
} else if (pid == 0) {
@@ -105,11 +112,7 @@
* Set up to catch SIGINT. The kids will wait till a
* SIGINT has been received before they proceed.
*/
- if ((sig_t)signal(SIGINT, inthandlr) == SIG_ERR) {
- tst_brkm(TFAIL, cleanup, "signal SIGINT failed,"
- " errno = %d", errno);
- /*NOTREACHED*/
- }
+ setup_sigint();
/* check for looping state if -i option is given */
for (lc = 0; TEST_LOOPING(lc); lc++) {
@@ -119,11 +122,18 @@
intintr = 0;
fail = 0;
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
tst_brkm(TFAIL, cleanup, "Fork failed.");
/*NOTREACHED*/
} else if (pid == 0) { /* child */
+#ifdef UCLINUX
+ if (self_exec(argv[0], "") < 0) {
+ tst_brkm(TFAIL, cleanup, "self_exec failed");
+ /*NOTREACHED*/
+ }
+#else
do_exit();
+#endif
} else { /* parent */
/*
@@ -139,6 +149,12 @@
ret);
fail = 1;
}
+#ifdef UCLINUX
+ /* Give the kids a chance to setup SIGINT again, since
+ * this is cleared by exec().
+ */
+ sleep(3);
+#endif
/* send SIGINT to child to tell it to proceed */
if (kill(pid, SIGINT) < 0) {
@@ -169,7 +185,7 @@
}
}
- if ((pid = fork()) < 0) {
+ if ((pid = FORK_OR_VFORK()) < 0) {
tst_brkm(TFAIL, cleanup, "Second fork failed.");
/*NOTREACHED*/
} else if (pid == 0) { /* child */
@@ -256,6 +272,21 @@
}
/*
+ * setup_sigint()
+ * sets up a SIGINT handler
+ */
+void
+setup_sigint(void)
+{
+ if ((sig_t)signal(SIGINT, inthandlr) == SIG_ERR) {
+ tst_brkm(TFAIL, cleanup, "signal SIGINT failed, errno = %d",
+ errno);
+ tst_exit();
+ /*NOTREACHED*/
+ }
+}
+
+/*
* setup()
* performs all ONE TIME setup for this test
*/
@@ -310,3 +341,16 @@
wait_for_parent();
exit(0);
}
+
+#ifdef UCLINUX
+/*
+ * do_exit_uclinux()
+ * Sets up SIGINT handler again, then calls do_exit
+ */
+void
+do_exit_uclinux()
+{
+ setup_sigint();
+ do_exit();
+}
+#endif
diff --git a/testcases/kernel/syscalls/waitpid/waitpid10.c b/testcases/kernel/syscalls/waitpid/waitpid10.c
index e19eb40..80c0513 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid10.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid10.c
@@ -86,6 +86,10 @@
int fail;
+#ifdef UCLINUX
+static char *argv0;
+#endif
+
int main(int ac, char **av)
{
int kid_count, ret_val, status, nkids;
@@ -101,6 +105,16 @@
(char *)NULL) {
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
}
+
+#ifdef UCLINUX
+ argv0 = av[0];
+
+ maybe_run_child(&do_exit, "n", 1);
+ maybe_run_child(&do_compute, "n", 2);
+ maybe_run_child(&do_fork, "n", 3);
+ maybe_run_child(&do_sleep, "n", 4);
+ maybe_run_child(&do_mkdir, "n", 5);
+#endif
/*
* process the arg -- If there is one arg, it is the
@@ -165,10 +179,17 @@
* So that we may not miss any signals !
*/
intintr = 0;
- ret_val = fork();
+ ret_val = FORK_OR_VFORK();
if (ret_val == 0) { /* child 0 */
// intintr = 0;
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 1) < 0) {
+ tst_resm(TFAIL, "self_exec 0 failed");
+ tst_exit();
+ }
+#else
do_exit();
+#endif
}
if (ret_val < 0) {
tst_resm(TFAIL, "Fork kid 0 failed. errno = "
@@ -179,10 +200,17 @@
/* parent */
fork_kid_pid[kid_count++] = ret_val;
- ret_val = fork();
+ ret_val = FORK_OR_VFORK();
if (ret_val == 0) { /* child 1 */
// intintr = 0;
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 1) < 0) {
+ tst_resm(TFAIL, "self_exec 1 failed");
+ tst_exit();
+ }
+#else
do_exit();
+#endif
}
if (ret_val < 0) {
tst_resm(TFAIL, "Fork kid 1 failed. errno = "
@@ -193,11 +221,17 @@
/* parent */
fork_kid_pid[kid_count++] = ret_val;
- ret_val = fork();
+ ret_val = FORK_OR_VFORK();
if (ret_val == 0) { /* child 2 */
// intintr = 0;
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 2) < 0) {
+ tst_resm(TFAIL, "self_exec 2 failed");
+ tst_exit();
+ }
+#else
do_compute();
- exit(4);
+#endif
}
if (ret_val < 0) {
tst_resm(TFAIL, "Fork kid 2 failed. errno = "
@@ -208,11 +242,17 @@
/* parent */
fork_kid_pid[kid_count++] = ret_val;
- ret_val = fork();
+ ret_val = FORK_OR_VFORK();
if (ret_val == 0) { /* child 3 */
// intintr = 0;
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 2) < 0) {
+ tst_resm(TFAIL, "self_exec 3 failed");
+ tst_exit();
+ }
+#else
do_compute();
- exit(4);
+#endif
}
if (ret_val < 0) {
tst_resm(TFAIL, "Fork kid 3 failed. errno = "
@@ -223,11 +263,17 @@
/* parent */
fork_kid_pid[kid_count++] = ret_val;
- ret_val = fork();
+ ret_val = FORK_OR_VFORK();
if (ret_val == 0) { /* child 4 */
// intintr = 0;
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 3) < 0) {
+ tst_resm(TFAIL, "self_exec 4 failed");
+ tst_exit();
+ }
+#else
do_fork();
- exit(4);
+#endif
}
if (ret_val < 0) {
tst_resm(TFAIL, "Fork kid 4 failed. errno = "
@@ -238,11 +284,17 @@
/* parent */
fork_kid_pid[kid_count++] = ret_val;
- ret_val = fork();
+ ret_val = FORK_OR_VFORK();
if (ret_val == 0) { /* child 5 */
// intintr = 0;
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 3) < 0) {
+ tst_resm(TFAIL, "self_exec 5 failed");
+ tst_exit();
+ }
+#else
do_fork();
- exit(4);
+#endif
}
if (ret_val < 0) {
tst_resm(TFAIL, "Fork kid 5 failed. errno = "
@@ -253,11 +305,17 @@
/* parent */
fork_kid_pid[kid_count++] = ret_val;
- ret_val = fork();
+ ret_val = FORK_OR_VFORK();
if (ret_val == 0) { /* child 6 */
// intintr = 0;
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 4) < 0) {
+ tst_resm(TFAIL, "self_exec 6 failed");
+ tst_exit();
+ }
+#else
do_sleep();
- exit(4);
+#endif
}
if (ret_val < 0) {
tst_resm(TFAIL, "Fork kid 6 failed. errno = "
@@ -268,11 +326,17 @@
/* parent */
fork_kid_pid[kid_count++] = ret_val;
- ret_val = fork();
+ ret_val = FORK_OR_VFORK();
if (ret_val == 0) { /* child 7 */
// intintr = 0;
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 4) < 0) {
+ tst_resm(TFAIL, "self_exec 7 failed");
+ tst_exit();
+ }
+#else
do_sleep();
- exit(4);
+#endif
}
if (ret_val < 0) {
tst_resm(TFAIL, "Fork kid 7 failed. errno = "
@@ -448,6 +512,8 @@
for (i = 0; i < 100000; i++);
for (i = 0; i < 100000; i++);
for (i = 0; i < 100000; i++);
+
+ exit(4);
}
void
@@ -464,14 +530,20 @@
* sure they are the same.
*/
for (i = 0; i < 50; i++) {
- fork_pid = fork();
+ fork_pid = FORK_OR_VFORK();
if (fork_pid < 0) {
tst_resm(TFAIL, "Fork failed");
tst_exit();
}
if (fork_pid == 0) {
+#ifdef UCLINUX
+ if (self_exec(argv0, "n", 5) < 0) {
+ tst_resm(TFAIL, "do_fork self_exec failed");
+ tst_exit();
+ }
+#else
do_mkdir();
- exit(4);
+#endif
}
errno = 0;
@@ -491,6 +563,8 @@
}
}
}
+
+ exit(4);
}
void
@@ -499,6 +573,8 @@
wait_for_parent();
sleep(1);
sleep(1);
+
+ exit(4);
}
void
@@ -511,4 +587,6 @@
* part of the test.
*/
ret_val = mkdir("waitpid14.ttt.ttt", 0777);
+
+ exit(4);
}
diff --git a/testcases/kernel/syscalls/waitpid/waitpid11.c b/testcases/kernel/syscalls/waitpid/waitpid11.c
index aa86489..765c7a3 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid11.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid11.c
@@ -60,6 +60,10 @@
void inthandlr();
void wait_for_parent();
void do_exit();
+void setup_sigint();
+#ifdef UCLINUX
+void do_exit_uclinux();
+#endif
int fail;
@@ -82,6 +86,10 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ maybe_run_child(&do_exit_uclinux, "");
+#endif
+
setup();
/* check for looping state if -i option is given */
@@ -95,7 +103,7 @@
* test to be a session leader and setpgrp fails.
*/
- if ((pid = fork()) != 0) {
+ if ((pid = FORK_OR_VFORK()) != 0) {
fail = 0;
waitpid(pid, &status, 0);
if (WEXITSTATUS(status) != 0) {
@@ -118,12 +126,7 @@
* Set up to catch SIGINT. The kids will wait till a SIGINT
* has been received before they proceed.
*/
- if ((sig_t)signal(SIGINT, inthandlr) == SIG_ERR) {
- tst_resm(TFAIL, "signal SIGINT failed, errno = %d",
- errno);
- tst_exit();
- /*NOTREACHED*/
- }
+ setup_sigint();
group1 = getpgrp();
@@ -135,7 +138,16 @@
intintr = 0;
ret_val = fork();
if (ret_val == 0) {
+#ifdef UCLINUX
+ if (self_exec(av[0], "") < 0) {
+ tst_resm(TFAIL, "self_exec kid %d "
+ "failed", kid_count);
+ tst_exit();
+ /*NOTREACHED*/
+ }
+#else
do_exit();
+#endif
/*NOTREACHED*/
}
@@ -149,6 +161,13 @@
/* parent */
fork_kid_pid[kid_count] = ret_val;
}
+
+#ifdef UCLINUX
+ /* Give the kids a chance to setup SIGINT again, since this is
+ * cleared by exec().
+ */
+ sleep(3);
+#endif
/* Now send all the kids a SIGINT to tell them to proceed */
for (i = 0; i < MAXKIDS; i++) {
@@ -298,6 +317,21 @@
}
/*
+ * setup_sigint()
+ * sets up a SIGINT handler
+ */
+void
+setup_sigint(void)
+{
+ if ((sig_t)signal(SIGINT, inthandlr) == SIG_ERR) {
+ tst_resm(TFAIL, "signal SIGINT failed, errno = %d",
+ errno);
+ tst_exit();
+ /*NOTREACHED*/
+ }
+}
+
+/*
* setup()
* performs all ONE TIME setup for this test
*/
@@ -350,3 +384,16 @@
wait_for_parent();
exit(3);
}
+
+#ifdef UCLINUX
+/*
+ * do_exit_uclinux()
+ * Sets up SIGINT handler again, then calls do_exit
+ */
+void
+do_exit_uclinux()
+{
+ setup_sigint();
+ do_exit();
+}
+#endif
diff --git a/testcases/kernel/syscalls/waitpid/waitpid12.c b/testcases/kernel/syscalls/waitpid/waitpid12.c
index cb4f539..916fed6 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid12.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid12.c
@@ -61,6 +61,10 @@
void inthandlr();
void wait_for_parent();
void do_exit();
+void setup_sigint();
+#ifdef UCLINUX
+void do_exit_uclinux();
+#endif
int fail;
@@ -83,6 +87,10 @@
/*NOTREACHED*/
}
+#ifdef UCLINUX
+ maybe_run_child(&do_exit_uclinux, "");
+#endif
+
setup();
/* check for looping state if -i option is given */
@@ -95,7 +103,7 @@
* test to be a session leader and setpgrp fails.
*/
- if ((pid = fork()) != 0) {
+ if ((pid = FORK_OR_VFORK()) != 0) {
fail = 0;
waitpid(pid, &status, 0);
if (WEXITSTATUS(status) != 0) {
@@ -118,12 +126,7 @@
* Set up to catch SIGINT. The kids will wait till a SIGINT
* has been received before they proceed.
*/
- if (signal(SIGINT, inthandlr) == SIG_ERR) {
- tst_resm(TFAIL, "signal SIGINT failed, errno = %d",
- errno);
- tst_exit();
- /*NOTREACHED*/
- }
+ setup_sigint();
group1 = getpgrp();
@@ -135,7 +138,16 @@
intintr = 0;
ret_val = fork();
if (ret_val == 0) {
+#ifdef UCLINUX
+ if (self_exec(argv[0], "") < 0) {
+ tst_resm(TFAIL, "self_exec kid %d "
+ "failed", kid_count);
+ tst_exit();
+ /*NOTREACHED*/
+ }
+#else
do_exit();
+#endif
/*NOTREACHED*/
}
@@ -157,6 +169,13 @@
fail = 1;
}
+#ifdef UCLINUX
+ /* Give the kids a chance to setup SIGINT again, since this is
+ * cleared by exec().
+ */
+ sleep(3);
+#endif
+
/* Now send all the kids a SIGINT to tell them to proceed */
for (i = 0; i < MAXKIDS; i++) {
if (kill(fork_kid_pid[i], SIGINT) < 0) {
@@ -305,6 +324,22 @@
}
+
+/*
+ * setup_sigint()
+ * sets up a SIGINT handler
+ */
+void
+setup_sigint(void)
+{
+ if ((sig_t)signal(SIGINT, inthandlr) == SIG_ERR) {
+ tst_resm(TFAIL, "signal SIGINT failed, errno = %d",
+ errno);
+ tst_exit();
+ /*NOTREACHED*/
+ }
+}
+
/*
* setup()
* performs all ONE TIME setup for this test
@@ -362,3 +397,16 @@
wait_for_parent();
exit(3);
}
+
+#ifdef UCLINUX
+/*
+ * do_exit_uclinux()
+ * Sets up SIGINT handler again, then calls do_exit
+ */
+void
+do_exit_uclinux()
+{
+ setup_sigint();
+ do_exit();
+}
+#endif
diff --git a/testcases/kernel/syscalls/waitpid/waitpid13.c b/testcases/kernel/syscalls/waitpid/waitpid13.c
index 096f458..c2f17ac 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid13.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid13.c
@@ -61,6 +61,10 @@
void inthandlr();
void wait_for_parent();
void do_exit();
+void setup_sigint();
+#ifdef UCLINUX
+void do_exit_uclinux();
+#endif
int fail;
@@ -81,6 +85,10 @@
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
}
+#ifdef UCLINUX
+ maybe_run_child(&do_exit_uclinux, "");
+#endif
+
setup();
/* check for looping state if -i option is given */
@@ -92,7 +100,7 @@
* Need to have test run from child as test driver causes
* test to be a session leader and setpgrp fails.
*/
- if ((pid = fork()) != 0) {
+ if ((pid = FORK_OR_VFORK()) != 0) {
fail = 0;
waitpid(pid, &status, 0);
if (WEXITSTATUS(status) != 0) {
@@ -115,11 +123,7 @@
* Set up to catch SIGINT. The kids will wait till a SIGINT
* has been received before they proceed.
*/
- if ((sig_t)signal(SIGINT, inthandlr) == SIG_ERR) {
- tst_brkm(TFAIL, cleanup, "signal SIGINT failed, "
- "errno = %d", errno);
- /*NOTREACHED*/
- }
+ setup_sigint();
group1 = getpgrp();
@@ -129,9 +133,18 @@
}
intintr = 0;
- ret_val = fork();
+ ret_val = FORK_OR_VFORK();
if (ret_val == 0) {
+#ifdef UCLINUX
+ if (self_exec(av[0], "") < 0) {
+ tst_resm(TFAIL, "self_exec kid %d "
+ "failed", kid_count);
+ tst_exit();
+ /*NOTREACHED*/
+ }
+#else
do_exit();
+#endif
/*NOTREACHED*/
}
@@ -155,6 +168,13 @@
fail = 1;
}
+#ifdef UCLINUX
+ /* Give the kids a chance to setup SIGINT again, since this is
+ * cleared by exec().
+ */
+ sleep(3);
+#endif
+
/* Now send all the kids a SIGINT to tell them to proceed */
for (i = 0; i < MAXKIDS; i++) {
if (kill(fork_kid_pid[i], SIGINT) < 0) {
@@ -341,6 +361,20 @@
}
/*
+ * setup_sigint()
+ * sets up a SIGINT handler
+ */
+void
+setup_sigint(void)
+{
+ if ((sig_t)signal(SIGINT, inthandlr) == SIG_ERR) {
+ tst_brkm(TFAIL, cleanup, "signal SIGINT failed, errno = %d",
+ errno);
+ /*NOTREACHED*/
+ }
+}
+
+/*
* setup()
* performs all ONE TIME setup for this test
*/
@@ -395,3 +429,16 @@
kill(getpid(), SIGSTOP);
exit(3);
}
+
+#ifdef UCLINUX
+/*
+ * do_exit_uclinux()
+ * Sets up SIGINT handler again, then calls do_exit
+ */
+void
+do_exit_uclinux()
+{
+ setup_sigint();
+ do_exit();
+}
+#endif
diff --git a/testcases/kernel/syscalls/write/Makefile b/testcases/kernel/syscalls/write/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/write/Makefile
+++ b/testcases/kernel/syscalls/write/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/write/write03.c b/testcases/kernel/syscalls/write/write03.c
index 6e9a754..e0e562e 100644
--- a/testcases/kernel/syscalls/write/write03.c
+++ b/testcases/kernel/syscalls/write/write03.c
@@ -170,7 +170,8 @@
sprintf(filename, "./write03.%d", getpid());
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
printf("mmap failed\n");
}
diff --git a/testcases/kernel/syscalls/write/write05.c b/testcases/kernel/syscalls/write/write05.c
index 83cd00e..2ab49ee 100644
--- a/testcases/kernel/syscalls/write/write05.c
+++ b/testcases/kernel/syscalls/write/write05.c
@@ -140,7 +140,7 @@
//block3:
tst_resm(TINFO, "Enter Block 3: test with invalid pipe");
- if ((pid = fork()) == 0) { /* child */
+ if ((pid = FORK_OR_VFORK()) == 0) { /* child */
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
tst_resm(TINFO, "signal failed");
}
@@ -211,7 +211,8 @@
sprintf(filename, "write05.%d", getpid());
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
printf("mmap failed\n");
}
diff --git a/testcases/kernel/syscalls/writev/Makefile b/testcases/kernel/syscalls/writev/Makefile
index ee50aa5..621e249 100644
--- a/testcases/kernel/syscalls/writev/Makefile
+++ b/testcases/kernel/syscalls/writev/Makefile
@@ -20,7 +20,9 @@
# name of file : Makefile #
###########################################################################
CFLAGS+= -I../../../../include -Wall
+CFLAGS+= $(if $(UCLINUX),-DUCLINUX)
LOADLIBES+= -L../../../../lib -lltp
+LOADLIBES+= $(if $(UCLINUX),-lc)
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
diff --git a/testcases/kernel/syscalls/writev/writev01.c b/testcases/kernel/syscalls/writev/writev01.c
index b89884a..b4f3328 100644
--- a/testcases/kernel/syscalls/writev/writev01.c
+++ b/testcases/kernel/syscalls/writev/writev01.c
@@ -480,7 +480,8 @@
strcpy(name, DATA_FILE);
sprintf(f_name, "%s.%d", name, getpid());
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
printf("mmap failed\n");
}
diff --git a/testcases/kernel/syscalls/writev/writev02.c b/testcases/kernel/syscalls/writev/writev02.c
index dfd5b58..496843d 100644
--- a/testcases/kernel/syscalls/writev/writev02.c
+++ b/testcases/kernel/syscalls/writev/writev02.c
@@ -247,7 +247,8 @@
strcpy(name, DATA_FILE);
sprintf(f_name, "%s.%d", name, getpid());
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
printf("mmap failed\n");
}
diff --git a/testcases/kernel/syscalls/writev/writev05.c b/testcases/kernel/syscalls/writev/writev05.c
index 48ddf92..f9725d9 100644
--- a/testcases/kernel/syscalls/writev/writev05.c
+++ b/testcases/kernel/syscalls/writev/writev05.c
@@ -232,7 +232,8 @@
strcpy(name, DATA_FILE);
sprintf(f_name, "%s.%d", name, getpid());
- bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ bad_addr = mmap(0, 1, PROT_NONE,
+ MAP_PRIVATE_EXCEPT_UCLINUX|MAP_ANONYMOUS, 0, 0);
if (bad_addr <= 0) {
printf("mmap failed\n");
}