Skip to content

Eliminate recv() race condition #47

Eliminate recv() race condition

Eliminate recv() race condition #47

Workflow file for this run

name: GDBStub Tests
on:
push:
pull_request:
env:
TOOLCHAIN_VERSION: "2025.01.20"
TOOLCHAIN_CACHE_DIR: /home/runner/.cache/riscv-toolchain
jobs:
build-and-test:
name: Test ${{ matrix.arch }}
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
arch: [rv32, rv64]
include:
- arch: rv32
cross_compile: riscv32-unknown-elf-
toolchain_arch: riscv32
- arch: rv64
cross_compile: riscv64-unknown-elf-
toolchain_arch: riscv64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential gdb-multiarch
- name: Cache RISC-V toolchain
id: cache-toolchain
uses: actions/cache@v4
with:
path: |
/opt/riscv/${{ matrix.toolchain_arch }}
${{ env.TOOLCHAIN_CACHE_DIR }}
key: riscv-toolchain-${{ matrix.toolchain_arch }}-${{ env.TOOLCHAIN_VERSION }}-ubuntu-24.04
- name: Download RISC-V toolchain
if: steps.cache-toolchain.outputs.cache-hit != 'true'
run: |
mkdir -p ${{ env.TOOLCHAIN_CACHE_DIR }}
TOOLCHAIN_FILE="${{ matrix.toolchain_arch }}-elf-ubuntu-24.04-gcc-nightly-${{ env.TOOLCHAIN_VERSION }}-nightly.tar.xz"
TOOLCHAIN_URL="https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/${{ env.TOOLCHAIN_VERSION }}/${TOOLCHAIN_FILE}"
echo "Downloading: $TOOLCHAIN_URL"
curl -fsSL --retry 5 --retry-delay 2 -o "${{ env.TOOLCHAIN_CACHE_DIR }}/${TOOLCHAIN_FILE}" "$TOOLCHAIN_URL"
echo "Extracting toolchain..."
sudo mkdir -p /opt/riscv/${{ matrix.toolchain_arch }}
sudo tar -xJf "${{ env.TOOLCHAIN_CACHE_DIR }}/${TOOLCHAIN_FILE}" -C /opt/riscv/${{ matrix.toolchain_arch }} --strip-components=1
- name: Extract cached toolchain
if: steps.cache-toolchain.outputs.cache-hit == 'true'
run: |
TOOLCHAIN_FILE="${{ matrix.toolchain_arch }}-elf-ubuntu-24.04-gcc-nightly-${{ env.TOOLCHAIN_VERSION }}-nightly.tar.xz"
if [[ -f "${{ env.TOOLCHAIN_CACHE_DIR }}/${TOOLCHAIN_FILE}" ]] && [[ ! -d /opt/riscv/${{ matrix.toolchain_arch }}/bin ]]; then
echo "Extracting cached toolchain..."
sudo mkdir -p /opt/riscv/${{ matrix.toolchain_arch }}
sudo tar -xJf "${{ env.TOOLCHAIN_CACHE_DIR }}/${TOOLCHAIN_FILE}" -C /opt/riscv/${{ matrix.toolchain_arch }} --strip-components=1
fi
- name: Verify toolchain
run: |
export PATH="/opt/riscv/${{ matrix.toolchain_arch }}/bin:$PATH"
${{ matrix.cross_compile }}gcc --version
- name: Build libgdbstub
run: make
- name: Build emulator (${{ matrix.arch }})
run: |
export PATH="/opt/riscv/${{ matrix.toolchain_arch }}/bin:$PATH"
make build-emu ARCH=${{ matrix.arch }} CROSS_COMPILE=${{ matrix.cross_compile }}
- name: Run continue test
id: test-continue
continue-on-error: true
run: |
export PATH="/opt/riscv/${{ matrix.toolchain_arch }}/bin:$PATH"
export CROSS_COMPILE=${{ matrix.cross_compile }}
ARCH=${{ matrix.arch }} .ci/gdbstub_cont_test.sh
- name: Run breakpoint test
id: test-breakpoint
continue-on-error: true
run: |
export PATH="/opt/riscv/${{ matrix.toolchain_arch }}/bin:$PATH"
export CROSS_COMPILE=${{ matrix.cross_compile }}
ARCH=${{ matrix.arch }} .ci/gdbstub_bp_test.sh
- name: Run single register write test
id: test-regwrite-single
continue-on-error: true
run: |
export PATH="/opt/riscv/${{ matrix.toolchain_arch }}/bin:$PATH"
export CROSS_COMPILE=${{ matrix.cross_compile }}
ARCH=${{ matrix.arch }} .ci/gdbstub_regwrite_single_test.sh
- name: Run bulk register reject test
id: test-regwrite-bulk-reject
continue-on-error: true
run: |
export PATH="/opt/riscv/${{ matrix.toolchain_arch }}/bin:$PATH"
export CROSS_COMPILE=${{ matrix.cross_compile }}
ARCH=${{ matrix.arch }} .ci/gdbstub_regwrite_bulk_reject_test.sh
- name: Run bulk register roundtrip test
id: test-regwrite-bulk-roundtrip
continue-on-error: true
run: |
export PATH="/opt/riscv/${{ matrix.toolchain_arch }}/bin:$PATH"
export CROSS_COMPILE=${{ matrix.cross_compile }}
ARCH=${{ matrix.arch }} .ci/gdbstub_regwrite_bulk_roundtrip_test.sh
- name: Run no-ack mode test
id: test-noack
continue-on-error: true
run: |
export PATH="/opt/riscv/${{ matrix.toolchain_arch }}/bin:$PATH"
export CROSS_COMPILE=${{ matrix.cross_compile }}
ARCH=${{ matrix.arch }} .ci/gdbstub_noack_test.sh
- name: Run detach test
id: test-detach
continue-on-error: true
run: |
export PATH="/opt/riscv/${{ matrix.toolchain_arch }}/bin:$PATH"
export CROSS_COMPILE=${{ matrix.cross_compile }}
ARCH=${{ matrix.arch }} .ci/gdbstub_detach_test.sh
- name: Test Summary
if: always()
run: |
echo "## Test Results for ${{ matrix.arch }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Test | Status |" >> $GITHUB_STEP_SUMMARY
echo "|------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Continue Test | ${{ steps.test-continue.outcome == 'success' && 'PASSED' || 'FAILED' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Breakpoint Test | ${{ steps.test-breakpoint.outcome == 'success' && 'PASSED' || 'FAILED' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Single Register Write | ${{ steps.test-regwrite-single.outcome == 'success' && 'PASSED' || 'FAILED' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Bulk Register Reject | ${{ steps.test-regwrite-bulk-reject.outcome == 'success' && 'PASSED' || 'FAILED' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Bulk Register Roundtrip | ${{ steps.test-regwrite-bulk-roundtrip.outcome == 'success' && 'PASSED' || 'FAILED' }} |" >> $GITHUB_STEP_SUMMARY
echo "| No-Ack Mode | ${{ steps.test-noack.outcome == 'success' && 'PASSED' || 'FAILED' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Detach | ${{ steps.test-detach.outcome == 'success' && 'PASSED' || 'FAILED' }} |" >> $GITHUB_STEP_SUMMARY
- name: Fail if any test failed
if: always()
run: |
if [[ "${{ steps.test-continue.outcome }}" != "success" ]] || \
[[ "${{ steps.test-breakpoint.outcome }}" != "success" ]] || \
[[ "${{ steps.test-regwrite-single.outcome }}" != "success" ]] || \
[[ "${{ steps.test-regwrite-bulk-reject.outcome }}" != "success" ]] || \
[[ "${{ steps.test-regwrite-bulk-roundtrip.outcome }}" != "success" ]] || \
[[ "${{ steps.test-noack.outcome }}" != "success" ]] || \
[[ "${{ steps.test-detach.outcome }}" != "success" ]]; then
echo "One or more tests failed"
exit 1
fi
# Summary job that depends on all test jobs
test-summary:
name: Test Summary
runs-on: ubuntu-latest
needs: [build-and-test]
if: always()
steps:
- name: Check test results
run: |
echo "## Overall Test Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [[ "${{ needs.build-and-test.result }}" == "success" ]]; then
echo "All architecture tests passed!" >> $GITHUB_STEP_SUMMARY
exit 0
else
echo "Some tests failed. See individual job logs for details." >> $GITHUB_STEP_SUMMARY
exit 1
fi