diff options
author | Simon Glass | 2020-07-07 13:11:51 -0600 |
---|---|---|
committer | Bin Meng | 2020-07-17 14:32:24 +0800 |
commit | 03967ce2e5e4332edd1e023360707a1086f42242 (patch) | |
tree | b2b38e054b8a3a2bc35b81851d8186be1a9879e2 /test | |
parent | 7e148f2ed365c89f50701ed45acd6e36138de447 (diff) |
acpigen: Support writing a package
A package collects together several elements. Add an easy way of writing
a package header and updating its length later.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/dm/acpigen.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/dm/acpigen.c b/test/dm/acpigen.c index c7568470934..aaffc6a4cf5 100644 --- a/test/dm/acpigen.c +++ b/test/dm/acpigen.c @@ -404,3 +404,30 @@ static int dm_test_acpi_len(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_acpi_len, 0); + +/* Test writing a package */ +static int dm_test_acpi_package(struct unit_test_state *uts) +{ + struct acpi_ctx *ctx; + char *num_elements; + u8 *ptr; + + ut_assertok(alloc_context(&ctx)); + + ptr = acpigen_get_current(ctx); + + num_elements = acpigen_write_package(ctx, 3); + ut_asserteq_ptr(num_elements, ptr + 4); + + /* For ease of testing, just emit a byte, not valid package contents */ + acpigen_emit_byte(ctx, 0x23); + acpigen_pop_len(ctx); + ut_asserteq(PACKAGE_OP, ptr[0]); + ut_asserteq(5, get_length(ptr + 1)); + ut_asserteq(3, ptr[4]); + + free_context(&ctx); + + return 0; +} +DM_TEST(dm_test_acpi_package, 0); |