Skip to content

Commit

Permalink
Add basic testing infrastructure.
Browse files Browse the repository at this point in the history
Each .query file contains some command-line arguments that are passed to
the binary.  It is must be accompanied by a .expected file that contains
the expected output.
  • Loading branch information
davidchisnall committed Mar 5, 2024
1 parent 12a0ee0 commit 12d58fd
Show file tree
Hide file tree
Showing 7 changed files with 5,255 additions and 0 deletions.
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 "*.query" 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()

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

0 comments on commit 12d58fd

Please sign in to comment.