Skip to contentSkip to conversation

tests: Fix TCG make test

PATCH In review Andreas Färber 4 participants 24 messages Apr 11, 2015 – Jun 24, 2015

lore
Share & tools
lore
#0 lore raw

cover tests: Fix TCG make test

Hello,

In my quest to improve our test coverage, in light of the recent cpu_copy() breakage, I've taken a stab at make test and actually managed to get most of it to work on x86_64.

Regards,
Andreas

Andreas Färber (7):
tests/tcg: Fix test_path build
tests/tcg: Fix linux-test build
tests/tcg: Disable hanging test-mmap runs
tests/tcg: Fix running x86_64 tests
tests/tcg: Fix run-runcom target
tests/tcg: Prettify run-runcom output
tests/tcg: Enable runcom test by default

 tests/tcg/Makefile     | 17 ++++++++---------
 tests/tcg/linux-test.c |  1 +
 2 files changed, 9 insertions(+), 9 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/7 tests/tcg: Fix test_path build

tests/tcg/test_path.c incorporates source files that rely on GLib. Add GLIB_CFLAGS to QEMU_CFLAGS to fix the build.

---
 tests/tcg/Makefile | 1 +
 1 file changed, 1 insertion(+)
tests/tcg/Makefile +1 -0
index 89e3342..64f661a 100644
@@ -10,6 +10,7 @@ CC_X86_64=$(CC_I386) -m64
 QEMU_INCLUDES += -I../..
 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
 #CFLAGS+=-msse2
+QEMU_CFLAGS += $(GLIB_CFLAGS)
 LDFLAGS=
 
 # TODO: automatically detect ARM and MIPS compilers, and run those too
Signature · 1 line
2.1.4
Reviewed-by on v1 1/7
#2 lore raw

Re: [Qemu-devel] [PATCH for-2.3? 1/7] tests/tcg: Fix test_path build

Quoted 4 lines · Andreas Färber

tests/tcg/test_path.c incorporates source files that rely on GLib. Add GLIB_CFLAGS to QEMU_CFLAGS to fix the build.

Quoted 16 lines
---
 tests/tcg/Makefile | 1 +
 1 file changed, 1 insertion(+)
tests/tcg/Makefile +1 -0
index 89e3342..64f661a 100644
@@ -10,6 +10,7 @@ CC_X86_64=$(CC_I386) -m64
 QEMU_INCLUDES += -I../..
 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
 #CFLAGS+=-msse2
+QEMU_CFLAGS += $(GLIB_CFLAGS)
 LDFLAGS=
 
 # TODO: automatically detect ARM and MIPS compilers, and run those too
Signature · 1 line
Alex Bennée
#3 lore raw

PATCH 2/7 tests/tcg: Fix linux-test build

In reply to Andreas Färber

Include a missing system header for struct rusage / getrusage().

---
 tests/tcg/linux-test.c | 1 +
 1 file changed, 1 insertion(+)
tests/tcg/linux-test.c +1 -0
index 1c6c013..15c9d7f 100644
@@ -39,6 +39,7 @@
 #include <dirent.h>
 #include <setjmp.h>
 #include <sys/shm.h>
+#include <sys/resource.h>
 
 #define TESTPATH "/tmp/linux-test.tmp"
 #define TESTPORT 7654
Signature · 1 line
2.1.4
Reviewed-by on v1 2/7
#4 lore raw

Re: [Qemu-devel] [PATCH for-2.3? 2/7] tests/tcg: Fix linux-test build

Quoted 3 lines · Andreas Färber

Include a missing system header for struct rusage / getrusage().

Quoted 16 lines
---
 tests/tcg/linux-test.c | 1 +
 1 file changed, 1 insertion(+)
tests/tcg/linux-test.c +1 -0
index 1c6c013..15c9d7f 100644
@@ -39,6 +39,7 @@
 #include <dirent.h>
 #include <setjmp.h>
 #include <sys/shm.h>
+#include <sys/resource.h>
 
 #define TESTPATH "/tmp/linux-test.tmp"
 #define TESTPORT 7654
Signature · 1 line
Alex Bennée
#5 lore raw

PATCH 3/7 tests/tcg: Disable hanging test-mmap runs

In reply to Andreas Färber

All three invocations of test-mmap with -p parameters hang without producing any output.

Don't call them for now, to let make test proceed.

---
 tests/tcg/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tests/tcg/Makefile +3 -3
index 64f661a..d79e0bb 100644
@@ -69,9 +69,9 @@ run-test-x86_64: test-x86_64
 
 run-test-mmap: test-mmap
 	-$(QEMU) ./test-mmap
