* [Qemu-devel] [PATCH v3 0/2] acpi unit-test: rebuild aml files functionality @ 2013-12-26 14:07 Marcel Apfelbaum 2013-12-26 14:07 ` [Qemu-devel] [PATCH v3 1/2] acpi unit-test: added script to rebuild the expected aml files Marcel Apfelbaum 2013-12-26 14:07 ` [Qemu-devel] [PATCH v3 2/2] acpi unit-test: hook to rebuild " Marcel Apfelbaum 0 siblings, 2 replies; 6+ messages in thread From: Marcel Apfelbaum @ 2013-12-26 14:07 UTC (permalink / raw) To: qemu-devel; +Cc: mst Acpi unit-test will fail every time the acpi tables change. The series adds a script that rebuilds the expected aml files, so the test will pass. It also validates the modifications. The acpi unit test will rebuild the aml tables if TEST_ACPI_REBUILD_AML environment variable is set. v2 -> v3: Addressed Michael S. Tsirkin's comments: - Used qemu_write_full instead of write - Some trailing space v1 -> v2: Addressed Michael S. Tsirkin's comments: - added TEST_ prefix to the environment variable - some rephrases Marcel Apfelbaum (2): acpi unit-test: added script to rebuild the expected aml files acpi unit-test: hook to rebuild expected aml files tests/acpi-test-data/rebuild-expected-aml.sh | 36 +++++++++++++++++++++++++++ tests/acpi-test.c | 37 ++++++++++++++++++++++------ 2 files changed, 66 insertions(+), 7 deletions(-) create mode 100755 tests/acpi-test-data/rebuild-expected-aml.sh -- 1.8.3.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v3 1/2] acpi unit-test: added script to rebuild the expected aml files 2013-12-26 14:07 [Qemu-devel] [PATCH v3 0/2] acpi unit-test: rebuild aml files functionality Marcel Apfelbaum @ 2013-12-26 14:07 ` Marcel Apfelbaum 2013-12-26 14:07 ` [Qemu-devel] [PATCH v3 2/2] acpi unit-test: hook to rebuild " Marcel Apfelbaum 1 sibling, 0 replies; 6+ messages in thread From: Marcel Apfelbaum @ 2013-12-26 14:07 UTC (permalink / raw) To: qemu-devel; +Cc: mst Acpi unit-test will fail every time the acpi tables change. This script rebuild the expected aml files, so the test will pass. It also validates the modifications. Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com> --- v2 -> v3: Addressed Michael S. Tsirkin's comments: - Some trailing space v1 -> v2: Addressed Michael S. Tsirkin's comments: - added TEST_ prefix to the environment variable - some rephrases tests/acpi-test-data/rebuild-expected-aml.sh | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 tests/acpi-test-data/rebuild-expected-aml.sh diff --git a/tests/acpi-test-data/rebuild-expected-aml.sh b/tests/acpi-test-data/rebuild-expected-aml.sh new file mode 100755 index 0000000..ab98498 --- /dev/null +++ b/tests/acpi-test-data/rebuild-expected-aml.sh @@ -0,0 +1,36 @@ +#! /bin/bash + +# +# Rebuild expected AML files for acpi unit-test +# +# Copyright (c) 2013 Red Hat Inc. +# +# Authors: +# Marcel Apfelbaum <marcel.a@redhat.com> +# +# This work is licensed under the terms of the GNU GPLv2. +# See the COPYING.LIB file in the top-level directory. + +qemu= + +if [ -e x86_64-softmmu/qemu-system-x86_64 ]; then + qemu="x86_64-softmmu/qemu-system-x86_64" +elif [ -e i386-softmmu/qemu-system-i386 ]; then + qemu="i386-softmmu/qemu-system-i386" +else + echo "Run 'make' to build the qemu exectutable!" + echo "Run this script from the build directory." + exit 1; +fi + +if [ ! -e "tests/acpi-test" ]; then + echo "Test: acpi-test is required! Run make check before this script." + echo "Run this script from the build directory." + exit 1; +fi + +TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/acpi-test + +echo "The files were rebuilt and can be added to git." +echo "However, if new files were created, please copy them manually" \ + "to tests/acpi-test-data/pc/ or tests/acpi-test-data/q35/ ." -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v3 2/2] acpi unit-test: hook to rebuild expected aml files 2013-12-26 14:07 [Qemu-devel] [PATCH v3 0/2] acpi unit-test: rebuild aml files functionality Marcel Apfelbaum 2013-12-26 14:07 ` [Qemu-devel] [PATCH v3 1/2] acpi unit-test: added script to rebuild the expected aml files Marcel Apfelbaum @ 2013-12-26 14:07 ` Marcel Apfelbaum 2013-12-26 14:24 ` Michael S. Tsirkin 1 sibling, 1 reply; 6+ messages in thread From: Marcel Apfelbaum @ 2013-12-26 14:07 UTC (permalink / raw) To: qemu-devel; +Cc: mst When running the test with TEST_ACPI_REBUILD_AML=y environment variable, the test will rebuild and validate the expected aml files. Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com> --- v2 -> v3: Addressed Michael S. Tsirkin's comments: - Used qemu_write_full instead of write v1 -> v2: Addressed Michael S. Tsirkin's comments: - added TEST_ prefix to the environment variable tests/acpi-test.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/tests/acpi-test.c b/tests/acpi-test.c index 954d9b9..5aa0a00 100644 --- a/tests/acpi-test.c +++ b/tests/acpi-test.c @@ -13,6 +13,7 @@ #include <string.h> #include <stdio.h> #include <glib.h> +#include <glib/gstdio.h> #include "qemu-common.h" #include "libqtest.h" #include "qemu/compiler.h" @@ -21,6 +22,8 @@ #define MACHINE_PC "pc" #define MACHINE_Q35 "q35" +#define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML" + /* DSDT and SSDTs format */ typedef struct { AcpiTableHeader header; @@ -363,23 +366,39 @@ static void test_acpi_ssdt_tables(test_data *data) } } -static void dump_aml_files(test_data *data) +static void dump_aml_files(test_data *data, bool rebuild) { AcpiSdtTable *sdt; GError *error = NULL; + gchar *aml_file = NULL; gint fd; int i; + ssize_t ret; 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); + if (rebuild) { + aml_file = g_strdup_printf("%s/%s/%.4s", data_dir, data->machine, + (gchar *)&sdt->header.signature); + fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT, + S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); + } else { + fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error); + g_assert_no_error(error); + } + g_assert(fd >= 0); - write(fd, sdt, sizeof(AcpiTableHeader)); - write(fd, sdt->aml, sdt->aml_len); + ret = qemu_write_full(fd, sdt, sizeof(AcpiTableHeader)); + g_assert(ret == sizeof(AcpiTableHeader)); + ret = qemu_write_full(fd, sdt->aml, sdt->aml_len); + g_assert(ret == sdt->aml_len); close(fd); + + if (aml_file) { + g_free(aml_file); + } } } @@ -487,7 +506,7 @@ static void test_acpi_asl(test_data *data) memset(&exp_data, 0, sizeof(exp_data)); exp_data.ssdt_tables = load_expected_aml(data); - dump_aml_files(data); + dump_aml_files(data, false); for (i = 0; i < data->ssdt_tables->len; ++i) { GString *asl, *exp_asl; @@ -553,7 +572,11 @@ static void test_acpi_one(const char *params, test_data *data) test_acpi_ssdt_tables(data); if (iasl) { - test_acpi_asl(data); + if (getenv(ACPI_REBUILD_EXPECTED_AML)) { + dump_aml_files(data, true); + } else { + test_acpi_asl(data); + } } qtest_quit(global_qtest); -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v3 2/2] acpi unit-test: hook to rebuild expected aml files 2013-12-26 14:07 ` [Qemu-devel] [PATCH v3 2/2] acpi unit-test: hook to rebuild " Marcel Apfelbaum @ 2013-12-26 14:24 ` Michael S. Tsirkin 2013-12-26 14:28 ` Marcel Apfelbaum 2013-12-26 14:30 ` Marcel Apfelbaum 0 siblings, 2 replies; 6+ messages in thread From: Michael S. Tsirkin @ 2013-12-26 14:24 UTC (permalink / raw) To: Marcel Apfelbaum; +Cc: qemu-devel On Thu, Dec 26, 2013 at 04:07:59PM +0200, Marcel Apfelbaum wrote: > When running the test with TEST_ACPI_REBUILD_AML=y environment > variable, the test will rebuild and validate the expected aml > files. > > Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com> > --- > v2 -> v3: > Addressed Michael S. Tsirkin's comments: > - Used qemu_write_full instead of write > v1 -> v2: > Addressed Michael S. Tsirkin's comments: > - added TEST_ prefix to the environment variable > > tests/acpi-test.c | 37 ++++++++++++++++++++++++++++++------- > 1 file changed, 30 insertions(+), 7 deletions(-) > > diff --git a/tests/acpi-test.c b/tests/acpi-test.c > index 954d9b9..5aa0a00 100644 > --- a/tests/acpi-test.c > +++ b/tests/acpi-test.c > @@ -13,6 +13,7 @@ > #include <string.h> > #include <stdio.h> > #include <glib.h> > +#include <glib/gstdio.h> > #include "qemu-common.h" > #include "libqtest.h" > #include "qemu/compiler.h" > @@ -21,6 +22,8 @@ > #define MACHINE_PC "pc" > #define MACHINE_Q35 "q35" > > +#define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML" > + > /* DSDT and SSDTs format */ > typedef struct { > AcpiTableHeader header; > @@ -363,23 +366,39 @@ static void test_acpi_ssdt_tables(test_data *data) > } > } > > -static void dump_aml_files(test_data *data) > +static void dump_aml_files(test_data *data, bool rebuild) > { > AcpiSdtTable *sdt; > GError *error = NULL; > + gchar *aml_file = NULL; > gint fd; > int i; > + ssize_t ret; > > 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); > + if (rebuild) { > + aml_file = g_strdup_printf("%s/%s/%.4s", data_dir, data->machine, > + (gchar *)&sdt->header.signature); > + fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT, > + S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); > + } else { > + fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error); > + g_assert_no_error(error); > + } > + g_assert(fd >= 0); > > - write(fd, sdt, sizeof(AcpiTableHeader)); > - write(fd, sdt->aml, sdt->aml_len); Please fix the original patch up and resend the whole series - it's not a good idea to break bisect. So just smash this patch into the previous one. > + ret = qemu_write_full(fd, sdt, sizeof(AcpiTableHeader)); > + g_assert(ret == sizeof(AcpiTableHeader)); > + ret = qemu_write_full(fd, sdt->aml, sdt->aml_len); > + g_assert(ret == sdt->aml_len); > close(fd); > + > + if (aml_file) { > + g_free(aml_file); > + } > } > } > > @@ -487,7 +506,7 @@ static void test_acpi_asl(test_data *data) > > memset(&exp_data, 0, sizeof(exp_data)); > exp_data.ssdt_tables = load_expected_aml(data); > - dump_aml_files(data); > + dump_aml_files(data, false); > for (i = 0; i < data->ssdt_tables->len; ++i) { > GString *asl, *exp_asl; > > @@ -553,7 +572,11 @@ static void test_acpi_one(const char *params, test_data *data) > test_acpi_ssdt_tables(data); > > if (iasl) { > - test_acpi_asl(data); > + if (getenv(ACPI_REBUILD_EXPECTED_AML)) { > + dump_aml_files(data, true); > + } else { > + test_acpi_asl(data); > + } > } > > qtest_quit(global_qtest); > -- > 1.8.3.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v3 2/2] acpi unit-test: hook to rebuild expected aml files 2013-12-26 14:24 ` Michael S. Tsirkin @ 2013-12-26 14:28 ` Marcel Apfelbaum 2013-12-26 14:30 ` Marcel Apfelbaum 1 sibling, 0 replies; 6+ messages in thread From: Marcel Apfelbaum @ 2013-12-26 14:28 UTC (permalink / raw) To: Michael S. Tsirkin; +Cc: qemu-devel On Thu, 2013-12-26 at 16:24 +0200, Michael S. Tsirkin wrote: > On Thu, Dec 26, 2013 at 04:07:59PM +0200, Marcel Apfelbaum wrote: > > When running the test with TEST_ACPI_REBUILD_AML=y environment > > variable, the test will rebuild and validate the expected aml > > files. > > > > Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com> > > --- > > v2 -> v3: > > Addressed Michael S. Tsirkin's comments: > > - Used qemu_write_full instead of write > > v1 -> v2: > > Addressed Michael S. Tsirkin's comments: > > - added TEST_ prefix to the environment variable > > > > tests/acpi-test.c | 37 ++++++++++++++++++++++++++++++------- > > 1 file changed, 30 insertions(+), 7 deletions(-) > > > > diff --git a/tests/acpi-test.c b/tests/acpi-test.c > > index 954d9b9..5aa0a00 100644 > > --- a/tests/acpi-test.c > > +++ b/tests/acpi-test.c > > @@ -13,6 +13,7 @@ > > #include <string.h> > > #include <stdio.h> > > #include <glib.h> > > +#include <glib/gstdio.h> > > #include "qemu-common.h" > > #include "libqtest.h" > > #include "qemu/compiler.h" > > @@ -21,6 +22,8 @@ > > #define MACHINE_PC "pc" > > #define MACHINE_Q35 "q35" > > > > +#define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML" > > + > > /* DSDT and SSDTs format */ > > typedef struct { > > AcpiTableHeader header; > > @@ -363,23 +366,39 @@ static void test_acpi_ssdt_tables(test_data *data) > > } > > } > > > > -static void dump_aml_files(test_data *data) > > +static void dump_aml_files(test_data *data, bool rebuild) > > { > > AcpiSdtTable *sdt; > > GError *error = NULL; > > + gchar *aml_file = NULL; > > gint fd; > > int i; > > + ssize_t ret; > > > > 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); > > + if (rebuild) { > > + aml_file = g_strdup_printf("%s/%s/%.4s", data_dir, data->machine, > > + (gchar *)&sdt->header.signature); > > + fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT, > > + S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); > > + } else { > > + fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error); > > + g_assert_no_error(error); > > + } > > + g_assert(fd >= 0); > > > > - write(fd, sdt, sizeof(AcpiTableHeader)); > > - write(fd, sdt->aml, sdt->aml_len); > > Please fix the original patch up and resend the whole series - > it's not a good idea to break bisect. > > So just smash this patch into the previous one. It is exactly what I did (and resent the whole series), did I miss anything? Thanks, Marcel > > > + ret = qemu_write_full(fd, sdt, sizeof(AcpiTableHeader)); > > + g_assert(ret == sizeof(AcpiTableHeader)); > > + ret = qemu_write_full(fd, sdt->aml, sdt->aml_len); > > + g_assert(ret == sdt->aml_len); > > close(fd); > > + > > + if (aml_file) { > > + g_free(aml_file); > > + } > > } > > } > > > > @@ -487,7 +506,7 @@ static void test_acpi_asl(test_data *data) > > > > memset(&exp_data, 0, sizeof(exp_data)); > > exp_data.ssdt_tables = load_expected_aml(data); > > - dump_aml_files(data); > > + dump_aml_files(data, false); > > for (i = 0; i < data->ssdt_tables->len; ++i) { > > GString *asl, *exp_asl; > > > > @@ -553,7 +572,11 @@ static void test_acpi_one(const char *params, test_data *data) > > test_acpi_ssdt_tables(data); > > > > if (iasl) { > > - test_acpi_asl(data); > > + if (getenv(ACPI_REBUILD_EXPECTED_AML)) { > > + dump_aml_files(data, true); > > + } else { > > + test_acpi_asl(data); > > + } > > } > > > > qtest_quit(global_qtest); > > -- > > 1.8.3.1 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v3 2/2] acpi unit-test: hook to rebuild expected aml files 2013-12-26 14:24 ` Michael S. Tsirkin 2013-12-26 14:28 ` Marcel Apfelbaum @ 2013-12-26 14:30 ` Marcel Apfelbaum 1 sibling, 0 replies; 6+ messages in thread From: Marcel Apfelbaum @ 2013-12-26 14:30 UTC (permalink / raw) To: Michael S. Tsirkin; +Cc: qemu-devel On Thu, 2013-12-26 at 16:24 +0200, Michael S. Tsirkin wrote: > On Thu, Dec 26, 2013 at 04:07:59PM +0200, Marcel Apfelbaum wrote: > > When running the test with TEST_ACPI_REBUILD_AML=y environment > > variable, the test will rebuild and validate the expected aml > > files. > > > > Signed-off-by: Marcel Apfelbaum <marcel.a@redhat.com> > > --- > > v2 -> v3: > > Addressed Michael S. Tsirkin's comments: > > - Used qemu_write_full instead of write > > v1 -> v2: > > Addressed Michael S. Tsirkin's comments: > > - added TEST_ prefix to the environment variable > > > > tests/acpi-test.c | 37 ++++++++++++++++++++++++++++++------- > > 1 file changed, 30 insertions(+), 7 deletions(-) > > > > diff --git a/tests/acpi-test.c b/tests/acpi-test.c > > index 954d9b9..5aa0a00 100644 > > --- a/tests/acpi-test.c > > +++ b/tests/acpi-test.c > > @@ -13,6 +13,7 @@ > > #include <string.h> > > #include <stdio.h> > > #include <glib.h> > > +#include <glib/gstdio.h> > > #include "qemu-common.h" > > #include "libqtest.h" > > #include "qemu/compiler.h" > > @@ -21,6 +22,8 @@ > > #define MACHINE_PC "pc" > > #define MACHINE_Q35 "q35" > > > > +#define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML" > > + > > /* DSDT and SSDTs format */ > > typedef struct { > > AcpiTableHeader header; > > @@ -363,23 +366,39 @@ static void test_acpi_ssdt_tables(test_data *data) > > } > > } > > > > -static void dump_aml_files(test_data *data) > > +static void dump_aml_files(test_data *data, bool rebuild) > > { > > AcpiSdtTable *sdt; > > GError *error = NULL; > > + gchar *aml_file = NULL; > > gint fd; > > int i; > > + ssize_t ret; > > > > 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); > > + if (rebuild) { > > + aml_file = g_strdup_printf("%s/%s/%.4s", data_dir, data->machine, > > + (gchar *)&sdt->header.signature); > > + fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT, > > + S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); > > + } else { > > + fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error); > > + g_assert_no_error(error); > > + } > > + g_assert(fd >= 0); > > > > - write(fd, sdt, sizeof(AcpiTableHeader)); > > - write(fd, sdt->aml, sdt->aml_len); > > Please fix the original patch up and resend the whole series - > it's not a good idea to break bisect. I finally understood, the prev series :) I am sending both of them shortly. Thanks, Marcel > > So just smash this patch into the previous one. > > > + ret = qemu_write_full(fd, sdt, sizeof(AcpiTableHeader)); > > + g_assert(ret == sizeof(AcpiTableHeader)); > > + ret = qemu_write_full(fd, sdt->aml, sdt->aml_len); > > + g_assert(ret == sdt->aml_len); > > close(fd); > > + > > + if (aml_file) { > > + g_free(aml_file); > > + } > > } > > } > > > > @@ -487,7 +506,7 @@ static void test_acpi_asl(test_data *data) > > > > memset(&exp_data, 0, sizeof(exp_data)); > > exp_data.ssdt_tables = load_expected_aml(data); > > - dump_aml_files(data); > > + dump_aml_files(data, false); > > for (i = 0; i < data->ssdt_tables->len; ++i) { > > GString *asl, *exp_asl; > > > > @@ -553,7 +572,11 @@ static void test_acpi_one(const char *params, test_data *data) > > test_acpi_ssdt_tables(data); > > > > if (iasl) { > > - test_acpi_asl(data); > > + if (getenv(ACPI_REBUILD_EXPECTED_AML)) { > > + dump_aml_files(data, true); > > + } else { > > + test_acpi_asl(data); > > + } > > } > > > > qtest_quit(global_qtest); > > -- > > 1.8.3.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-12-26 14:30 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-12-26 14:07 [Qemu-devel] [PATCH v3 0/2] acpi unit-test: rebuild aml files functionality Marcel Apfelbaum 2013-12-26 14:07 ` [Qemu-devel] [PATCH v3 1/2] acpi unit-test: added script to rebuild the expected aml files Marcel Apfelbaum 2013-12-26 14:07 ` [Qemu-devel] [PATCH v3 2/2] acpi unit-test: hook to rebuild " Marcel Apfelbaum 2013-12-26 14:24 ` Michael S. Tsirkin 2013-12-26 14:28 ` Marcel Apfelbaum 2013-12-26 14:30 ` Marcel Apfelbaum
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).