Skip to contentSkip to conversation

add "make check"

PATCH Applied Gerd Hoffmann 7 participants 24 messages Sep 1, 2011 – Nov 1, 2011 Kbuild

lore
Share & tools
lore
#0 lore raw

cover add "make check"

Hi,

This patch series intends to make unit testing easier. It adds a new "make check" target which can be used to run all unit tests which are currently in the tree. It also enables the unit tests by default, so you don't have to re-run configure with a special switch.

cheers,
Gerd

Gerd Hoffmann (4):
Probe for libcheck by default.
move checks to separate variable
add "make check" target
add test-coroutine to checks

 Makefile  |   10 ++++++++--
 configure |    7 ++++---
 2 files changed, 12 insertions(+), 5 deletions(-)
#1 lore raw

PATCH 1/4 Probe for libcheck by default.

Probe for libcheck and build checks (if found) by default. Can be explicitly disabled using --disable-check-utests.

---
 configure |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
configure +1 -1
index 1340c33..920de9e 100755
@@ -170,7 +170,7 @@ mixemu="no"
 aix="no"
 blobs="yes"
 pkgversion=""
-check_utests="no"
+check_utests=""
 user_pie="no"
 zero_malloc=""
 trace_backend="nop"
Signature · 1 line
1.7.1
#2 lore raw

Re: [Qemu-devel] [PATCH 1/4] Probe for libcheck by default.

Quoted 7 lines · Gerd Hoffmann

Probe for libcheck and build checks (if found) by default. Can be explicitly disabled using --disable-check-utests.

---
  configure |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

I think we should convert the check tests to gtest, and then have make check use gtester and gtester-report generate a single report of all of the test cases.

We could then have build bot run make check and post the output. I don't want to end up with a bunch of non gtest unit tests...

Regards,

Anthony Liguori

Quoted 14 lines
configure +1 -1
index 1340c33..920de9e 100755
@@ -170,7 +170,7 @@ mixemu="no"
  aix="no"
  blobs="yes"
  pkgversion=""
-check_utests="no"
+check_utests=""
  user_pie="no"
  zero_malloc=""
  trace_backend="nop"
#3 lore raw

Re: [Qemu-devel] [PATCH 1/4] Probe for libcheck by default.

Quoted 4 lines · Anthony Liguori
Quoted 3 lines · Gerd Hoffmann

Probe for libcheck and build checks (if found) by default. Can be explicitly disabled using --disable-check-utests.

Quoted 8 lines
Quoted 4 lines

---
configure | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)

I think we should convert the check tests to gtest, and then have make check use gtester and gtester-report generate a single report of all of the test cases.

I wouldn't object, that is *way* beyond the scope of this little patch series though.

Quoted 1 line

We could then have build bot run make check and post the output.

Running "make check" in buildbot is indeed the motivation to do this ;)

Quoted 2 lines

I don't
want to end up with a bunch of non gtest unit tests...

This patch series doesn't add any. It just adds some build system glue so "make check" runs the existing stuff.

cheers,
Gerd

#4 lore raw

Re: [Qemu-devel] [PATCH 1/4] Probe for libcheck by default.

Quoted 10 lines · Gerd Hoffmann
Quoted 9 lines · Anthony Liguori
Quoted 7 lines · Gerd Hoffmann

Probe for libcheck and build checks (if found) by default. Can be explicitly disabled using --disable-check-utests.

---
configure | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 6 lines
Quoted 3 lines

I think we should convert the check tests to gtest, and then have make check use gtester and gtester-report generate a single report of all of the test cases.

I wouldn't object, that is *way* beyond the scope of this little patch series though.

One step at a time.

Quoted 8 lines
Quoted 1 line

We could then have build bot run make check and post the output.

Running "make check" in buildbot is indeed the motivation to do this ;)

Quoted 2 lines

I don't
want to end up with a bunch of non gtest unit tests...

This patch series doesn't add any.

Yep. If you want to standardize on gtest, you get to convert or remove the existing tests. Until then, we use what we have.

Quoted 2 lines

It just adds some build system
glue so "make check" runs the existing stuff.

Running self-tests shouldn't be made any harder than that.

#5 lore raw

PATCH 2/4 move checks to separate variable

In reply to Gerd Hoffmann

Create a new CHECKS variable. Put the checks there instead of adding them to the TOOLS variable.

---
 Makefile  |    4 ++--
 configure |    5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)
Makefile +2 -2
index 8606849..2963c8b 100644
@@ -71,7 +71,7 @@ defconfig:
 
 -include config-all-devices.mak
 
-build-all: $(DOCS) $(TOOLS) recurse-all
+build-all: $(DOCS) $(TOOLS) $(CHECKS) recurse-all
 
 config-host.h: config-host.h-timestamp
 config-host.h-timestamp: config-host.mak
@@ -205,7 +205,7 @@ clean:
 # avoid old build problems by removing potentially incorrect old files
 	rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
 	rm -f qemu-options.def
