xref: /titanic_51/usr/src/contrib/ast/src/cmd/ksh93/ksh-regress.rt (revision b4dd7d09880f14016feece03929a224eca1cf39a)
1*b4dd7d09SAndy FiddamanNOTE regression tests for --regress enabled ksh
2*b4dd7d09SAndy Fiddaman
3*b4dd7d09SAndy FiddamanUNIT ksh-regress
4*b4dd7d09SAndy Fiddaman
5*b4dd7d09SAndy FiddamanEXPORT HOME=. ENV=.env.sh LC_ALL=C HISTFILE=
6*b4dd7d09SAndy Fiddaman
7*b4dd7d09SAndy FiddamanTEST mode suid/sgid combinations
8*b4dd7d09SAndy Fiddaman
9*b4dd7d09SAndy Fiddaman# these tests are the product { all modes combinations } X { tests }
10*b4dd7d09SAndy Fiddaman
11*b4dd7d09SAndy Fiddamandefaults=(
12*b4dd7d09SAndy Fiddaman	"etc=$HOME"
13*b4dd7d09SAndy Fiddaman	"source"
14*b4dd7d09SAndy Fiddaman)
15*b4dd7d09SAndy Fiddamanmodes=(
16*b4dd7d09SAndy Fiddaman	interactive
17*b4dd7d09SAndy Fiddaman	login
18*b4dd7d09SAndy Fiddaman	privileged
19*b4dd7d09SAndy Fiddaman	rc
20*b4dd7d09SAndy Fiddaman	restricted
21*b4dd7d09SAndy Fiddaman)
22*b4dd7d09SAndy Fiddamantests=(
23*b4dd7d09SAndy Fiddaman	""
24*b4dd7d09SAndy Fiddaman	"euid=0"
25*b4dd7d09SAndy Fiddaman	"euid=0 p_suid=0"
26*b4dd7d09SAndy Fiddaman	"euid=0 p_suid=99999"
27*b4dd7d09SAndy Fiddaman	"euid=1"
28*b4dd7d09SAndy Fiddaman	"euid=1 p_suid=0"
29*b4dd7d09SAndy Fiddaman	"euid=1 p_suid=99999"
30*b4dd7d09SAndy Fiddaman	"egid=1"
31*b4dd7d09SAndy Fiddaman	"egid=1 p_suid=0"
32*b4dd7d09SAndy Fiddaman	"egid=1 p_suid=99999"
33*b4dd7d09SAndy Fiddaman)
34*b4dd7d09SAndy Fiddaman
35*b4dd7d09SAndy Fiddamaninteger n=1 m=${#modes[@]}
36*b4dd7d09SAndy Fiddamand=
37*b4dd7d09SAndy Fiddamanfor o in ${defaults[@]}
38*b4dd7d09SAndy Fiddamando	d="$d --regress=$o"
39*b4dd7d09SAndy Fiddamandone
40*b4dd7d09SAndy Fiddamanfor ((b=0; b<m; b++))
41*b4dd7d09SAndy Fiddamando	(( n *= 3 ))
42*b4dd7d09SAndy Fiddamandone
43*b4dd7d09SAndy Fiddamanfor (( b=0; b<n; b++ ))
44*b4dd7d09SAndy Fiddamando	k=
45*b4dd7d09SAndy Fiddaman	z=$(printf "%0$m..3u" $b)
46*b4dd7d09SAndy Fiddaman	for (( i=0; i<m; i++ ))
47*b4dd7d09SAndy Fiddaman	do	case $z in
48*b4dd7d09SAndy Fiddaman		1*)	k="$k --no${modes[i]}" ;;
49*b4dd7d09SAndy Fiddaman		2*)	k="$k --${modes[i]}" ;;
50*b4dd7d09SAndy Fiddaman		esac
51*b4dd7d09SAndy Fiddaman		z=${z#?}
52*b4dd7d09SAndy Fiddaman	done
53*b4dd7d09SAndy Fiddaman	for t in "${tests[@]}"
54*b4dd7d09SAndy Fiddaman	do	o=$d
55*b4dd7d09SAndy Fiddaman		for r in $t
56*b4dd7d09SAndy Fiddaman		do	o="$o --regress=$r"
57*b4dd7d09SAndy Fiddaman		done
58*b4dd7d09SAndy Fiddaman		o="$o $k"
59*b4dd7d09SAndy Fiddaman
60*b4dd7d09SAndy FiddamanEXEC $o <<!
61*b4dd7d09SAndy Fiddamanset --state
62*b4dd7d09SAndy Fiddaman!
63*b4dd7d09SAndy Fiddaman
64*b4dd7d09SAndy Fiddaman	done
65*b4dd7d09SAndy Fiddamandone
66*b4dd7d09SAndy Fiddaman
67*b4dd7d09SAndy FiddamanTEST privileged/noprivileged sequence
68*b4dd7d09SAndy Fiddaman
69*b4dd7d09SAndy FiddamanEXEC --regress=etc=. --regress=euid=1 --privileged <<!
70*b4dd7d09SAndy Fiddamanset --state; set --noprivileged; set --state; set --privileged; set --state; set --noprivileged; set --state
71*b4dd7d09SAndy Fiddaman!
72