qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

tests/tcg: move architecture independent tests into subdir

We will want to build these for all supported guest architectures so
lets move them all into one place. We also drop test_path at this
point because it needs qemu utils and glib bits which is hard to
support for cross compiling.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

+45 -194
+4
MAINTAINERS
··· 303 303 F: hw/tricore/ 304 304 F: include/hw/tricore/ 305 305 306 + Multiarch Linux User Tests 307 + M: Alex Bennée <alex.bennee@linaro.org> 308 + F: tests/tcg/multiarch/ 309 + 306 310 Guest CPU Cores (KVM): 307 311 ---------------------- 308 312
-31
tests/tcg/Makefile
··· 18 18 # also, pi_10.com runs indefinitely 19 19 20 20 I386_TESTS=hello-i386 \ 21 - linux-test \ 22 - testthread \ 23 21 sha1-i386 \ 24 22 test-i386 \ 25 23 test-i386-fprem \ 26 - test-mmap \ 27 24 # runcom 28 25 29 26 # native i386 compilers sometimes are not biarch. assume cross-compilers are ··· 47 44 -$(QEMU) ./$* 48 45 49 46 run-hello-i386: hello-i386 50 - run-linux-test: linux-test 51 - run-testthread: testthread 52 47 run-sha1-i386: sha1-i386 53 48 54 49 run-test-i386: test-i386 ··· 66 61 -$(QEMU_X86_64) test-x86_64 > test-x86_64.out 67 62 @if diff -u test-x86_64.ref test-x86_64.out ; then echo "Auto Test OK"; fi 68 63 69 - run-test-mmap: test-mmap 70 - -$(QEMU) ./test-mmap 71 - -$(QEMU) -p 8192 ./test-mmap 8192 72 - -$(QEMU) -p 16384 ./test-mmap 16384 73 - -$(QEMU) -p 32768 ./test-mmap 32768 74 64 75 65 run-runcom: runcom 76 66 -$(QEMU) ./runcom $(SRC_PATH)/tests/pi_10.com ··· 80 70 81 71 # rules to compile tests 82 72 83 - test_path: test_path.o 84 - 85 - test_path.o: test_path.c 86 - 87 73 hello-i386: hello-i386.c 88 74 $(CC_I386) -nostdlib $(CFLAGS) -static $(LDFLAGS) -o $@ $< 89 75 strip $@ 90 76 91 - testthread: testthread.c 92 - $(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lpthread 93 - 94 77 # i386/x86_64 emulation test (test various opcodes) */ 95 78 test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S \ 96 79 test-i386.h test-i386-shift.h test-i386-muldiv.h ··· 104 87 test-i386.h test-i386-shift.h test-i386-muldiv.h 105 88 $(CC_X86_64) $(QEMU_INCLUDES) $(CFLAGS) $(LDFLAGS) -o $@ $(<D)/test-i386.c -lm 106 89 107 - # generic Linux and CPU test 108 - linux-test: linux-test.c 109 - $(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< -lm 110 - 111 90 # vm86 test 112 91 runcom: runcom.c 113 92 $(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< 114 - 115 - test-mmap: test-mmap.c 116 - $(CC_I386) -m32 $(CFLAGS) -Wall -O2 $(LDFLAGS) -o $@ $< 117 93 118 94 # speed test 119 95 sha1-i386: sha1.c 120 96 $(CC_I386) $(CFLAGS) $(LDFLAGS) -o $@ $< 121 - 122 - sha1: sha1.c 123 - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< 124 - 125 - speed: sha1 sha1-i386 126 - time ./sha1 127 - time $(QEMU) ./sha1-i386 128 97 129 98 # arm test 130 99 hello-arm: hello-arm.o
+4 -6
tests/tcg/README
··· 1 - This directory contains various interesting programs for 2 - regression testing. 3 - 4 - The target "make test" runs the programs and, if applicable, 5 - runs "diff" to detect mismatches between output on the host and 6 - output on QEMU. 1 + This directory contains various interesting guest programs for 2 + regression testing. Tests are either multi-arch, meaning they can be 3 + built for all guest architectures that support linux-user executable, 4 + or they are architecture specific. 7 5 8 6 i386 9 7 ====
tests/tcg/linux-test.c tests/tcg/multiarch/linux-test.c
+36
tests/tcg/multiarch/Makefile.target
··· 1 + # -*- Mode: makefile -*- 2 + # 3 + # Multiarch Tests - included from tests/tcg/Makefile.target 4 + # 5 + # These tests are plain C and built without any architecture specific code. 6 + # 7 + 8 + MULTIARCH_SRC=$(SRC_PATH)/tests/tcg/multiarch 9 + 10 + # Set search path for all sources 11 + VPATH += $(MULTIARCH_SRC) 12 + MULTIARCH_SRCS =$(notdir $(wildcard $(MULTIARCH_SRC)/*.c)) 13 + MULTIARCH_TESTS =$(MULTIARCH_SRCS:.c=) 14 + 15 + # Update TESTS 16 + TESTS +=$(MULTIARCH_TESTS) 17 + 18 + # 19 + # The following are any additional rules needed to build things 20 + # 21 + 22 + testthread: LDFLAGS+=-lpthread 23 + 24 + # We define the runner for test-mmap after the individual 25 + # architectures have defined their supported pages sizes. If no 26 + # additional page sizes are defined we only run the default test. 27 + 28 + # default case (host page size) 29 + run-test-mmap: test-mmap 30 + $(call quiet-command, $(QEMU) $< > test-mmap.out, "TEST", \ 31 + "$< (default) on $(TARGET_NAME)") 32 + 33 + # additional page sizes (defined by each architecture adding to EXTRA_RUNS) 34 + run-test-mmap-%: test-mmap 35 + $(call quiet-command, $(QEMU) -p $* $< > test-mmap-$*.out, "TEST", \ 36 + "$< ($* byte pages) on $(TARGET_NAME)")
+1
tests/tcg/multiarch/README
··· 1 + Multi-architecture linux-user tests
tests/tcg/sha1.c tests/tcg/multiarch/sha1.c
tests/tcg/test-mmap.c tests/tcg/multiarch/test-mmap.c
-157
tests/tcg/test_path.c
··· 1 - /* Test path override code */ 2 - #include "config-host.h" 3 - #include "util/cutils.c" 4 - #include "util/hexdump.c" 5 - #include "util/iov.c" 6 - #include "util/path.c" 7 - #include "util/qemu-timer-common.c" 8 - #include <stdarg.h> 9 - #include <sys/stat.h> 10 - #include <fcntl.h> 11 - 12 - void qemu_log(const char *fmt, ...); 13 - 14 - /* Any log message kills the test. */ 15 - void qemu_log(const char *fmt, ...) 16 - { 17 - va_list ap; 18 - 19 - fprintf(stderr, "FATAL: "); 20 - va_start(ap, fmt); 21 - vfprintf(stderr, fmt, ap); 22 - va_end(ap); 23 - exit(1); 24 - } 25 - 26 - #define NO_CHANGE(_path) \ 27 - do { \ 28 - if (strcmp(path(_path), _path) != 0) return __LINE__; \ 29 - } while(0) 30 - 31 - #define CHANGE_TO(_path, _newpath) \ 32 - do { \ 33 - if (strcmp(path(_path), _newpath) != 0) return __LINE__; \ 34 - } while(0) 35 - 36 - static void cleanup(void) 37 - { 38 - unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE"); 39 - unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE2"); 40 - unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE3"); 41 - unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE4"); 42 - unlink("/tmp/qemu-test_path/DIR1/DIR2/FILE5"); 43 - rmdir("/tmp/qemu-test_path/DIR1/DIR2"); 44 - rmdir("/tmp/qemu-test_path/DIR1/DIR3"); 45 - rmdir("/tmp/qemu-test_path/DIR1"); 46 - rmdir("/tmp/qemu-test_path"); 47 - } 48 - 49 - static unsigned int do_test(void) 50 - { 51 - if (mkdir("/tmp/qemu-test_path", 0700) != 0) 52 - return __LINE__; 53 - 54 - if (mkdir("/tmp/qemu-test_path/DIR1", 0700) != 0) 55 - return __LINE__; 56 - 57 - if (mkdir("/tmp/qemu-test_path/DIR1/DIR2", 0700) != 0) 58 - return __LINE__; 59 - 60 - if (mkdir("/tmp/qemu-test_path/DIR1/DIR3", 0700) != 0) 61 - return __LINE__; 62 - 63 - if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE", 0600)) != 0) 64 - return __LINE__; 65 - 66 - if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE2", 0600)) != 0) 67 - return __LINE__; 68 - 69 - if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE3", 0600)) != 0) 70 - return __LINE__; 71 - 72 - if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE4", 0600)) != 0) 73 - return __LINE__; 74 - 75 - if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE5", 0600)) != 0) 76 - return __LINE__; 77 - 78 - init_paths("/tmp/qemu-test_path"); 79 - 80 - NO_CHANGE("/tmp"); 81 - NO_CHANGE("/tmp/"); 82 - NO_CHANGE("/tmp/qemu-test_path"); 83 - NO_CHANGE("/tmp/qemu-test_path/"); 84 - NO_CHANGE("/tmp/qemu-test_path/D"); 85 - NO_CHANGE("/tmp/qemu-test_path/DI"); 86 - NO_CHANGE("/tmp/qemu-test_path/DIR"); 87 - NO_CHANGE("/tmp/qemu-test_path/DIR1"); 88 - NO_CHANGE("/tmp/qemu-test_path/DIR1/"); 89 - 90 - NO_CHANGE("/D"); 91 - NO_CHANGE("/DI"); 92 - NO_CHANGE("/DIR"); 93 - NO_CHANGE("/DIR2"); 94 - NO_CHANGE("/DIR1."); 95 - 96 - CHANGE_TO("/DIR1", "/tmp/qemu-test_path/DIR1"); 97 - CHANGE_TO("/DIR1/", "/tmp/qemu-test_path/DIR1"); 98 - 99 - NO_CHANGE("/DIR1/D"); 100 - NO_CHANGE("/DIR1/DI"); 101 - NO_CHANGE("/DIR1/DIR"); 102 - NO_CHANGE("/DIR1/DIR1"); 103 - 104 - CHANGE_TO("/DIR1/DIR2", "/tmp/qemu-test_path/DIR1/DIR2"); 105 - CHANGE_TO("/DIR1/DIR2/", "/tmp/qemu-test_path/DIR1/DIR2"); 106 - 107 - CHANGE_TO("/DIR1/DIR3", "/tmp/qemu-test_path/DIR1/DIR3"); 108 - CHANGE_TO("/DIR1/DIR3/", "/tmp/qemu-test_path/DIR1/DIR3"); 109 - 110 - NO_CHANGE("/DIR1/DIR2/F"); 111 - NO_CHANGE("/DIR1/DIR2/FI"); 112 - NO_CHANGE("/DIR1/DIR2/FIL"); 113 - NO_CHANGE("/DIR1/DIR2/FIL."); 114 - 115 - CHANGE_TO("/DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); 116 - CHANGE_TO("/DIR1/DIR2/FILE2", "/tmp/qemu-test_path/DIR1/DIR2/FILE2"); 117 - CHANGE_TO("/DIR1/DIR2/FILE3", "/tmp/qemu-test_path/DIR1/DIR2/FILE3"); 118 - CHANGE_TO("/DIR1/DIR2/FILE4", "/tmp/qemu-test_path/DIR1/DIR2/FILE4"); 119 - CHANGE_TO("/DIR1/DIR2/FILE5", "/tmp/qemu-test_path/DIR1/DIR2/FILE5"); 120 - 121 - NO_CHANGE("/DIR1/DIR2/FILE6"); 122 - NO_CHANGE("/DIR1/DIR2/FILE/X"); 123 - 124 - CHANGE_TO("/DIR1/../DIR1", "/tmp/qemu-test_path/DIR1"); 125 - CHANGE_TO("/DIR1/../DIR1/", "/tmp/qemu-test_path/DIR1"); 126 - CHANGE_TO("/../DIR1", "/tmp/qemu-test_path/DIR1"); 127 - CHANGE_TO("/../DIR1/", "/tmp/qemu-test_path/DIR1"); 128 - CHANGE_TO("/DIR1/DIR2/../DIR2", "/tmp/qemu-test_path/DIR1/DIR2"); 129 - CHANGE_TO("/DIR1/DIR2/../DIR2/../../DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); 130 - CHANGE_TO("/DIR1/DIR2/../DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); 131 - 132 - NO_CHANGE("/DIR1/DIR2/../DIR1"); 133 - NO_CHANGE("/DIR1/DIR2/../FILE"); 134 - 135 - CHANGE_TO("/./DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); 136 - CHANGE_TO("/././DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); 137 - CHANGE_TO("/DIR1/./DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); 138 - CHANGE_TO("/DIR1/././DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); 139 - CHANGE_TO("/DIR1/DIR2/./FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); 140 - CHANGE_TO("/DIR1/DIR2/././FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); 141 - CHANGE_TO("/./DIR1/./DIR2/./FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); 142 - 143 - return 0; 144 - } 145 - 146 - int main(int argc, char *argv[]) 147 - { 148 - int ret; 149 - 150 - ret = do_test(); 151 - cleanup(); 152 - if (ret) { 153 - fprintf(stderr, "test_path: failed on line %i\n", ret); 154 - return 1; 155 - } 156 - return 0; 157 - }
tests/tcg/testthread.c tests/tcg/multiarch/testthread.c