Add a simple bsd-user smoke test for ensuring bsd-user is minimally
functional. This runs only when bsd-user has been configured. It adds a
simple execution of 'hello world' type binaries for bsd-user. At the
present these are tiny, hand-crafted binaries that are statically linked
and do not depend on any host libraries being present (they also take
advantage of the fact that on FreeBSD all system call numbers are
uniform on all architectures). This was done both for building and
testing simplicity, as well as recognizing the current state of bsd-user
in qemu upstream is extremely basic.

Signed-off-by: Warner Losh <i...@bsdimp.com>
---
 tests/bsd-user-smoke/meson.build | 31 +++++++++++++++++++++++++++++++
 tests/meson.build                |  1 +
 2 files changed, 32 insertions(+)
 create mode 100644 tests/bsd-user-smoke/meson.build

diff --git a/tests/bsd-user-smoke/meson.build b/tests/bsd-user-smoke/meson.build
new file mode 100644
index 00000000000..586697ab3b6
--- /dev/null
+++ b/tests/bsd-user-smoke/meson.build
@@ -0,0 +1,31 @@
+if not have_bsd_user
+   subdir_done()
+endif
+
+smoke_bsd_user = find_program('smoke-bsd-user')
+
+bsd_user_archs = [ 'armv7', 'amd64', 'i386' ]
+targs = []
+foreach i : bsd_user_archs
+    h = 'h.' + i
+    targs += custom_target('bsd-user h.' + i,
+        output : h,
+       input : h + '.S',
+       command : ['clang',
+           '-target',
+           i + '-unknown-freebsd14.0',
+           '-o',
+           '@OUTPUT@',
+           '@INPUT@',
+           '-nostdlib',
+           '-Wl,-e',
+           '-Wl,qemu_start',
+           '-static'],
+       install : false)
+endforeach
+
+test('bsd-user-smoke', smoke_bsd_user,
+    args: [meson.project_build_root(), meson.current_build_dir()],
+    suite: 'smoke',
+    depends: targs
+)
diff --git a/tests/meson.build b/tests/meson.build
index 3f3882748ae..3b95efe8896 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,6 +1,7 @@
 py3 = import('python').find_installation()
 
 subdir('bench')
+subdir('bsd-user-smoke')
 
 test_qapi_outputs = [
   'qapi-builtin-types.c',
-- 
2.33.0


Reply via email to