Skip to content

Commit af30a56

Browse files
committed
Add diagnosis to failing hostap CI tests
1 parent 43e44cb commit af30a56

1 file changed

Lines changed: 44 additions & 20 deletions

File tree

.github/workflows/hostap-vm.yml

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ jobs:
340340
KVMARGS="-cpu host"
341341
EOF
342342
git config --global --add safe.directory $GITHUB_WORKSPACE/hostap
343+
# Persist logs for tests that fail (after retry) so they survive
344+
# the per-batch `rm -r` and can be inspected/uploaded.
345+
PERSISTENT_LOGS=$GITHUB_WORKSPACE/failed-test-logs
346+
mkdir -p "$PERSISTENT_LOGS"
343347
# Run tests in increments of 200 to not stall out the parallel-vm script
344348
while mapfile -t -n 200 ary && ((${#ary[@]})); do
345349
TESTS=$(printf '%s\n' "${ary[@]}" | tr '\n' ' ')
@@ -349,28 +353,48 @@ jobs:
349353
# Let's re-run the failing tests. We gather the failed tests from the log file.
350354
FAILED_TESTS=$(grep 'failed tests' /tmp/hwsim-test-logs/*-parallel.log | sed 's/failed tests: //' | tr ' ' '\n' | sort | uniq | tr '\n' ' ')
351355
printf 'failed tests: %s\n' "$FAILED_TESTS"
352-
./vm/parallel-vm.py ${{ env.hostap_debug_flags }} --nocurses $(nproc) $FAILED_TESTS
356+
RETRY_RES=0
357+
./vm/parallel-vm.py ${{ env.hostap_debug_flags }} --nocurses $(nproc) $FAILED_TESTS || RETRY_RES=$?
358+
if [ "$RETRY_RES" -ne "0" ]; then
359+
# Retry also had failures: snapshot relevant logs for diagnosis.
360+
# Capture every test that was reported failing in this batch
361+
# (initial run + retry) so we have full context.
362+
ALL_FAILED=$(grep 'failed tests' /tmp/hwsim-test-logs/*-parallel.log 2>/dev/null | sed 's/.*failed tests: //' | tr ' ' '\n' | sort | uniq | tr '\n' ' ')
363+
DEST="$PERSISTENT_LOGS/batch-$(date +%s%N)"
364+
mkdir -p "$DEST"
365+
cp /tmp/hwsim-test-logs/*-parallel.log "$DEST/" 2>/dev/null || true
366+
for test in $ALL_FAILED; do
367+
for f in $(find /tmp/hwsim-test-logs -name "${test}.log"); do
368+
rel=${f#/tmp/hwsim-test-logs/}
369+
mkdir -p "$DEST/$(dirname "$rel")"
370+
cp "$f" "$DEST/$rel"
371+
done
372+
done
373+
fi
353374
fi
354375
rm -r /tmp/hwsim-test-logs
355376
done < $GITHUB_WORKSPACE/wolfssl/.github/workflows/hostap-files/configs/${{ matrix.config.hostap_ref }}/tests
356377
357-
- name: show errors
378+
- name: Show failed test logs
358379
if: ${{ failure() && steps.testing.outcome == 'failure' }}
359-
run: grep -riP 'fail|error' /tmp/hwsim-test-logs/latest
360-
361-
# The logs are quite big. It hasn't been useful so far so let's not waste
362-
# precious gh space.
363-
#- name: zip logs
364-
# if: ${{ failure() && steps.testing.outcome == 'failure' }}
365-
# working-directory: hostap/tests/hwsim/
366-
# run: |
367-
# rm /tmp/hwsim-test-logs/latest
368-
# zip -9 -r logs.zip /tmp/hwsim-test-logs
369-
#
370-
#- name: Upload failure logs
371-
# if: ${{ failure() && steps.testing.outcome == 'failure' }}
372-
# uses: actions/upload-artifact@v4
373-
# with:
374-
# name: hostap-logs-${{ env.our_job_run_id }}
375-
# path: hostap/tests/hwsim/logs.zip
376-
# retention-days: 5
380+
run: |
381+
DIR=$GITHUB_WORKSPACE/failed-test-logs
382+
if [ ! -d "$DIR" ] || [ -z "$(ls -A "$DIR" 2>/dev/null)" ]; then
383+
echo "No persisted failure logs found."
384+
exit 0
385+
fi
386+
echo "=== Captured failure logs ==="
387+
find "$DIR" -name "*.log" | sort
388+
for f in $(find "$DIR" -name "*.log" -not -name "*-parallel.log" | sort); do
389+
echo "----- $f -----"
390+
tail -100 "$f"
391+
done
392+
393+
- name: Upload failure logs
394+
if: ${{ failure() && steps.testing.outcome == 'failure' }}
395+
uses: actions/upload-artifact@v4
396+
with:
397+
name: hostap-logs-${{ env.our_job_run_id }}
398+
path: failed-test-logs
399+
retention-days: 5
400+
if-no-files-found: ignore

0 commit comments

Comments
 (0)