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

@ -304,6 +304,8 @@ def main():
hopper_thread.daemon = True hopper_thread.daemon = True
hopper_thread.start() hopper_thread.start()
print("LISTENING_STARTED", flush=True)
while running: while running:
sniff(iface=args.monitor_iface, prn=handle_packet, store=False, timeout=5) 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" LISTENER_SAMPLE_FILE="${TEST_FILE%.csv}-listener-$COUNTER-$i.csv"
log "Launching listener for sample $COUNTER/$i..." log "Launching listener for sample $COUNTER/$i..."
READY_FILE="/tmp/listener_ready_$COUNTER_$i"
sudo "${SCRIPT_DIRECTORY}/listener.py" \ sudo "${SCRIPT_DIRECTORY}/listener.py" \
--main-iface "$INTERFACE" \ --main-iface "$INTERFACE" \
--monitor-iface "$LISTEN_INTERFACE" \ --monitor-iface "$LISTEN_INTERFACE" \
--outfile "$LISTENER_SAMPLE_FILE" \ --outfile "$LISTENER_SAMPLE_FILE" \
"${LISTENER_ARGS[@]}" & "${LISTENER_ARGS[@]}" > >(tee "$READY_FILE") &
LISTENER_PID=$! 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 fi
log " Sample $i of $NUM_SAMPLES" log " Sample $i of $NUM_SAMPLES"
START_TIME=$(date -Iseconds) START_TIME=$(date -Iseconds)