Skip to contentSkip to conversation

Cleanup of TCG tests

PATCH In review Pranith Kumar 4 participants 32 messages Dec 1, 2016 – Dec 14, 2016

lore
Share & tools
lore
#0 lore raw

v5 cover Cleanup of TCG tests

Hello,

This patch series cleans up the tcg tests in tests/tcg folder.

The tests have bit-rotten and were not compiling or running. I fixed the Makefiles to make them compile though there are tests which do not pass.

The motivation is to add litmus tests to each arch and have them run using the 'make check' target to test consistency on TCG.

There are no maintainers listed for this test folder. So I am cc'ing people who I think might be interested.

The tests are hooked to the 'tests-tcg' target. Alternatively, as suggested by Alex Bennee you can run a tcg tests for a particular arch from the build/<arch>-linux-user/tests directory as follows:

$ CROSS_CC=<cross-compiler> make -f ../../tests/tcg/<arch>/Makefile

Thanks,
--
Pranith

Marc-André Lureau (9):
linux-user: fix settime old value location
linux-user: fix tcg/mmap test
check-help: add some hint to run a single test tests/tcg: comment unused code
tests/tcg: declare some functions as static
linux-test: fix build
linux-test: fix set/getitimer returned timer check Fix test-i386-fprem compilation
test-i386: modernize vector code v4sf

Pranith Kumar (10):
tests/tcg: Move arm tests to arch specific folder tests/tcg: Move mips test to arch specific folder tests/tcg: Add tests-tcg hook in Makefile tests/tcg/i386: Fix hello-i386 test
tests/tcg: Move i386 tests to arch specific folder tests/tcg/i386: Fix test-i386 compilation tests/tcg: Fix compilation of linux-test.c tests/tcg: Move arch independent tests to misc directory tests/tcg: Add and update Makefiles
tests/tcg: test-i386.c: Fix format warnings

 linux-user/mmap.c                       |  27 +++---
 linux-user/syscall.c                    |   2 +-
 tests/Makefile.include                  |   2 +
 tests/tcg/Makefile                      | 156 --------------------------------
 tests/tcg/Makefile.include              |  33 +++++++
 tests/tcg/alpha/Makefile                |  38 +++++---
 tests/tcg/arm/Makefile                  |  51 +++++++++++
 tests/tcg/{ => arm}/hello-arm.c         |   0
 tests/tcg/{ => arm}/test-arm-iwmmxt.s   |   0
 tests/tcg/cris/Makefile                 |  17 +++-
 tests/tcg/i386/Makefile                 |  87 ++++++++++++++++++
 tests/tcg/{ => i386}/hello-i386.c       |   9 +-
 tests/tcg/{ => i386}/pi_10.com          | Bin
 tests/tcg/{ => i386}/runcom.c           |   0
 tests/tcg/{ => i386}/test-i386-code16.S |   0
 tests/tcg/{ => i386}/test-i386-fprem.c  |  10 +-
 tests/tcg/{ => i386}/test-i386-muldiv.h |   0
 tests/tcg/{ => i386}/test-i386-shift.h  |   0
 tests/tcg/{ => i386}/test-i386-ssse3.c  |   0
 tests/tcg/{ => i386}/test-i386-vm86.S   |   0
 tests/tcg/{ => i386}/test-i386.c        |   7 +-
 tests/tcg/{ => i386}/test-i386.h        |   0
 tests/tcg/lm32/Makefile                 |  17 +++-
 tests/tcg/mips/Makefile                 |  46 ++++++++++
 tests/tcg/{ => mips}/hello-mips.c       |   0
 tests/tcg/mips/mips32-dsp/Makefile      |  17 +++-
 tests/tcg/mips/mips32-dspr2/Makefile    |  17 +++-
 tests/tcg/mips/mips64-dsp/Makefile      |  18 +++-
 tests/tcg/mips/mips64-dspr2/Makefile    |  17 +++-
 tests/tcg/misc/Makefile                 |  81 +++++++++++++++++
 tests/tcg/{ => misc}/linux-test.c       |  57 +++++++-----
 tests/tcg/{ => misc}/sha1.c             |   0
 tests/tcg/{ => misc}/test-mmap.c        |   2 +-
 tests/tcg/{ => misc}/test_path.c        |   0
 tests/tcg/{ => misc}/testthread.c       |   0
 tests/tcg/openrisc/Makefile             |  19 +++-
 tests/tcg/xtensa/Makefile               |  17 +++-
 37 files changed, 518 insertions(+), 229 deletions(-)
 delete mode 100644 tests/tcg/Makefile
 create mode 100644 tests/tcg/Makefile.include
 create mode 100644 tests/tcg/arm/Makefile
 rename tests/tcg/{ => arm}/hello-arm.c (100%)
 rename tests/tcg/{ => arm}/test-arm-iwmmxt.s (100%)
 create mode 100644 tests/tcg/i386/Makefile
 rename tests/tcg/{ => i386}/hello-i386.c (72%)
 rename tests/tcg/{ => i386}/pi_10.com (100%)
 rename tests/tcg/{ => i386}/runcom.c (100%)
 rename tests/tcg/{ => i386}/test-i386-code16.S (100%)
 rename tests/tcg/{ => i386}/test-i386-fprem.c (98%)
 rename tests/tcg/{ => i386}/test-i386-muldiv.h (100%)
 rename tests/tcg/{ => i386}/test-i386-shift.h (100%)
 rename tests/tcg/{ => i386}/test-i386-ssse3.c (100%)
 rename tests/tcg/{ => i386}/test-i386-vm86.S (100%)
 rename tests/tcg/{ => i386}/test-i386.c (99%)
 rename tests/tcg/{ => i386}/test-i386.h (100%)
 create mode 100644 tests/tcg/mips/Makefile
 rename tests/tcg/{ => mips}/hello-mips.c (100%)
 create mode 100644 tests/tcg/misc/Makefile
 rename tests/tcg/{ => misc}/linux-test.c (90%)
 rename tests/tcg/{ => misc}/sha1.c (100%)
 rename tests/tcg/{ => misc}/test-mmap.c (99%)
 rename tests/tcg/{ => misc}/test_path.c (100%)
 rename tests/tcg/{ => misc}/testthread.c (100%)
Signature · 1 line
2.10.2
#1 lore raw

PATCH v5 1/19 linux-user: fix settime old value location

From: Marc-André Lureau <[email protected]>

old_value is the 4th argument of timer_settime(), not the 2nd.

---
 linux-user/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/syscall.c +1 -1
index 7b77503..5bd477a 100644
@@ -12027,7 +12027,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             target_to_host_itimerspec(&hspec_new, arg3);
             ret = get_errno(
                           timer_settime(htimer, arg2, &hspec_new, &hspec_old));
-            host_to_target_itimerspec(arg2, &hspec_old);
+            host_to_target_itimerspec(arg4, &hspec_old);
         }
         break;
     }
Signature · 1 line
2.10.2
#4 lore raw

PATCH v5 2/19 linux-user: fix tcg/mmap test

In reply to Pranith Kumar

From: Marc-André Lureau <[email protected]>

tests/tcg/mmap test fails with values other than default target page size. When creating a map beyond EOF, extra anonymous pages are added up to the target page boundary. Currently, this operation is performed only when qemu_real_host_page_size < TARGET_PAGE_SIZE, but it should be performed if the configured page size (qemu -p) is larger than qemu_real_host_page_size too.

(also fixes some style issues to please checkpatch)

---
 linux-user/mmap.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
linux-user/mmap.c +14 -13
index 61685bf..0794a43 100644
@@ -418,31 +418,32 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
     }
 
     /* When mapping files into a memory area larger than the file, accesses
-       to pages beyond the file size will cause a SIGBUS. 
+       to pages beyond the file size will cause a SIGBUS.
 
        For example, if mmaping a file of 100 bytes on a host with 4K pages
        emulating a target with 8K pages, the target expects to be able to
        access the first 8K. But the host will trap us on any access beyond
-       4K.  
+       4K.
 
        When emulating a target with a larger page-size than the hosts, we
        may need to truncate file maps at EOF and add extra anonymous pages
        up to the targets page boundary.  */
 
-    if ((qemu_real_host_page_size < TARGET_PAGE_SIZE)
-        && !(flags & MAP_ANONYMOUS)) {
-       struct stat sb;
+    if ((qemu_real_host_page_size < qemu_host_page_size) &&
+        !(flags & MAP_ANONYMOUS)) {
+        struct stat sb;
 
-       if (fstat (fd, &sb) == -1)
-           goto fail;
+        if (fstat(fd, &sb) == -1) {
+            goto fail;
+        }
 
        /* Are we trying to create a map beyond EOF?.  */
-       if (offset + len > sb.st_size) {
-           /* If so, truncate the file map at eof aligned with 
-              the hosts real pagesize. Additional anonymous maps
-              will be created beyond EOF.  */
-           len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset);
-       }
+        if (offset + len > sb.st_size) {
+            /* If so, truncate the file map at eof aligned with
+               the hosts real pagesize. Additional anonymous maps
+               will be created beyond EOF.  */
+            len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset);
+        }
     }
 
     if (!(flags & MAP_FIXED)) {
Signature · 1 line
2.10.2
#7 lore raw

PATCH v5 3/19 check-help: add some hint to run a single test

In reply to Pranith Kumar

From: Marc-André Lureau <[email protected]>

It's possible to run the test directly, tests/test-foo, but then recompilation is not triggered and test environment variables aren't set for you.

---
 tests/Makefile.include | 1 +
 1 file changed, 1 insertion(+)
tests/Makefile.include +1 -0
index e98d3b6..2a2b78d 100644
@@ -731,6 +731,7 @@ check-help:
 	@echo " make check-qtest-TARGET   Run qtest tests for given target"
 	@echo " make check-qtest          Run qtest tests"
 	@echo " make check-unit           Run qobject tests"
+	@echo " make check-tests/test-foo Run the tests/test-foo unit test only"
 	@echo " make check-qapi-schema    Run QAPI schema tests"
 	@echo " make check-block          Run block tests"
 	@echo " make check-report.html    Generates an HTML test report"
Signature · 1 line
2.10.2
#9 lore raw

PATCH v5 4/19 tests/tcg: comment unused code

In reply to Pranith Kumar

From: Marc-André Lureau <[email protected]>

I didn't remove it, as suggest by checkpatch, because it looks like it may eventually be restored back.

---
 tests/tcg/linux-test.c      | 8 ++++++--
 tests/tcg/test-i386-fprem.c | 4 ++++
 2 files changed, 10 insertions(+), 2 deletions(-)
tests/tcg/linux-test.c +6 -2
index 5070d31..38d163c 100644
@@ -350,6 +350,7 @@ void test_socket(void)
 
 #define WCOUNT_MAX 512
 
+#if 0
 void test_pipe(void)
 {
     fd_set rfds, wfds;
@@ -421,11 +422,13 @@ void test_clone(void)
 
     stack1 = malloc(STACK_SIZE);
     pid1 = chk_error(clone(thread1_func, stack1 + STACK_SIZE,
-                           CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello1"));
+                           CLONE_VM | CLONE_FS | CLONE_FILES |
+                           SIGCHLD, (void *)"hello1"));
 
     stack2 = malloc(STACK_SIZE);
     pid2 = chk_error(clone(thread2_func, stack2 + STACK_SIZE,
-                           CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello2"));
+                           CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD,
+                           (void *)"hello2"));
 
     while (waitpid(pid1, &status1, 0) != pid1);
     free(stack1);
@@ -435,6 +438,7 @@ void test_clone(void)
         thread2_res != 6)
         error("clone");
 }
+#endif
 
 /***********************************/
 
