Skip to contentSkip to conversation

bios-tables-test: more documentation

PATCH In review Michael S. Tsirkin 3 participants 12 messages Jan 22, 2020

lore
Share & tools
lore
#0 lore raw

cover bios-tables-test: more documentation

Better error messages, documentation tweaks to help people follow the process for expected file updates.

Michael S. Tsirkin (5):
bios-tables-test: tell people how to update
bios-tables-test: fix up DIFF generation
bios-tables-test: default diff command
bios-tables-test: fix path to allowed diff rebuild-expected-aml.sh: remind about the process

 tests/qtest/bios-tables-test.c          | 32 ++++++++++++-------------
 tests/data/acpi/rebuild-expected-aml.sh |  7 ++++++
 2 files changed, 23 insertions(+), 16 deletions(-)
Signature · 1 line
MST
#1 lore raw

PATCH 1/5 bios-tables-test: tell people how to update

For now just a pointer to the source file.

---
 tests/qtest/bios-tables-test.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/qtest/bios-tables-test.c +3 -1
index 3ab4872bd7..6b5f24bf62 100644
@@ -426,7 +426,9 @@ static void test_acpi_asl(test_data *data)
 
         fprintf(stderr,
                 "acpi-test: Warning! %.4s binary file mismatch. "
-                "Actual [aml:%s], Expected [aml:%s].\n",
+                "Actual [aml:%s], Expected [aml:%s].\n"
+                "See source file tests/qtest/bios-tables-test.c "
+                "for instructions on how to update expected files.\n",
                 exp_sdt->aml, sdt->aml_file, exp_sdt->aml_file);
 
         all_tables_match = all_tables_match &&
Signature · 1 line
MST
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] bios-tables-test: tell people how to update

Quoted 13 lines · Michael S. Tsirkin

For now just a pointer to the source file.

---
 tests/qtest/bios-tables-test.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/qtest/bios-tables-test.c +0 -0
index 3ab4872bd7..6b5f24bf62 100644

tests/qtest/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 434

Quoted 10 lines
tests/qtest/bios-tables-test.c +3 -1
@@ -426,7 +426,9 @@ static void test_acpi_asl(test_data *data)
 
         fprintf(stderr,
                 "acpi-test: Warning! %.4s binary file mismatch. "
-                "Actual [aml:%s], Expected [aml:%s].\n",
+                "Actual [aml:%s], Expected [aml:%s].\n"
+                "See source file tests/qtest/bios-tables-test.c "
+                "for instructions on how to update expected files.\n",
                 exp_sdt->aml, sdt->aml_file, exp_sdt->aml_file);
 
         all_tables_match = all_tables_match &&
Reviewed-by on v1 1/5
#3 lore raw

Re: [PATCH 1/5] bios-tables-test: tell people how to update

In reply to Michael S. Tsirkin
Quoted 13 lines · Michael S. Tsirkin

For now just a pointer to the source file.

---
 tests/qtest/bios-tables-test.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/qtest/bios-tables-test.c +0 -0
index 3ab4872bd7..6b5f24bf62 100644

tests/qtest/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 434

Quoted 10 lines
tests/qtest/bios-tables-test.c +3 -1
@@ -426,7 +426,9 @@ static void test_acpi_asl(test_data *data)
 
         fprintf(stderr,
                 "acpi-test: Warning! %.4s binary file mismatch. "
-                "Actual [aml:%s], Expected [aml:%s].\n",
+                "Actual [aml:%s], Expected [aml:%s].\n"
+                "See source file tests/qtest/bios-tables-test.c "
+                "for instructions on how to update expected files.\n",
                 exp_sdt->aml, sdt->aml_file, exp_sdt->aml_file);
 
         all_tables_match = all_tables_match &&
#4 lore raw

PATCH 2/5 bios-tables-test: fix up DIFF generation

In reply to Michael S. Tsirkin

Turns out it goes to stdout which is suppressed even with V=1. Force DIFF output to stderr to make it visible.

---
 tests/qtest/bios-tables-test.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tests/qtest/bios-tables-test.c +6 -1
index 6b5f24bf62..c8db2839b2 100644
@@ -463,13 +463,18 @@ static void test_acpi_asl(test_data *data)
                         "Actual [asl:%s, aml:%s], Expected [asl:%s, aml:%s].\n",
                         exp_sdt->aml, sdt->asl_file, sdt->aml_file,
                         exp_sdt->asl_file, exp_sdt->aml_file);
