Skip to content

Commit dcd354d

Browse files
committed
Add CI for the examples.
Also update the RTOS and network-stack submodules and fix issues along the way. A recent compiler change broke the old version of the RTOS, which broke the examples. CI should make it easy to avoid this in the future. Fixes #2
1 parent 05fe319 commit dcd354d

File tree

10 files changed

+65
-5
lines changed

10 files changed

+65
-5
lines changed

.github/workflows/main.yml

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ on:
55
branches: [ main ]
66
pull_request:
77
branches: [ main ]
8+
workflow_dispatch:
9+
inputs:
10+
rtos_commit:
11+
description: 'Set to override default RTOS commit hash'
12+
type: string
13+
required: false
14+
network_stack_commit:
15+
description: 'Set to override default network stack commit hash'
16+
type: string
17+
required: false
818

919

1020
jobs:
@@ -24,8 +34,8 @@ jobs:
2434
- name: Run clang-format
2535
run: ./scripts/run_clang_format.sh /cheriot-tools/bin
2636

27-
build-examples:
28-
name: Build examples
37+
check-examples:
38+
name: Build and run examples
2939
runs-on: ubuntu-latest
3040
container:
3141
image: ghcr.io/cheriot-platform/devcontainer:latest
@@ -35,6 +45,18 @@ jobs:
3545
uses: actions/checkout@v4
3646
with:
3747
submodules: recursive
48+
- name: Set RTOS version
49+
if: ${{ inputs.rtos_commit }}
50+
run: |
51+
cd cheriot-rtos
52+
git checkout ${{ inputs.rtos_commit }}
53+
git submodule update --init --recursive
54+
- name: Set network stack version
55+
if: ${{ inputs.network_stack_commit }}
56+
run: |
57+
cd network-stack
58+
git checkout ${{ inputs.network_stack_commit }}
59+
git submodule update --init --recursive
3860
- name: Build examples
3961
run: |
4062
set -e
@@ -46,9 +68,45 @@ jobs:
4668
xmake
4769
fi
4870
done
71+
- name: Run examples
72+
run: |
73+
try_run()
74+
{
75+
timeout 10 xmake run
76+
RESULT=$?
77+
if [ $RESULT -eq 0 ] ; then
78+
return 0
79+
fi
80+
if [ -f .noterminate -a $RESULT -eq 124 ] ; then
81+
echo Killed via timeout, as expected
82+
return 0
83+
fi
84+
if [ -f .xcrash ] ; then
85+
echo Killed via CHERI trap, as expected
86+
return 0
87+
fi
88+
echo Test $(pwd) failed!
89+
exit 1
90+
}
91+
92+
for example_dir in $PWD/examples/*/; do
93+
if [ -f $example_dir/xmake.lua ] ; then
94+
cd $example_dir
95+
# Skip trying to run tests if the don't run on a simulator
96+
if grep sail xmake.lua ; then
97+
echo Testing $example_dir with Sail
98+
try_run
99+
fi
100+
if grep ibex xmake.lua ; then
101+
echo Testing $example_dir with Ibex
102+
try_run
103+
fi
104+
fi
105+
done
106+
49107
50108
all-checks:
51-
needs: [build-examples, check-format]
109+
needs: [check-examples, check-format]
52110
runs-on: ubuntu-latest
53111
steps:
54112
- name: Dummy step

cheriot-rtos

Submodule cheriot-rtos updated 187 files

examples/check_arguments/uart.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: MIT
33

44
#include "hello.h"
5+
#include <allocator.h>
56
#include <debug.hh>
67
#include <futex.h>
78
#include <locks.hh>

examples/interrupts_disabled/.noterminate

Whitespace-only changes.

examples/locking/.noterminate

Whitespace-only changes.

examples/priority_inheritance/.noterminate

Whitespace-only changes.

examples/producer_consumer/queue.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <debug.hh>
55
#include <fail-simulator-on-error.h>
6+
#include <futex.h>
67
#include <queue.h>
78
#include <timeout.hh>
89
#include <token.h>

examples/safebox/.noterminate

Whitespace-only changes.

examples/software_capability/.xcrash

Whitespace-only changes.

0 commit comments

Comments
 (0)