-	-$(QEMU) -p 8192 ./test-mmap 8192
-	-$(QEMU) -p 16384 ./test-mmap 16384
-	-$(QEMU) -p 32768 ./test-mmap 32768
+#	-$(QEMU) -p 8192 ./test-mmap 8192
+#	-$(QEMU) -p 16384 ./test-mmap 16384
+#	-$(QEMU) -p 32768 ./test-mmap 32768
 
 run-runcom: runcom
 	-$(QEMU) ./runcom $(SRC_PATH)/tests/pi_10.com
Signature · 1 line
2.1.4
#6 lore raw

PATCH 4/7 tests/tcg: Fix running x86_64 tests

In reply to Andreas Färber

When ARCH != i386, the wrong test target was being added to the list of tests to run. Fix this to have test-x86_64 run as well.

Note that test-x86_64 produces two build warnings on gcc 4.8.3, but we don't use -Werror for these tests:

test-i386.c:2110:1: warning: specifying vector types with __attribute__ ((mode)) is deprecated [-Wattributes]
typedef int __m64 __attribute__ ((__mode__ (__V2SI__)));
test-i386.c:2110:1: warning: use __attribute__ ((vector_size)) instead [-Wattributes]

test-i386.c:2111:1: warning: specifying vector types with __attribute__ ((mode)) is deprecated [-Wattributes]
typedef float __m128 __attribute__ ((__mode__(__V4SF__)));
test-i386.c:2111:1: warning: use __attribute__ ((vector_size)) instead [-Wattributes]

---
 tests/tcg/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/tcg/Makefile +1 -1
index d79e0bb..ab1055f 100644
@@ -29,7 +29,7 @@ I386_TESTS=hello-i386 \
 
 # native i386 compilers sometimes are not biarch.  assume cross-compilers are
 ifneq ($(ARCH),i386)
-I386_TESTS+=run-test-x86_64
+I386_TESTS+=test-x86_64
 endif
 
 TESTS = test_path
Signature · 1 line
2.1.4
Reviewed-by on v1 4/7
#7 lore raw

Re: [Qemu-devel] [PATCH for-2.3? 4/7] tests/tcg: Fix running x86_64 tests

Quoted 10 lines · Andreas Färber

When ARCH != i386, the wrong test target was being added to the list of tests to run. Fix this to have test-x86_64 run as well.

Note that test-x86_64 produces two build warnings on gcc 4.8.3, but we don't use -Werror for these tests:

test-i386.c:2110:1: warning: specifying vector types with __attribute__ ((mode)) is deprecated [-Wattributes]
typedef int __m64 __attribute__ ((__mode__ (__V2SI__)));
test-i386.c:2110:1: warning: use __attribute__ ((vector_size)) instead [-Wattributes]

Quoted 5 lines

test-i386.c:2111:1: warning: specifying vector types with __attribute__ ((mode)) is deprecated [-Wattributes]
typedef float __m128 __attribute__ ((__mode__(__V4SF__)));
test-i386.c:2111:1: warning: use __attribute__ ((vector_size)) instead [-Wattributes]

Quoted 17 lines
---
 tests/tcg/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/tcg/Makefile +1 -1
index d79e0bb..ab1055f 100644
@@ -29,7 +29,7 @@ I386_TESTS=hello-i386 \
 
 # native i386 compilers sometimes are not biarch.  assume cross-compilers are
 ifneq ($(ARCH),i386)
-I386_TESTS+=run-test-x86_64
+I386_TESTS+=test-x86_64
 endif
 
 TESTS = test_path
Signature · 1 line
Alex Bennée
#8 lore raw

PATCH 5/7 tests/tcg: Fix run-runcom target

In reply to Andreas Färber

The path had not been updated after relocating the TCG tests.

Fix this to allow executing the test via make -C tests/tcg run-runcom.

---
 tests/tcg/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/tcg/Makefile +1 -1
index ab1055f..db8c510 100644
@@ -74,7 +74,7 @@ run-test-mmap: test-mmap
 #	-$(QEMU) -p 32768 ./test-mmap 32768
 
 run-runcom: runcom
-	-$(QEMU) ./runcom $(SRC_PATH)/tests/pi_10.com
+	-$(QEMU) ./runcom $(SRC_PATH)/tests/tcg/pi_10.com
 
 run-test_path: test_path
 	./test_path
Signature · 1 line
2.1.4
Reviewed-by on v1 5/7
#9 lore raw

