From: Robert W. <ro...@us...> - 2005-07-11 22:29:54
|
Update of /cvsroot/ltp/ltp/testcases/kernel/syscalls/ipc/shmctl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23055/testcases/kernel/syscalls/ipc/shmctl Modified Files: Makefile shmctl01.c shmctl03.c Log Message: Applied fixes by Paul J.Y. Lahaie to implement support for UCLinux Index: shmctl03.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/ipc/shmctl/shmctl03.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** shmctl03.c 18 Nov 2002 19:55:02 -0000 1.3 --- shmctl03.c 11 Jul 2005 22:28:29 -0000 1.4 *************** *** 104,108 **** setup(); /* global setup */ ! if ((pid = fork()) == -1) { tst_brkm(TBROK, cleanup, "could not fork"); } --- 104,108 ---- setup(); /* global setup */ ! if ((pid = FORK_OR_VFORK()) == -1) { tst_brkm(TBROK, cleanup, "could not fork"); } Index: shmctl01.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** shmctl01.c 15 Jun 2004 14:35:05 -0000 1.7 --- shmctl01.c 11 Jul 2005 22:28:29 -0000 1.8 *************** *** 63,67 **** --- 63,71 ---- char *TCID = "shmctl01"; + #ifndef UCLINUX int TST_TOTAL = 4; + #else + int TST_TOTAL = 3; + #endif extern int Tst_count; *************** *** 97,100 **** --- 101,107 ---- void func_rmid(void); + /* Child function */ + void do_child(void); + struct test_case_t { int cmd; /* the command to test */ *************** *** 105,109 **** --- 112,120 ---- {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}, *************** *** 114,117 **** --- 125,134 ---- #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) { *************** *** 126,129 **** --- 143,151 ---- } + #ifdef UCLINUX + argv0 = av[0]; + maybe_run_child(do_child, "ddd", &stat_i, &stat_time, &shm_id_1); + #endif + setup(); /* global setup */ *************** *** 228,233 **** stat_setup() { ! int i, rval; ! void *test, *set_shmat(); pid_t pid; --- 250,254 ---- stat_setup() { ! void *set_shmat(); pid_t pid; *************** *** 246,250 **** } ! for (i=0; i<N_ATTACH; i++) { if ((pid = fork()) == -1) { tst_brkm(TBROK, cleanup, "could not fork"); --- 267,271 ---- } ! for (stat_i=0; stat_i<N_ATTACH; stat_i++) { if ((pid = fork()) == -1) { tst_brkm(TBROK, cleanup, "could not fork"); *************** *** 252,277 **** if (pid == 0) { /* child */ ! ! if (stat_time == FIRST) { ! test = set_shmat(); ! } else { ! test = set_shared; ! } ! ! /* 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 { /* parent */ /* save the child's pid for cleanup later */ ! pid_arr[i] = pid; } } --- 273,288 ---- if (pid == 0) { /* child */ ! #ifdef UCLINUX ! if (self_exec(argv0, "ddd", stat_i, stat_time, ! shm_id_1) < 0) { ! tst_brkm(TBROK, cleanup, "could not self_exec"); } ! #else ! do_child(); ! #endif } else { /* parent */ /* save the child's pid for cleanup later */ ! pid_arr[stat_i] = pid; } } *************** *** 281,284 **** --- 292,323 ---- /* + * 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, Index: Makefile =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/kernel/syscalls/ipc/shmctl/Makefile,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Makefile 26 Mar 2003 21:20:55 -0000 1.7 --- Makefile 11 Jul 2005 22:28:29 -0000 1.8 *************** *** 25,29 **** --- 25,31 ---- 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) |