Message ID | 20200122080538.591734-3-mst@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | bios-tables-test: more documentation | expand |
On 22/01/2020 09:05, Michael S. Tsirkin wrote: > Turns out it goes to stdout which is suppressed even with V=1. > Force DIFF output to stderr to make it visible. > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > --- > tests/qtest/bios-tables-test.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c > index 6b5f24bf62..c8db2839b2 100644 > --- a/tests/qtest/bios-tables-test.c > +++ b/tests/qtest/bios-tables-test.c > @@ -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); I think you need a "close(out)" here. Thanks, Laurent
On Wed, Jan 22, 2020 at 10:00:01AM +0100, Laurent Vivier wrote: > On 22/01/2020 09:05, Michael S. Tsirkin wrote: > > Turns out it goes to stdout which is suppressed even with V=1. > > Force DIFF output to stderr to make it visible. > > > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > > --- > > tests/qtest/bios-tables-test.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c > > index 6b5f24bf62..c8db2839b2 100644 > > --- a/tests/qtest/bios-tables-test.c > > +++ b/tests/qtest/bios-tables-test.c > > @@ -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); > > I think you need a "close(out)" here. > > Thanks, > Laurent Can't hurt, thanks!
diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index 6b5f24bf62..c8db2839b2 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -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 "
Turns out it goes to stdout which is suppressed even with V=1. Force DIFF output to stderr to make it visible. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> --- tests/qtest/bios-tables-test.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)