Skip to contentSkip to conversation

Use nsexec from user-cr

PATCH New Serge E. Hallyn 1 participant 1 message Feb 16, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use nsexec from user-cr

Have common.sh find nsexec (should be installed in /bin by user-cr) and call it $NSEXEC. Have all tests use $NSEXEC.

---
 Makefile                      |    2 +-
 bashckpt/bash-cr.sh           |    2 +-
 common.sh                     |    5 +
 counterloop/cloop_once.sh     |    2 +-
 counterloop/cloop_parallel.sh |    2 +-
 counterloop/cloop_serial.sh   |    2 +-
 fileio/run-fcntltests.sh      |    7 +-
 fileio/run-fileio1.sh         |    9 +-
 ipc/test-mq.sh                |    6 +-
 ipc/test-sem.sh               |    8 +-
 ipc/test-shm.sh               |    8 +-
 ns_exec.c                     |  318 -----------------------------------------
 process-tree/run-pthread1.sh  |    7 +-
 process-tree/run-pthread2.sh  |    7 +-
 process-tree/run-pthread3.sh  |    7 +-
 process-tree/run-ptree1.sh    |    7 +-
 simple/runtests.sh            |    3 +-
 17 files changed, 42 insertions(+), 360 deletions(-)
 delete mode 100644 ns_exec.c
Makefile +1 -1
index 0f3ff68..e8eb048 100644
@@ -25,7 +25,7 @@ all:
 
 include $(addsuffix /module.mk,$(modules))
 
-progs += ns_exec mysu
+progs += mysu
 
 .PHONY: all
 all: $(progs)
bashckpt/bash-cr.sh +1 -1
index 725466c..3b7ee4b 100755
@@ -30,7 +30,7 @@ echo results in $tmpdir ' EXIT
 echo "Running ./bash-simple.sh in background."
 ./bash-simple.sh $$ $tmpdir &
 
-# note: $! is the pid of ns_exec, not the command, so we need to be a
+# note: $! is the pid of nsexec, not the command, so we need to be a
 # little more clever to derive the pid to pass to ip link set netns
 
 echo -n "Waiting for background script to start... "
common.sh +5 -0
index 99a7968..28b87f1 100644
@@ -110,3 +110,8 @@ if [ $? -ne 0 ]; then
 	echo "BROK: restart not found in your path"
 	exit 1
 fi
+NSEXEC=`which nsexec`
+if [ $? -ne 0 ]; then
+	echo "BROK: nsexec not found in your path"
+	exit 1
+fi
counterloop/cloop_once.sh +1 -1
index 89c4d13..18e8b15 100644
@@ -21,7 +21,7 @@ my_debug()
 killall crcounter
 
 echo BAD > $dir/counter_out
-../ns_exec -m ./crcounter $dir &
+$NSEXEC -m ./crcounter $dir &
 while [ "`cat $dir/counter_out`" == "BAD" ]; do : ; done
 pid=`pidof crcounter`
 
counterloop/cloop_parallel.sh +1 -1
index 996fcaa..ce664b7 100644
@@ -83,7 +83,7 @@ while [ $kidsdone -eq 0 ]; do checkchildren counter_out; done
 echo "... all jobs started"
 canceltimer
 
-pids=`ps -ef | grep crcounter | grep -v grep | grep -v ns_exec | awk -F\  '{ print $2 '}`
+pids=`ps -ef | grep crcounter | grep -v grep | grep -v nsexec | awk -F\  '{ print $2 '}`
 
 cnt=1
 
counterloop/cloop_serial.sh +1 -1
index 8945395..cc94db4 100644
@@ -63,7 +63,7 @@ if [ $fail -ne 0 ]; then
 	echo "WARN there were $fail restart failures"
 fi
 
-numjobs=`ps -ef | grep crcounter | grep -v grep | grep -v ns_exec | wc -l`
+numjobs=`ps -ef | grep crcounter | grep -v grep | grep -v nsexec | wc -l`
 killall crcounter
 
 if [ $numjobs -ne 1 ]; then
fileio/run-fcntltests.sh +3 -4
index 2a5f628..aafc040 100755
@@ -41,8 +41,7 @@ CHECKPOINT_DONE="checkpoint-done"
 LOGS_DIR="logs.d"
 DATA_DIR="data.d"
 