tests/tcg/test-i386-fprem.c +4 -0
index 1a71623..1a2b144 100644
@@ -54,6 +54,7 @@ union float80u {
 
 #define IEEE854_LONG_DOUBLE_BIAS 0x3fff
 
+#if 0
 static const union float80u q_nan = {
     .ieee_nan.negative = 0,  /* X */
     .ieee_nan.exponent = 0x7fff,
@@ -61,6 +62,7 @@ static const union float80u q_nan = {
     .ieee_nan.quiet_nan = 1,
     .ieee_nan.mantissa = 0,
 };
+#endif
 
 static const union float80u s_nan = {
     .ieee_nan.negative = 0,  /* X */
@@ -91,12 +93,14 @@ static const union float80u pos_denorm = {
     .ieee.mantissa = 1,
 };
 
+#if 0
 static const union float80u smallest_positive_norm = {
     .ieee.negative = 0,
     .ieee.exponent = 1,
     .ieee.one = 1,
     .ieee.mantissa = 0,
 };
+#endif
 
 static void fninit()
 {
Signature · 1 line
2.10.2
#11 lore raw

PATCH v5 6/19 linux-test: fix build

In reply to Pranith Kumar

From: Marc-André Lureau <[email protected]>

- QEMU_INCLUDES because it uses qemu/include
- stdbool, for the bool usage
- sys/resource.h for rusage and friends
- qemu/compiler.h because it is no longer included in fprintf-fn.h (we may want to include it from qemu/cutils.h instead)

---
 tests/tcg/Makefile     | 2 +-
 tests/tcg/linux-test.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
tests/tcg/Makefile +1 -1
index 89e3342..d1557c2 100644
@@ -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) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm
 
 # vm86 test
 runcom: runcom.c
tests/tcg/linux-test.c +3 -0
index b46a1c4..65fca30 100644
@@ -17,6 +17,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 #define _GNU_SOURCE
+#include <stdbool.h>
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -31,6 +32,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 +41,7 @@
 #include <dirent.h>
 #include <setjmp.h>
 #include <sys/shm.h>
+#include "qemu/compiler.h"
 #include "qemu/cutils.h"
 
 #define TESTPATH "/tmp/linux-test.tmp"
Signature · 1 line
2.10.2
#12 lore raw

PATCH v5 7/19 linux-test: fix set/getitimer returned timer check

In reply to Pranith Kumar

From: Marc-André Lureau <[email protected]>

The previous value of the timer indicates the time to the next timer expiration, which is likely not the same as when the timer was set.

---
 tests/tcg/linux-test.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
tests/tcg/linux-test.c +9 -3
index 65fca30..24fce2b 100644
@@ -482,9 +482,12 @@ static void test_signal(void)
     it.it_value.tv_usec = 10 * 1000;
     chk_error(setitimer(ITIMER_REAL, &it, NULL));
     chk_error(getitimer(ITIMER_REAL, &oit));
-    if (oit.it_value.tv_sec != it.it_value.tv_sec ||
-        oit.it_value.tv_usec != it.it_value.tv_usec)
+    if (oit.it_value.tv_sec != it.it_interval.tv_sec ||
+        oit.it_value.tv_usec > it.it_interval.tv_usec ||
+        oit.it_interval.tv_sec != it.it_interval.tv_sec ||
+        oit.it_interval.tv_usec != it.it_interval.tv_usec) {
         error("itimer");
+    }
 
     while (alarm_count < 5) {
         usleep(10 * 1000);
@@ -497,8 +500,11 @@ static void test_signal(void)
     memset(&oit, 0xff, sizeof(oit));
     chk_error(setitimer(ITIMER_REAL, &it, &oit));
     if (oit.it_value.tv_sec != 0 ||
-        oit.it_value.tv_usec != 10 * 1000)
+        oit.it_value.tv_usec > 10 * 1000 ||
+        oit.it_interval.tv_sec != 0 ||
+        oit.it_interval.tv_usec != 10 * 1000) {
         error("setitimer");
+    }
 
     /* SIGSEGV test */
     act.sa_sigaction = sig_segv;
Signature · 1 line
2.10.2
#13 lore raw

PATCH v5 8/19 Fix test-i386-fprem compilation

In reply to Pranith Kumar

From: Marc-André Lureau <[email protected]>

This test doesn't depend on glib, and thus cannot use osdep.h.

---
 tests/tcg/test-i386-fprem.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tests/tcg/test-i386-fprem.c +5 -1
index 1a2b144..a258362 100644
@@ -23,7 +23,11 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "qemu/osdep.h"
+#include <stdint.h>
+#include <stdio.h>
+#include "qemu/compiler.h"
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
 /*
  * Inspired by <ieee754.h>'s union ieee854_long_double, but with single
Signature · 1 line
2.10.2
#14 lore raw

PATCH v5 9/19 test-i386: modernize vector code v4sf

In reply to Pranith Kumar

From: Marc-André Lureau <[email protected]>

Fixes the following compiler warning:

tests/tcg/test-i386.c:2110:1: warning: specifying vector types with __attribute__ ((mode)) is deprecated [-Wattributes]
typedef int __m64 __attribute__ ((__mode__ (__V2SI__)));
^~~~~~~

---
 tests/tcg/test-i386.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tests/tcg/test-i386.c +2 -3
index 0f7b943..b0f8975 100644
@@ -2107,15 +2107,14 @@ static void test_enter(void)
 
 #ifdef TEST_SSE
 
-typedef int __m64 __attribute__ ((__mode__ (__V2SI__)));
-typedef float __m128 __attribute__ ((__mode__(__V4SF__)));
+typedef float v4sf __attribute__ ((vector_size(4 * sizeof(float))));
 
 typedef union {
     double d[2];
     float s[4];
     uint32_t l[4];
     uint64_t q[2];
-    __m128 dq;
+    v4sf dq;
 } XMMReg;
 
 static uint64_t __attribute__((aligned(16))) test_values[4][2] = {
Signature · 1 line
2.10.2
#15 lore raw

PATCH v5 10/19 tests/tcg: Move arm tests to arch specific folder

In reply to Pranith Kumar
---
 tests/tcg/arm/Makefile                | 45 +++++++++++++++++++++++++++++++++++
 tests/tcg/{ => arm}/hello-arm.c       |  0
 tests/tcg/{ => arm}/test-arm-iwmmxt.s |  0
 3 files changed, 45 insertions(+)
 create mode 100644 tests/tcg/arm/Makefile
 rename tests/tcg/{ => arm}/hello-arm.c (100%)
 rename tests/tcg/{ => arm}/test-arm-iwmmxt.s (100%)
tests/tcg/arm/Makefile new file +45 -0
new file mode 100644
index 0000000..c2ae491
@@ -0,0 +1,45 @@
+BUILD_DIR?=$(CURDIR)
+SRC_PATH=../../../
+include $(BUILD_DIR)/config-host.mak
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/arm)
+
+QEMU=$(BUILD_DIR)/arm-linux-user/qemu-arm
+
+QEMU_INCLUDES += -I$(BUILD_DIR)
+CFLAGS=-Wall -O2 -g -fno-strict-aliasing
+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
+
+TESTS=hello-arm arm-iwmmxt
+
+all: $(patsubst %,run-%,$(TESTS))
+test: all
+
+# rules to run tests
+
+run-%: %
+	$(QEMU) ./$*
+
+#.PHONY: $(patsubst %,run-%,$(TESTS))
+
+run-hello-arm: hello-arm
+run-arm-iwmmxt: arm-iwmmxt
+
+# arm test
+hello-arm: hello-arm.o
+	arm-linux-gnueabi-ld -o $@ $<
+
+hello-arm.o: hello-arm.c
+	arm-linux-gnueabi-gcc -Wall -g -O2 -c -o $@ $<
+
+arm-iwmmxt: test-arm-iwmmxt.s
+	cpp < $< | arm-linux-gnueabi-gcc -Wall -static -march=iwmmxt -mabi=aapcs -x assembler - -o $@
+
+clean:
+	rm -f *~ *.o $(TESTS)
tests/tcg/arm/hello-arm.c renamed from tests/tcg/hello-arm.c +0 -0
similarity index 100%
rename from tests/tcg/hello-arm.c
rename to tests/tcg/arm/hello-arm.c
tests/tcg/arm/test-arm-iwmmxt.s renamed from tests/tcg/test-arm-iwmmxt.s +0 -0
similarity index 100%
rename from tests/tcg/test-arm-iwmmxt.s
rename to tests/tcg/arm/test-arm-iwmmxt.s
Signature · 1 line
2.10.2
#16 lore raw

PATCH v5 11/19 tests/tcg: Move mips test to arch specific folder

In reply to Pranith Kumar
---
 tests/tcg/{ => mips}/hello-mips.c | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename tests/tcg/{ => mips}/hello-mips.c (100%)
tests/tcg/mips/hello-mips.c renamed from tests/tcg/hello-mips.c +0 -0
similarity index 100%
rename from tests/tcg/hello-mips.c
rename to tests/tcg/mips/hello-mips.c
Signature · 1 line
2.10.2
#17 lore raw

PATCH v5 12/19 tests/tcg: Add tests-tcg hook in Makefile

In reply to Pranith Kumar

You can call 'make tests-tcg' to build and run native tcg tests.

---
 tests/Makefile.include     |  1 +
 tests/tcg/Makefile.include | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 tests/tcg/Makefile.include
tests/Makefile.include +1 -0
index 2a2b78d..b046bdd 100644
@@ -836,3 +836,4 @@ all: $(QEMU_IOTESTS_HELPERS-y)
 
 -include $(wildcard tests/*.d)
 -include $(wildcard tests/libqos/*.d)
+-include $(SRC_PATH)/tests/tcg/Makefile.include
tests/tcg/Makefile.include new file +33 -0
new file mode 100644
index 0000000..3eff125
@@ -0,0 +1,33 @@
+#
+# linux-user TCG tests
+#
+# The Make is expected to be invoked in the ${BUILD_DIR} directory
+# using the tests-tcg target
+#
+BUILD_DIR?=$(CURDIR)
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+
+UNAME_M := $(shell uname -m)
+
+tests-tcg: prepare $(UNAME_M)
+
+prepare:
+	mkdir -p $(BUILD_DIR)/$(UNAME_M)-linux-user/tests/
+
+x86_64:
+	cd $(BUILD_DIR)/x86_64-linux-user/tests/ && \
+	make -f $(SRC_PATH)/tests/tcg/i386/Makefile
+
+i386:
+	cd $(BUILD_DIR)/i386-linux-user/tests/ && \
+	make -f $(SRC_PATH)/tests/tcg/i386/Makefile
+
+arm:
+	cd $(BUILD_DIR)/arm-linux-user/tests/ && \
+	make -f $(SRC_PATH)/tests/tcg/arm/Makefile
+
+aarch64:
+	cd $(BUILD_DIR)/aarch64-linux-user/tests/ && \
+	make -f $(SRC_PATH)/tests/tcg/arm/Makefile
+
+.PHONY: tests-tcg
Signature · 1 line
2.10.2
#19 lore raw

PATCH v5 13/19 tests/tcg/i386: Fix hello-i386 test

In reply to Pranith Kumar

Include a missing header and rename the function names to avoid definition mis-match.

---
 tests/tcg/hello-i386.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
tests/tcg/hello-i386.c +5 -4
index fa00380..4a46f80 100644
@@ -1,6 +1,7 @@
 #include <asm/unistd.h>
+#include <stddef.h>
 
-static inline void exit(int status)
+static inline void _exit(int status)
 {
   int __res;
   __asm__ volatile ("movl %%ecx,%%ebx\n"\
@@ -8,7 +9,7 @@ static inline void exit(int status)
 		    :  "=a" (__res) : "0" (__NR_exit),"c" ((long)(status)));
 }
 
-static inline int write(int fd, const char * buf, int len)
+static inline int _write(int fd, const char * buf, int len)
 {
   int status;
   __asm__ volatile ("pushl %%ebx\n"\
@@ -22,6 +23,6 @@ static inline int write(int fd, const char * buf, int len)
 
 void _start(void)
 {
-    write(1, "Hello World\n", 12);
-    exit(0);
+    _write(1, "Hello World\n", 12);
+    _exit(0);
 }
Signature · 1 line
2.10.2
#21 lore raw

PATCH v5 15/19 tests/tcg/i386: Fix test-i386 compilation

In reply to Pranith Kumar
---
 tests/tcg/i386/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tests/tcg/i386/Makefile +4 -4
index 15f77af..97c1a97 100644
@@ -20,13 +20,13 @@ LDFLAGS=
 # also, pi_10.com runs indefinitely
 
 I386_TESTS=hello-i386 \
-	   test-i386 \
 	   test-i386-fprem
 	   # runcom
 
 # native i386 compilers sometimes are not biarch.  assume cross-compilers are
 ifneq ($(ARCH),i386)
-I386_TESTS+=run-test-x86_64
+I386_TESTS+=test-i386 \
+	    run-test-x86_64
 endif
 
 all: $(patsubst %,run-%,$(I386_TESTS))
@@ -44,7 +44,7 @@ run-hello-i386: hello-i386
 
 run-test-i386: test-i386
 	./test-i386 > test-i386.ref
-	-$(QEMU) test-i386 > test-i386.out
+	-$(QEMU_X86_64) test-i386 > test-i386.out
 	@if cmp -s test-i386.ref test-i386.out ; then echo "Auto Test OK"; fi
 
 run-test-i386-fprem: test-i386-fprem
@@ -69,7 +69,7 @@ hello-i386: hello-i386.c
 # i386/x86_64 emulation test (test various opcodes) */
 test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \
            test-i386.h test-i386-shift.h test-i386-muldiv.h
-	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
+	$(CC) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
               $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
 
 test-i386-fprem: test-i386-fprem.c
Signature · 1 line
2.10.2
#22 lore raw

PATCH v5 16/19 tests/tcg: Fix compilation of linux-test.c

In reply to Pranith Kumar
---
 tests/tcg/linux-test.c | 2 ++
 1 file changed, 2 insertions(+)
tests/tcg/linux-test.c +2 -0
index 24fce2b..e676e39 100644
@@ -41,6 +41,8 @@
 #include <dirent.h>
 #include <setjmp.h>
 #include <sys/shm.h>
+#include <stdbool.h>
+#include <sys/resource.h>
 #include "qemu/compiler.h"
 #include "qemu/cutils.h"
 
Signature · 1 line
2.10.2
#20 lore raw

PATCH v5 14/19 tests/tcg: Move i386 tests to arch specific folder

In reply to Pranith Kumar
---
 tests/tcg/Makefile                      | 156 --------------------------------
 tests/tcg/i386/Makefile                 |  88 ++++++++++++++++++
 tests/tcg/{ => i386}/hello-i386.c       |   0
 tests/tcg/{ => i386}/pi_10.com          | Bin
 tests/tcg/{ => i386}/runcom.c           |   0
 tests/tcg/{ => i386}/test-i386-code16.S |   0
 tests/tcg/{ => i386}/test-i386-fprem.c  |   0
 tests/tcg/{ => i386}/test-i386-muldiv.h |   0
 tests/tcg/{ => i386}/test-i386-shift.h  |   0
 tests/tcg/{ => i386}/test-i386-ssse3.c  |   0
 tests/tcg/{ => i386}/test-i386-vm86.S   |   0
 tests/tcg/{ => i386}/test-i386.c        |   0
 tests/tcg/{ => i386}/test-i386.h        |   0
 13 files changed, 88 insertions(+), 156 deletions(-)
 delete mode 100644 tests/tcg/Makefile
 create mode 100644 tests/tcg/i386/Makefile
 rename tests/tcg/{ => i386}/hello-i386.c (100%)
 rename tests/tcg/{ => i386}/pi_10.com (100%)
 rename tests/tcg/{ => i386}/runcom.c (100%)
 rename tests/tcg/{ => i386}/test-i386-code16.S (100%)
 rename tests/tcg/{ => i386}/test-i386-fprem.c (100%)
 rename tests/tcg/{ => i386}/test-i386-muldiv.h (100%)
 rename tests/tcg/{ => i386}/test-i386-shift.h (100%)
 rename tests/tcg/{ => i386}/test-i386-ssse3.c (100%)
 rename tests/tcg/{ => i386}/test-i386-vm86.S (100%)
 rename tests/tcg/{ => i386}/test-i386.c (100%)
 rename tests/tcg/{ => i386}/test-i386.h (100%)
tests/tcg/Makefile deleted +0 -156
deleted file mode 100644
index d1557c2..0000000
@@ -1,156 +0,0 @@
--include ../../config-host.mak
--include $(SRC_PATH)/rules.mak
-
-$(call set-vpath, $(SRC_PATH)/tests/tcg)
-
-QEMU=../../i386-linux-user/qemu-i386
-QEMU_X86_64=../../x86_64-linux-user/qemu-x86_64
-CC_X86_64=$(CC_I386) -m64
-
-QEMU_INCLUDES += -I../..
-CFLAGS=-Wall -O2 -g -fno-strict-aliasing
-#CFLAGS+=-msse2
-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 \
-	   sha1-i386 \
-	   test-i386 \
-	   test-i386-fprem \
-	   test-mmap \
-	   # runcom
-
-# native i386 compilers sometimes are not biarch.  assume cross-compilers are
-ifneq ($(ARCH),i386)
-I386_TESTS+=run-test-x86_64
-endif
-
-TESTS = test_path
-ifneq ($(call find-in-path, $(CC_I386)),)
-TESTS += $(I386_TESTS)
-endif
-
-all: $(patsubst %,run-%,$(TESTS))
-test: all
-
-# rules to run tests
-
-.PHONY: $(patsubst %,run-%,$(TESTS))
-
-run-%: %
-	-$(QEMU) ./$*
-
-run-hello-i386: hello-i386
-run-linux-test: linux-test
-run-testthread: testthread
-run-sha1-i386: sha1-i386
-
-run-test-i386: test-i386
-	./test-i386 > test-i386.ref
-	-$(QEMU) test-i386 > test-i386.out
-	@if diff -u test-i386.ref test-i386.out ; then echo "Auto Test OK"; fi
-
-run-test-i386-fprem: test-i386-fprem
-	./test-i386-fprem > test-i386-fprem.ref
-	-$(QEMU) test-i386-fprem > test-i386-fprem.out
-	@if diff -u test-i386-fprem.ref test-i386-fprem.out ; then echo "Auto Test OK"; fi
-
-run-test-x86_64: test-x86_64
-	./test-x86_64 > test-x86_64.ref
-	-$(QEMU_X86_64) test-x86_64 > test-x86_64.out
-	@if diff -u test-x86_64.ref test-x86_64.out ; then echo "Auto Test OK"; fi
-
-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
-
-run-runcom: runcom
-	-$(QEMU) ./runcom $(SRC_PATH)/tests/pi_10.com
-
-run-test_path: test_path
-	./test_path
-
-# rules to compile tests
-
-test_path: test_path.o
-
-test_path.o: test_path.c
-
-hello-i386: hello-i386.c
-	$(CC_I386) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $<
-	strip $@
-
-testthread: testthread.c
-	$(CC_I386) $(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 \
-           test-i386.h test-i386-shift.h test-i386-muldiv.h
-	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ \
-              $(<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 $@ $^
-
-test-x86_64: test-i386.c \
-           test-i386.h test-i386-shift.h test-i386-muldiv.h
-	$(CC_X86_64) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm
-
-# generic Linux and CPU test
-linux-test: linux-test.c
-	$(CC_I386) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm
-
-# vm86 test
-runcom: runcom.c
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $<
-
-test-mmap: test-mmap.c
-	$(CC_I386) -m32 $(CFLAGS) -Wall -O2 $(LDFLAGS) -o $@ $<
-
-# speed test
-sha1-i386: sha1.c
-	$(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $<
-
-sha1: sha1.c
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
-
-speed: sha1 sha1-i386
-	time ./sha1
-	time $(QEMU) ./sha1-i386
-
-# arm test
-hello-arm: hello-arm.o
-	arm-linux-ld -o $@ $<
-
-hello-arm.o: hello-arm.c
-	arm-linux-gcc -Wall -g -O2 -c -o $@ $<
-
-test-arm-iwmmxt: test-arm-iwmmxt.s
-	cpp < $< | arm-linux-gnu-gcc -Wall -static -march=iwmmxt -mabi=aapcs -x assembler - -o $@
-
-# MIPS test
-hello-mips: hello-mips.c
-	mips-linux-gnu-gcc -nostdlib -static -mno-abicalls -fno-PIC -mabi=32 -Wall -Wextra -g -O2 -o $@ $<
-
-hello-mipsel: hello-mips.c
-	mipsel-linux-gnu-gcc -nostdlib -static -mno-abicalls -fno-PIC -mabi=32 -Wall -Wextra -g -O2 -o $@ $<
-
-# testsuite for the CRIS port.
-test-cris:
-	$(MAKE) -C cris check
-
-# testsuite for the LM32 port.
-test-lm32:
-	$(MAKE) -C lm32 check
-
-clean:
-	rm -f *~ *.o test-i386.out test-i386.ref \
-           test-x86_64.log test-x86_64.ref qruncom $(TESTS)
tests/tcg/i386/Makefile new file +88 -0

88 lines not on this page · raw message

tests/tcg/i386/hello-i386.c renamed from tests/tcg/hello-i386.c +0 -0
similarity index 100%
rename from tests/tcg/hello-i386.c
rename to tests/tcg/i386/hello-i386.c
tests/tcg/i386/pi_10.com renamed from tests/tcg/pi_10.com +0 -0
similarity index 100%
rename from tests/tcg/pi_10.com
rename to tests/tcg/i386/pi_10.com
tests/tcg/i386/runcom.c renamed from tests/tcg/runcom.c +0 -0
similarity index 100%
rename from tests/tcg/runcom.c
rename to tests/tcg/i386/runcom.c
tests/tcg/i386/test-i386-code16.S renamed from tests/tcg/test-i386-code16.S +0 -0
similarity index 100%
rename from tests/tcg/test-i386-code16.S
rename to tests/tcg/i386/test-i386-code16.S
tests/tcg/i386/test-i386-fprem.c renamed from tests/tcg/test-i386-fprem.c +0 -0
similarity index 100%
rename from tests/tcg/test-i386-fprem.c
rename to tests/tcg/i386/test-i386-fprem.c
tests/tcg/i386/test-i386-muldiv.h renamed from tests/tcg/test-i386-muldiv.h +0 -0
similarity index 100%
rename from tests/tcg/test-i386-muldiv.h
rename to tests/tcg/i386/test-i386-muldiv.h
tests/tcg/i386/test-i386-shift.h renamed from tests/tcg/test-i386-shift.h +0 -0
similarity index 100%
rename from tests/tcg/test-i386-shift.h
rename to tests/tcg/i386/test-i386-shift.h
tests/tcg/i386/test-i386-ssse3.c renamed from tests/tcg/test-i386-ssse3.c +0 -0
similarity index 100%
rename from tests/tcg/test-i386-ssse3.c
rename to tests/tcg/i386/test-i386-ssse3.c
tests/tcg/i386/test-i386-vm86.S renamed from tests/tcg/test-i386-vm86.S +0 -0
similarity index 100%
rename from tests/tcg/test-i386-vm86.S
rename to tests/tcg/i386/test-i386-vm86.S
tests/tcg/i386/test-i386.c renamed from tests/tcg/test-i386.c +0 -0
similarity index 100%
rename from tests/tcg/test-i386.c
rename to tests/tcg/i386/test-i386.c
tests/tcg/i386/test-i386.h renamed from tests/tcg/test-i386.h +0 -0
similarity index 100%
rename from tests/tcg/test-i386.h
rename to tests/tcg/i386/test-i386.h
Signature · 1 line
2.10.2
#24 lore raw

PATCH v5 17/19 tests/tcg: Move independent tests to misc dir

In reply to Pranith Kumar
---
 tests/tcg/misc/Makefile           | 81 +++++++++++++++++++++++++++++++++++++++
 tests/tcg/{ => misc}/linux-test.c |  0
 tests/tcg/{ => misc}/sha1.c       |  0
 tests/tcg/{ => misc}/test-mmap.c  |  0
 tests/tcg/{ => misc}/test_path.c  |  0
 tests/tcg/{ => misc}/testthread.c |  0
 6 files changed, 81 insertions(+)
 create mode 100644 tests/tcg/misc/Makefile
 rename tests/tcg/{ => misc}/linux-test.c (100%)
 rename tests/tcg/{ => misc}/sha1.c (100%)
 rename tests/tcg/{ => misc}/test-mmap.c (100%)
 rename tests/tcg/{ => misc}/test_path.c (100%)
 rename tests/tcg/{ => misc}/testthread.c (100%)
tests/tcg/misc/Makefile new file +81 -0
new file mode 100644
index 0000000..0aa6f2e
@@ -0,0 +1,81 @@
+# -*- Mode: makefile -*-
+#
+# Generic linux-user TCG tests
+#
+# These tests all use standard non-architecture specific APIs so can
+# be built for all TCG targets. The Make is expected to be called in
+# the ${BUILD_DIR}/$(TARGET_NAME_ARCH)-linux-user/tests directory
+#
+# To build for other architectures call make with CROSS_CC set
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/misc)
+
+QEMU=$(BUILD_DIR)/$(TARGET_NAME)-linux-user/qemu-$(TARGET_NAME)
+
+# Compiler set-up, default to system compiler if not set
+CROSS_CC?=$(CC)
+
+CFLAGS=-Wall -O2 -g -fno-strict-aliasing -static
+LDFLAGS=
+
+TESTS=linux-test \
+      testthread \
+      sha1 \
+      test-mmap
+
+all: $(patsubst %,run-%,$(TESTS))
+test: all
+
+# rules to run tests
+
+run-%: %
+	-$(QEMU) ./$*
+
+run-linux-test: linux-test
+run-testthread: testthread
+run-sha1: sha1
+run-test_path: test_path
+
+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
+
+run-test_path: test_path
+
+# rules to compile tests
+
+# These two need to be re-written as relying on glib (rather than just glibc)
+# test_path: test_path.o
+# 	$(CROSS_CC) $^ -o $@ -lglib-2.0
+
+# test_path.o: test_path.c
+# 	$(CROSS_CC) $^ -c -o $@ $(QEMU_INCLUDES) `pkg-config --cflags --libs glib-2.0`
+
+testthread: testthread.c
+	$(CROSS_CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpthread
+
+# generic Linux and CPU test
+linux-test: linux-test.c
+	$(CROSS_CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm
+
+test-mmap: test-mmap.c
+	$(CROSS_CC) $(CFLAGS) -Wall -O2 $(LDFLAGS) -o $@ $< -static
+
+# speed test
+sha1: sha1.c
+	$(CROSS_CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
+
+speed: sha1
+	time ./sha1
+	time $(QEMU) ./sha1
+
+clean:
+	rm -f *~ *.o $(TESTS)
tests/tcg/misc/linux-test.c renamed from tests/tcg/linux-test.c +0 -0
similarity index 100%
rename from tests/tcg/linux-test.c
rename to tests/tcg/misc/linux-test.c
tests/tcg/misc/sha1.c renamed from tests/tcg/sha1.c +0 -0
similarity index 100%
rename from tests/tcg/sha1.c
rename to tests/tcg/misc/sha1.c
tests/tcg/misc/test-mmap.c renamed from tests/tcg/test-mmap.c +0 -0
similarity index 100%
rename from tests/tcg/test-mmap.c
rename to tests/tcg/misc/test-mmap.c
tests/tcg/misc/test_path.c renamed from tests/tcg/test_path.c +0 -0
similarity index 100%
rename from tests/tcg/test_path.c
rename to tests/tcg/misc/test_path.c
tests/tcg/misc/testthread.c renamed from tests/tcg/testthread.c +0 -0
similarity index 100%
rename from tests/tcg/testthread.c
rename to tests/tcg/misc/testthread.c
Signature · 1 line
2.10.2
#26 lore raw

PATCH v5 18/19 tests/tcg: Add and update Makefiles

In reply to Pranith Kumar

This commit fixes the makefiles to bring them to the desired state.

---
 tests/tcg/alpha/Makefile             | 38 +++++++++++++++++++----------
 tests/tcg/arm/Makefile               | 32 +++++++++++++++----------
 tests/tcg/cris/Makefile              | 17 +++++++++++--
 tests/tcg/i386/Makefile              | 23 +++++++++---------
 tests/tcg/lm32/Makefile              | 17 +++++++++++--
 tests/tcg/mips/Makefile              | 46 ++++++++++++++++++++++++++++++++++++
 tests/tcg/mips/mips32-dsp/Makefile   | 17 +++++++++++--
 tests/tcg/mips/mips32-dspr2/Makefile | 17 +++++++++++--
 tests/tcg/mips/mips64-dsp/Makefile   | 18 ++++++++++++--
 tests/tcg/mips/mips64-dspr2/Makefile | 17 ++++++++++++-
 tests/tcg/openrisc/Makefile          | 19 ++++++++++++---
 tests/tcg/xtensa/Makefile            | 17 +++++++++++--
 12 files changed, 225 insertions(+), 53 deletions(-)
 create mode 100644 tests/tcg/mips/Makefile
tests/tcg/alpha/Makefile +26 -12
index 2b1f03d..e20315f 100644
@@ -1,33 +1,47 @@
-CROSS=alpha-linux-gnu-
-CC=$(CROSS)gcc
-AS=$(CROSS)as
+# -*- Mode: makefile -*-
+#
+# Alpha linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/alpha-linux-user/tests directory
+#
 
-SIM=../../alpha-linux-user/qemu-alpha
+BUILD_DIR?=$(CURDIR)
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
 
-CFLAGS=-O
-LINK=$(CC) -o $@ crt.o $< -nostdlib
+$(call set-vpath, $(SRC_PATH)/tests/tcg/alpha)
+
+QEMU=$(BUILD_DIR)/alpha-linux-user/qemu-alpha
+
+# Compiler set-up, default to system compiler if not set
+CROSS_CC?=$(CC)
+
+CFLAGS=-Wall -O2 -g -fno-strict-aliasing -static
+LDFLAGS=-nostdlib
 
 TESTS=test-cond test-cmov
 
 all: hello-alpha $(TESTS)
 
 hello-alpha: hello-alpha.o crt.o
-	$(LINK)
+	$(CROSS_CC) -o $@ crt.o $< $(LDFLAGS)
 
 test-cond: test-cond.o crt.o
-	$(LINK)
+	$(CROSS_CC) -o $@ crt.o $< $(LDFLAGS)
 
 test-cmov.o: test-cond.c
-	$(CC) -c $(CFLAGS) -DTEST_CMOV -o $@ $<
+	$(CROSS_CC) -c $(CFLAGS) -DTEST_CMOV -o $@ $<
 
 test-cmov: test-cmov.o crt.o
-	$(LINK)
+	$(CROSS_CC) -o $@ crt.o $< $(LDFLAGS)
 
 test-ovf: test-ovf.o crt.o
-	$(LINK)
+	$(CROSS_CC) -o $@ crt.o $< $(LDFLAGS)
 
 check: $(TESTS)
-	for f in $(TESTS); do $(SIM) $$f || exit 1; done
+	for f in $(TESTS); do $(QEMU) $$f || exit 1; done
 
 clean:
 	$(RM) *.o *~ hello-alpha $(TESTS)
tests/tcg/arm/Makefile +19 -13
index c2ae491..a7c8953 100644
@@ -1,20 +1,26 @@
-BUILD_DIR?=$(CURDIR)
-SRC_PATH=../../../
-include $(BUILD_DIR)/config-host.mak
+# -*- Mode: makefile -*-
+#
+# Arm linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/arm-linux-user/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
 include $(SRC_PATH)/rules.mak
 
 $(call set-vpath, $(SRC_PATH)/tests/tcg/arm)
 
 QEMU=$(BUILD_DIR)/arm-linux-user/qemu-arm
 
-QEMU_INCLUDES += -I$(BUILD_DIR)
-CFLAGS=-Wall -O2 -g -fno-strict-aliasing
-LDFLAGS=
-
-# TODO: automatically detect ARM and MIPS compilers, and run those too
+# Compiler set-up, default to system compiler if not set
+CROSS_CC?=$(CC)
 
-# runcom maps page 0, so it requires root privileges
-# also, pi_10.com runs indefinitely
+QEMU_INCLUDES += -I$(BUILD_DIR)
+CFLAGS=-Wall -O2 -g -fno-strict-aliasing -nostdlib
+LDFLAGS=-nostdlib
 
 TESTS=hello-arm arm-iwmmxt
 
@@ -33,13 +39,13 @@ run-arm-iwmmxt: arm-iwmmxt
 
 # arm test
 hello-arm: hello-arm.o
-	arm-linux-gnueabi-ld -o $@ $<
+	$(CROSS_CC) $(LDFLAGS) -o $@ $<
 
 hello-arm.o: hello-arm.c
-	arm-linux-gnueabi-gcc -Wall -g -O2 -c -o $@ $<
+	$(CROSS_CC) $(CFLAGS) -c -o $@ $<
 
 arm-iwmmxt: test-arm-iwmmxt.s
-	cpp < $< | arm-linux-gnueabi-gcc -Wall -static -march=iwmmxt -mabi=aapcs -x assembler - -o $@
+	cpp < $< | $(CROSS_CC) -Wall -static -march=iwmmxt -mabi=aapcs -x assembler - -o $@
 
 clean:
 	rm -f *~ *.o $(TESTS)
tests/tcg/cris/Makefile +15 -2
index 6b3dba4..009c3f4 100644
@@ -1,7 +1,20 @@
--include ../../../config-host.mak
+# -*- Mode: makefile -*-
+#
+# Cris linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/cris-linux-user/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/arm)
 
 CROSS=crisv32-axis-linux-gnu-
-SIM=../../../cris-linux-user/qemu-cris -L ./
+SIM=$(BUILD_DIR)/cris-linux-user/qemu-cris -L ./
 SIMG=cris-axis-linux-gnu-run --sysroot=./
 
 CC      = $(CROSS)gcc
tests/tcg/i386/Makefile +11 -12
index 97c1a97..55a45ad 100644
@@ -1,6 +1,14 @@
-BUILD_DIR=../../../build/
-SRC_PATH=../../../
-include $(BUILD_DIR)/config-host.mak
+# -*- Mode: makefile -*-
+#
+# i386 linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/i386-linux-user/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
 include $(SRC_PATH)/rules.mak
 
 $(call set-vpath, $(SRC_PATH)/tests/tcg/i386)
@@ -14,14 +22,8 @@ CFLAGS=-Wall -O2 -g -fno-strict-aliasing
 #CFLAGS+=-msse2
 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 \
 	   test-i386-fprem
-	   # runcom
 
 # native i386 compilers sometimes are not biarch.  assume cross-compilers are
 ifneq ($(ARCH),i386)
@@ -57,9 +59,6 @@ run-test-x86_64: test-x86_64
 	-$(QEMU_X86_64) test-x86_64 > test-x86_64.out
 	@if diff -u test-x86_64.ref test-x86_64.out ; then echo "Auto Test OK"; fi
 
-run-runcom: runcom
-	-$(QEMU) ./runcom $(SRC_PATH)/tests/pi_10.com
-
 # rules to compile tests
 
 hello-i386: hello-i386.c
tests/tcg/lm32/Makefile +15 -2
index 57e7363..ad5d9a7 100644
@@ -1,8 +1,21 @@
--include ../../../config-host.mak
+# -*- Mode: makefile -*-
+#
+# lm32 linux-system TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/lm32-softmmu/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/lm32)
 
 CROSS=lm32-elf-
 
-SIM = qemu-system-lm32
+QEMU=$(BUILD_DIR)/lm32-softmmu/qemu-system-lm32
 SIMFLAGS = -M lm32-evr -nographic -semihosting -net none -kernel
 
 CC      = $(CROSS)gcc
tests/tcg/mips/Makefile new file +46 -0

46 lines not on this page · raw message

tests/tcg/mips/mips32-dsp/Makefile +15 -2
index c3a0a00..996b9a0 100644
@@ -1,8 +1,21 @@
--include ../../config-host.mak
+# -*- Mode: makefile -*-
+#
+# mipsel linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/mipsel-linux-user/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/mips/mips32-dsp)
 
 CROSS=mips64el-unknown-linux-gnu-
 
-SIM=qemu-mipsel
+SIM=$(BUILD_DIR)/mipsel-linux-user/qemu-mipsel
 SIM_FLAGS=-cpu 74Kf
 
 CC      = $(CROSS)gcc
tests/tcg/mips/mips32-dspr2/Makefile +15 -2
index ed19581..e99f2bc 100644
@@ -1,8 +1,21 @@
--include ../../config-host.mak
+# -*- Mode: makefile -*-
+#
+# mipsel linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/mipsel-linux-user/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/mips/mips32-dsp)
 
 CROSS=mips64el-unknown-linux-gnu-
 
-SIM=qemu-mipsel
+SIM=$(BUILD_DIR)/mipsel-linux-user/qemu-mipsel
 SIM_FLAGS=-cpu 74Kf
 
 CC      = $(CROSS)gcc
tests/tcg/mips/mips64-dsp/Makefile +16 -2
index b2ac6b3..4ee3bbb 100644
@@ -1,7 +1,21 @@
+# -*- Mode: makefile -*-
+#
+# mips64el linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/mips64el-linux-user/tests directory
+#
 
-CROSS_COMPILE	?= mips64el-unknown-linux-gnu-
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
 
-SIM = qemu-system-mips64el
+$(call set-vpath, $(SRC_PATH)/tests/tcg/mips/mips64-dsp)
+
+CROSS=mips64el-unknown-linux-gnu-
+
+SIM=$(BUILD_DIR)/mipsel-linux-user/qemu-mips64el
 SIMFLAGS = -nographic -cpu mips64dspr2 -kernel
 
 AS      = $(CROSS_COMPILE)as
tests/tcg/mips/mips64-dspr2/Makefile +16 -1
index ba44bb9..8510d8c 100644
@@ -1,6 +1,21 @@
+# -*- Mode: makefile -*-
+#
+# mips64el linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/mips64el-linux-user/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/mips/mips64-dsp)
+
 CROSS_COMPILE	?= mips64el-unknown-linux-gnu-
 
-SIM = qemu-system-mips64el
+SIM=$(BUILD_DIR)/mipsel-linux-user/qemu-mips64el
 SIMFLAGS = -nographic -cpu mips64dspr2 -kernel
 
 AS      = $(CROSS_COMPILE)as
tests/tcg/openrisc/Makefile +16 -3
index 7e65888..071aaab 100644
@@ -1,8 +1,21 @@
--include ../../config-host.mak
+# -*- Mode: makefile -*-
+#
+# openrisc linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/or32-linux-user/tests directory
+#
 
-CROSS = or32-linux-
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/openrisc)
 
-SIM = qemu-or32
+SIM=$(BUILD_DIR)/or32-linux-user/qemu-mips
+
+CROSS = or32-linux-
 
 CC = $(CROSS)gcc
 
tests/tcg/xtensa/Makefile +15 -2
index 522a63e..e3269ed 100644
@@ -1,10 +1,23 @@
--include ../../../config-host.mak
+# -*- Mode: makefile -*-
+#
+# xtensa linux TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/xtensa-softmmu/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/xtensa)
 
 CORE=dc232b
 CROSS=xtensa-$(CORE)-elf-
 
 ifndef XT
-SIM = ../../../xtensa-softmmu/qemu-system-xtensa
+SIM = $(BUILD_DIR)/xtensa-softmmu/qemu-system-xtensa
 SIMFLAGS = -M sim -cpu $(CORE) -nographic -semihosting $(EXTFLAGS) -kernel
 SIMDEBUG = -s -S
 else
Signature · 1 line
2.10.2
#28 lore raw

PATCH v5 19/19 tests/tcg: test-i386.c: Fix format warnings

In reply to Pranith Kumar
---
 tests/tcg/i386/test-i386.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/tcg/i386/test-i386.c +1 -1
index b0f8975..6a11c2f 100644
@@ -2258,7 +2258,7 @@ SSE_OP(a ## sd);
         "pop %0\n"\
         : "=rm" (eflags)\
         : "x" (a.dq), "x" (b.dq));\
-    printf("%-9s: a=%f b=%f cc=%04x\n",\
+    printf("%-9s: a=%f b=%f cc=%04lx\n",\
            #op, a1, b1,\
            eflags & (CC_C | CC_P | CC_Z | CC_S | CC_O | CC_A));\
 }
Signature · 1 line
2.10.2
#29 lore raw
In reply to Pranith Kumar
Quoted 6 lines · Pranith Kumar

Hello,

This patch series cleans up the tcg tests in tests/tcg folder.

 linux-user/mmap.c                       |  27 +++---
 linux-user/syscall.c                    |   2 +-

These aren't test code -- it would probably be better not to mix actual bug fixes up in a series that's mostly trying to fix up test code.

I'd still like to see what the plan is for having this actually work given that you don't know whether there's a cross-toolchain available. That's the fundamental reason why these tests have been left to bitrot.

thanks
-- PMM

#30 lore raw
Quoted 11 lines · Peter Maydell
Quoted 6 lines · Pranith Kumar

Hello,

This patch series cleans up the tcg tests in tests/tcg folder.

 linux-user/mmap.c                       |  27 +++---
 linux-user/syscall.c                    |   2 +-

These aren't test code -- it would probably be better not to mix actual bug fixes up in a series that's mostly trying to fix up test code.

OK, I will send these in a separate series.

Quoted 5 lines

I'd still like to see what the plan is for having this actually work given that you don't know whether there's a cross-toolchain available. That's the fundamental reason why these tests have been left to bitrot.

The current idea is to call these tests explicitly with the cross compiler passed as an argument. We can, at the very least, download the cross compilers and enable the tests in travis.

Thanks,

Signature · 1 line
Pranith
Reviewed-by on v5 1/19
#2 lore raw

Re: [Qemu-devel] [PATCH 01/19] linux-user: fix settime old value location

In reply to Pranith Kumar
Quoted 6 lines · Pranith Kumar

From: Marc-André Lureau <[email protected]>

old_value is the 4th argument of timer_settime(), not the 2nd.

but this should really be sent in another series.

Quoted 9 lines
---
 linux-user/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/syscall.c +0 -0
index 7b77503..5bd477a 100644

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 12033

Quoted 8 lines
linux-user/syscall.c +1 -1
@@ -12027,7 +12027,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             target_to_host_itimerspec(&hspec_new, arg3);
             ret = get_errno(
                           timer_settime(htimer, arg2, &hspec_new, &hspec_old));
-            host_to_target_itimerspec(arg2, &hspec_old);
+            host_to_target_itimerspec(arg4, &hspec_old);
         }
         break;
     }

--
Alex Bennée

Reviewed-by on v5 2/19
#5 lore raw

Re: [Qemu-devel] [PATCH 02/19] linux-user: fix tcg/mmap test

In reply to Pranith Kumar
Quoted 9 lines · Pranith Kumar

From: Marc-André Lureau <[email protected]>

tests/tcg/mmap test fails with values other than default target page size. When creating a map beyond EOF, extra anonymous pages are added up to the target page boundary. Currently, this operation is performed only when qemu_real_host_page_size < TARGET_PAGE_SIZE, but it should be performed if the configured page size (qemu -p) is larger than qemu_real_host_page_size too.

Quoted 4 lines

(also fixes some style issues to please checkpatch)

but again doesn't really need to be in this series

Quoted 44 lines
---
 linux-user/mmap.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
linux-user/mmap.c +8 -12
index 61685bf..0794a43 100644
@@ -418,31 +418,32 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
     }
 
     /* When mapping files into a memory area larger than the file, accesses
-       to pages beyond the file size will cause a SIGBUS.
+       to pages beyond the file size will cause a SIGBUS.
 
        For example, if mmaping a file of 100 bytes on a host with 4K pages
        emulating a target with 8K pages, the target expects to be able to
        access the first 8K. But the host will trap us on any access beyond
-       4K.
+       4K.
 
        When emulating a target with a larger page-size than the hosts, we
        may need to truncate file maps at EOF and add extra anonymous pages
        up to the targets page boundary.  */
 
-    if ((qemu_real_host_page_size < TARGET_PAGE_SIZE)
-        && !(flags & MAP_ANONYMOUS)) {
-       struct stat sb;
+    if ((qemu_real_host_page_size < qemu_host_page_size) &&
+        !(flags & MAP_ANONYMOUS)) {
+        struct stat sb;
 
-       if (fstat (fd, &sb) == -1)
-           goto fail;
+        if (fstat(fd, &sb) == -1) {
+            goto fail;
+        }
 
        /* Are we trying to create a map beyond EOF?.  */
-       if (offset + len > sb.st_size) {
-           /* If so, truncate the file map at eof aligned with
-              the hosts real pagesize. Additional anonymous maps
-              will be created beyond EOF.  */
-           len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset);

linux-user/mmap.c abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, · line 449

Quoted 10 lines
linux-user/mmap.c +6 -1
-       }
+        if (offset + len > sb.st_size) {
+            /* If so, truncate the file map at eof aligned with
+               the hosts real pagesize. Additional anonymous maps
+               will be created beyond EOF.  */
+            len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset);
+        }
     }
 
     if (!(flags & MAP_FIXED)) {

--
Alex Bennée

Reviewed-by on v5 3/19
#8 lore raw

Re: [Qemu-devel] [PATCH 03/19] check-help: add some hint to run a single test

In reply to Pranith Kumar
Quoted 8 lines · Pranith Kumar

From: Marc-André Lureau <[email protected]>

It's possible to run the test directly, tests/test-foo, but then recompilation is not triggered and test environment variables aren't set for you.

Quoted 9 lines
---
 tests/Makefile.include | 1 +
 1 file changed, 1 insertion(+)
tests/Makefile.include +0 -0
index e98d3b6..2a2b78d 100644

tests/Makefile.include check-help: · line 737

Quoted 7 lines
tests/Makefile.include +1 -0
@@ -731,6 +731,7 @@ check-help:
 	@echo " make check-qtest-TARGET   Run qtest tests for given target"
 	@echo " make check-qtest          Run qtest tests"
 	@echo " make check-unit           Run qobject tests"
+	@echo " make check-tests/test-foo Run the tests/test-foo unit test only"
 	@echo " make check-qapi-schema    Run QAPI schema tests"
 	@echo " make check-block          Run block tests"
 	@echo " make check-report.html    Generates an HTML test report"

--
Alex Bennée

#10 lore raw

Re: [Qemu-devel] [PATCH 04/19] tests/tcg: comment unused code

In reply to Pranith Kumar
Quoted 4 lines · Pranith Kumar

From: Marc-André Lureau <[email protected]>

I didn't remove it, as suggest by checkpatch, because it looks like it may eventually be restored back.

I'm not so sure, especially with having full source control. Either fix it or delete it please.

Quoted 69 lines
---
 tests/tcg/linux-test.c      | 8 ++++++--
 tests/tcg/test-i386-fprem.c | 4 ++++
 2 files changed, 10 insertions(+), 2 deletions(-)
tests/tcg/linux-test.c +6 -2
index 5070d31..38d163c 100644
@@ -350,6 +350,7 @@ void test_socket(void)
 
 #define WCOUNT_MAX 512
 
+#if 0
 void test_pipe(void)
 {
     fd_set rfds, wfds;
@@ -421,11 +422,13 @@ void test_clone(void)
 
     stack1 = malloc(STACK_SIZE);
     pid1 = chk_error(clone(thread1_func, stack1 + STACK_SIZE,
-                           CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello1"));
+                           CLONE_VM | CLONE_FS | CLONE_FILES |
+                           SIGCHLD, (void *)"hello1"));
 
     stack2 = malloc(STACK_SIZE);
     pid2 = chk_error(clone(thread2_func, stack2 + STACK_SIZE,
-                           CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello2"));
+                           CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD,
+                           (void *)"hello2"));
 
     while (waitpid(pid1, &status1, 0) != pid1);
     free(stack1);
@@ -435,6 +438,7 @@ void test_clone(void)
         thread2_res != 6)
         error("clone");
 }
+#endif
 
 /***********************************/
 
tests/tcg/test-i386-fprem.c +3 -0
index 1a71623..1a2b144 100644
@@ -54,6 +54,7 @@ union float80u {
 
 #define IEEE854_LONG_DOUBLE_BIAS 0x3fff
 
+#if 0
 static const union float80u q_nan = {
     .ieee_nan.negative = 0,  /* X */
     .ieee_nan.exponent = 0x7fff,
@@ -61,6 +62,7 @@ static const union float80u q_nan = {
     .ieee_nan.quiet_nan = 1,
     .ieee_nan.mantissa = 0,
 };
+#endif
 
 static const union float80u s_nan = {
     .ieee_nan.negative = 0,  /* X */
@@ -91,12 +93,14 @@ static const union float80u pos_denorm = {
     .ieee.mantissa = 1,
 };
 
+#if 0

tests/tcg/test-i386-fprem.c static const union float80u pos_denorm = { · line 106

Quoted 10 lines
tests/tcg/test-i386-fprem.c +1 -0
 static const union float80u smallest_positive_norm = {
     .ieee.negative = 0,
     .ieee.exponent = 1,
     .ieee.one = 1,
     .ieee.mantissa = 0,
 };
+#endif
 
 static void fninit()
 {

--
Alex Bennée

#3 lore raw

Re: [Qemu-devel] [PATCH 01/19] linux-user: fix settime old value location

In reply to Pranith Kumar
Quoted 16 lines · Pranith Kumar

From: Marc-André Lureau <[email protected]>

old_value is the 4th argument of timer_settime(), not the 2nd.

---
 linux-user/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/syscall.c +0 -0
index 7b77503..5bd477a 100644

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 12033

Quoted 8 lines
linux-user/syscall.c +1 -1
@@ -12027,7 +12027,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             target_to_host_itimerspec(&hspec_new, arg3);
             ret = get_errno(
                           timer_settime(htimer, arg2, &hspec_new, &hspec_old));
-            host_to_target_itimerspec(arg2, &hspec_old);
+            host_to_target_itimerspec(arg4, &hspec_old);
         }
         break;
     }

arg4 can be NULL.

You should check for the return value like in timerfd_settime.

In the kernel we have:

	if (old_setting && !error &&
	    copy_to_user(old_setting, &old_spec, sizeof (old_spec)))
		error = -EFAULT;

Laurent

Reviewed-by on v5 2/19
#6 lore raw

Re: [Qemu-devel] [PATCH 02/19] linux-user: fix tcg/mmap test

In reply to Pranith Kumar
Quoted 23 lines · Pranith Kumar

From: Marc-André Lureau <[email protected]>

tests/tcg/mmap test fails with values other than default target page size. When creating a map beyond EOF, extra anonymous pages are added up to the target page boundary. Currently, this operation is performed only when qemu_real_host_page_size < TARGET_PAGE_SIZE, but it should be performed if the configured page size (qemu -p) is larger than qemu_real_host_page_size too.

(also fixes some style issues to please checkpatch)

---
 linux-user/mmap.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
linux-user/mmap.c +0 -0
index 61685bf..0794a43 100644
@@ -418,31 +418,32 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
     }

linux-user/mmap.c abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, · line 426

Quoted 10 lines
linux-user/mmap.c +2 -2
 
     /* When mapping files into a memory area larger than the file, accesses
-       to pages beyond the file size will cause a SIGBUS. 
+       to pages beyond the file size will cause a SIGBUS.
 
        For example, if mmaping a file of 100 bytes on a host with 4K pages
        emulating a target with 8K pages, the target expects to be able to
        access the first 8K. But the host will trap us on any access beyond
-       4K.  
+       4K.

You should not mix coding style update and fix: this hides what it is done in the patch: one word change. I think checkpatch only requires changes around the fix.

linux-user/mmap.c abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, · line 432

Quoted 8 lines
linux-user/mmap.c +1 -3
        When emulating a target with a larger page-size than the hosts, we
        may need to truncate file maps at EOF and add extra anonymous pages
        up to the targets page boundary.  */
 
-    if ((qemu_real_host_page_size < TARGET_PAGE_SIZE)
-        && !(flags & MAP_ANONYMOUS)) {
-       struct stat sb;
+    if ((qemu_real_host_page_size < qemu_host_page_size) &&

So it appears to be the fix :)

Thanks,
Laurent

#31 lore raw
In reply to Pranith Kumar
Quoted 11 lines · Pranith Kumar

Hello,

This patch series cleans up the tcg tests in tests/tcg folder.

The tests have bit-rotten and were not compiling or running. I fixed the Makefiles to make them compile though there are tests which do not pass.

The motivation is to add litmus tests to each arch and have them run using the 'make check' target to test consistency on TCG.

Quoted 8 lines

There are no maintainers listed for this test folder. So I am cc'ing people who I think might be interested.

The tests are hooked to the 'tests-tcg' target. Alternatively, as suggested by Alex Bennee you can run a tcg tests for a particular arch from the build/<arch>-linux-user/tests directory as follows:

$ CROSS_CC=<cross-compiler> make -f ../../tests/tcg/<arch>/Makefile

So admittedly this isn't using a cross compiler rather than a linux-user powered docker image but I first of all had to:

mkdir arm-linux-user/tests

And then running:

  docker run --rm -it -v /home/alex/lsrc/qemu/qemu.git/:/src --user=alex:alex -w /src/arm-linux-user/tests debian:armhf make -f ../../tests/tcg/arm/Makefile

yielded:

../../tests/tcg/arm/Makefile:12: /home/alex/lsrc/qemu/qemu.git/rules.mak: No such file or directory
make: *** No rule to make target '/home/alex/lsrc/qemu/qemu.git/rules.mak'. Stop.

Which I guess is a relative vs absolute problem. I wonder if there is a way to make it cleaner in the event of these re-locations?

BTW running:

  docker run --rm -it -v /home/alex/lsrc/qemu/qemu.git/:/home/alex/lsrc/qemu/qemu.git/ --user=alex:alex -w /home/alex/lsrc/qemu/qemu.git/arm-linux-user/tests debian:armhf make -f ../../tests/tcg/arm/Makefile

Gives:

cc -Wall -O2 -g -fno-strict-aliasing -nostdlib -c -o hello-arm.o /home/alex/lsrc/qemu/qemu.git/tests/tcg/arm/hello-arm.c
/tmp/ccaztzVL.s: Assembler messages:
/tmp/ccaztzVL.s:41: Error: invalid swi expression
/tmp/ccaztzVL.s:41: Error: value of 9437185 too large for field of 2 bytes at 6
/tmp/ccaztzVL.s:77: Error: invalid swi expression
/tmp/ccaztzVL.s:77: Error: value of 9437188 too large for field of 2 bytes at 30
/tmp/ccaztzVL.s:122: Error: invalid swi expression
/tmp/ccaztzVL.s:122: Error: value of 9437188 too large for field of 2 bytes at 60
/tmp/ccaztzVL.s:136: Error: invalid swi expression
/tmp/ccaztzVL.s:136: Error: value of 9437185 too large for field of 2 bytes at 68 ../../tests/tcg/arm/Makefile:45: recipe for target 'hello-arm.o' failed
make: *** [hello-arm.o] Error 1

Quoted 83 lines

Thanks,
--
Pranith

Marc-André Lureau (9):
linux-user: fix settime old value location
linux-user: fix tcg/mmap test
check-help: add some hint to run a single test tests/tcg: comment unused code
tests/tcg: declare some functions as static
linux-test: fix build
linux-test: fix set/getitimer returned timer check Fix test-i386-fprem compilation
test-i386: modernize vector code v4sf

Pranith Kumar (10):
tests/tcg: Move arm tests to arch specific folder tests/tcg: Move mips test to arch specific folder tests/tcg: Add tests-tcg hook in Makefile tests/tcg/i386: Fix hello-i386 test
tests/tcg: Move i386 tests to arch specific folder tests/tcg/i386: Fix test-i386 compilation tests/tcg: Fix compilation of linux-test.c tests/tcg: Move arch independent tests to misc directory tests/tcg: Add and update Makefiles
tests/tcg: test-i386.c: Fix format warnings

 linux-user/mmap.c                       |  27 +++---
 linux-user/syscall.c                    |   2 +-
 tests/Makefile.include                  |   2 +
 tests/tcg/Makefile                      | 156 --------------------------------
 tests/tcg/Makefile.include              |  33 +++++++
 tests/tcg/alpha/Makefile                |  38 +++++---
 tests/tcg/arm/Makefile                  |  51 +++++++++++
 tests/tcg/{ => arm}/hello-arm.c         |   0
 tests/tcg/{ => arm}/test-arm-iwmmxt.s   |   0
 tests/tcg/cris/Makefile                 |  17 +++-
 tests/tcg/i386/Makefile                 |  87 ++++++++++++++++++
 tests/tcg/{ => i386}/hello-i386.c       |   9 +-
 tests/tcg/{ => i386}/pi_10.com          | Bin
 tests/tcg/{ => i386}/runcom.c           |   0
 tests/tcg/{ => i386}/test-i386-code16.S |   0
 tests/tcg/{ => i386}/test-i386-fprem.c  |  10 +-
 tests/tcg/{ => i386}/test-i386-muldiv.h |   0
 tests/tcg/{ => i386}/test-i386-shift.h  |   0
 tests/tcg/{ => i386}/test-i386-ssse3.c  |   0
 tests/tcg/{ => i386}/test-i386-vm86.S   |   0
 tests/tcg/{ => i386}/test-i386.c        |   7 +-
 tests/tcg/{ => i386}/test-i386.h        |   0
 tests/tcg/lm32/Makefile                 |  17 +++-
 tests/tcg/mips/Makefile                 |  46 ++++++++++
 tests/tcg/{ => mips}/hello-mips.c       |   0
 tests/tcg/mips/mips32-dsp/Makefile      |  17 +++-
 tests/tcg/mips/mips32-dspr2/Makefile    |  17 +++-
 tests/tcg/mips/mips64-dsp/Makefile      |  18 +++-
 tests/tcg/mips/mips64-dspr2/Makefile    |  17 +++-
 tests/tcg/misc/Makefile                 |  81 +++++++++++++++++
 tests/tcg/{ => misc}/linux-test.c       |  57 +++++++-----
 tests/tcg/{ => misc}/sha1.c             |   0
 tests/tcg/{ => misc}/test-mmap.c        |   2 +-
 tests/tcg/{ => misc}/test_path.c        |   0
 tests/tcg/{ => misc}/testthread.c       |   0
 tests/tcg/openrisc/Makefile             |  19 +++-
 tests/tcg/xtensa/Makefile               |  17 +++-
 37 files changed, 518 insertions(+), 229 deletions(-)
 delete mode 100644 tests/tcg/Makefile
 create mode 100644 tests/tcg/Makefile.include
 create mode 100644 tests/tcg/arm/Makefile
 rename tests/tcg/{ => arm}/hello-arm.c (100%)
 rename tests/tcg/{ => arm}/test-arm-iwmmxt.s (100%)
 create mode 100644 tests/tcg/i386/Makefile
 rename tests/tcg/{ => i386}/hello-i386.c (72%)
 rename tests/tcg/{ => i386}/pi_10.com (100%)
 rename tests/tcg/{ => i386}/runcom.c (100%)
 rename tests/tcg/{ => i386}/test-i386-code16.S (100%)
 rename tests/tcg/{ => i386}/test-i386-fprem.c (98%)
 rename tests/tcg/{ => i386}/test-i386-muldiv.h (100%)
 rename tests/tcg/{ => i386}/test-i386-shift.h (100%)
 rename tests/tcg/{ => i386}/test-i386-ssse3.c (100%)
 rename tests/tcg/{ => i386}/test-i386-vm86.S (100%)
 rename tests/tcg/{ => i386}/test-i386.c (99%)
 rename tests/tcg/{ => i386}/test-i386.h (100%)
Quoted 8 lines
 create mode 100644 tests/tcg/mips/Makefile
 rename tests/tcg/{ => mips}/hello-mips.c (100%)
 create mode 100644 tests/tcg/misc/Makefile
 rename tests/tcg/{ => misc}/linux-test.c (90%)
 rename tests/tcg/{ => misc}/sha1.c (100%)
 rename tests/tcg/{ => misc}/test-mmap.c (99%)
 rename tests/tcg/{ => misc}/test_path.c (100%)
 rename tests/tcg/{ => misc}/testthread.c (100%)

--
Alex Bennée

#23 lore raw

Re: [Qemu-devel] [PATCH 16/19] tests/tcg: Fix compilation of linux-test.c

In reply to Pranith Kumar
Quoted 10 lines · Pranith Kumar
---
 tests/tcg/linux-test.c | 2 ++
 1 file changed, 2 insertions(+)
tests/tcg/linux-test.c +0 -0
index 24fce2b..e676e39 100644

tests/tcg/linux-test.c line 47

Quoted 7 lines
tests/tcg/linux-test.c +2 -0
@@ -41,6 +41,8 @@
 #include <dirent.h>
 #include <setjmp.h>
 #include <sys/shm.h>
+#include <stdbool.h>
+#include <sys/resource.h>
 #include "qemu/compiler.h"
 #include "qemu/cutils.h"

Should this be merged with patch 6/19?

--
Alex Bennée

#25 lore raw

Re: [Qemu-devel] [PATCH 17/19] tests/tcg: Move independent tests to misc dir

In reply to Pranith Kumar
Quoted 79 lines · Pranith Kumar
---
 tests/tcg/misc/Makefile           | 81 +++++++++++++++++++++++++++++++++++++++
 tests/tcg/{ => misc}/linux-test.c |  0
 tests/tcg/{ => misc}/sha1.c       |  0
 tests/tcg/{ => misc}/test-mmap.c  |  0
 tests/tcg/{ => misc}/test_path.c  |  0
 tests/tcg/{ => misc}/testthread.c |  0
 6 files changed, 81 insertions(+)
 create mode 100644 tests/tcg/misc/Makefile
 rename tests/tcg/{ => misc}/linux-test.c (100%)
 rename tests/tcg/{ => misc}/sha1.c (100%)
 rename tests/tcg/{ => misc}/test-mmap.c (100%)
 rename tests/tcg/{ => misc}/test_path.c (100%)
 rename tests/tcg/{ => misc}/testthread.c (100%)
tests/tcg/misc/Makefile new file +57 -0
new file mode 100644
index 0000000..0aa6f2e
@@ -0,0 +1,81 @@
+# -*- Mode: makefile -*-
+#
+# Generic linux-user TCG tests
+#
+# These tests all use standard non-architecture specific APIs so can
+# be built for all TCG targets. The Make is expected to be called in
+# the ${BUILD_DIR}/$(TARGET_NAME_ARCH)-linux-user/tests directory
+#
+# To build for other architectures call make with CROSS_CC set
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/misc)
+
+QEMU=$(BUILD_DIR)/$(TARGET_NAME)-linux-user/qemu-$(TARGET_NAME)
+
+# Compiler set-up, default to system compiler if not set
+CROSS_CC?=$(CC)
+
+CFLAGS=-Wall -O2 -g -fno-strict-aliasing -static
+LDFLAGS=
+
+TESTS=linux-test \
+      testthread \
+      sha1 \
+      test-mmap
+
+all: $(patsubst %,run-%,$(TESTS))
+test: all
+
+# rules to run tests
+
+run-%: %
+	-$(QEMU) ./$*
+
+run-linux-test: linux-test
+run-testthread: testthread
+run-sha1: sha1
+run-test_path: test_path
+
+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
+
+run-test_path: test_path
+
+# rules to compile tests
+
+# These two need to be re-written as relying on glib (rather than just glibc)
+# test_path: test_path.o
+# 	$(CROSS_CC) $^ -o $@ -lglib-2.0

tests/tcg/misc/Makefile line 67

Quoted 10 lines
tests/tcg/misc/Makefile new file +10 -0
+
+# test_path.o: test_path.c
+# 	$(CROSS_CC) $^ -c -o $@ $(QEMU_INCLUDES) `pkg-config --cflags --libs glib-2.0`
+
+testthread: testthread.c
+	$(CROSS_CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpthread
+
+# generic Linux and CPU test
+linux-test: linux-test.c
+	$(CROSS_CC) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm

This breaks the previous fix from 6/19

tests/tcg/misc/testthread.c

Quoted 34 lines
tests/tcg/misc/Makefile new file +14 -0
+
+test-mmap: test-mmap.c
+	$(CROSS_CC) $(CFLAGS) -Wall -O2 $(LDFLAGS) -o $@ $< -static
+
+# speed test
+sha1: sha1.c
+	$(CROSS_CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
+
+speed: sha1
+	time ./sha1
+	time $(QEMU) ./sha1
+
+clean:
+	rm -f *~ *.o $(TESTS)
tests/tcg/misc/linux-test.c renamed from tests/tcg/linux-test.c +0 -0
similarity index 100%
rename from tests/tcg/linux-test.c
rename to tests/tcg/misc/linux-test.c
tests/tcg/misc/sha1.c renamed from tests/tcg/sha1.c +0 -0
similarity index 100%
rename from tests/tcg/sha1.c
rename to tests/tcg/misc/sha1.c
tests/tcg/misc/test-mmap.c renamed from tests/tcg/test-mmap.c +0 -0
similarity index 100%
rename from tests/tcg/test-mmap.c
rename to tests/tcg/misc/test-mmap.c
tests/tcg/misc/test_path.c renamed from tests/tcg/test_path.c +0 -0
similarity index 100%
rename from tests/tcg/test_path.c
rename to tests/tcg/misc/test_path.c
tests/tcg/misc/testthread.c renamed from tests/tcg/testthread.c +0 -0
similarity index 100%
rename from tests/tcg/testthread.c
rename to tests/tcg/misc/testthread.c

--
Alex Bennée

#18 lore raw

Re: [Qemu-devel] [PATCH 12/19] tests/tcg: Add tests-tcg hook in Makefile

In reply to Pranith Kumar
Quoted 3 lines · Pranith Kumar

You can call 'make tests-tcg' to build and run native tcg tests.

This breaks the normal make check output:

GTESTER tests/ptimer-test
CC tests/tmp105-test.o
CC tests/libqos/pci.o
tests/libqos/pci.c:14:24: fatal error: libqos/pci.h: No such file or directory compilation terminated.
/home/alex/lsrc/qemu/qemu.git/rules.mak:60: recipe for target 'tests/libqos/pci.o' failed
make: *** [tests/libqos/pci.o] Error 1

Quoted 44 lines
---
 tests/Makefile.include     |  1 +
 tests/tcg/Makefile.include | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 tests/tcg/Makefile.include
tests/Makefile.include +1 -0
index 2a2b78d..b046bdd 100644
@@ -836,3 +836,4 @@ all: $(QEMU_IOTESTS_HELPERS-y)
 
 -include $(wildcard tests/*.d)
 -include $(wildcard tests/libqos/*.d)
+-include $(SRC_PATH)/tests/tcg/Makefile.include
tests/tcg/Makefile.include new file +23 -0
new file mode 100644
index 0000000..3eff125
@@ -0,0 +1,33 @@
+#
+# linux-user TCG tests
+#
+# The Make is expected to be invoked in the ${BUILD_DIR} directory
+# using the tests-tcg target
+#
+BUILD_DIR?=$(CURDIR)
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+
+UNAME_M := $(shell uname -m)
+
+tests-tcg: prepare $(UNAME_M)
+
+prepare:
+	mkdir -p $(BUILD_DIR)/$(UNAME_M)-linux-user/tests/
+
+x86_64:
+	cd $(BUILD_DIR)/x86_64-linux-user/tests/ && \
+	make -f $(SRC_PATH)/tests/tcg/i386/Makefile
+
+i386:
+	cd $(BUILD_DIR)/i386-linux-user/tests/ && \
+	make -f $(SRC_PATH)/tests/tcg/i386/Makefile

tests/tcg/Makefile.include line 33

Quoted 10 lines
tests/tcg/Makefile.include new file +10 -0
+
+arm:
+	cd $(BUILD_DIR)/arm-linux-user/tests/ && \
+	make -f $(SRC_PATH)/tests/tcg/arm/Makefile
+
+aarch64:
+	cd $(BUILD_DIR)/aarch64-linux-user/tests/ && \
+	make -f $(SRC_PATH)/tests/tcg/arm/Makefile
+
+.PHONY: tests-tcg

--
Alex Bennée

#27 lore raw

Re: [Qemu-devel] [PATCH 18/19] tests/tcg: Add and update Makefiles

In reply to Pranith Kumar
Quoted 18 lines · Pranith Kumar

This commit fixes the makefiles to bring them to the desired state.

---
 tests/tcg/alpha/Makefile             | 38 +++++++++++++++++++----------
 tests/tcg/arm/Makefile               | 32 +++++++++++++++----------
 tests/tcg/cris/Makefile              | 17 +++++++++++--
 tests/tcg/i386/Makefile              | 23 +++++++++---------
 tests/tcg/lm32/Makefile              | 17 +++++++++++--
 tests/tcg/mips/Makefile              | 46 ++++++++++++++++++++++++++++++++++++
 tests/tcg/mips/mips32-dsp/Makefile   | 17 +++++++++++--
 tests/tcg/mips/mips32-dspr2/Makefile | 17 +++++++++++--
 tests/tcg/mips/mips64-dsp/Makefile   | 18 ++++++++++++--
 tests/tcg/mips/mips64-dspr2/Makefile | 17 ++++++++++++-
 tests/tcg/openrisc/Makefile          | 19 ++++++++++++---
 tests/tcg/xtensa/Makefile            | 17 +++++++++++--
 12 files changed, 225 insertions(+), 53 deletions(-)
 create mode 100644 tests/tcg/mips/Makefile

I think these changes should be split and merged with each move commit. I should be able to manually build each individual test target with each move.

Quoted 247 lines
tests/tcg/alpha/Makefile +26 -12
index 2b1f03d..e20315f 100644
@@ -1,33 +1,47 @@
-CROSS=alpha-linux-gnu-
-CC=$(CROSS)gcc
-AS=$(CROSS)as
+# -*- Mode: makefile -*-
+#
+# Alpha linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/alpha-linux-user/tests directory
+#
 
-SIM=../../alpha-linux-user/qemu-alpha
+BUILD_DIR?=$(CURDIR)
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
 
-CFLAGS=-O
-LINK=$(CC) -o $@ crt.o $< -nostdlib
+$(call set-vpath, $(SRC_PATH)/tests/tcg/alpha)
+
+QEMU=$(BUILD_DIR)/alpha-linux-user/qemu-alpha
+
+# Compiler set-up, default to system compiler if not set
+CROSS_CC?=$(CC)
+
+CFLAGS=-Wall -O2 -g -fno-strict-aliasing -static
+LDFLAGS=-nostdlib
 
 TESTS=test-cond test-cmov
 
 all: hello-alpha $(TESTS)
 
 hello-alpha: hello-alpha.o crt.o
-	$(LINK)
+	$(CROSS_CC) -o $@ crt.o $< $(LDFLAGS)
 
 test-cond: test-cond.o crt.o
-	$(LINK)
+	$(CROSS_CC) -o $@ crt.o $< $(LDFLAGS)
 
 test-cmov.o: test-cond.c
-	$(CC) -c $(CFLAGS) -DTEST_CMOV -o $@ $<
+	$(CROSS_CC) -c $(CFLAGS) -DTEST_CMOV -o $@ $<
 
 test-cmov: test-cmov.o crt.o
-	$(LINK)
+	$(CROSS_CC) -o $@ crt.o $< $(LDFLAGS)
 
 test-ovf: test-ovf.o crt.o
-	$(LINK)
+	$(CROSS_CC) -o $@ crt.o $< $(LDFLAGS)
 
 check: $(TESTS)
-	for f in $(TESTS); do $(SIM) $$f || exit 1; done
+	for f in $(TESTS); do $(QEMU) $$f || exit 1; done
 
 clean:
 	$(RM) *.o *~ hello-alpha $(TESTS)
tests/tcg/arm/Makefile +19 -13
index c2ae491..a7c8953 100644
@@ -1,20 +1,26 @@
-BUILD_DIR?=$(CURDIR)
-SRC_PATH=../../../
-include $(BUILD_DIR)/config-host.mak
+# -*- Mode: makefile -*-
+#
+# Arm linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/arm-linux-user/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
 include $(SRC_PATH)/rules.mak
 
 $(call set-vpath, $(SRC_PATH)/tests/tcg/arm)
 
 QEMU=$(BUILD_DIR)/arm-linux-user/qemu-arm
 
-QEMU_INCLUDES += -I$(BUILD_DIR)
-CFLAGS=-Wall -O2 -g -fno-strict-aliasing
-LDFLAGS=
-
-# TODO: automatically detect ARM and MIPS compilers, and run those too
+# Compiler set-up, default to system compiler if not set
+CROSS_CC?=$(CC)
 
-# runcom maps page 0, so it requires root privileges
-# also, pi_10.com runs indefinitely
+QEMU_INCLUDES += -I$(BUILD_DIR)
+CFLAGS=-Wall -O2 -g -fno-strict-aliasing -nostdlib
+LDFLAGS=-nostdlib
 
 TESTS=hello-arm arm-iwmmxt
 
@@ -33,13 +39,13 @@ run-arm-iwmmxt: arm-iwmmxt
 
 # arm test
 hello-arm: hello-arm.o
-	arm-linux-gnueabi-ld -o $@ $<
+	$(CROSS_CC) $(LDFLAGS) -o $@ $<
 
 hello-arm.o: hello-arm.c
-	arm-linux-gnueabi-gcc -Wall -g -O2 -c -o $@ $<
+	$(CROSS_CC) $(CFLAGS) -c -o $@ $<
 
 arm-iwmmxt: test-arm-iwmmxt.s
-	cpp < $< | arm-linux-gnueabi-gcc -Wall -static -march=iwmmxt -mabi=aapcs -x assembler - -o $@
+	cpp < $< | $(CROSS_CC) -Wall -static -march=iwmmxt -mabi=aapcs -x assembler - -o $@
 
 clean:
 	rm -f *~ *.o $(TESTS)
tests/tcg/cris/Makefile +15 -2
index 6b3dba4..009c3f4 100644
@@ -1,7 +1,20 @@
--include ../../../config-host.mak
+# -*- Mode: makefile -*-
+#
+# Cris linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/cris-linux-user/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/arm)
 
 CROSS=crisv32-axis-linux-gnu-
-SIM=../../../cris-linux-user/qemu-cris -L ./
+SIM=$(BUILD_DIR)/cris-linux-user/qemu-cris -L ./
 SIMG=cris-axis-linux-gnu-run --sysroot=./
 
 CC      = $(CROSS)gcc
tests/tcg/i386/Makefile +11 -12
index 97c1a97..55a45ad 100644
@@ -1,6 +1,14 @@
-BUILD_DIR=../../../build/
-SRC_PATH=../../../
-include $(BUILD_DIR)/config-host.mak
+# -*- Mode: makefile -*-
+#
+# i386 linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/i386-linux-user/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
 include $(SRC_PATH)/rules.mak
 
 $(call set-vpath, $(SRC_PATH)/tests/tcg/i386)
@@ -14,14 +22,8 @@ CFLAGS=-Wall -O2 -g -fno-strict-aliasing
 #CFLAGS+=-msse2
 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 \
 	   test-i386-fprem
-	   # runcom
 
 # native i386 compilers sometimes are not biarch.  assume cross-compilers are
 ifneq ($(ARCH),i386)
@@ -57,9 +59,6 @@ run-test-x86_64: test-x86_64
 	-$(QEMU_X86_64) test-x86_64 > test-x86_64.out
 	@if diff -u test-x86_64.ref test-x86_64.out ; then echo "Auto Test OK"; fi
 
-run-runcom: runcom
-	-$(QEMU) ./runcom $(SRC_PATH)/tests/pi_10.com
-
 # rules to compile tests
 
 hello-i386: hello-i386.c
tests/tcg/lm32/Makefile +15 -2
index 57e7363..ad5d9a7 100644
@@ -1,8 +1,21 @@
--include ../../../config-host.mak
+# -*- Mode: makefile -*-
+#
+# lm32 linux-system TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/lm32-softmmu/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/lm32)
 
 CROSS=lm32-elf-
 
-SIM = qemu-system-lm32
+QEMU=$(BUILD_DIR)/lm32-softmmu/qemu-system-lm32
 SIMFLAGS = -M lm32-evr -nographic -semihosting -net none -kernel
 
 CC      = $(CROSS)gcc
tests/tcg/mips/Makefile new file +16 -0
new file mode 100644
index 0000000..a56d6c8
@@ -0,0 +1,46 @@
+# -*- Mode: makefile -*-
+#
+# mips linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/mips-linux-user/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/mips)
+
+QEMU=$(BUILD_DIR)/mips-linux-user/qemu-mips

tests/tcg/mips/Makefile line 26

Quoted 10 lines
tests/tcg/mips/Makefile new file +10 -0
+
+# Compiler set-up, default to system compiler if not set
+CROSS_CC?=$(CC)
+
+CFLAGS=-Wall -O2 -g -fno-strict-aliasing
+LDFLAGS=
+
+TESTS=hello-mips
+
+all: $(patsubst %,run-%,$(TESTS))

We need new run targets for the tests - certainly a default make shouldn't run the test.

Quoted 180 lines
tests/tcg/mips/Makefile new file +20 -0
+test: all
+
+# rules to run tests
+
+run-%: %
+	$(QEMU) ./$*
+
+#.PHONY: $(patsubst %,run-%,$(TESTS))
+
+run-hello-mips: hello-mips
+
+# mips test
+hello-mips: hello-mips.o
+	$(CROSS_CC) -o $@ $<
+
+hello-mips.o: hello-mips.c
+	$(CROSS_CC) -Wall -g -O2 -c -o $@ $<
+
+clean:
+	rm -f *~ *.o $(TESTS)
tests/tcg/mips/mips32-dsp/Makefile +15 -2
index c3a0a00..996b9a0 100644
@@ -1,8 +1,21 @@
--include ../../config-host.mak
+# -*- Mode: makefile -*-
+#
+# mipsel linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/mipsel-linux-user/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/mips/mips32-dsp)
 
 CROSS=mips64el-unknown-linux-gnu-
 
-SIM=qemu-mipsel
+SIM=$(BUILD_DIR)/mipsel-linux-user/qemu-mipsel
 SIM_FLAGS=-cpu 74Kf
 
 CC      = $(CROSS)gcc
tests/tcg/mips/mips32-dspr2/Makefile +15 -2
index ed19581..e99f2bc 100644
@@ -1,8 +1,21 @@
--include ../../config-host.mak
+# -*- Mode: makefile -*-
+#
+# mipsel linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/mipsel-linux-user/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/mips/mips32-dsp)
 
 CROSS=mips64el-unknown-linux-gnu-
 
-SIM=qemu-mipsel
+SIM=$(BUILD_DIR)/mipsel-linux-user/qemu-mipsel
 SIM_FLAGS=-cpu 74Kf
 
 CC      = $(CROSS)gcc
tests/tcg/mips/mips64-dsp/Makefile +16 -2
index b2ac6b3..4ee3bbb 100644
@@ -1,7 +1,21 @@
+# -*- Mode: makefile -*-
+#
+# mips64el linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/mips64el-linux-user/tests directory
+#
 
-CROSS_COMPILE	?= mips64el-unknown-linux-gnu-
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
 
-SIM = qemu-system-mips64el
+$(call set-vpath, $(SRC_PATH)/tests/tcg/mips/mips64-dsp)
+
+CROSS=mips64el-unknown-linux-gnu-
+
+SIM=$(BUILD_DIR)/mipsel-linux-user/qemu-mips64el
 SIMFLAGS = -nographic -cpu mips64dspr2 -kernel
 
 AS      = $(CROSS_COMPILE)as
tests/tcg/mips/mips64-dspr2/Makefile +16 -1
index ba44bb9..8510d8c 100644
@@ -1,6 +1,21 @@
+# -*- Mode: makefile -*-
+#
+# mips64el linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/mips64el-linux-user/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/mips/mips64-dsp)
+
 CROSS_COMPILE	?= mips64el-unknown-linux-gnu-
 
-SIM = qemu-system-mips64el
+SIM=$(BUILD_DIR)/mipsel-linux-user/qemu-mips64el
 SIMFLAGS = -nographic -cpu mips64dspr2 -kernel
 
 AS      = $(CROSS_COMPILE)as
tests/tcg/openrisc/Makefile +16 -3
index 7e65888..071aaab 100644
@@ -1,8 +1,21 @@
--include ../../config-host.mak
+# -*- Mode: makefile -*-
+#
+# openrisc linux-user TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/or32-linux-user/tests directory
+#
 
-CROSS = or32-linux-
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/openrisc)
 
-SIM = qemu-or32
+SIM=$(BUILD_DIR)/or32-linux-user/qemu-mips
+
+CROSS = or32-linux-
 
 CC = $(CROSS)gcc
 
tests/tcg/xtensa/Makefile +14 -1
index 522a63e..e3269ed 100644
@@ -1,10 +1,23 @@
--include ../../../config-host.mak
+# -*- Mode: makefile -*-
+#
+# xtensa linux TCG tests
+#
+# The Make is expected to be called in the
+# ${BUILD_DIR}/xtensa-softmmu/tests directory
+#
+
+BUILD_DIR=../..
+include $(BUILD_DIR)/config-host.mak	# brings in SRC_PATH
+include ../config-target.mak		# TARGET_NAME
+include $(SRC_PATH)/rules.mak
+
+$(call set-vpath, $(SRC_PATH)/tests/tcg/xtensa)

tests/tcg/xtensa/Makefile line 23

Quoted 10 lines
tests/tcg/xtensa/Makefile +1 -1
 
 CORE=dc232b
 CROSS=xtensa-$(CORE)-elf-
 
 ifndef XT
-SIM = ../../../xtensa-softmmu/qemu-system-xtensa
+SIM = $(BUILD_DIR)/xtensa-softmmu/qemu-system-xtensa
 SIMFLAGS = -M sim -cpu $(CORE) -nographic -semihosting $(EXTFLAGS) -kernel
 SIMDEBUG = -s -S
 else

--
Alex Bennée