From: Garrett C. <yab...@us...> - 2009-11-09 07:01:36
|
Update of /cvsroot/ltp/ltp/testcases/kernel/controllers/freezer In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv972/testcases/kernel/controllers/freezer Modified Files: vfork.c vfork_freeze.sh Log Message: vfork.c: - Fix autoconf test result name for PTRACE_O_TRACEVFORK*. vfork_freeze.sh: - Implement proper TMPDIR logic. - Remove forced make in place of optional (if needed) make operation. Signed-off-by: Garrett Cooper <yan...@gm...> Index: vfork_freeze.sh =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/kernel/controllers/freezer/vfork_freeze.sh,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** vfork_freeze.sh 26 Feb 2009 07:19:31 -0000 1.1 --- vfork_freeze.sh 9 Nov 2009 07:01:22 -0000 1.2 *************** *** 1,3 **** ! #!/bin/bash # Copyright (c) International Business Machines Corp., 2008 --- 1,3 ---- ! #!/bin/sh # Copyright (c) International Business Machines Corp., 2008 *************** *** 26,33 **** # we need the vfork test binary -- ensure it's been built ! make vfork || { ! echo "ERROR: Failed to build vfork test binary." 1>&2 ! exit -1 ! } . "${CGROUPS_TESTROOT}/libcgroup_freezer" --- 26,48 ---- # we need the vfork test binary -- ensure it's been built ! CGROUPS_TESTROOT=${CGROUPS_TESTROOT:=$(dirname "$0")} ! ! if [ ! -x "$CGROUPS_TESTROOT/vfork" ] ; then ! ! print_make_message=1 ! ! # Maintain ease-of-use backwards compatibility so Matt doesn't want to ! # hang me for the script change :]. ! if type make > /dev/null ; then ! make all && print_make_message=0 ! fi ! ! if [ $print_make_message -eq 1 ] ; then ! cat <<EOF ! ${0##*/}: ERROR: you must run \`make all' in $CGROUPS_TESTROOT before running ! this script. ! EOF ! exit 1 ! fi . "${CGROUPS_TESTROOT}/libcgroup_freezer" *************** *** 38,41 **** --- 53,58 ---- export TCID TST_COUNT TST_TOTAL + TMPDIR=${TMPDIR:=/tmp} + # We replace the normal sample process with a process which uses vfork to # create new processes. The vfork'ed processes then sleep, causing the *************** *** 44,49 **** function vfork_sleep() { ! # TODO use a proper temp file ! ./vfork -s$sample_sleep 1 > /tmp/tmp.txt & local rc=$? export vfork_proc=$! --- 61,65 ---- function vfork_sleep() { ! vfork -s$sample_sleep 1 > "$TMPDIR/${0##*/}.$$.txt" & local rc=$? export vfork_proc=$! *************** *** 63,67 **** vfork_sleep && { ! while /bin/true ; do trap 'break' ERR --- 79,83 ---- vfork_sleep && { ! while [ 1 ] ; do trap 'break' ERR *************** *** 95,99 **** umount_freezer ; } ! rm -f tmp.txt # Failsafe cleanup --- 111,115 ---- umount_freezer ; } ! rm -f "$TMPDIR/${0##*/}.$$.txt" # Failsafe cleanup Index: vfork.c =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/kernel/controllers/freezer/vfork.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** vfork.c 9 Nov 2009 06:20:45 -0000 1.4 --- vfork.c 9 Nov 2009 07:01:22 -0000 1.5 *************** *** 40,45 **** #include <sys/wait.h> #include <sys/socket.h> #include "config.h" - #include "../../syscalls/ptrace/ptrace.h" --- 40,45 ---- #include <sys/wait.h> #include <sys/socket.h> + #include "test.h" #include "config.h" #include "../../syscalls/ptrace/ptrace.h" *************** *** 50,53 **** --- 50,56 ---- perror("ERROR at " __FILE__ ":" str_expand(__LINE__) ": " s ) + int TST_TOTAL = 1; + char* TCID = "vfork"; + /* for signal handlers */ void do_nothing(int sig) *************** *** 173,177 **** return 0; ! /*printf("pausing for vfork() child: %d\n", gchild);*/ printf("\t%d\n", gchild); if (do_pause) --- 176,180 ---- return 0; ! fprintf(stderr, "Grandchild spawn's pid=%d", gchild); printf("\t%d\n", gchild); if (do_pause) *************** *** 261,267 **** { ! #if HAVE_DECL_PTRACE_SETOPTIONS && HAVE_DECL_PTRACE_O_VTRACEFORK pid_t child; ! int psync[2]; parse_opts(argc, argv); --- 264,270 ---- { ! #if defined(HAVE_DECL_PTRACE_SETOPTIONS) && defined(HAVE_DECL_PTRACE_O_TRACEVFORK) pid_t child; ! int exit_status, psync[2]; parse_opts(argc, argv); *************** *** 274,282 **** child = fork(); if (child == -1) { ! debug("fork(): "); ! exit(EXIT_FAILURE); ! } ! ! if (child == 0) { close(psync[1]); --- 277,282 ---- child = fork(); if (child == -1) { ! tst_resm(TBROK | TERRNO, "fork() failed"); ! } else if (child == 0) { close(psync[1]); *************** *** 307,316 **** close(psync[1]); ! printf("%d\n", child); ! exit(do_trace(child, ++num_vforks)); } #else ! printf("System doesn't support have required ptrace capabilities\n."); ! return 1; #endif } --- 307,324 ---- close(psync[1]); ! fprintf(stderr, "Child spawn's pid=%d", child); ! printf("\t%d\n", gchild); ! ! exit_status = do_trace(child, ++num_vforks); ! ! tst_resm(exit_status == 0 ? TPASS : TFAIL, "do_trace exit status %s", ! (exit_status == 0 ? "succeeded" : "failed")); ! } #else ! tst_resm(TCONF, "System doesn't support have required ptrace " ! "capabilities.\n"); #endif + tst_exit(); + } |