Simon Glass | 2d67fdf | 2020-04-08 16:57:34 -0600 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Tests for ACPI table generation |
| 4 | * |
| 5 | * Copyright 2019 Google LLC |
| 6 | * Written by Simon Glass <sjg@chromium.org> |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <dm.h> |
| 11 | #include <dm/acpi.h> |
| 12 | #include <dm/test.h> |
| 13 | #include <test/ut.h> |
| 14 | |
| 15 | #define ACPI_TEST_DEV_NAME "ABCD" |
| 16 | |
| 17 | static int testacpi_get_name(const struct udevice *dev, char *out_name) |
| 18 | { |
| 19 | return acpi_copy_name(out_name, ACPI_TEST_DEV_NAME); |
| 20 | } |
| 21 | |
| 22 | struct acpi_ops testacpi_ops = { |
| 23 | .get_name = testacpi_get_name, |
| 24 | }; |
| 25 | |
| 26 | static const struct udevice_id testacpi_ids[] = { |
| 27 | { .compatible = "denx,u-boot-acpi-test" }, |
| 28 | { } |
| 29 | }; |
| 30 | |
| 31 | U_BOOT_DRIVER(testacpi_drv) = { |
| 32 | .name = "testacpi_drv", |
| 33 | .of_match = testacpi_ids, |
| 34 | .id = UCLASS_TEST_ACPI, |
| 35 | ACPI_OPS_PTR(&testacpi_ops) |
| 36 | }; |
| 37 | |
| 38 | UCLASS_DRIVER(testacpi) = { |
| 39 | .name = "testacpi", |
| 40 | .id = UCLASS_TEST_ACPI, |
| 41 | }; |
| 42 | |
| 43 | /* Test ACPI get_name() */ |
| 44 | static int dm_test_acpi_get_name(struct unit_test_state *uts) |
| 45 | { |
| 46 | char name[ACPI_NAME_MAX]; |
| 47 | struct udevice *dev; |
| 48 | |
| 49 | ut_assertok(uclass_first_device_err(UCLASS_TEST_ACPI, &dev)); |
| 50 | ut_assertok(acpi_get_name(dev, name)); |
| 51 | ut_asserteq_str(ACPI_TEST_DEV_NAME, name); |
| 52 | |
| 53 | return 0; |
| 54 | } |
| 55 | DM_TEST(dm_test_acpi_get_name, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |