Enhance listener output handling in runtest.sh to manage empty and missing sample files

This commit is contained in:
Yaro Kasear 2025-05-02 15:45:53 -05:00
parent 656f067fa5
commit 099ea01a52
2 changed files with 19 additions and 3 deletions

View file

@ -244,8 +244,24 @@ for ((COUNTER = 1; COUNTER <= NUM_TESTS; COUNTER++)); do
END_TIME=$(date -Iseconds)
LISTENER_ROW=$(tail -n 1 "$LISTENER_SAMPLE_FILE")
echo "$START_TIME,$END_TIME,$link_level_noise,$bssid_and_bitrate,$speed_results,$FAILED_DELTA,$channel,$freq,$packet_loss,$jitter,$LocalTCPUp,$LocalTCPDown,$LocalUDPUp,$LocalUDPDown,$RemoteTCPUp,$RemoteTCPDown,$RemoteUDPUp,$RemoteUDPDown,$LISTENER_ROW" >> "$TEST_FILE"
if [ "$LISTENER_ENABLED" -eq 1 ] && [ -n "${LISTENER_SAMPLE_FILE:-}" ]; then
if [ -f "$LISTENER_SAMPLE_FILE" ]; then
LISTENER_ROW=$(tail -n 1 "$LISTENER_SAMPLE_FILE")
if [ -n "$LISTENER_ROW" ]; then
echo "$START_TIME,$END_TIME,$link_level_noise,$bssid_and_bitrate,$speed_results,$FAILED_DELTA,$channel,$freq,$packet_loss,$jitter,$LocalTCPUp,$LocalTCPDown,$LocalUDPUp,$LocalUDPDown,$RemoteTCPUp,$RemoteTCPDown,$RemoteUDPUp,$RemoteUDPDown,$LISTENER_ROW" >> "$TEST_FILE"
else
warn "Listener output file $LISTENER_SAMPLE_FILE was empty. Appending blank listener columns."
echo "$START_TIME,$END_TIME,$link_level_noise,$bssid_and_bitrate,$speed_results,$FAILED_DELTA,$channel,$freq,$packet_loss,$jitter,$LocalTCPUp,$LocalTCPDown,$LocalUDPUp,$LocalUDPDown,$RemoteTCPUp,$RemoteTCPDown,$RemoteUDPUp,$RemoteUDPDown,$(yes ',' | head -n 12 | tr -d '\n')" >> "$TEST_FILE"
fi
rm -f "$LISTENER_SAMPLE_FILE"
else
warn "Listener sample file $LISTENER_SAMPLE_FILE not found. Appending blank listener columns."
echo "$START_TIME,$END_TIME,$link_level_noise,$bssid_and_bitrate,$speed_results,$FAILED_DELTA,$channel,$freq,$packet_loss,$jitter,$LocalTCPUp,$LocalTCPDown,$LocalUDPUp,$LocalUDPDown,$RemoteTCPUp,$RemoteTCPDown,$RemoteUDPUp,$RemoteUDPDown,$(yes ',' | head -n 12 | tr -d '\n')" >> "$TEST_FILE"
fi
else
echo "$START_TIME,$END_TIME,$link_level_noise,$bssid_and_bitrate,$speed_results,$FAILED_DELTA,$channel,$freq,$packet_loss,$jitter,$LocalTCPUp,$LocalTCPDown,$LocalUDPUp,$LocalUDPDown,$RemoteTCPUp,$RemoteTCPDown,$RemoteUDPUp,$RemoteUDPDown" >> "$TEST_FILE"
fi
done
[[ "$COUNTER" -lt "$NUM_TESTS" ]] && log "Waiting $TIME_BETWEEN before next test..." && sleep "$TIME_BETWEEN"