Skip to content

Commit

Permalink
test: Add first full integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aengelke committed Jan 22, 2023
1 parent 6cef066 commit da679f4
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .builds/llvm13-x86_64-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ packages:
- llvm-13-dev
- libssl-dev
- pkg-config
- clang
- lld
sources:
- https://git.sr.ht/~aengelke/instrew
tasks:
Expand Down
2 changes: 2 additions & 0 deletions .builds/llvm15-x86_64-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ packages:
- llvm-15-dev
- libssl-dev
- pkg-config
- clang
- lld
sources:
- https://git.sr.ht/~aengelke/instrew
tasks:
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ subdir('tool-api')
subdir('server')

subdir('tools-simple')
subdir('test')
10 changes: 5 additions & 5 deletions server/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ client_bytes = custom_target('hex-client', output: 'client.inc', input: client,
capture: true,
command: [python3, '-c', pytobytes, '@INPUT@'])

executable('instrew', sources, client_bytes,
include_directories: include_directories('.', '../shared'),
dependencies: [librellume, fadec, frvdec, farmdec, libllvm, libcrypto, instrew_api],
link_args: ['-ldl'],
install: true)
instrew = executable('instrew', sources, client_bytes,
include_directories: include_directories('.', '../shared'),
dependencies: [librellume, fadec, frvdec, farmdec, libllvm, libcrypto, instrew_api],
link_args: ['-ldl'],
install: true)
7 changes: 7 additions & 0 deletions test/aarch64/exit.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.text
.global _start
_start:
mov x0, #0
mov x8, #94
svc #0
udf #0
5 changes: 5 additions & 0 deletions test/aarch64/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

triple = 'aarch64-linux-gnu'
cases = [
{'name': 'exit', 'src': files('exit.S')},
]
Empty file added test/empty.s
Empty file.
28 changes: 28 additions & 0 deletions test/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

clang = find_program('clang', native: true, required: false, disabler: true)
if not clang.found()
warning('unable to find clang; disabling tests')
endif

foreach arch : ['aarch64', 'x86_64']
subdir(arch)

testcc = [clang, '--target=@0@'.format(triple), '-nostdlib', '-static', '-fuse-ld=lld']
testrun = run_command(testcc + ['-o', '/dev/null', files('empty.s')], check: false)
if testrun.returncode() != 0
warning('defunctional @0@ Clang/LLD; disabling tests'.format(arch))
continue
endif

foreach case : cases
name = '@0@-@1@'.format(arch, case.get('name'))
exec = custom_target(name,
input: case.get('src'),
output: name,
depfile: name + '.d',
command: testcc + ['-MD', '-MF', '@DEPFILE@', '-o', '@OUTPUT@', '@INPUT@'] + case.get('compile_args', []))
test(name, instrew, suite: [arch],
args: case.get('instrew_args', []) + [exec] + case.get('args', []),
should_fail: case.get('should_fail', false))
endforeach
endforeach
14 changes: 14 additions & 0 deletions test/x86_64/call-pop.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.intel_syntax noprefix
.text
.global _start
_start:
mov eax, 0x1000000
1: call 2f
2: pop rcx
sub eax, 1
jnz 1b

xor edi, edi
mov eax, 231
syscall
ud2
8 changes: 8 additions & 0 deletions test/x86_64/exit.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.intel_syntax noprefix
.text
.global _start
_start:
xor edi, edi
mov eax, 231
syscall
ud2
6 changes: 6 additions & 0 deletions test/x86_64/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
triple = 'x86_64-linux-gnu'
cases = [
{'name': 'exit', 'src': files('exit.S')},
{'name': 'call-pop', 'src': files('call-pop.S')},
{'name': 'nowrite', 'src': files('nowrite.S'), 'should_fail': true},
]
13 changes: 13 additions & 0 deletions test/x86_64/nowrite.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.intel_syntax noprefix
.text
.global _start
_start:
mov byte ptr [rip + data], 0
// should not be reached
xor edi, edi
mov eax, 231
syscall

.rodata
data:
.byte 0xff

0 comments on commit da679f4

Please sign in to comment.