Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests #2

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
jobs:
build:
strategy:
fail-fast: false
matrix:
config:
- {
Expand Down Expand Up @@ -60,3 +61,7 @@ jobs:
working-directory: ${{github.workspace}}/build
# Build your program with the given configuration
run: NINJA_STATUS="%p [%f:%s/%t] %o/s, %es" && ninja
- name: Test
working-directory: ${{github.workspace}}/build
# Build your program with the given configuration
run: ctest -j4 --output-on-failure
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ set_property(TARGET cheriot-audit PROPERTY CXX_STANDARD 20)

target_link_libraries(cheriot-audit PRIVATE regocpp::rego)
target_link_libraries(cheriot-audit PRIVATE nlohmann_json::nlohmann_json)

enable_testing()
add_subdirectory("Tests")
10 changes: 10 additions & 0 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
message(STATUS "Adding tests")
file(GLOB TESTS CONFIGURE_DEPENDS "*.query")

message(STATUS "Tests: ${TESTS}")

foreach(TEST ${TESTS})
get_filename_component(TEST_NAME ${TEST} NAME_WE)
add_test(${TEST_NAME}_expected "${CMAKE_CURRENT_SOURCE_DIR}/testexpected.sh" "${CMAKE_BINARY_DIR}/cheriot-audit" ${TEST})
endforeach()

3 changes: 3 additions & 0 deletions Tests/compartment_check.query
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Check that we can demangle a library export correctly.
--board inputs/sail.json -j inputs/test-suite.json -q 'data.compartment.compartment_call_allow_list("allocator_test", `test_allocator\(\)`, {"test_runner"})'

1 change: 1 addition & 0 deletions Tests/compartment_check.query.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true
4 changes: 4 additions & 0 deletions Tests/demangle_compartment_call.query
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Check that we can demangle a compartment export correctly.
--board inputs/sail.json -j inputs/test-suite.json -q 'export_entry_demangle("alloc", input.compartments.allocator.exports[6].export_symbol)'


1 change: 1 addition & 0 deletions Tests/demangle_compartment_call.query.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"heap_free(SObjStruct*, void*)"
3 changes: 3 additions & 0 deletions Tests/demangle_libcall.query
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Check that we can demangle a library export correctly.
--board inputs/sail.json -j inputs/test-suite.json -q 'export_entry_demangle("token_library", input.compartments.token_library.exports[0].export_symbol)'

1 change: 1 addition & 0 deletions Tests/demangle_libcall.query.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"token_obj_unseal(SKeyStruct*, SObjStruct*)"
40 changes: 40 additions & 0 deletions Tests/inputs/sail.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"devices": {
"clint": {
"start": 0x2000000,
"length": 0x10000
},
"uart": {
"start": 0x10000000,
"end": 0x10000100
},
"shadow" : {
"start" : 0x83000000,
"end" : 0x83001000
}
},
"instruction_memory": {
"start": 0x80000000,
"end": 0x80040000
},
"heap": {
"end": 0x80040000
},
"interrupts": [
{
"name": "FakeInterrupt",
"number": 4,
"priority": 2
}
],
"defines" : "SAIL",
"driver_includes" : [
"../include/platform/generic-riscv"
],
"timer_hz" : 2000,
"tickrate_hz" : 10,
"revoker" : "software",
"stack_high_water_mark" : true,
"simulator" : "cheriot_sim",
"simulation": true
}
Loading
Loading