+                fflush(stderr);
                 if (getenv("V")) {
                     const char *diff_cmd = getenv("DIFF");
                     if (diff_cmd) {
-                        int ret G_GNUC_UNUSED;
                         char *diff = g_strdup_printf("%s %s %s", diff_cmd,
                             exp_sdt->asl_file, sdt->asl_file);
+                        int out = dup(STDOUT_FILENO);
+                        int ret G_GNUC_UNUSED;
+
+                        dup2(STDERR_FILENO, STDOUT_FILENO);
                         ret = system(diff) ;
+                        dup2(out, STDOUT_FILENO);
                         g_free(diff);
                     } else {
                         fprintf(stderr, "acpi-test: Warning. not showing "
Signature · 1 line
MST
#5 lore raw

Re: [PATCH 2/5] bios-tables-test: fix up DIFF generation

Quoted 19 lines · Michael S. Tsirkin

Turns out it goes to stdout which is suppressed even with V=1. Force DIFF output to stderr to make it visible.

---
 tests/qtest/bios-tables-test.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tests/qtest/bios-tables-test.c +1 -0
index 6b5f24bf62..c8db2839b2 100644
@@ -463,13 +463,18 @@ static void test_acpi_asl(test_data *data)
                         "Actual [asl:%s, aml:%s], Expected [asl:%s, aml:%s].\n",
                         exp_sdt->aml, sdt->asl_file, sdt->aml_file,
                         exp_sdt->asl_file, exp_sdt->aml_file);
+                fflush(stderr);
                 if (getenv("V")) {
                     const char *diff_cmd = getenv("DIFF");

tests/qtest/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 477

Quoted 10 lines
tests/qtest/bios-tables-test.c +5 -1
                     if (diff_cmd) {
-                        int ret G_GNUC_UNUSED;
                         char *diff = g_strdup_printf("%s %s %s", diff_cmd,
                             exp_sdt->asl_file, sdt->asl_file);
+                        int out = dup(STDOUT_FILENO);
+                        int ret G_GNUC_UNUSED;
+
+                        dup2(STDERR_FILENO, STDOUT_FILENO);
                         ret = system(diff) ;
+                        dup2(out, STDOUT_FILENO);

I think you need a "close(out)" here.

Thanks,
Laurent

#6 lore raw

Re: [PATCH 2/5] bios-tables-test: fix up DIFF generation

Quoted 33 lines · Laurent Vivier
Quoted 19 lines · Michael S. Tsirkin

Turns out it goes to stdout which is suppressed even with V=1. Force DIFF output to stderr to make it visible.

---
 tests/qtest/bios-tables-test.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tests/qtest/bios-tables-test.c +1 -0
index 6b5f24bf62..c8db2839b2 100644
@@ -463,13 +463,18 @@ static void test_acpi_asl(test_data *data)
                         "Actual [asl:%s, aml:%s], Expected [asl:%s, aml:%s].\n",
                         exp_sdt->aml, sdt->asl_file, sdt->aml_file,
                         exp_sdt->asl_file, exp_sdt->aml_file);
+                fflush(stderr);
                 if (getenv("V")) {
                     const char *diff_cmd = getenv("DIFF");

tests/qtest/bios-tables-test.c static void test_acpi_asl(test_data *data) · line 477

Quoted 10 lines
tests/qtest/bios-tables-test.c +5 -1
                     if (diff_cmd) {
-                        int ret G_GNUC_UNUSED;
                         char *diff = g_strdup_printf("%s %s %s", diff_cmd,
                             exp_sdt->asl_file, sdt->asl_file);
+                        int out = dup(STDOUT_FILENO);
+                        int ret G_GNUC_UNUSED;
+
+                        dup2(STDERR_FILENO, STDOUT_FILENO);
                         ret = system(diff) ;
+                        dup2(out, STDOUT_FILENO);

I think you need a "close(out)" here.

Quoted 2 lines

Thanks,
Laurent

Can't hurt, thanks!

#7 lore raw

PATCH 3/5 bios-tables-test: default diff command

In reply to Michael S. Tsirkin

Most people probably just want diff -u. So let's use that as the default.

---
 tests/qtest/bios-tables-test.c | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)
tests/qtest/bios-tables-test.c +10 -17
index c8db2839b2..6ec1c5be64 100644
@@ -465,24 +465,17 @@ static void test_acpi_asl(test_data *data)
                         exp_sdt->asl_file, exp_sdt->aml_file);
                 fflush(stderr);
                 if (getenv("V")) {
-                    const char *diff_cmd = getenv("DIFF");
-                    if (diff_cmd) {
-                        char *diff = g_strdup_printf("%s %s %s", diff_cmd,
-                            exp_sdt->asl_file, sdt->asl_file);
-                        int out = dup(STDOUT_FILENO);
-                        int ret G_GNUC_UNUSED;
+                    const char *diff_env = getenv("DIFF");
+                    const char *diff_cmd = diff_env ? diff_env : "diff -u";
+                    char *diff = g_strdup_printf("%s %s %s", diff_cmd,
+                                                 exp_sdt->asl_file, sdt->asl_file);
+                    int out = dup(STDOUT_FILENO);
+                    int ret G_GNUC_UNUSED;
 
-                        dup2(STDERR_FILENO, STDOUT_FILENO);
-                        ret = system(diff) ;
-                        dup2(out, STDOUT_FILENO);
-                        g_free(diff);
-                    } else {
-                        fprintf(stderr, "acpi-test: Warning. not showing "
-                            "difference since no diff utility is specified. "
-                            "Set 'DIFF' environment variable to a preferred "
-                            "diff utility and run 'make V=1 check' again to "
-                            "see ASL difference.");
-                    }
+                    dup2(STDERR_FILENO, STDOUT_FILENO);
+                    ret = system(diff) ;
+                    dup2(out, STDOUT_FILENO);
+                    g_free(diff);
                 }
             }
         }
Signature · 1 line
MST
#8 lore raw

PATCH 4/5 bios-tables-test: fix path to allowed diff

In reply to Michael S. Tsirkin
Fixes 1e8a1fae7464 ("test: Move qtests to a separate directory")
---
 tests/qtest/bios-tables-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/bios-tables-test.c +1 -1
index 6ec1c5be64..6535ab7f04 100644
@@ -21,7 +21,7 @@
  * in binary commit created in step 6):
  *
  * After 1-3 above tests will pass but ignore differences with the expected files.
