Skip to content

[WIP] Allow user to run scripts in between test runs #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 74 additions & 7 deletions con-test/con-test
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ SUDO=''
stop_file_collect()
{
side=$1
auth=$(check_auth $side)
auth=$(check_auth "$side")

if [[ "$side" == "$CLIENT" ]]; then
ip=$CLIENT_IP
Expand All @@ -57,10 +57,10 @@ stop_file_collect()
fi

if [[ "$auth" == "$PASSWD" ]]; then
sshpass -p $passwd ssh ${user}@${ip} \
sshpass -p "$passwd" ssh "${user}@${ip}" \
'touch /tmp/stop'
else
ssh -i $cert ${user}@${ip} \
ssh -i "$cert" "${user}@${ip}" \
'touch /tmp/stop'
fi
}
Expand All @@ -72,7 +72,7 @@ add_timestamp()
run=$3
append=$4

while usleep $time
while usleep "$time"
do
if [ -f '/tmp/stop' ]; then
break
Expand Down Expand Up @@ -256,6 +256,66 @@ start_iperf()
fi
}

get_script_language()
{
test_file=$1
if [ -z "$lang" ]; then
echo "nothing set"
lang=$(awk 'NR==1 { print $NF}' "$test_file" )
fi
case $lang in
sh | "env sh" | \
python | "env python" | \
python2 | \
python3 | \
perl | "perl -w" | \
"awk -f")
echo "$lang"
return $SUCCESS
;;
*)
return $FAILURE
;;
esac
}

# run user specific script
#
# Arguments:
# script: script provided by user to run
# side: where to start the script 0 for client, 1 for server
#
run_script()
{
script=$1
side=$2
script_lang=$(get_script_language $script)
auth=$(check_auth "$side")

printf "${INFO} running script $script on $side"
if [[ "$side" == "$CLIENT" ]]; then
ip=$CLIENT_IP
user=$CLIENT_USER
passwd=$CLIENT_PASSWORD
cert=$CLIENT_CERTIFICATE
else
ip=$SERVER_IP
user=$SERVER_USER
passwd=$SERVER_PASSWORD
cert=$SERVER_CERTIFICATE
fi

if [[ "$auth" == "$PASSWD" ]]; then
sshpass -p "$passwd" scp "$script" "$user"@"$ip":/tmp/
sshpass -p "$passwd" ssh "$user"@"$ip" \
"$script_lang" "/tmp/$(basename "$script")"
else
scp -i "$cert" "$script" "$user"@"$ip":/tmp/
ssh -i "$cert" "$user"@"$ip" \
"$script_lang" "/tmp/$(basename "$script")"
fi
}

# start attenuators, get the attenuation up
#
# Arguments:
Expand Down Expand Up @@ -432,7 +492,14 @@ main()
fi

if [[ "$mon" == "$ON" ]]; then
bash wireless_monitor -o $LOG_PATH -c $config_path &
bash wireless_monitor -o "$LOG_PATH" \
-c "$config_path" &
fi

#run scripts
if [ -n "${USER_SCRIPT[${i} - 1]}" ]; then
run_script "${USER_SCRIPT[${1} - 1]}" $CLIENT
run_script "${USER_SCRIPT[${1} - 1]}" $SERVER
fi

#start measurement
Expand All @@ -444,7 +511,7 @@ main()

sleep 3

start_antennuator ${ATTENUATOR_PARAMS[${i} - 1]}
start_antennuator "${ATTENUATOR_PARAMS[${i} - 1]}"

sleep 2

Expand All @@ -457,4 +524,4 @@ main()
done
}

main $@
main "$@"
2 changes: 2 additions & 0 deletions con-test/con-test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ TIME=('100000' '200000' '200000')
# set name for package to update with number accordingly to update position
# including the relativ, or absolute path to the package
UPDATE_PKG=('' 'mac80211.ipk' '')

USER_SCRIPT('' 'test.sh' '')
# Optional:
# Provide Parameters for iperf according to the run number.
# -s/-c will be added by default
Expand Down