-NS_EXEC="../../ns_exec"
-NS_EXEC_ARGS="-cgpuimP $TEST_PID_FILE"
+NSEXEC_ARGS="-cgpuimP $TEST_PID_FILE"
 
 checkpoint()
 {
@@ -95,7 +94,7 @@ function create_container()
 {
 	local pid;
 
-	cmdline="$NS_EXEC $NS_EXEC_ARGS -- $TEST_CMD $TEST_ARGS"
+	cmdline="$NSEXEC $NSEXEC_ARGS -- $TEST_CMD $TEST_ARGS"
 
 	$ECHO "\t- Creating container:"
 	$ECHO "\t- $cmdline"
@@ -224,7 +223,7 @@ while [ $cnt -lt 20 ]; do
 	ps -efL |grep $TEST_CMD >> $SCRIPT_LOG
 	$ECHO "\t- num_pids1 $num_pids1, num_pids2 $num_pids2";
 
-	# ns_exec pid is parent-pid of restarted-container-init
+	# nsexec pid is parent-pid of restarted-container-init
 	nspid=`pidof restart`
 
 	if [ "x$nspid" == "x" ]; then
fileio/run-fileio1.sh +4 -5
index c7179ab..36528e8 100755
@@ -23,7 +23,6 @@ TEST_LOG_SNAP="$dir/log.${test_case}.snap"
 
 LOG_FILE="$dir/f1-loop.log"
 TEST_CMD="./$test_case"
-NS_EXEC="../ns_exec"
 
 # Make sure no stray TEST_CMD from another run is still going
 killall $TEST_CMD
@@ -46,7 +45,7 @@ for testnum in `seq 1 $NUMTESTS`; do
 	# Remove CKPT_READY file, start the application and let app tell
 	# us when it is ready
 	rm -f $CKPT_READY;
-	$NS_EXEC -m $TEST_CMD -d $dir -c $SRC_FILE $DEST_FILE &
+	$NSEXEC -m $TEST_CMD -d $dir -c $SRC_FILE $DEST_FILE &
 	while [ ! -f $CKPT_READY ]; do
 		sleep 1;
 	done;
@@ -94,7 +93,7 @@ for testnum in `seq 1 $NUMTESTS`; do
 	rm -f $COPY_DONE;
 
 	# Restart.
-	$NS_EXEC -m rstrsh $CKPT_FILE &
+	$NSEXEC -m rstrsh $CKPT_FILE &
 	ret=$?
 
 	if [ $ret -ne 0 ]; then
@@ -112,9 +111,9 @@ for testnum in `seq 1 $NUMTESTS`; do
 		exit 1
 	fi
 
-	nspid=`pidof $NS_EXEC`
+	nspid=`pidof $NSEXEC`
 	if [ "x$nspid" == "x" ]; then
-		echo "Can't find pid of $NS_EXEC"
+		echo "Can't find pid of $NSEXEC"
 		exit 1
 	fi
 
ipc/test-mq.sh +3 -3
index 957ec91..fc5343e 100644
@@ -33,7 +33,7 @@ do_checkpoint() {
 
 echo "XXX Test 1: simple restart with SYSVIPC msq"
 clean_all
-../../ns_exec -ci ../check-mq &
+$NSEXEC -ci ../check-mq &
 do_checkpoint
 # Restart it.  If it finds the msq it created, it creates msq-ok
 $RESTART --pids < ckpt.msq
@@ -45,7 +45,7 @@ echo "PASS"
 
 echo "XXX Test 2: re-create root-owned msq as non-root user"
 clean_all
-../../ns_exec -ci ../check-mq -u 501 &
+$NSEXEC -ci ../check-mq -u 501 &
 do_checkpoint
 # restart should fail to create msq
 $RESTART --pids --copy-status < ckpt.msq
@@ -58,7 +58,7 @@ echo "PASS"
 # Create msq as non-root user
 echo "XXX Test 3: create msq as non-root user and restart"
 clean_all
-../../ns_exec -ci ../check-mq -e -u 501 &
+$NSEXEC -ci ../check-mq -e -u 501 &
 do_checkpoint
 # restart should be able to create msq
 $RESTART --pids --copy-status < ckpt.msq
ipc/test-sem.sh +4 -4
index 52c96a3..0144c8b 100644
@@ -33,7 +33,7 @@ do_checkpoint() {
 
 echo "XXX Test 1: simple restart with SYSVIPC semaphores"
 clean_all
-../../ns_exec -ci ../create-sem &
+$NSEXEC -ci ../create-sem &
 do_checkpoint
 # Restart it.  If it finds the sem it created, it creates sem-ok
 $RESTART --pids < ckpt.sem
@@ -45,7 +45,7 @@ echo "PASS"
 
 echo "XXX Test 2: re-create root-owned semaphores as non-root user"
 clean_all
-../../ns_exec -ci ../create-sem -u 501 &
+$NSEXEC -ci ../create-sem -u 501 &
 do_checkpoint
 # restart should fail to create sems
 $RESTART --pids < ckpt.sem
@@ -58,7 +58,7 @@ echo "PASS"
 # Create semaphores as non-root user
 echo "XXX Test 3: create semaphores as non-root user and restart"
 clean_all
-../../ns_exec -ci ../create-sem -e -u 501 &
+$NSEXEC -ci ../create-sem -e -u 501 &
 do_checkpoint
 # restart should be able to create sems
 $RESTART --pids  --copy-status < ckpt.sem
@@ -74,7 +74,7 @@ if [ $uid -eq -1 ]; then
 	echo "not running ltp-uid test"
 	exit 0
 fi
-../../ns_exec -ci ../create-sem -r -u $uid &
+$NSEXEC -ci ../create-sem -r -u $uid &
 do_checkpoint
 chown $uid ckpt.sem
 setcap cap_sys_admin+pe $RESTART
ipc/test-shm.sh +4 -4
index 4bd79df..06f1add 100644
@@ -33,7 +33,7 @@ do_checkpoint() {
 
 echo "XXX Test 1: simple restart with SYSVIPC shm"
 clean_all
-../../ns_exec -ci ../create-shm &
+$NSEXEC -ci ../create-shm &
 do_checkpoint
 # Restart it.  If it finds the shm it created, it creates shm-ok
 $RESTART --pids --copy-status < ckpt.shm
@@ -45,7 +45,7 @@ echo "PASS"
 
 echo "XXX Test 2: re-create root-owned shm as non-root user"
 clean_all
-../../ns_exec -ci ../create-shm -u 501 &
+$NSEXEC -ci ../create-shm -u 501 &
 do_checkpoint
 # restart should fail to create shm
 $RESTART --pids --copy-status < ckpt.shm
@@ -58,7 +58,7 @@ echo "PASS"
 # Create shm as non-root user
 echo "XXX Test 3: create shm as non-root user and restart"
 clean_all
-../../ns_exec -ci ../create-shm -e -u 501 &
+$NSEXEC -ci ../create-shm -e -u 501 &
 do_checkpoint
 # restart should be able to create shm
 $RESTART --pids --copy-status < ckpt.shm
@@ -74,7 +74,7 @@ if [ $uid -eq -1 ]; then
 	echo "not running ltp-uid test"
 	exit 0
 fi
-../../ns_exec -ci ../create-shm -r -u $uid &
+$NSEXEC -ci ../create-shm -r -u $uid &
 do_checkpoint
 chown $uid ckpt.shm
 setcap cap_sys_admin+pe $RESTART
ns_exec.c deleted +0 -318

318 lines not on this page · raw message

process-tree/run-pthread1.sh +3 -4
index e616753..64747e1 100755
@@ -28,8 +28,7 @@ CHECKPOINT_DONE="checkpoint-done"
 
 LOGS_DIR="logs.d"
 
-NS_EXEC="../../ns_exec"
-NS_EXEC_ARGS="-cgpuimP $TEST_PID_FILE"
+NSEXEC_ARGS="-cgpuimP $TEST_PID_FILE"
 
 checkpoint()
 {
@@ -49,7 +48,7 @@ function create_container()
 {
 	local pid;
 
-	cmdline="$NS_EXEC $NS_EXEC_ARGS -- $TEST_CMD $TEST_ARGS"
+	cmdline="$NSEXEC $NSEXEC_ARGS -- $TEST_CMD $TEST_ARGS"
 
 	$ECHO "\t- Creating container:"
 	$ECHO "\t- $cmdline"
@@ -193,7 +192,7 @@ while [ $cnt -lt 15 ]; do
 	ps -efL |grep $TEST_CMD >> $SCRIPT_LOG
 	$ECHO "\t- num_pids1 $num_pids1, num_pids2 $num_pids2";
 
-	# ns_exec pid is parent-pid of restarted-container-init
+	# nsexec pid is parent-pid of restarted-container-init
 	nspid=`pidof restart`
 
 	if [ "x$nspid" == "x" ]; then
process-tree/run-pthread2.sh +3 -4
index ff7f0ac..8fe6607 100755
@@ -29,8 +29,7 @@ CHECKPOINT_DONE="checkpoint-done"
 
 LOGS_DIR="logs.d"
 
-NS_EXEC="../../ns_exec"
-NS_EXEC_ARGS="-cgpuimP $TEST_PID_FILE"
+NSEXEC_ARGS="-cgpuimP $TEST_PID_FILE"
 
 checkpoint()
 {
@@ -59,7 +58,7 @@ function create_container()
 {
 	local pid;
 
-	cmdline="$NS_EXEC $NS_EXEC_ARGS -- $TEST_CMD $TEST_ARGS"
+	cmdline="$NSEXEC $NSEXEC_ARGS -- $TEST_CMD $TEST_ARGS"
 
 	$ECHO "\t- Creating container:"
 	$ECHO "\t- $cmdline"
@@ -184,7 +183,7 @@ while [ $cnt -lt 15 ]; do
 	ps -efL |grep $TEST_CMD >> $SCRIPT_LOG
 	$ECHO "\t- num_pids1 $num_pids1, num_pids2 $num_pids2";
 
-	# ns_exec pid is parent-pid of restarted-container-init
+	# nsexec pid is parent-pid of restarted-container-init
 	nspid=`pidof restart`
 
 	if [ "x$nspid" == "x" ]; then
process-tree/run-pthread3.sh +3 -4
index 0cffe44..af88aed 100755
@@ -29,8 +29,7 @@ CHECKPOINT_DONE="checkpoint-done"
 
 LOGS_DIR="logs.d"
 
-NS_EXEC="../../ns_exec"
-NS_EXEC_ARGS="-cgpuimP $TEST_PID_FILE"
+NSEXEC_ARGS="-cgpuimP $TEST_PID_FILE"
 
 checkpoint()
 {
@@ -59,7 +58,7 @@ function create_container()
 {
 	local pid;
 
-	cmdline="$NS_EXEC $NS_EXEC_ARGS -- $TEST_CMD $TEST_ARGS"
+	cmdline="$NSEXEC $NSEXEC_ARGS -- $TEST_CMD $TEST_ARGS"
 
 	$ECHO "\t- Creating container:"
 	$ECHO "\t- $cmdline"
@@ -184,7 +183,7 @@ while [ $cnt -lt 15 ]; do
 	ps -efL |grep $TEST_CMD >> $SCRIPT_LOG
 	$ECHO "\t- num_pids1 $num_pids1, num_pids2 $num_pids2";
 
-	# ns_exec pid is parent-pid of restarted-container-init
+	# nsexec pid is parent-pid of restarted-container-init
 	nspid=`pidof restart`
 
 	if [ "x$nspid" == "x" ]; then
process-tree/run-ptree1.sh +3 -4
index 2b1e8c5..65b9fba 100755
@@ -29,8 +29,7 @@ CHECKPOINT_READY="checkpoint-ready"
 CHECKPOINT_DONE="checkpoint-done"
 INPUT_DATA="input.data";
 
-NS_EXEC="$BASE_DIR/ns_exec"
-NS_EXEC_ARGS="-cgpuimP $TEST_PID_FILE"
+NSEXEC_ARGS="-cgpuimP $TEST_PID_FILE"
 
 
 checkpoint()
@@ -52,7 +51,7 @@ function create_container()
 {
 	local pid;
 
-	cmdline="$NS_EXEC $NS_EXEC_ARGS -- $TEST_CMD $TEST_ARGS"
+	cmdline="$NSEXEC $NSEXEC_ARGS -- $TEST_CMD $TEST_ARGS"
 
 	$ECHO "\t- Creating container:"
 	$ECHO "\t- $cmdline"
@@ -208,7 +207,7 @@ while [ $cnt -lt 15 ]; do
 	ps aux |grep $TEST_CMD >> $SCRIPT_LOG
 	$ECHO "\t- num_pids1 $num_pids1, num_pids2 $num_pids2";
 
-	# ns_exec pid is parent-pid of restarted-container-init
+	# nsexec pid is parent-pid of restarted-container-init
 	nspid=`pidof restart`
 
 	if [ "x$nspid" == "x" ]; then
simple/runtests.sh +2 -1
index d10c388..34ef9a8 100755
@@ -3,12 +3,13 @@
 # Author: Serge Hallyn
 
 RESTART=`which restart`
+NSEXEC=`which nsexec`
 
 dir=`mktemp -p . -d -t cr_simple_XXXXXXX` || (echo "mktemp failed"; exit 1)
 
 echo "Using output dir $dir"
 
-../ns_exec -cp ./ckpt  $dir
+$NSEXEC -cp ./ckpt  $dir
 if [ ! -f $dir/cr-test.out ]; then
 	echo "FAIL - ckpt did not create $dir/cr-test.out"
 	exit 1
Signature · 1 line
1.6.1.1