Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
zyma98 committed Jun 19, 2024
1 parent 8d37be5 commit 6ffe2fa
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 21 deletions.
46 changes: 25 additions & 21 deletions .github/workflows/actions/test-hello-world/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,34 @@ inputs:
runs:
using: "composite"
steps:
- name: Prepare QEMU
uses: ./.github/workflows/actions/prepare-qemu
with:
cookie: ${{ inputs.cookie }}
# - name: Prepare QEMU
# uses: ./.github/workflows/actions/prepare-qemu
# with:
# cookie: ${{ inputs.cookie }}

- name: Download test "hello world"
uses: actions/download-artifact@v4
with:
name: hello_world
path: ./artifacts
# - name: Download test "hello world"
# uses: actions/download-artifact@v4
# with:
# name: hello_world
# path: ./artifacts

- name: Run test "hello world"
run: |
timeout 5s \
qemu-system-arm -machine netduinoplus2 -nographic \
-semihosting-config enable=on,target=native \
-kernel ./artifacts/hello_world \
> output.txt
shell: bash
# - name: Run test "hello world"
# run: |
# timeout 5s \
# qemu-system-arm -machine netduinoplus2 -nographic \
# -semihosting-config enable=on,target=native \
# -kernel ./artifacts/hello_world \
# > output.txt
# shell: bash

- name: Emit ground truth output
run: echo "hello world!" > truth.txt
shell: bash

- name: Check test output
run: diff output.txt truth.txt
shell: bash

- name: Run test "hello world"
uses: ./.github/workflows/actions/test-run
with:
cookie: ${{ inputs.cookie }}
test-name: hello world
test-image-key: hello_world
output-ground-truth: truth.txt
47 changes: 47 additions & 0 deletions .github/workflows/actions/test-run/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Run ELF Image for Testing
description: "Run the given ELF image with QEMU and compare the output with ground truth."

inputs:
cookie:
description: "Cookie for download authorization."
required: true
test-name:
description: "Name of the test to be run."
required: true
test-image-key:
description: "The artifact key for the ELF image to be tested."
required: true
output-ground-truth:
description: "The correct answer for output."
required: true
timeout:
description: "Timeout to prevent unresponsive QEMU."
required: false
default: 5s

runs:
using: "composite"
steps:
- name: Prepare QEMU
uses: ./.github/workflows/actions/prepare-qemu
with:
cookie: ${{ inputs.cookie }}

- name: Download test ${{ inputs.test-name }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.test-image-key }}
path: ./artifacts

- name: Run test ${{ inputs.test-name }}
run: |
timeout ${{ inputs.timeout }} \
qemu-system-arm -machine netduinoplus2 -nographic \
-semihosting-config enable=on,target=native \
-kernel "./artifacts/${{ inputs.test-image-key }}" \
> output.txt
shell: bash

- name: Check test output
run: diff output.txt "${{ inputs.output-ground-truth }}"
shell: bash

0 comments on commit 6ffe2fa

Please sign in to comment.