A2osX/TESTS/ARGTEST2.txt
2019-03-06 21:13:28 -05:00

233 lines
4.5 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.
#
# $0 should be name of script
#
IF [ -Z $T ]
SET T = 0
FI
SET T = $T + 1
IF [ $0 = "${PWD}ARGTEST2" ]
IF [ -N $Log ]
SET P = $P + 1
echo "ARGTEST Arg 0 Passed" >> ${Log}
FI
echo "ARGTEST Arg 0 Passed"
ELSE
IF [ -N $Log ]
SET F = $F + 1
echo "ARGTEST Arg 0 Failed - $0" >> ${Log}
FI
echo "ARGTEST Arg 0 Failed - $0"
FI
#
# $1 should be 'A'
#
SET T = $T + 1
IF [ $1 = "A" ]
IF [ -N $Log ]
SET P = $P + 1
echo "ARGTEST Arg 1 Passed" >> ${Log}
FI
echo "ARGTEST Arg 1 Passed"
ELSE
IF [ -N $Log ]
SET F = $F + 1
echo "ARGTEST Arg 1 Failed - $1" >> ${Log}
FI
echo "ARGTEST Arg 1 Failed"
FI
#
# $2 should be '1'
#
SET T = $T + 1
IF [ $2 -EQ 1 ]
IF [ -N $Log ]
SET P = $P + 1
echo "ARGTEST Arg 2 Passed" >> ${Log}
FI
echo "ARGTEST Arg 2 Passed"
ELSE
IF [ -N $Log ]
SET F = $F + 1
echo "ARGTEST Arg 2 Failed - $2" >> ${Log}
FI
echo "ARGTEST Arg 2 Failed"
FI
#
# $3 should be 'B'
#
SET T = $T + 1
IF [ $3 = "B" ]
IF [ -N $Log ]
SET P = $P + 1
echo "ARGTEST Arg 3 Passed" >> ${Log}
FI
echo "ARGTEST Arg 3 Passed"
ELSE
IF [ -N $Log ]
SET F = $F + 1
echo "ARGTEST Arg 3 Failed - $3" >> ${Log}
FI
echo "ARGTEST Arg 3 Failed"
FI
#
# $4 should be '2'
#
SET T = $T + 1
IF [ $4 -EQ 2 ]
IF [ -N $Log ]
SET P = $P + 1
echo "ARGTEST Arg 4 Passed" >> ${Log}
FI
echo "ARGTEST Arg 4 Passed"
ELSE
IF [ -N $Log ]
SET F = $F + 1
echo "ARGTEST Arg 4 Failed - $4" >> ${Log}
FI
echo "ARGTEST Arg 4 Failed"
FI
#
# $5 should be 'C'
#
SET T = $T + 1
IF [ $5 = "C" ]
IF [ -N $Log ]
SET P = $P + 1
echo "ARGTEST Arg 5 Passed" >> ${Log}
FI
echo "ARGTEST Arg 5 Passed"
ELSE
IF [ -N $Log ]
SET F = $F + 1
echo "ARGTEST Arg 5 Failed - $5" >> ${Log}
FI
echo "ARGTEST Arg 5 Failed"
FI
#
# $6 should be '3'
#
SET T = $T + 1
IF [ $6 -EQ 3 ]
IF [ -N $Log ]
SET P = $P + 1
echo "ARGTEST Arg 6 Passed" >> ${Log}
FI
echo "ARGTEST Arg 6 Passed"
ELSE
IF [ -N $Log ]
SET F = $F + 1
echo "ARGTEST Arg 6 Failed - $6" >> ${Log}
FI
echo "ARGTEST Arg 6 Failed"
FI
#
# $7 should be 'Hello'
#
SET T = $T + 1
IF [ $7 = "Hello" ]
IF [ -N $Log ]
SET P = $P + 1
echo "ARGTEST Arg 7 Passed" >> ${Log}
FI
echo "ARGTEST Arg 7 Passed"
ELSE
IF [ -N $Log ]
SET F = $F + 1
echo "ARGTEST Arg 7 Failed - $7" >> ${Log}
FI
echo "ARGTEST Arg 7 Failed"
FI
#
# $8 should be the process id of the parent
#
SET T = $T + 1
IF [ $8 -EQ $@ ]
IF [ -N $Log ]
SET P = $P + 1
echo "ARGTEST Arg 8 Passed" >> ${Log}
FI
echo "ARGTEST Arg 8 Passed"
ELSE
IF [ -N $Log ]
SET F = $F + 1
echo "ARGTEST Arg 8 Failed - $8 vs $@" >> ${Log}
FI
echo "ARGTEST Arg 8 Failed"
FI
#
# $9 should be '82'
#
SET T = $T + 1
IF [ $9 -EQ 82 ]
IF [ -N $Log ]
SET P = $P + 1
echo "ARGTEST Arg 9 Passed" >> ${Log}
FI
echo "ARGTEST Arg 9 Passed"
ELSE
IF [ -N $Log ]
SET F = $F + 1
echo "ARGTEST Arg 9 Failed - $9" >> ${Log}
FI
echo "ARGTEST Arg 9 Failed"
FI
#
# $# should be '10'
#
SET T = $T + 1
IF [ $# -EQ 10 ]
IF [ -N $Log ]
SET P = $P + 1
echo "ARGTEST Arg Count Passed" >> ${Log}
FI
echo "ARGTEST Arg Count Passed"
ELSE
IF [ -N $Log ]
SET F = $F + 1
echo "ARGTEST Arg Count Failed - $#" >> ${Log}
FI
echo "ARGTEST Arg Count Failed"
FI
#
# $* should be 'A 1 B 2 C 3 Hello $@ 82 Tenth'
# Note $$ was actually passed after Hello, but
# we sub $@ as its our parents ID.
#
SET T = $T + 1
IF [ $* = "A 1 B 2 C 3 Hello $@ 82 Tenth" ]
IF [ -N $Log ]
SET P = $P + 1
echo "ARGTEST Arg ALL Passed" >> ${Log}
FI
echo "ARGTEST Arg ALL Passed"
ELSE
IF [ -N $Log ]
SET F = $F + 1
echo "ARGTEST Arg ALL Failed - $*" >> ${Log}
FI
echo "ARGTEST Arg ALL Failed"
FI
ECHO "Arg Tests Done"
IF [ -N $Log ]
echo "Arg Tests Complete" >> ${Log}
FI
MAN
TEXT /MAKE/USR/SHARE/TESTS/ARGTEST2