Use nsexec from user-cr
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.
Signed-off-by Serge E. Hallyn <serue-r/[email protected]>
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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