Files
serenity/Tests/LibACPI/TestAML.cpp
T
Undefine b5d4da532a Tests: Add a simple test for the LibACPI AML Interpreter
The test .aml file was built with iASL 20260930, using
`iasl Tests/LibACPI/test-inputs/scope_and_name.dsl`
2026-10-28 18:13:04 +01:00

34 lines
1.0 KiB
C++

/*
* Copyright (c) 2026, Undefine <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibACPI/Interpreter.h>
#include <LibACPI/NameString.h>
#include <LibCore/MappedFile.h>
#include <LibTest/Macros.h>
#include <LibTest/TestCase.h>
#ifdef AK_OS_SERENITY
# define TEST_INPUT(x) ("/usr/Tests/LibACPI/test-inputs/" x)
#else
# define TEST_INPUT(x) ("test-inputs/" x)
#endif
TEST_CASE(scope_and_name)
{
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("scope_and_name.aml"sv)));
auto interpreter = TRY_OR_FAIL(ACPI::AML::Interpreter::create());
TRY_OR_FAIL(interpreter->load(file->bytes()));
auto num1 = TRY_OR_FAIL(interpreter->evaluate(TRY_OR_FAIL(ACPI::AML::NameString::from_string_view("\\_SB_.NUM1"sv))));
EXPECT(num1.is<u64>());
EXPECT_EQ(MUST(num1.as<u64>()), 0x1234ul);
auto num2 = TRY_OR_FAIL(interpreter->evaluate(TRY_OR_FAIL(ACPI::AML::NameString::from_string_view("\\_SB_.NUM2"sv))));
EXPECT(num2.is<u64>());
EXPECT_EQ(MUST(num2.as<u64>()), 42ul);
}