Re: [Qemu-devel] [PATCH for-2.3? 5/7] tests/tcg: Fix run-runcom target

Quoted 5 lines · Andreas Färber

The path had not been updated after relocating the TCG tests.

Fix this to allow executing the test via make -C tests/tcg run-runcom.

Quoted 17 lines
---
 tests/tcg/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/tcg/Makefile +1 -1
index ab1055f..db8c510 100644
@@ -74,7 +74,7 @@ run-test-mmap: test-mmap
 #	-$(QEMU) -p 32768 ./test-mmap 32768
 
 run-runcom: runcom
-	-$(QEMU) ./runcom $(SRC_PATH)/tests/pi_10.com
+	-$(QEMU) ./runcom $(SRC_PATH)/tests/tcg/pi_10.com
 
 run-test_path: test_path
 	./test_path
Signature · 1 line
Alex Bennée
#10 lore raw

PATCH 6/7 tests/tcg: Prettify run-runcom output

In reply to Andreas Färber

Executing the binary pi_10.com terminates without a trailing newline.

As it does not seem to be caused by the runcom program and since we can't easily fix pi_10.com, add an echo after executing it. This places "make:" output (or that of a target following it) on a new line as expected.

---
 tests/tcg/Makefile | 1 +
 1 file changed, 1 insertion(+)
tests/tcg/Makefile +1 -0
index db8c510..f853d54 100644
@@ -75,6 +75,7 @@ run-test-mmap: test-mmap
 
 run-runcom: runcom
 	-$(QEMU) ./runcom $(SRC_PATH)/tests/tcg/pi_10.com
+	@echo
 
 run-test_path: test_path
 	./test_path
Signature · 1 line
2.1.4
#11 lore raw

Re: [Qemu-devel] [PATCH for-2.3? 6/7] tests/tcg: Prettify run-runcom output

Quoted 16 lines · Andreas Färber

Executing the binary pi_10.com terminates without a trailing newline.

As it does not seem to be caused by the runcom program and since we can't easily fix pi_10.com, add an echo after executing it. This places "make:" output (or that of a target following it) on a new line as expected.

---
 tests/tcg/Makefile | 1 +
 1 file changed, 1 insertion(+)
tests/tcg/Makefile +0 -0
index db8c510..f853d54 100644

tests/tcg/Makefile run-test-mmap: test-mmap · line 78

Quoted 4 lines
tests/tcg/Makefile +1 -0
@@ -75,6 +75,7 @@ run-test-mmap: test-mmap
 
 run-runcom: runcom
 	-$(QEMU) ./runcom $(SRC_PATH)/tests/tcg/pi_10.com
+	@echo

I'm not so sure about this. Shouldn't we be being a lot quieter by default. At the moment the TCG tests are very noisy with their output compared to the rest of the tests. On a V=0 run I expect just to see test name and a PASS/FAIL.

Quoted 3 lines
tests/tcg/Makefile +0 -0
 run-test_path: test_path
 	./test_path
Signature · 1 line
Alex Bennée
#12 lore raw

Re: [Qemu-devel] [PATCH for-2.3? 6/7] tests/tcg: Prettify run-runcom output

Quoted 4 lines · Alex Bennée

I'm not so sure about this. Shouldn't we be being a lot quieter by default. At the moment the TCG tests are very noisy with their output compared to the rest of the tests. On a V=0 run I expect just to see test name and a PASS/FAIL.

Yes, this test needs to be much quieter about what it's doing. It also takes about an order of magnitude too long to execute for a test case.

-- PMM

#13 lore raw

PATCH 7/7 tests/tcg: Enable runcom test by default

In reply to Andreas Färber

The comment of it requiring root appears outdated - makes no difference. pi_10.com terminates reproducibly with "...10559240190274216248".

---
 tests/tcg/Makefile | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
tests/tcg/Makefile +1 -4
index f853d54..1ba4264 100644
@@ -15,9 +15,6 @@ LDFLAGS=
 
 # TODO: automatically detect ARM and MIPS compilers, and run those too
 
-# runcom maps page 0, so it requires root privileges
-# also, pi_10.com runs indefinitely
-
 I386_TESTS=hello-i386 \
 	   linux-test \
 	   testthread \
@@ -25,7 +22,7 @@ I386_TESTS=hello-i386 \
 	   test-i386 \
 	   test-i386-fprem \
 	   test-mmap \
-	   # runcom
+	   runcom
 
 # native i386 compilers sometimes are not biarch.  assume cross-compilers are
 ifneq ($(ARCH),i386)
Signature · 1 line
2.1.4
#14 lore raw

Re: [Qemu-devel] [PATCH for-2.3? 7/7] tests/tcg: Enable runcom test by default

Quoted 1 line · Andreas Färber

The comment of it requiring root appears outdated - makes no difference.

This depends on what your system has set for the tunable /proc/sys/vm/mmap_min_addr. On my system it is 65536 (I think Ubuntu and Debian ship like this), and in that case you can't mmap MAP_FIXED to address zero unless you're root (tested with a little C program that does the same mmap that runcom does).

thanks
-- PMM

#15 lore raw

Re: [Qemu-devel] [PATCH for-2.3? 7/7] tests/tcg: Enable runcom test by default

Am 11.04.2015 um 22:22 schrieb Peter Maydell:

Quoted 8 lines · Andreas Färber
Quoted 1 line

The comment of it requiring root appears outdated - makes no difference.

This depends on what your system has set for the tunable /proc/sys/vm/mmap_min_addr. On my system it is 65536 (I think Ubuntu and Debian ship like this), and in that case you can't mmap MAP_FIXED to address zero unless you're root (tested with a little C program that does the same mmap that runcom does).

Hm,

$ cat /proc/sys/vm/mmap_min_addr
65536

Are you sure that QEMU / runcom / pi_10.com still try to map to that address zero?

Regards,
Andreas

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)
#16 lore raw

Re: [Qemu-devel] [PATCH for-2.3? 7/7] tests/tcg: Enable runcom test by default

Quoted 2 lines · Andreas Färber

Are you sure that QEMU / runcom / pi_10.com still try to map to that address zero?

It's the first thing runcom.c's main() does after checking you've passed it enough command line arguments.

-- PMM

#17 lore raw

Re: [Qemu-devel] [PATCH for-2.3? 7/7] tests/tcg: Enable runcom test by default

Am 11.04.2015 um 23:33 schrieb Peter Maydell:

Quoted 6 lines · Andreas Färber
Quoted 2 lines

Are you sure that QEMU / runcom / pi_10.com still try to map to that address zero?

It's the first thing runcom.c's main() does after checking you've passed it enough command line arguments.

This?

    vm86_mem = mmap((void *)0x00000000, 0x110000,
                    PROT_WRITE | PROT_READ | PROT_EXEC,
                    MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);
    if (vm86_mem == MAP_FAILED) {
        perror("mmap");
        exit(1);
    }

For whatever reason it does not take the MAP_FAILED path here...

But I can certainly live with dropping this patch, it's the last for a reason. :)

Andreas

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)
#18 lore raw

Re: [Qemu-devel] [PATCH for-2.3? 7/7] tests/tcg: Enable runcom test by default

Quoted 22 lines

Am 11.04.2015 um 23:46 schrieb Andreas Färber <[email protected]>:

Quoted 7 lines

Am 11.04.2015 um 23:33 schrieb Peter Maydell:

Quoted 3 lines · Andreas Färber

Are you sure that QEMU / runcom / pi_10.com still try to map to that address zero?

It's the first thing runcom.c's main() does after checking you've passed it enough command line arguments.

This?

   vm86_mem = mmap((void *)0x00000000, 0x110000,
                   PROT_WRITE | PROT_READ | PROT_EXEC,
                   MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);
   if (vm86_mem == MAP_FAILED) {
       perror("mmap");
       exit(1);
   }
Quoted 1 line

For whatever reason it does not take the MAP_FAILED path here...

Wasn't a NULL argument for the address a hint saying "map wherever you please"? I also feel like I'm missing context here - what exactly is broken?

Alex

Quoted 10 lines

But I can certainly live with dropping this patch, it's the last for a reason. :)

Andreas

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)
#19 lore raw

Re: [Qemu-devel] [PATCH for-2.3? 7/7] tests/tcg: Enable runcom test by default

Am 12.04.2015 um 10:34 schrieb Alexander Graf:

Quoted 20 lines
Quoted 20 lines

Am 11.04.2015 um 23:46 schrieb Andreas Färber <[email protected]>:

Quoted 7 lines

Am 11.04.2015 um 23:33 schrieb Peter Maydell:

Quoted 3 lines · Andreas Färber

Are you sure that QEMU / runcom / pi_10.com still try to map to that address zero?

It's the first thing runcom.c's main() does after checking you've passed it enough command line arguments.

This?

   vm86_mem = mmap((void *)0x00000000, 0x110000,
                   PROT_WRITE | PROT_READ | PROT_EXEC,
                   MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);
   if (vm86_mem == MAP_FAILED) {
       perror("mmap");
       exit(1);
   }
