diff options
Diffstat (limited to 'test cases/common/51 run target')
-rw-r--r-- | test cases/common/51 run target/.clang-format | 1 | ||||
-rw-r--r-- | test cases/common/51 run target/.clang-tidy | 0 | ||||
-rw-r--r-- | test cases/common/51 run target/check-env.py | 28 | ||||
-rwxr-xr-x | test cases/common/51 run target/check_exists.py | 7 | ||||
-rwxr-xr-x | test cases/common/51 run target/configure.in | 3 | ||||
-rw-r--r-- | test cases/common/51 run target/converter.py | 6 | ||||
-rwxr-xr-x | test cases/common/51 run target/fakeburner.py | 15 | ||||
-rw-r--r-- | test cases/common/51 run target/helloprinter.c | 11 | ||||
-rw-r--r-- | test cases/common/51 run target/meson.build | 112 | ||||
-rw-r--r-- | test cases/common/51 run target/subdir/textprinter.py | 3 |
10 files changed, 186 insertions, 0 deletions
diff --git a/test cases/common/51 run target/.clang-format b/test cases/common/51 run target/.clang-format new file mode 100644 index 0000000..9b3aa8b --- /dev/null +++ b/test cases/common/51 run target/.clang-format @@ -0,0 +1 @@ +BasedOnStyle: LLVM diff --git a/test cases/common/51 run target/.clang-tidy b/test cases/common/51 run target/.clang-tidy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/common/51 run target/.clang-tidy diff --git a/test cases/common/51 run target/check-env.py b/test cases/common/51 run target/check-env.py new file mode 100644 index 0000000..1c66ffa --- /dev/null +++ b/test cases/common/51 run target/check-env.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +import os, sys +from pathlib import Path + +assert 'MESON_SOURCE_ROOT' in os.environ +assert 'MESON_BUILD_ROOT' in os.environ +assert 'MESON_SUBDIR' in os.environ +assert 'MESONINTROSPECT' in os.environ +assert 'MY_ENV' in os.environ + +# Environment has absolute paths and argv has relative paths when using ninja +# backend and absolute paths when using vs backend. What matters is once +# resolved they point to same location. +env_source_root = Path(os.environ['MESON_SOURCE_ROOT']).resolve() +env_build_root = Path(os.environ['MESON_BUILD_ROOT']).resolve() +env_current_source_dir = Path(env_source_root, os.environ['MESON_SUBDIR']).resolve() + +print(sys.argv) +argv_paths = [Path(i).resolve() for i in sys.argv[1:]] +source_root, build_root, current_source_dir = argv_paths + +print(f'{source_root} == {env_source_root}') +assert source_root == env_source_root +print(f'{build_root} == {env_build_root}') +assert build_root == env_build_root +print(f'{current_source_dir} == {env_current_source_dir}') +assert current_source_dir == env_current_source_dir diff --git a/test cases/common/51 run target/check_exists.py b/test cases/common/51 run target/check_exists.py new file mode 100755 index 0000000..b6fc967 --- /dev/null +++ b/test cases/common/51 run target/check_exists.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 + +import os +import sys + +if not os.path.isfile(sys.argv[1]): + raise Exception("Couldn't find {!r}".format(sys.argv[1])) diff --git a/test cases/common/51 run target/configure.in b/test cases/common/51 run target/configure.in new file mode 100755 index 0000000..0d42d04 --- /dev/null +++ b/test cases/common/51 run target/configure.in @@ -0,0 +1,3 @@ +#!/usr/bin/env python3 + +print('Success')
\ No newline at end of file diff --git a/test cases/common/51 run target/converter.py b/test cases/common/51 run target/converter.py new file mode 100644 index 0000000..8dd31fe --- /dev/null +++ b/test cases/common/51 run target/converter.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +import sys + +with open(sys.argv[1], 'rb') as ifile, open(sys.argv[2], 'wb') as ofile: + ofile.write(ifile.read()) diff --git a/test cases/common/51 run target/fakeburner.py b/test cases/common/51 run target/fakeburner.py new file mode 100755 index 0000000..8b1f353 --- /dev/null +++ b/test cases/common/51 run target/fakeburner.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + + +import sys + +plain_arg = sys.argv[1] +_, filename, _ = plain_arg.split(':') +try: + with open(filename, 'rb') as f: + content = f.read() +except FileNotFoundError: + print('Could not open file. Missing dependency?') + sys.exit(1) +print('File opened, pretending to send it somewhere.') +print(len(content), 'bytes uploaded') diff --git a/test cases/common/51 run target/helloprinter.c b/test cases/common/51 run target/helloprinter.c new file mode 100644 index 0000000..4a6e0ac --- /dev/null +++ b/test cases/common/51 run target/helloprinter.c @@ -0,0 +1,11 @@ +#include<stdio.h> + +int main(int argc, char **argv) { + if(argc != 2) { + printf("I can not haz argument.\n"); + return 1; + } else { + printf("I can haz argument: %s\n", argv[1]); + } + return 0; +} diff --git a/test cases/common/51 run target/meson.build b/test cases/common/51 run target/meson.build new file mode 100644 index 0000000..dbb6732 --- /dev/null +++ b/test cases/common/51 run target/meson.build @@ -0,0 +1,112 @@ +project('run target', 'c') + +# Make it possible to run built programs. +# In cross builds exe_wrapper should be added if it exists. + +exe = executable('helloprinter', 'helloprinter.c') + +if not meson.is_cross_build() or meson.can_run_host_binaries() + run_target('runhello', + command : [exe, 'argument']) +endif + +converter = find_program('converter.py') + +hex = custom_target('exe.hex', + input : exe, + output : 'exe.hex', + command : [converter, '@INPUT@', '@OUTPUT@', + ], +) + +fakeburner = find_program('fakeburner.py') + +# These emulates the Arduino flasher application. It sandwiches the filename inside +# a packed argument. Thus we need to declare it manually. +run_target('upload', + command : [fakeburner, 'x:@0@:y'.format(exe.full_path())], + depends : exe, +) + +run_target('upload2', + command : [fakeburner, 'x:@0@:y'.format(hex.full_path())], + depends : hex, +) + +python3 = find_program('python3', required : false) +if not python3.found() + python3 = find_program('python') +endif + +run_target('py3hi', + command : [python3, '-c', 'print("I am Python3.")']) + +run_target('check_exists', + command : [find_program('check_exists.py'), files('helloprinter.c')]) + +run_target('check_exists', + command : [find_program('check_exists.py'), files('helloprinter.c')], + depends : disabler(), +) + +run_target('check_exists', + command : [disabler(), files('helloprinter.c')]) + +# What if the output of a custom_target is the command to +# execute. Obviously this will not work as hex is not an +# executable but test that the output is generated correctly. +run_target('donotrunme', + command : hex) + +# Ensure configure files can be passed +conf = configure_file( + input: 'configure.in', + output: 'configure', + configuration: configuration_data() +) + +run_target('configure_script', + command : conf +) + +custom_target('configure_script_ct', + command: conf, + output: 'dummy.txt', + capture: true) + +# Target names that clash with potential builtin functionality. +run_target('ctags', + command : converter) + +clangf = run_target('clang-format', + command : [converter, files('.clang-format'), meson.current_build_dir() / 'clang-format']) +custom_target('clang-tidy', + input: '.clang-tidy', + output: 'clang-tidy', + command : [converter, '@INPUT@', '@OUTPUT@']) +alias_target('clang-format-check', clangf) + +# Check we can pass env to the program. Also check some string substitutions +# that were added in 0.57.0 but not documented. This is documented behaviour +# since 0.57.1. +run_target('check-env', + command: [find_program('check-env.py'), '@SOURCE_ROOT@', '@BUILD_ROOT@', + '@CURRENT_SOURCE_DIR@'], + env: {'MY_ENV': '1'}, +) + +# Check some string substitutions that has always been done but never documented. +# Some projects have been relying on this implementation detail. This is +# documented behaviour since 0.57.1. +custom_target('check-env-ct', + command: [find_program('check-env.py'), '@SOURCE_ROOT@', '@BUILD_ROOT@', + '@CURRENT_SOURCE_DIR@'], + env: {'MESON_SOURCE_ROOT': meson.source_root(), + 'MESON_BUILD_ROOT': meson.build_root(), + 'MESON_SUBDIR': meson.current_source_dir(), + 'MESONINTROSPECT': 'fake value', + 'MY_ENV': '1'}, + output: 'check-env-ct', +) + +run_target('textprinter', command: ['subdir/textprinter.py']) diff --git a/test cases/common/51 run target/subdir/textprinter.py b/test cases/common/51 run target/subdir/textprinter.py new file mode 100644 index 0000000..3159c08 --- /dev/null +++ b/test cases/common/51 run target/subdir/textprinter.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python3 + +print('I am a script. Being run.') |