-	rm -f *.o *.d *.a *.lo $(TOOLS) qemu-ga TAGS cscope.* *.pod *~ */*~
+	rm -f *.o *.d *.a *.lo $(TOOLS) $(CHECKS) qemu-ga TAGS cscope.* *.pod *~ */*~
 	rm -Rf .libs
 	rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d net/*.o net/*.d fsdev/*.o fsdev/*.d ui/*.o ui/*.d qapi/*.o qapi/*.d qga/*.o qga/*.d
 	rm -f qemu-img-cmds.h
configure +3 -2
index 920de9e..44b3295 100755
@@ -2630,8 +2630,8 @@ if test "$softmmu" = yes ; then
       tools="qemu-ga\$(EXESUF) $tools"
     fi
     if [ "$check_utests" = "yes" ]; then
-      tools="check-qint check-qstring check-qdict check-qlist $tools"
-      tools="check-qfloat check-qjson $tools"
+      checks="check-qint check-qstring check-qdict check-qlist"
+      checks="check-qfloat check-qjson $checks"
     fi
   fi
 fi
@@ -3078,6 +3078,7 @@ fi
 echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
 
 echo "TOOLS=$tools" >> $config_host_mak
+echo "CHECKS=$checks" >> $config_host_mak
 echo "ROMS=$roms" >> $config_host_mak
 echo "MAKE=$make" >> $config_host_mak
 echo "INSTALL=$install" >> $config_host_mak
Signature · 1 line
1.7.1
#6 lore raw

PATCH 3/4 add "make check" target

In reply to Gerd Hoffmann

Add some Makefile glue so we have a simple "make check" to run the unit tests.

---
 Makefile |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
Makefile +6 -0
index 2963c8b..80c0bc2 100644
@@ -289,6 +289,12 @@ endif
 test speed: all
 	$(MAKE) -C tests $@
 
+.PHONY: check
+check: $(patsubst %,run-check-%,$(CHECKS))
+
+run-check-%: %
+	./$<
+
 .PHONY: TAGS
 TAGS:
 	find "$(SRC_PATH)" -name '*.[hc]' -print0 | xargs -0 etags
Signature · 1 line
1.7.1
#7 lore raw

PATCH 4/4 add test-coroutine to checks

In reply to Gerd Hoffmann

There is a "test-coroutine" which isn't in the list. Add it so "make check" runs it too.

---
 configure |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
configure +1 -1
index 44b3295..b677801 100755
@@ -2631,7 +2631,7 @@ if test "$softmmu" = yes ; then
     fi
     if [ "$check_utests" = "yes" ]; then
       checks="check-qint check-qstring check-qdict check-qlist"
-      checks="check-qfloat check-qjson $checks"
+      checks="check-qfloat check-qjson test-coroutine $checks"
     fi
   fi
 fi
Signature · 1 line
1.7.1
Reviewed-by on the v1 series
#8 lore raw
In reply to Gerd Hoffmann
Quoted 6 lines · Gerd Hoffmann

Hi,

This patch series intends to make unit testing easier. It adds a new "make check" target which can be used to run all unit tests which are currently in the tree. It also enables the unit tests by default, so you don't have to re-run configure with a special switch.

One test fails, but Luiz has a fix in his tree.

Reviewed-by
#9 lore raw
Quoted 4 lines · Markus Armbruster
Quoted 2 lines · Gerd Hoffmann

Hi,

Quoted 8 lines
Quoted 4 lines

This patch series intends to make unit testing easier. It adds a new "make check" target which can be used to run all unit tests which are currently in the tree. It also enables the unit tests by default, so you don't have to re-run configure with a special switch.

One test fails, but Luiz has a fix in his tree.

Now all tests are passing. Why this was not applied yet?

Signature · 1 line
Eduardo
#10 lore raw
Quoted 10 lines · Eduardo Habkost
Quoted 9 lines · Markus Armbruster
Quoted 6 lines · Gerd Hoffmann
   Hi,

This patch series intends to make unit testing easier. It adds a new "make check" target which can be used to run all unit tests which are currently in the tree. It also enables the unit tests by default, so you don't have to re-run configure with a special switch.

Quoted 7 lines
Quoted 3 lines

One test fails, but Luiz has a fix in his tree.

Now all tests are passing. Why this was not applied yet?

I was hoping for more, but maybe we just need to start here and grow organically, I'll queue it again.

Regards,

Anthony Liguori

Quoted 1 line
#11 lore raw

Am 24.10.2011 20:57, schrieb Anthony Liguori:

Quoted 13 lines · Eduardo Habkost
Quoted 12 lines · Markus Armbruster
Quoted 11 lines
Quoted 6 lines · Gerd Hoffmann
   Hi,

This patch series intends to make unit testing easier. It adds a new "make check" target which can be used to run all unit tests which are currently in the tree. It also enables the unit tests by default, so you don't have to re-run configure with a special switch.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

One test fails, but Luiz has a fix in his tree.

Now all tests are passing. Why this was not applied yet?

I was hoping for more, but maybe we just need to start here and grow organically, I'll queue it again.

A while ago I played with some simple IDE tests. It basically was a small x86 kernel with an empty image that sends IDE commands and prints some results, and a script that invokes the guest and checks whether the test has passed or failed.

So at first I started with my own multiboot kernel and copied over some parts of kvm-unittest's libc. Clearly not the best idea once it's more than a couple of lines, so at some point I took the code and integrated with my real kvm-unittests repository.

Now I don't have to duplicate code any more, but at the same time there's no chance that a 'make check' in an upstream qemu tree could run this. Tests for other devices will have exactly the same problem.

Any suggestions on how to go forward with this kind of tests? Should this go into qemu or into kvm-unittests? Or should kvm-unittests be merged into the qemu tree? Or is the approach completely wrong?

Kevin

#12 lore raw

Hi,

Quoted 7 lines
Quoted 2 lines

I was hoping for more, but maybe we just need to start here and grow organically, I'll queue it again.

A while ago I played with some simple IDE tests. It basically was a small x86 kernel with an empty image that sends IDE commands and prints some results, and a script that invokes the guest and checks whether the test has passed or failed.

That reminds me that I've started toying with running tests inside a guest too. Stopped working on it a while back due to other priorities.
Attached what I have so far.

Quoted 5 lines

So at first I started with my own multiboot kernel and copied over some parts of kvm-unittest's libc. Clearly not the best idea once it's more than a couple of lines, so at some point I took the code and integrated with my real kvm-unittests repository.

Quoted 7 lines

Now I don't have to duplicate code any more, but at the same time there's no chance that a 'make check' in an upstream qemu tree could run this. Tests for other devices will have exactly the same problem.

Any suggestions on how to go forward with this kind of tests? Should this go into qemu or into kvm-unittests? Or should kvm-unittests be merged into the qemu tree? Or is the approach completely wrong?

I think we should have some framework to run tests inside the guest in the qemu source tree. I'm not sure kvm-unittests is the right tool for the job though. It is quite low-level and mainly targets the kvm bits inside the linux kernel. Testing -- for example -- usb device emulation would pretty much require writing a usb stack for kvm-unitests ...

cheers,
Gerd

From 096f68ea08c3c4baf1bbdc549b257a67ecc87e25 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <[email protected]>
Date: Tue, 13 Sep 2011 17:38:37 +0200
Subject: [PATCH] initramfs test framework

---
 initramfs/.gitignore         |    3 +
 initramfs/10-qemu-udev.rules |    5 +
 initramfs/Makefile           |   36 +++++++
 initramfs/README             |   44 ++++++++
 initramfs/init.c             |  225 ++++++++++++++++++++++++++++++++++++++++++
 initramfs/initramfs-boot     |   32 ++++++
 initramfs/initramfs-create   |  111 +++++++++++++++++++++
 initramfs/test-ehci          |    3 +
 initramfs/test-ehci.good     |    8 ++
 initramfs/test-hello.c       |    7 ++
 initramfs/test-hello.good    |    1 +
 initramfs/test-uhci          |    3 +
 initramfs/test-uhci.good     |    3 +
 13 files changed, 481 insertions(+), 0 deletions(-)
 create mode 100644 initramfs/.gitignore
 create mode 100644 initramfs/10-qemu-udev.rules
 create mode 100644 initramfs/Makefile
 create mode 100644 initramfs/README
 create mode 100644 initramfs/init.c
 create mode 100755 initramfs/initramfs-boot
 create mode 100755 initramfs/initramfs-create
 create mode 100755 initramfs/test-ehci
 create mode 100644 initramfs/test-ehci.good
 create mode 100644 initramfs/test-hello.c
 create mode 100644 initramfs/test-hello.good
 create mode 100755 initramfs/test-uhci
 create mode 100644 initramfs/test-uhci.good
initramfs/.gitignore new file +3 -0
new file mode 100644
index 0000000..8ece42c
@@ -0,0 +1,3 @@
+initramfs.cpio.gz
+init
+test-hello
initramfs/10-qemu-udev.rules new file +5 -0
new file mode 100644
index 0000000..fb5cc0a
@@ -0,0 +1,5 @@
+# load modules
+DRIVER!="?*", ENV{MODALIAS}=="?*", RUN+="/sbin/modprobe -b $env{MODALIAS}"
+
+# virtio console
+KERNEL=="vport*", ATTR{name}=="?*", SYMLINK+="virtio-ports/$attr{name}"
initramfs/Makefile new file +36 -0
new file mode 100644
index 0000000..2db2b76
@@ -0,0 +1,36 @@
+
+CC	:= gcc
+CFLAGS	:= -O2 -g -Wall
+LDFLAGS	:= -lutil
+
+TOOLS	:= init
+TEST_C	:= test-hello
+TEST_SH	:= test-uhci test-ehci
+
+TARGETS := $(TOOLS) $(TEST_C) initramfs.cpio.gz
+TESTS	:= $(TEST_C) $(TEST_SH)
+
+run-test-uhci : QEMU_ARGS := -usb -device usb-tablet
+run-test-ehci : QEMU_ARGS := -readconfig ../docs/ich9-ehci-uhci.cfg
+
+default all: $(TARGETS)
+
+clean:
+	rm -f $(TARGETS) *.o *~
+	rm -f org.qemu.initramfs.log
+
+init: init.o
+test-hello: test-hello.o
+
+initramfs.cpio.gz: $(TOOLS) $(TESTS) initramfs-create
+	./initramfs-create $@ $(TESTS)
+
+boot shell: $(TARGETS)
+	./initramfs-boot
+
+run-test-%: $(TARGETS)
+	./initramfs-boot /tests/test-$* $(QEMU_ARGS)
+	diff -u org.qemu.initramfs.log test-$*.good
+
+run-tests: $(patsubst %,run-%,$(TESTS))
+
initramfs/README new file +44 -0

44 lines not on this page · raw message

initramfs/init.c new file +225 -0

225 lines not on this page · raw message

initramfs/initramfs-boot new file +32 -0
new file mode 100755
index 0000000..4884a6d
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+base="$(dirname $0)"
+command="$1"
+shift;
+
+case "$(uname -m)" in
+	x86_64)	qemu="x86_64-softmmu/qemu-system-x86_64"
+		;;
+	i?86)	qemu="i386-softmmu/qemu-system-i386"
+		;;
+	*)	echo "unknown arch: $(uname -m)"
+		exit 1
+		;;
+esac
+
+kernel="$(echo /boot/vmlinu*$(uname -r)*)"
+initrd="initramfs.cpio.gz"
+append="console=ttyS0"
+if test "$command" != ""; then
+	append="$append QEMU_RUN=$command"
+fi
+
+exec ../$qemu -nographic -no-reboot \
+	-machine accel=kvm:tcg \
+	-kernel "$kernel" \
+	-initrd "$initrd" \
+	-append "$append" \
+	-chardev file,id=cmdlog,path=org.qemu.initramfs.log \
+	-device virtio-serial \
+	-device virtserialport,name=org.qemu.initramfs.log,chardev=cmdlog \
+	"$@"
initramfs/initramfs-create new file +111 -0

111 lines not on this page · raw message

initramfs/test-ehci new file +3 -0
new file mode 100755
index 0000000..bd4bb5c
@@ -0,0 +1,3 @@
+#!/bin/sh
+/sbin/lspci -s1d
+/sbin/lsusb | sort
initramfs/test-ehci.good new file +8 -0
new file mode 100644
index 0000000..dd9c6b8
@@ -0,0 +1,8 @@
+00:1d.0 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #1 (rev 03)
+00:1d.1 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #2 (rev 03)
+00:1d.2 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #3 (rev 03)
+00:1d.7 USB Controller: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #1 (rev 03)
+Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
+Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
+Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
+Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
initramfs/test-hello.c new file +7 -0
new file mode 100644
index 0000000..e5ce2d2
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+    printf("Hello world!\n");
+    return 0;
+}
initramfs/test-hello.good new file +1 -0
new file mode 100644
index 0000000..dfd6895
@@ -0,0 +1 @@
+Hello world!
initramfs/test-uhci new file +3 -0
new file mode 100755
index 0000000..0af70e0
@@ -0,0 +1,3 @@
+#!/bin/sh
+/sbin/lspci -s1.2
+/sbin/lsusb | sort
\ No newline at end of file
initramfs/test-uhci.good new file +3 -0
new file mode 100644
index 0000000..c87271e
@@ -0,0 +1,3 @@
+00:01.2 USB Controller: Intel Corporation 82371SB PIIX3 USB [Natoma/Triton II] (rev 01)
+Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
+Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd 
Signature · 1 line
1.7.1
#13 lore raw

Am 25.10.2011 15:27, schrieb Gerd Hoffmann:

Quoted 27 lines

Hi,

Quoted 7 lines
Quoted 2 lines

I was hoping for more, but maybe we just need to start here and grow organically, I'll queue it again.

A while ago I played with some simple IDE tests. It basically was a small x86 kernel with an empty image that sends IDE commands and prints some results, and a script that invokes the guest and checks whether the test has passed or failed.

That reminds me that I've started toying with running tests inside a guest too. Stopped working on it a while back due to other priorities.
Attached what I have so far.

Quoted 5 lines

So at first I started with my own multiboot kernel and copied over some parts of kvm-unittest's libc. Clearly not the best idea once it's more than a couple of lines, so at some point I took the code and integrated with my real kvm-unittests repository.

Quoted 7 lines

Now I don't have to duplicate code any more, but at the same time there's no chance that a 'make check' in an upstream qemu tree could run this. Tests for other devices will have exactly the same problem.

Any suggestions on how to go forward with this kind of tests? Should this go into qemu or into kvm-unittests? Or should kvm-unittests be merged into the qemu tree? Or is the approach completely wrong?

Quoted 5 lines

I think we should have some framework to run tests inside the guest in the qemu source tree. I'm not sure kvm-unittests is the right tool for the job though. It is quite low-level and mainly targets the kvm bits inside the linux kernel. Testing -- for example -- usb device emulation would pretty much require writing a usb stack for kvm-unitests ...

Which is more or less the only way to do a reasonably complete test (particularly including the error handling paths that a current Linux might never exercise) at least for the host controllers.

I'm not sure if you can send arbitrary USB packets from Linux (is USB passthrough really direct passthrough or does the kernel mess with it?), so maybe for everything above host controllers you could use that. If you can't, you're back to your own USB stack.

Kevin

#14 lore raw
In reply to Gerd Hoffmann

On Tue, Oct 25, 2011 at 03:27:35PM +0200, Gerd Hoffmann wrote:
[...]

Quoted 22 lines
Quoted 4 lines

A while ago I played with some simple IDE tests. It basically was a small x86 kernel with an empty image that sends IDE commands and prints some results, and a script that invokes the guest and checks whether the test has passed or failed.

That reminds me that I've started toying with running tests inside a guest too. Stopped working on it a while back due to other priorities.
Attached what I have so far.

Quoted 5 lines

So at first I started with my own multiboot kernel and copied over some parts of kvm-unittest's libc. Clearly not the best idea once it's more than a couple of lines, so at some point I took the code and integrated with my real kvm-unittests repository.

Quoted 7 lines

Now I don't have to duplicate code any more, but at the same time there's no chance that a 'make check' in an upstream qemu tree could run this. Tests for other devices will have exactly the same problem.

Any suggestions on how to go forward with this kind of tests? Should this go into qemu or into kvm-unittests? Or should kvm-unittests be merged into the qemu tree? Or is the approach completely wrong?

Quoted 5 lines

I think we should have some framework to run tests inside the guest in the qemu source tree. I'm not sure kvm-unittests is the right tool for the job though. It is quite low-level and mainly targets the kvm bits inside the linux kernel. Testing -- for example -- usb device emulation would pretty much require writing a usb stack for kvm-unitests ...

We have a framework to run tests inside a fully-installed guest, that's KVM-Autotest. But maybe it's too much for the kind of tests you need, I don't know. There are different "levels" of testing, with different reequirements, and we need to have good tools for all levels.

Just trying to enumerate the kind of tests somebody may need:

A) Simple unit tests for internal qemu C functions
- 'make check' can run them, using either libcheck or gtest.
B) Functional tests that tests actual virtualization/emulation, but only of some specific subsystems, not using a fully-featured qemu process.
- We don't have anything like that, today, right? I am not sure we need it.
C) Functional tests that just need to run a small binary with no OS installed in the guest, but running a fully-feature qemu process.
- The tests in the 'tests' directory do this, right? kvm-unittests does this, right?
D) Functional tests that need a minimal OS installed, with, e.g., at least a Linux kernel and a shell.
- This is what Gerd's patch below does, right? Also, KVM-Autotest can be used for this.
E) Functional tests that need a full OS installed and configured.
- Today we use KVM-Autotest for this.

Does the above model look correct/complete, or is there some case I missed?

Quoted 39 lines

cheers,
Gerd

From 096f68ea08c3c4baf1bbdc549b257a67ecc87e25 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <[email protected]>
Date: Tue, 13 Sep 2011 17:38:37 +0200
Subject: [PATCH] initramfs test framework

---
 initramfs/.gitignore         |    3 +
 initramfs/10-qemu-udev.rules |    5 +
 initramfs/Makefile           |   36 +++++++
 initramfs/README             |   44 ++++++++
 initramfs/init.c             |  225 ++++++++++++++++++++++++++++++++++++++++++
 initramfs/initramfs-boot     |   32 ++++++
 initramfs/initramfs-create   |  111 +++++++++++++++++++++
 initramfs/test-ehci          |    3 +
 initramfs/test-ehci.good     |    8 ++
 initramfs/test-hello.c       |    7 ++
 initramfs/test-hello.good    |    1 +
 initramfs/test-uhci          |    3 +
 initramfs/test-uhci.good     |    3 +
 13 files changed, 481 insertions(+), 0 deletions(-)
 create mode 100644 initramfs/.gitignore
 create mode 100644 initramfs/10-qemu-udev.rules
 create mode 100644 initramfs/Makefile
 create mode 100644 initramfs/README
 create mode 100644 initramfs/init.c
 create mode 100755 initramfs/initramfs-boot
 create mode 100755 initramfs/initramfs-create
 create mode 100755 initramfs/test-ehci
 create mode 100644 initramfs/test-ehci.good
 create mode 100644 initramfs/test-hello.c
 create mode 100644 initramfs/test-hello.good
 create mode 100755 initramfs/test-uhci
 create mode 100644 initramfs/test-uhci.good
Signature · 1 line
Eduardo
#15 lore raw

Am 25.10.2011 17:03, schrieb Eduardo Habkost:

Quoted 30 lines · Gerd Hoffmann

[...]

Quoted 22 lines
Quoted 4 lines

A while ago I played with some simple IDE tests. It basically was a small x86 kernel with an empty image that sends IDE commands and prints some results, and a script that invokes the guest and checks whether the test has passed or failed.

That reminds me that I've started toying with running tests inside a guest too. Stopped working on it a while back due to other priorities.
Attached what I have so far.

Quoted 5 lines

So at first I started with my own multiboot kernel and copied over some parts of kvm-unittest's libc. Clearly not the best idea once it's more than a couple of lines, so at some point I took the code and integrated with my real kvm-unittests repository.

Quoted 7 lines

Now I don't have to duplicate code any more, but at the same time there's no chance that a 'make check' in an upstream qemu tree could run this. Tests for other devices will have exactly the same problem.

Any suggestions on how to go forward with this kind of tests? Should this go into qemu or into kvm-unittests? Or should kvm-unittests be merged into the qemu tree? Or is the approach completely wrong?

Quoted 5 lines

I think we should have some framework to run tests inside the guest in the qemu source tree. I'm not sure kvm-unittests is the right tool for the job though. It is quite low-level and mainly targets the kvm bits inside the linux kernel. Testing -- for example -- usb device emulation would pretty much require writing a usb stack for kvm-unitests ...

Quoted 4 lines

We have a framework to run tests inside a fully-installed guest, that's KVM-Autotest. But maybe it's too much for the kind of tests you need, I don't know. There are different "levels" of testing, with different reequirements, and we need to have good tools for all levels.

Autotest works for an entirely different use case.

Autotest is the right tool when you can let the tests run over night or over the weekend. Good to run regularly on the current git tree, the right thing to do to test release candidates.

It's the wrong tool for testing the patch that I'm currently working on. The focus here is on being able to run very quick tests. I don't want to wait for a guest installation to complete, and I don't even necessarily want to wait for a full-blown Linux guest to boot up.

Quoted 8 lines

Just trying to enumerate the kind of tests somebody may need:

A) Simple unit tests for internal qemu C functions
- 'make check' can run them, using either libcheck or gtest.
B) Functional tests that tests actual virtualization/emulation, but only of some specific subsystems, not using a fully-featured qemu process.
- We don't have anything like that, today, right? I am not sure we need it.

I think qemu-iotests could be considered an instance of B)

Quoted 4 lines

C) Functional tests that just need to run a small binary with no OS installed in the guest, but running a fully-feature qemu process.
- The tests in the 'tests' directory do this, right? kvm-unittests does this, right?

Not sure what test/ does, but for kvm-unittests yes. And this is also what I was talking about.

Quoted 10 lines

D) Functional tests that need a minimal OS installed, with, e.g., at least a Linux kernel and a shell.
- This is what Gerd's patch below does, right? Also, KVM-Autotest can be used for this.
E) Functional tests that need a full OS installed and configured.
- Today we use KVM-Autotest for this.

Does the above model look correct/complete, or is there some case I missed?

I think it covers what we need.

Kevin

#16 lore raw
Quoted 10 lines · Kevin Wolf

Am 25.10.2011 17:03, schrieb Eduardo Habkost:
I think qemu-iotests could be considered an instance of B)

Quoted 4 lines

C) Functional tests that just need to run a small binary with no OS installed in the guest, but running a fully-feature qemu process.
- The tests in the 'tests' directory do this, right? kvm-unittests does this, right?

Not sure what test/ does, but for kvm-unittests yes. And this is also what I was talking about.

Thinking more about this...

We could add a new '-x-test-server CHR' option. When this option is added, it would do the following:

1) Open CHR character device
2) Use /dev/shm for guest memory
3) Listen for connections on CHR
4) When something connects to CHR
a) reset device model
b) send /dev/shm fd over CHR
c) register CPU physical memory client
1. upon CPU physical memory changes, send the change info over CHR
d) instead of doing [kvm_]cpu_exec(), block reading on CHR

So when you launch qemu with -x-test-server, it'll sit there doing nothing terribly useful. But this lets you write a program that connects to CHR, and then by mapping {out,in}[bwl] to RPCs over the connection, and accessing RAM via mmap()'ing the passed fd using the client mapping table, you can essentially write kvm-unittest style tests while still having full access to libc.

And since each test program can reset QEMU after running, you could very nicely tie into something like gtest as a unit test framework. I think it's pretty appealing from a debugability perspective too.

It also means that it's possible to have 100% C test cases such that you could still build something like ppc64-softmmu and run it against the written test cases without having to really understand ppc64 assembly or have a ppc64 build environment (to generate native binaries to run under ppc64 TCG).

I think this could work out fairly well as a unit test framework.

Regards,

Anthony Liguori

Quoted 16 lines
Quoted 11 lines

D) Functional tests that need a minimal OS installed, with, e.g., at least a Linux kernel and a shell.
- This is what Gerd's patch below does, right? Also, KVM-Autotest can be used for this.
E) Functional tests that need a full OS installed and configured.
- Today we use KVM-Autotest for this.

Does the above model look correct/complete, or is there some case I missed?

I think it covers what we need.

Kevin

#17 lore raw

Am 26.10.2011 22:49, schrieb Anthony Liguori:

Quoted 27 lines · Kevin Wolf
Quoted 10 lines

Am 25.10.2011 17:03, schrieb Eduardo Habkost:
I think qemu-iotests could be considered an instance of B)

Quoted 4 lines

C) Functional tests that just need to run a small binary with no OS installed in the guest, but running a fully-feature qemu process.
- The tests in the 'tests' directory do this, right? kvm-unittests does this, right?

Not sure what test/ does, but for kvm-unittests yes. And this is also what I was talking about.

Thinking more about this...

We could add a new '-x-test-server CHR' option. When this option is added, it would do the following:

1) Open CHR character device
2) Use /dev/shm for guest memory
3) Listen for connections on CHR
4) When something connects to CHR
a) reset device model
b) send /dev/shm fd over CHR
c) register CPU physical memory client
1. upon CPU physical memory changes, send the change info over CHR
d) instead of doing [kvm_]cpu_exec(), block reading on CHR

Quoted 5 lines

So when you launch qemu with -x-test-server, it'll sit there doing nothing terribly useful. But this lets you write a program that connects to CHR, and then by mapping {out,in}[bwl] to RPCs over the connection, and accessing RAM via mmap()'ing the passed fd using the client mapping table, you can essentially write kvm-unittest style tests while still having full access to libc.

IRQs need to go through the connection as well.

Oh, and you would finally have a C user for libqmp. The test cases definitely need to be able to access the monitor. For example I would really love to have test cases for the I/O error paths that stop the VM (or actually it's the resume that must be tested).

Quoted 10 lines

And since each test program can reset QEMU after running, you could very nicely tie into something like gtest as a unit test framework. I think it's pretty appealing from a debugability perspective too.

It also means that it's possible to have 100% C test cases such that you could still build something like ppc64-softmmu and run it against the written test cases without having to really understand ppc64 assembly or have a ppc64 build environment (to generate native binaries to run under ppc64 TCG).

I think this could work out fairly well as a unit test framework.

Sounds great, where are the patches? ;-)

Kevin

#18 lore raw
Quoted 28 lines · Kevin Wolf

Am 26.10.2011 22:49, schrieb Anthony Liguori:

Quoted 27 lines · Kevin Wolf
Quoted 10 lines

Am 25.10.2011 17:03, schrieb Eduardo Habkost:
I think qemu-iotests could be considered an instance of B)

Quoted 4 lines

C) Functional tests that just need to run a small binary with no OS installed in the guest, but running a fully-feature qemu process.
- The tests in the 'tests' directory do this, right? kvm-unittests does this, right?

Not sure what test/ does, but for kvm-unittests yes. And this is also what I was talking about.

Thinking more about this...

We could add a new '-x-test-server CHR' option. When this option is added, it would do the following:

1) Open CHR character device
2) Use /dev/shm for guest memory
3) Listen for connections on CHR
4) When something connects to CHR
a) reset device model
b) send /dev/shm fd over CHR
c) register CPU physical memory client
1. upon CPU physical memory changes, send the change info over CHR
d) instead of doing [kvm_]cpu_exec(), block reading on CHR

Quoted 7 lines
Quoted 5 lines

So when you launch qemu with -x-test-server, it'll sit there doing nothing terribly useful. But this lets you write a program that connects to CHR, and then by mapping {out,in}[bwl] to RPCs over the connection, and accessing RAM via mmap()'ing the passed fd using the client mapping table, you can essentially write kvm-unittest style tests while still having full access to libc.

IRQs need to go through the connection as well.

Yes, forgot to mention that.

Quoted 5 lines

Oh, and you would finally have a C user for libqmp. The test cases definitely need to be able to access the monitor. For example I would really love to have test cases for the I/O error paths that stop the VM (or actually it's the resume that must be tested).

Yeah, tunnelling a monitor session sounds like a really good idea.

Quoted 4 lines
Quoted 4 lines

And since each test program can reset QEMU after running, you could very nicely tie into something like gtest as a unit test framework. I think it's pretty appealing from a debugability perspective too.

Quoted 8 lines
Quoted 6 lines

It also means that it's possible to have 100% C test cases such that you could still build something like ppc64-softmmu and run it against the written test cases without having to really understand ppc64 assembly or have a ppc64 build environment (to generate native binaries to run under ppc64 TCG).

I think this could work out fairly well as a unit test framework.

Sounds great, where are the patches? ;-)

Heh, need to find a volunteer although I spent a few minutes this afternoon trying to figure out how hard it would be. Turns out, it's much simpler than I expected if you do the same trick that Xen does. Instead of mucking with hooking cpu_exec, Xen simply starts the CPUs in the halted state such that TCG simply never runs. The following patch is all we really need.

test_init() just needs to register the appropriate file descriptor callbacks and then in the data path dispatch PIO/MMIO. It would also need to override cpu_interrupt_handler to intercept interrupt operations.

hw/pc.c +7 -1
index eb4c2d8..f3fd32d 100644
@@ -923,12 +923,18 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
     }
 }
 
+extern int test_allowed;
+
 static void pc_cpu_reset(void *opaque)
 {
     CPUState *env = opaque;
 
     cpu_reset(env);
-    env->halted = !cpu_is_bsp(env);
+    if (test_allowed) {
+        env->halted = 1;
+    } else {
+        env->halted = !cpu_is_bsp(env);
+    }
 }
 
 static CPUState *pc_new_cpu(const char *cpu_model)
vl.c +14 -0
index 1ddb17b..adc626a 100644
@@ -1988,6 +1988,19 @@ static int tcg_init(void)
     return 0;
 }
 
+static int test_init(void)
+{
+    printf("Hello World\n");
+    return 0;
+}
+
+static int test_available(void)
+{
+    return 1;
+}
+
+int test_allowed = 1;
+
 static struct {
     const char *opt_name;
     const char *name;
@@ -1998,6 +2011,7 @@ static struct {
     { "tcg", "tcg", tcg_available, tcg_init, &tcg_allowed },
     { "xen", "Xen", xen_available, xen_init, &xen_allowed },
     { "kvm", "KVM", kvm_available, kvm_init, &kvm_allowed },
+    { "test", "Test", test_available, test_init, &test_allowed },
 };
 
 static int configure_accelerator(void)
Quoted 2 lines

Kevin

#19 lore raw
Quoted 120 lines · Anthony Liguori
Quoted 28 lines · Kevin Wolf

Am 26.10.2011 22:49, schrieb Anthony Liguori:

Quoted 27 lines · Kevin Wolf
Quoted 10 lines

Am 25.10.2011 17:03, schrieb Eduardo Habkost:
I think qemu-iotests could be considered an instance of B)

Quoted 4 lines

C) Functional tests that just need to run a small binary with no OS installed in the guest, but running a fully-feature qemu process.
- The tests in the 'tests' directory do this, right? kvm-unittests does this, right?

Not sure what test/ does, but for kvm-unittests yes. And this is also what I was talking about.

Thinking more about this...

We could add a new '-x-test-server CHR' option. When this option is added, it would do the following:

1) Open CHR character device
2) Use /dev/shm for guest memory
3) Listen for connections on CHR
4) When something connects to CHR
a) reset device model
b) send /dev/shm fd over CHR
c) register CPU physical memory client
1. upon CPU physical memory changes, send the change info over CHR
d) instead of doing [kvm_]cpu_exec(), block reading on CHR

Quoted 7 lines
Quoted 5 lines

So when you launch qemu with -x-test-server, it'll sit there doing nothing terribly useful. But this lets you write a program that connects to CHR, and then by mapping {out,in}[bwl] to RPCs over the connection, and accessing RAM via mmap()'ing the passed fd using the client mapping table, you can essentially write kvm-unittest style tests while still having full access to libc.

IRQs need to go through the connection as well.

Yes, forgot to mention that.

Quoted 5 lines

Oh, and you would finally have a C user for libqmp. The test cases definitely need to be able to access the monitor. For example I would really love to have test cases for the I/O error paths that stop the VM (or actually it's the resume that must be tested).

Yeah, tunnelling a monitor session sounds like a really good idea.

Quoted 4 lines
Quoted 4 lines

And since each test program can reset QEMU after running, you could very nicely tie into something like gtest as a unit test framework. I think it's pretty appealing from a debugability perspective too.

Quoted 8 lines
Quoted 6 lines

It also means that it's possible to have 100% C test cases such that you could still build something like ppc64-softmmu and run it against the written test cases without having to really understand ppc64 assembly or have a ppc64 build environment (to generate native binaries to run under ppc64 TCG).

I think this could work out fairly well as a unit test framework.

Sounds great, where are the patches? ;-)

Heh, need to find a volunteer although I spent a few minutes this afternoon trying to figure out how hard it would be. Turns out, it's much simpler than I expected if you do the same trick that Xen does. Instead of mucking with hooking cpu_exec, Xen simply starts the CPUs in the halted state such that TCG simply never runs. The following patch is all we really need.

test_init() just needs to register the appropriate file descriptor callbacks and then in the data path dispatch PIO/MMIO. It would also need to override cpu_interrupt_handler to intercept interrupt operations.

hw/pc.c +7 -1
index eb4c2d8..f3fd32d 100644
@@ -923,12 +923,18 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
      }
  }
 
+extern int test_allowed;
+
  static void pc_cpu_reset(void *opaque)
  {
      CPUState *env = opaque;
 
      cpu_reset(env);
-    env->halted = !cpu_is_bsp(env);
+    if (test_allowed) {
+        env->halted = 1;
+    } else {
+        env->halted = !cpu_is_bsp(env);
+    }
  }
 
  static CPUState *pc_new_cpu(const char *cpu_model)
vl.c +13 -0
index 1ddb17b..adc626a 100644
@@ -1988,6 +1988,19 @@ static int tcg_init(void)
      return 0;
  }
 
+static int test_init(void)
+{
+    printf("Hello World\n");
+    return 0;
+}
+
+static int test_available(void)
+{
+    return 1;
+}
+
+int test_allowed = 1;
+
  static struct {
      const char *opt_name;
      const char *name;

vl.c static struct { · line 2017

Quoted 7 lines
vl.c +1 -0
@@ -1998,6 +2011,7 @@ static struct {
      { "tcg", "tcg", tcg_available, tcg_init, &tcg_allowed },
      { "xen", "Xen", xen_available, xen_init, &xen_allowed },
      { "kvm", "KVM", kvm_available, kvm_init, &kvm_allowed },
+    { "test", "Test", test_available, test_init, &test_allowed },
  };
 
  static int configure_accelerator(void)

vl.c seems to have changed a bit since then, but I think this was the same basic approach we took with QTest:

http://repo.or.cz/w/qemu/mdroth.git/commitdiff/2e55d8a892297512f6c7883aff2c4b082bd6a3d5?hp=07d8a50cb0e096c5cdc5a81b8030e40833664dd3

http://wiki.qemu.org/Features/QTest

There was even a brief period where we were using gtest, but GLib hadn't been merged yet so we pulled it "temporarially" before going off and working on other stuff.

Quoted 5 lines
Quoted 3 lines

Kevin

Signature · 3 lines
Sincerely,
Mike Roth
IBM Linux Technology Center
#20 lore raw
In reply to Eduardo Habkost

Hi,

Quoted 4 lines

Just trying to enumerate the kind of tests somebody may need:

A) Simple unit tests for internal qemu C functions
- 'make check' can run them, using either libcheck or gtest.

Yes, those tests should work and succeed anywhere where qemu compiles.

Quoted 4 lines

B) Functional tests that tests actual virtualization/emulation, but only of some specific subsystems, not using a fully-featured qemu process.
- We don't have anything like that, today, right? I am not sure we need it.

qemu-kvm used to have such tests. There is no point in not using qemu here though, thats why they where transformed into (C).

Quoted 4 lines

C) Functional tests that just need to run a small binary with no OS installed in the guest, but running a fully-feature qemu process.
- The tests in the 'tests' directory do this, right? kvm-unittests does this, right?

kvm-unittests yes.

tests/ seems to be a somewhat bitrotted random collection of tests.

Quoted 4 lines

D) Functional tests that need a minimal OS installed, with, e.g., at least a Linux kernel and a shell.
- This is what Gerd's patch below does, right? Also, KVM-Autotest can be used for this.

What the patch tries is to use the bits which are on the host anyway to run guest tests (obviously linux-on-linux only), so we can do parts of
(E) with less configuration, less internet bandwith (no iso downloads), less disk space requirements (no iso + disk storage) and faster (no guest installs needed). Didn't try yet to mount the host filesystem using 9p yet, with that we could possibly take the approach quite far as we suddenly don't have just a "minimal os" any more but alot more.

Using the host bits is at the same time a possible trouble spot. There are lots of different distros with more or less subtile differences out there. Each machine has a different set of packages installed. So having this "just work" everythere probably isn't that easy ...

Quoted 2 lines

E) Functional tests that need a full OS installed and configured.
- Today we use KVM-Autotest for this.

cheers,
Gerd

#21 lore raw
In reply to Eduardo Habkost
Quoted 37 lines · Eduardo Habkost

On Tue, Oct 25, 2011 at 03:27:35PM +0200, Gerd Hoffmann wrote:
[...]

Quoted 22 lines
Quoted 4 lines

A while ago I played with some simple IDE tests. It basically was a small x86 kernel with an empty image that sends IDE commands and prints some results, and a script that invokes the guest and checks whether the test has passed or failed.

That reminds me that I've started toying with running tests inside a guest too. Stopped working on it a while back due to other priorities.
Attached what I have so far.

Quoted 5 lines

So at first I started with my own multiboot kernel and copied over some parts of kvm-unittest's libc. Clearly not the best idea once it's more than a couple of lines, so at some point I took the code and integrated with my real kvm-unittests repository.

Quoted 7 lines

Now I don't have to duplicate code any more, but at the same time there's no chance that a 'make check' in an upstream qemu tree could run this. Tests for other devices will have exactly the same problem.

Any suggestions on how to go forward with this kind of tests? Should this go into qemu or into kvm-unittests? Or should kvm-unittests be merged into the qemu tree? Or is the approach completely wrong?

Quoted 5 lines

I think we should have some framework to run tests inside the guest in the qemu source tree. I'm not sure kvm-unittests is the right tool for the job though. It is quite low-level and mainly targets the kvm bits inside the linux kernel. Testing -- for example -- usb device emulation would pretty much require writing a usb stack for kvm-unitests ...

We have a framework to run tests inside a fully-installed guest, that's KVM-Autotest. But maybe it's too much for the kind of tests you need, I don't know. There are different "levels" of testing, with different reequirements, and we need to have good tools for all levels.

Just trying to enumerate the kind of tests somebody may need:

Quoted 14 lines

A) Simple unit tests for internal qemu C functions
- 'make check' can run them, using either libcheck or gtest.
B) Functional tests that tests actual virtualization/emulation, but only of some specific subsystems, not using a fully-featured qemu process.
- We don't have anything like that, today, right? I am not sure we need it.
C) Functional tests that just need to run a small binary with no OS installed in the guest, but running a fully-feature qemu process.
- The tests in the 'tests' directory do this, right? kvm-unittests does this, right?
D) Functional tests that need a minimal OS installed, with, e.g., at least a Linux kernel and a shell.
- This is what Gerd's patch below does, right? Also, KVM-Autotest can be used for this.

Yes, it can. There's instrumentation to get ssh sessions, serial sessions, execute monitor commands... Only need to specify the path to a pre-installed minimal guest, skip install tests and have the bare minimal subset of tests needed. If only a small subset of tests are run with a minimal image, a kvm autotest job is quick to run and suitable for development use. I've looked at Gerd's initial patch to add an initramfs for such lightweight testing, and the init ramdisk generation could be implemented in autotest.

However...

Problem today is that KVM autotest is considered to be hard to approach and integrate with qemu developer's workflow. I won't argue it's not, so I'm admitting failure here. We've been juggling to keep it stable for the regular, full blown QE case, with expanding test and targets coverage (see libvirt test), and yet trying to make it better documented and sufficiently easy to approach to do simpler ad hoc testing. I wish it was easier to accomplish the later, though.

So, an in-tree solution for D) like the one Gerd started to work on seems better, as it won't generate frustration from folks having to learn kvm autotest, which will ultimately lead to them ignoring the effort.

Quoted 48 lines

E) Functional tests that need a full OS installed and configured.
- Today we use KVM-Autotest for this.

Does the above model look correct/complete, or is there some case I missed?

Quoted 39 lines

cheers,
Gerd

From 096f68ea08c3c4baf1bbdc549b257a67ecc87e25 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann<[email protected]>
Date: Tue, 13 Sep 2011 17:38:37 +0200
Subject: [PATCH] initramfs test framework

---
  initramfs/.gitignore         |    3 +
  initramfs/10-qemu-udev.rules |    5 +
  initramfs/Makefile           |   36 +++++++
  initramfs/README             |   44 ++++++++
  initramfs/init.c             |  225 ++++++++++++++++++++++++++++++++++++++++++
  initramfs/initramfs-boot     |   32 ++++++
  initramfs/initramfs-create   |  111 +++++++++++++++++++++
  initramfs/test-ehci          |    3 +
  initramfs/test-ehci.good     |    8 ++
  initramfs/test-hello.c       |    7 ++
  initramfs/test-hello.good    |    1 +
  initramfs/test-uhci          |    3 +
  initramfs/test-uhci.good     |    3 +
  13 files changed, 481 insertions(+), 0 deletions(-)

create mode 100644 initramfs/.gitignore
create mode 100644 initramfs/10-qemu-udev.rules
create mode 100644 initramfs/Makefile
create mode 100644 initramfs/README
create mode 100644 initramfs/init.c
create mode 100755 initramfs/initramfs-boot
create mode 100755 initramfs/initramfs-create
create mode 100755 initramfs/test-ehci
create mode 100644 initramfs/test-ehci.good
create mode 100644 initramfs/test-hello.c
create mode 100644 initramfs/test-hello.good
create mode 100755 initramfs/test-uhci
create mode 100644 initramfs/test-uhci.good

#22 lore raw
In reply to Kevin Wolf
Quoted 28 lines · Kevin Wolf

Am 24.10.2011 20:57, schrieb Anthony Liguori:

Quoted 13 lines · Eduardo Habkost
Quoted 12 lines · Markus Armbruster
Quoted 11 lines
Quoted 6 lines · Gerd Hoffmann
    Hi,

This patch series intends to make unit testing easier. It adds a new "make check" target which can be used to run all unit tests which are currently in the tree. It also enables the unit tests by default, so you don't have to re-run configure with a special switch.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

One test fails, but Luiz has a fix in his tree.

Now all tests are passing. Why this was not applied yet?

I was hoping for more, but maybe we just need to start here and grow organically, I'll queue it again.

A while ago I played with some simple IDE tests. It basically was a small x86 kernel with an empty image that sends IDE commands and prints some results, and a script that invokes the guest and checks whether the test has passed or failed.

Quoted 4 lines

So at first I started with my own multiboot kernel and copied over some parts of kvm-unittest's libc. Clearly not the best idea once it's more than a couple of lines, so at some point I took the code and integrated with my real kvm-unittests repository.

I did something very similar. I just added PCI support to kvm-unittests such that I could write a small virtio driver.

I actually do think tests like this could live in a make check framework in QEMU.

Regards,

Anthony Liguori

Quoted 11 lines

Now I don't have to duplicate code any more, but at the same time there's no chance that a 'make check' in an upstream qemu tree could run this. Tests for other devices will have exactly the same problem.

Any suggestions on how to go forward with this kind of tests? Should this go into qemu or into kvm-unittests? Or should kvm-unittests be merged into the qemu tree? Or is the approach completely wrong?

Kevin

#23 lore raw
In reply to Gerd Hoffmann
Quoted 6 lines · Gerd Hoffmann
   Hi,

This patch series intends to make unit testing easier. It adds a new "make check" target which can be used to run all unit tests which are currently in the tree. It also enables the unit tests by default, so you don't have to re-run configure with a special switch.

Applied all. Thanks.

Regards,

Anthony Liguori

Quoted 16 lines

cheers,
Gerd

Gerd Hoffmann (4):
Probe for libcheck by default.
move checks to separate variable
add "make check" target
add test-coroutine to checks

  Makefile  |   10 ++++++++--
  configure |    7 ++++---
  2 files changed, 12 insertions(+), 5 deletions(-)