A2osX/TESTS/ARGTEST2

236 lines
4.6 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
PREFIX
AUTO 4,1
#!/BIN/SH
#
# This is a test of passing args
# This script is called by ARGTEST passing a known set
# of arguments which this script checks to verify
# arg passing works.
#
# The args passed are:
#
# A 1 B 2 C 3 Hello $$ 82 Tenth
#
# Note that $$ is passed which is this process id
# of the calling script that can be compared with this
# scripts parent process id; validating both are working.
#
# We first need to check if this script is being called
# by BUILDTEST or if it is being run interactively.
#
IF [ -F ${ROOT}TMP/BUILDTEST ]
ELSE
SET B = 0
FI
#
# $0 should be name of script
#
SET T = $T + 1
IF [ $0 = "ARGTEST2" ]
IF [ $B -GT 0 ]
SET P = $P + 1
echo "ARGTEST Arg 0 Passed" >> ${Log}
FI
echo "\nARGTEST Arg 0 Passed\n"
ELSE
IF [ $B -GT 0 ]
SET F = $F + 1
echo "ARGTEST Arg 0 Failed - $0" >> ${Log}
FI
echo "\nARGTEST Arg 0 Failed\n"
FI
#
# $1 should be 'A'
#
SET T = $T + 1
IF [ $1 = "A" ]
IF [ $B -GT 0 ]
SET P = $P + 1
echo "ARGTEST Arg 1 Passed" >> ${Log}
FI
echo "\nARGTEST Arg 1 Passed\n"
ELSE
IF [ $B -GT 0 ]
SET F = $F + 1
echo "ARGTEST Arg 1 Failed - $1" >> ${Log}
FI
echo "\nARGTEST Arg 1 Failed\n"
FI
#
# $2 should be '1'
#
SET T = $T + 1
IF [ $2 -EQ 1 ]
IF [ $B -GT 0 ]
SET P = $P + 1
echo "ARGTEST Arg 2 Passed" >> ${Log}
FI
echo "\nARGTEST Arg 2 Passed\n"
ELSE
IF [ $B -GT 0 ]
SET F = $F + 1
echo "ARGTEST Arg 2 Failed - $2" >> ${Log}
FI
echo "\nARGTEST Arg 2 Failed\n"
FI
#
# $3 should be 'B'
#
SET T = $T + 1
IF [ $3 = "B" ]
IF [ $B -GT 0 ]
SET P = $P + 1
echo "ARGTEST Arg 3 Passed" >> ${Log}
FI
echo "\nARGTEST Arg 3 Passed\n"
ELSE
IF [ $B -GT 0 ]
SET F = $F + 1
echo "ARGTEST Arg 3 Failed - $3" >> ${Log}
FI
echo "\nARGTEST Arg 3 Failed\n"
FI
#
# $4 should be '2'
#
SET T = $T + 1
IF [ $4 -EQ 2 ]
IF [ $B -GT 0 ]
SET P = $P + 1
echo "ARGTEST Arg 4 Passed" >> ${Log}
FI
echo "\nARGTEST Arg 4 Passed\n"
ELSE
IF [ $B -GT 0 ]
SET F = $F + 1
echo "ARGTEST Arg 4 Failed - $4" >> ${Log}
FI
echo "\nARGTEST Arg 4 Failed\n"
FI
#
# $5 should be 'C'
#
SET T = $T + 1
IF [ $5 = "C" ]
IF [ $B -GT 0 ]
SET P = $P + 1
echo "ARGTEST Arg 5 Passed" >> ${Log}
FI
echo "\nARGTEST Arg 5 Passed\n"
ELSE
IF [ $B -GT 0 ]
SET F = $F + 1
echo "ARGTEST Arg 5 Failed - $5" >> ${Log}
FI
echo "\nARGTEST Arg 5 Failed\n"
FI
#
# $6 should be '3'
#
SET T = $T + 1
IF [ $6 -EQ 3 ]
IF [ $B -GT 0 ]
SET P = $P + 1
echo "ARGTEST Arg 6 Passed" >> ${Log}
FI
echo "\nARGTEST Arg 6 Passed\n"
ELSE
IF [ $B -GT 0 ]
SET F = $F + 1
echo "ARGTEST Arg 6 Failed - $6" >> ${Log}
FI
echo "\nARGTEST Arg 6 Failed\n"
FI
#
# $7 should be 'Hello'
#
SET T = $T + 1
IF [ $7 = "Hello" ]
IF [ $B -GT 0 ]
SET P = $P + 1
echo "ARGTEST Arg 7 Passed" >> ${Log}
FI
echo "\nARGTEST Arg 7 Passed\n"
ELSE
IF [ $B -GT 0 ]
SET F = $F + 1
echo "ARGTEST Arg 7 Failed - $7" >> ${Log}
FI
echo "\nARGTEST Arg 7 Failed\n"
FI
#
# $8 should be the process id of the parent
#
SET T = $T + 1
IF [ $8 -EQ $@ ]
IF [ $B -GT 0 ]
SET P = $P + 1
echo "ARGTEST Arg 8 Passed" >> ${Log}
FI
echo "\nARGTEST Arg 8 Passed\n"
ELSE
IF [ $B -GT 0 ]
SET F = $F + 1
echo "ARGTEST Arg 8 Failed - $8 vs $@" >> ${Log}
FI
echo "\nARGTEST Arg 8 Failed\n"
FI
#
# $9 should be '82'
#
SET T = $T + 1
IF [ $2 -EQ 82 ]
IF [ $B -GT 0 ]
SET P = $P + 1
echo "ARGTEST Arg 9 Passed" >> ${Log}
FI
echo "\nARGTEST Arg 9 Passed\n"
ELSE
IF [ $B -GT 0 ]
SET F = $F + 1
echo "ARGTEST Arg 9 Failed - $9" >> ${Log}
FI
echo "\nARGTEST Arg 9 Failed\n"
FI
#
# $# should be '10'
#
SET T = $T + 1
IF [ $# -EQ 10 ]
IF [ $B -GT 0 ]
SET P = $P + 1
echo "ARGTEST Arg Count Passed" >> ${Log}
FI
echo "\nARGTEST Arg Count Passed\n"
ELSE
IF [ $B -GT 0 ]
SET F = $F + 1
echo "ARGTEST Arg Count Failed - $#" >> ${Log}
FI
echo "\nARGTEST Arg Count Failed\n"
FI
#
# $* should be 'A 1 B 2 C 3 Hello $$ 82 Tenth'
#
SET T = $T + 1
IF [ $* = "A 1 B 2 C 3 Hello $$ 82 Tenth" ]
IF [ $B -GT 0 ]
SET P = $P + 1
echo "ARGTEST Arg ALL Passed" >> ${Log}
FI
echo "\nARGTEST Arg ALL Passed\n"
ELSE
IF [ $B -GT 0 ]
SET F = $F + 1
echo "ARGTEST Arg ALL Failed - $*" >> ${Log}
FI
echo "\nARGTEST Arg ALL Failed\n"
FI
ECHO "\nArg Tests Done
IF [ $B -GT 0 ]
echo "Arg Tests Complete" >> ${Log}
FI
MAN
TEXT /MAKE/USR/SHARE/TESTS/ARGTEST2