mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
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`
This commit is contained in:
1 parent
bc4f17f9f1
commit
b5d4da532a
6 files changed
+52
No files matched your search
@@ -691,6 +691,7 @@ if (BUILD_LAGOM)
|
||||
set(TEST_DIRECTORIES
|
||||
AK
|
||||
Kernel/POSIX
|
||||
LibACPI
|
||||
LibCompress
|
||||
LibCrypto
|
||||
LibDisassembly
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
add_subdirectory(AK)
|
||||
add_subdirectory(Kernel)
|
||||
add_subdirectory(LibACPI)
|
||||
add_subdirectory(LibAudio)
|
||||
add_subdirectory(LibC)
|
||||
add_subdirectory(LibCompress)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
set(TEST_SOURCES
|
||||
TestAML.cpp
|
||||
)
|
||||
|
||||
foreach(source IN LISTS TEST_SOURCES)
|
||||
serenity_test("${source}" LibACPI LIBS LibACPI)
|
||||
endforeach()
|
||||
|
||||
install(DIRECTORY test-inputs DESTINATION usr/Tests/LibACPI)
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
DefinitionBlock ("", "DSDT", 2, "BUGGIE", "SERENITY", 0x00000001)
|
||||
{
|
||||
Scope (\_SB)
|
||||
{
|
||||
Name (NUM1, 0x1234)
|
||||
Name (NUM2, 42)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user