Skip to contentSkip to conversation

test: replace gtester with a TAP driver

PATCH Superseded Paolo Bonzini 5 participants 17 messages Nov 29, 2018 – Nov 30, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover test: replace gtester with a TAP driver

gtester is deprecated by upstream glib and it does not support tests that call g_test_skip in some glib stable releases.

glib suggests instead using Automake's TAP support. We do not support Automake, but we can copy the code that beautifies the TAP output and use it. I chose to use the Perl copy rather than the shell/awk one, in order to reuse Perl's TAP parsing package, but I'm open to suggestions about which language to use.

Thanks,

Paolo

Paolo Bonzini (2):
test: execute g_test_run when tests are skipped
test: replace gtester with a TAP driver

 scripts/gtester-cat                          |  26 --
 scripts/tap-driver.pl                        | 386 +++++++++++++++++++++++++++
 scripts/tap-merge.pl                         | 108 ++++++++
 tests/Makefile.include                       |  54 ++--
 tests/cdrom-test.c                           |   2 +-
 tests/docker/dockerfiles/centos7.docker      |   1 +
 tests/docker/dockerfiles/debian-amd64.docker |   1 +
 tests/docker/dockerfiles/debian-ports.docker |   1 +
 tests/docker/dockerfiles/debian-sid.docker   |   1 +
 tests/docker/dockerfiles/debian8.docker      |   1 +
 tests/docker/dockerfiles/debian9.docker      |   1 +
 tests/docker/dockerfiles/fedora.docker       |   1 +
 tests/docker/dockerfiles/ubuntu.docker       |   1 +
 tests/migration-test.c                       |   8 +-
 14 files changed, 540 insertions(+), 52 deletions(-)
 delete mode 100755 scripts/gtester-cat
 create mode 100755 scripts/tap-driver.pl
 create mode 100755 scripts/tap-merge.pl
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/2 test: execute g_test_run when tests are skipped

Sometimes a test's main() function recognizes that the environment does not support the test, and therefore exits. In this case, we still should run g_test_run() so that a TAP harness will print the test plan ("1..0") and the test will be marked as skipped.

---
 tests/cdrom-test.c     | 2 +-
 tests/migration-test.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
tests/cdrom-test.c +1 -1
index 9b43dc9..14bd981 100644
@@ -169,7 +169,7 @@ int main(int argc, char **argv)
 
     if (exec_genisoimg(genisocheck)) {
         /* genisoimage not available - so can't run tests */
-        return 0;
+        return g_test_run();
     }
 
     ret = prepare_image(arch, isoimage);
tests/migration-test.c +4 -4
index 06ca506..8352612 100644
@@ -789,7 +789,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
 
     if (!ufd_version_check()) {
-        return 0;
+        return g_test_run();
     }
 
     /*
@@ -800,7 +800,7 @@ int main(int argc, char **argv)
     if (g_str_equal(qtest_get_arch(), "ppc64") &&
         access("/sys/module/kvm_hv", F_OK)) {
         g_test_message("Skipping test: kvm_hv not available");
-        return 0;
+        return g_test_run();
     }
 
     /*
@@ -811,11 +811,11 @@ int main(int argc, char **argv)
 #if defined(HOST_S390X)
         if (access("/dev/kvm", R_OK | W_OK)) {
             g_test_message("Skipping test: kvm not available");
-            return 0;
+            return g_test_run();
         }
 #else
         g_test_message("Skipping test: Need s390x host to work properly");
-        return 0;
+        return g_test_run();
 #endif
     }
 
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] test: execute g_test_run when tests are skipped

Quoted 10 lines · Paolo Bonzini

Sometimes a test's main() function recognizes that the environment does not support the test, and therefore exits. In this case, we still should run g_test_run() so that a TAP harness will print the test plan ("1..0") and the test will be marked as skipped.

---
  tests/cdrom-test.c     | 2 +-
  tests/migration-test.c | 8 ++++----
  2 files changed, 5 insertions(+), 5 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
Reviewed-by on v1 1/2
#3 lore raw

Re: [Qemu-devel] [PATCH 1/2] test: execute g_test_run when tests are skipped

In reply to Paolo Bonzini
Quoted 49 lines · Paolo Bonzini

Sometimes a test's main() function recognizes that the environment does not support the test, and therefore exits. In this case, we still should run g_test_run() so that a TAP harness will print the test plan ("1..0") and the test will be marked as skipped.

---
 tests/cdrom-test.c     | 2 +-
 tests/migration-test.c | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
tests/cdrom-test.c +1 -1
index 9b43dc9..14bd981 100644
@@ -169,7 +169,7 @@ int main(int argc, char **argv)
 
     if (exec_genisoimg(genisocheck)) {
         /* genisoimage not available - so can't run tests */
