All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] tests: Fix broken tcg test compilation
@ 2016-09-01  9:02 Michal Privoznik
  2016-09-01 14:30 ` Eric Blake
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Privoznik @ 2016-09-01  9:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: veroniabahaa, pbonzini

The first build error to be seen is that linux-test.c fails to
include cutils.h:

linux-test.c:42:25: fatal error: qemu/cutils.h: No such file or directory

This is because toplevel include/ dir is not put onto compiler's
command line. After that:

qemu.git/include/qemu/cutils.h:171:1: error: unknown type name ‘bool’

So we need to include "qemu/osdep.h" which will define bool type
for us. However, osdep.h eventually includes glib.h from system,
therefore we need to put GLIB_CFLAGS onto compiler's command line
too.

Lastly, getrusage is used in linux-test.c. This function and a
struct it uses are defined in sys/resource.h:

linux-test.c:247:5: warning: implicit declaration of function ‘getrusage’

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---

Frankly, with this patch I'm at least able to compile the test suite. Although
every test fails with invalid instruction (and a coredump).

 tests/tcg/Makefile     | 6 +++---
 tests/tcg/linux-test.c | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/tests/tcg/Makefile b/tests/tcg/Makefile
index 89e3342..5eadd8b 100644
--- a/tests/tcg/Makefile
+++ b/tests/tcg/Makefile
@@ -89,7 +89,7 @@ hello-i386: hello-i386.c
 	strip $@
 
 testthread: testthread.c
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpthread
+	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpthread
 
 # i386/x86_64 emulation test (test various opcodes) */
 test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
@@ -98,7 +98,7 @@ test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
               $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
 
 test-i386-fprem: test-i386-fprem.c
-	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $^
+	$(CC_I386) $(QEMU_INCLUDES) $(GLIB_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^
 
 test-x86_64: test-i386.c \
            test-i386.h test-i386-shift.h test-i386-muldiv.h
@@ -106,7 +106,7 @@ test-x86_64: test-i386.c \
 
 # generic Linux and CPU test
 linux-test: linux-test.c
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm
+	$(CC_I386) $(QEMU_INCLUDES) $(GLIB_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm
 
 # vm86 test
 runcom: runcom.c
diff --git a/tests/tcg/linux-test.c b/tests/tcg/linux-test.c
index 5070d31..2a46eba 100644
--- a/tests/tcg/linux-test.c
+++ b/tests/tcg/linux-test.c
@@ -31,6 +31,7 @@
 #include <utime.h>
 #include <time.h>
 #include <sys/time.h>
+#include <sys/resource.h>
 #include <sys/uio.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -39,6 +40,7 @@
 #include <dirent.h>
 #include <setjmp.h>
 #include <sys/shm.h>
+#include "qemu/osdep.h"
 #include "qemu/cutils.h"
 
 #define TESTPATH "/tmp/linux-test.tmp"
-- 
2.8.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] tests: Fix broken tcg test compilation
  2016-09-01  9:02 [Qemu-devel] [PATCH] tests: Fix broken tcg test compilation Michal Privoznik
@ 2016-09-01 14:30 ` Eric Blake
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Blake @ 2016-09-01 14:30 UTC (permalink / raw)
  To: Michal Privoznik, qemu-devel; +Cc: veroniabahaa, pbonzini

[-- Attachment #1: Type: text/plain, Size: 1502 bytes --]

On 09/01/2016 04:02 AM, Michal Privoznik wrote:
> The first build error to be seen is that linux-test.c fails to
> include cutils.h:
> 
> linux-test.c:42:25: fatal error: qemu/cutils.h: No such file or directory
> 
> This is because toplevel include/ dir is not put onto compiler's
> command line. After that:
> 
> qemu.git/include/qemu/cutils.h:171:1: error: unknown type name ‘bool’
> 
> So we need to include "qemu/osdep.h" which will define bool type
> for us. However, osdep.h eventually includes glib.h from system,
> therefore we need to put GLIB_CFLAGS onto compiler's command line
> too.
> 
> Lastly, getrusage is used in linux-test.c. This function and a
> struct it uses are defined in sys/resource.h:
> 
> linux-test.c:247:5: warning: implicit declaration of function ‘getrusage’
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
> 

> +++ b/tests/tcg/linux-test.c
> @@ -31,6 +31,7 @@
>  #include <utime.h>
>  #include <time.h>
>  #include <sys/time.h>
> +#include <sys/resource.h>
>  #include <sys/uio.h>
>  #include <sys/socket.h>
>  #include <netinet/in.h>
> @@ -39,6 +40,7 @@
>  #include <dirent.h>
>  #include <setjmp.h>
>  #include <sys/shm.h>
> +#include "qemu/osdep.h"

osdep.h has to be included first, before any system headers (in case it
sets defines that modify the behavior of those system headers).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-01 14:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-01  9:02 [Qemu-devel] [PATCH] tests: Fix broken tcg test compilation Michal Privoznik
2016-09-01 14:30 ` Eric Blake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.