Skip to content

Commit

Permalink
tests/runner: add basic usage of event API
Browse files Browse the repository at this point in the history
Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
  • Loading branch information
d-tatianin committed Dec 19, 2024
1 parent 4df0ded commit 65c72c8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/runner/test_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <uacpi/osi.h>
#include <uacpi/tables.h>
#include <uacpi/opregion.h>
#include <uacpi/event.h>

void run_resource_tests();

Expand Down Expand Up @@ -272,6 +273,14 @@ static uacpi_status handle_ec(uacpi_region_op op, uacpi_handle op_data)
}
}

static uacpi_interrupt_ret handle_gpe(
uacpi_handle, uacpi_namespace_node *, uacpi_u16
)
{
std::cout << "got a GPE" << std::endl;
return UACPI_INTERRUPT_HANDLED | UACPI_GPE_REENABLE;
}

static void ensure_ok_status(uacpi_status st)
{
if (st == UACPI_STATUS_OK)
Expand Down Expand Up @@ -507,6 +516,20 @@ static void run_test(
);
ensure_ok_status(st);

st = uacpi_install_gpe_handler(
UACPI_NULL, 123, UACPI_GPE_TRIGGERING_EDGE, handle_gpe, UACPI_NULL
);
ensure_ok_status(st);

st = uacpi_enable_gpe(UACPI_NULL, 123);
ensure_ok_status(st);

st = uacpi_disable_gpe(UACPI_NULL, 123);
ensure_ok_status(st);

st = uacpi_uninstall_gpe_handler(UACPI_NULL, 123, handle_gpe);
ensure_ok_status(st);

st = uacpi_namespace_initialize();
ensure_ok_status(st);

Expand Down

0 comments on commit 65c72c8

Please sign in to comment.