- * You will also notice that tests/bios-tables-test-allowed-diff.h lists
+ * You will also notice that tests/qtest/bios-tables-test-allowed-diff.h lists
  * a bunch of files. This is your hint that you need to do the below:
  * 4. Run
  *      make check V=1
Signature · 1 line
MST
Reviewed-by on v1 4/5
#9 lore raw

Re: [PATCH 4/5] bios-tables-test: fix path to allowed diff

Quoted 12 lines · Michael S. Tsirkin
Fixes 1e8a1fae7464 ("test: Move qtests to a separate directory")
---
 tests/qtest/bios-tables-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/bios-tables-test.c +0 -0
index 6ec1c5be64..6535ab7f04 100644

tests/qtest/bios-tables-test.c line 27

Quoted 8 lines
tests/qtest/bios-tables-test.c +1 -1
@@ -21,7 +21,7 @@
  * in binary commit created in step 6):
  *
  * After 1-3 above tests will pass but ignore differences with the expected files.
- * You will also notice that tests/bios-tables-test-allowed-diff.h lists
+ * You will also notice that tests/qtest/bios-tables-test-allowed-diff.h lists
  * a bunch of files. This is your hint that you need to do the below:
  * 4. Run
  *      make check V=1
Reviewed-by on v1 4/5
#10 lore raw

Re: [PATCH 4/5] bios-tables-test: fix path to allowed diff

In reply to Michael S. Tsirkin
Quoted 12 lines · Michael S. Tsirkin
Fixes 1e8a1fae7464 ("test: Move qtests to a separate directory")
---
 tests/qtest/bios-tables-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/bios-tables-test.c +0 -0
index 6ec1c5be64..6535ab7f04 100644

tests/qtest/bios-tables-test.c line 27

Quoted 8 lines
tests/qtest/bios-tables-test.c +1 -1
@@ -21,7 +21,7 @@
  * in binary commit created in step 6):
  *
  * After 1-3 above tests will pass but ignore differences with the expected files.
- * You will also notice that tests/bios-tables-test-allowed-diff.h lists
+ * You will also notice that tests/qtest/bios-tables-test-allowed-diff.h lists
  * a bunch of files. This is your hint that you need to do the below:
  * 4. Run
  *      make check V=1
#11 lore raw

PATCH 5/5 rebuild-expected-aml.sh: remind about the process

In reply to Michael S. Tsirkin

Remind users of rebuild-expected-aml.sh about the process to follow. Suppress the warning if allowed file list exists - that's a big hint user is already aware of the process.

---
 tests/data/acpi/rebuild-expected-aml.sh | 7 +++++++
 1 file changed, 7 insertions(+)
tests/data/acpi/rebuild-expected-aml.sh +7 -0
index d44e511533..9cbaab1a4d 100755
@@ -31,6 +31,13 @@ done
 
 eval `grep SRC_PATH= config-host.mak`
 
+old_allowed_dif=`grep -v -e 'List of comma-separated changed AML files to ignore' ${SRC_PATH}/tests/qtest/bios-tables-test-allowed-diff.h`
+
 echo '/* List of comma-separated changed AML files to ignore */' > ${SRC_PATH}/tests/qtest/bios-tables-test-allowed-diff.h
 
 echo "The files were rebuilt and can be added to git."
+
+if [ -z "$old_allowed_dif" ]; then
+    echo "Note! Please do not commit expected files with source changes"
+    echo "Note! Please follow the process documented in ${SRC_PATH}/tests/qtest/bios-tables-test.c"
+fi
Signature · 1 line
MST