Message ID | 16b62ea67fcc34be255541423fbb1db9cdc1c258.1472720373.git.mprivozn@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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).
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"
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(-)