acpi.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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. #include <common.h>
  9. #include <console.h>
  10. #include <dm.h>
  11. #include <malloc.h>
  12. #include <mapmem.h>
  13. #include <version.h>
  14. #include <tables_csum.h>
  15. #include <version.h>
  16. #include <acpi/acpigen.h>
  17. #include <acpi/acpi_device.h>
  18. #include <acpi/acpi_table.h>
  19. #include <dm/acpi.h>
  20. #include <dm/test.h>
  21. #include <test/ut.h>
  22. #include "acpi.h"
  23. #define BUF_SIZE 4096
  24. /**
  25. * struct testacpi_platdata - Platform data for the test ACPI device
  26. *
  27. * @no_name: true to emit an empty ACPI name from testacpi_get_name()
  28. * @return_error: true to return an error instead of a name
  29. */
  30. struct testacpi_platdata {
  31. bool return_error;
  32. bool no_name;
  33. };
  34. static int testacpi_write_tables(const struct udevice *dev,
  35. struct acpi_ctx *ctx)
  36. {
  37. struct acpi_dmar *dmar;
  38. int ret;
  39. dmar = (struct acpi_dmar *)ctx->current;
  40. acpi_create_dmar(dmar, DMAR_INTR_REMAP);
  41. ctx->current += sizeof(struct acpi_dmar);
  42. ret = acpi_add_table(ctx, dmar);
  43. if (ret)
  44. return log_msg_ret("add", ret);
  45. return 0;
  46. }
  47. static int testacpi_get_name(const struct udevice *dev, char *out_name)
  48. {
  49. struct testacpi_platdata *plat = dev_get_platdata(dev);
  50. if (plat->return_error)
  51. return -EINVAL;
  52. if (plat->no_name) {
  53. *out_name = '\0';
  54. return 0;
  55. }
  56. if (device_get_uclass_id(dev->parent) == UCLASS_TEST_ACPI)
  57. return acpi_copy_name(out_name, ACPI_TEST_CHILD_NAME);
  58. else
  59. return acpi_copy_name(out_name, ACPI_TEST_DEV_NAME);
  60. }
  61. static int testacpi_fill_ssdt(const struct udevice *dev, struct acpi_ctx *ctx)
  62. {
  63. const char *data;
  64. data = dev_read_string(dev, "acpi-ssdt-test-data");
  65. if (data) {
  66. while (*data)
  67. acpigen_emit_byte(ctx, *data++);
  68. }
  69. return 0;
  70. }
  71. static int testacpi_inject_dsdt(const struct udevice *dev, struct acpi_ctx *ctx)
  72. {
  73. const char *data;
  74. data = dev_read_string(dev, "acpi-dsdt-test-data");
  75. if (data) {
  76. while (*data)
  77. acpigen_emit_byte(ctx, *data++);
  78. }
  79. return 0;
  80. }
  81. struct acpi_ops testacpi_ops = {
  82. .get_name = testacpi_get_name,
  83. .write_tables = testacpi_write_tables,
  84. .fill_ssdt = testacpi_fill_ssdt,
  85. .inject_dsdt = testacpi_inject_dsdt,
  86. };
  87. static const struct udevice_id testacpi_ids[] = {
  88. { .compatible = "denx,u-boot-acpi-test" },
  89. { }
  90. };
  91. U_BOOT_DRIVER(testacpi_drv) = {
  92. .name = "testacpi_drv",
  93. .of_match = testacpi_ids,
  94. .id = UCLASS_TEST_ACPI,
  95. .bind = dm_scan_fdt_dev,
  96. .platdata_auto_alloc_size = sizeof(struct testacpi_platdata),
  97. ACPI_OPS_PTR(&testacpi_ops)
  98. };
  99. UCLASS_DRIVER(testacpi) = {
  100. .name = "testacpi",
  101. .id = UCLASS_TEST_ACPI,
  102. };
  103. /* Test ACPI get_name() */
  104. static int dm_test_acpi_get_name(struct unit_test_state *uts)
  105. {
  106. char name[ACPI_NAME_MAX];
  107. struct udevice *dev, *dev2, *i2c, *spi, *serial, *timer, *sound;
  108. struct udevice *pci, *root;
  109. /* Test getting the name from the driver */
  110. ut_assertok(uclass_first_device_err(UCLASS_TEST_ACPI, &dev));
  111. ut_assertok(acpi_get_name(dev, name));
  112. ut_asserteq_str(ACPI_TEST_DEV_NAME, name);
  113. /* Test getting the name from the device tree */
  114. ut_assertok(uclass_get_device_by_name(UCLASS_TEST_FDT, "a-test",
  115. &dev2));
  116. ut_assertok(acpi_get_name(dev2, name));
  117. ut_asserteq_str("GHIJ", name);
  118. /* Test getting the name from acpi_device_get_name() */
  119. ut_assertok(uclass_first_device(UCLASS_I2C, &i2c));
  120. ut_assertok(acpi_get_name(i2c, name));
  121. ut_asserteq_str("I2C0", name);
  122. ut_assertok(uclass_first_device(UCLASS_SPI, &spi));
  123. ut_assertok(acpi_get_name(spi, name));
  124. ut_asserteq_str("SPI0", name);
  125. /* The uart has no sequence number, so this should fail */
  126. ut_assertok(uclass_first_device(UCLASS_SERIAL, &serial));
  127. ut_asserteq(-ENXIO, acpi_get_name(serial, name));
  128. /* ACPI doesn't know about the timer */
  129. ut_assertok(uclass_first_device(UCLASS_TIMER, &timer));
  130. ut_asserteq(-ENOENT, acpi_get_name(timer, name));
  131. /* May as well test the rest of the cases */
  132. ut_assertok(uclass_first_device(UCLASS_SOUND, &sound));
  133. ut_assertok(acpi_get_name(sound, name));
  134. ut_asserteq_str("HDAS", name);
  135. ut_assertok(uclass_first_device(UCLASS_PCI, &pci));
  136. ut_assertok(acpi_get_name(pci, name));
  137. ut_asserteq_str("PCI0", name);
  138. ut_assertok(uclass_first_device(UCLASS_ROOT, &root));
  139. ut_assertok(acpi_get_name(root, name));
  140. ut_asserteq_str("\\_SB", name);
  141. /* Note that we don't have tests for acpi_name_from_id() */
  142. return 0;
  143. }
  144. DM_TEST(dm_test_acpi_get_name, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  145. /* Test acpi_get_table_revision() */
  146. static int dm_test_acpi_get_table_revision(struct unit_test_state *uts)
  147. {
  148. ut_asserteq(1, acpi_get_table_revision(ACPITAB_MCFG));
  149. ut_asserteq(2, acpi_get_table_revision(ACPITAB_RSDP));
  150. ut_asserteq(4, acpi_get_table_revision(ACPITAB_TPM2));
  151. ut_asserteq(-EINVAL, acpi_get_table_revision(ACPITAB_COUNT));
  152. return 0;
  153. }
  154. DM_TEST(dm_test_acpi_get_table_revision,
  155. DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  156. /* Test acpi_create_dmar() */
  157. static int dm_test_acpi_create_dmar(struct unit_test_state *uts)
  158. {
  159. struct acpi_dmar dmar;
  160. ut_assertok(acpi_create_dmar(&dmar, DMAR_INTR_REMAP));
  161. ut_asserteq(DMAR_INTR_REMAP, dmar.flags);
  162. ut_asserteq(32 - 1, dmar.host_address_width);
  163. return 0;
  164. }
  165. DM_TEST(dm_test_acpi_create_dmar, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  166. /* Test acpi_fill_header() */
  167. static int dm_test_acpi_fill_header(struct unit_test_state *uts)
  168. {
  169. struct acpi_table_header hdr;
  170. /* Make sure these 5 fields are not changed */
  171. hdr.length = 0x11;
  172. hdr.revision = 0x22;
  173. hdr.checksum = 0x33;
  174. hdr.aslc_revision = 0x44;
  175. acpi_fill_header(&hdr, "ABCD");
  176. ut_asserteq_mem("ABCD", hdr.signature, sizeof(hdr.signature));
  177. ut_asserteq(0x11, hdr.length);
  178. ut_asserteq(0x22, hdr.revision);
  179. ut_asserteq(0x33, hdr.checksum);
  180. ut_asserteq_mem(OEM_ID, hdr.oem_id, sizeof(hdr.oem_id));
  181. ut_asserteq_mem(OEM_TABLE_ID, hdr.oem_table_id,
  182. sizeof(hdr.oem_table_id));
  183. ut_asserteq(U_BOOT_BUILD_DATE, hdr.oem_revision);
  184. ut_asserteq_mem(ASLC_ID, hdr.aslc_id, sizeof(hdr.aslc_id));
  185. ut_asserteq(0x44, hdr.aslc_revision);
  186. return 0;
  187. }
  188. DM_TEST(dm_test_acpi_fill_header, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  189. /* Test ACPI write_tables() */
  190. static int dm_test_acpi_write_tables(struct unit_test_state *uts)
  191. {
  192. struct acpi_dmar *dmar;
  193. struct acpi_ctx ctx;
  194. void *buf;
  195. int i;
  196. buf = malloc(BUF_SIZE);
  197. ut_assertnonnull(buf);
  198. acpi_setup_base_tables(&ctx, buf);
  199. dmar = ctx.current;
  200. ut_assertok(acpi_write_dev_tables(&ctx));
  201. /*
  202. * We should have three dmar tables, one for each
  203. * "denx,u-boot-acpi-test" device
  204. */
  205. ut_asserteq_ptr(dmar + 3, ctx.current);
  206. ut_asserteq(DMAR_INTR_REMAP, dmar->flags);
  207. ut_asserteq(32 - 1, dmar->host_address_width);
  208. ut_asserteq(DMAR_INTR_REMAP, dmar[1].flags);
  209. ut_asserteq(32 - 1, dmar[1].host_address_width);
  210. ut_asserteq(DMAR_INTR_REMAP, dmar[2].flags);
  211. ut_asserteq(32 - 1, dmar[2].host_address_width);
  212. /* Check that the pointers were added correctly */
  213. for (i = 0; i < 3; i++) {
  214. ut_asserteq(map_to_sysmem(dmar + i), ctx.rsdt->entry[i]);
  215. ut_asserteq(map_to_sysmem(dmar + i), ctx.xsdt->entry[i]);
  216. }
  217. ut_asserteq(0, ctx.rsdt->entry[3]);
  218. ut_asserteq(0, ctx.xsdt->entry[3]);
  219. return 0;
  220. }
  221. DM_TEST(dm_test_acpi_write_tables, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  222. /* Test basic ACPI functions */
  223. static int dm_test_acpi_basic(struct unit_test_state *uts)
  224. {
  225. struct acpi_ctx ctx;
  226. /* Check align works */
  227. ctx.current = (void *)5;
  228. acpi_align(&ctx);
  229. ut_asserteq_ptr((void *)16, ctx.current);
  230. /* Check that align does nothing if already aligned */
  231. acpi_align(&ctx);
  232. ut_asserteq_ptr((void *)16, ctx.current);
  233. acpi_align64(&ctx);
  234. ut_asserteq_ptr((void *)64, ctx.current);
  235. acpi_align64(&ctx);
  236. ut_asserteq_ptr((void *)64, ctx.current);
  237. /* Check incrementing */
  238. acpi_inc(&ctx, 3);
  239. ut_asserteq_ptr((void *)67, ctx.current);
  240. acpi_inc_align(&ctx, 3);
  241. ut_asserteq_ptr((void *)80, ctx.current);
  242. return 0;
  243. }
  244. DM_TEST(dm_test_acpi_basic, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  245. /* Test acpi_setup_base_tables */
  246. static int dm_test_acpi_setup_base_tables(struct unit_test_state *uts)
  247. {
  248. struct acpi_rsdp *rsdp;
  249. struct acpi_rsdt *rsdt;
  250. struct acpi_xsdt *xsdt;
  251. struct acpi_ctx ctx;
  252. void *buf, *end;
  253. /*
  254. * Use an unaligned address deliberately, by allocating an aligned
  255. * address and then adding 4 to it
  256. */
  257. buf = memalign(64, BUF_SIZE);
  258. ut_assertnonnull(buf);
  259. acpi_setup_base_tables(&ctx, buf + 4);
  260. ut_asserteq(map_to_sysmem(PTR_ALIGN(buf + 4, 16)), gd->arch.acpi_start);
  261. rsdp = buf + 16;
  262. ut_asserteq_ptr(rsdp, ctx.rsdp);
  263. ut_asserteq_mem(RSDP_SIG, rsdp->signature, sizeof(rsdp->signature));
  264. ut_asserteq(sizeof(*rsdp), rsdp->length);
  265. ut_assertok(table_compute_checksum(rsdp, 20));
  266. ut_assertok(table_compute_checksum(rsdp, sizeof(*rsdp)));
  267. rsdt = PTR_ALIGN((void *)rsdp + sizeof(*rsdp), 16);
  268. ut_asserteq_ptr(rsdt, ctx.rsdt);
  269. ut_asserteq_mem("RSDT", rsdt->header.signature, ACPI_NAME_LEN);
  270. ut_asserteq(sizeof(*rsdt), rsdt->header.length);
  271. ut_assertok(table_compute_checksum(rsdt, sizeof(*rsdt)));
  272. xsdt = PTR_ALIGN((void *)rsdt + sizeof(*rsdt), 16);
  273. ut_asserteq_ptr(xsdt, ctx.xsdt);
  274. ut_asserteq_mem("XSDT", xsdt->header.signature, ACPI_NAME_LEN);
  275. ut_asserteq(sizeof(*xsdt), xsdt->header.length);
  276. ut_assertok(table_compute_checksum(xsdt, sizeof(*xsdt)));
  277. end = PTR_ALIGN((void *)xsdt + sizeof(*xsdt), 64);
  278. ut_asserteq_ptr(end, ctx.current);
  279. ut_asserteq(map_to_sysmem(rsdt), rsdp->rsdt_address);
  280. ut_asserteq(map_to_sysmem(xsdt), rsdp->xsdt_address);
  281. return 0;
  282. }
  283. DM_TEST(dm_test_acpi_setup_base_tables,
  284. DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  285. /* Test 'acpi list' command */
  286. static int dm_test_acpi_cmd_list(struct unit_test_state *uts)
  287. {
  288. struct acpi_ctx ctx;
  289. ulong addr;
  290. void *buf;
  291. buf = memalign(16, BUF_SIZE);
  292. ut_assertnonnull(buf);
  293. acpi_setup_base_tables(&ctx, buf);
  294. ut_assertok(acpi_write_dev_tables(&ctx));
  295. console_record_reset();
  296. run_command("acpi list", 0);
  297. addr = (ulong)map_to_sysmem(buf);
  298. ut_assert_nextline("ACPI tables start at %lx", addr);
  299. ut_assert_nextline("RSDP %08lx %06lx (v02 U-BOOT)", addr,
  300. sizeof(struct acpi_rsdp));
  301. addr = ALIGN(addr + sizeof(struct acpi_rsdp), 16);
  302. ut_assert_nextline("RSDT %08lx %06lx (v01 U-BOOT U-BOOTBL %u INTL 0)",
  303. addr, sizeof(struct acpi_table_header) +
  304. 3 * sizeof(u32), U_BOOT_BUILD_DATE);
  305. addr = ALIGN(addr + sizeof(struct acpi_rsdt), 16);
  306. ut_assert_nextline("XSDT %08lx %06lx (v01 U-BOOT U-BOOTBL %u INTL 0)",
  307. addr, sizeof(struct acpi_table_header) +
  308. 3 * sizeof(u64), U_BOOT_BUILD_DATE);
  309. addr = ALIGN(addr + sizeof(struct acpi_xsdt), 64);
  310. ut_assert_nextline("DMAR %08lx %06lx (v01 U-BOOT U-BOOTBL %u INTL 0)",
  311. addr, sizeof(struct acpi_dmar), U_BOOT_BUILD_DATE);
  312. addr = ALIGN(addr + sizeof(struct acpi_dmar), 16);
  313. ut_assert_nextline("DMAR %08lx %06lx (v01 U-BOOT U-BOOTBL %u INTL 0)",
  314. addr, sizeof(struct acpi_dmar), U_BOOT_BUILD_DATE);
  315. addr = ALIGN(addr + sizeof(struct acpi_dmar), 16);
  316. ut_assert_nextline("DMAR %08lx %06lx (v01 U-BOOT U-BOOTBL %u INTL 0)",
  317. addr, sizeof(struct acpi_dmar), U_BOOT_BUILD_DATE);
  318. ut_assert_console_end();
  319. return 0;
  320. }
  321. DM_TEST(dm_test_acpi_cmd_list, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  322. /* Test 'acpi dump' command */
  323. static int dm_test_acpi_cmd_dump(struct unit_test_state *uts)
  324. {
  325. struct acpi_ctx ctx;
  326. ulong addr;
  327. void *buf;
  328. buf = memalign(16, BUF_SIZE);
  329. ut_assertnonnull(buf);
  330. acpi_setup_base_tables(&ctx, buf);
  331. ut_assertok(acpi_write_dev_tables(&ctx));
  332. /* First search for a non-existent table */
  333. console_record_reset();
  334. run_command("acpi dump rdst", 0);
  335. ut_assert_nextline("Table 'RDST' not found");
  336. ut_assert_console_end();
  337. /* Now a real table */
  338. console_record_reset();
  339. run_command("acpi dump dmar", 0);
  340. addr = ALIGN(map_to_sysmem(ctx.xsdt) + sizeof(struct acpi_xsdt), 64);
  341. ut_assert_nextline("DMAR @ %08lx", addr);
  342. ut_assert_nextlines_are_dump(0x30);
  343. ut_assert_console_end();
  344. return 0;
  345. }
  346. DM_TEST(dm_test_acpi_cmd_dump, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  347. /* Test acpi_device_path() */
  348. static int dm_test_acpi_device_path(struct unit_test_state *uts)
  349. {
  350. struct testacpi_platdata *plat;
  351. char buf[ACPI_PATH_MAX];
  352. struct udevice *dev, *child;
  353. ut_assertok(uclass_first_device_err(UCLASS_TEST_ACPI, &dev));
  354. ut_assertok(acpi_device_path(dev, buf, sizeof(buf)));
  355. ut_asserteq_str("\\_SB." ACPI_TEST_DEV_NAME, buf);
  356. /* Test running out of space */
  357. buf[5] = '\0';
  358. ut_asserteq(-ENOSPC, acpi_device_path(dev, buf, 5));
  359. ut_asserteq('\0', buf[5]);
  360. /* Test a three-component name */
  361. ut_assertok(device_first_child_err(dev, &child));
  362. ut_assertok(acpi_device_path(child, buf, sizeof(buf)));
  363. ut_asserteq_str("\\_SB." ACPI_TEST_DEV_NAME "." ACPI_TEST_CHILD_NAME,
  364. buf);
  365. /* Test handling of a device which doesn't produce a name */
  366. plat = dev_get_platdata(dev);
  367. plat->no_name = true;
  368. ut_assertok(acpi_device_path(child, buf, sizeof(buf)));
  369. ut_asserteq_str("\\_SB." ACPI_TEST_CHILD_NAME, buf);
  370. /* Test handling of a device which returns an error */
  371. plat = dev_get_platdata(dev);
  372. plat->return_error = true;
  373. ut_asserteq(-EINVAL, acpi_device_path(child, buf, sizeof(buf)));
  374. return 0;
  375. }
  376. DM_TEST(dm_test_acpi_device_path, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  377. /* Test acpi_device_status() */
  378. static int dm_test_acpi_device_status(struct unit_test_state *uts)
  379. {
  380. struct udevice *dev;
  381. ut_assertok(uclass_first_device_err(UCLASS_TEST_ACPI, &dev));
  382. ut_asserteq(ACPI_DSTATUS_ALL_ON, acpi_device_status(dev));
  383. return 0;
  384. }
  385. DM_TEST(dm_test_acpi_device_status, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  386. /* Test acpi_fill_ssdt() */
  387. static int dm_test_acpi_fill_ssdt(struct unit_test_state *uts)
  388. {
  389. struct acpi_ctx ctx;
  390. u8 *buf;
  391. buf = malloc(BUF_SIZE);
  392. ut_assertnonnull(buf);
  393. ctx.current = buf;
  394. buf[4] = 'z'; /* sentinel */
  395. ut_assertok(acpi_fill_ssdt(&ctx));
  396. /*
  397. * These values come from acpi-test2's acpi-ssdt-test-data property.
  398. * This device comes first because of u-boot,acpi-ssdt-order
  399. */
  400. ut_asserteq('c', buf[0]);
  401. ut_asserteq('d', buf[1]);
  402. /* These values come from acpi-test's acpi-ssdt-test-data property */
  403. ut_asserteq('a', buf[2]);
  404. ut_asserteq('b', buf[3]);
  405. ut_asserteq('z', buf[4]);
  406. return 0;
  407. }
  408. DM_TEST(dm_test_acpi_fill_ssdt, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  409. /* Test acpi_inject_dsdt() */
  410. static int dm_test_acpi_inject_dsdt(struct unit_test_state *uts)
  411. {
  412. struct acpi_ctx ctx;
  413. u8 *buf;
  414. buf = malloc(BUF_SIZE);
  415. ut_assertnonnull(buf);
  416. ctx.current = buf;
  417. buf[4] = 'z'; /* sentinel */
  418. ut_assertok(acpi_inject_dsdt(&ctx));
  419. /*
  420. * These values come from acpi-test's acpi-dsdt-test-data property.
  421. * There is no u-boot,acpi-dsdt-order so device-tree order is used.
  422. */
  423. ut_asserteq('h', buf[0]);
  424. ut_asserteq('i', buf[1]);
  425. /* These values come from acpi-test's acpi-dsdt-test-data property */
  426. ut_asserteq('j', buf[2]);
  427. ut_asserteq('k', buf[3]);
  428. ut_asserteq('z', buf[4]);
  429. return 0;
  430. }
  431. DM_TEST(dm_test_acpi_inject_dsdt, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
  432. /* Test 'acpi items' command */
  433. static int dm_test_acpi_cmd_items(struct unit_test_state *uts)
  434. {
  435. struct acpi_ctx ctx;
  436. void *buf;
  437. buf = malloc(BUF_SIZE);
  438. ut_assertnonnull(buf);
  439. ctx.current = buf;
  440. ut_assertok(acpi_fill_ssdt(&ctx));
  441. console_record_reset();
  442. run_command("acpi items", 0);
  443. ut_assert_nextline("dev 'acpi-test', type 1, size 2");
  444. ut_assert_nextline("dev 'acpi-test2', type 1, size 2");
  445. ut_assert_console_end();
  446. ctx.current = buf;
  447. ut_assertok(acpi_inject_dsdt(&ctx));
  448. console_record_reset();
  449. run_command("acpi items", 0);
  450. ut_assert_nextline("dev 'acpi-test', type 2, size 2");
  451. ut_assert_nextline("dev 'acpi-test2', type 2, size 2");
  452. ut_assert_console_end();
  453. console_record_reset();
  454. run_command("acpi items -d", 0);
  455. ut_assert_nextline("dev 'acpi-test', type 2, size 2");
  456. ut_assert_nextlines_are_dump(2);
  457. ut_assert_nextline("%s", "");
  458. ut_assert_nextline("dev 'acpi-test2', type 2, size 2");
  459. ut_assert_nextlines_are_dump(2);
  460. ut_assert_nextline("%s", "");
  461. ut_assert_console_end();
  462. return 0;
  463. }
  464. DM_TEST(dm_test_acpi_cmd_items, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);