-        return 0;
+        return g_test_run();
     }
 
     ret = prepare_image(arch, isoimage);
tests/migration-test.c +2 -2
index 06ca506..8352612 100644
@@ -789,7 +789,7 @@ int main(int argc, char **argv)
     g_test_init(&argc, &argv, NULL);
 
     if (!ufd_version_check()) {
-        return 0;
+        return g_test_run();
     }
 
     /*
@@ -800,7 +800,7 @@ int main(int argc, char **argv)
     if (g_str_equal(qtest_get_arch(), "ppc64") &&
         access("/sys/module/kvm_hv", F_OK)) {
         g_test_message("Skipping test: kvm_hv not available");
-        return 0;
+        return g_test_run();
     }
 
     /*
@@ -811,11 +811,11 @@ int main(int argc, char **argv)
 #if defined(HOST_S390X)
         if (access("/dev/kvm", R_OK | W_OK)) {

tests/migration-test.c int main(int argc, char **argv) · line 820

Quoted 10 lines
tests/migration-test.c +2 -2
             g_test_message("Skipping test: kvm not available");
-            return 0;
+            return g_test_run();
         }
 #else
         g_test_message("Skipping test: Need s390x host to work properly");
-        return 0;
+        return g_test_run();
 #endif
     }
#4 lore raw

PATCH 2/2 test: replace gtester with a TAP driver

In reply to Paolo Bonzini

gtester is deprecated by upstream glib and it does not support tests that call g_test_skip in some glib stable releases.

glib suggests instead using Automake's TAP support. We do not support Automake, but we can copy the code that beautifies the TAP output and use it. I chose to use the Perl copy rather than the shell/awk one, in order to reuse Perl's TAP parsing package, but I'm open to suggestions about which language to use.

---
 scripts/gtester-cat                          |  26 --
 scripts/tap-driver.pl                        | 386 +++++++++++++++++++++++++++
 scripts/tap-merge.pl                         | 108 ++++++++
 tests/Makefile.include                       |  54 ++--
 tests/docker/dockerfiles/centos7.docker      |   1 +
 tests/docker/dockerfiles/debian-amd64.docker |   1 +
 tests/docker/dockerfiles/debian-ports.docker |   1 +
 tests/docker/dockerfiles/debian-sid.docker   |   1 +
 tests/docker/dockerfiles/debian8.docker      |   1 +
 tests/docker/dockerfiles/debian9.docker      |   1 +
 tests/docker/dockerfiles/fedora.docker       |   1 +
 tests/docker/dockerfiles/ubuntu.docker       |   1 +
 12 files changed, 535 insertions(+), 47 deletions(-)
 delete mode 100755 scripts/gtester-cat
 create mode 100755 scripts/tap-driver.pl
 create mode 100755 scripts/tap-merge.pl
scripts/gtester-cat deleted +0 -26
deleted file mode 100755
index 061a952..0000000
@@ -1,26 +0,0 @@
-#!/bin/sh
-#
-# Copyright IBM, Corp. 2012
-#
-# Authors:
-#  Anthony Liguori <[email protected]>
-#
-# This work is licensed under the terms of the GNU GPLv2 or later.
-# See the COPYING file in the top-level directory.
-
-cat <<EOF
-<?xml version="1.0"?>
-<gtester>
- <info>
-  <package>qemu</package>
-  <version>0.0</version>
-  <revision>rev</revision>
- </info>
-EOF
-
-sed \
-  -e '/<?xml/d' \
-  -e '/^<gtester>$/d' \
-  -e '/<info>/,/<\/info>/d' \
-  -e '$b' \
-  -e '/^<\/gtester>$/d' "$@"
scripts/tap-driver.pl new file +386 -0

386 lines not on this page · raw message

scripts/tap-merge.pl new file +108 -0

108 lines not on this page · raw message

tests/Makefile.include +33 -21

74 lines not on this page · raw message

tests/docker/dockerfiles/centos7.docker +1 -0
index 0a04bfb..e0f18f5 100644
@@ -22,6 +22,7 @@ ENV PACKAGES \
     mesa-libEGL-devel \
     mesa-libgbm-devel \
     nettle-devel \
+    perl-Test-Harness \
     pixman-devel \
     SDL-devel \
     spice-glib-devel \
tests/docker/dockerfiles/debian-amd64.docker +1 -0
index 24b113b..c66e341 100644
@@ -16,6 +16,7 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \
         liblzo2-dev \
         librdmacm-dev \
         libsnappy-dev \
+        libtest-harness-perl \
         libvte-dev
 
 # virgl
tests/docker/dockerfiles/debian-ports.docker +1 -0
index e05a9a9..514ab53 100644
@@ -29,6 +29,7 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \
         flex \
         gettext \
         git \
+        libtest-harness-perl \
         pkg-config \
         psmisc \
         python \
tests/docker/dockerfiles/debian-sid.docker +1 -0
index 9a3d168..b30cbe7 100644
@@ -26,6 +26,7 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \
         ca-certificates \
         flex \
         git \
+        libtest-harness-perl \
         pkg-config \
         psmisc \
         python \
tests/docker/dockerfiles/debian8.docker +1 -0
index 5294563..cdc3f11 100644
@@ -29,6 +29,7 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \
         gettext \
         git \
         gnupg \
+        libtest-harness-perl \
         pkg-config \
         python-minimal
 
tests/docker/dockerfiles/debian9.docker +1 -0
index 154ae2a..9561d4f 100644
@@ -24,6 +24,7 @@ RUN DEBIAN_FRONTEND=noninteractive eatmydata \
         flex \
         gettext \
         git \
+        libtest-harness-perl \
         pkg-config \
         psmisc \
         python \
tests/docker/dockerfiles/fedora.docker +1 -0
index 0c4eb9e..1d0e3dc 100644
@@ -70,6 +70,7 @@ ENV PACKAGES \
     nss-devel \
     numactl-devel \
     perl \
+    perl-Test-Harness \
     pixman-devel \
     python3 \
     PyYAML \
tests/docker/dockerfiles/ubuntu.docker +1 -0
index 36e2b17..229add5 100644
@@ -45,6 +45,7 @@ ENV PACKAGES flex bison \
     libspice-protocol-dev \
     libspice-server-dev \
     libssh2-1-dev \
+    libtest-harness-perl \
     libusb-1.0-0-dev \
     libusbredirhost-dev \
     libvdeplug-dev \
Signature · 1 line
1.8.3.1
Reviewed-by on v1 2/2
#5 lore raw
Quoted 8 lines · Paolo Bonzini

gtester is deprecated by upstream glib and it does not support tests that call g_test_skip in some glib stable releases.

glib suggests instead using Automake's TAP support. We do not support Automake, but we can copy the code that beautifies the TAP output and use it. I chose to use the Perl copy rather than the shell/awk one, in order to reuse Perl's TAP parsing package, but I'm open to suggestions about which language to use.

Maybe a reference to a URL documenting the glib deprecation would be in order? I found https://blog.gtk.org/2018/07/11/news-from-glib-2-58/

scripts/tap-driver.pl line 2

Quoted 8 lines

---

+++ b/scripts/tap-driver.pl

scripts/tap-driver.pl new file +2 -0
@@ -0,0 +1,386 @@
+#! /usr/bin/env perl
+# Copyright (C) 2011-2013 Free Software Foundation, Inc.

This is not the latest version of automake.git/contrib/tap-driver.pl - which Automake version is it from? Automake moved its perl driver out to pasture in 2013, stating that the awk+shell version is preferred in new automake projects. I don't have a strong preference for which one you pick, but do worry that if automake adds future enhancements to the awk+shell, then the perl version won't keep up and we'll be stuck redoing things again in a few years. On the other hand, TAP doesn't seem to be gaining new features at a very fast rate.

Review line 4

Quoted 2 lines
(quoted diff) +2 -0
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.

Among other things, the most recent version of tap-driver.pl switched all references to https://.

scripts/tap-driver.pl line 20

Quoted 5 lines
scripts/tap-driver.pl new file +5 -0
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.

We do not use Autoconf, so this exception does not apply to our use of this file. But since our project is GPL, I don't see including this file as a problem, nor do I find any problem with leaving the exception in place.

Review line 11

Quoted 2 lines
(quoted diff) +2 -0
+
+my $VERSION = '2012-02-01.19'; # UTC

Okay, so this matches the version in automake.git commit 6b819187, which was shipped in automake 1.11b. Six years old, but still does what we need, at least for today.

Otherwise, looks good to me, although I'm weak enough with TAP in general that this is a fairly weak:

(The real test is if all the CI systems are happy with it...)

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#6 lore raw
Quoted 4 lines · Eric Blake
Quoted 3 lines · Paolo Bonzini

gtester is deprecated by upstream glib and it does not support tests that call g_test_skip in some glib stable releases.

Quoted 8 lines
Quoted 5 lines

glib suggests instead using Automake's TAP support.  We do not support Automake, but we can copy the code that beautifies the TAP output and use it.  I chose to use the Perl copy rather than the shell/awk one, in order to reuse Perl's TAP parsing package, but I'm open to suggestions about which language to use.

Maybe a reference to a URL documenting the glib deprecation would be in order? I found https://blog.gtk.org/2018/07/11/news-from-glib-2-58/

Good idea.

Quoted 16 lines

scripts/tap-driver.pl line 2

Quoted 7 lines

---

+++ b/scripts/tap-driver.pl

scripts/tap-driver.pl new file +2 -0
@@ -0,0 +1,386 @@
+#! /usr/bin/env perl
+# Copyright (C) 2011-2013 Free Software Foundation, Inc.

This is not the latest version of automake.git/contrib/tap-driver.pl - which Automake version is it from?  Automake moved its perl driver out to pasture in 2013, stating that the awk+shell version is preferred in new automake projects.  I don't have a strong preference for which one you pick, but do worry that if automake adds future enhancements to the awk+shell, then the perl version won't keep up and we'll be stuck redoing things again in a few years.  On the other hand, TAP doesn't seem to be gaining new features at a very fast rate.

It does get some new features from time to time, and that's why I preferred an external parser to a home-grown one---especially if we would need to duplicate the awk parser in tap-merge.pl.

The version I used is just the one in the machine where I developed it (RHEL 7), but there have been no relevant changes after that commit, so it's not important.

Quoted 5 lines

Review line 4

Quoted 2 lines
(quoted diff) +2 -0
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.

Among other things, the most recent version of tap-driver.pl switched all references to https://.

I can change this too.

Quoted 9 lines

scripts/tap-driver.pl line 20

Quoted 4 lines
scripts/tap-driver.pl new file +4 -0
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.

We do not use Autoconf, so this exception does not apply to our use of this file.  But since our project is GPL, I don't see including this file as a problem, nor do I find any problem with leaving the exception in place.

Yes, I find removing exceptions to be a bit unkind.

Paolo

#7 lore raw
In reply to Paolo Bonzini
Quoted 8 lines · Paolo Bonzini

gtester is deprecated by upstream glib and it does not support tests that call g_test_skip in some glib stable releases.

glib suggests instead using Automake's TAP support. We do not support Automake, but we can copy the code that beautifies the TAP output and use it. I chose to use the Perl copy rather than the shell/awk one, in order to reuse Perl's TAP parsing package, but I'm open to suggestions about which language to use.

Do we even need the beutifier ?

IIUC, this output is only seen when you with 'make check' passing V=1, so most people won't see it.

When V=1 is set, it just changes:

$ ./tests/test-io-channel-socket -k --tap
# random seed: R02Sb9d02d2a9658ae1be211540f5ceebc01
1..9
# Start of io tests
# Start of channel tests
# Start of socket tests
ok 1 /io/channel/socket/ipv4-sync
ok 2 /io/channel/socket/ipv4-async
ok 3 /io/channel/socket/ipv4-fd
ok 4 /io/channel/socket/ipv6-sync
ok 5 /io/channel/socket/ipv6-async
ok 6 /io/channel/socket/unix-sync
ok 7 /io/channel/socket/unix-async
**
ERROR:tests/test-io-channel-socket.c:424:test_io_channel_unix_fd_pass: assertion failed: (0)
Bail out! ERROR:tests/test-io-channel-socket.c:424:test_io_channel_unix_fd_pass: assertion failed: (0)
Aborted (core dumped)

To look like:

$ ./tests/test-io-channel-socket -k --tap | ./scripts/tap-driver.pl 
PASS 1 /io/channel/socket/ipv4-sync
PASS 2 /io/channel/socket/ipv4-async
PASS 3 /io/channel/socket/ipv4-fd
PASS 4 /io/channel/socket/ipv6-sync
PASS 5 /io/channel/socket/ipv6-async
PASS 6 /io/channel/socket/unix-sync
PASS 7 /io/channel/socket/unix-async
ERROR - Bail out! ERROR:tests/test-io-channel-socket.c:424:test_io_channel_unix_fd_pass: assertion failed: (0)

where 'PASS' is coloured in green and 'ERROR' is red. I'm not convinced this change justifies having the tap-driver.pl script

Since this commit already proposes a dep on the perl-Test-Harness package, the host will have the 'prove' command, which can be used for invoking tests.

Prove just needs a wrapper to know how to invoke glib tests:

  $ cat glibharness.sh 
  #!/bin/sh
  exec "$@" -k --tap

Now you can run :

$ prove -v -e ./glibharness.sh  tests/test-io-channel-socket
tests/test-io-channel-socket .. 
# random seed: R02S7b47ca0de1bc27cbbcf22dcc130c2b7f
1..9
# Start of io tests
# Start of channel tests
# Start of socket tests
ok 1 /io/channel/socket/ipv4-sync
ok 2 /io/channel/socket/ipv4-async
ok 3 /io/channel/socket/ipv4-fd
ok 4 /io/channel/socket/ipv6-sync
ok 5 /io/channel/socket/ipv6-async
ok 6 /io/channel/socket/unix-sync
ok 7 /io/channel/socket/unix-async
**
ERROR:tests/test-io-channel-socket.c:424:test_io_channel_unix_fd_pass: assertion failed: (0)
Bailout called.  Further testing stopped:  ERROR:tests/test-io-channel-socket.c:424:test_io_channel_unix_fd_pass: assertion failed: (0)
Bail out! ERROR:tests/test-io-channel-socket.c:424:test_io_channel_unix_fd_pass: assertion failed: (0)
FAILED--Further testing stopped: ERROR:tests/test-io-channel-socket.c:424:test_io_channel_unix_fd_pass: assertion failed: (0)

Where the failure line is now coloured in Red (or sucess is coloured in green)

prove can also run tests in batches, giving progress of execution of each test as it runs

$ prove  -e ./glibharness.sh  tests/test-io-channel-{buffer,command,file,socket,tls} 
tests/test-io-channel-buffer ... ok   
tests/test-io-channel-command .. ok   
tests/test-io-channel-file ..... ok   
tests/test-io-channel-socket ... 1/? **
ERROR:tests/test-io-channel-socket.c:424:test_io_channel_unix_fd_pass: assertion failed: (0)
Bailout called.  Further testing stopped:  ERROR:tests/test-io-channel-socket.c:424:test_io_channel_unix_fd_pass: assertion failed: (0)
FAILED--Further testing stopped: ERROR:tests/test-io-channel-socket.c:424:test_io_channel_unix_fd_pass: assertion failed: (0)

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#8 lore raw
Quoted 2 lines · Daniel P. Berrangé

IIUC, this output is only seen when you with 'make check' passing V=1, so most people won't see it.

V=1 should be enabled by default on Patchew, so it will be visible in the CI logs. But anyway that's minor, there are more reasons why a custom beautifier is better than prove.

First, at the very least, failures should be included in the output even if V=1 is not provided. Therefore, for failing tests we'd have:

  $ scripts/tap-driver.pl < f.tap
  FAIL 2 bbb
  XPASS 3 ccc # TODO
  FAIL 6 fff # SKIP cannot find frobnicator

And the output of prove in that case would be inferior for developers, unless you use "V=1":

  $ prove -e cat f.tap
  f.tap .. Failed 2/6 subtests
	(less 2 skipped subtests: 2 okay)
	(1 TODO test unexpectedly succeeded)

Test Summary Report
-------------------
f.tap (Wstat: 0 Tests: 6 Failed: 2)
Failed tests: 2, 6
TODO passed: 3
Files=1, Tests=6, 0 wallclock secs ( 0.02 usr + 0.00 sys = 0.02 CPU)
Result: FAIL

where you don't really know what tests 2 and 6 are without looking at the TAP output. The part before the summary provides a nice progress report, as you point out, but it adds a bunch of noise with respect to skipped subtests (skipped tests will be more common once patch 1 is merged; qgraph also adds some) that I personally dislike.

You can hide it with -Q, but then you cannot invoke anymore more than one test with a single invocation of prove, and the Makefile output becomes much bigger:

TEST check-foo

vs.

TEST check-foo
All tests successful.
Files=1, Tests=3, 0 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)
Result: PASS

There are two other smaller "philosophical" differences. First, prove treats XPASS as passes, while tap-driver.pl treats them as failures. Second, skipped tests really stand out in the "prove -v" output, with white-on-blue text.

I'd rather avoid getting into the business of beautifying the output of prove.

Paolo

#9 lore raw
In reply to Paolo Bonzini
Quoted 8 lines · Paolo Bonzini

gtester is deprecated by upstream glib and it does not support tests that call g_test_skip in some glib stable releases.

glib suggests instead using Automake's TAP support. We do not support Automake, but we can copy the code that beautifies the TAP output and use it. I chose to use the Perl copy rather than the shell/awk one, in order to reuse Perl's TAP parsing package, but I'm open to suggestions about which language to use.

I'm less familiar with the TAP protocol than I'd like to admit, but I did find:

https://blog.gtk.org/2018/07/11/news-from-glib-2-58/

which corroborates your claim that switching to Automake's TAP parser is indeed a recommended approach to avoid the now-deprecated gtester.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#10 lore raw
Quoted 10 lines · Eric Blake
Quoted 8 lines · Paolo Bonzini

gtester is deprecated by upstream glib and it does not support tests that call g_test_skip in some glib stable releases.

glib suggests instead using Automake's TAP support.  We do not support Automake, but we can copy the code that beautifies the TAP output and use it.  I chose to use the Perl copy rather than the shell/awk one, in order to reuse Perl's TAP parsing package, but I'm open to suggestions about which language to use.

Quoted 7 lines

I'm less familiar with the TAP protocol than I'd like to admit, but I did find:

https://blog.gtk.org/2018/07/11/news-from-glib-2-58/

which corroborates your claim that switching to Automake's TAP parser is indeed a recommended approach to avoid the now-deprecated gtester.

Hmm, do we really have to maintain our own version of a test runner now? There's already some effort going on to use avocado in "make check-acceptance" ... maybe we could use avocado as replacement for gtester, too?

Thomas

#11 lore raw
Quoted 14 lines · Thomas Huth
Quoted 13 lines · Eric Blake
Quoted 8 lines · Paolo Bonzini

gtester is deprecated by upstream glib and it does not support tests that call g_test_skip in some glib stable releases.

glib suggests instead using Automake's TAP support.  We do not support Automake, but we can copy the code that beautifies the TAP output and use it.  I chose to use the Perl copy rather than the shell/awk one, in order to reuse Perl's TAP parsing package, but I'm open to suggestions about which language to use.

I'm less familiar with the TAP protocol than I'd like to admit, but I did find:

Quoted 6 lines
Quoted 4 lines

https://blog.gtk.org/2018/07/11/news-from-glib-2-58/

which corroborates your claim that switching to Automake's TAP parser is indeed a recommended approach to avoid the now-deprecated gtester.

Hmm, do we really have to maintain our own version of a test runner now?

Well, that's what you get for using a custom build system but it's "just" an output beautifier really. I could just "grep -ve ^# -e ^ok" but it wouldn't look very nice (plus things that start as 1-line shell scripts end up being the same as the thing you're trying to replace).

I don't think it will be a big maintenance headache---just like most other files in scripts/, some of which have had exactly zero commits since they were added. In fact, Automake has hardly changed its driver since the first commit.

Quoted 3 lines

There's already some effort going on to use avocado in "make check-acceptance" ... maybe we could use avocado as replacement for gtester, too?

Avocado does not have the required functionality, unfortunately. It can produce TAP, but not consume it. Also, Python libraries for TAP do not abound and are generally not shipped with the OS (apart from Perl, which basically invented TAP, the language with the most TAP libraries seem to be JavaScript!).

Paolo

#12 lore raw
Quoted 36 lines · Paolo Bonzini
Quoted 14 lines · Thomas Huth
Quoted 13 lines · Eric Blake
Quoted 8 lines · Paolo Bonzini

gtester is deprecated by upstream glib and it does not support tests that call g_test_skip in some glib stable releases.

glib suggests instead using Automake's TAP support.  We do not support Automake, but we can copy the code that beautifies the TAP output and use it.  I chose to use the Perl copy rather than the shell/awk one, in order to reuse Perl's TAP parsing package, but I'm open to suggestions about which language to use.

I'm less familiar with the TAP protocol than I'd like to admit, but I did find:

Quoted 6 lines
Quoted 4 lines

https://blog.gtk.org/2018/07/11/news-from-glib-2-58/

which corroborates your claim that switching to Automake's TAP parser is indeed a recommended approach to avoid the now-deprecated gtester.

Hmm, do we really have to maintain our own version of a test runner now?

Well, that's what you get for using a custom build system but it's "just" an output beautifier really. I could just "grep -ve ^# -e ^ok" but it wouldn't look very nice (plus things that start as 1-line shell scripts end up being the same as the thing you're trying to replace).

I don't think it will be a big maintenance headache---just like most other files in scripts/, some of which have had exactly zero commits since they were added. In fact, Automake has hardly changed its driver since the first commit.

Quoted 3 lines

There's already some effort going on to use avocado in "make check-acceptance" ... maybe we could use avocado as replacement for gtester, too?

Quoted 6 lines

Avocado does not have the required functionality, unfortunately. It can produce TAP, but not consume it. Also, Python libraries for TAP do not abound and are generally not shipped with the OS (apart from Perl, which basically invented TAP, the language with the most TAP libraries seem to be JavaScript!).

Avocado can't currently consume TAP (it produces it, though), but it has some integration with glib based tests:

https://avocado-framework.readthedocs.io/en/66.0/optional_plugins/glib.html

But, there may be bits missing to fully replae gtests. Given that we have been adding features to Avocado based on QEMU requirements, we can certainly look at adding missing pieces there. If this sounds like something you'd be interested in, I can come up with an integration proposal.

Quoted 2 lines

Paolo

Cheers,
- Cleber.

#13 lore raw
Quoted 30 lines · Cleber Rosa
Quoted 27 lines · Paolo Bonzini
Quoted 14 lines · Thomas Huth
Quoted 13 lines · Eric Blake
Quoted 8 lines · Paolo Bonzini

gtester is deprecated by upstream glib and it does not support tests that call g_test_skip in some glib stable releases.

glib suggests instead using Automake's TAP support.  We do not support Automake, but we can copy the code that beautifies the TAP output and use it.  I chose to use the Perl copy rather than the shell/awk one, in order to reuse Perl's TAP parsing package, but I'm open to suggestions about which language to use.

I'm less familiar with the TAP protocol than I'd like to admit, but I did find:

Quoted 6 lines
Quoted 4 lines

https://blog.gtk.org/2018/07/11/news-from-glib-2-58/

which corroborates your claim that switching to Automake's TAP parser is indeed a recommended approach to avoid the now-deprecated gtester.

Hmm, do we really have to maintain our own version of a test runner now?

Well, that's what you get for using a custom build system but it's "just" an output beautifier really. I could just "grep -ve ^# -e ^ok" but it wouldn't look very nice (plus things that start as 1-line shell scripts end up being the same as the thing you're trying to replace).

Quoted 4 lines
Quoted 4 lines

I don't think it will be a big maintenance headache---just like most other files in scripts/, some of which have had exactly zero commits since they were added. In fact, Automake has hardly changed its driver since the first commit.

OK, fair.

Quoted 13 lines
Quoted 9 lines
Quoted 3 lines

There's already some effort going on to use avocado in "make check-acceptance" ... maybe we could use avocado as replacement for gtester, too?

Avocado does not have the required functionality, unfortunately. It can produce TAP, but not consume it. Also, Python libraries for TAP do not abound and are generally not shipped with the OS (apart from Perl, which basically invented TAP, the language with the most TAP libraries seem to be JavaScript!).

Avocado can't currently consume TAP (it produces it, though), but it has some integration with glib based tests:

Quoted 7 lines

https://avocado-framework.readthedocs.io/en/66.0/optional_plugins/glib.html

But, there may be bits missing to fully replae gtests. Given that we have been adding features to Avocado based on QEMU requirements, we can certainly look at adding missing pieces there. If this sounds like something you'd be interested in, I can come up with an integration proposal.

FWIW, it seems basically to work, indeed:

$ export QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64
$ avocado run --loaders glib -- tests/pxe-test tests/cdrom-test
JOB ID     : 67657631c2f1f80e34d90fe0c2c05e05aab6f1ba
JOB LOG    : /home/thuth/avocado/job-results/job-2018-11-30T10.02-6765763/job.log
 (01/12) tests/pxe-test:/x86_64/pxe/ipv4/pc/e1000: PASS (6.46 s)
 (02/12) tests/pxe-test:/x86_64/pxe/ipv4/pc/virtio-net-pci: PASS (6.47 s)
 (03/12) tests/pxe-test:/x86_64/pxe/ipv4/q35/e1000e: PASS (6.46 s)
 (04/12) tests/pxe-test:/x86_64/pxe/ipv4/q35/virtio-net-pci: PASS (6.46 s)
 (05/12) tests/cdrom-test:/x86_64/cdrom/boot/default: PASS (0.25 s)
 (06/12) tests/cdrom-test:/x86_64/cdrom/boot/virtio-scsi: PASS (0.25 s)
 (07/12) tests/cdrom-test:/x86_64/cdrom/boot/isapc: PASS (0.24 s)
 (08/12) tests/cdrom-test:/x86_64/cdrom/boot/am53c974: PASS (0.25 s)
 (09/12) tests/cdrom-test:/x86_64/cdrom/boot/dc390: PASS (0.25 s)
 (10/12) tests/cdrom-test:/x86_64/cdrom/boot/lsi53c895a: PASS (0.26 s)
 (11/12) tests/cdrom-test:/x86_64/cdrom/boot/megasas: PASS (0.15 s)
 (12/12) tests/cdrom-test:/x86_64/cdrom/boot/megasas-gen2: PASS (0.15 s)
RESULTS    : PASS 12 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME   : 28.31 s
JOB HTML   : /home/thuth/avocado/job-results/job-2018-11-30T10.02-6765763/results.html

Thomas

#14 lore raw
In reply to Eric Blake
Quoted 10 lines · Eric Blake
Quoted 8 lines · Paolo Bonzini

gtester is deprecated by upstream glib and it does not support tests that call g_test_skip in some glib stable releases.

glib suggests instead using Automake's TAP support. We do not support Automake, but we can copy the code that beautifies the TAP output and use it. I chose to use the Perl copy rather than the shell/awk one, in order to reuse Perl's TAP parsing package, but I'm open to suggestions about which language to use.

Quoted 7 lines

I'm less familiar with the TAP protocol than I'd like to admit, but I did find:

https://blog.gtk.org/2018/07/11/news-from-glib-2-58/

which corroborates your claim that switching to Automake's TAP parser is indeed a recommended approach to avoid the now-deprecated gtester.

FYI, for docs about the TAP protocol see:

https://testanything.org/tap-specification.html

I've always liked the TAP protocol approach to test output where you print an ok/not ok status for each piece of the test, as opposed to assertion style tests where you just abort at the first piece that fails.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#15 lore raw
Quoted 7 lines · Daniel P. Berrangé

FYI, for docs about the TAP protocol see:

https://testanything.org/tap-specification.html

I've always liked the TAP protocol approach to test output where you print an ok/not ok status for each piece of the test, as opposed to assertion style tests where you just abort at the first piece that fails.

FWIW, this is not what this series does. Each ok/not ok line corresponds to one assertion-style test.

Paolo

#16 lore raw
Quoted 11 lines · Paolo Bonzini
Quoted 7 lines · Daniel P. Berrangé

FYI, for docs about the TAP protocol see:

https://testanything.org/tap-specification.html

I've always liked the TAP protocol approach to test output where you print an ok/not ok status for each piece of the test, as opposed to assertion style tests where you just abort at the first piece that fails.

FWIW, this is not what this series does. Each ok/not ok line corresponds to one assertion-style test.

Oh sure, that's the way they've integrated it into the glib test APIs. I just meant that in terms of the output format, I like its flexibility in this manner.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|