2019-02-21 21:19:56 +00:00
|
|
|
|
NEW
|
|
|
|
|
PREFIX
|
|
|
|
|
AUTO 4,1
|
|
|
|
|
#!/BIN/SH
|
|
|
|
|
#
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# This script tests the String comparison options of the
|
|
|
|
|
# IF directive in shell.
|
2019-02-21 21:19:56 +00:00
|
|
|
|
#
|
|
|
|
|
#!/BIN/SH
|
2019-03-10 05:20:43 +00:00
|
|
|
|
ECHO "\f\n\n IF String Tests"
|
|
|
|
|
ECHO "\n\nThis Performs Several String Comparison Tests"
|
|
|
|
|
ECHO
|
|
|
|
|
ECHO "Begin IF String Tests"
|
|
|
|
|
ECHO
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Begin IF String Tests" >> ${Log}
|
|
|
|
|
ELSE
|
|
|
|
|
SET T = 0
|
|
|
|
|
SET F = 0
|
|
|
|
|
SET P = 0
|
|
|
|
|
FI
|
|
|
|
|
# First test that 2 of the same constants equal each other.
|
|
|
|
|
SET T = $T + 1
|
2019-01-16 04:50:18 +00:00
|
|
|
|
IF [ "ABC" = "ABC" ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
Echo " Test 1 ABC = ABC : PASSED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 1 ABC = ABC : PASSED" >> ${Log}
|
|
|
|
|
SET P = $P + 1
|
|
|
|
|
FI
|
2019-01-16 04:50:18 +00:00
|
|
|
|
ELSE
|
2019-03-10 05:20:43 +00:00
|
|
|
|
Echo " Test 1 ABC = ABC : FAILED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 1 ABC = ABC : FAILED" >> ${Log}
|
|
|
|
|
SET F = $F + 1
|
|
|
|
|
FI
|
2019-01-16 04:50:18 +00:00
|
|
|
|
FI
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Second Test that 2 unique constants are not equal.
|
|
|
|
|
SET T = $T + 1
|
2019-01-16 04:50:18 +00:00
|
|
|
|
IF [ "ABC" != "DEF" ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
Echo " Test 2 ABC != DEF : PASSED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 2 ABC != DEF : PASSED" >> ${Log}
|
|
|
|
|
SET P = $P + 1
|
|
|
|
|
FI
|
2019-01-16 04:50:18 +00:00
|
|
|
|
ELSE
|
2019-03-10 05:20:43 +00:00
|
|
|
|
Echo " Test 2 ABC != DEF : FAILED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 2 ABC != DEF : FAILED" >> ${Log}
|
|
|
|
|
SET F = $F + 1
|
|
|
|
|
FI
|
2019-01-16 04:50:18 +00:00
|
|
|
|
FI
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Third test 2 similar but unequal constants are not equal.
|
|
|
|
|
SET T = $T + 1
|
2019-01-16 04:50:18 +00:00
|
|
|
|
IF [ "ABC" = "ABCD" ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
Echo " Test 3 ABC = ABCD : FAILED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 3 ABC = ABCD : FAILED" >> ${Log}
|
|
|
|
|
SET F = $F + 1
|
|
|
|
|
FI
|
2019-01-16 04:50:18 +00:00
|
|
|
|
ELSE
|
2019-03-10 05:20:43 +00:00
|
|
|
|
Echo " Test 3 ABC = ABCD : PASSED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 3 ABC = ABCD : PASSED" >> ${Log}
|
|
|
|
|
SET P = $P + 1
|
|
|
|
|
FI
|
2019-01-16 04:50:18 +00:00
|
|
|
|
FI
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Fourth test the same constants to be not equal to test for false.
|
|
|
|
|
SET T = $T + 1
|
2019-01-16 04:50:18 +00:00
|
|
|
|
IF [ "ABC" != "ABC" ]
|
2019-03-10 05:20:43 +00:00
|
|
|
|
Echo " Test 4 ABC != ABC : FAILED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 4 ABC != ABC : FAILED" >> ${Log}
|
|
|
|
|
SET F = $F + 1
|
|
|
|
|
FI
|
2019-01-16 04:50:18 +00:00
|
|
|
|
ELSE
|
2019-03-10 05:20:43 +00:00
|
|
|
|
Echo " Test 4 ABC != ABC : PASSED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 4 ABC != ABC : PASSED" >> ${Log}
|
|
|
|
|
SET P = $P + 1
|
|
|
|
|
FI
|
2019-01-16 04:50:18 +00:00
|
|
|
|
FI
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Fifth test compare VAR to constant to be equal.
|
|
|
|
|
SET ABC = "ABC"
|
|
|
|
|
SET T = $T + 1
|
|
|
|
|
IF [ $ABC = "ABC" ]
|
|
|
|
|
Echo " Test 5 VAR = ABC : PASSED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 5 VAR = ABC : PASSED" >> ${Log}
|
|
|
|
|
SET P = $P + 1
|
|
|
|
|
FI
|
2019-03-01 01:42:33 +00:00
|
|
|
|
ELSE
|
2019-03-10 05:20:43 +00:00
|
|
|
|
Echo " Test 5 VAR = ABC : FAILED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 5 VAR = ABC : FAILED" >> ${Log}
|
|
|
|
|
SET F = $F + 1
|
|
|
|
|
FI
|
2019-03-01 01:42:33 +00:00
|
|
|
|
FI
|
2019-03-10 05:20:43 +00:00
|
|
|
|
# Sixth test compare complex VAR to constant to be equal.
|
|
|
|
|
SET ABC = "ABC"
|
|
|
|
|
SET DEF = "${ABC}123${ABC}456${ABC}"
|
|
|
|
|
SET T = $T + 1
|
|
|
|
|
IF [ $DEF = "ABC123ABC456ABC" ]
|
|
|
|
|
Echo " Test 6 Complex VAR = ABC123ABC456ABC : PASSED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 6 Complex VAR = ABC123ABC456ABC : PASSED" >> ${Log}
|
|
|
|
|
SET P = $P + 1
|
|
|
|
|
FI
|
2019-03-01 18:19:14 +00:00
|
|
|
|
ELSE
|
2019-03-10 05:20:43 +00:00
|
|
|
|
Echo " Test 6 Complex VAR = ABC123ABC456ABC : FAILED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 6 Complex VAR = ABC123ABC456ABC : FAILED" >> ${Log}
|
|
|
|
|
SET F = $F + 1
|
|
|
|
|
FI
|
|
|
|
|
FI
|
2019-03-12 04:05:03 +00:00
|
|
|
|
|
|
|
|
|
# Seventh test new .> comparison option ABC and DEF
|
|
|
|
|
SET T = $T + 1
|
|
|
|
|
IF [ "ABC" .> "DEF" ]
|
|
|
|
|
Echo " Test 7 ABC .> DEF : FAILED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 7 ABC .> DEF : FAILED" >> ${Log}
|
|
|
|
|
SET F = $F + 1
|
|
|
|
|
FI
|
|
|
|
|
ELSE
|
|
|
|
|
Echo " Test 7 ABC .> DEF : PASSED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 7 ABC .> DEF : PASSED" >> ${Log}
|
|
|
|
|
SET P = $P + 1
|
|
|
|
|
FI
|
|
|
|
|
FI
|
|
|
|
|
# Eighth test new .< comparison option ABC and DEF
|
|
|
|
|
SET T = $T + 1
|
|
|
|
|
IF [ "ABC" .< "DEF" ]
|
|
|
|
|
Echo " Test 8 ABC .< DEF : PASSED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 8 ABC .< DEF : PASSED" >> ${Log}
|
|
|
|
|
SET P = $P + 1
|
|
|
|
|
FI
|
|
|
|
|
ELSE
|
|
|
|
|
Echo " Test 8 ABC .< DEF : FAILED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 8 ABC .< DEF : FAILED" >> ${Log}
|
|
|
|
|
SET F = $F + 1
|
|
|
|
|
FI
|
|
|
|
|
FI
|
|
|
|
|
# Nineth test new >= comparison option ABC and DEF
|
|
|
|
|
SET T = $T + 1
|
|
|
|
|
IF [ "ABC" >= "DEF" ]
|
|
|
|
|
Echo " Test 9 ABC >= DEF : FAILED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 9 ABC >= DEF : FAILED" >> ${Log}
|
|
|
|
|
SET F = $F + 1
|
|
|
|
|
FI
|
|
|
|
|
ELSE
|
|
|
|
|
Echo " Test 9 ABC >= DEF : PASSED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 9 ABC >= DEF : PASSED" >> ${Log}
|
|
|
|
|
SET P = $P + 1
|
|
|
|
|
FI
|
|
|
|
|
FI
|
|
|
|
|
# Tenth test new <= comparison option ABC and DEF
|
|
|
|
|
SET T = $T + 1
|
|
|
|
|
IF [ "ABC" <= "DEF" ]
|
|
|
|
|
Echo " Test 10 ABC <= DEF : PASSED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 10 ABC <= DEF : PASSED" >> ${Log}
|
|
|
|
|
SET P = $P + 1
|
|
|
|
|
FI
|
|
|
|
|
ELSE
|
|
|
|
|
Echo " Test 10 ABC <= DEF : FAILED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 10 ABC <= DEF : FAILED" >> ${Log}
|
|
|
|
|
SET F = $F + 1
|
|
|
|
|
FI
|
|
|
|
|
FI
|
|
|
|
|
# Eleventh test new >= comparison option ABC and ABC
|
|
|
|
|
SET T = $T + 1
|
|
|
|
|
IF [ "ABC" >= "ABC" ]
|
|
|
|
|
Echo " Test 10 ABC >= ABC : PASSED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 10 ABC >= ABC : PASSED" >> ${Log}
|
|
|
|
|
SET P = $P + 1
|
|
|
|
|
FI
|
|
|
|
|
ELSE
|
|
|
|
|
Echo " Test 10 ABC >= ABC : FAILED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 10 ABC >= ABC : FAILED" >> ${Log}
|
|
|
|
|
SET F = $F + 1
|
|
|
|
|
FI
|
|
|
|
|
FI
|
|
|
|
|
# Twelveth test new <= comparison option ABC and ABC
|
|
|
|
|
SET T = $T + 1
|
|
|
|
|
IF [ "ABC" <= "ABC" ]
|
|
|
|
|
Echo " Test 10 ABC <= ABC : PASSED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 10 ABC <= ABC : PASSED" >> ${Log}
|
|
|
|
|
SET P = $P + 1
|
|
|
|
|
FI
|
|
|
|
|
ELSE
|
|
|
|
|
Echo " Test 10 ABC <= ABC : FAILED"
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "Test 10 ABC <= ABC : FAILED" >> ${Log}
|
|
|
|
|
SET F = $F + 1
|
|
|
|
|
FI
|
|
|
|
|
FI
|
2019-03-10 05:20:43 +00:00
|
|
|
|
ECHO "\nEnd IF String Tests"
|
|
|
|
|
ECHO
|
|
|
|
|
IF [ -N $Log ]
|
|
|
|
|
ECHO "End IF String Tests" >> ${Log}
|
2019-03-01 18:19:14 +00:00
|
|
|
|
FI
|
2019-03-10 05:20:43 +00:00
|
|
|
|
SET ABC =
|
|
|
|
|
SET DEF =
|
2019-02-21 21:19:56 +00:00
|
|
|
|
MAN
|
|
|
|
|
TEXT /MAKE/USR/SHARE/TESTS/IFSTRTEST
|