<commit_before>#!/bin/bash

ZP="zdtm/live"

TEST_LIST="
static/pipe00
static/pipe01
static/busyloop00
static/cwd00
static/env00
static/maps00
static/maps01
static/mprotect00
static/mtime_mmap
static/sleeping00
static/write_read00
static/write_read01
static/write_read02
static/wait00
static/vdso00
static/file_shared
static/timers
static/futex
static/xids00
streaming/pipe_loop00
streaming/pipe_shared00
transition/file_read
static/sockets00
static/sockets_spair
static/sockets_dgram
static/socket_queues
static/pid00
static/pstree
static/caps00
static/cmdlinenv00
static/socket_listen
static/socket_udp
static/socket6_udp
static/socket_udplite
static/selfexe00
static/unlink_fstat00
static/unlink_fstat02
static/eventfs00
static/inotify00
"
# Duplicate list with pidns/ prefix
TEST_LIST=$TEST_LIST$(echo $TEST_LIST | tr ' ' '\n' | sed 's#^#pidns/#')

# These ones are not in pidns
TEST_LIST="$TEST_LIST
static/zombie00
transition/fork
static/file_fown
"

MNT_TEST_LIST="
static/mountpoints
"

# These ones are in pidns
TEST_LIST="$TEST_LIST
pidns/static/session00
"

UTS_TEST_LIST="
static/utsname
"

IPC_TEST_LIST="
static/ipc_namespace
static/shm
static/msgque
static/sem
transition/ipc
"

CRTOOLS=`pwd`/`dirname $0`/../crtools
TINIT=`pwd`/`dirname $0`/zdtm/lib/test_init
test -x $CRTOOLS || exit 1

ARGS=""

PID=""
PIDNS=""

start_test()
{
	local tdir=$1
	local tname=$2

	killall -9 $tname &> /dev/null
	make -C $tdir cleanout

	if [ -z "$PIDNS" ]; then
		make -C $tdir $tname.pid
		PID=`cat $test.pid` || return 1
	else
		killall -9 test_init
		$TINIT  $tdir $tname || {
			echo ERROR: fail to start $tdir/$tname
			return 1;
		}

		PID=`ps h -C test_init -o pid`
		PID=$((PID))
	fi
}

stop_test()
{
	local tdir=$1
	local tname=$2

	if [ -z "$PIDNS" ]; then
		make -C $tdir $tname.out
	else
		killall test_init
	fi
}

save_fds()
{
	test -n "$PIDNS" && return 0
	ls -l /proc/$1/fd | sed 's/\(-> \(pipe\|socket\)\):.*/\1/' | awk '{ print $9,$10,$11; }' > $2
}

diff_fds()
{
	test -n "$PIDNS" && return 0
	if ! diff -up $1 $2; then
		echo ERROR: Sets of descriptors are differ:
		echo $1
		echo $2
		return 1
	fi
}

run_test()
{
	local test=$1

	expr "$test" : 'pidns/' && PIDNS=1 || PIDNS=""
	test=${ZP}/${test#pidns/}

	shift
	local args=$*
	local tname=`basename $test`
	local tdir=`dirname $test`
	DUMP_PATH=""

	echo "Execute $test"

	start_test $tdir $tname || return 1

	local ddump
	kill -s 0 "$PID" || {
		echo "Get a wrong pid '$PID'"
		return 1
	}

	ddump=dump/$tname/$PID
	DUMP_PATH=`pwd`/$ddump

	if [ -n "$PIDNS" ]; then
		args="--namespace pid $args"<commit_msg>zdtm: don't print useless numbers<commit_after>#!/bin/bash

ZP="zdtm/live"

TEST_LIST="
static/pipe00
static/pipe01
static/busyloop00
static/cwd00
static/env00
static/maps00
static/maps01
static/mprotect00
static/mtime_mmap
static/sleeping00
static/write_read00
static/write_read01
static/write_read02
static/wait00
static/vdso00
static/file_shared
static/timers
static/futex
static/xids00
streaming/pipe_loop00
streaming/pipe_shared00
transition/file_read
static/sockets00
static/sockets_spair
static/sockets_dgram
static/socket_queues
static/pid00
static/pstree
static/caps00
static/cmdlinenv00
static/socket_listen
static/socket_udp
static/socket6_udp
static/socket_udplite
static/selfexe00
static/unlink_fstat00
static/unlink_fstat02
static/eventfs00
static/inotify00
"
# Duplicate list with pidns/ prefix
TEST_LIST=$TEST_LIST$(echo $TEST_LIST | tr ' ' '\n' | sed 's#^#pidns/#')

# These ones are not in pidns
TEST_LIST="$TEST_LIST
static/zombie00
transition/fork
static/file_fown
"

MNT_TEST_LIST="
static/mountpoints
"

# These ones are in pidns
TEST_LIST="$TEST_LIST
pidns/static/session00
"

UTS_TEST_LIST="
static/utsname
"

IPC_TEST_LIST="
static/ipc_namespace
static/shm
static/msgque
static/sem
transition/ipc
"

CRTOOLS=`pwd`/`dirname $0`/../crtools
TINIT=`pwd`/`dirname $0`/zdtm/lib/test_init
test -x $CRTOOLS || exit 1

ARGS=""

PID=""
PIDNS=""

start_test()
{
	local tdir=$1
	local tname=$2

	killall -9 $tname &> /dev/null
	make -C $tdir cleanout

	if [ -z "$PIDNS" ]; then
		make -C $tdir $tname.pid
		PID=`cat $test.pid` || return 1
	else
		killall -9 test_init
		$TINIT  $tdir $tname || {
			echo ERROR: fail to start $tdir/$tname
			return 1;
		}

		PID=`ps h -C test_init -o pid`
		PID=$((PID))
	fi
}

stop_test()
{
	local tdir=$1
	local tname=$2

	if [ -z "$PIDNS" ]; then
		make -C $tdir $tname.out
	else
		killall test_init
	fi
}

save_fds()
{
	test -n "$PIDNS" && return 0
	ls -l /proc/$1/fd | sed 's/\(-> \(pipe\|socket\)\):.*/\1/' | awk '{ print $9,$10,$11; }' > $2
}

diff_fds()
{
	test -n "$PIDNS" && return 0
	if ! diff -up $1 $2; then
		echo ERROR: Sets of descriptors are differ:
		echo $1
		echo $2
		return 1
	fi
}

run_test()
{
	local test=$1

	expr "$test" : 'pidns/' > /dev/null && PIDNS=1 || PIDNS=""
	test=${ZP}/${test#pidns/}

	shift
	local args=$*
	local tname=`basename $test`
	local tdir=`dirname $test`
	DUMP_PATH=""

	echo "Execute $test"

	start_test $tdir $tname || return 1

	local ddump
	kill -s 0 "$PID" || {
		echo "Get a wrong pid '$PID'"
		return 1
	}

	ddump=dump/$tname/$PID
	DUMP_PATH=`pwd`/$ddump

	if [ -n "$PIDNS" ]; then
		args="--namespace pid $args"
{'fraction_non_alphanumeric': 0.14464560862865947, 'fraction_numerical': 0.03389830508474576, 'mean_word_length': 4.096172718351325, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3771881', 'n_tokens_mistral': 2353, 'n_tokens_neox': 2153, 'n_words': 502}