diff options
author | Nikolaus Rath <Nikolaus@rath.org> | 2017-01-05 09:37:00 -0800 |
---|---|---|
committer | Nikolaus Rath <Nikolaus@rath.org> | 2017-01-12 15:19:04 -0800 |
commit | 9f96db71252fc66b72c433e2ca0d49e031c6a5fd (patch) | |
tree | 494132dae14dba3de18a9013f2299cfc37cceda5 /test | |
parent | 3006686b536942f6f96675e3d12b793087e78e6a (diff) |
Added experimental support for building with Meson+Ninja
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/meson.build | 35 | ||||
-rwxr-xr-x | test/test_examples.py | 2 | ||||
-rw-r--r-- | test/test_syscalls.c (renamed from test/test.c) | 0 | ||||
-rw-r--r-- | test/util.py | 7 | ||||
-rw-r--r-- | test/wrong_command.c | 10 |
6 files changed, 53 insertions, 6 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 9eb0a73..6bcea43 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,7 +1,10 @@ ## Process this file with automake to produce Makefile.in AM_CPPFLAGS = -I$(top_srcdir)/include -D_REENTRANT -noinst_PROGRAMS = test test_write_cache test_setattr +noinst_PROGRAMS = test_syscalls test_write_cache test_setattr test_write_cache_LDADD = ../lib/libfuse3.la test_setattr_LDADD = ../lib/libfuse3.la + +EXTRA_DIST = meson.build wrong_command.c + diff --git a/test/meson.build b/test/meson.build new file mode 100644 index 0000000..971c64a --- /dev/null +++ b/test/meson.build @@ -0,0 +1,35 @@ +# Attention, emacs, please use -*- mode: python -*- +# (even though this isn't actually Python code) + +# Compile helper programs +td = [] +foreach prog: [ 'test_write_cache', 'test_setattr' ] + td += executable(prog, prog + '.c', + include_directories: include_dirs, + link_with: [ libfuse ], + dependencies: thread_dep, + install: false) +endforeach +td += executable('test_syscalls', 'test_syscalls.c', + include_directories: include_dirs, + install: false) + +# Actual tests are written in Python and can simply be copied. +foreach fname : [ 'conftest.py', 'pytest.ini', 'test_examples.py', + 'util.py' ] + td += custom_target(fname, input: fname, output: fname, + command: ['cp', '-fP', '--preserve=mode', + '@INPUT@', '@OUTPUT@']) +endforeach + +# Create a new 'tests' target that we can run with Ninja +run_target('tests', depends: td, + command: [ 'python3', '-m', 'pytest', + meson.current_build_dir() ]) + + +# Provide something helpful when running 'ninja test' +wrong_cmd = executable('wrong_command', 'wrong_command.c', + install: false) +test('wrong_cmd', wrong_cmd) + diff --git a/test/test_examples.py b/test/test_examples.py index cfd6734..92a67c0 100755 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -77,7 +77,7 @@ def test_passthrough(tmpdir, name, debug): wait_for_mount(mount_process, mnt_dir) work_dir = pjoin(mnt_dir, src_dir) - subprocess.check_call([ os.path.join(basename, 'test', 'test'), + subprocess.check_call([ os.path.join(basename, 'test', 'test_syscalls'), work_dir, ':' + src_dir ]) tst_write(work_dir) diff --git a/test/test.c b/test/test_syscalls.c index 281f218..281f218 100644 --- a/test/test.c +++ b/test/test_syscalls.c diff --git a/test/util.py b/test/util.py index 6bba9e2..48670bd 100644 --- a/test/util.py +++ b/test/util.py @@ -105,7 +105,7 @@ def fuse_test_marker(): return pytest.mark.uses_fuse() -# If valgrind and libtool are available, use them +# If valgrind is available, use it def has_program(name): try: ret = subprocess.call([name, '--version'], @@ -115,9 +115,8 @@ def has_program(name): return False return ret == 0 -if has_program('valgrind') and has_program('libtool'): - base_cmdline = [ 'libtool', '--mode=execute', - 'valgrind', '-q', '--' ] +if has_program('valgrind'): + base_cmdline = [ 'valgrind', '-q', '--' ] else: base_cmdline = [] diff --git a/test/wrong_command.c b/test/wrong_command.c new file mode 100644 index 0000000..ef835b3 --- /dev/null +++ b/test/wrong_command.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main(void) { + fprintf(stderr, "\x1B[31m\e[1m" + "This is not the command you are looking for.\n" + "You probably want to run 'ninja tests' instead " + "(note the 's' at the end).\n" + "\e[0m"); + return 1; +} |