bsd-user-smoke: A simple smoke test for bsd-user
cover bsd-user-smoke: A simple smoke test for bsd-user
This series adds a number of simple binaries that FreeBSD's clang can build on any system. I've kept it simple so that there's no extra binaries that need to be installed. Given the current state of bsd-user in the project's repo, this likely is as extensive a set of tests that should be done right now. We can load static binaries only (so these are static binaries) and hello world is the canonical test. I have binaries for all the supported FreeBSD targets, but have included only the ones that are in upstream (or in review) at this time.
In the future, I'll integreate with the tcg tests when there's more in upstream they can test. Since that requires putting together FreeBSD sysroots for all the supported architectures for multiple versions, I'm going to delay that for a while. I'll also integrate FreeBSD's 5k system tests when we're much further along with the upstreaming.
The purpose of this is to give others doing changes in this area a standardized way to ensure their changes don't fundamentally break bsd-user. This approach will work for all setups that do a 'make check' to do their testing.
Based-on: [email protected]
Warner Losh (5):
h.armv7: Simple hello-world test for armv7
h.i386: Simple hello-world test for i386
h.amd64: Simple hello-world test for x86_64
smoke-bsd-user: A test script to run all the FreeBSD binaries
bsd-user-smoke: Add to build
tests/bsd-user-smoke/h.amd64.S | 28 +++++++++++++++++++++ tests/bsd-user-smoke/h.armv7.S | 37 +++++++++++++++++++++++++++ tests/bsd-user-smoke/h.i386.S | 39 +++++++++++++++++++++++++++++ tests/bsd-user-smoke/meson.build | 31 +++++++++++++++++++++++ tests/bsd-user-smoke/smoke-bsd-user | 22 ++++++++++++++++ tests/meson.build | 1 + 6 files changed, 158 insertions(+) create mode 100644 tests/bsd-user-smoke/h.amd64.S create mode 100644 tests/bsd-user-smoke/h.armv7.S create mode 100644 tests/bsd-user-smoke/h.i386.S create mode 100644 tests/bsd-user-smoke/meson.build create mode 100644 tests/bsd-user-smoke/smoke-bsd-user
Signature · 1 line
2.33.0
PATCH 1/5 h.armv7: Simple hello-world test for armv7
A simple, tiny, statically linked armv7 'hello world' test. It uses two system calls (write and exit) and provides a basic sanity check to make sure that the arm bsd-user binary can interpret FreeBSD armv7 binaries.
--- tests/bsd-user-smoke/h.armv7.S | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/bsd-user-smoke/h.armv7.S
tests/bsd-user-smoke/h.armv7.S new file +37 -0
@@ -0,0 +1,37 @@ +# Copyright (c) 2021 Warner Losh +# SPDX-License-Identifier: BSD-2-Clause + +#include <sys/syscall.h> +#define STDOUT_FILENO 1 + + .text + .file "hello.s" + .syntax unified + .globl qemu_start @ -- Begin function qemu_start + .p2align 2 + .type qemu_start,%function + .code 32 @ @qemu_start +qemu_start: +@ %bb.0: @ %entry + + # write(1, .L.str, sizeof(.L.str) - 1) + movw r1, :lower16:.L.str @ Load hello world + movt r1, :upper16:.L.str + ldr r0, =STDOUT_FILENO + ldr r2, =(.L.strEnd - .L.str - 1) + ldr r7, =SYS_write + swi 0 + + # _exit(0) + ldr r0, =0 @ success + ldr r7, =SYS_exit + swi 0 +.Lfunc_end0: + .size qemu_start, .Lfunc_end0-qemu_start + @ -- End function + .type .L.str,%object @ @.str + .section .rodata.str1.1,"aMS",%progbits,1 +.L.str: + .asciz "Hello World\n" +.L.strEnd: + .size .L.str, .L.strEnd - .L.str
Signature · 1 line
2.33.0
PATCH 2/5 h.i386: Simple hello-world test for i386
In reply to Warner LoshA simple, tiny, statically linked i386 'hello world' test. It uses two system calls (write and exit) and provides a basic sanity check to make sure that the arm bsd-user binary can interpret FreeBSD 32-bit i386 binaries.
--- tests/bsd-user-smoke/h.i386.S | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/bsd-user-smoke/h.i386.S
tests/bsd-user-smoke/h.i386.S new file +39 -0
@@ -0,0 +1,39 @@ +# Copyright (c) 2021 Warner Losh +# SPDX-License-Identifier: BSD-2-Clause + +#include <sys/syscall.h> +#define STDOUT_FILENO 1 + + .text + .file "hello.s" + .globl qemu_start # -- Begin function qemu_start + .p2align 4, 0x90 + .type qemu_start,@function +qemu_start: # @qemu_start +# %bb.0: # %entry + pushl %ebp + movl %esp, %ebp + + # write(1, .L.str, sizeof(.L.str) - 1) + pushl $(.L.strEnd - .L.str - 1) + pushl $.L.str + pushl $STDOUT_FILENO + pushl %eax # dummy return address + movl $SYS_write, %eax + int $0x80 + addl $16, %esp # 3 args + 1 dummy + + # _exit(0) + pushl $0 + pushl %eax # dummy return address + movl $SYS_exit, %eax + int $0x80 +.Lfunc_end0: + .size qemu_start, .Lfunc_end0-qemu_start + # -- End function + .type .L.str,@object # @.str + .section .rodata.str1.1,"aMS",@progbits,1 +.L.str: + .asciz "Hello World\n" +.L.strEnd: + .size .L.str, .L.strEnd - .L.str
Signature · 1 line
2.33.0
PATCH 3/5 h.amd64: Simple hello-world test for x86_64
In reply to Warner LoshA simple, tiny, statically linked 64-bit x86 'hello world' test. It uses two system calls (write and exit) and provides a basic sanity check to make sure that the arm bsd-user binary can interpret FreeBSD 64-bit amd64 binaries. Please note: it's named amd64 because that's the target name for FreeBSD's clang and it simplifies building a little.
--- tests/bsd-user-smoke/h.amd64.S | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/bsd-user-smoke/h.amd64.S
tests/bsd-user-smoke/h.amd64.S new file +28 -0
@@ -0,0 +1,28 @@ +# Copyright (c) 2021 Warner Losh +# SPDX-License-Identifier: BSD-2-Clause + +#include <sys/syscall.h> +#define STDOUT_FILENO 1 + + .text + .globl qemu_start + .p2align 4, 0x90 +qemu_start: + + # write(1, .L.str, sizeof(.L.str) - 1) + movq $.L.str, %rsi + movl $STDOUT_FILENO, %edi + movl $len, %edx + movl $SYS_write, %eax + syscall + + # _exit(0) + xorl %edi, %edi + movl $SYS_exit, %eax + syscall + + .section .rodata.str1.1,"aMS",@progbits,1 +.L.str: + .asciz "Hello World\n" +.L.strEnd: +len=.L.strEnd - .L.str - 1
Signature · 1 line
2.33.0
PATCH 4/5 smoke-bsd-user: A test script to run all the FreeBSD binaries
In reply to Warner LoshSimple shell script to iterate through all the FreeBSD binaries running qemu-$binary to ensure that we have minimal functionality for each platform. When more of the bsd-user fork has been upstreamed, this will be replaced by more extensive regresion tests.
--- tests/bsd-user-smoke/smoke-bsd-user | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/bsd-user-smoke/smoke-bsd-user
tests/bsd-user-smoke/smoke-bsd-user new file +22 -0
@@ -0,0 +1,22 @@ +#!/bin/sh + +build=$1 +testing=$2 + +smoke_one() { + local a=$1 q=$2 + + echo Hello World > foo1 + $build/qemu-$q $testing/h.$a > foo2 || die "cmd failed: $build/qemu-$q $testing/h.$a" + cmp foo1 foo2 || die "Hello World expected" + rm foo1 foo2 +} + +die() { + echo $1 + exit 1 +} + +smoke_one amd64 x86_64 +smoke_one armv7 arm +smoke_one i386 i386
Signature · 1 line
2.33.0
PATCH 5/5 bsd-user-smoke: Add to build
In reply to Warner LoshAdd 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.
--- 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
tests/bsd-user-smoke/meson.build new file +31 -0
@@ -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 +)
tests/meson.build +1 -0
@@ -1,6 +1,7 @@ py3 = import('python').find_installation() subdir('bench') +subdir('bsd-user-smoke') test_qapi_outputs = [ 'qapi-builtin-types.c',
Signature · 1 line
2.33.0
Re: [PATCH for 7.0 5/5] bsd-user-smoke: Add to build
+Paolo for meson
Quoted 27 lines · Warner Losh
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 <[email protected]>--- tests/bsd-user-smoke/meson.build | 31 +++++++++++++++++++++++++++++++ tests/meson.build | 1 + 2 files changed, 32 insertions(+) create mode 100644 tests/bsd-user-smoke/meson.buildtests/bsd-user-smoke/meson.build new file +4
-0@@ -0,0 +1,31 @@ +if not have_bsd_user + subdir_done() +endif +
tests/bsd-user-smoke/meson.build line 14
Quoted 10 lines
tests/bsd-user-smoke/meson.build new file +10
-0+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',
Do we want a find_program(clang) somewhere?
tests/bsd-user-smoke/meson.build line 16
Quoted 2 lines
tests/bsd-user-smoke/meson.build new file +2
-0+ '-target', + i + '-unknown-freebsd14.0',
Also, I wonder if this trailer shouldn´t be populated by meson.
Quoted 27 lines
tests/bsd-user-smoke/meson.build new file +15
-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 +)tests/meson.build +1
-0@@ -1,6 +1,7 @@ py3 = import('python').find_installation() subdir('bench') +subdir('bsd-user-smoke') test_qapi_outputs = [ 'qapi-builtin-types.c',
Re: [PATCH for 7.0 5/5] bsd-user-smoke: Add to build
Quoted 35 lines · Philippe Mathieu-Daudé
+Paolo for meson
Quoted 10 lines · Warner Losh
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.
Review
Quoted 8 lines
Signed-off-by Warner Losh <[email protected]>--- 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(quoted diff) +0
-0b/tests/bsd-user-smoke/meson.build
Quoted 13 lines
new file mode 100644
index 00000000000..586697ab3b6tests/bsd-user-smoke/meson.build new file +8
-0@@ -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 = []
Quoted 9 lines
tests/bsd-user-smoke/meson.build line 14
Quoted 6 lines
tests/bsd-user-smoke/meson.build new file +6
-0+foreach i : bsd_user_archs + h = 'h.' + i + targs += custom_target('bsd-user h.' + i, + output : h, + input : h + '.S', + command : ['clang',Do we want a
find_program(clang)somewhere?
I am new and naive in the ways of meson... :) I am willing, however, to learn...
Is it just s/'clang'/find_program(clang)/ here or something more complex....
Quoted 5 lines
tests/bsd-user-smoke/meson.build line 16
Quoted 2 lines
tests/bsd-user-smoke/meson.build new file +2
-0+ '-target', + i + '-unknown-freebsd14.0',Also, I wonder if this trailer shouldn´t be populated by meson.
I like that idea. See above :)
Warner
Quoted 28 lines
Quoted 27 lines
tests/bsd-user-smoke/meson.build new file +15
-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 +)tests/meson.build +1
-0@@ -1,6 +1,7 @@ py3 = import('python').find_installation() subdir('bench') +subdir('bsd-user-smoke') test_qapi_outputs = [ 'qapi-builtin-types.c',
PING!
If anybody (especially the BSD reviewers) could look at these, that would be great!
It's been suggested I rename bsd-user-smoke to just be bsd-user and we put our tests there until we can switch to the more generic tcg tests, so I'll do that and resend in a few days.
Warner
Quoted 55 lines · Warner Losh
This series adds a number of simple binaries that FreeBSD's clang can build on
any system. I've kept it simple so that there's no extra binaries that need to
be installed. Given the current state of bsd-user in the project's repo, this
likely is as extensive a set of tests that should be done right now. We can load
static binaries only (so these are static binaries) and hello world is the canonical test. I have binaries for all the supported FreeBSD targets, but have
included only the ones that are in upstream (or in review) at this time.In the future, I'll integreate with the tcg tests when there's more in upstream
they can test. Since that requires putting together FreeBSD sysroots for all
the supported architectures for multiple versions, I'm going to delay that for a
while. I'll also integrate FreeBSD's 5k system tests when we're much further
along with the upstreaming.The purpose of this is to give others doing changes in this area a standardized
way to ensure their changes don't fundamentally break bsd-user. This approach
will work for all setups that do a 'make check' to do their testing.Based-on: [email protected]
Warner Losh (5):
h.armv7: Simple hello-world test for armv7
h.i386: Simple hello-world test for i386
h.amd64: Simple hello-world test forx86_64
smoke-bsd-user: A test script to run all the FreeBSD binaries
bsd-user-smoke: Add to buildtests/bsd-user-smoke/h.amd64.S | 28 +++++++++++++++++++++ tests/bsd-user-smoke/h.armv7.S | 37 +++++++++++++++++++++++++++ tests/bsd-user-smoke/h.i386.S | 39 +++++++++++++++++++++++++++++ tests/bsd-user-smoke/meson.build | 31 +++++++++++++++++++++++ tests/bsd-user-smoke/smoke-bsd-user | 22 ++++++++++++++++ tests/meson.build | 1 + 6 files changed, 158 insertions(+) create mode 100644 tests/bsd-user-smoke/h.amd64.S create mode 100644 tests/bsd-user-smoke/h.armv7.S create mode 100644 tests/bsd-user-smoke/h.i386.S create mode 100644 tests/bsd-user-smoke/meson.build create mode 100644 tests/bsd-user-smoke/smoke-bsd-user--
2.33.0
Quoted 6 lines · Warner Losh
PING!
If anybody (especially the BSD reviewers) could look at these, that would be great!
It's been suggested I rename bsd-user-smoke to just be bsd-user and we put our tests there until we can switch to the more generic tcg tests, so I'll do that and resend in a few days.
That seems reasonable. I'm curious how much of check-tcg runs on BSD at the moment?
Quoted 47 lines
Warner
On Sat, Nov 27, 2021 at 1:19 PM Warner Losh <[email protected]> wrote:
This series adds a number of simple binaries that FreeBSD's clang can build on any system. I've kept it simple so that there's no extra binaries that need to be installed. Given the current state of bsd-user in the project's repo, this likely is as extensive a set of tests that should be done right now. We can load static binaries only (so these are static binaries) and hello world is the canonical test. I have binaries for all the supported FreeBSD targets, but have included only the ones that are in upstream (or in review) at this time.
In the future, I'll integreate with the tcg tests when there's more in upstream they can test. Since that requires putting together FreeBSD sysroots for all the supported architectures for multiple versions, I'm going to delay that for a while. I'll also integrate FreeBSD's 5k system tests when we're much further along with the upstreaming.
The purpose of this is to give others doing changes in this area a standardized way to ensure their changes don't fundamentally break bsd-user. This approach will work for all setups that do a 'make check' to do their testing.
Based-on: [email protected]
Warner Losh (5):
h.armv7: Simple hello-world test for armv7
h.i386: Simple hello-world test for i386
h.amd64: Simple hello-world test forx86_64
smoke-bsd-user: A test script to run all the FreeBSD binaries
bsd-user-smoke: Add to buildtests/bsd-user-smoke/h.amd64.S | 28 +++++++++++++++++++++ tests/bsd-user-smoke/h.armv7.S | 37 +++++++++++++++++++++++++++ tests/bsd-user-smoke/h.i386.S | 39 +++++++++++++++++++++++++++++ tests/bsd-user-smoke/meson.build | 31 +++++++++++++++++++++++ tests/bsd-user-smoke/smoke-bsd-user | 22 ++++++++++++++++ tests/meson.build | 1 + 6 files changed, 158 insertions(+)create mode 100644
tests/bsd-user-smoke/h.amd64.Screate mode 100644tests/bsd-user-smoke/h.armv7.Screate mode 100644tests/bsd-user-smoke/h.i386.Screate mode 100644 tests/bsd-user-smoke/meson.build create mode 100644 tests/bsd-user-smoke/smoke-bsd-user--
2.33.0
Signature · 1 line
Alex Bennée
Quoted 6 lines · Alex Bennée
Quoted 3 lines · Warner Losh
PING!
If anybody (especially the BSD reviewers) could look at these, that
Quoted 9 lines
would be great!
Quoted 2 lines
It's been suggested I rename bsd-user-smoke to just be bsd-user and we
put our tests there until we can switch to the more generic tcg
Quoted 1 line
tests, so I'll do that and resend in a few days.
That seems reasonable. I'm curious how much of check-tcg runs on BSD at the moment?
About 1/3-1/2 on x86 (due to lack of signal support, the x86 stuff is pretty basic since it's
really never evolved past it's early Blue Swirl origin phase). On other platforms, you
need a 'sysroot' to build with the cross compiler specified. FreeBSD has the compiler
built to build for any target by default, but not the sysroot needed and we don't
currently have a good sysroot package that would easily drop into automation. The
smoke test is carefully crafted to not need this. To be honest, I've not yet tested other
architectures due to this issue with check-tcg, but will do so now that I'm back from
the holidays. There's some other issues with bsd-user I need to focus on first (more
changes to sys/user.h breaking the build leading to much downstream angst).
Warner
Quoted 64 lines
Quoted 6 lines
Warner
On Sat, Nov 27, 2021 at 1:19 PM Warner Losh <[email protected]> wrote:
This series adds a number of simple binaries that FreeBSD's clang can
build on
Quoted 1 line
any system. I've kept it simple so that there's no extra binaries that
need to
Quoted 1 line
be installed. Given the current state of bsd-user in the project's
repo, this
Quoted 1 line
likely is as extensive a set of tests that should be done right now. We
can load
Quoted 1 line
static binaries only (so these are static binaries) and hello world is
the
Quoted 1 line
canonical test. I have binaries for all the supported FreeBSD targets,
but have
Quoted 3 lines
included only the ones that are in upstream (or in review) at this time.
In the future, I'll integreate with the tcg tests when there's more in
upstream
Quoted 1 line
they can test. Since that requires putting together FreeBSD sysroots
for all
Quoted 1 line
the supported architectures for multiple versions, I'm going to delay
that for a
Quoted 1 line
while. I'll also integrate FreeBSD's 5k system tests when we're much
further
Quoted 3 lines
along with the upstreaming.
The purpose of this is to give others doing changes in this area a
standardized
Quoted 1 line
way to ensure their changes don't fundamentally break bsd-user. This
approach
Quoted 18 lines
will work for all setups that do a 'make check' to do their testing.
Based-on: [email protected]
Warner Losh (5):
h.armv7: Simple hello-world test for armv7
h.i386: Simple hello-world test for i386
h.amd64: Simple hello-world test forx86_64
smoke-bsd-user: A test script to run all the FreeBSD binaries
bsd-user-smoke: Add to buildtests/bsd-user-smoke/h.amd64.S | 28 +++++++++++++++++++++ tests/bsd-user-smoke/h.armv7.S | 37 +++++++++++++++++++++++++++ tests/bsd-user-smoke/h.i386.S | 39 +++++++++++++++++++++++++++++ tests/bsd-user-smoke/meson.build | 31 +++++++++++++++++++++++ tests/bsd-user-smoke/smoke-bsd-user | 22 ++++++++++++++++ tests/meson.build | 1 + 6 files changed, 158 insertions(+)Quoted 8 lines
create mode 100644
tests/bsd-user-smoke/h.amd64.Screate mode 100644tests/bsd-user-smoke/h.armv7.Screate mode 100644tests/bsd-user-smoke/h.i386.Screate mode 100644 tests/bsd-user-smoke/meson.build create mode 100644 tests/bsd-user-smoke/smoke-bsd-user--
2.33.0--
Alex Bennée