Quoted 3 lines
Quoted 1 line

For whatever reason it does not take the MAP_FAILED path here...

Wasn't a NULL argument for the address a hint saying "map wherever you please"? I also feel like I'm missing context here - what exactly is broken?

Sorry for CC'ing you so late, I believe you and rth had been fiddling with guest bases and that stuff back in the day... Please just take a look at the whole series, in particular patches 3 and 7.

Thanks,
Andreas

Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)
#20 lore raw

Re: [Qemu-devel] [PATCH for-2.3? 7/7] tests/tcg: Enable runcom test by default

In reply to Alexander Graf
Quoted 22 lines · Alexander Graf
Quoted 22 lines

Am 11.04.2015 um 23:46 schrieb Andreas Färber <[email protected]>:

Quoted 7 lines

Am 11.04.2015 um 23:33 schrieb Peter Maydell:

Quoted 3 lines · Andreas Färber

Are you sure that QEMU / runcom / pi_10.com still try to map to that address zero?

It's the first thing runcom.c's main() does after checking you've passed it enough command line arguments.

This?

   vm86_mem = mmap((void *)0x00000000, 0x110000,
                   PROT_WRITE | PROT_READ | PROT_EXEC,
                   MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);
   if (vm86_mem == MAP_FAILED) {
       perror("mmap");
       exit(1);
   }
Quoted 4 lines
Quoted 1 line

For whatever reason it does not take the MAP_FAILED path here...

Wasn't a NULL argument for the address a hint saying "map wherever you please"?

Only if you don't also say MAP_FIXED.

That aside, I've now looked more carefully at the makefile, and we're not running 'runcom' directly, we're running it within QEMU's user-mode. So a guest allocation at vaddr 0 isn't going to turn into a host mmap at vaddr 0 (we actually query the host mmap_min_addr parameter in linux-user/main.c).

So I think the issue noted in the comment on the makefile (back in 2010) would have been a bug which we've presumably fixed in the meantime by adding support for guest_base and making sure it works correctly. (Looking at the revision log suggests that guest_base should in theory have already supported adjustment based on mmap_min_addr at the point when runcom was taken out of the makefile, but presumably there was a bug.)

-- PMM

#21 lore raw
In reply to Andreas Färber
Quoted 4 lines · Andreas Färber

Hello,

In my quest to improve our test coverage, in light of the recent cpu_copy() breakage, I've taken a stab at make test and actually managed to get most of it to work on x86_64.

Thanks for tackling this cleanup; to answer the question in the subject, I think that at this point in the release cycle and given that 'make test' has always been somewhere between flaky and broken we should not put this in 2.3.

-- PMM

#22 lore raw
Quoted 10 lines · Peter Maydell
Quoted 4 lines · Andreas Färber

Hello,

In my quest to improve our test coverage, in light of the recent cpu_copy() breakage, I've taken a stab at make test and actually managed to get most of it to work on x86_64.

Thanks for tackling this cleanup; to answer the question in the subject, I think that at this point in the release cycle and given that 'make test' has always been somewhere between flaky and broken we should not put this in 2.3.

[summary of a comment from IRC]
Also, even with this patchset it looks like obvious test failures (eg "reference output differs from actual" and "test segvs") don't turn into "'make test' returns an error status, so it doesn't seem to me that "make test" is actually testing anything usefully at all. I would favour for 2.3 sticking with our current approach (viz, telling people to use 'make check', not 'make test'), and for 2.4 trying to integrate these tests into 'make check', fixing them up in the process.

thanks
-- PMM

#23 lore raw
In reply to Andreas Färber

Am 11.04.2015 um 20:34 schrieb Andreas Färber:

Quoted 7 lines

Hello,

In my quest to improve our test coverage, in light of the recent cpu_copy() breakage, I've taken a stab at make test and actually managed to get most of it to work on x86_64.

Regards,
Andreas

Ping for 2.4. CC'ing Marc-André.

Quoted 14 lines

Andreas Färber (7):
tests/tcg: Fix test_path build
tests/tcg: Fix linux-test build
tests/tcg: Disable hanging test-mmap runs
tests/tcg: Fix running x86_64 tests
tests/tcg: Fix run-runcom target
tests/tcg: Prettify run-runcom output
tests/tcg: Enable runcom test by default

 tests/tcg/Makefile     | 17 ++++++++---------
 tests/tcg/linux-test.c |  1 +
 2 files changed, 9 insertions(+), 9 deletions(-)
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)