Signed-off-by: Pierrick Bouvier <[email protected]>
---
tests/tcg/loongarch64/Makefile.softmmu-target | 33 -------------
tests/tcg/loongarch64/meson.build | 2 +
tests/tcg/loongarch64/system/meson.build | 47 +++++++++++++++++++
3 files changed, 49 insertions(+), 33 deletions(-)
delete mode 100644 tests/tcg/loongarch64/Makefile.softmmu-target
create mode 100644 tests/tcg/loongarch64/system/meson.build
diff --git a/tests/tcg/loongarch64/Makefile.softmmu-target
b/tests/tcg/loongarch64/Makefile.softmmu-target
deleted file mode 100644
index 6d4a20fde73..00000000000
--- a/tests/tcg/loongarch64/Makefile.softmmu-target
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Loongarch64 system tests
-#
-
-LOONGARCH64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/loongarch64/system
-VPATH+=$(LOONGARCH64_SYSTEM_SRC)
-
-# These objects provide the basic boot code and helper functions for all tests
-CRT_OBJS=boot.o
-
-LOONGARCH64_TEST_SRCS=$(wildcard $(LOONGARCH64_SYSTEM_SRC)/*.c)
-LOONGARCH64_TESTS = $(patsubst $(LOONGARCH64_SYSTEM_SRC)/%.c, %,
$(LOONGARCH64_TEST_SRCS))
-
-CRT_PATH=$(LOONGARCH64_SYSTEM_SRC)
-LINK_SCRIPT=$(LOONGARCH64_SYSTEM_SRC)/kernel.ld
-LDFLAGS=-Wl,-T$(LINK_SCRIPT)
-TESTS+=$(LOONGARCH64_TESTS) $(MULTIARCH_TESTS)
-CFLAGS+=-nostdlib -g -O1 -march=loongarch64 -mabi=lp64d $(MINILIB_INC)
-LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
-Wl,--no-warn-rwx-segments
-
-# building head blobs
-.PRECIOUS: $(CRT_OBJS)
-
-%.o: $(CRT_PATH)/%.S
- $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -x assembler-with-cpp -Wa,--noexecstack
-c $< -o $@
-
-# Build and link the tests
-%: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
- $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
-
-memory: CFLAGS+=-DCHECK_UNALIGNED=0
-# Running
-QEMU_OPTS+=-serial chardev:output -kernel
diff --git a/tests/tcg/loongarch64/meson.build
b/tests/tcg/loongarch64/meson.build
index 209179fd96c..1d62de64ed6 100644
--- a/tests/tcg/loongarch64/meson.build
+++ b/tests/tcg/loongarch64/meson.build
@@ -2,6 +2,8 @@ cc = 'loongarch64-unknown-linux-gnu-gcc'
cc_dockerfile = 'debian-loongarch-cross'
cc_docker_host_arch = ['x86_64']
+subdir('system')
+
tests = []
tests += tcg_tests['multiarch-linux-user']['tests']
diff --git a/tests/tcg/loongarch64/system/meson.build
b/tests/tcg/loongarch64/system/meson.build
new file mode 100644
index 00000000000..b46d2234032
--- /dev/null
+++ b/tests/tcg/loongarch64/system/meson.build
@@ -0,0 +1,47 @@
+tests = []
+
+minilib_dir = meson.current_source_dir() / '..' / '..' / 'minilib'
+minilib_printf = files(minilib_dir / 'printf.c')[0]
+link_script = files('kernel.ld')[0]
+boot = files('boot.S')[0]
+cflags = ['-nostdlib',
+ '-Wa,--noexecstack',
+ '-I', minilib_dir, minilib_printf, boot,
+ '-Wl,-T', link_script,
+ '-march=loongarch64',
+ '-mabi=lp64d',
+ '-Wl,--no-warn-rwx-segments',
+ '-lgcc']
+qemu_def_args = ['-display', 'none',
+ '-serial', 'stdio',
+ '-kernel']
+
+# Multi arch tests
+multi_src = []
+foreach t: tcg_tests['multiarch-softmmu']['tests']
+ foreach src, setup: t
+ new_cflags = cflags
+ if fs.stem(src) == 'memory'
+ new_cflags += '-DCHECK_UNALIGNED=0'
+ endif
+ if src not in multi_src
+ setup += {'cflags': [new_cflags]}
+ multi_src += src
+ endif
+ tests += {src: setup + {'qemu_args': qemu_def_args}}
+ endforeach
+endforeach
+
+if 'qemu-system-loongarch64' in emulators
+ tcg_tests += {
+ 'loongarch64-softmmu': {
+ 'cc': cc,
+ 'cc_dockerfile': cc_dockerfile,
+ 'cc_docker_host_arch': cc_docker_host_arch,
+ 'folder': 'loongarch64/system',
+ 'gdb_arch': 'loongarch64',
+ 'qemu': emulators['qemu-system-loongarch64'],
+ 'tests': tests,
+ }
+ }
+endif
--
2.47.3