@@ -14,24 +14,26 @@ TEST_FILE=$(mktemp)
1414
1515# This represents
1616#
17- # TEST_ID:TEST_COUNT:ENABLED:TARGET
17+ # TEST_ID:TEST_COUNT:ENABLED:TARGET:SKIP_NO_TARGET
1818#
1919# TEST_ID: is the test id number
2020# TEST_COUNT: number of times we should run the test
2121# ENABLED: 1 if enabled, 0 otherwise
2222# TARGET: test target file required on the test_sysctl module
23+ # SKIP_NO_TARGET: 1 skip if TARGET not there
24+ # 0 run eventhough TARGET not there
2325#
2426# Once these are enabled please leave them as-is. Write your own test,
2527# we have tons of space.
26- ALL_TESTS=" 0001:1:1:int_0001"
27- ALL_TESTS=" $ALL_TESTS 0002:1:1:string_0001"
28- ALL_TESTS=" $ALL_TESTS 0003:1:1:int_0002"
29- ALL_TESTS=" $ALL_TESTS 0004:1:1:uint_0001"
30- ALL_TESTS=" $ALL_TESTS 0005:3:1:int_0003"
31- ALL_TESTS=" $ALL_TESTS 0006:50:1:bitmap_0001"
32- ALL_TESTS=" $ALL_TESTS 0007:1:1:boot_int"
33- ALL_TESTS=" $ALL_TESTS 0008:1:1:match_int"
34- ALL_TESTS=" $ALL_TESTS 0009:1:1:unregister_error"
28+ ALL_TESTS=" 0001:1:1:int_0001:1 "
29+ ALL_TESTS=" $ALL_TESTS 0002:1:1:string_0001:1 "
30+ ALL_TESTS=" $ALL_TESTS 0003:1:1:int_0002:1 "
31+ ALL_TESTS=" $ALL_TESTS 0004:1:1:uint_0001:1 "
32+ ALL_TESTS=" $ALL_TESTS 0005:3:1:int_0003:1 "
33+ ALL_TESTS=" $ALL_TESTS 0006:50:1:bitmap_0001:1 "
34+ ALL_TESTS=" $ALL_TESTS 0007:1:1:boot_int:1 "
35+ ALL_TESTS=" $ALL_TESTS 0008:1:1:match_int:1 "
36+ ALL_TESTS=" $ALL_TESTS 0009:1:1:unregister_error:0 "
3537
3638function allow_user_defaults()
3739{
@@ -614,7 +616,6 @@ target_exists()
614616 TEST_ID=" $2 "
615617
616618 if [ ! -f ${TARGET} ] ; then
617- echo " Target for test $TEST_ID : $TARGET not exist, skipping test ..."
618619 return 0
619620 fi
620621 return 1
@@ -902,16 +903,36 @@ function get_test_target()
902903 echo ${TEST_DATA} | awk -F" :" ' {print $4}'
903904}
904905
906+ function get_test_skip_no_target()
907+ {
908+ test_num $1
909+ awk_field=$( remove_leading_zeros $1 )
910+ TEST_DATA=$( echo $ALL_TESTS | awk ' {print $' $awk_field ' }' )
911+ echo ${TEST_DATA} | awk -F" :" ' {print $5}'
912+ }
913+
914+ function skip_test()
915+ {
916+ TEST_ID=$1
917+ TEST_TARGET=$2
918+ if target_exists $TEST_TARGET $TEST_ID ; then
919+ TEST_SKIP=$( get_test_skip_no_target $TEST_ID )
920+ if [[ $TEST_SKIP -eq " 1" ]]; then
921+ echo " Target for test $TEST_ID : $TEST_TARGET not exist, skipping test ..."
922+ return 0
923+ fi
924+ fi
925+ return 1
926+ }
927+
905928function run_all_tests()
906929{
907930 for i in $ALL_TESTS ; do
908- TEST_ID=${i%:*:*:* }
931+ TEST_ID=${i%:*:*:*:* }
909932 ENABLED=$( get_test_enabled $TEST_ID )
910933 TEST_COUNT=$( get_test_count $TEST_ID )
911934 TEST_TARGET=$( get_test_target $TEST_ID )
912- if target_exists $TEST_TARGET $TEST_ID ; then
913- continue
914- fi
935+
915936 if [[ $ENABLED -eq " 1" ]]; then
916937 test_case $TEST_ID $TEST_COUNT $TEST_TARGET
917938 fi
@@ -946,18 +967,19 @@ function watch_case()
946967
947968function test_case()
948969{
970+ TEST_ID=$1
949971 NUM_TESTS=$2
972+ TARGET=$3
950973
951- i=0
952-
953- if target_exists $3 $1 ; then
954- continue
974+ if skip_test $TEST_ID $TARGET ; then
975+ return
955976 fi
956977
978+ i=0
957979 while [ $i -lt $NUM_TESTS ]; do
958- test_num $1
959- watch_log $i ${TEST_NAME} _test_$1 noclear
960- RUN_TEST=${TEST_NAME} _test_$1
980+ test_num $TEST_ID
981+ watch_log $i ${TEST_NAME} _test_${TEST_ID} noclear
982+ RUN_TEST=${TEST_NAME} _test_${TEST_ID}
961983 $RUN_TEST
962984 let i=$i +1
963985 done
0 commit comments