* [Qemu-devel] [PATCH v2 0/3] acpi unit-test: compare resulting aml vs expected aml
@ 2013-12-23 10:13 Marcel Apfelbaum
2013-12-23 10:13 ` [Qemu-devel] [PATCH v2 1/3] acpi unit-test: add test files Marcel Apfelbaum
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Marcel Apfelbaum @ 2013-12-23 10:13 UTC (permalink / raw)
To: qemu-devel; +Cc: mst
The test:
- runs only if iasl is installed on the host machine.
- the test plan:
1. Dumps the ACPI tables as AML on the disk.
2. Runs iasl to disassembly the tables into ASL files.
3. Runs iasl to disassembly the offline AML files.
3. Compares them with expected offline ASL files.
- the test runs for both default machine and q35.
- in case the test fails, it can be easily tweaked to
show the differences between the ASL files and
understand the issue.
Patches:
1/3 - expected aml files
2/3 - creates links for the expected files
if the build directory is not current
3/3 - the test
Marcel Apfelbaum (3):
acpi unit-test: add test files
configure: added acpi unit-test files
acpi unit-test: compare DSDT and SSDT tables against expected values
configure | 4 +
tests/acpi-test-data/pc/APIC | Bin 0 -> 120 bytes
tests/acpi-test-data/pc/DSDT | Bin 0 -> 4407 bytes
tests/acpi-test-data/pc/FACP | Bin 0 -> 116 bytes
tests/acpi-test-data/pc/FACS | Bin 0 -> 64 bytes
tests/acpi-test-data/pc/HPET | Bin 0 -> 56 bytes
tests/acpi-test-data/pc/SSDT | Bin 0 -> 2104 bytes
tests/acpi-test-data/q35/APIC | Bin 0 -> 120 bytes
tests/acpi-test-data/q35/DSDT | Bin 0 -> 7344 bytes
tests/acpi-test-data/q35/FACP | Bin 0 -> 116 bytes
tests/acpi-test-data/q35/FACS | Bin 0 -> 64 bytes
tests/acpi-test-data/q35/HPET | Bin 0 -> 56 bytes
tests/acpi-test-data/q35/MCFG | Bin 0 -> 60 bytes
tests/acpi-test-data/q35/SSDT | Bin 0 -> 2104 bytes
tests/acpi-test.c | 257 ++++++++++++++++++++++++++++++++++++++----
15 files changed, 240 insertions(+), 21 deletions(-)
create mode 100644 tests/acpi-test-data/pc/APIC
create mode 100644 tests/acpi-test-data/pc/DSDT
create mode 100644 tests/acpi-test-data/pc/FACP
create mode 100644 tests/acpi-test-data/pc/FACS
create mode 100644 tests/acpi-test-data/pc/HPET
create mode 100644 tests/acpi-test-data/pc/SSDT
create mode 100644 tests/acpi-test-data/q35/APIC
create mode 100644 tests/acpi-test-data/q35/DSDT
create mode 100644 tests/acpi-test-data/q35/FACP
create mode 100644 tests/acpi-test-data/q35/FACS
create mode 100644 tests/acpi-test-data/q35/HPET
create mode 100644 tests/acpi-test-data/q35/MCFG
create mode 100644 tests/acpi-test-data/q35/SSDT
--
1.8.3.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH v2 1/3] acpi unit-test: add test files
2013-12-23 10:13 [Qemu-devel] [PATCH v2 0/3] acpi unit-test: compare resulting aml vs expected aml Marcel Apfelbaum
@ 2013-12-23 10:13 ` Marcel Apfelbaum
2013-12-23 10:13 ` [Qemu-devel] [PATCH v2 2/3] configure: added acpi unit-test files Marcel Apfelbaum
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Marcel Apfelbaum @ 2013-12-23 10:13 UTC (permalink / raw)
To: qemu-devel; +Cc: mst
Added unit-test's expected aml files to be compared
with the actual ACPI tables.
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
tests/acpi-test-data/pc/APIC | Bin 0 -> 120 bytes
tests/acpi-test-data/pc/DSDT | Bin 0 -> 4407 bytes
tests/acpi-test-data/pc/FACP | Bin 0 -> 116 bytes
tests/acpi-test-data/pc/FACS | Bin 0 -> 64 bytes
tests/acpi-test-data/pc/HPET | Bin 0 -> 56 bytes
tests/acpi-test-data/pc/SSDT | Bin 0 -> 2104 bytes
tests/acpi-test-data/q35/APIC | Bin 0 -> 120 bytes
tests/acpi-test-data/q35/DSDT | Bin 0 -> 7344 bytes
tests/acpi-test-data/q35/FACP | Bin 0 -> 116 bytes
tests/acpi-test-data/q35/FACS | Bin 0 -> 64 bytes
tests/acpi-test-data/q35/HPET | Bin 0 -> 56 bytes
tests/acpi-test-data/q35/MCFG | Bin 0 -> 60 bytes
tests/acpi-test-data/q35/SSDT | Bin 0 -> 2104 bytes
13 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 tests/acpi-test-data/pc/APIC
create mode 100644 tests/acpi-test-data/pc/DSDT
create mode 100644 tests/acpi-test-data/pc/FACP
create mode 100644 tests/acpi-test-data/pc/FACS
create mode 100644 tests/acpi-test-data/pc/HPET
create mode 100644 tests/acpi-test-data/pc/SSDT
create mode 100644 tests/acpi-test-data/q35/APIC
create mode 100644 tests/acpi-test-data/q35/DSDT
create mode 100644 tests/acpi-test-data/q35/FACP
create mode 100644 tests/acpi-test-data/q35/FACS
create mode 100644 tests/acpi-test-data/q35/HPET
create mode 100644 tests/acpi-test-data/q35/MCFG
create mode 100644 tests/acpi-test-data/q35/SSDT
diff --git a/tests/acpi-test-data/pc/APIC b/tests/acpi-test-data/pc/APIC
new file mode 100644
index 0000000000000000000000000000000000000000..84509e0ae4cabeb5ead3e42a4edfa50abddbc17d
GIT binary patch
literal 120
zcmZ<^@N}+VU|?W;>*Vk35v<@85#a0y6k`O6f!H9Lf#JbFFwFr}2jnsGfW!{`1CdNz
hKn!AlSgfo-nis_4<b<)ffC?aD+}vOm3)_F75db|X4FLcE
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/pc/DSDT b/tests/acpi-test-data/pc/DSDT
new file mode 100644
index 0000000000000000000000000000000000000000..b12e5eb85bb22f27fe10ce0fcf1d9a71f38360eb
GIT binary patch
literal 4407
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
TLKSsYG*scK!dFF86`Sxs!<!O4
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/pc/FACP b/tests/acpi-test-data/pc/FACP
new file mode 100644
index 0000000000000000000000000000000000000000..0639999ed1f748d44977f88e63d6a0ab49add040
GIT binary patch
literal 116
zcmZ>BbPgzCU|?Xp>E!S15v<@85#a0w6k`O6f!H9L;lclU2Owr-;AGeY<bM1BBsPE~
l7#LWfG>FXsWItFBVgbdO7+6?<^nd>U{9pknv9y7K0RZCI76AYN
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/pc/FACS b/tests/acpi-test-data/pc/FACS
new file mode 100644
index 0000000000000000000000000000000000000000..fc67ecc40782bd7fe8921e430d7de67f0bfaad93
GIT binary patch
literal 64
PcmZ>BbPjf4ARhn#RKNjV
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/pc/HPET b/tests/acpi-test-data/pc/HPET
new file mode 100644
index 0000000000000000000000000000000000000000..df689b8f99c1c43cfd7d63bdede3bcdfd23b7de1
GIT binary patch
literal 56
xcmeYWa1F6wU|?WmcJg=j2v%^42ypfQiZKGkKx`1rxTviGNCClxe-N610RT2D3IPBB
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/pc/SSDT b/tests/acpi-test-data/pc/SSDT
new file mode 100644
index 0000000000000000000000000000000000000000..5ab1b96af004737738f3386e73e4dc1d425ab77e
GIT binary patch
literal 2104
zcmZvc%TC)s6o$vSVVs*23<>wHDs@$dJG(lzDW**_#D-D@X|kyVi%M*}qf}+Xk{6&-
z-lK0;dL}vlf_AdWcV<2v|DK#onnu}yErext2jOx0s(T^Bl-4XEgl7Hic8iz7mVT-#
zRNWHAs`C8&`;RR<=gOh2PO2JZhuX|Ov=INh@bSfh`-VEIbXzq`1&f|RyrY_S!O1zf
zX|=0&bT{{1<??M_rClY%#81*djqZAmjL$P$9Vb!sH13`GzTcq~ahjEd7~RTvFtl`K
zjlP$;keThZRhk9jM(>QDN{?eP5x)u(r|#8;k<9dl%*K<kSNSxQnRRoeYg>iGv{7}O
z_xdF0n7)Yzz2xMQL9ai<0^tR9Px{HMyWW~UMsK)3zX~0H^rKr0rSI!D^omKO^wCY<
zAqZtc@31ety6Od)n1r$yXn|@Snd&s-IzI8OP{t>^yz)Y;pB;V9J(VA?9C5GPU)!M^
z^qUbybsxS6eQ2Y**Qwu8bjD|W$Ffxr4e5up=xNkUSrZw?Cwgz{ZLybwmot0Y?B(I*
zb$XrdWxpNv3h)YMZ<oCyyrS9LW3L3SWcK#in}auJ_72#y;n`;IkiB_$^JXt#&w=Nd
zy)JuYcxAH}vR8puF?$hvRd`ji7qeG`S2KG@?A77bjb6uR&xPljJ<MMNUc>BR{+jTb
zW)JhX0B^zUVg5XLp4r3vEy7zgdzil^cuQsv^VfpcGJBZ6HoUgk!~8A7TQ+-`zZG~Z
zW)JhX3UAfyVgA<Ot(iT{-#WZ?vxoWHfVW}xFn^oyHvjXy4=ow?v)S!u-RnE<dU_M)
zh_{&Y#M{gT;vME9@h)?Tc#nCGc%RuOK46|FK4f-?1LiVum$^b5GFOQs<{EL#Tqiza
zcJEXA|I9Ksh>^cZjQk74$nOy&{~|H+FA*buix~Oa#K^x)jQlIa$iGUA{A<L>zfO$&
M8^p-JNlf|w0)H3)9{>OV
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/q35/APIC b/tests/acpi-test-data/q35/APIC
new file mode 100644
index 0000000000000000000000000000000000000000..84509e0ae4cabeb5ead3e42a4edfa50abddbc17d
GIT binary patch
literal 120
zcmZ<^@N}+VU|?W;>*Vk35v<@85#a0y6k`O6f!H9Lf#JbFFwFr}2jnsGfW!{`1CdNz
hKn!AlSgfo-nis_4<b<)ffC?aD+}vOm3)_F75db|X4FLcE
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/q35/DSDT b/tests/acpi-test-data/q35/DSDT
new file mode 100644
index 0000000000000000000000000000000000000000..59243b952d78c465298e0a2ec05a52f480dd92fb
GIT binary patch
literal 7344
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
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/q35/FACP b/tests/acpi-test-data/q35/FACP
new file mode 100644
index 0000000000000000000000000000000000000000..19f3ac3ce6ab732caa750d835ce1261bc7343cf2
GIT binary patch
literal 116
zcmZ>BbPgzCU|?YEaPoKd2v%^42yk`-iZKGkKx`1raN&Qw0}wMZa58KHa+#Qc#0HQA
i0|N_`2C+GSYz3G&69bC?Q0zbde}0f03@mM6U;qFojS~R?
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/q35/FACS b/tests/acpi-test-data/q35/FACS
new file mode 100644
index 0000000000000000000000000000000000000000..fc67ecc40782bd7fe8921e430d7de67f0bfaad93
GIT binary patch
literal 64
PcmZ>BbPjf4ARhn#RKNjV
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/q35/HPET b/tests/acpi-test-data/q35/HPET
new file mode 100644
index 0000000000000000000000000000000000000000..df689b8f99c1c43cfd7d63bdede3bcdfd23b7de1
GIT binary patch
literal 56
xcmeYWa1F6wU|?WmcJg=j2v%^42ypfQiZKGkKx`1rxTviGNCClxe-N610RT2D3IPBB
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/q35/MCFG b/tests/acpi-test-data/q35/MCFG
new file mode 100644
index 0000000000000000000000000000000000000000..79ceb27a038c6e29d098b98dda2e229495f96b7c
GIT binary patch
literal 60
rcmeZuc5}C3U|?W;@8s|75v<@85#a0#6k`O6f!H7#32cC}|AS}%SE304
literal 0
HcmV?d00001
diff --git a/tests/acpi-test-data/q35/SSDT b/tests/acpi-test-data/q35/SSDT
new file mode 100644
index 0000000000000000000000000000000000000000..186e748e6c16ffef80634be5eae9c3fa17210811
GIT binary patch
literal 2104
zcmZvc%Wl&^6o$vS)pc%8>Ne?}6%s3)-n+xGUFt%TY3!DwRGMs%+67X#?4XEly6g)S
zDenOrUW;-jIsXEfZ1SC%PshI}CzGa8c3=x({pt?F<MdhgLWU`=SwaZS`rGXmFNH1r
zR8^?@NffKf)6<XNw(OiMhqgMYYLp#nGyBj&{O`iszZTpV)KR6|s#z*n^bF!1)wBza
zaHs`UyLv}=b6-_1U*=WXRWeNcBn{N)w&%$BJhRnt5>-#*-kI<F9ZC_WSy_nDXBiKM
zmaeSPmogVJv%R)Tvq0SFo$+JoVJs%%dtu_#z1lF6nck4ucrx}X?}jq7Zmx7~t8kb$
zs*dwopM<ciPvTxLIk{xe>(8)2ctPEhelqK>x2BKL8}7G{LdPF{?G{7n`??LiViGBR
zbklbTLYdGz><h21dO;>8q3i`(pjt<!I?cF_Pkbws@rf?4ywK`rNAGiw<%cUr-0Ak$
zb|?q^W<*il`wv1N+UWLq>UR{K>RI2hY!yU9`XMcP8Z}eaM27K+-kW+`?B(F)%-%M8
zd3brVx5HimUcv0`vR8yxG<$pOmEe`k-adPC@aD|k0edz)+w2{(HxF;#>;>#O@Eo((
zWv>jcZ1zI-D)1_1FJi9>uWI&U_G<8IX77l-I=s5k>-g-s@LaQp`D?&ym_5v26JFEo
zVg452Etoybp9jw~dzimPc#CEa^S1<V$?ReNTJTzC5A)ZC*EV~Yzh!vKW)JhX0&m6a
zVg6R(t(rZ|-x|C%vxoUxhqrF_Fn=5HHq0L8Zxi0;f1dZICBuF;yZx*?eaBr-Z^9h$
z7IU6>o4G)|!(1fZWiAo#G0ze2Guy-m%=5&D%notDTqf=^SBOLADsjYIBaWHt#7E5T
zT}uC-S>^^Y@;8Z*e}NeJJ!0fvBu4%vV&rcTBY&G1`Im{2e}x$NSBa5-jTrgYiIIPU
K82LAeDgPgv$^jn$
literal 0
HcmV?d00001
--
1.8.3.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH v2 2/3] configure: added acpi unit-test files
2013-12-23 10:13 [Qemu-devel] [PATCH v2 0/3] acpi unit-test: compare resulting aml vs expected aml Marcel Apfelbaum
2013-12-23 10:13 ` [Qemu-devel] [PATCH v2 1/3] acpi unit-test: add test files Marcel Apfelbaum
@ 2013-12-23 10:13 ` Marcel Apfelbaum
2013-12-23 10:13 ` [Qemu-devel] [PATCH v2 3/3] acpi unit-test: compare DSDT and SSDT tables against expected values Marcel Apfelbaum
2013-12-23 12:02 ` [Qemu-devel] [PATCH v2 0/3] acpi unit-test: compare resulting aml vs expected aml Michael S. Tsirkin
3 siblings, 0 replies; 10+ messages in thread
From: Marcel Apfelbaum @ 2013-12-23 10:13 UTC (permalink / raw)
To: qemu-devel; +Cc: mst
Ensure configure will set-up links for the files
if the build is created in other directory.
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
configure | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/configure b/configure
index edfea95..c30be12 100755
--- a/configure
+++ b/configure
@@ -4744,6 +4744,10 @@ for bios_file in \
do
FILES="$FILES pc-bios/`basename $bios_file`"
done
+for test_file in `find $source_path/tests/acpi-test-data -type f`
+do
+ FILES="$FILES tests/acpi-test-data`echo $test_file | sed -e 's/.*acpi-test-data//'`"
+done
mkdir -p $DIRS
for f in $FILES ; do
if [ -e "$source_path/$f" ] && [ "$source_path" != `pwd` ]; then
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH v2 3/3] acpi unit-test: compare DSDT and SSDT tables against expected values
2013-12-23 10:13 [Qemu-devel] [PATCH v2 0/3] acpi unit-test: compare resulting aml vs expected aml Marcel Apfelbaum
2013-12-23 10:13 ` [Qemu-devel] [PATCH v2 1/3] acpi unit-test: add test files Marcel Apfelbaum
2013-12-23 10:13 ` [Qemu-devel] [PATCH v2 2/3] configure: added acpi unit-test files Marcel Apfelbaum
@ 2013-12-23 10:13 ` Marcel Apfelbaum
2013-12-23 12:06 ` Michael S. Tsirkin
2013-12-23 12:02 ` [Qemu-devel] [PATCH v2 0/3] acpi unit-test: compare resulting aml vs expected aml Michael S. Tsirkin
3 siblings, 1 reply; 10+ messages in thread
From: Marcel Apfelbaum @ 2013-12-23 10:13 UTC (permalink / raw)
To: qemu-devel; +Cc: mst
This test will run only if iasl is installed on the host machine.
The test plan:
1. Dumps the ACPI tables as AML on the disk.
2. Runs iasl to disassembly the tables into ASL files.
3. Runs iasl to disassembly the offline AML files into ASL files.
4. Compares the ASL files.
The test runs for both default machine and q35.
In case the test fails, it can be easily tweaked to
show the differences between the ASL files and
understand the issue.
Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
---
tests/acpi-test.c | 257 +++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 236 insertions(+), 21 deletions(-)
diff --git a/tests/acpi-test.c b/tests/acpi-test.c
index ca83b1d..4f0cca6 100644
--- a/tests/acpi-test.c
+++ b/tests/acpi-test.c
@@ -18,14 +18,22 @@
#include "qemu/compiler.h"
#include "hw/i386/acpi-defs.h"
+#define MACHINE_PC "pc"
+#define MACHINE_Q35 "q35"
+
/* DSDT and SSDTs format */
typedef struct {
AcpiTableHeader header;
- uint8_t *aml;
- int aml_len;
-} AcpiSdtTable;
+ gchar *aml; /* aml bytecode from guest */
+ gsize aml_len;
+ gchar *aml_file;
+ gchar *asl; /* asl code generated from aml */
+ gsize asl_len;
+ gchar *asl_file;
+} QEMU_PACKED AcpiSdtTable;
typedef struct {
+ const char *machine;
uint32_t rsdp_addr;
AcpiRsdpDescriptor rsdp_table;
AcpiRsdtDescriptorRev1 rsdt_table;
@@ -33,8 +41,7 @@ typedef struct {
AcpiFacsDescriptorRev1 facs_table;
uint32_t *rsdt_tables_addr;
int rsdt_tables_nr;
- AcpiSdtTable dsdt_table;
- GArray *ssdt_tables;
+ GArray *ssdt_tables; /* first is DSDT */
} test_data;
#define LOW(x) ((x) & 0xff)
@@ -91,8 +98,10 @@ typedef struct {
/* Boot sector code: write SIGNATURE into memory,
* then halt.
+ * Q35 machine requires a minimum 0x7e000 bytes disk.
+ * (bug or feature?)
*/
-static uint8_t boot_sector[0x200] = {
+static uint8_t boot_sector[0x7e000] = {
/* 7c00: mov $0xdead,%ax */
[0x00] = 0xb8,
[0x01] = LOW(SIGNATURE),
@@ -117,17 +126,40 @@ static uint8_t boot_sector[0x200] = {
};
static const char *disk = "tests/acpi-test-disk.raw";
+static const char *data_dir = "tests/acpi-test-data";
static void free_test_data(test_data *data)
{
+ AcpiSdtTable *temp;
int i;
- g_free(data->rsdt_tables_addr);
+ if (data->rsdt_tables_addr) {
+ g_free(data->rsdt_tables_addr);
+ }
+
for (i = 0; i < data->ssdt_tables->len; ++i) {
- g_free(g_array_index(data->ssdt_tables, AcpiSdtTable, i).aml);
+ temp = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
+ if (temp->aml) {
+ g_free(temp->aml);
+ }
+ if (temp->aml_file) {
+ if (g_strstr_len(temp->aml_file, -1, "aml-")) {
+ unlink(temp->aml_file);
+ }
+ g_free(temp->aml_file);
+ }
+ if (temp->asl) {
+ g_free(temp->asl);
+ }
+ if (temp->asl_file) {
+ if (g_strstr_len(temp->asl_file, -1, "asl-")) {
+ unlink(temp->asl_file);
+ }
+ g_free(temp->asl_file);
+ }
}
+
g_array_free(data->ssdt_tables, false);
- g_free(data->dsdt_table.aml);
}
static uint8_t acpi_checksum(const uint8_t *data, int len)
@@ -292,34 +324,203 @@ static void test_dst_table(AcpiSdtTable *sdt_table, uint32_t addr)
ACPI_READ_ARRAY_PTR(sdt_table->aml, sdt_table->aml_len, addr);
checksum = acpi_checksum((uint8_t *)sdt_table, sizeof(AcpiTableHeader)) +
- acpi_checksum(sdt_table->aml, sdt_table->aml_len);
+ acpi_checksum((uint8_t *)sdt_table->aml, sdt_table->aml_len);
g_assert(!checksum);
}
static void test_acpi_dsdt_table(test_data *data)
{
- AcpiSdtTable *dsdt_table = &data->dsdt_table;
+ AcpiSdtTable dsdt_table;
uint32_t addr = data->fadt_table.dsdt;
- test_dst_table(dsdt_table, addr);
- g_assert_cmphex(dsdt_table->header.signature, ==, ACPI_DSDT_SIGNATURE);
+ memset(&dsdt_table, 0, sizeof(dsdt_table));
+ data->ssdt_tables = g_array_new(false, true, sizeof(AcpiSdtTable));
+
+ test_dst_table(&dsdt_table, addr);
+ g_assert_cmphex(dsdt_table.header.signature, ==, ACPI_DSDT_SIGNATURE);
+
+ /* Place DSDT first */
+ g_array_append_val(data->ssdt_tables, dsdt_table);
}
static void test_acpi_ssdt_tables(test_data *data)
{
- GArray *ssdt_tables;
int ssdt_tables_nr = data->rsdt_tables_nr - 1; /* fadt is first */
int i;
- ssdt_tables = g_array_sized_new(false, true, sizeof(AcpiSdtTable),
- ssdt_tables_nr);
for (i = 0; i < ssdt_tables_nr; i++) {
AcpiSdtTable ssdt_table;
+
+ memset(&ssdt_table, 0 , sizeof(ssdt_table));
uint32_t addr = data->rsdt_tables_addr[i + 1]; /* fadt is first */
test_dst_table(&ssdt_table, addr);
- g_array_append_val(ssdt_tables, ssdt_table);
+ g_array_append_val(data->ssdt_tables, ssdt_table);
+ }
+}
+
+static bool iasl_installed(void)
+{
+ gchar *out = NULL, *out_err = NULL;
+ bool ret;
+
+ /* pass 'out' and 'out_err' in order to be redirected */
+ ret = g_spawn_command_line_sync("iasl", &out, &out_err, NULL, NULL);
+
+ if (out_err) {
+ ret = ret && (out_err[0] == '\0');
+ g_free(out_err);
}
- data->ssdt_tables = ssdt_tables;
+
+ if (out) {
+ g_free(out);
+ }
+
+ return ret;
+}
+
+static void dump_aml_files(test_data *data)
+{
+ AcpiSdtTable *sdt;
+ GError *error = NULL;
+ gint fd;
+ int i;
+
+ for (i = 0; i < data->ssdt_tables->len; ++i) {
+ sdt = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
+ g_assert(sdt->aml);
+
+ fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error);
+ g_assert_no_error(error);
+
+ write(fd, sdt, sizeof(AcpiTableHeader));
+ write(fd, sdt->aml, sdt->aml_len);
+ close(fd);
+ }
+}
+
+static void load_asl(GArray *sdts, AcpiSdtTable *sdt)
+{
+ AcpiSdtTable *temp;
+ GError *error = NULL;
+ GString *command_line = g_string_new("'iasl' ");
+ gint fd;
+ gchar *out, *out_err;
+ gboolean ret;
+ int i;
+
+ fd = g_file_open_tmp("asl-XXXXXX.dsl", &sdt->asl_file, &error);
+ g_assert_no_error(error);
+ close(fd);
+
+ /* build command line */
+ g_string_append_printf(command_line, "-p %s ", sdt->asl_file);
+ for (i = 0; i < 2; ++i) { /* reference DSDT and SSDT */
+ temp = &g_array_index(sdts, AcpiSdtTable, i);
+ g_string_append_printf(command_line, "-e %s ", temp->aml_file);
+ }
+ g_string_append_printf(command_line, "-d %s", sdt->aml_file);
+
+ /* pass 'out' and 'out_err' in order to be redirected */
+ g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error);
+ g_assert_no_error(error);
+
+ ret = g_file_get_contents(sdt->asl_file, (gchar **)&sdt->asl,
+ &sdt->asl_len, &error);
+ g_assert(ret);
+ g_assert_no_error(error);
+ g_assert(sdt->asl_len);
+
+ g_free(out);
+ g_free(out_err);
+ g_string_free(command_line, true);
+}
+
+#define COMMENT_END "*/"
+#define DEF_BLOCK "DefinitionBlock ("
+#define BLOCK_NAME_END ".aml"
+
+static GString *normalize_asl(gchar *asl_code)
+{
+ GString *asl = g_string_new(asl_code);
+ gchar *comment, *block_name;
+
+ /* strip comments (different generation days) */
+ comment = g_strstr_len(asl->str, asl->len, COMMENT_END);
+ if (comment) {
+ asl = g_string_erase(asl, 0, comment + sizeof(COMMENT_END) - asl->str);
+ }
+
+ /* strip def block name (it has file path in it) */
+ if (g_str_has_prefix(asl->str, DEF_BLOCK)) {
+ block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);
+ g_assert(block_name);
+ asl = g_string_erase(asl, 0,
+ block_name + sizeof(BLOCK_NAME_END) - asl->str);
+ }
+
+ return asl;
+}
+
+static GArray *load_expected_aml(test_data *data)
+{
+ int i;
+ AcpiSdtTable *sdt;
+ gchar *aml_file;
+ GError *error = NULL;
+ gboolean ret;
+
+ GArray *exp_ssdt_tables = g_array_new(false, true, sizeof(AcpiSdtTable));
+ for (i = 0; i < data->ssdt_tables->len; ++i) {
+ AcpiSdtTable exp_sdt;
+ sdt = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
+
+ memset(&exp_sdt, 0, sizeof(exp_sdt));
+ exp_sdt.header.signature = sdt->header.signature;
+
+ aml_file = g_strdup_printf("%s/%s/%.4s", data_dir, data->machine,
+ (gchar *)&exp_sdt.header.signature);
+ exp_sdt.aml_file = aml_file;
+ g_assert(g_file_test(aml_file, G_FILE_TEST_EXISTS));
+ ret = g_file_get_contents(aml_file, &exp_sdt.aml,
+ &exp_sdt.aml_len, &error);
+ g_assert(ret);
+ g_assert_no_error(error);
+ g_assert(exp_sdt.aml);
+ g_assert(exp_sdt.aml_len);
+
+ g_array_append_val(exp_ssdt_tables, exp_sdt);
+ }
+
+ return exp_ssdt_tables;
+}
+
+static void test_acpi_asl(test_data *data)
+{
+ int i;
+ AcpiSdtTable *sdt, *exp_sdt;
+ test_data exp_data;
+
+ memset(&exp_data, 0, sizeof(exp_data));
+ exp_data.ssdt_tables = load_expected_aml(data);
+ dump_aml_files(data);
+ for (i = 0; i < data->ssdt_tables->len; ++i) {
+ GString *asl, *exp_asl;
+
+ sdt = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
+ exp_sdt = &g_array_index(exp_data.ssdt_tables, AcpiSdtTable, i);
+
+ load_asl(data->ssdt_tables, sdt);
+ asl = normalize_asl(sdt->asl);
+
+ load_asl(exp_data.ssdt_tables, exp_sdt);
+ exp_asl = normalize_asl(exp_sdt->asl);
+
+ g_assert(!g_strcmp0(asl->str, exp_asl->str));
+ g_string_free(asl, true);
+ g_string_free(exp_asl, true);
+ }
+
+ free_test_data(&exp_data);
}
static void test_acpi_one(const char *params, test_data *data)
@@ -329,10 +530,14 @@ static void test_acpi_one(const char *params, test_data *data)
uint8_t signature_high;
uint16_t signature;
int i;
+ const char *device = "";
- memset(data, 0, sizeof(*data));
- args = g_strdup_printf("-net none -display none %s %s",
- params ? params : "", disk);
+ if (!g_strcmp0(data->machine, MACHINE_Q35)) {
+ device = ",id=hd -device ide-hd,drive=hd";
+ }
+
+ args = g_strdup_printf("-net none -display none %s -drive file=%s%s,",
+ params ? params : "", disk, device);
qtest_start(args);
/* Wait at most 1 minute */
@@ -362,6 +567,10 @@ static void test_acpi_one(const char *params, test_data *data)
test_acpi_dsdt_table(data);
test_acpi_ssdt_tables(data);
+ if (iasl_installed()) {
+ test_acpi_asl(data);
+ }
+
qtest_quit(global_qtest);
g_free(args);
}
@@ -373,8 +582,14 @@ static void test_acpi_tcg(void)
/* Supplying -machine accel argument overrides the default (qtest).
* This is to make guest actually run.
*/
+ memset(&data, 0, sizeof(data));
+ data.machine = MACHINE_PC;
test_acpi_one("-machine accel=tcg", &data);
+ free_test_data(&data);
+ memset(&data, 0, sizeof(data));
+ data.machine = MACHINE_Q35;
+ test_acpi_one("-machine q35,accel=tcg", &data);
free_test_data(&data);
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/3] acpi unit-test: compare resulting aml vs expected aml
2013-12-23 10:13 [Qemu-devel] [PATCH v2 0/3] acpi unit-test: compare resulting aml vs expected aml Marcel Apfelbaum
` (2 preceding siblings ...)
2013-12-23 10:13 ` [Qemu-devel] [PATCH v2 3/3] acpi unit-test: compare DSDT and SSDT tables against expected values Marcel Apfelbaum
@ 2013-12-23 12:02 ` Michael S. Tsirkin
2013-12-23 12:18 ` Marcel Apfelbaum
3 siblings, 1 reply; 10+ messages in thread
From: Michael S. Tsirkin @ 2013-12-23 12:02 UTC (permalink / raw)
To: Marcel Apfelbaum; +Cc: qemu-devel
On Mon, Dec 23, 2013 at 12:13:23PM +0200, Marcel Apfelbaum wrote:
> The test:
> - runs only if iasl is installed on the host machine.
> - the test plan:
> 1. Dumps the ACPI tables as AML on the disk.
> 2. Runs iasl to disassembly the tables into ASL files.
> 3. Runs iasl to disassembly the offline AML files.
> 3. Compares them with expected offline ASL files.
> - the test runs for both default machine and q35.
Looks good to me overall.
One thing I'd like to ask is that you add a script to
run after ACPI tables are updated.
It could update both pre-generated hex files and the
expected files.
> - in case the test fails, it can be easily tweaked to
> show the differences between the ASL files and
> understand the issue.
How exactly does it need to be tweaked?
> Patches:
> 1/3 - expected aml files
> 2/3 - creates links for the expected files
> if the build directory is not current
> 3/3 - the test
> Marcel Apfelbaum (3):
> acpi unit-test: add test files
> configure: added acpi unit-test files
> acpi unit-test: compare DSDT and SSDT tables against expected values
>
> configure | 4 +
> tests/acpi-test-data/pc/APIC | Bin 0 -> 120 bytes
> tests/acpi-test-data/pc/DSDT | Bin 0 -> 4407 bytes
> tests/acpi-test-data/pc/FACP | Bin 0 -> 116 bytes
> tests/acpi-test-data/pc/FACS | Bin 0 -> 64 bytes
> tests/acpi-test-data/pc/HPET | Bin 0 -> 56 bytes
> tests/acpi-test-data/pc/SSDT | Bin 0 -> 2104 bytes
> tests/acpi-test-data/q35/APIC | Bin 0 -> 120 bytes
> tests/acpi-test-data/q35/DSDT | Bin 0 -> 7344 bytes
> tests/acpi-test-data/q35/FACP | Bin 0 -> 116 bytes
> tests/acpi-test-data/q35/FACS | Bin 0 -> 64 bytes
> tests/acpi-test-data/q35/HPET | Bin 0 -> 56 bytes
> tests/acpi-test-data/q35/MCFG | Bin 0 -> 60 bytes
> tests/acpi-test-data/q35/SSDT | Bin 0 -> 2104 bytes
> tests/acpi-test.c | 257 ++++++++++++++++++++++++++++++++++++++----
> 15 files changed, 240 insertions(+), 21 deletions(-)
> create mode 100644 tests/acpi-test-data/pc/APIC
> create mode 100644 tests/acpi-test-data/pc/DSDT
> create mode 100644 tests/acpi-test-data/pc/FACP
> create mode 100644 tests/acpi-test-data/pc/FACS
> create mode 100644 tests/acpi-test-data/pc/HPET
> create mode 100644 tests/acpi-test-data/pc/SSDT
> create mode 100644 tests/acpi-test-data/q35/APIC
> create mode 100644 tests/acpi-test-data/q35/DSDT
> create mode 100644 tests/acpi-test-data/q35/FACP
> create mode 100644 tests/acpi-test-data/q35/FACS
> create mode 100644 tests/acpi-test-data/q35/HPET
> create mode 100644 tests/acpi-test-data/q35/MCFG
> create mode 100644 tests/acpi-test-data/q35/SSDT
>
> --
> 1.8.3.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/3] acpi unit-test: compare DSDT and SSDT tables against expected values
2013-12-23 10:13 ` [Qemu-devel] [PATCH v2 3/3] acpi unit-test: compare DSDT and SSDT tables against expected values Marcel Apfelbaum
@ 2013-12-23 12:06 ` Michael S. Tsirkin
2013-12-23 12:22 ` Marcel Apfelbaum
0 siblings, 1 reply; 10+ messages in thread
From: Michael S. Tsirkin @ 2013-12-23 12:06 UTC (permalink / raw)
To: Marcel Apfelbaum; +Cc: qemu-devel
On Mon, Dec 23, 2013 at 12:13:26PM +0200, Marcel Apfelbaum wrote:
> This test will run only if iasl is installed on the host machine.
> The test plan:
> 1. Dumps the ACPI tables as AML on the disk.
> 2. Runs iasl to disassembly the tables into ASL files.
> 3. Runs iasl to disassembly the offline AML files into ASL files.
> 4. Compares the ASL files.
>
> The test runs for both default machine and q35.
> In case the test fails, it can be easily tweaked to
> show the differences between the ASL files and
> understand the issue.
>
> Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> ---
> tests/acpi-test.c | 257 +++++++++++++++++++++++++++++++++++++++++++++++++-----
> 1 file changed, 236 insertions(+), 21 deletions(-)
>
> diff --git a/tests/acpi-test.c b/tests/acpi-test.c
> index ca83b1d..4f0cca6 100644
> --- a/tests/acpi-test.c
> +++ b/tests/acpi-test.c
> @@ -18,14 +18,22 @@
> #include "qemu/compiler.h"
> #include "hw/i386/acpi-defs.h"
>
> +#define MACHINE_PC "pc"
> +#define MACHINE_Q35 "q35"
> +
> /* DSDT and SSDTs format */
> typedef struct {
> AcpiTableHeader header;
> - uint8_t *aml;
> - int aml_len;
> -} AcpiSdtTable;
> + gchar *aml; /* aml bytecode from guest */
> + gsize aml_len;
> + gchar *aml_file;
> + gchar *asl; /* asl code generated from aml */
> + gsize asl_len;
> + gchar *asl_file;
> +} QEMU_PACKED AcpiSdtTable;
>
> typedef struct {
> + const char *machine;
> uint32_t rsdp_addr;
> AcpiRsdpDescriptor rsdp_table;
> AcpiRsdtDescriptorRev1 rsdt_table;
> @@ -33,8 +41,7 @@ typedef struct {
> AcpiFacsDescriptorRev1 facs_table;
> uint32_t *rsdt_tables_addr;
> int rsdt_tables_nr;
> - AcpiSdtTable dsdt_table;
> - GArray *ssdt_tables;
> + GArray *ssdt_tables; /* first is DSDT */
> } test_data;
>
> #define LOW(x) ((x) & 0xff)
> @@ -91,8 +98,10 @@ typedef struct {
>
> /* Boot sector code: write SIGNATURE into memory,
> * then halt.
> + * Q35 machine requires a minimum 0x7e000 bytes disk.
> + * (bug or feature?)
> */
> -static uint8_t boot_sector[0x200] = {
> +static uint8_t boot_sector[0x7e000] = {
> /* 7c00: mov $0xdead,%ax */
> [0x00] = 0xb8,
> [0x01] = LOW(SIGNATURE),
> @@ -117,17 +126,40 @@ static uint8_t boot_sector[0x200] = {
> };
>
> static const char *disk = "tests/acpi-test-disk.raw";
> +static const char *data_dir = "tests/acpi-test-data";
>
> static void free_test_data(test_data *data)
> {
> + AcpiSdtTable *temp;
> int i;
>
> - g_free(data->rsdt_tables_addr);
> + if (data->rsdt_tables_addr) {
> + g_free(data->rsdt_tables_addr);
> + }
> +
> for (i = 0; i < data->ssdt_tables->len; ++i) {
> - g_free(g_array_index(data->ssdt_tables, AcpiSdtTable, i).aml);
> + temp = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
> + if (temp->aml) {
> + g_free(temp->aml);
> + }
> + if (temp->aml_file) {
> + if (g_strstr_len(temp->aml_file, -1, "aml-")) {
> + unlink(temp->aml_file);
> + }
> + g_free(temp->aml_file);
> + }
> + if (temp->asl) {
> + g_free(temp->asl);
> + }
> + if (temp->asl_file) {
> + if (g_strstr_len(temp->asl_file, -1, "asl-")) {
> + unlink(temp->asl_file);
> + }
> + g_free(temp->asl_file);
> + }
> }
> +
> g_array_free(data->ssdt_tables, false);
> - g_free(data->dsdt_table.aml);
> }
>
> static uint8_t acpi_checksum(const uint8_t *data, int len)
> @@ -292,34 +324,203 @@ static void test_dst_table(AcpiSdtTable *sdt_table, uint32_t addr)
> ACPI_READ_ARRAY_PTR(sdt_table->aml, sdt_table->aml_len, addr);
>
> checksum = acpi_checksum((uint8_t *)sdt_table, sizeof(AcpiTableHeader)) +
> - acpi_checksum(sdt_table->aml, sdt_table->aml_len);
> + acpi_checksum((uint8_t *)sdt_table->aml, sdt_table->aml_len);
> g_assert(!checksum);
> }
>
> static void test_acpi_dsdt_table(test_data *data)
> {
> - AcpiSdtTable *dsdt_table = &data->dsdt_table;
> + AcpiSdtTable dsdt_table;
> uint32_t addr = data->fadt_table.dsdt;
>
> - test_dst_table(dsdt_table, addr);
> - g_assert_cmphex(dsdt_table->header.signature, ==, ACPI_DSDT_SIGNATURE);
> + memset(&dsdt_table, 0, sizeof(dsdt_table));
> + data->ssdt_tables = g_array_new(false, true, sizeof(AcpiSdtTable));
> +
> + test_dst_table(&dsdt_table, addr);
> + g_assert_cmphex(dsdt_table.header.signature, ==, ACPI_DSDT_SIGNATURE);
> +
> + /* Place DSDT first */
> + g_array_append_val(data->ssdt_tables, dsdt_table);
> }
>
> static void test_acpi_ssdt_tables(test_data *data)
> {
> - GArray *ssdt_tables;
> int ssdt_tables_nr = data->rsdt_tables_nr - 1; /* fadt is first */
> int i;
>
> - ssdt_tables = g_array_sized_new(false, true, sizeof(AcpiSdtTable),
> - ssdt_tables_nr);
> for (i = 0; i < ssdt_tables_nr; i++) {
> AcpiSdtTable ssdt_table;
> +
> + memset(&ssdt_table, 0 , sizeof(ssdt_table));
> uint32_t addr = data->rsdt_tables_addr[i + 1]; /* fadt is first */
> test_dst_table(&ssdt_table, addr);
> - g_array_append_val(ssdt_tables, ssdt_table);
> + g_array_append_val(data->ssdt_tables, ssdt_table);
> + }
> +}
> +
> +static bool iasl_installed(void)
> +{
> + gchar *out = NULL, *out_err = NULL;
> + bool ret;
> +
> + /* pass 'out' and 'out_err' in order to be redirected */
> + ret = g_spawn_command_line_sync("iasl", &out, &out_err, NULL, NULL);
One interesting option here is to include config-hosts.mak
from Makefile, then use IASL configured there.
Can be a patch on top though.
> +
> + if (out_err) {
> + ret = ret && (out_err[0] == '\0');
> + g_free(out_err);
> }
> - data->ssdt_tables = ssdt_tables;
> +
> + if (out) {
> + g_free(out);
> + }
> +
> + return ret;
> +}
> +
> +static void dump_aml_files(test_data *data)
> +{
> + AcpiSdtTable *sdt;
> + GError *error = NULL;
> + gint fd;
> + int i;
> +
> + for (i = 0; i < data->ssdt_tables->len; ++i) {
> + sdt = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
> + g_assert(sdt->aml);
> +
> + fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error);
> + g_assert_no_error(error);
> +
> + write(fd, sdt, sizeof(AcpiTableHeader));
> + write(fd, sdt->aml, sdt->aml_len);
> + close(fd);
> + }
> +}
> +
> +static void load_asl(GArray *sdts, AcpiSdtTable *sdt)
> +{
> + AcpiSdtTable *temp;
> + GError *error = NULL;
> + GString *command_line = g_string_new("'iasl' ");
> + gint fd;
> + gchar *out, *out_err;
> + gboolean ret;
> + int i;
> +
> + fd = g_file_open_tmp("asl-XXXXXX.dsl", &sdt->asl_file, &error);
> + g_assert_no_error(error);
> + close(fd);
> +
> + /* build command line */
> + g_string_append_printf(command_line, "-p %s ", sdt->asl_file);
> + for (i = 0; i < 2; ++i) { /* reference DSDT and SSDT */
> + temp = &g_array_index(sdts, AcpiSdtTable, i);
> + g_string_append_printf(command_line, "-e %s ", temp->aml_file);
> + }
> + g_string_append_printf(command_line, "-d %s", sdt->aml_file);
> +
> + /* pass 'out' and 'out_err' in order to be redirected */
> + g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error);
> + g_assert_no_error(error);
> +
> + ret = g_file_get_contents(sdt->asl_file, (gchar **)&sdt->asl,
> + &sdt->asl_len, &error);
> + g_assert(ret);
> + g_assert_no_error(error);
> + g_assert(sdt->asl_len);
> +
> + g_free(out);
> + g_free(out_err);
> + g_string_free(command_line, true);
> +}
> +
> +#define COMMENT_END "*/"
> +#define DEF_BLOCK "DefinitionBlock ("
> +#define BLOCK_NAME_END ".aml"
> +
> +static GString *normalize_asl(gchar *asl_code)
> +{
> + GString *asl = g_string_new(asl_code);
> + gchar *comment, *block_name;
> +
> + /* strip comments (different generation days) */
> + comment = g_strstr_len(asl->str, asl->len, COMMENT_END);
> + if (comment) {
> + asl = g_string_erase(asl, 0, comment + sizeof(COMMENT_END) - asl->str);
> + }
> +
> + /* strip def block name (it has file path in it) */
> + if (g_str_has_prefix(asl->str, DEF_BLOCK)) {
> + block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);
> + g_assert(block_name);
> + asl = g_string_erase(asl, 0,
> + block_name + sizeof(BLOCK_NAME_END) - asl->str);
> + }
> +
> + return asl;
> +}
> +
> +static GArray *load_expected_aml(test_data *data)
> +{
> + int i;
> + AcpiSdtTable *sdt;
> + gchar *aml_file;
> + GError *error = NULL;
> + gboolean ret;
> +
> + GArray *exp_ssdt_tables = g_array_new(false, true, sizeof(AcpiSdtTable));
> + for (i = 0; i < data->ssdt_tables->len; ++i) {
> + AcpiSdtTable exp_sdt;
> + sdt = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
> +
> + memset(&exp_sdt, 0, sizeof(exp_sdt));
> + exp_sdt.header.signature = sdt->header.signature;
> +
> + aml_file = g_strdup_printf("%s/%s/%.4s", data_dir, data->machine,
> + (gchar *)&exp_sdt.header.signature);
> + exp_sdt.aml_file = aml_file;
> + g_assert(g_file_test(aml_file, G_FILE_TEST_EXISTS));
> + ret = g_file_get_contents(aml_file, &exp_sdt.aml,
> + &exp_sdt.aml_len, &error);
> + g_assert(ret);
> + g_assert_no_error(error);
> + g_assert(exp_sdt.aml);
> + g_assert(exp_sdt.aml_len);
> +
> + g_array_append_val(exp_ssdt_tables, exp_sdt);
> + }
> +
> + return exp_ssdt_tables;
> +}
> +
> +static void test_acpi_asl(test_data *data)
> +{
> + int i;
> + AcpiSdtTable *sdt, *exp_sdt;
> + test_data exp_data;
> +
> + memset(&exp_data, 0, sizeof(exp_data));
> + exp_data.ssdt_tables = load_expected_aml(data);
> + dump_aml_files(data);
> + for (i = 0; i < data->ssdt_tables->len; ++i) {
> + GString *asl, *exp_asl;
> +
> + sdt = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
> + exp_sdt = &g_array_index(exp_data.ssdt_tables, AcpiSdtTable, i);
> +
> + load_asl(data->ssdt_tables, sdt);
> + asl = normalize_asl(sdt->asl);
> +
> + load_asl(exp_data.ssdt_tables, exp_sdt);
> + exp_asl = normalize_asl(exp_sdt->asl);
> +
> + g_assert(!g_strcmp0(asl->str, exp_asl->str));
> + g_string_free(asl, true);
> + g_string_free(exp_asl, true);
> + }
> +
> + free_test_data(&exp_data);
> }
>
> static void test_acpi_one(const char *params, test_data *data)
> @@ -329,10 +530,14 @@ static void test_acpi_one(const char *params, test_data *data)
> uint8_t signature_high;
> uint16_t signature;
> int i;
> + const char *device = "";
>
> - memset(data, 0, sizeof(*data));
> - args = g_strdup_printf("-net none -display none %s %s",
> - params ? params : "", disk);
> + if (!g_strcmp0(data->machine, MACHINE_Q35)) {
> + device = ",id=hd -device ide-hd,drive=hd";
> + }
> +
> + args = g_strdup_printf("-net none -display none %s -drive file=%s%s,",
> + params ? params : "", disk, device);
> qtest_start(args);
>
> /* Wait at most 1 minute */
> @@ -362,6 +567,10 @@ static void test_acpi_one(const char *params, test_data *data)
> test_acpi_dsdt_table(data);
> test_acpi_ssdt_tables(data);
>
> + if (iasl_installed()) {
> + test_acpi_asl(data);
> + }
> +
> qtest_quit(global_qtest);
> g_free(args);
> }
> @@ -373,8 +582,14 @@ static void test_acpi_tcg(void)
> /* Supplying -machine accel argument overrides the default (qtest).
> * This is to make guest actually run.
> */
> + memset(&data, 0, sizeof(data));
> + data.machine = MACHINE_PC;
> test_acpi_one("-machine accel=tcg", &data);
> + free_test_data(&data);
>
> + memset(&data, 0, sizeof(data));
> + data.machine = MACHINE_Q35;
> + test_acpi_one("-machine q35,accel=tcg", &data);
> free_test_data(&data);
> }
>
> --
> 1.8.3.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/3] acpi unit-test: compare resulting aml vs expected aml
2013-12-23 12:02 ` [Qemu-devel] [PATCH v2 0/3] acpi unit-test: compare resulting aml vs expected aml Michael S. Tsirkin
@ 2013-12-23 12:18 ` Marcel Apfelbaum
2013-12-23 14:59 ` Michael S. Tsirkin
0 siblings, 1 reply; 10+ messages in thread
From: Marcel Apfelbaum @ 2013-12-23 12:18 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
On Mon, 2013-12-23 at 14:02 +0200, Michael S. Tsirkin wrote:
> On Mon, Dec 23, 2013 at 12:13:23PM +0200, Marcel Apfelbaum wrote:
> > The test:
> > - runs only if iasl is installed on the host machine.
> > - the test plan:
> > 1. Dumps the ACPI tables as AML on the disk.
> > 2. Runs iasl to disassembly the tables into ASL files.
> > 3. Runs iasl to disassembly the offline AML files.
> > 3. Compares them with expected offline ASL files.
> > - the test runs for both default machine and q35.
>
> Looks good to me overall.
> One thing I'd like to ask is that you add a script to
> run after ACPI tables are updated.
> It could update both pre-generated hex files and the
> expected files.
I don't think that I understand, what is the script's
purpose?
>
> > - in case the test fails, it can be easily tweaked to
> > show the differences between the ASL files and
> > understand the issue.
>
> How exactly does it need to be tweaked?
Instead of the assert that is failing when the asl files
are not the same, one could print them to console.
Another thing that can be done is to print to
console the dumped asl file names and manually do the diff.
Thanks,
Marcel
>
> > Patches:
> > 1/3 - expected aml files
> > 2/3 - creates links for the expected files
> > if the build directory is not current
> > 3/3 - the test
> > Marcel Apfelbaum (3):
> > acpi unit-test: add test files
> > configure: added acpi unit-test files
> > acpi unit-test: compare DSDT and SSDT tables against expected values
> >
> > configure | 4 +
> > tests/acpi-test-data/pc/APIC | Bin 0 -> 120 bytes
> > tests/acpi-test-data/pc/DSDT | Bin 0 -> 4407 bytes
> > tests/acpi-test-data/pc/FACP | Bin 0 -> 116 bytes
> > tests/acpi-test-data/pc/FACS | Bin 0 -> 64 bytes
> > tests/acpi-test-data/pc/HPET | Bin 0 -> 56 bytes
> > tests/acpi-test-data/pc/SSDT | Bin 0 -> 2104 bytes
> > tests/acpi-test-data/q35/APIC | Bin 0 -> 120 bytes
> > tests/acpi-test-data/q35/DSDT | Bin 0 -> 7344 bytes
> > tests/acpi-test-data/q35/FACP | Bin 0 -> 116 bytes
> > tests/acpi-test-data/q35/FACS | Bin 0 -> 64 bytes
> > tests/acpi-test-data/q35/HPET | Bin 0 -> 56 bytes
> > tests/acpi-test-data/q35/MCFG | Bin 0 -> 60 bytes
> > tests/acpi-test-data/q35/SSDT | Bin 0 -> 2104 bytes
> > tests/acpi-test.c | 257 ++++++++++++++++++++++++++++++++++++++----
> > 15 files changed, 240 insertions(+), 21 deletions(-)
> > create mode 100644 tests/acpi-test-data/pc/APIC
> > create mode 100644 tests/acpi-test-data/pc/DSDT
> > create mode 100644 tests/acpi-test-data/pc/FACP
> > create mode 100644 tests/acpi-test-data/pc/FACS
> > create mode 100644 tests/acpi-test-data/pc/HPET
> > create mode 100644 tests/acpi-test-data/pc/SSDT
> > create mode 100644 tests/acpi-test-data/q35/APIC
> > create mode 100644 tests/acpi-test-data/q35/DSDT
> > create mode 100644 tests/acpi-test-data/q35/FACP
> > create mode 100644 tests/acpi-test-data/q35/FACS
> > create mode 100644 tests/acpi-test-data/q35/HPET
> > create mode 100644 tests/acpi-test-data/q35/MCFG
> > create mode 100644 tests/acpi-test-data/q35/SSDT
> >
> > --
> > 1.8.3.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/3] acpi unit-test: compare DSDT and SSDT tables against expected values
2013-12-23 12:06 ` Michael S. Tsirkin
@ 2013-12-23 12:22 ` Marcel Apfelbaum
2013-12-23 15:26 ` Michael S. Tsirkin
0 siblings, 1 reply; 10+ messages in thread
From: Marcel Apfelbaum @ 2013-12-23 12:22 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
On Mon, 2013-12-23 at 14:06 +0200, Michael S. Tsirkin wrote:
> On Mon, Dec 23, 2013 at 12:13:26PM +0200, Marcel Apfelbaum wrote:
> > This test will run only if iasl is installed on the host machine.
> > The test plan:
> > 1. Dumps the ACPI tables as AML on the disk.
> > 2. Runs iasl to disassembly the tables into ASL files.
> > 3. Runs iasl to disassembly the offline AML files into ASL files.
> > 4. Compares the ASL files.
> >
> > The test runs for both default machine and q35.
> > In case the test fails, it can be easily tweaked to
> > show the differences between the ASL files and
> > understand the issue.
> >
> > Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> > ---
> > tests/acpi-test.c | 257 +++++++++++++++++++++++++++++++++++++++++++++++++-----
> > 1 file changed, 236 insertions(+), 21 deletions(-)
> >
> > diff --git a/tests/acpi-test.c b/tests/acpi-test.c
> > index ca83b1d..4f0cca6 100644
> > --- a/tests/acpi-test.c
> > +++ b/tests/acpi-test.c
> > @@ -18,14 +18,22 @@
> > #include "qemu/compiler.h"
> > #include "hw/i386/acpi-defs.h"
> >
> > +#define MACHINE_PC "pc"
> > +#define MACHINE_Q35 "q35"
> > +
> > /* DSDT and SSDTs format */
> > typedef struct {
> > AcpiTableHeader header;
> > - uint8_t *aml;
> > - int aml_len;
> > -} AcpiSdtTable;
> > + gchar *aml; /* aml bytecode from guest */
> > + gsize aml_len;
> > + gchar *aml_file;
> > + gchar *asl; /* asl code generated from aml */
> > + gsize asl_len;
> > + gchar *asl_file;
> > +} QEMU_PACKED AcpiSdtTable;
> >
> > typedef struct {
> > + const char *machine;
> > uint32_t rsdp_addr;
> > AcpiRsdpDescriptor rsdp_table;
> > AcpiRsdtDescriptorRev1 rsdt_table;
> > @@ -33,8 +41,7 @@ typedef struct {
> > AcpiFacsDescriptorRev1 facs_table;
> > uint32_t *rsdt_tables_addr;
> > int rsdt_tables_nr;
> > - AcpiSdtTable dsdt_table;
> > - GArray *ssdt_tables;
> > + GArray *ssdt_tables; /* first is DSDT */
> > } test_data;
> >
> > #define LOW(x) ((x) & 0xff)
> > @@ -91,8 +98,10 @@ typedef struct {
> >
> > /* Boot sector code: write SIGNATURE into memory,
> > * then halt.
> > + * Q35 machine requires a minimum 0x7e000 bytes disk.
> > + * (bug or feature?)
> > */
> > -static uint8_t boot_sector[0x200] = {
> > +static uint8_t boot_sector[0x7e000] = {
> > /* 7c00: mov $0xdead,%ax */
> > [0x00] = 0xb8,
> > [0x01] = LOW(SIGNATURE),
> > @@ -117,17 +126,40 @@ static uint8_t boot_sector[0x200] = {
> > };
> >
> > static const char *disk = "tests/acpi-test-disk.raw";
> > +static const char *data_dir = "tests/acpi-test-data";
> >
> > static void free_test_data(test_data *data)
> > {
> > + AcpiSdtTable *temp;
> > int i;
> >
> > - g_free(data->rsdt_tables_addr);
> > + if (data->rsdt_tables_addr) {
> > + g_free(data->rsdt_tables_addr);
> > + }
> > +
> > for (i = 0; i < data->ssdt_tables->len; ++i) {
> > - g_free(g_array_index(data->ssdt_tables, AcpiSdtTable, i).aml);
> > + temp = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
> > + if (temp->aml) {
> > + g_free(temp->aml);
> > + }
> > + if (temp->aml_file) {
> > + if (g_strstr_len(temp->aml_file, -1, "aml-")) {
> > + unlink(temp->aml_file);
> > + }
> > + g_free(temp->aml_file);
> > + }
> > + if (temp->asl) {
> > + g_free(temp->asl);
> > + }
> > + if (temp->asl_file) {
> > + if (g_strstr_len(temp->asl_file, -1, "asl-")) {
> > + unlink(temp->asl_file);
> > + }
> > + g_free(temp->asl_file);
> > + }
> > }
> > +
> > g_array_free(data->ssdt_tables, false);
> > - g_free(data->dsdt_table.aml);
> > }
> >
> > static uint8_t acpi_checksum(const uint8_t *data, int len)
> > @@ -292,34 +324,203 @@ static void test_dst_table(AcpiSdtTable *sdt_table, uint32_t addr)
> > ACPI_READ_ARRAY_PTR(sdt_table->aml, sdt_table->aml_len, addr);
> >
> > checksum = acpi_checksum((uint8_t *)sdt_table, sizeof(AcpiTableHeader)) +
> > - acpi_checksum(sdt_table->aml, sdt_table->aml_len);
> > + acpi_checksum((uint8_t *)sdt_table->aml, sdt_table->aml_len);
> > g_assert(!checksum);
> > }
> >
> > static void test_acpi_dsdt_table(test_data *data)
> > {
> > - AcpiSdtTable *dsdt_table = &data->dsdt_table;
> > + AcpiSdtTable dsdt_table;
> > uint32_t addr = data->fadt_table.dsdt;
> >
> > - test_dst_table(dsdt_table, addr);
> > - g_assert_cmphex(dsdt_table->header.signature, ==, ACPI_DSDT_SIGNATURE);
> > + memset(&dsdt_table, 0, sizeof(dsdt_table));
> > + data->ssdt_tables = g_array_new(false, true, sizeof(AcpiSdtTable));
> > +
> > + test_dst_table(&dsdt_table, addr);
> > + g_assert_cmphex(dsdt_table.header.signature, ==, ACPI_DSDT_SIGNATURE);
> > +
> > + /* Place DSDT first */
> > + g_array_append_val(data->ssdt_tables, dsdt_table);
> > }
> >
> > static void test_acpi_ssdt_tables(test_data *data)
> > {
> > - GArray *ssdt_tables;
> > int ssdt_tables_nr = data->rsdt_tables_nr - 1; /* fadt is first */
> > int i;
> >
> > - ssdt_tables = g_array_sized_new(false, true, sizeof(AcpiSdtTable),
> > - ssdt_tables_nr);
> > for (i = 0; i < ssdt_tables_nr; i++) {
> > AcpiSdtTable ssdt_table;
> > +
> > + memset(&ssdt_table, 0 , sizeof(ssdt_table));
> > uint32_t addr = data->rsdt_tables_addr[i + 1]; /* fadt is first */
> > test_dst_table(&ssdt_table, addr);
> > - g_array_append_val(ssdt_tables, ssdt_table);
> > + g_array_append_val(data->ssdt_tables, ssdt_table);
> > + }
> > +}
> > +
> > +static bool iasl_installed(void)
> > +{
> > + gchar *out = NULL, *out_err = NULL;
> > + bool ret;
> > +
> > + /* pass 'out' and 'out_err' in order to be redirected */
> > + ret = g_spawn_command_line_sync("iasl", &out, &out_err, NULL, NULL);
>
> One interesting option here is to include config-hosts.mak
> from Makefile, then use IASL configured there.
Would be better, I agree, expect I have
no idea how to include this file. I'll look
it up and send it as different patch as you
suggested.
Thanks for the review!
Marcel
>
> Can be a patch on top though.
>
> > +
> > + if (out_err) {
> > + ret = ret && (out_err[0] == '\0');
> > + g_free(out_err);
> > }
> > - data->ssdt_tables = ssdt_tables;
> > +
> > + if (out) {
> > + g_free(out);
> > + }
> > +
> > + return ret;
> > +}
> > +
> > +static void dump_aml_files(test_data *data)
> > +{
> > + AcpiSdtTable *sdt;
> > + GError *error = NULL;
> > + gint fd;
> > + int i;
> > +
> > + for (i = 0; i < data->ssdt_tables->len; ++i) {
> > + sdt = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
> > + g_assert(sdt->aml);
> > +
> > + fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error);
> > + g_assert_no_error(error);
> > +
> > + write(fd, sdt, sizeof(AcpiTableHeader));
> > + write(fd, sdt->aml, sdt->aml_len);
> > + close(fd);
> > + }
> > +}
> > +
> > +static void load_asl(GArray *sdts, AcpiSdtTable *sdt)
> > +{
> > + AcpiSdtTable *temp;
> > + GError *error = NULL;
> > + GString *command_line = g_string_new("'iasl' ");
> > + gint fd;
> > + gchar *out, *out_err;
> > + gboolean ret;
> > + int i;
> > +
> > + fd = g_file_open_tmp("asl-XXXXXX.dsl", &sdt->asl_file, &error);
> > + g_assert_no_error(error);
> > + close(fd);
> > +
> > + /* build command line */
> > + g_string_append_printf(command_line, "-p %s ", sdt->asl_file);
> > + for (i = 0; i < 2; ++i) { /* reference DSDT and SSDT */
> > + temp = &g_array_index(sdts, AcpiSdtTable, i);
> > + g_string_append_printf(command_line, "-e %s ", temp->aml_file);
> > + }
> > + g_string_append_printf(command_line, "-d %s", sdt->aml_file);
> > +
> > + /* pass 'out' and 'out_err' in order to be redirected */
> > + g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error);
> > + g_assert_no_error(error);
> > +
> > + ret = g_file_get_contents(sdt->asl_file, (gchar **)&sdt->asl,
> > + &sdt->asl_len, &error);
> > + g_assert(ret);
> > + g_assert_no_error(error);
> > + g_assert(sdt->asl_len);
> > +
> > + g_free(out);
> > + g_free(out_err);
> > + g_string_free(command_line, true);
> > +}
> > +
> > +#define COMMENT_END "*/"
> > +#define DEF_BLOCK "DefinitionBlock ("
> > +#define BLOCK_NAME_END ".aml"
> > +
> > +static GString *normalize_asl(gchar *asl_code)
> > +{
> > + GString *asl = g_string_new(asl_code);
> > + gchar *comment, *block_name;
> > +
> > + /* strip comments (different generation days) */
> > + comment = g_strstr_len(asl->str, asl->len, COMMENT_END);
> > + if (comment) {
> > + asl = g_string_erase(asl, 0, comment + sizeof(COMMENT_END) - asl->str);
> > + }
> > +
> > + /* strip def block name (it has file path in it) */
> > + if (g_str_has_prefix(asl->str, DEF_BLOCK)) {
> > + block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);
> > + g_assert(block_name);
> > + asl = g_string_erase(asl, 0,
> > + block_name + sizeof(BLOCK_NAME_END) - asl->str);
> > + }
> > +
> > + return asl;
> > +}
> > +
> > +static GArray *load_expected_aml(test_data *data)
> > +{
> > + int i;
> > + AcpiSdtTable *sdt;
> > + gchar *aml_file;
> > + GError *error = NULL;
> > + gboolean ret;
> > +
> > + GArray *exp_ssdt_tables = g_array_new(false, true, sizeof(AcpiSdtTable));
> > + for (i = 0; i < data->ssdt_tables->len; ++i) {
> > + AcpiSdtTable exp_sdt;
> > + sdt = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
> > +
> > + memset(&exp_sdt, 0, sizeof(exp_sdt));
> > + exp_sdt.header.signature = sdt->header.signature;
> > +
> > + aml_file = g_strdup_printf("%s/%s/%.4s", data_dir, data->machine,
> > + (gchar *)&exp_sdt.header.signature);
> > + exp_sdt.aml_file = aml_file;
> > + g_assert(g_file_test(aml_file, G_FILE_TEST_EXISTS));
> > + ret = g_file_get_contents(aml_file, &exp_sdt.aml,
> > + &exp_sdt.aml_len, &error);
> > + g_assert(ret);
> > + g_assert_no_error(error);
> > + g_assert(exp_sdt.aml);
> > + g_assert(exp_sdt.aml_len);
> > +
> > + g_array_append_val(exp_ssdt_tables, exp_sdt);
> > + }
> > +
> > + return exp_ssdt_tables;
> > +}
> > +
> > +static void test_acpi_asl(test_data *data)
> > +{
> > + int i;
> > + AcpiSdtTable *sdt, *exp_sdt;
> > + test_data exp_data;
> > +
> > + memset(&exp_data, 0, sizeof(exp_data));
> > + exp_data.ssdt_tables = load_expected_aml(data);
> > + dump_aml_files(data);
> > + for (i = 0; i < data->ssdt_tables->len; ++i) {
> > + GString *asl, *exp_asl;
> > +
> > + sdt = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
> > + exp_sdt = &g_array_index(exp_data.ssdt_tables, AcpiSdtTable, i);
> > +
> > + load_asl(data->ssdt_tables, sdt);
> > + asl = normalize_asl(sdt->asl);
> > +
> > + load_asl(exp_data.ssdt_tables, exp_sdt);
> > + exp_asl = normalize_asl(exp_sdt->asl);
> > +
> > + g_assert(!g_strcmp0(asl->str, exp_asl->str));
> > + g_string_free(asl, true);
> > + g_string_free(exp_asl, true);
> > + }
> > +
> > + free_test_data(&exp_data);
> > }
> >
> > static void test_acpi_one(const char *params, test_data *data)
> > @@ -329,10 +530,14 @@ static void test_acpi_one(const char *params, test_data *data)
> > uint8_t signature_high;
> > uint16_t signature;
> > int i;
> > + const char *device = "";
> >
> > - memset(data, 0, sizeof(*data));
> > - args = g_strdup_printf("-net none -display none %s %s",
> > - params ? params : "", disk);
> > + if (!g_strcmp0(data->machine, MACHINE_Q35)) {
> > + device = ",id=hd -device ide-hd,drive=hd";
> > + }
> > +
> > + args = g_strdup_printf("-net none -display none %s -drive file=%s%s,",
> > + params ? params : "", disk, device);
> > qtest_start(args);
> >
> > /* Wait at most 1 minute */
> > @@ -362,6 +567,10 @@ static void test_acpi_one(const char *params, test_data *data)
> > test_acpi_dsdt_table(data);
> > test_acpi_ssdt_tables(data);
> >
> > + if (iasl_installed()) {
> > + test_acpi_asl(data);
> > + }
> > +
> > qtest_quit(global_qtest);
> > g_free(args);
> > }
> > @@ -373,8 +582,14 @@ static void test_acpi_tcg(void)
> > /* Supplying -machine accel argument overrides the default (qtest).
> > * This is to make guest actually run.
> > */
> > + memset(&data, 0, sizeof(data));
> > + data.machine = MACHINE_PC;
> > test_acpi_one("-machine accel=tcg", &data);
> > + free_test_data(&data);
> >
> > + memset(&data, 0, sizeof(data));
> > + data.machine = MACHINE_Q35;
> > + test_acpi_one("-machine q35,accel=tcg", &data);
> > free_test_data(&data);
> > }
> >
> > --
> > 1.8.3.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/3] acpi unit-test: compare resulting aml vs expected aml
2013-12-23 12:18 ` Marcel Apfelbaum
@ 2013-12-23 14:59 ` Michael S. Tsirkin
0 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2013-12-23 14:59 UTC (permalink / raw)
To: Marcel Apfelbaum; +Cc: qemu-devel
On Mon, Dec 23, 2013 at 02:18:47PM +0200, Marcel Apfelbaum wrote:
> On Mon, 2013-12-23 at 14:02 +0200, Michael S. Tsirkin wrote:
> > On Mon, Dec 23, 2013 at 12:13:23PM +0200, Marcel Apfelbaum wrote:
> > > The test:
> > > - runs only if iasl is installed on the host machine.
> > > - the test plan:
> > > 1. Dumps the ACPI tables as AML on the disk.
> > > 2. Runs iasl to disassembly the tables into ASL files.
> > > 3. Runs iasl to disassembly the offline AML files.
> > > 3. Compares them with expected offline ASL files.
> > > - the test runs for both default machine and q35.
> >
> > Looks good to me overall.
> > One thing I'd like to ask is that you add a script to
> > run after ACPI tables are updated.
> > It could update both pre-generated hex files and the
> > expected files.
> I don't think that I understand, what is the script's
> purpose?
Update aml in git after we make source changes.
> >
> > > - in case the test fails, it can be easily tweaked to
> > > show the differences between the ASL files and
> > > understand the issue.
> >
> > How exactly does it need to be tweaked?
> Instead of the assert that is failing when the asl files
> are not the same, one could print them to console.
> Another thing that can be done is to print to
> console the dumped asl file names and manually do the diff.
>
> Thanks,
> Marcel
Can this be done automatically e.g. before the assert?
Alternatively add a comment so people know what to do
and where.
> >
> > > Patches:
> > > 1/3 - expected aml files
> > > 2/3 - creates links for the expected files
> > > if the build directory is not current
> > > 3/3 - the test
> > > Marcel Apfelbaum (3):
> > > acpi unit-test: add test files
> > > configure: added acpi unit-test files
> > > acpi unit-test: compare DSDT and SSDT tables against expected values
> > >
> > > configure | 4 +
> > > tests/acpi-test-data/pc/APIC | Bin 0 -> 120 bytes
> > > tests/acpi-test-data/pc/DSDT | Bin 0 -> 4407 bytes
> > > tests/acpi-test-data/pc/FACP | Bin 0 -> 116 bytes
> > > tests/acpi-test-data/pc/FACS | Bin 0 -> 64 bytes
> > > tests/acpi-test-data/pc/HPET | Bin 0 -> 56 bytes
> > > tests/acpi-test-data/pc/SSDT | Bin 0 -> 2104 bytes
> > > tests/acpi-test-data/q35/APIC | Bin 0 -> 120 bytes
> > > tests/acpi-test-data/q35/DSDT | Bin 0 -> 7344 bytes
> > > tests/acpi-test-data/q35/FACP | Bin 0 -> 116 bytes
> > > tests/acpi-test-data/q35/FACS | Bin 0 -> 64 bytes
> > > tests/acpi-test-data/q35/HPET | Bin 0 -> 56 bytes
> > > tests/acpi-test-data/q35/MCFG | Bin 0 -> 60 bytes
> > > tests/acpi-test-data/q35/SSDT | Bin 0 -> 2104 bytes
> > > tests/acpi-test.c | 257 ++++++++++++++++++++++++++++++++++++++----
> > > 15 files changed, 240 insertions(+), 21 deletions(-)
> > > create mode 100644 tests/acpi-test-data/pc/APIC
> > > create mode 100644 tests/acpi-test-data/pc/DSDT
> > > create mode 100644 tests/acpi-test-data/pc/FACP
> > > create mode 100644 tests/acpi-test-data/pc/FACS
> > > create mode 100644 tests/acpi-test-data/pc/HPET
> > > create mode 100644 tests/acpi-test-data/pc/SSDT
> > > create mode 100644 tests/acpi-test-data/q35/APIC
> > > create mode 100644 tests/acpi-test-data/q35/DSDT
> > > create mode 100644 tests/acpi-test-data/q35/FACP
> > > create mode 100644 tests/acpi-test-data/q35/FACS
> > > create mode 100644 tests/acpi-test-data/q35/HPET
> > > create mode 100644 tests/acpi-test-data/q35/MCFG
> > > create mode 100644 tests/acpi-test-data/q35/SSDT
> > >
> > > --
> > > 1.8.3.1
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/3] acpi unit-test: compare DSDT and SSDT tables against expected values
2013-12-23 12:22 ` Marcel Apfelbaum
@ 2013-12-23 15:26 ` Michael S. Tsirkin
0 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2013-12-23 15:26 UTC (permalink / raw)
To: Marcel Apfelbaum; +Cc: qemu-devel
On Mon, Dec 23, 2013 at 02:22:38PM +0200, Marcel Apfelbaum wrote:
> On Mon, 2013-12-23 at 14:06 +0200, Michael S. Tsirkin wrote:
> > On Mon, Dec 23, 2013 at 12:13:26PM +0200, Marcel Apfelbaum wrote:
> > > This test will run only if iasl is installed on the host machine.
> > > The test plan:
> > > 1. Dumps the ACPI tables as AML on the disk.
> > > 2. Runs iasl to disassembly the tables into ASL files.
> > > 3. Runs iasl to disassembly the offline AML files into ASL files.
> > > 4. Compares the ASL files.
> > >
> > > The test runs for both default machine and q35.
> > > In case the test fails, it can be easily tweaked to
> > > show the differences between the ASL files and
> > > understand the issue.
> > >
> > > Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com>
> > > ---
> > > tests/acpi-test.c | 257 +++++++++++++++++++++++++++++++++++++++++++++++++-----
> > > 1 file changed, 236 insertions(+), 21 deletions(-)
> > >
> > > diff --git a/tests/acpi-test.c b/tests/acpi-test.c
> > > index ca83b1d..4f0cca6 100644
> > > --- a/tests/acpi-test.c
> > > +++ b/tests/acpi-test.c
> > > @@ -18,14 +18,22 @@
> > > #include "qemu/compiler.h"
> > > #include "hw/i386/acpi-defs.h"
> > >
> > > +#define MACHINE_PC "pc"
> > > +#define MACHINE_Q35 "q35"
> > > +
> > > /* DSDT and SSDTs format */
> > > typedef struct {
> > > AcpiTableHeader header;
> > > - uint8_t *aml;
> > > - int aml_len;
> > > -} AcpiSdtTable;
> > > + gchar *aml; /* aml bytecode from guest */
> > > + gsize aml_len;
> > > + gchar *aml_file;
> > > + gchar *asl; /* asl code generated from aml */
> > > + gsize asl_len;
> > > + gchar *asl_file;
> > > +} QEMU_PACKED AcpiSdtTable;
> > >
> > > typedef struct {
> > > + const char *machine;
> > > uint32_t rsdp_addr;
> > > AcpiRsdpDescriptor rsdp_table;
> > > AcpiRsdtDescriptorRev1 rsdt_table;
> > > @@ -33,8 +41,7 @@ typedef struct {
> > > AcpiFacsDescriptorRev1 facs_table;
> > > uint32_t *rsdt_tables_addr;
> > > int rsdt_tables_nr;
> > > - AcpiSdtTable dsdt_table;
> > > - GArray *ssdt_tables;
> > > + GArray *ssdt_tables; /* first is DSDT */
> > > } test_data;
> > >
> > > #define LOW(x) ((x) & 0xff)
> > > @@ -91,8 +98,10 @@ typedef struct {
> > >
> > > /* Boot sector code: write SIGNATURE into memory,
> > > * then halt.
> > > + * Q35 machine requires a minimum 0x7e000 bytes disk.
> > > + * (bug or feature?)
> > > */
> > > -static uint8_t boot_sector[0x200] = {
> > > +static uint8_t boot_sector[0x7e000] = {
> > > /* 7c00: mov $0xdead,%ax */
> > > [0x00] = 0xb8,
> > > [0x01] = LOW(SIGNATURE),
> > > @@ -117,17 +126,40 @@ static uint8_t boot_sector[0x200] = {
> > > };
> > >
> > > static const char *disk = "tests/acpi-test-disk.raw";
> > > +static const char *data_dir = "tests/acpi-test-data";
> > >
> > > static void free_test_data(test_data *data)
> > > {
> > > + AcpiSdtTable *temp;
> > > int i;
> > >
> > > - g_free(data->rsdt_tables_addr);
> > > + if (data->rsdt_tables_addr) {
> > > + g_free(data->rsdt_tables_addr);
> > > + }
> > > +
> > > for (i = 0; i < data->ssdt_tables->len; ++i) {
> > > - g_free(g_array_index(data->ssdt_tables, AcpiSdtTable, i).aml);
> > > + temp = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
> > > + if (temp->aml) {
> > > + g_free(temp->aml);
> > > + }
> > > + if (temp->aml_file) {
> > > + if (g_strstr_len(temp->aml_file, -1, "aml-")) {
> > > + unlink(temp->aml_file);
> > > + }
> > > + g_free(temp->aml_file);
> > > + }
> > > + if (temp->asl) {
> > > + g_free(temp->asl);
> > > + }
> > > + if (temp->asl_file) {
> > > + if (g_strstr_len(temp->asl_file, -1, "asl-")) {
> > > + unlink(temp->asl_file);
> > > + }
> > > + g_free(temp->asl_file);
> > > + }
> > > }
> > > +
> > > g_array_free(data->ssdt_tables, false);
> > > - g_free(data->dsdt_table.aml);
> > > }
> > >
> > > static uint8_t acpi_checksum(const uint8_t *data, int len)
> > > @@ -292,34 +324,203 @@ static void test_dst_table(AcpiSdtTable *sdt_table, uint32_t addr)
> > > ACPI_READ_ARRAY_PTR(sdt_table->aml, sdt_table->aml_len, addr);
> > >
> > > checksum = acpi_checksum((uint8_t *)sdt_table, sizeof(AcpiTableHeader)) +
> > > - acpi_checksum(sdt_table->aml, sdt_table->aml_len);
> > > + acpi_checksum((uint8_t *)sdt_table->aml, sdt_table->aml_len);
> > > g_assert(!checksum);
> > > }
> > >
> > > static void test_acpi_dsdt_table(test_data *data)
> > > {
> > > - AcpiSdtTable *dsdt_table = &data->dsdt_table;
> > > + AcpiSdtTable dsdt_table;
> > > uint32_t addr = data->fadt_table.dsdt;
> > >
> > > - test_dst_table(dsdt_table, addr);
> > > - g_assert_cmphex(dsdt_table->header.signature, ==, ACPI_DSDT_SIGNATURE);
> > > + memset(&dsdt_table, 0, sizeof(dsdt_table));
> > > + data->ssdt_tables = g_array_new(false, true, sizeof(AcpiSdtTable));
> > > +
> > > + test_dst_table(&dsdt_table, addr);
> > > + g_assert_cmphex(dsdt_table.header.signature, ==, ACPI_DSDT_SIGNATURE);
> > > +
> > > + /* Place DSDT first */
> > > + g_array_append_val(data->ssdt_tables, dsdt_table);
> > > }
> > >
> > > static void test_acpi_ssdt_tables(test_data *data)
> > > {
> > > - GArray *ssdt_tables;
> > > int ssdt_tables_nr = data->rsdt_tables_nr - 1; /* fadt is first */
> > > int i;
> > >
> > > - ssdt_tables = g_array_sized_new(false, true, sizeof(AcpiSdtTable),
> > > - ssdt_tables_nr);
> > > for (i = 0; i < ssdt_tables_nr; i++) {
> > > AcpiSdtTable ssdt_table;
> > > +
> > > + memset(&ssdt_table, 0 , sizeof(ssdt_table));
> > > uint32_t addr = data->rsdt_tables_addr[i + 1]; /* fadt is first */
> > > test_dst_table(&ssdt_table, addr);
> > > - g_array_append_val(ssdt_tables, ssdt_table);
> > > + g_array_append_val(data->ssdt_tables, ssdt_table);
> > > + }
> > > +}
> > > +
> > > +static bool iasl_installed(void)
> > > +{
> > > + gchar *out = NULL, *out_err = NULL;
> > > + bool ret;
> > > +
> > > + /* pass 'out' and 'out_err' in order to be redirected */
> > > + ret = g_spawn_command_line_sync("iasl", &out, &out_err, NULL, NULL);
> >
> > One interesting option here is to include config-hosts.mak
> > from Makefile, then use IASL configured there.
> Would be better, I agree, expect I have
> no idea how to include this file.
In fact it already includes that I think
so just add -DCONFIG_IASL="${IASL}"
might do the trick.
> I'll look
> it up and send it as different patch as you
> suggested.
>
> Thanks for the review!
> Marcel
>
> >
> > Can be a patch on top though.
> >
> > > +
> > > + if (out_err) {
> > > + ret = ret && (out_err[0] == '\0');
> > > + g_free(out_err);
> > > }
> > > - data->ssdt_tables = ssdt_tables;
> > > +
> > > + if (out) {
> > > + g_free(out);
> > > + }
> > > +
> > > + return ret;
> > > +}
> > > +
> > > +static void dump_aml_files(test_data *data)
> > > +{
> > > + AcpiSdtTable *sdt;
> > > + GError *error = NULL;
> > > + gint fd;
> > > + int i;
> > > +
> > > + for (i = 0; i < data->ssdt_tables->len; ++i) {
> > > + sdt = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
> > > + g_assert(sdt->aml);
> > > +
> > > + fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error);
> > > + g_assert_no_error(error);
> > > +
> > > + write(fd, sdt, sizeof(AcpiTableHeader));
> > > + write(fd, sdt->aml, sdt->aml_len);
> > > + close(fd);
> > > + }
> > > +}
> > > +
> > > +static void load_asl(GArray *sdts, AcpiSdtTable *sdt)
> > > +{
> > > + AcpiSdtTable *temp;
> > > + GError *error = NULL;
> > > + GString *command_line = g_string_new("'iasl' ");
> > > + gint fd;
> > > + gchar *out, *out_err;
> > > + gboolean ret;
> > > + int i;
> > > +
> > > + fd = g_file_open_tmp("asl-XXXXXX.dsl", &sdt->asl_file, &error);
> > > + g_assert_no_error(error);
> > > + close(fd);
> > > +
> > > + /* build command line */
> > > + g_string_append_printf(command_line, "-p %s ", sdt->asl_file);
> > > + for (i = 0; i < 2; ++i) { /* reference DSDT and SSDT */
> > > + temp = &g_array_index(sdts, AcpiSdtTable, i);
> > > + g_string_append_printf(command_line, "-e %s ", temp->aml_file);
> > > + }
> > > + g_string_append_printf(command_line, "-d %s", sdt->aml_file);
> > > +
> > > + /* pass 'out' and 'out_err' in order to be redirected */
> > > + g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error);
> > > + g_assert_no_error(error);
> > > +
> > > + ret = g_file_get_contents(sdt->asl_file, (gchar **)&sdt->asl,
> > > + &sdt->asl_len, &error);
> > > + g_assert(ret);
> > > + g_assert_no_error(error);
> > > + g_assert(sdt->asl_len);
> > > +
> > > + g_free(out);
> > > + g_free(out_err);
> > > + g_string_free(command_line, true);
> > > +}
> > > +
> > > +#define COMMENT_END "*/"
> > > +#define DEF_BLOCK "DefinitionBlock ("
> > > +#define BLOCK_NAME_END ".aml"
> > > +
> > > +static GString *normalize_asl(gchar *asl_code)
> > > +{
> > > + GString *asl = g_string_new(asl_code);
> > > + gchar *comment, *block_name;
> > > +
> > > + /* strip comments (different generation days) */
> > > + comment = g_strstr_len(asl->str, asl->len, COMMENT_END);
> > > + if (comment) {
> > > + asl = g_string_erase(asl, 0, comment + sizeof(COMMENT_END) - asl->str);
> > > + }
> > > +
> > > + /* strip def block name (it has file path in it) */
> > > + if (g_str_has_prefix(asl->str, DEF_BLOCK)) {
> > > + block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);
> > > + g_assert(block_name);
> > > + asl = g_string_erase(asl, 0,
> > > + block_name + sizeof(BLOCK_NAME_END) - asl->str);
> > > + }
> > > +
> > > + return asl;
> > > +}
> > > +
> > > +static GArray *load_expected_aml(test_data *data)
> > > +{
> > > + int i;
> > > + AcpiSdtTable *sdt;
> > > + gchar *aml_file;
> > > + GError *error = NULL;
> > > + gboolean ret;
> > > +
> > > + GArray *exp_ssdt_tables = g_array_new(false, true, sizeof(AcpiSdtTable));
> > > + for (i = 0; i < data->ssdt_tables->len; ++i) {
> > > + AcpiSdtTable exp_sdt;
> > > + sdt = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
> > > +
> > > + memset(&exp_sdt, 0, sizeof(exp_sdt));
> > > + exp_sdt.header.signature = sdt->header.signature;
> > > +
> > > + aml_file = g_strdup_printf("%s/%s/%.4s", data_dir, data->machine,
> > > + (gchar *)&exp_sdt.header.signature);
> > > + exp_sdt.aml_file = aml_file;
> > > + g_assert(g_file_test(aml_file, G_FILE_TEST_EXISTS));
> > > + ret = g_file_get_contents(aml_file, &exp_sdt.aml,
> > > + &exp_sdt.aml_len, &error);
> > > + g_assert(ret);
> > > + g_assert_no_error(error);
> > > + g_assert(exp_sdt.aml);
> > > + g_assert(exp_sdt.aml_len);
> > > +
> > > + g_array_append_val(exp_ssdt_tables, exp_sdt);
> > > + }
> > > +
> > > + return exp_ssdt_tables;
> > > +}
> > > +
> > > +static void test_acpi_asl(test_data *data)
> > > +{
> > > + int i;
> > > + AcpiSdtTable *sdt, *exp_sdt;
> > > + test_data exp_data;
> > > +
> > > + memset(&exp_data, 0, sizeof(exp_data));
> > > + exp_data.ssdt_tables = load_expected_aml(data);
> > > + dump_aml_files(data);
> > > + for (i = 0; i < data->ssdt_tables->len; ++i) {
> > > + GString *asl, *exp_asl;
> > > +
> > > + sdt = &g_array_index(data->ssdt_tables, AcpiSdtTable, i);
> > > + exp_sdt = &g_array_index(exp_data.ssdt_tables, AcpiSdtTable, i);
> > > +
> > > + load_asl(data->ssdt_tables, sdt);
> > > + asl = normalize_asl(sdt->asl);
> > > +
> > > + load_asl(exp_data.ssdt_tables, exp_sdt);
> > > + exp_asl = normalize_asl(exp_sdt->asl);
> > > +
> > > + g_assert(!g_strcmp0(asl->str, exp_asl->str));
> > > + g_string_free(asl, true);
> > > + g_string_free(exp_asl, true);
> > > + }
> > > +
> > > + free_test_data(&exp_data);
> > > }
> > >
> > > static void test_acpi_one(const char *params, test_data *data)
> > > @@ -329,10 +530,14 @@ static void test_acpi_one(const char *params, test_data *data)
> > > uint8_t signature_high;
> > > uint16_t signature;
> > > int i;
> > > + const char *device = "";
> > >
> > > - memset(data, 0, sizeof(*data));
> > > - args = g_strdup_printf("-net none -display none %s %s",
> > > - params ? params : "", disk);
> > > + if (!g_strcmp0(data->machine, MACHINE_Q35)) {
> > > + device = ",id=hd -device ide-hd,drive=hd";
> > > + }
> > > +
> > > + args = g_strdup_printf("-net none -display none %s -drive file=%s%s,",
> > > + params ? params : "", disk, device);
> > > qtest_start(args);
> > >
> > > /* Wait at most 1 minute */
> > > @@ -362,6 +567,10 @@ static void test_acpi_one(const char *params, test_data *data)
> > > test_acpi_dsdt_table(data);
> > > test_acpi_ssdt_tables(data);
> > >
> > > + if (iasl_installed()) {
> > > + test_acpi_asl(data);
> > > + }
> > > +
> > > qtest_quit(global_qtest);
> > > g_free(args);
> > > }
> > > @@ -373,8 +582,14 @@ static void test_acpi_tcg(void)
> > > /* Supplying -machine accel argument overrides the default (qtest).
> > > * This is to make guest actually run.
> > > */
> > > + memset(&data, 0, sizeof(data));
> > > + data.machine = MACHINE_PC;
> > > test_acpi_one("-machine accel=tcg", &data);
> > > + free_test_data(&data);
> > >
> > > + memset(&data, 0, sizeof(data));
> > > + data.machine = MACHINE_Q35;
> > > + test_acpi_one("-machine q35,accel=tcg", &data);
> > > free_test_data(&data);
> > > }
> > >
> > > --
> > > 1.8.3.1
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-12-23 15:22 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-23 10:13 [Qemu-devel] [PATCH v2 0/3] acpi unit-test: compare resulting aml vs expected aml Marcel Apfelbaum
2013-12-23 10:13 ` [Qemu-devel] [PATCH v2 1/3] acpi unit-test: add test files Marcel Apfelbaum
2013-12-23 10:13 ` [Qemu-devel] [PATCH v2 2/3] configure: added acpi unit-test files Marcel Apfelbaum
2013-12-23 10:13 ` [Qemu-devel] [PATCH v2 3/3] acpi unit-test: compare DSDT and SSDT tables against expected values Marcel Apfelbaum
2013-12-23 12:06 ` Michael S. Tsirkin
2013-12-23 12:22 ` Marcel Apfelbaum
2013-12-23 15:26 ` Michael S. Tsirkin
2013-12-23 12:02 ` [Qemu-devel] [PATCH v2 0/3] acpi unit-test: compare resulting aml vs expected aml Michael S. Tsirkin
2013-12-23 12:18 ` Marcel Apfelbaum
2013-12-23 14:59 ` Michael S. Tsirkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).