Skip to content

Commit

Permalink
tests/runner: install a fake SSDT when running tests
Browse files Browse the repository at this point in the history
This accomplishes the following things:
- Testing the table installation interface
- Testing the SSDT loading code
- Giving tests the ability to identify the uACPI test runner

Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
  • Loading branch information
d-tatianin committed Jun 12, 2024
1 parent d6278c7 commit 6305138
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/runner/test_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,27 @@ uint8_t table_override[] = {
0x6e, 0x6e, 0x65, 0x72, 0x00
};

/*
* DefinitionBlock ("x.aml", "SSDT", 1, "uTEST", "RUNRIDTB", 0xF0F0F0F0)
* {
* Name (\_SI.TID, "uACPI")
* Printf("TestRunner ID SSDT loaded!")
* }
*/
uint8_t runner_id_table[] = {
0x53, 0x53, 0x44, 0x54, 0x55, 0x00, 0x00, 0x00,
0x01, 0x45, 0x75, 0x54, 0x45, 0x53, 0x54, 0x00,
0x52, 0x55, 0x4e, 0x52, 0x49, 0x44, 0x54, 0x42,
0xf0, 0xf0, 0xf0, 0xf0, 0x49, 0x4e, 0x54, 0x4c,
0x25, 0x09, 0x20, 0x20, 0x08, 0x5c, 0x2e, 0x5f,
0x53, 0x49, 0x5f, 0x54, 0x49, 0x44, 0x5f, 0x0d,
0x75, 0x41, 0x43, 0x50, 0x49, 0x00, 0x70, 0x0d,
0x54, 0x65, 0x73, 0x74, 0x52, 0x75, 0x6e, 0x6e,
0x65, 0x72, 0x20, 0x49, 0x44, 0x20, 0x53, 0x53,
0x44, 0x54, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x65,
0x64, 0x21, 0x00, 0x5b, 0x31
};

static uacpi_table_installation_disposition handle_table_install(
struct acpi_sdt_hdr *hdr, uacpi_u64 *out_override
)
Expand Down Expand Up @@ -318,9 +339,25 @@ static void run_test(
st = uacpi_enable_host_interface(UACPI_HOST_INTERFACE_MODULE_DEVICE);
ensure_ok_status(st);

if (mode == run_mode::TEST) {
st = uacpi_table_install(runner_id_table, UACPI_NULL);
ensure_ok_status(st);
}

st = uacpi_namespace_load();
ensure_ok_status(st);

if (mode == run_mode::TEST) {
uacpi_object *runner_id;
st = uacpi_eval_typed(UACPI_NULL, "\\_SI.TID", UACPI_NULL,
UACPI_OBJECT_STRING_BIT, &runner_id);
ensure_ok_status(st);

if (strcmp(runner_id->buffer->text, "uACPI") != 0)
throw std::runtime_error("invalid test runner id");
uacpi_object_unref(runner_id);
}

st = uacpi_namespace_initialize();
ensure_ok_status(st);

Expand Down

0 comments on commit 6305138

Please sign in to comment.