Revision 8ac2adf7
b/tests/acpi-test.c | ||
---|---|---|
34 | 34 |
uint32_t *rsdt_tables_addr; |
35 | 35 |
int rsdt_tables_nr; |
36 | 36 |
AcpiSdtTable dsdt_table; |
37 |
AcpiSdtTable *ssdt_tables;
|
|
37 |
GArray *ssdt_tables;
|
|
38 | 38 |
} test_data; |
39 | 39 |
|
40 | 40 |
#define LOW(x) ((x) & 0xff) |
... | ... | |
118 | 118 |
|
119 | 119 |
static const char *disk = "tests/acpi-test-disk.raw"; |
120 | 120 |
|
121 |
static void free_test_data(test_data *data) |
|
122 |
{ |
|
123 |
int i; |
|
124 |
|
|
125 |
g_free(data->rsdt_tables_addr); |
|
126 |
for (i = 0; i < data->ssdt_tables->len; ++i) { |
|
127 |
g_free(g_array_index(data->ssdt_tables, AcpiSdtTable, i).aml); |
|
128 |
} |
|
129 |
g_array_free(data->ssdt_tables, false); |
|
130 |
g_free(data->dsdt_table.aml); |
|
131 |
} |
|
132 |
|
|
121 | 133 |
static uint8_t acpi_checksum(const uint8_t *data, int len) |
122 | 134 |
{ |
123 | 135 |
int i; |
... | ... | |
295 | 307 |
|
296 | 308 |
static void test_acpi_ssdt_tables(test_data *data) |
297 | 309 |
{ |
298 |
AcpiSdtTable *ssdt_tables;
|
|
310 |
GArray *ssdt_tables;
|
|
299 | 311 |
int ssdt_tables_nr = data->rsdt_tables_nr - 1; /* fadt is first */ |
300 | 312 |
int i; |
301 | 313 |
|
302 |
ssdt_tables = g_new0(AcpiSdtTable, ssdt_tables_nr); |
|
314 |
ssdt_tables = g_array_sized_new(false, true, sizeof(AcpiSdtTable), |
|
315 |
ssdt_tables_nr); |
|
303 | 316 |
for (i = 0; i < ssdt_tables_nr; i++) { |
304 |
AcpiSdtTable *ssdt_table = &ssdt_tables[i];
|
|
317 |
AcpiSdtTable ssdt_table;
|
|
305 | 318 |
uint32_t addr = data->rsdt_tables_addr[i + 1]; /* fadt is first */ |
306 |
|
|
307 |
test_dst_table(ssdt_table, addr);
|
|
319 |
test_dst_table(&ssdt_table, addr); |
|
320 |
g_array_append_val(ssdt_tables, ssdt_table);
|
|
308 | 321 |
} |
309 | 322 |
data->ssdt_tables = ssdt_tables; |
310 | 323 |
} |
311 | 324 |
|
312 |
static void test_acpi_one(const char *params) |
|
325 |
static void test_acpi_one(const char *params, test_data *data)
|
|
313 | 326 |
{ |
314 | 327 |
char *args; |
315 | 328 |
uint8_t signature_low; |
316 | 329 |
uint8_t signature_high; |
317 | 330 |
uint16_t signature; |
318 | 331 |
int i; |
319 |
test_data data; |
|
320 | 332 |
|
321 |
memset(&data, 0, sizeof(data));
|
|
333 |
memset(data, 0, sizeof(*data));
|
|
322 | 334 |
args = g_strdup_printf("-net none -display none %s %s", |
323 | 335 |
params ? params : "", disk); |
324 | 336 |
qtest_start(args); |
... | ... | |
342 | 354 |
} |
343 | 355 |
g_assert_cmphex(signature, ==, SIGNATURE); |
344 | 356 |
|
345 |
test_acpi_rsdp_address(&data);
|
|
346 |
test_acpi_rsdp_table(&data);
|
|
347 |
test_acpi_rsdt_table(&data);
|
|
348 |
test_acpi_fadt_table(&data);
|
|
357 |
test_acpi_rsdp_address(data); |
|
358 |
test_acpi_rsdp_table(data); |
|
359 |
test_acpi_rsdt_table(data); |
|
360 |
test_acpi_fadt_table(data); |
|
349 | 361 |
test_acpi_facs_table(data); |
350 |
test_acpi_dsdt_table(&data); |
|
351 |
test_acpi_ssdt_tables(&data); |
|
352 |
|
|
353 |
g_free(data.rsdt_tables_addr); |
|
354 |
for (i = 0; i < (data.rsdt_tables_nr - 1); ++i) { |
|
355 |
g_free(data.ssdt_tables[i].aml); |
|
356 |
} |
|
357 |
g_free(data.ssdt_tables); |
|
358 |
g_free(data.dsdt_table.aml); |
|
362 |
test_acpi_dsdt_table(data); |
|
363 |
test_acpi_ssdt_tables(data); |
|
359 | 364 |
|
360 | 365 |
qtest_quit(global_qtest); |
361 | 366 |
g_free(args); |
... | ... | |
363 | 368 |
|
364 | 369 |
static void test_acpi_tcg(void) |
365 | 370 |
{ |
371 |
test_data data; |
|
372 |
|
|
366 | 373 |
/* Supplying -machine accel argument overrides the default (qtest). |
367 | 374 |
* This is to make guest actually run. |
368 | 375 |
*/ |
369 |
test_acpi_one("-machine accel=tcg"); |
|
376 |
test_acpi_one("-machine accel=tcg", &data); |
|
377 |
|
|
378 |
free_test_data(&data); |
|
370 | 379 |
} |
371 | 380 |
|
372 | 381 |
int main(int argc, char *argv[]) |
Also available in: Unified diff