mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 03:07:56 +00:00
test_all_scripts.sh: replaces case with associative array, replaces string tests with arithmetic tests
This commit is contained in:
@@ -8,10 +8,12 @@ SSID_USED="jedway-wpa2-x2048-5-3"
|
||||
PASSWD_USED="jedway-wpa2-x2048-5-3"
|
||||
RADIO_USED="wiphy1"
|
||||
SECURITY="wpa2"
|
||||
CURR_TEST_NAME="BLANK"
|
||||
CURR_TEST_NUM=0
|
||||
STOP_NUM=9
|
||||
|
||||
START_NUM=0
|
||||
CURR_TEST_NUM=0
|
||||
CURR_TEST_NAME="BLANK"
|
||||
STOP_NUM=9
|
||||
|
||||
#Test array
|
||||
testCommands=("./example_wpa_connection.py --num_stations $NUM_STA --ssid jedway-r8000-36 --passwd jedway-r8000-36 --radio $RADIO_USED --security wpa"
|
||||
"./example_wpa2_connection.py --num_stations $NUM_STA --ssid $SSID_USED --passwd $SSID_USED --radio $RADIO_USED --security wpa2"
|
||||
@@ -24,37 +26,19 @@ testCommands=("./example_wpa_connection.py --num_stations $NUM_STA --ssid jedway
|
||||
"./test_ipv4_l4_wifi.py --upstream_port eth1 --radio wiphy0 --num_stations $NUM_STA --security $SECURITY --ssid jedway-wpa2-x2048-4-4 --passwd jedway-wpa2-x2048-4-4 --test_duration 3m"
|
||||
"./test_ipv4_l4.py --radio wiphy3 --num_stations 4 --security wpa2 --ssid jedway-wpa2-x2048-4-1 --passwd jedway-wpa2-x2048-4-1 --url \"dl http://10.40.0.1 /dev/null\" --test_duration 2m --debug"
|
||||
)
|
||||
function ret_case_num() {
|
||||
case $1 in
|
||||
"example_wpa_connection")
|
||||
echo 1
|
||||
;;
|
||||
"example_wpa2_connection")
|
||||
echo 2
|
||||
;;
|
||||
"example_wpa3_connection")
|
||||
echo 4
|
||||
;;
|
||||
"example_wep_connection")
|
||||
echo 3
|
||||
;;
|
||||
"test_ipv4_connection")
|
||||
echo 5
|
||||
;;
|
||||
"test_generic")
|
||||
echo 6
|
||||
;;
|
||||
"test_ipv4_l4_urls_per_ten")
|
||||
echo 7
|
||||
;;
|
||||
"test_ipv4_l4_wifi")
|
||||
echo 8
|
||||
;;
|
||||
"test_ipv4_l4")
|
||||
echo 9
|
||||
;;
|
||||
esac
|
||||
}
|
||||
declare -A name_to_num
|
||||
name_to_num=(
|
||||
["example_wpa_connection"]=1
|
||||
["example_wpa2_connection"]=2
|
||||
["example_wpa3_connection"]=4
|
||||
["example_wep_connection"]=3
|
||||
["test_ipv4_connection"]=5
|
||||
["test_generic"]=6
|
||||
["test_ipv4_l4_urls_per_ten"]=7
|
||||
["test_ipv4_l4_wifi"]=8
|
||||
["test_ipv4_l4"]=9
|
||||
)
|
||||
|
||||
function blank_db() {
|
||||
echo "Loading blank scenario..." >>~/test_all_output_file.txt
|
||||
./scenario.py --load BLANK >>~/test_all_output_file.txt
|
||||
@@ -65,14 +49,20 @@ function echo_print() {
|
||||
}
|
||||
function run_test() {
|
||||
for i in "${testCommands[@]}"; do
|
||||
set -x
|
||||
set -e
|
||||
CURR_TEST_NAME=${i%%.py*}
|
||||
CURR_TEST_NAME=${CURR_TEST_NAME#./*}
|
||||
CURR_TEST_NUM=$(ret_case_num $CURR_TEST_NAME)
|
||||
if [[ $CURR_TEST_NUM -gt $STOP_NUM ]] || [[ $STOP_NUM -eq $CURR_NUM && $STOP_NUM -ne 0 ]]; then
|
||||
CURR_TEST_NUM="${name_to_num[$CURR_TEST_NAME]}"
|
||||
echo "$CURR_TEST_NAME $CURR_TEST_NUM"
|
||||
|
||||
if (( $CURR_TEST_NUM > $STOP_NUM )) || (( $STOP_NUM == $CURR_TEST_NUM )) && (( $STOP_NUM != 0 )); then
|
||||
exit 1
|
||||
fi
|
||||
if [[ $CURR_TEST_NUM -gt $START_NUM ]] || [[ $CURR_TEST_NUM -eq $START_NUM ]]; then
|
||||
if (( $CURR_TEST_NUM > $START_NUM )) || (( $CURR_TEST_NUM == $START_NUM )); then
|
||||
echo_print
|
||||
echo "$i"
|
||||
sleep 3
|
||||
eval $i >>~/test_all_output_file.txt
|
||||
if [ $? -ne 0 ]; then
|
||||
echo $CURR_TEST_NAME failure
|
||||
|
||||
Reference in New Issue
Block a user