Add listener readiness check in runtest.sh

This commit is contained in:
Yaro Kasear 2025-05-02 14:41:50 -05:00
parent 4beafbe674
commit 3cdcadcb6d
2 changed files with 10 additions and 1 deletions

View file

@ -303,6 +303,8 @@ def main():
hopper_thread = threading.Thread(target=channel_hopper, args=(args.monitor_iface,))
hopper_thread.daemon = True
hopper_thread.start()
print("LISTENING_STARTED", flush=True)
while running:
sniff(iface=args.monitor_iface, prn=handle_packet, store=False, timeout=5)

View file

@ -168,12 +168,19 @@ for ((COUNTER = 1; COUNTER <= NUM_TESTS; COUNTER++)); do
LISTENER_SAMPLE_FILE="${TEST_FILE%.csv}-listener-$COUNTER-$i.csv"
log "Launching listener for sample $COUNTER/$i..."
READY_FILE="/tmp/listener_ready_$COUNTER_$i"
sudo "${SCRIPT_DIRECTORY}/listener.py" \
--main-iface "$INTERFACE" \
--monitor-iface "$LISTEN_INTERFACE" \
--outfile "$LISTENER_SAMPLE_FILE" \
"${LISTENER_ARGS[@]}" &
"${LISTENER_ARGS[@]}" > >(tee "$READY_FILE") &
LISTENER_PID=$!
# Wait for the READY_FILE to contain "LISTENING_STARTED"
timeout 5 bash -c "until grep -q LISTENING_STARTED $READY_FILE; do sleep 0.2; done"
fi
log " Sample $i of $NUM_SAMPLES"
START_TIME=$(date -Iseconds)