diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-29 04:41:38 +0000 |
commit | 7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch) | |
tree | 4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/unit | |
parent | Initial commit. (diff) | |
download | meson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.tar.xz meson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.zip |
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test cases/unit')
514 files changed, 4058 insertions, 0 deletions
diff --git a/test cases/unit/1 soname/CMakeLists.txt b/test cases/unit/1 soname/CMakeLists.txt new file mode 100644 index 0000000..c4f2e3e --- /dev/null +++ b/test cases/unit/1 soname/CMakeLists.txt @@ -0,0 +1,26 @@ +# This is a CMake version of this test. It behaves slightly differently +# so in case you ever need to debug this, here it is. +# +# The biggest difference is that if SOVERSION is not set, it +# is set to VERSION. Autotools sets it to the first number +# of VERSION. That is, for version number 1.2.3 CMake sets +# soname to 1.2.3 but Autotools sets it to 1. + +project(vertest C) +cmake_minimum_required(VERSION 3.5) + +add_library(nover SHARED versioned.c) + +add_library(verset SHARED versioned.c) +set_target_properties(verset PROPERTIES VERSION 4.5.6) + +add_library(soverset SHARED versioned.c) +set_target_properties(soverset PROPERTIES SOVERSION 1.2.3) + +add_library(bothset SHARED versioned.c) +set_target_properties(bothset PROPERTIES SOVERSION 1.2.3) +set_target_properties(bothset PROPERTIES VERSION 4.5.6) + +add_library(settosame SHARED versioned.c) +set_target_properties(settosame PROPERTIES SOVERSION 7.8.9) +set_target_properties(settosame PROPERTIES VERSION 7.8.9) diff --git a/test cases/unit/1 soname/main.c b/test cases/unit/1 soname/main.c new file mode 100644 index 0000000..f5ccbb9 --- /dev/null +++ b/test cases/unit/1 soname/main.c @@ -0,0 +1,5 @@ +int versioned_func (void); + +int main (void) { + return versioned_func(); +} diff --git a/test cases/unit/1 soname/meson.build b/test cases/unit/1 soname/meson.build new file mode 100644 index 0000000..44b003a --- /dev/null +++ b/test cases/unit/1 soname/meson.build @@ -0,0 +1,35 @@ +project('vertest', 'c') + +shared_library('nover', 'versioned.c', + install : true) + +shared_library('verset', 'versioned.c', + install : true, + version : '4.5.6') + +shared_library('soverset', 'versioned.c', + install : true, + soversion : '1.2.3') + +shared_library('bothset', 'versioned.c', + install : true, + soversion : '1.2.3', + version : '4.5.6') + +shared_library('settosame', 'versioned.c', + install : true, + soversion : '7.8.9', + version : '7.8.9') + +shared_module('some_module', 'versioned.c', + install: true) + +module1 = shared_module('linked_module1', 'versioned.c', + install: true) + +module2 = shared_module('linked_module2', 'versioned.c', + install: true) +module2_dep = declare_dependency(link_with: module2) + +executable('main1', 'main.c', link_with: module1) +executable('main2', 'main.c', dependencies: module2_dep) diff --git a/test cases/unit/1 soname/versioned.c b/test cases/unit/1 soname/versioned.c new file mode 100644 index 0000000..f48d2b0 --- /dev/null +++ b/test cases/unit/1 soname/versioned.c @@ -0,0 +1,3 @@ +int versioned_func() { + return 0; +} diff --git a/test cases/unit/10 build_rpath/meson.build b/test cases/unit/10 build_rpath/meson.build new file mode 100644 index 0000000..c0bc3bd --- /dev/null +++ b/test cases/unit/10 build_rpath/meson.build @@ -0,0 +1,16 @@ +project('build rpath', 'c', 'cpp') + +subdir('sub') +executable('prog', 'prog.c', + link_with : l, + build_rpath : '/foo/bar', + install_rpath : '/baz', + install : true, + ) + +executable('progcxx', 'prog.cc', + link_with : l, + build_rpath : '/foo/bar', + install_rpath : 'baz', + install : true, + ) diff --git a/test cases/unit/10 build_rpath/prog.c b/test cases/unit/10 build_rpath/prog.c new file mode 100644 index 0000000..45b2fa3 --- /dev/null +++ b/test cases/unit/10 build_rpath/prog.c @@ -0,0 +1,5 @@ +int get_stuff(); + +int main(int argc, char **argv) { + return get_stuff(); +} diff --git a/test cases/unit/10 build_rpath/prog.cc b/test cases/unit/10 build_rpath/prog.cc new file mode 100644 index 0000000..c7c2123 --- /dev/null +++ b/test cases/unit/10 build_rpath/prog.cc @@ -0,0 +1,8 @@ +#include <string> +#include <iostream> + +int main(int argc, char **argv) { + std::string* s = new std::string("Hello"); + delete s; + return 0; +} diff --git a/test cases/unit/10 build_rpath/sub/meson.build b/test cases/unit/10 build_rpath/sub/meson.build new file mode 100644 index 0000000..6879ec6 --- /dev/null +++ b/test cases/unit/10 build_rpath/sub/meson.build @@ -0,0 +1 @@ +l = shared_library('stuff', 'stuff.c') diff --git a/test cases/unit/10 build_rpath/sub/stuff.c b/test cases/unit/10 build_rpath/sub/stuff.c new file mode 100644 index 0000000..d56d8b0 --- /dev/null +++ b/test cases/unit/10 build_rpath/sub/stuff.c @@ -0,0 +1,3 @@ +int get_stuff() { + return 0; +} diff --git a/test cases/unit/100 relative find program/foo.py b/test cases/unit/100 relative find program/foo.py new file mode 100755 index 0000000..21239b7 --- /dev/null +++ b/test cases/unit/100 relative find program/foo.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python3 + +exit(0)
\ No newline at end of file diff --git a/test cases/unit/100 relative find program/meson.build b/test cases/unit/100 relative find program/meson.build new file mode 100644 index 0000000..5745d8a --- /dev/null +++ b/test cases/unit/100 relative find program/meson.build @@ -0,0 +1,3 @@ +project('relative find program') + +subdir('subdir')
\ No newline at end of file diff --git a/test cases/unit/100 relative find program/subdir/meson.build b/test cases/unit/100 relative find program/subdir/meson.build new file mode 100644 index 0000000..475f5f5 --- /dev/null +++ b/test cases/unit/100 relative find program/subdir/meson.build @@ -0,0 +1,2 @@ +prog = find_program('./foo.py', required: false) +assert(not prog.found())
\ No newline at end of file diff --git a/test cases/unit/101 rlib linkage/lib2.rs b/test cases/unit/101 rlib linkage/lib2.rs new file mode 100644 index 0000000..3487bc5 --- /dev/null +++ b/test cases/unit/101 rlib linkage/lib2.rs @@ -0,0 +1,5 @@ +use lib; + +pub fn fun() { + lib::fun(); +} diff --git a/test cases/unit/101 rlib linkage/main.rs b/test cases/unit/101 rlib linkage/main.rs new file mode 100644 index 0000000..d0f82e4 --- /dev/null +++ b/test cases/unit/101 rlib linkage/main.rs @@ -0,0 +1,5 @@ +use lib2::fun; + +fn main() { + fun(); +} diff --git a/test cases/unit/101 rlib linkage/meson.build b/test cases/unit/101 rlib linkage/meson.build new file mode 100644 index 0000000..2d15b2a --- /dev/null +++ b/test cases/unit/101 rlib linkage/meson.build @@ -0,0 +1,22 @@ +project('rlib linkage', 'rust', default_options : ['rust_std=2018']) + +lib = static_library( + 'lib', + 'lib.rs', + rust_crate_type : 'rlib', +) + +lib2 = static_library( + 'lib2', + 'lib2.rs', + rust_crate_type : 'rlib', + link_with : lib, +) + +exe = executable( + 'exe', + 'main.rs', + link_with : lib2, +) + +test('main', exe) diff --git a/test cases/unit/102 python without pkgconfig/meson.build b/test cases/unit/102 python without pkgconfig/meson.build new file mode 100644 index 0000000..014a617 --- /dev/null +++ b/test cases/unit/102 python without pkgconfig/meson.build @@ -0,0 +1,4 @@ +project('python without pkgconfig', 'c') + +# This unit test is ran with PKG_CONFIG=notfound +import('python').find_installation().dependency() diff --git a/test cases/unit/103 strip/lib.c b/test cases/unit/103 strip/lib.c new file mode 100644 index 0000000..7d8163c --- /dev/null +++ b/test cases/unit/103 strip/lib.c @@ -0,0 +1,3 @@ +#include <stdio.h> + +void func(void){ fprintf(stderr, "Test 1 2 3\n"); } diff --git a/test cases/unit/103 strip/meson.build b/test cases/unit/103 strip/meson.build new file mode 100644 index 0000000..dff61ab --- /dev/null +++ b/test cases/unit/103 strip/meson.build @@ -0,0 +1,3 @@ +project('strip', 'c') + +shared_library('a', 'lib.c', install: true) diff --git a/test cases/unit/104 debug function/meson.build b/test cases/unit/104 debug function/meson.build new file mode 100644 index 0000000..c3f4c76 --- /dev/null +++ b/test cases/unit/104 debug function/meson.build @@ -0,0 +1,4 @@ +project('debug function', 'c') + +debug('This is an example debug output, should only end up in debug log') +debug('Test logging other things', true, 1, ['Array'], {'Key' : 'Value'}) diff --git a/test cases/unit/105 pkgconfig relocatable with absolute path/meson.build b/test cases/unit/105 pkgconfig relocatable with absolute path/meson.build new file mode 100644 index 0000000..ff21286 --- /dev/null +++ b/test cases/unit/105 pkgconfig relocatable with absolute path/meson.build @@ -0,0 +1,15 @@ +project( + 'pkgconfig-relocatable-with-absolute-path', + version : '1.0', + default_options: [ + 'pkgconfig.relocatable=true', + ]) + +pkgg = import('pkgconfig') + +pkgg.generate( + name : 'libsimple', + version : '1.0', + description : 'A simple pkgconfig.', + install_dir: get_option('prefix')/'share/misc/pkgconfig', +) diff --git a/test cases/unit/106 subproject symlink/cp.py b/test cases/unit/106 subproject symlink/cp.py new file mode 100644 index 0000000..adb0547 --- /dev/null +++ b/test cases/unit/106 subproject symlink/cp.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +from sys import argv +from shutil import copy + +copy(argv[1], argv[2]) diff --git a/test cases/unit/106 subproject symlink/main.c b/test cases/unit/106 subproject symlink/main.c new file mode 100644 index 0000000..62bd4b4 --- /dev/null +++ b/test cases/unit/106 subproject symlink/main.c @@ -0,0 +1,6 @@ +extern int foo(void); + +int main(void) +{ + return foo(); +} diff --git a/test cases/unit/106 subproject symlink/meson.build b/test cases/unit/106 subproject symlink/meson.build new file mode 100644 index 0000000..6766c8e --- /dev/null +++ b/test cases/unit/106 subproject symlink/meson.build @@ -0,0 +1,15 @@ +project('foo', 'c') + +symlinked_subproject = subproject('symlinked_subproject').get_variable('dep') + +executable('foo', + sources : 'main.c', + dependencies : symlinked_subproject +) + +custom_target( + input : symlinked_subproject.get_variable('datadir') / 'datafile', + output : 'datafile_copy', + command : [find_program('cp.py'), '@INPUT@', '@OUTPUT@'], + build_always : true +) diff --git a/test cases/unit/106 subproject symlink/symlinked_subproject/datadir/datafile b/test cases/unit/106 subproject symlink/symlinked_subproject/datadir/datafile new file mode 100644 index 0000000..6a68294 --- /dev/null +++ b/test cases/unit/106 subproject symlink/symlinked_subproject/datadir/datafile @@ -0,0 +1 @@ +hello meson diff --git a/test cases/unit/106 subproject symlink/symlinked_subproject/datadir/meson.build b/test cases/unit/106 subproject symlink/symlinked_subproject/datadir/meson.build new file mode 100644 index 0000000..cbeb0a9 --- /dev/null +++ b/test cases/unit/106 subproject symlink/symlinked_subproject/datadir/meson.build @@ -0,0 +1 @@ +install_data('datafile') diff --git a/test cases/unit/106 subproject symlink/symlinked_subproject/meson.build b/test cases/unit/106 subproject symlink/symlinked_subproject/meson.build new file mode 100644 index 0000000..3930465 --- /dev/null +++ b/test cases/unit/106 subproject symlink/symlinked_subproject/meson.build @@ -0,0 +1,10 @@ +project('symlinked_subproject', 'c', version : '1.0.0') + +dep = declare_dependency( + sources : 'src.c', + variables : { + 'datadir': meson.current_source_dir() / 'datadir' + } +) + +subdir('datadir') diff --git a/test cases/unit/106 subproject symlink/symlinked_subproject/src.c b/test cases/unit/106 subproject symlink/symlinked_subproject/src.c new file mode 100644 index 0000000..97d7ad1 --- /dev/null +++ b/test cases/unit/106 subproject symlink/symlinked_subproject/src.c @@ -0,0 +1,4 @@ +int foo(void) +{ + return 0; +} diff --git a/test cases/unit/107 new subproject on reconfigure/meson.build b/test cases/unit/107 new subproject on reconfigure/meson.build new file mode 100644 index 0000000..7342c9a --- /dev/null +++ b/test cases/unit/107 new subproject on reconfigure/meson.build @@ -0,0 +1,3 @@ +project('New subproject on reconfigure') + +subproject('foo', required: get_option('foo')) diff --git a/test cases/unit/107 new subproject on reconfigure/meson_options.txt b/test cases/unit/107 new subproject on reconfigure/meson_options.txt new file mode 100644 index 0000000..b3dd683 --- /dev/null +++ b/test cases/unit/107 new subproject on reconfigure/meson_options.txt @@ -0,0 +1 @@ +option('foo', type: 'feature', value: 'disabled') diff --git a/test cases/unit/107 new subproject on reconfigure/subprojects/foo/foo.c b/test cases/unit/107 new subproject on reconfigure/subprojects/foo/foo.c new file mode 100644 index 0000000..1edf995 --- /dev/null +++ b/test cases/unit/107 new subproject on reconfigure/subprojects/foo/foo.c @@ -0,0 +1,2 @@ +void foo(void); +void foo(void) {} diff --git a/test cases/unit/107 new subproject on reconfigure/subprojects/foo/meson.build b/test cases/unit/107 new subproject on reconfigure/subprojects/foo/meson.build new file mode 100644 index 0000000..2a6e30a --- /dev/null +++ b/test cases/unit/107 new subproject on reconfigure/subprojects/foo/meson.build @@ -0,0 +1,8 @@ +project('foo', 'c') + +# Ensure that builtin options have been initialised. +assert(get_option('default_library') == 'shared') + +# This uses default_library option internally and used to cause a crash: +# https://github.com/mesonbuild/meson/issues/10225. +library('foo', 'foo.c') diff --git a/test cases/unit/108 configure same noop/meson.build b/test cases/unit/108 configure same noop/meson.build new file mode 100644 index 0000000..d3f1326 --- /dev/null +++ b/test cases/unit/108 configure same noop/meson.build @@ -0,0 +1 @@ +project('configure same noop test') diff --git a/test cases/unit/108 configure same noop/meson_options.txt b/test cases/unit/108 configure same noop/meson_options.txt new file mode 100644 index 0000000..c406af2 --- /dev/null +++ b/test cases/unit/108 configure same noop/meson_options.txt @@ -0,0 +1,5 @@ +option( + 'opt', + type : 'string', + value: '', +) diff --git a/test cases/unit/109 freeze/freeze.c b/test cases/unit/109 freeze/freeze.c new file mode 100644 index 0000000..0a45c1a --- /dev/null +++ b/test cases/unit/109 freeze/freeze.c @@ -0,0 +1,21 @@ +#include<stdio.h> +#include <signal.h> +#include <string.h> +#include <stdlib.h> + +static void do_nothing(int signo, siginfo_t *info, void *context) { +} + +int main(int argc, char **argv) { + struct sigaction sa; + memset(&sa, 0, sizeof(struct sigaction)); + sa.sa_sigaction = do_nothing; + if (sigaction(SIGTERM, &sa, NULL) == -1) { + printf("Could not set up signal handler.\n"); + return 1; + } + printf("Freezing forever.\n"); + while(1) { + } + return 0; +} diff --git a/test cases/unit/109 freeze/meson.build b/test cases/unit/109 freeze/meson.build new file mode 100644 index 0000000..1a84f37 --- /dev/null +++ b/test cases/unit/109 freeze/meson.build @@ -0,0 +1,4 @@ +project('freeze', 'c') + +e = executable('freeze', 'freeze.c') +test('freeze', e, timeout: 1) diff --git a/test cases/unit/11 cross prog/meson.build b/test cases/unit/11 cross prog/meson.build new file mode 100644 index 0000000..192169a --- /dev/null +++ b/test cases/unit/11 cross prog/meson.build @@ -0,0 +1,16 @@ +project('cross find program', 'c') + +native_exe = find_program('sometool.py', native : true) +cross_exe = find_program('sometool.py') +cross_other_exe = find_program('someothertool.py') + +native_out = run_command(native_exe, check: true).stdout().strip() +cross_out = run_command(cross_exe, check: true).stdout().strip() +cross_other_out = run_command(cross_other_exe, check: true).stdout().strip() + +assert(native_out == 'native', + 'Native output incorrect:' + native_out) +assert(cross_out == 'cross', + 'Cross output incorrect:' + cross_out) +assert(cross_out == cross_other_out, + 'Cross output incorrect:' + cross_other_out) diff --git a/test cases/unit/11 cross prog/some_cross_tool.py b/test cases/unit/11 cross prog/some_cross_tool.py new file mode 100755 index 0000000..6c01b1a --- /dev/null +++ b/test cases/unit/11 cross prog/some_cross_tool.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 + + +print('cross') diff --git a/test cases/unit/11 cross prog/sometool.py b/test cases/unit/11 cross prog/sometool.py new file mode 100755 index 0000000..06bcdc8 --- /dev/null +++ b/test cases/unit/11 cross prog/sometool.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 + + +print('native') diff --git a/test cases/unit/110 classpath/com/mesonbuild/Simple.java b/test cases/unit/110 classpath/com/mesonbuild/Simple.java new file mode 100644 index 0000000..325a49a --- /dev/null +++ b/test cases/unit/110 classpath/com/mesonbuild/Simple.java @@ -0,0 +1,7 @@ +package com.mesonbuild; + +class Simple { + public static void main(String [] args) { + System.out.println("Java is working.\n"); + } +} diff --git a/test cases/unit/110 classpath/meson.build b/test cases/unit/110 classpath/meson.build new file mode 100644 index 0000000..e6b9b84 --- /dev/null +++ b/test cases/unit/110 classpath/meson.build @@ -0,0 +1,14 @@ +project('simplejava', 'java') + +one = jar('one', 'com/mesonbuild/Simple.java', + main_class : 'com.mesonbuild.Simple', + install : true, + install_dir : get_option('bindir'), +) + +two = jar('two', 'com/mesonbuild/Simple.java', + main_class : 'com.mesonbuild.Simple', + install : true, + install_dir : get_option('bindir'), + link_with : one, +) diff --git a/test cases/unit/12 promote/meson.build b/test cases/unit/12 promote/meson.build new file mode 100644 index 0000000..5012bf6 --- /dev/null +++ b/test cases/unit/12 promote/meson.build @@ -0,0 +1,4 @@ +project('promotion test', 'c') + +subproject('s1') +subproject('s2') diff --git a/test cases/unit/12 promote/subprojects/s1/meson.build b/test cases/unit/12 promote/subprojects/s1/meson.build new file mode 100644 index 0000000..88c467b --- /dev/null +++ b/test cases/unit/12 promote/subprojects/s1/meson.build @@ -0,0 +1,7 @@ +project('s1', 'c') + +sc = subproject('scommon') +s3 = subproject('s3') + +executable('s1', 's1.c', + link_with : [sc.get_variable('clib'), s3.get_variable('l')]) diff --git a/test cases/unit/12 promote/subprojects/s1/s1.c b/test cases/unit/12 promote/subprojects/s1/s1.c new file mode 100644 index 0000000..7d1d775 --- /dev/null +++ b/test cases/unit/12 promote/subprojects/s1/s1.c @@ -0,0 +1,6 @@ +int func(); +int func2(); + +int main(int argc, char **argv) { + return func() + func2(); +} diff --git a/test cases/unit/12 promote/subprojects/s1/subprojects/s3/meson.build b/test cases/unit/12 promote/subprojects/s1/subprojects/s3/meson.build new file mode 100644 index 0000000..71db691 --- /dev/null +++ b/test cases/unit/12 promote/subprojects/s1/subprojects/s3/meson.build @@ -0,0 +1,3 @@ +project('s3', 'c') + +l = static_library('s3', 's3.c') diff --git a/test cases/unit/12 promote/subprojects/s1/subprojects/s3/s3.c b/test cases/unit/12 promote/subprojects/s1/subprojects/s3/s3.c new file mode 100644 index 0000000..0166603 --- /dev/null +++ b/test cases/unit/12 promote/subprojects/s1/subprojects/s3/s3.c @@ -0,0 +1,3 @@ +int func2() { + return -42; +} diff --git a/test cases/unit/12 promote/subprojects/s1/subprojects/scommon/meson.build b/test cases/unit/12 promote/subprojects/s1/subprojects/scommon/meson.build new file mode 100644 index 0000000..8ca550a --- /dev/null +++ b/test cases/unit/12 promote/subprojects/s1/subprojects/scommon/meson.build @@ -0,0 +1,3 @@ +project('scommon', 'c') + +clib = static_library('scommon', 'scommon_broken.c') diff --git a/test cases/unit/12 promote/subprojects/s1/subprojects/scommon/scommon_broken.c b/test cases/unit/12 promote/subprojects/s1/subprojects/scommon/scommon_broken.c new file mode 100644 index 0000000..3665a9c --- /dev/null +++ b/test cases/unit/12 promote/subprojects/s1/subprojects/scommon/scommon_broken.c @@ -0,0 +1 @@ +#error This file must not be used. The other scommon one should be instead. diff --git a/test cases/unit/12 promote/subprojects/s2/meson.build b/test cases/unit/12 promote/subprojects/s2/meson.build new file mode 100644 index 0000000..4aaeb59 --- /dev/null +++ b/test cases/unit/12 promote/subprojects/s2/meson.build @@ -0,0 +1,5 @@ +project('s2', 'c') + +sc = subproject('scommon') + +executable('s2', 's2.c', link_with : sc.get_variable('clib')) diff --git a/test cases/unit/12 promote/subprojects/s2/s2.c b/test cases/unit/12 promote/subprojects/s2/s2.c new file mode 100644 index 0000000..2a6d1e6 --- /dev/null +++ b/test cases/unit/12 promote/subprojects/s2/s2.c @@ -0,0 +1,6 @@ +int func(); + + +int main(int argc, char **argv) { + return func() != 42; +} diff --git a/test cases/unit/12 promote/subprojects/s2/subprojects/athing.wrap b/test cases/unit/12 promote/subprojects/s2/subprojects/athing.wrap new file mode 100644 index 0000000..11b2178 --- /dev/null +++ b/test cases/unit/12 promote/subprojects/s2/subprojects/athing.wrap @@ -0,0 +1 @@ +[wrap-file] diff --git a/test cases/unit/12 promote/subprojects/s2/subprojects/scommon/meson.build b/test cases/unit/12 promote/subprojects/s2/subprojects/scommon/meson.build new file mode 100644 index 0000000..54049a8 --- /dev/null +++ b/test cases/unit/12 promote/subprojects/s2/subprojects/scommon/meson.build @@ -0,0 +1,3 @@ +project('scommon', 'c') + +clib = static_library('scommon', 'scommon_ok.c') diff --git a/test cases/unit/12 promote/subprojects/s2/subprojects/scommon/scommon_ok.c b/test cases/unit/12 promote/subprojects/s2/subprojects/scommon/scommon_ok.c new file mode 100644 index 0000000..652f4eb --- /dev/null +++ b/test cases/unit/12 promote/subprojects/s2/subprojects/scommon/scommon_ok.c @@ -0,0 +1,3 @@ +int func() { + return 42; +} diff --git a/test cases/unit/13 reconfigure/meson.build b/test cases/unit/13 reconfigure/meson.build new file mode 100644 index 0000000..453644a --- /dev/null +++ b/test cases/unit/13 reconfigure/meson.build @@ -0,0 +1,5 @@ +project('reconfigure test', ['c']) + +if get_option('b_coverage') != true + error('b_coverage not set') +endif diff --git a/test cases/unit/14 testsetup selection/main.c b/test cases/unit/14 testsetup selection/main.c new file mode 100644 index 0000000..9b6bdc2 --- /dev/null +++ b/test cases/unit/14 testsetup selection/main.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/test cases/unit/14 testsetup selection/meson.build b/test cases/unit/14 testsetup selection/meson.build new file mode 100644 index 0000000..ae996c5 --- /dev/null +++ b/test cases/unit/14 testsetup selection/meson.build @@ -0,0 +1,10 @@ +project('main', 'c') + +main = executable('main', 'main.c') +test('Test main', main) + +add_test_setup('worksforall') +add_test_setup('missingfromfoo') + +subproject('foo') +subproject('bar') diff --git a/test cases/unit/14 testsetup selection/subprojects/bar/bar.c b/test cases/unit/14 testsetup selection/subprojects/bar/bar.c new file mode 100644 index 0000000..9b6bdc2 --- /dev/null +++ b/test cases/unit/14 testsetup selection/subprojects/bar/bar.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/test cases/unit/14 testsetup selection/subprojects/bar/meson.build b/test cases/unit/14 testsetup selection/subprojects/bar/meson.build new file mode 100644 index 0000000..1155a88 --- /dev/null +++ b/test cases/unit/14 testsetup selection/subprojects/bar/meson.build @@ -0,0 +1,6 @@ +project('bar', 'c') +bar = executable('bar', 'bar.c') +test('Test bar', bar) +add_test_setup('onlyinbar') +add_test_setup('worksforall') +add_test_setup('missingfromfoo') diff --git a/test cases/unit/14 testsetup selection/subprojects/foo/foo.c b/test cases/unit/14 testsetup selection/subprojects/foo/foo.c new file mode 100644 index 0000000..9b6bdc2 --- /dev/null +++ b/test cases/unit/14 testsetup selection/subprojects/foo/foo.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/test cases/unit/14 testsetup selection/subprojects/foo/meson.build b/test cases/unit/14 testsetup selection/subprojects/foo/meson.build new file mode 100644 index 0000000..2eef840 --- /dev/null +++ b/test cases/unit/14 testsetup selection/subprojects/foo/meson.build @@ -0,0 +1,4 @@ +project('foo', 'c') +foo = executable('foo', 'foo.c') +test('Test foo', foo) +add_test_setup('worksforall') diff --git a/test cases/unit/15 prebuilt object/cp.py b/test cases/unit/15 prebuilt object/cp.py new file mode 100644 index 0000000..cb09cf3 --- /dev/null +++ b/test cases/unit/15 prebuilt object/cp.py @@ -0,0 +1,5 @@ +#! /usr/bin/env python3 + +import sys +from shutil import copyfile +copyfile(*sys.argv[1:]) diff --git a/test cases/unit/15 prebuilt object/main.c b/test cases/unit/15 prebuilt object/main.c new file mode 100644 index 0000000..480bda5 --- /dev/null +++ b/test cases/unit/15 prebuilt object/main.c @@ -0,0 +1,5 @@ +int func(); + +int main(int argc, char **argv) { + return func() == 42 ? 0 : 99; +} diff --git a/test cases/unit/15 prebuilt object/meson.build b/test cases/unit/15 prebuilt object/meson.build new file mode 100644 index 0000000..b542d1c --- /dev/null +++ b/test cases/unit/15 prebuilt object/meson.build @@ -0,0 +1,40 @@ +# This test is on its own because it is special. +# To run the test you need the prebuilt object +# file for the given platform. +# +# Combined with cross compilation this would make +# the state space explode so let's just keep this +# in its own subdir so it's not run during cross +# compilation tests. + +project('prebuilt object', 'c') + +if host_machine.system() == 'windows' + prebuilt = 'prebuilt.obj' +else + prebuilt = 'prebuilt.o' +endif + +# Remember: do not put source.c in this +# declaration. run_tests.py generates the +# prebuilt object before running this test. + +e = [] + +e += executable('exe1', sources: 'main.c', objects: prebuilt) +e += executable('exe2', sources: 'main.c', objects: files(prebuilt)) + +sl1 = static_library('lib3', objects: prebuilt) +e += executable('exe3', sources: 'main.c', objects: sl1.extract_all_objects(recursive: true)) + +ct = custom_target(output: 'copy-' + prebuilt, input: prebuilt, + command: [find_program('cp.py'), '@INPUT@', '@OUTPUT@']) +e += executable('exe4', 'main.c', ct) +e += executable('exe5', 'main.c', ct[0]) + +sl2 = static_library('lib6', sources: ct) +e += executable('exe6', sources: 'main.c', objects: sl2.extract_all_objects(recursive: true)) + +foreach i : e + test(i.name(), i) +endforeach diff --git a/test cases/unit/15 prebuilt object/source.c b/test cases/unit/15 prebuilt object/source.c new file mode 100644 index 0000000..f39b4f3 --- /dev/null +++ b/test cases/unit/15 prebuilt object/source.c @@ -0,0 +1,8 @@ +/* + * Compile this manually on new platforms and add the + * object file to revision control and Meson configuration. + */ + +int func() { + return 42; +} diff --git a/test cases/unit/16 prebuilt static/libdir/best.c b/test cases/unit/16 prebuilt static/libdir/best.c new file mode 100644 index 0000000..ab774e1 --- /dev/null +++ b/test cases/unit/16 prebuilt static/libdir/best.c @@ -0,0 +1,3 @@ +const char *msg() { + return "I am the best."; +} diff --git a/test cases/unit/16 prebuilt static/libdir/best.h b/test cases/unit/16 prebuilt static/libdir/best.h new file mode 100644 index 0000000..063017f --- /dev/null +++ b/test cases/unit/16 prebuilt static/libdir/best.h @@ -0,0 +1,3 @@ +#pragma once + +const char *msg(); diff --git a/test cases/unit/16 prebuilt static/libdir/meson.build b/test cases/unit/16 prebuilt static/libdir/meson.build new file mode 100644 index 0000000..8d74ccf --- /dev/null +++ b/test cases/unit/16 prebuilt static/libdir/meson.build @@ -0,0 +1,5 @@ +cc = meson.get_compiler('c') +stlib = cc.find_library('best', dirs : meson.current_source_dir()) + +best_dep = declare_dependency(dependencies : stlib, + include_directories : include_directories('.')) diff --git a/test cases/unit/16 prebuilt static/main.c b/test cases/unit/16 prebuilt static/main.c new file mode 100644 index 0000000..d172625 --- /dev/null +++ b/test cases/unit/16 prebuilt static/main.c @@ -0,0 +1,7 @@ +#include<stdio.h> +#include<best.h> + +int main(int argc, char **argv) { + printf("%s\n", msg()); + return 0; +} diff --git a/test cases/unit/16 prebuilt static/meson.build b/test cases/unit/16 prebuilt static/meson.build new file mode 100644 index 0000000..9ea1d0d --- /dev/null +++ b/test cases/unit/16 prebuilt static/meson.build @@ -0,0 +1,5 @@ +project('prebuilt static lib', 'c') + +subdir('libdir') + +test('static', executable('mainprog', 'main.c', dependencies : best_dep)) diff --git a/test cases/unit/17 prebuilt shared/alexandria.c b/test cases/unit/17 prebuilt shared/alexandria.c new file mode 100644 index 0000000..2d6b848 --- /dev/null +++ b/test cases/unit/17 prebuilt shared/alexandria.c @@ -0,0 +1,6 @@ +#include"alexandria.h" +#include<stdio.h> + +void alexandria_visit() { + printf("You are surrounded by wisdom and knowledge. You feel enlightened.\n"); +} diff --git a/test cases/unit/17 prebuilt shared/alexandria.h b/test cases/unit/17 prebuilt shared/alexandria.h new file mode 100644 index 0000000..6e507c5 --- /dev/null +++ b/test cases/unit/17 prebuilt shared/alexandria.h @@ -0,0 +1,20 @@ +#pragma once + +/* Both funcs here for simplicity. */ + +#if defined _WIN32 || defined __CYGWIN__ +#if defined BUILDING_DLL + #define DLL_PUBLIC __declspec(dllexport) +#else + #define DLL_PUBLIC __declspec(dllimport) +#endif +#else + #if defined __GNUC__ + #define DLL_PUBLIC __attribute__ ((visibility("default"))) + #else + #pragma message ("Compiler does not support symbol visibility.") + #define DLL_PUBLIC + #endif +#endif + +void DLL_PUBLIC alexandria_visit(); diff --git a/test cases/unit/17 prebuilt shared/another_visitor.c b/test cases/unit/17 prebuilt shared/another_visitor.c new file mode 100644 index 0000000..18e5f15 --- /dev/null +++ b/test cases/unit/17 prebuilt shared/another_visitor.c @@ -0,0 +1,10 @@ +#include<alexandria.h> +#include<stdio.h> + +int main(int argc, char **argv) { + printf("Ahh, another visitor. Stay a while.\n"); + printf("You enter the library.\n\n"); + alexandria_visit(); + printf("\nYou decided not to stay forever.\n"); + return 0; +} diff --git a/test cases/unit/17 prebuilt shared/meson.build b/test cases/unit/17 prebuilt shared/meson.build new file mode 100644 index 0000000..7badcb7 --- /dev/null +++ b/test cases/unit/17 prebuilt shared/meson.build @@ -0,0 +1,38 @@ +project('prebuilt shared library', 'c') + +search_dir = get_option('search_dir') +if search_dir == 'auto' + search_dir = meson.current_source_dir() +endif + +cc = meson.get_compiler('c') +shlib = cc.find_library('alexandria', dirs : search_dir) + +exe = executable('patron', 'patron.c', dependencies : shlib) +test('visitation', exe) + +d = declare_dependency(dependencies : shlib) + +exe2 = executable('another_visitor', 'another_visitor.c', + dependencies : d) +test('another', exe2) + +stlib = static_library( + 'rejected', + 'rejected.c', + dependencies : shlib, +) + +rejected = executable( + 'rejected', + 'rejected_main.c', + link_with : stlib, +) +test('rejected', rejected) + +rejected_whole = executable( + 'rejected_whole', + 'rejected_main.c', + link_whole : stlib, +) +test('rejected (whole archive)', rejected_whole) diff --git a/test cases/unit/17 prebuilt shared/meson_options.txt b/test cases/unit/17 prebuilt shared/meson_options.txt new file mode 100644 index 0000000..7876a6f --- /dev/null +++ b/test cases/unit/17 prebuilt shared/meson_options.txt @@ -0,0 +1 @@ +option('search_dir', type : 'string', value : 'auto') diff --git a/test cases/unit/17 prebuilt shared/patron.c b/test cases/unit/17 prebuilt shared/patron.c new file mode 100644 index 0000000..461d7b4 --- /dev/null +++ b/test cases/unit/17 prebuilt shared/patron.c @@ -0,0 +1,9 @@ +#include<alexandria.h> +#include<stdio.h> + +int main(int argc, char **argv) { + printf("You are standing outside the Great Library of Alexandria.\n"); + printf("You decide to go inside.\n\n"); + alexandria_visit(); + return 0; +} diff --git a/test cases/unit/17 prebuilt shared/rejected.c b/test cases/unit/17 prebuilt shared/rejected.c new file mode 100644 index 0000000..9d7ac94 --- /dev/null +++ b/test cases/unit/17 prebuilt shared/rejected.c @@ -0,0 +1,8 @@ +#include "rejected.h" + +void say(void) { + printf("You are standing outside the Great Library of Alexandria.\n"); + printf("You decide to go inside.\n\n"); + alexandria_visit(); + printf("The librarian tells you it's time to leave\n"); +} diff --git a/test cases/unit/17 prebuilt shared/rejected.h b/test cases/unit/17 prebuilt shared/rejected.h new file mode 100644 index 0000000..b9ccf31 --- /dev/null +++ b/test cases/unit/17 prebuilt shared/rejected.h @@ -0,0 +1,6 @@ +#include <stdio.h> +#include <alexandria.h> + +#pragma once + +void say(void); diff --git a/test cases/unit/17 prebuilt shared/rejected_main.c b/test cases/unit/17 prebuilt shared/rejected_main.c new file mode 100644 index 0000000..4d35061 --- /dev/null +++ b/test cases/unit/17 prebuilt shared/rejected_main.c @@ -0,0 +1,6 @@ +#include "rejected.h" + +int main(void) { + say(); + return 0; +} diff --git a/test cases/unit/18 pkgconfig static/foo.c b/test cases/unit/18 pkgconfig static/foo.c new file mode 100644 index 0000000..bf7fbdd --- /dev/null +++ b/test cases/unit/18 pkgconfig static/foo.c @@ -0,0 +1,8 @@ +int power_level (void) +{ +#ifdef FOO_STATIC + return 9001; +#else + return 8999; +#endif +} diff --git a/test cases/unit/18 pkgconfig static/foo.pc.in b/test cases/unit/18 pkgconfig static/foo.pc.in new file mode 100644 index 0000000..b26c0b0 --- /dev/null +++ b/test cases/unit/18 pkgconfig static/foo.pc.in @@ -0,0 +1,11 @@ +prefix=@PREFIX@ +libdir=${prefix} +includedir=${prefix}/include +datadir=${prefix}/data + +Name: libfoo +Description: A foo library. +Version: 1.0 +Libs: -L${libdir} -lfoo +Libs.private: -lm +Cflags: -I${includedir} diff --git a/test cases/unit/18 pkgconfig static/include/foo.h b/test cases/unit/18 pkgconfig static/include/foo.h new file mode 100644 index 0000000..88ef554 --- /dev/null +++ b/test cases/unit/18 pkgconfig static/include/foo.h @@ -0,0 +1,3 @@ +#pragma once + +int power_level (void); diff --git a/test cases/unit/18 pkgconfig static/main.c b/test cases/unit/18 pkgconfig static/main.c new file mode 100644 index 0000000..cc4649f --- /dev/null +++ b/test cases/unit/18 pkgconfig static/main.c @@ -0,0 +1,14 @@ +#include <foo.h> +#include <stdio.h> + +int +main (int argc, char * argv[]) +{ + int value = power_level (); + if (value < 9000) { + printf ("Power level is %i\n", value); + return 1; + } + printf ("IT'S OVER 9000!!!\n"); + return 0; +} diff --git a/test cases/unit/18 pkgconfig static/meson.build b/test cases/unit/18 pkgconfig static/meson.build new file mode 100644 index 0000000..d1b0fd5 --- /dev/null +++ b/test cases/unit/18 pkgconfig static/meson.build @@ -0,0 +1,37 @@ +project('pkg-config static', 'c') + +if build_machine.system() != 'windows' + prefix = meson.source_root() +else + # pkg-config files should not use paths with \ + prefix_parts = meson.source_root().split('\\') + # If the path is C:/foo/bar, convert it to /c/foo/bar so we can test if our + # automatic conversion to C:/foo/bar inside PkgConfigDependency is working. + if prefix_parts[0][1] == ':' + drive = prefix_parts[0][0] + else + drive = prefix_parts[0] + endif + new_parts = [] + foreach part : prefix_parts + if part != prefix_parts[0] + new_parts += part + endif + endforeach + prefix = '/@0@/@1@'.format(drive, '/'.join(new_parts)) +endif +message(prefix) + +# Escape spaces +prefix_parts = prefix.split(' ') +prefix = '\ '.join(prefix_parts) + +conf = configuration_data() +conf.set('PREFIX', prefix) +configure_file(input : 'foo.pc.in', + output : 'foo.pc', + configuration : conf) + +foo_dep = dependency('foo', static : true) + +test('footest', executable('foomain', 'main.c', dependencies : foo_dep)) diff --git a/test cases/unit/19 array option/meson.build b/test cases/unit/19 array option/meson.build new file mode 100644 index 0000000..2b44181 --- /dev/null +++ b/test cases/unit/19 array option/meson.build @@ -0,0 +1,15 @@ +# Copyright © 2017 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +project('array option test') diff --git a/test cases/unit/19 array option/meson_options.txt b/test cases/unit/19 array option/meson_options.txt new file mode 100644 index 0000000..0ccdcc4 --- /dev/null +++ b/test cases/unit/19 array option/meson_options.txt @@ -0,0 +1,20 @@ +# Copyright © 2017 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +option( + 'list', + type : 'array', + value : ['foo', 'bar'], + choices : ['foo', 'bar', 'oink', 'boink'], +) diff --git a/test cases/unit/2 testsetups/buggy.c b/test cases/unit/2 testsetups/buggy.c new file mode 100644 index 0000000..d238830 --- /dev/null +++ b/test cases/unit/2 testsetups/buggy.c @@ -0,0 +1,14 @@ +#include<stdio.h> +#include<stdlib.h> + +#include<impl.h> + +int main(int argc, char **argv) { + char *ten = malloc(10); + if(getenv("TEST_ENV")) { + do_nasty(ten); + printf("TEST_ENV is set.\n"); + } + free(ten); + return 0; +} diff --git a/test cases/unit/2 testsetups/envcheck.py b/test cases/unit/2 testsetups/envcheck.py new file mode 100755 index 0000000..e41a715 --- /dev/null +++ b/test cases/unit/2 testsetups/envcheck.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 + +import os + +assert 'PATH' in os.environ diff --git a/test cases/unit/2 testsetups/impl.c b/test cases/unit/2 testsetups/impl.c new file mode 100644 index 0000000..d87f3de --- /dev/null +++ b/test cases/unit/2 testsetups/impl.c @@ -0,0 +1,5 @@ +/* Write past the end. */ + +void do_nasty(char *ptr) { + ptr[10] = 'n'; +} diff --git a/test cases/unit/2 testsetups/impl.h b/test cases/unit/2 testsetups/impl.h new file mode 100644 index 0000000..7a08cb3 --- /dev/null +++ b/test cases/unit/2 testsetups/impl.h @@ -0,0 +1,3 @@ +#pragma once + +void do_nasty(char *ptr); diff --git a/test cases/unit/2 testsetups/meson.build b/test cases/unit/2 testsetups/meson.build new file mode 100644 index 0000000..91a5fbe --- /dev/null +++ b/test cases/unit/2 testsetups/meson.build @@ -0,0 +1,33 @@ +project('testsetups', 'c') + +vg = find_program('valgrind') + +cc = meson.get_compiler('c') +# clang 14 uses dwarf 5, and valgrind 3.19 GIT does not support this +if cc.get_id() == 'clang' and cc.version().version_compare('>=14') and \ + vg.version().version_compare('<3.20') + add_project_arguments('-gdwarf-4', language: 'c') +endif + +# This is only set when running under Valgrind test setup. +env = environment() +env.set('TEST_ENV', '1') + +add_test_setup('valgrind', + exe_wrapper : [vg, '--error-exitcode=1', '--leak-check=full'], + timeout_multiplier : 100, + env : env) + +buggy = executable('buggy', 'buggy.c', 'impl.c') +test('Test buggy', buggy, suite: ['buggy']) + +envcheck = find_program('envcheck.py') +test('test-env', envcheck) + +add_test_setup('empty') +add_test_setup('onlyenv', env : env) +add_test_setup('onlyenv2', env : 'TEST_ENV=1') +add_test_setup('onlyenv3', env : ['TEST_ENV=1']) +add_test_setup('wrapper', exe_wrapper : [vg, '--error-exitcode=1']) +add_test_setup('timeout', timeout_multiplier : 20) +add_test_setup('good', exclude_suites : 'buggy') diff --git a/test cases/unit/20 subproj dep variables/meson.build b/test cases/unit/20 subproj dep variables/meson.build new file mode 100644 index 0000000..954463b --- /dev/null +++ b/test cases/unit/20 subproj dep variables/meson.build @@ -0,0 +1,16 @@ +project('subproj found dep not found', 'c') + +dependency('somedep', required : false, + fallback : ['nosubproj', 'dep_name']) + +dependency('somedep', required : false, + fallback : ['failingsubproj', 'dep_name']) + +dependency('somenotfounddep', required : false, + fallback : ['somesubproj', 'dep_name']) + +dependency('zlibproxy', required : true, + fallback : ['somesubproj', 'zlibproxy_dep']) + +dependency('somedep', required : false, + fallback : ['nestedsubproj', 'nestedsubproj_dep']) diff --git a/test cases/unit/20 subproj dep variables/subprojects/failingsubproj/meson.build b/test cases/unit/20 subproj dep variables/subprojects/failingsubproj/meson.build new file mode 100644 index 0000000..3a84bd2 --- /dev/null +++ b/test cases/unit/20 subproj dep variables/subprojects/failingsubproj/meson.build @@ -0,0 +1,3 @@ +project('failingsubproj', 'c') + +dep_name = declare_dependency('arg') diff --git a/test cases/unit/20 subproj dep variables/subprojects/nestedsubproj/meson.build b/test cases/unit/20 subproj dep variables/subprojects/nestedsubproj/meson.build new file mode 100644 index 0000000..4bf549e --- /dev/null +++ b/test cases/unit/20 subproj dep variables/subprojects/nestedsubproj/meson.build @@ -0,0 +1,3 @@ +project('dep', 'c') + +subproject('subsubproject') diff --git a/test cases/unit/20 subproj dep variables/subprojects/nestedsubproj/subprojects/subsubproject.wrap b/test cases/unit/20 subproj dep variables/subprojects/nestedsubproj/subprojects/subsubproject.wrap new file mode 100644 index 0000000..11b2178 --- /dev/null +++ b/test cases/unit/20 subproj dep variables/subprojects/nestedsubproj/subprojects/subsubproject.wrap @@ -0,0 +1 @@ +[wrap-file] diff --git a/test cases/unit/20 subproj dep variables/subprojects/somesubproj/meson.build b/test cases/unit/20 subproj dep variables/subprojects/somesubproj/meson.build new file mode 100644 index 0000000..dd65c99 --- /dev/null +++ b/test cases/unit/20 subproj dep variables/subprojects/somesubproj/meson.build @@ -0,0 +1,3 @@ +project('dep', 'c') + +zlibproxy_dep = declare_dependency(dependencies : dependency('zlib', required : false)) diff --git a/test cases/unit/21 exit status/meson.build b/test cases/unit/21 exit status/meson.build new file mode 100644 index 0000000..4f5485b --- /dev/null +++ b/test cases/unit/21 exit status/meson.build @@ -0,0 +1,2 @@ +project('exit status') +exception() diff --git a/test cases/unit/22 warning location/a.c b/test cases/unit/22 warning location/a.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/22 warning location/a.c diff --git a/test cases/unit/22 warning location/b.c b/test cases/unit/22 warning location/b.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/22 warning location/b.c diff --git a/test cases/unit/22 warning location/conf.in b/test cases/unit/22 warning location/conf.in new file mode 100644 index 0000000..a2903ed --- /dev/null +++ b/test cases/unit/22 warning location/conf.in @@ -0,0 +1 @@ +@MISSING@ diff --git a/test cases/unit/22 warning location/main.c b/test cases/unit/22 warning location/main.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/22 warning location/main.c diff --git a/test cases/unit/22 warning location/meson.build b/test cases/unit/22 warning location/meson.build new file mode 100644 index 0000000..132939e --- /dev/null +++ b/test cases/unit/22 warning location/meson.build @@ -0,0 +1,11 @@ +project('warning location', 'c') +a = library('liba', 'a.c') +b = library('libb', 'b.c') +executable('main', 'main.c', link_with: a, link_with: b) +subdir('sub') +warning('a warning of some sort') +import('unstable-simd') + +conf_data = configuration_data() +conf_data.set('NOTMISSING', 1) +configure_file(input: 'conf.in' , output: 'conf', configuration: conf_data) diff --git a/test cases/unit/22 warning location/sub/c.c b/test cases/unit/22 warning location/sub/c.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/22 warning location/sub/c.c diff --git a/test cases/unit/22 warning location/sub/d.c b/test cases/unit/22 warning location/sub/d.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/22 warning location/sub/d.c diff --git a/test cases/unit/22 warning location/sub/meson.build b/test cases/unit/22 warning location/sub/meson.build new file mode 100644 index 0000000..27f6778 --- /dev/null +++ b/test cases/unit/22 warning location/sub/meson.build @@ -0,0 +1,4 @@ +c = library('libc', 'c.c') +d = library('libd', 'd.c') +executable('sub', 'sub.c', link_with: c, link_with: d) +warning('subdir warning') diff --git a/test cases/unit/22 warning location/sub/sub.c b/test cases/unit/22 warning location/sub/sub.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/22 warning location/sub/sub.c diff --git a/test cases/unit/23 unfound pkgconfig/meson.build b/test cases/unit/23 unfound pkgconfig/meson.build new file mode 100644 index 0000000..1285c0a --- /dev/null +++ b/test cases/unit/23 unfound pkgconfig/meson.build @@ -0,0 +1,15 @@ +project('foobar', 'c') + +unfound = dependency('blub_blob_blib', required : false) + +pkgg = import('pkgconfig') + +l = shared_library('somename', 'some.c', + dependencies : unfound) + +pkgg.generate( + libraries : l, + name : 'somename', + version : '1.0.0', + description : 'A test library.', +) diff --git a/test cases/unit/23 unfound pkgconfig/some.c b/test cases/unit/23 unfound pkgconfig/some.c new file mode 100644 index 0000000..fb765fb --- /dev/null +++ b/test cases/unit/23 unfound pkgconfig/some.c @@ -0,0 +1,3 @@ +int some() { + return 6; +} diff --git a/test cases/unit/24 compiler run_command/meson.build b/test cases/unit/24 compiler run_command/meson.build new file mode 100644 index 0000000..e99b880 --- /dev/null +++ b/test cases/unit/24 compiler run_command/meson.build @@ -0,0 +1,10 @@ +project('compiler_object_in_run_command', 'c') +cc = meson.get_compiler('c') + +# This test only checks that the compiler object can be passed to +# run_command(). If the compiler has been launched, it is expected +# to output something either to stdout or to stderr. +result = run_command(cc, '--version', check: false) +if result.stdout() == '' and result.stderr() == '' + error('No output in stdout and stderr. Did the compiler run at all?') +endif diff --git a/test cases/unit/25 non-permitted kwargs/meson.build b/test cases/unit/25 non-permitted kwargs/meson.build new file mode 100644 index 0000000..287acfd --- /dev/null +++ b/test cases/unit/25 non-permitted kwargs/meson.build @@ -0,0 +1,5 @@ +project('non-permitted kwargs', 'c') +cc = meson.get_compiler('c') +cc.has_header_symbol('stdio.h', 'printf', prefixxx: '#define XXX') +cc.links('int main(void){}', argsxx: '') +cc.get_id(invalidxx: '') diff --git a/test cases/unit/26 install umask/datafile.cat b/test cases/unit/26 install umask/datafile.cat new file mode 100644 index 0000000..53d81fc --- /dev/null +++ b/test cases/unit/26 install umask/datafile.cat @@ -0,0 +1 @@ +Installed cat is installed. diff --git a/test cases/unit/26 install umask/meson.build b/test cases/unit/26 install umask/meson.build new file mode 100644 index 0000000..225f71c --- /dev/null +++ b/test cases/unit/26 install umask/meson.build @@ -0,0 +1,7 @@ +project('install umask', 'c') +executable('prog', 'prog.c', install : true) +install_headers('sample.h') +install_man('prog.1') +install_data('datafile.cat', install_dir : get_option('prefix') + '/share') +install_subdir('subdir', install_dir : get_option('prefix') + '/share') +meson.add_install_script('myinstall.py', 'share', 'file.dat') diff --git a/test cases/unit/26 install umask/myinstall.py b/test cases/unit/26 install umask/myinstall.py new file mode 100644 index 0000000..db6a51c --- /dev/null +++ b/test cases/unit/26 install umask/myinstall.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 + +import os +import sys + +prefix = os.environ['MESON_INSTALL_DESTDIR_PREFIX'] + +dirname = os.path.join(prefix, sys.argv[1]) + +try: + os.makedirs(dirname) +except FileExistsError: + if not os.path.isdir(dirname): + raise + +with open(os.path.join(dirname, sys.argv[2]), 'w') as f: + f.write('') diff --git a/test cases/unit/26 install umask/prog.1 b/test cases/unit/26 install umask/prog.1 new file mode 100644 index 0000000..08ef7da --- /dev/null +++ b/test cases/unit/26 install umask/prog.1 @@ -0,0 +1 @@ +Man up, you. diff --git a/test cases/unit/26 install umask/prog.c b/test cases/unit/26 install umask/prog.c new file mode 100644 index 0000000..0f0061d --- /dev/null +++ b/test cases/unit/26 install umask/prog.c @@ -0,0 +1,3 @@ +int main(int argc, char **arv) { + return 0; +} diff --git a/test cases/unit/26 install umask/sample.h b/test cases/unit/26 install umask/sample.h new file mode 100644 index 0000000..dc030da --- /dev/null +++ b/test cases/unit/26 install umask/sample.h @@ -0,0 +1,6 @@ +#ifndef SAMPLE_H +#define SAMPLE_H + +int wackiness(); + +#endif diff --git a/test cases/unit/26 install umask/subdir/datafile.dog b/test cases/unit/26 install umask/subdir/datafile.dog new file mode 100644 index 0000000..7a5bcb7 --- /dev/null +++ b/test cases/unit/26 install umask/subdir/datafile.dog @@ -0,0 +1 @@ +Installed dog is installed. diff --git a/test cases/unit/26 install umask/subdir/sayhello b/test cases/unit/26 install umask/subdir/sayhello new file mode 100755 index 0000000..1e1c90a --- /dev/null +++ b/test cases/unit/26 install umask/subdir/sayhello @@ -0,0 +1,2 @@ +#!/bin/sh +echo 'Hello, World!' diff --git a/test cases/unit/27 pkgconfig usage/dependee/meson.build b/test cases/unit/27 pkgconfig usage/dependee/meson.build new file mode 100644 index 0000000..03e294e --- /dev/null +++ b/test cases/unit/27 pkgconfig usage/dependee/meson.build @@ -0,0 +1,6 @@ +project('pkgconfig user', 'c') + +pkgdep = dependency('libpkgdep') + +executable('pkguser', 'pkguser.c', + dependencies : pkgdep) diff --git a/test cases/unit/27 pkgconfig usage/dependee/pkguser.c b/test cases/unit/27 pkgconfig usage/dependee/pkguser.c new file mode 100644 index 0000000..2bff316 --- /dev/null +++ b/test cases/unit/27 pkgconfig usage/dependee/pkguser.c @@ -0,0 +1,6 @@ +#include<pkgdep.h> + +int main(int argc, char **argv) { + int res = pkgdep(); + return res != 99; +} diff --git a/test cases/unit/27 pkgconfig usage/dependency/meson.build b/test cases/unit/27 pkgconfig usage/dependency/meson.build new file mode 100644 index 0000000..ee0f1da --- /dev/null +++ b/test cases/unit/27 pkgconfig usage/dependency/meson.build @@ -0,0 +1,24 @@ +project('pkgconfig dep', 'c', + version : '1.0.0') + +# This is not used in the code, only to check that it does not +# leak out to --libs. +glib_dep = dependency('glib-2.0') + +pkgconfig = import('pkgconfig') + +intlib = static_library('libpkgdep-int', 'privatelib.c') +intdep = declare_dependency(link_with : intlib) + +lib = shared_library('pkgdep', 'pkgdep.c', + dependencies : [glib_dep, intdep], + install : true) + +install_headers('pkgdep.h') + +pkgconfig.generate( + filebase : 'libpkgdep', + name : 'Libpkgdep', + description : 'Sample pkgconfig dependency library', + version : meson.project_version(), + libraries : lib) diff --git a/test cases/unit/27 pkgconfig usage/dependency/pkgdep.c b/test cases/unit/27 pkgconfig usage/dependency/pkgdep.c new file mode 100644 index 0000000..bd5c3f4 --- /dev/null +++ b/test cases/unit/27 pkgconfig usage/dependency/pkgdep.c @@ -0,0 +1,7 @@ +#include<pkgdep.h> + +int internal_thingy(); + +int pkgdep() { + return internal_thingy(); +} diff --git a/test cases/unit/27 pkgconfig usage/dependency/pkgdep.h b/test cases/unit/27 pkgconfig usage/dependency/pkgdep.h new file mode 100644 index 0000000..16d622e --- /dev/null +++ b/test cases/unit/27 pkgconfig usage/dependency/pkgdep.h @@ -0,0 +1,3 @@ +#pragma once + +int pkgdep(); diff --git a/test cases/unit/27 pkgconfig usage/dependency/privatelib.c b/test cases/unit/27 pkgconfig usage/dependency/privatelib.c new file mode 100644 index 0000000..71d2179 --- /dev/null +++ b/test cases/unit/27 pkgconfig usage/dependency/privatelib.c @@ -0,0 +1,3 @@ +int internal_thingy() { + return 99; +} diff --git a/test cases/unit/28 ndebug if-release/main.c b/test cases/unit/28 ndebug if-release/main.c new file mode 100644 index 0000000..70b3d04 --- /dev/null +++ b/test cases/unit/28 ndebug if-release/main.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <stdlib.h> + +int main(void) { +#ifdef NDEBUG + printf("NDEBUG=1\n"); +#else + printf("NDEBUG=0\n"); +#endif + return 0; +} diff --git a/test cases/unit/28 ndebug if-release/meson.build b/test cases/unit/28 ndebug if-release/meson.build new file mode 100644 index 0000000..4af2406 --- /dev/null +++ b/test cases/unit/28 ndebug if-release/meson.build @@ -0,0 +1,3 @@ +project('ndebug enabled', 'c') + +executable('main', 'main.c') diff --git a/test cases/unit/29 guessed linker dependencies/exe/app.c b/test cases/unit/29 guessed linker dependencies/exe/app.c new file mode 100644 index 0000000..29c8d9c --- /dev/null +++ b/test cases/unit/29 guessed linker dependencies/exe/app.c @@ -0,0 +1,6 @@ +void liba_func(); + +int main(void) { + liba_func(); + return 0; +} diff --git a/test cases/unit/29 guessed linker dependencies/exe/meson.build b/test cases/unit/29 guessed linker dependencies/exe/meson.build new file mode 100644 index 0000000..8bb1bd7 --- /dev/null +++ b/test cases/unit/29 guessed linker dependencies/exe/meson.build @@ -0,0 +1,7 @@ +project('exe', ['c']) + +executable('app', + 'app.c', + # Use uninterpreted strings to avoid path finding by dependency or compiler.find_library + link_args: ['-ltest-lib'] + ) diff --git a/test cases/unit/29 guessed linker dependencies/lib/lib.c b/test cases/unit/29 guessed linker dependencies/lib/lib.c new file mode 100644 index 0000000..1a8f94d --- /dev/null +++ b/test cases/unit/29 guessed linker dependencies/lib/lib.c @@ -0,0 +1,20 @@ +#if defined _WIN32 + #define DLL_PUBLIC __declspec(dllexport) +#else + #if defined __GNUC__ + #define DLL_PUBLIC __attribute__ ((visibility("default"))) + #else + #pragma message ("Compiler does not support symbol visibility.") + #define DLL_PUBLIC + #endif +#endif + +void DLL_PUBLIC liba_func() { +} + +#ifdef MORE_EXPORTS + +void DLL_PUBLIC libb_func() { +} + +#endif diff --git a/test cases/unit/29 guessed linker dependencies/lib/meson.build b/test cases/unit/29 guessed linker dependencies/lib/meson.build new file mode 100644 index 0000000..36df112 --- /dev/null +++ b/test cases/unit/29 guessed linker dependencies/lib/meson.build @@ -0,0 +1,11 @@ +project('lib1', ['c']) + +c_args = [] + +# Microsoft's compiler is quite smart about touching import libs on changes, +# so ensure that there is actually a change in symbols. +if get_option('more_exports') + c_args += '-DMORE_EXPORTS' +endif + +a = library('test-lib', 'lib.c', c_args: c_args, install: true) diff --git a/test cases/unit/29 guessed linker dependencies/lib/meson_options.txt b/test cases/unit/29 guessed linker dependencies/lib/meson_options.txt new file mode 100644 index 0000000..2123e45 --- /dev/null +++ b/test cases/unit/29 guessed linker dependencies/lib/meson_options.txt @@ -0,0 +1 @@ +option('more_exports', type : 'boolean', value : false) diff --git a/test cases/unit/3 subproject defaults/meson.build b/test cases/unit/3 subproject defaults/meson.build new file mode 100644 index 0000000..dafa40a --- /dev/null +++ b/test cases/unit/3 subproject defaults/meson.build @@ -0,0 +1,10 @@ +project('subproject defaults', 'c', + default_options : ['defopoverride=defopt', # This should be overridden. + 'fromcmdline=defopt'] # This should get the value set in command line. + ) + +subproject('foob', default_options : ['fromspfunc=spfunc', 'fromspfunconly=spfunc']) + +assert(get_option('fromcmdline') == 'cmdline', 'Default option defined in cmd line is incorrect: ' + get_option('fromcmdline')) +assert(get_option('defopoverride') == 'defopt', 'Default option without cmd line override is incorrect: ' + get_option('defopoverride')) +assert(get_option('fromoptfile') == 'optfile', 'Default value from option file is incorrect: ' + get_option('fromoptfile')) diff --git a/test cases/unit/3 subproject defaults/meson_options.txt b/test cases/unit/3 subproject defaults/meson_options.txt new file mode 100644 index 0000000..b63f512 --- /dev/null +++ b/test cases/unit/3 subproject defaults/meson_options.txt @@ -0,0 +1,3 @@ +option('defopoverride', type : 'string', value : 'optfile', description : 'A value for overriding.') +option('fromcmdline', type : 'string', value : 'optfile', description : 'A value for overriding.') +option('fromoptfile', type : 'string', value : 'optfile', description : 'A value for not overriding.') diff --git a/test cases/unit/3 subproject defaults/subprojects/foob/meson.build b/test cases/unit/3 subproject defaults/subprojects/foob/meson.build new file mode 100644 index 0000000..9a611a9 --- /dev/null +++ b/test cases/unit/3 subproject defaults/subprojects/foob/meson.build @@ -0,0 +1,11 @@ +project('foob', 'c', + default_options : ['defopoverride=s_defopt', # This should be overridden. + 'fromspfunc=s_defopt', # This is specified with a default_options kwarg to subproject() + 'fromcmdline=s_defopt'] # This should get the value set in command line. + ) + +assert(get_option('fromcmdline') == 's_cmdline', 'Default option defined in cmd line is incorrect: ' + get_option('fromcmdline')) +assert(get_option('fromspfunc') == 'spfunc', 'Default option set with subproject() incorrect: ' + get_option('fromspfunc')) +assert(get_option('fromspfunconly') == 'spfunc', 'Default option set with subproject() incorrect: ' + get_option('fromspfunc')) +assert(get_option('defopoverride') == 's_defopt', 'Default option without cmd line override is incorrect: ' + get_option('defopoverride')) +assert(get_option('fromoptfile') == 's_optfile', 'Default value from option file is incorrect: ' + get_option('fromoptfile')) diff --git a/test cases/unit/3 subproject defaults/subprojects/foob/meson_options.txt b/test cases/unit/3 subproject defaults/subprojects/foob/meson_options.txt new file mode 100644 index 0000000..a9a615e --- /dev/null +++ b/test cases/unit/3 subproject defaults/subprojects/foob/meson_options.txt @@ -0,0 +1,5 @@ +option('defopoverride', type : 'string', value : 's_optfile', description : 'A value for overriding.') +option('fromcmdline', type : 'string', value : 's_optfile', description : 'A value for overriding.') +option('fromspfunc', type : 'string', value : 's_optfile', description : 'A value for overriding.') +option('fromspfunconly', type : 'string', value : 's_optfile', description : 'A value for overriding.') +option('fromoptfile', type : 'string', value : 's_optfile', description : 'A value for not overriding.') diff --git a/test cases/unit/30 shared_mod linking/libfile.c b/test cases/unit/30 shared_mod linking/libfile.c new file mode 100644 index 0000000..44f7667 --- /dev/null +++ b/test cases/unit/30 shared_mod linking/libfile.c @@ -0,0 +1,14 @@ +#if defined _WIN32 || defined __CYGWIN__ + #define DLL_PUBLIC __declspec(dllexport) +#else + #if defined __GNUC__ + #define DLL_PUBLIC __attribute__ ((visibility("default"))) + #else + #pragma message ("Compiler does not support symbol visibility.") + #define DLL_PUBLIC + #endif +#endif + +int DLL_PUBLIC func() { + return 0; +} diff --git a/test cases/unit/30 shared_mod linking/main.c b/test cases/unit/30 shared_mod linking/main.c new file mode 100644 index 0000000..12f9c98 --- /dev/null +++ b/test cases/unit/30 shared_mod linking/main.c @@ -0,0 +1,11 @@ +#if defined _WIN32 || defined __CYGWIN__ + #define DLL_IMPORT __declspec(dllimport) +#else + #define DLL_IMPORT +#endif + +int DLL_IMPORT func(); + +int main(int argc, char **arg) { + return func(); +} diff --git a/test cases/unit/30 shared_mod linking/meson.build b/test cases/unit/30 shared_mod linking/meson.build new file mode 100644 index 0000000..994a5d3 --- /dev/null +++ b/test cases/unit/30 shared_mod linking/meson.build @@ -0,0 +1,5 @@ +project('shared library linking test', 'c', 'cpp') + +mod = shared_module('mymod', 'libfile.c') + +exe = executable('prog', 'main.c', link_with : mod, install : true)
\ No newline at end of file diff --git a/test cases/unit/31 forcefallback/meson.build b/test cases/unit/31 forcefallback/meson.build new file mode 100644 index 0000000..8d84a60 --- /dev/null +++ b/test cases/unit/31 forcefallback/meson.build @@ -0,0 +1,9 @@ +project('mainproj', 'c', + default_options : []) + +zlib_dep = dependency('zlib', fallback: ['notzlib', 'zlib_dep']) +notfound_dep = dependency('cannotabletofind', fallback: ['definitelynotfound', 'some_var'], required : false) + +test_not_zlib = executable('test_not_zlib', ['test_not_zlib.c'], dependencies: [zlib_dep, notfound_dep]) + +test('test_not_zlib', test_not_zlib) diff --git a/test cases/unit/31 forcefallback/subprojects/notzlib/meson.build b/test cases/unit/31 forcefallback/subprojects/notzlib/meson.build new file mode 100644 index 0000000..254a136 --- /dev/null +++ b/test cases/unit/31 forcefallback/subprojects/notzlib/meson.build @@ -0,0 +1,7 @@ +project('notzlib', 'c') + +notzlib_sources = ['notzlib.c'] + +notzlib = library('notzlib', notzlib_sources) + +zlib_dep = declare_dependency(link_with: notzlib, include_directories: include_directories(['.'])) diff --git a/test cases/unit/31 forcefallback/subprojects/notzlib/notzlib.c b/test cases/unit/31 forcefallback/subprojects/notzlib/notzlib.c new file mode 100644 index 0000000..c3b6bf9 --- /dev/null +++ b/test cases/unit/31 forcefallback/subprojects/notzlib/notzlib.c @@ -0,0 +1,6 @@ +#include "notzlib.h" + +int not_a_zlib_function (void) +{ + return 42; +} diff --git a/test cases/unit/31 forcefallback/subprojects/notzlib/notzlib.h b/test cases/unit/31 forcefallback/subprojects/notzlib/notzlib.h new file mode 100644 index 0000000..695921d --- /dev/null +++ b/test cases/unit/31 forcefallback/subprojects/notzlib/notzlib.h @@ -0,0 +1,18 @@ +#pragma once + +#if defined _WIN32 || defined __CYGWIN__ +#if defined BUILDING_DLL + #define DLL_PUBLIC __declspec(dllexport) +#else + #define DLL_PUBLIC __declspec(dllimport) +#endif +#else + #if defined __GNUC__ + #define DLL_PUBLIC __attribute__ ((visibility("default"))) + #else + #pragma message ("Compiler does not support symbol visibility.") + #define DLL_PUBLIC + #endif +#endif + +int DLL_PUBLIC not_a_zlib_function (void); diff --git a/test cases/unit/31 forcefallback/test_not_zlib.c b/test cases/unit/31 forcefallback/test_not_zlib.c new file mode 100644 index 0000000..36256af --- /dev/null +++ b/test cases/unit/31 forcefallback/test_not_zlib.c @@ -0,0 +1,8 @@ +#include <notzlib.h> + +int main (int ac, char **av) +{ + if (not_a_zlib_function () != 42) + return 1; + return 0; +} diff --git a/test cases/unit/32 pkgconfig use libraries/app/app.c b/test cases/unit/32 pkgconfig use libraries/app/app.c new file mode 100644 index 0000000..7b8d8fa --- /dev/null +++ b/test cases/unit/32 pkgconfig use libraries/app/app.c @@ -0,0 +1,6 @@ +void libb_func(); + +int main(void) { + libb_func(); + return 0; +} diff --git a/test cases/unit/32 pkgconfig use libraries/app/meson.build b/test cases/unit/32 pkgconfig use libraries/app/meson.build new file mode 100644 index 0000000..3d85a32 --- /dev/null +++ b/test cases/unit/32 pkgconfig use libraries/app/meson.build @@ -0,0 +1,5 @@ +project('app', ['c']) + +b = dependency('test-b') + +executable('app', 'app.c', dependencies : [b]) diff --git a/test cases/unit/32 pkgconfig use libraries/lib/liba.c b/test cases/unit/32 pkgconfig use libraries/lib/liba.c new file mode 100644 index 0000000..e98906b --- /dev/null +++ b/test cases/unit/32 pkgconfig use libraries/lib/liba.c @@ -0,0 +1,2 @@ +void liba_func() { +} diff --git a/test cases/unit/32 pkgconfig use libraries/lib/libb.c b/test cases/unit/32 pkgconfig use libraries/lib/libb.c new file mode 100644 index 0000000..3160e5f --- /dev/null +++ b/test cases/unit/32 pkgconfig use libraries/lib/libb.c @@ -0,0 +1,5 @@ +void liba_func(); + +void libb_func() { + liba_func(); +} diff --git a/test cases/unit/32 pkgconfig use libraries/lib/meson.build b/test cases/unit/32 pkgconfig use libraries/lib/meson.build new file mode 100644 index 0000000..e9918ce --- /dev/null +++ b/test cases/unit/32 pkgconfig use libraries/lib/meson.build @@ -0,0 +1,14 @@ +project('lib', ['c']) + +a = library('test-a', 'liba.c', install: true) + +b = library('test-b', 'libb.c', link_with: a, install: true) + +import('pkgconfig').generate( + version: '0.0', + description: 'test library', + filebase: 'test-b', + name: 'test library', + libraries: [b], + subdirs: ['.'] +) diff --git a/test cases/unit/33 cross file overrides always args/meson.build b/test cases/unit/33 cross file overrides always args/meson.build new file mode 100644 index 0000000..ef6556e --- /dev/null +++ b/test cases/unit/33 cross file overrides always args/meson.build @@ -0,0 +1,3 @@ +project('cross compile args override always args', 'c') + +executable('no-file-offset-bits', 'test.c') diff --git a/test cases/unit/33 cross file overrides always args/test.c b/test cases/unit/33 cross file overrides always args/test.c new file mode 100644 index 0000000..315f92e --- /dev/null +++ b/test cases/unit/33 cross file overrides always args/test.c @@ -0,0 +1,8 @@ +#ifdef _FILE_OFFSET_BITS + #error "_FILE_OFFSET_BITS should not be set" +#endif + +int main(int argc, char *argv[]) +{ + return 0; +} diff --git a/test cases/unit/33 cross file overrides always args/ubuntu-armhf-overrides.txt b/test cases/unit/33 cross file overrides always args/ubuntu-armhf-overrides.txt new file mode 100644 index 0000000..a00a7d1 --- /dev/null +++ b/test cases/unit/33 cross file overrides always args/ubuntu-armhf-overrides.txt @@ -0,0 +1,19 @@ +[binaries] +# we could set exe_wrapper = qemu-arm-static but to test the case +# when cross compiled binaries can't be run we don't do that +c = '/usr/bin/arm-linux-gnueabihf-gcc' +cpp = '/usr/bin/arm-linux-gnueabihf-g++' +rust = ['rustc', '--target', 'arm-unknown-linux-gnueabihf', '-C', 'linker=/usr/bin/arm-linux-gnueabihf-gcc-7'] +ar = '/usr/arm-linux-gnueabihf/bin/ar' +strip = '/usr/arm-linux-gnueabihf/bin/strip' +pkgconfig = '/usr/bin/arm-linux-gnueabihf-pkg-config' + +[properties] +root = '/usr/arm-linux-gnueabihf' +c_args = ['-U_FILE_OFFSET_BITS'] + +[host_machine] +system = 'linux' +cpu_family = 'arm' +cpu = 'armv7' # Not sure if correct. +endian = 'little' diff --git a/test cases/unit/34 command line/meson.build b/test cases/unit/34 command line/meson.build new file mode 100644 index 0000000..6207ca5 --- /dev/null +++ b/test cases/unit/34 command line/meson.build @@ -0,0 +1,9 @@ +project('command line test', 'c', + default_options : ['default_library=static', 'set_sub_opt=true'] +) + +if get_option('set_sub_opt') + subproject('subp', default_options : ['subp_opt=default3']) +else + subproject('subp') +endif diff --git a/test cases/unit/34 command line/meson_options.txt b/test cases/unit/34 command line/meson_options.txt new file mode 100644 index 0000000..244f570 --- /dev/null +++ b/test cases/unit/34 command line/meson_options.txt @@ -0,0 +1,2 @@ +option('set_sub_opt', type : 'boolean', value : false) +option('set_percent_opt', type : 'string', value: 'not_set') diff --git a/test cases/unit/34 command line/subprojects/subp/meson.build b/test cases/unit/34 command line/subprojects/subp/meson.build new file mode 100644 index 0000000..cf79fa4 --- /dev/null +++ b/test cases/unit/34 command line/subprojects/subp/meson.build @@ -0,0 +1,3 @@ +project('subp', + default_options : ['subp_opt=default2'] +) diff --git a/test cases/unit/34 command line/subprojects/subp/meson_options.txt b/test cases/unit/34 command line/subprojects/subp/meson_options.txt new file mode 100644 index 0000000..8c50615 --- /dev/null +++ b/test cases/unit/34 command line/subprojects/subp/meson_options.txt @@ -0,0 +1 @@ +option('subp_opt', type : 'string', value : 'default1') diff --git a/test cases/unit/35 dist script/meson.build b/test cases/unit/35 dist script/meson.build new file mode 100644 index 0000000..8db4235 --- /dev/null +++ b/test cases/unit/35 dist script/meson.build @@ -0,0 +1,10 @@ +project('dist script', 'c', + version : '1.0.0') + +exe = executable('comparer', 'prog.c') +test('compare', exe) + +meson.add_dist_script('replacer.py', '"incorrect"', '"correct"') +meson.add_dist_script(find_program('replacer.py'), '"incorrect"', '"correct"') + +subproject('sub') diff --git a/test cases/unit/35 dist script/prog.c b/test cases/unit/35 dist script/prog.c new file mode 100644 index 0000000..1bb6b05 --- /dev/null +++ b/test cases/unit/35 dist script/prog.c @@ -0,0 +1,7 @@ +#include<string.h> + +#define REPLACEME "incorrect" + +int main(int argc, char **argv) { + return strcmp(REPLACEME, "correct"); +} diff --git a/test cases/unit/35 dist script/replacer.py b/test cases/unit/35 dist script/replacer.py new file mode 100755 index 0000000..96ccdcc --- /dev/null +++ b/test cases/unit/35 dist script/replacer.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 + +import os +import pathlib +import sys + +if len(sys.argv) < 3: + sys.exit('usage: replacer.py <pattern> <replacement>') + +source_root = pathlib.Path(os.environ['MESON_DIST_ROOT']) + +modfile = source_root / 'prog.c' + +contents = modfile.read_text() +contents = contents.replace(sys.argv[1], sys.argv[2]) +modfile.write_text(contents) diff --git a/test cases/unit/35 dist script/subprojects/sub/dist-script.py b/test cases/unit/35 dist script/subprojects/sub/dist-script.py new file mode 100644 index 0000000..1274f29 --- /dev/null +++ b/test cases/unit/35 dist script/subprojects/sub/dist-script.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +import os +import pathlib +import sys + +assert sys.argv[1] == 'success' + +source_root = pathlib.Path(os.environ['MESON_PROJECT_DIST_ROOT']) +modfile = source_root / 'prog.c' +with modfile.open('w') as f: + f.write('int main(){return 0;}') diff --git a/test cases/unit/35 dist script/subprojects/sub/meson.build b/test cases/unit/35 dist script/subprojects/sub/meson.build new file mode 100644 index 0000000..a41a3b6 --- /dev/null +++ b/test cases/unit/35 dist script/subprojects/sub/meson.build @@ -0,0 +1,11 @@ +project('sub', 'c') + +if get_option('broken_dist_script') + # Make sure we can add a dist script in a subproject, but it won't be run + # if not using --include-subprojects. + meson.add_dist_script('dist-script.py', 'broken') +else + # The dist script replace prog.c with something that actually build. + meson.add_dist_script('dist-script.py', 'success') + executable('prog', 'prog.c') +endif diff --git a/test cases/unit/35 dist script/subprojects/sub/meson_options.txt b/test cases/unit/35 dist script/subprojects/sub/meson_options.txt new file mode 100644 index 0000000..8f52e0f --- /dev/null +++ b/test cases/unit/35 dist script/subprojects/sub/meson_options.txt @@ -0,0 +1 @@ +option('broken_dist_script', type: 'boolean', value: true) diff --git a/test cases/unit/35 dist script/subprojects/sub/prog.c b/test cases/unit/35 dist script/subprojects/sub/prog.c new file mode 100644 index 0000000..049b36a --- /dev/null +++ b/test cases/unit/35 dist script/subprojects/sub/prog.c @@ -0,0 +1 @@ +#error This should be replaced by a program during dist diff --git a/test cases/unit/36 exe_wrapper behaviour/broken-cross.txt b/test cases/unit/36 exe_wrapper behaviour/broken-cross.txt new file mode 100644 index 0000000..a5a3931 --- /dev/null +++ b/test cases/unit/36 exe_wrapper behaviour/broken-cross.txt @@ -0,0 +1,20 @@ +[binaries] +c = '/usr/bin/x86_64-w64-mingw32-gcc' +cpp = '/usr/bin/x86_64-w64-mingw32-g++' +ar = '/usr/bin/x86_64-w64-mingw32-ar' +strip = '/usr/bin/x86_64-w64-mingw32-strip' +pkgconfig = '/usr/bin/x86_64-w64-mingw32-pkg-config' +windres = '/usr/bin/x86_64-w64-mingw32-windres' +exe_wrapper = 'broken' + +[properties] +# Directory that contains 'bin', 'lib', etc +root = '/usr/x86_64-w64-mingw32' +# Directory that contains 'bin', 'lib', etc for the toolchain and system libraries +sys_root = '/usr/x86_64-w64-mingw32/sys-root/mingw' + +[host_machine] +system = 'windows' +cpu_family = 'x86_64' +cpu = 'x86_64' +endian = 'little' diff --git a/test cases/unit/36 exe_wrapper behaviour/meson.build b/test cases/unit/36 exe_wrapper behaviour/meson.build new file mode 100644 index 0000000..d0817ba --- /dev/null +++ b/test cases/unit/36 exe_wrapper behaviour/meson.build @@ -0,0 +1,19 @@ +project('exe wrapper behaviour', 'c') + +assert(meson.is_cross_build(), 'not setup as cross build') +assert(meson.has_exe_wrapper(), 'exe wrapper not defined?') # intentionally not changed to can_run_host_binaries, + +exe = executable('prog', 'prog.c') + +if get_option('custom-target') + custom_target('use-exe-wrapper', + build_by_default: true, + output: 'out.txt', + command: [exe, '@OUTPUT@']) +endif + +test('test-prog', exe) + +if get_option('run-target') + run_target('run-prog', command : exe) +endif diff --git a/test cases/unit/36 exe_wrapper behaviour/meson_options.txt b/test cases/unit/36 exe_wrapper behaviour/meson_options.txt new file mode 100644 index 0000000..e5645a0 --- /dev/null +++ b/test cases/unit/36 exe_wrapper behaviour/meson_options.txt @@ -0,0 +1,2 @@ +option('custom-target', type: 'boolean', value: true) +option('run-target', type: 'boolean', value: true) diff --git a/test cases/unit/36 exe_wrapper behaviour/prog.c b/test cases/unit/36 exe_wrapper behaviour/prog.c new file mode 100644 index 0000000..3213780 --- /dev/null +++ b/test cases/unit/36 exe_wrapper behaviour/prog.c @@ -0,0 +1,17 @@ +#include <stdio.h> + +int main (int argc, char * argv[]) +{ + const char *out = "SUCCESS!"; + + if (argc != 2) { + printf ("%s\n", out); + } else { + int ret; + FILE *f = fopen (argv[1], "w"); + ret = fwrite (out, sizeof (out), 1, f); + if (ret != 1) + return -1; + } + return 0; +} diff --git a/test cases/unit/37 mixed command line args/meson.build b/test cases/unit/37 mixed command line args/meson.build new file mode 100644 index 0000000..af5cdc7 --- /dev/null +++ b/test cases/unit/37 mixed command line args/meson.build @@ -0,0 +1 @@ +project('Mixed command line arguments') diff --git a/test cases/unit/37 mixed command line args/meson_options.txt b/test cases/unit/37 mixed command line args/meson_options.txt new file mode 100644 index 0000000..5a4bc22 --- /dev/null +++ b/test cases/unit/37 mixed command line args/meson_options.txt @@ -0,0 +1,10 @@ +option( + 'one', + type : 'string', +) +option( + 'two', + type : 'combo', + choices : ['foo', 'bar'], + value : 'foo', +) diff --git a/test cases/unit/38 pkgconfig format/meson.build b/test cases/unit/38 pkgconfig format/meson.build new file mode 100644 index 0000000..ea00f5d --- /dev/null +++ b/test cases/unit/38 pkgconfig format/meson.build @@ -0,0 +1,18 @@ +project('pkgformat', 'c', + version : '1.0') + +gio = dependency('gio-2.0', required: false) +if not gio.found() + error('MESON_SKIP_TEST glib not found.') +endif + +pkgg = import('pkgconfig') + +s = static_library('returner', 'someret.c') +l = library('something', 'somelib.c', link_whole: s) + +pkgg.generate(libraries: l, + version: '1.0', + name: 'libsomething', + description: 'A library that does something', + requires: 'gobject-2.0 >= 2.0, gio-2.0 >= 2.0') diff --git a/test cases/unit/38 pkgconfig format/somelib.c b/test cases/unit/38 pkgconfig format/somelib.c new file mode 100644 index 0000000..0558024 --- /dev/null +++ b/test cases/unit/38 pkgconfig format/somelib.c @@ -0,0 +1,7 @@ +#include<stdio.h> + +int get_returnvalue (void); + +int some_func() { + return get_returnvalue(); +} diff --git a/test cases/unit/38 pkgconfig format/someret.c b/test cases/unit/38 pkgconfig format/someret.c new file mode 100644 index 0000000..69f4299 --- /dev/null +++ b/test cases/unit/38 pkgconfig format/someret.c @@ -0,0 +1,3 @@ +int get_returnvalue (void) { + return 0; +} diff --git a/test cases/unit/39 external, internal library rpath/built library/bar.c b/test cases/unit/39 external, internal library rpath/built library/bar.c new file mode 100644 index 0000000..4f5662e --- /dev/null +++ b/test cases/unit/39 external, internal library rpath/built library/bar.c @@ -0,0 +1,7 @@ +int foo_system_value (void); +int faa_system_value (void); + +int bar_built_value (int in) +{ + return faa_system_value() + foo_system_value() + in; +} diff --git a/test cases/unit/39 external, internal library rpath/built library/meson.build b/test cases/unit/39 external, internal library rpath/built library/meson.build new file mode 100644 index 0000000..07fe7bb --- /dev/null +++ b/test cases/unit/39 external, internal library rpath/built library/meson.build @@ -0,0 +1,26 @@ +project('built library', 'c') + +cc = meson.get_compiler('c') + +if host_machine.system() != 'cygwin' + # bar_in_system has undefined symbols, but still must be found + bar_system_dep = cc.find_library('bar_in_system') +endif + +foo_system_dep = cc.find_library('foo_in_system') + +faa_pkg_dep = dependency('faa_pkg') + +l = shared_library('bar_built', 'bar.c', + install: true, + dependencies : [foo_system_dep, faa_pkg_dep]) + +if host_machine.system() == 'darwin' + e = executable('prog', 'prog.c', link_with: l, install: true) + test('testprog', e) +elif host_machine.system() == 'linux' + e = executable('prog', 'prog.c', link_with: l, install: true, + install_rpath: '$ORIGIN/..' / get_option('libdir'), + ) + test('testprog', e) +endif diff --git a/test cases/unit/39 external, internal library rpath/built library/meson_options.txt b/test cases/unit/39 external, internal library rpath/built library/meson_options.txt new file mode 100644 index 0000000..aa1d2ec --- /dev/null +++ b/test cases/unit/39 external, internal library rpath/built library/meson_options.txt @@ -0,0 +1 @@ +option('foo_system_path', type: 'string', value: '') diff --git a/test cases/unit/39 external, internal library rpath/built library/prog.c b/test cases/unit/39 external, internal library rpath/built library/prog.c new file mode 100644 index 0000000..e3d4cf6 --- /dev/null +++ b/test cases/unit/39 external, internal library rpath/built library/prog.c @@ -0,0 +1,7 @@ +int bar_built_value (int in); + +int main (int argc, char *argv[]) +{ + // this will evaluate to 0 + return bar_built_value(10) - (42 + 1969 + 10); +} diff --git a/test cases/unit/39 external, internal library rpath/external library/bar.c b/test cases/unit/39 external, internal library rpath/external library/bar.c new file mode 100644 index 0000000..c6f42d6 --- /dev/null +++ b/test cases/unit/39 external, internal library rpath/external library/bar.c @@ -0,0 +1,6 @@ +int some_undefined_func (void); + +int bar_system_value (void) +{ + return some_undefined_func (); +} diff --git a/test cases/unit/39 external, internal library rpath/external library/faa.c b/test cases/unit/39 external, internal library rpath/external library/faa.c new file mode 100644 index 0000000..4733575 --- /dev/null +++ b/test cases/unit/39 external, internal library rpath/external library/faa.c @@ -0,0 +1,4 @@ +int faa_system_value (void) +{ + return 1969; +} diff --git a/test cases/unit/39 external, internal library rpath/external library/foo.c b/test cases/unit/39 external, internal library rpath/external library/foo.c new file mode 100644 index 0000000..a34e4a8 --- /dev/null +++ b/test cases/unit/39 external, internal library rpath/external library/foo.c @@ -0,0 +1,4 @@ +int foo_system_value (void) +{ + return 42; +} diff --git a/test cases/unit/39 external, internal library rpath/external library/meson.build b/test cases/unit/39 external, internal library rpath/external library/meson.build new file mode 100644 index 0000000..06ffa0f --- /dev/null +++ b/test cases/unit/39 external, internal library rpath/external library/meson.build @@ -0,0 +1,22 @@ +project('system library', 'c', default_options : ['b_lundef=false']) + +shared_library('foo_in_system', 'foo.c', install : true) +l = shared_library('faa_pkg', 'faa.c', install: true) + +if host_machine.system() == 'darwin' + ldflags = ['-framework', 'CoreFoundation', '-framework', 'CoreMedia'] + allow_undef_args = ['-Wl,-undefined,dynamic_lookup'] +else + ldflags = ['-Wl,-rpath,${libdir}'] + allow_undef_args = [] +endif + +pkg = import('pkgconfig') +pkg.generate(name: 'faa_pkg', + libraries: [l] + ldflags, + description: 'FAA, a pkg-config test library') + +# cygwin DLLs can't have undefined symbols +if host_machine.system() != 'cygwin' + shared_library('bar_in_system', 'bar.c', install : true, link_args : allow_undef_args) +endif diff --git a/test cases/unit/4 suite selection/failing_test.c b/test cases/unit/4 suite selection/failing_test.c new file mode 100644 index 0000000..393344d --- /dev/null +++ b/test cases/unit/4 suite selection/failing_test.c @@ -0,0 +1 @@ +int main(void) { return -1 ; } diff --git a/test cases/unit/4 suite selection/meson.build b/test cases/unit/4 suite selection/meson.build new file mode 100644 index 0000000..ea6db92 --- /dev/null +++ b/test cases/unit/4 suite selection/meson.build @@ -0,0 +1,17 @@ +project('mainprj', 'c') + +subproject('subprjfail') +subproject('subprjsucc') +subproject('subprjmix') + +test('mainprj-failing_test', + executable('failing_test', 'failing_test.c'), + suite : 'fail') + +test('mainprj-successful_test', + executable('successful_test', 'successful_test.c'), + suite : 'success') + +test('mainprj-successful_test_no_suite', + executable('no_suite_test', 'successful_test.c'), + suite : []) diff --git a/test cases/unit/4 suite selection/subprojects/subprjfail/failing_test.c b/test cases/unit/4 suite selection/subprojects/subprjfail/failing_test.c new file mode 100644 index 0000000..393344d --- /dev/null +++ b/test cases/unit/4 suite selection/subprojects/subprjfail/failing_test.c @@ -0,0 +1 @@ +int main(void) { return -1 ; } diff --git a/test cases/unit/4 suite selection/subprojects/subprjfail/meson.build b/test cases/unit/4 suite selection/subprojects/subprjfail/meson.build new file mode 100644 index 0000000..e6270a8 --- /dev/null +++ b/test cases/unit/4 suite selection/subprojects/subprjfail/meson.build @@ -0,0 +1,9 @@ +project('subprjfail', 'c') + +test('subprjfail-failing_test', + executable('failing_test', 'failing_test.c'), + suite : 'fail') + +test('subprjfail-failing_test_no_suite', + executable('failing_test_no_suite', 'failing_test.c'), + suite : []) diff --git a/test cases/unit/4 suite selection/subprojects/subprjmix/failing_test.c b/test cases/unit/4 suite selection/subprojects/subprjmix/failing_test.c new file mode 100644 index 0000000..393344d --- /dev/null +++ b/test cases/unit/4 suite selection/subprojects/subprjmix/failing_test.c @@ -0,0 +1 @@ +int main(void) { return -1 ; } diff --git a/test cases/unit/4 suite selection/subprojects/subprjmix/meson.build b/test cases/unit/4 suite selection/subprojects/subprjmix/meson.build new file mode 100644 index 0000000..1d0eeff --- /dev/null +++ b/test cases/unit/4 suite selection/subprojects/subprjmix/meson.build @@ -0,0 +1,9 @@ +project('subprjmix', 'c') + +test('subprjmix-failing_test', + executable('failing_test', 'failing_test.c'), + suite : 'fail') + +test('subprjmix-successful_test', + executable('successful_test', 'successful_test.c'), + suite : 'success') diff --git a/test cases/unit/4 suite selection/subprojects/subprjmix/successful_test.c b/test cases/unit/4 suite selection/subprojects/subprjmix/successful_test.c new file mode 100644 index 0000000..8842fc1 --- /dev/null +++ b/test cases/unit/4 suite selection/subprojects/subprjmix/successful_test.c @@ -0,0 +1 @@ +int main(void) { return 0 ; } diff --git a/test cases/unit/4 suite selection/subprojects/subprjsucc/meson.build b/test cases/unit/4 suite selection/subprojects/subprjsucc/meson.build new file mode 100644 index 0000000..b5ffaa4 --- /dev/null +++ b/test cases/unit/4 suite selection/subprojects/subprjsucc/meson.build @@ -0,0 +1,9 @@ +project('subprjsucc', 'c') + +test('subprjsucc-successful_test', + executable('successful_test', 'successful_test.c'), + suite : 'success') + +test('subprjsucc-successful_test_no_suite', + executable('successful_test_no_suite', 'successful_test.c'), + suite : []) diff --git a/test cases/unit/4 suite selection/subprojects/subprjsucc/successful_test.c b/test cases/unit/4 suite selection/subprojects/subprjsucc/successful_test.c new file mode 100644 index 0000000..8842fc1 --- /dev/null +++ b/test cases/unit/4 suite selection/subprojects/subprjsucc/successful_test.c @@ -0,0 +1 @@ +int main(void) { return 0 ; } diff --git a/test cases/unit/4 suite selection/successful_test.c b/test cases/unit/4 suite selection/successful_test.c new file mode 100644 index 0000000..8842fc1 --- /dev/null +++ b/test cases/unit/4 suite selection/successful_test.c @@ -0,0 +1 @@ +int main(void) { return 0 ; } diff --git a/test cases/unit/40 featurenew subprojects/meson.build b/test cases/unit/40 featurenew subprojects/meson.build new file mode 100644 index 0000000..d136bed --- /dev/null +++ b/test cases/unit/40 featurenew subprojects/meson.build @@ -0,0 +1,7 @@ +project('featurenew subproject', meson_version: '>=0.45') + +foo = {} + +subproject('foo') +subproject('bar') +subproject('baz') diff --git a/test cases/unit/40 featurenew subprojects/subprojects/bar/meson.build b/test cases/unit/40 featurenew subprojects/subprojects/bar/meson.build new file mode 100644 index 0000000..712a125 --- /dev/null +++ b/test cases/unit/40 featurenew subprojects/subprojects/bar/meson.build @@ -0,0 +1,3 @@ +project('foo subproject', meson_version: '>=0.46') + +import('python') diff --git a/test cases/unit/40 featurenew subprojects/subprojects/baz/meson.build b/test cases/unit/40 featurenew subprojects/subprojects/baz/meson.build new file mode 100644 index 0000000..811e7aa --- /dev/null +++ b/test cases/unit/40 featurenew subprojects/subprojects/baz/meson.build @@ -0,0 +1,3 @@ +project('baz subproject', meson_version: '!=0.40') + +disabler() diff --git a/test cases/unit/40 featurenew subprojects/subprojects/foo/meson.build b/test cases/unit/40 featurenew subprojects/subprojects/foo/meson.build new file mode 100644 index 0000000..0ef4472 --- /dev/null +++ b/test cases/unit/40 featurenew subprojects/subprojects/foo/meson.build @@ -0,0 +1,3 @@ +project('foo subproject', meson_version: '>=0.40') + +disabler() diff --git a/test cases/unit/41 rpath order/meson.build b/test cases/unit/41 rpath order/meson.build new file mode 100644 index 0000000..a722894 --- /dev/null +++ b/test cases/unit/41 rpath order/meson.build @@ -0,0 +1,11 @@ +project('myexe', 'c') + +sub1 = subproject('sub1') +sub1_dep = sub1.get_variable('sub1_dep') + +sub2 = subproject('sub2') +sub2_dep = sub2.get_variable('sub2_dep') + +executable('myexe', + 'myexe.c', + dependencies: [sub1_dep, sub2_dep]) diff --git a/test cases/unit/41 rpath order/myexe.c b/test cases/unit/41 rpath order/myexe.c new file mode 100644 index 0000000..03b2213 --- /dev/null +++ b/test cases/unit/41 rpath order/myexe.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/test cases/unit/41 rpath order/subprojects/sub1/lib.c b/test cases/unit/41 rpath order/subprojects/sub1/lib.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/41 rpath order/subprojects/sub1/lib.c diff --git a/test cases/unit/41 rpath order/subprojects/sub1/meson.build b/test cases/unit/41 rpath order/subprojects/sub1/meson.build new file mode 100644 index 0000000..4dd5d08 --- /dev/null +++ b/test cases/unit/41 rpath order/subprojects/sub1/meson.build @@ -0,0 +1,5 @@ +project('sub1', 'c') + +sub1_lib = library('sub1', 'lib.c') + +sub1_dep = declare_dependency(link_with : sub1_lib) diff --git a/test cases/unit/41 rpath order/subprojects/sub2/lib.c b/test cases/unit/41 rpath order/subprojects/sub2/lib.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/41 rpath order/subprojects/sub2/lib.c diff --git a/test cases/unit/41 rpath order/subprojects/sub2/meson.build b/test cases/unit/41 rpath order/subprojects/sub2/meson.build new file mode 100644 index 0000000..bc3510d --- /dev/null +++ b/test cases/unit/41 rpath order/subprojects/sub2/meson.build @@ -0,0 +1,5 @@ +project('sub2', 'c') + +sub2_lib = library('sub2', 'lib.c') + +sub2_dep = declare_dependency(link_with : sub2_lib) diff --git a/test cases/unit/42 dep order/lib1.c b/test cases/unit/42 dep order/lib1.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/42 dep order/lib1.c diff --git a/test cases/unit/42 dep order/lib2.c b/test cases/unit/42 dep order/lib2.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/42 dep order/lib2.c diff --git a/test cases/unit/42 dep order/meson.build b/test cases/unit/42 dep order/meson.build new file mode 100644 index 0000000..17cf9df --- /dev/null +++ b/test cases/unit/42 dep order/meson.build @@ -0,0 +1,8 @@ +project('myexe', 'c') + +lib1 = static_library('lib1', 'lib1.c') +lib2 = static_library('lib2', 'lib2.c') + +executable('myexe', + 'myexe.c', + link_with: [lib1, lib2]) diff --git a/test cases/unit/42 dep order/myexe.c b/test cases/unit/42 dep order/myexe.c new file mode 100644 index 0000000..8f4c045 --- /dev/null +++ b/test cases/unit/42 dep order/myexe.c @@ -0,0 +1,3 @@ +int main(int ac, char** av) { + return 0; +} diff --git a/test cases/unit/43 promote wrap/meson.build b/test cases/unit/43 promote wrap/meson.build new file mode 100644 index 0000000..5012bf6 --- /dev/null +++ b/test cases/unit/43 promote wrap/meson.build @@ -0,0 +1,4 @@ +project('promotion test', 'c') + +subproject('s1') +subproject('s2') diff --git a/test cases/unit/43 promote wrap/subprojects/s1/meson.build b/test cases/unit/43 promote wrap/subprojects/s1/meson.build new file mode 100644 index 0000000..48dc853 --- /dev/null +++ b/test cases/unit/43 promote wrap/subprojects/s1/meson.build @@ -0,0 +1 @@ +project('s1', 'c') diff --git a/test cases/unit/43 promote wrap/subprojects/s1/subprojects/ambiguous/meson.build b/test cases/unit/43 promote wrap/subprojects/s1/subprojects/ambiguous/meson.build new file mode 100644 index 0000000..b485d83 --- /dev/null +++ b/test cases/unit/43 promote wrap/subprojects/s1/subprojects/ambiguous/meson.build @@ -0,0 +1 @@ +project('ambiguous', 'c') diff --git a/test cases/unit/43 promote wrap/subprojects/s2/meson.build b/test cases/unit/43 promote wrap/subprojects/s2/meson.build new file mode 100644 index 0000000..901bc2a --- /dev/null +++ b/test cases/unit/43 promote wrap/subprojects/s2/meson.build @@ -0,0 +1 @@ +project('s2', 'c') diff --git a/test cases/unit/43 promote wrap/subprojects/s2/subprojects/ambiguous.wrap b/test cases/unit/43 promote wrap/subprojects/s2/subprojects/ambiguous.wrap new file mode 100644 index 0000000..09ba4e8 --- /dev/null +++ b/test cases/unit/43 promote wrap/subprojects/s2/subprojects/ambiguous.wrap @@ -0,0 +1,2 @@ +The contents of this wrap file are never evaluated so they +can be anything. diff --git a/test cases/unit/44 vscpp17/main.cpp b/test cases/unit/44 vscpp17/main.cpp new file mode 100644 index 0000000..3d07d4c --- /dev/null +++ b/test cases/unit/44 vscpp17/main.cpp @@ -0,0 +1,29 @@ +#include <iostream> + +#if __cpp_lib_filesystem || (defined(__cplusplus) && __cplusplus >= 201703L) +#include <filesystem> +#endif + +int main(){ + +#if __cpp_lib_filesystem || (defined(__cplusplus) && __cplusplus >= 201703L) +char fs = std::filesystem::path::preferred_separator; +std::cout << "OK: C++17 filesystem enabled" << std::endl; +#endif + +#if defined(_MSC_VER) +#if _HAS_CXX17 +std::cout << "OK: MSVC has C++17 enabled" << std::endl; +return EXIT_SUCCESS; +#else +std::cerr << "ERROR: MSVC does not have C++17 enabled" << std::endl; +return EXIT_FAILURE; +#endif +#elif defined(__cplusplus) && __cplusplus >= 201703L +std::cout << "OK: C++17 enabled" << std::endl; +return EXIT_SUCCESS; +#else +std::cerr << "ERROR: C++17 not enabled" << std::endl; +return EXIT_FAILURE; +#endif +} diff --git a/test cases/unit/44 vscpp17/meson.build b/test cases/unit/44 vscpp17/meson.build new file mode 100644 index 0000000..afe740b --- /dev/null +++ b/test cases/unit/44 vscpp17/meson.build @@ -0,0 +1,4 @@ +project('msvc_cpp17', 'cpp', default_options: ['cpp_std=c++17']) + +exe = executable('msvc_cpp17', 'main.cpp') +test('msvc_cpp17', exe) diff --git a/test cases/unit/45 native dep pkgconfig var/cross_pkgconfig.py b/test cases/unit/45 native dep pkgconfig var/cross_pkgconfig.py new file mode 100755 index 0000000..f0d89ee --- /dev/null +++ b/test cases/unit/45 native dep pkgconfig var/cross_pkgconfig.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +import os +import sys +import subprocess + +environ = os.environ.copy() +environ['PKG_CONFIG_LIBDIR'] = os.path.join( + os.path.dirname(os.path.realpath(__file__)), 'cross_pkgconfig') + +sys.exit( + subprocess.run(['pkg-config'] + sys.argv[1:], env=environ).returncode) diff --git a/test cases/unit/45 native dep pkgconfig var/cross_pkgconfig/dep_tester.pc b/test cases/unit/45 native dep pkgconfig var/cross_pkgconfig/dep_tester.pc new file mode 100644 index 0000000..67d7afa --- /dev/null +++ b/test cases/unit/45 native dep pkgconfig var/cross_pkgconfig/dep_tester.pc @@ -0,0 +1,5 @@ +dep_type=cross + +Name: dependency() test +Description: dependency() test +Version: 0 diff --git a/test cases/unit/45 native dep pkgconfig var/meson.build b/test cases/unit/45 native dep pkgconfig var/meson.build new file mode 100644 index 0000000..d95dbcd --- /dev/null +++ b/test cases/unit/45 native dep pkgconfig var/meson.build @@ -0,0 +1,15 @@ +project('native dep pkgconfig test') + +if get_option('start_native') + dep_native = dependency('dep_tester', native: true, method: 'pkg-config') + dep_cross = dependency('dep_tester', native: false, method: 'pkg-config') +else + dep_cross = dependency('dep_tester', native: false, method: 'pkg-config') + dep_native = dependency('dep_tester', native: true, method: 'pkg-config') +endif + +dep_type = dep_native.get_pkgconfig_variable('dep_type') +assert(dep_type == 'native', 'Expected native') + +dep_type = dep_cross.get_pkgconfig_variable('dep_type') +assert(dep_type == 'cross', 'Expected cross') diff --git a/test cases/unit/45 native dep pkgconfig var/meson_options.txt b/test cases/unit/45 native dep pkgconfig var/meson_options.txt new file mode 100644 index 0000000..37006dd --- /dev/null +++ b/test cases/unit/45 native dep pkgconfig var/meson_options.txt @@ -0,0 +1,6 @@ +option( + 'start_native', + type : 'boolean', + value : 'false', + description : 'Start by creating a dependency() with native : true', +) diff --git a/test cases/unit/45 native dep pkgconfig var/native_pkgconfig/dep_tester.pc b/test cases/unit/45 native dep pkgconfig var/native_pkgconfig/dep_tester.pc new file mode 100644 index 0000000..affaa97 --- /dev/null +++ b/test cases/unit/45 native dep pkgconfig var/native_pkgconfig/dep_tester.pc @@ -0,0 +1,5 @@ +dep_type=native + +Name: dependency() test +Description: dependency() test +Version: 0 diff --git a/test cases/unit/46 native file binary/meson.build b/test cases/unit/46 native file binary/meson.build new file mode 100644 index 0000000..2f55fe2 --- /dev/null +++ b/test cases/unit/46 native file binary/meson.build @@ -0,0 +1,21 @@ +project('test project') + +case = get_option('case') + +if case == 'find_program' + prog = find_program('bash') + result = run_command(prog, ['--version'], check: true) + assert(result.stdout().strip().endswith('12345'), 'Didn\'t load bash from config file') +elif case == 'config_dep' + add_languages('cpp') + dep = dependency('llvm', method : 'config-tool') + assert(dep.get_configtool_variable('version').endswith('12345'), 'Didn\'t load llvm from config file') +elif case == 'python3' + prog = import('python3').find_python() + result = run_command(prog, ['--version'], check: true) + assert(result.stdout().strip().endswith('12345'), 'Didn\'t load python3 from config file') +elif case == 'python' + prog = import('python').find_installation() + result = run_command(prog, ['--version'], check: true) + assert(result.stdout().strip().endswith('12345'), 'Didn\'t load python from config file') +endif diff --git a/test cases/unit/46 native file binary/meson_options.txt b/test cases/unit/46 native file binary/meson_options.txt new file mode 100644 index 0000000..651da0e --- /dev/null +++ b/test cases/unit/46 native file binary/meson_options.txt @@ -0,0 +1,5 @@ +option( + 'case', + type : 'combo', + choices : ['find_program', 'config_dep', 'python3', 'python'] +) diff --git a/test cases/unit/47 reconfigure/main.c b/test cases/unit/47 reconfigure/main.c new file mode 100644 index 0000000..25927f5 --- /dev/null +++ b/test cases/unit/47 reconfigure/main.c @@ -0,0 +1,4 @@ +int main(int argc, char *argv[]) +{ + return 0; +} diff --git a/test cases/unit/47 reconfigure/meson.build b/test cases/unit/47 reconfigure/meson.build new file mode 100644 index 0000000..4f35458 --- /dev/null +++ b/test cases/unit/47 reconfigure/meson.build @@ -0,0 +1,11 @@ +project('test-reconfigure', 'c') + +message('opt1 ' + get_option('opt1')) +message('opt2 ' + get_option('opt2')) +message('opt3 ' + get_option('opt3')) +message('opt4 ' + get_option('opt4')) + +exe = executable('test1', 'main.c') +test('test1', exe) + +sub1 = subproject('sub1') diff --git a/test cases/unit/47 reconfigure/meson_options.txt b/test cases/unit/47 reconfigure/meson_options.txt new file mode 100644 index 0000000..728f7b7 --- /dev/null +++ b/test cases/unit/47 reconfigure/meson_options.txt @@ -0,0 +1,4 @@ +option('opt1', type : 'string', value : 'default1') +option('opt2', type : 'string', value : 'default2') +option('opt3', type : 'string', value : 'default3') +option('opt4', type : 'string', value : 'default4') diff --git a/test cases/unit/47 reconfigure/subprojects/sub1/meson.build b/test cases/unit/47 reconfigure/subprojects/sub1/meson.build new file mode 100644 index 0000000..30fd19d --- /dev/null +++ b/test cases/unit/47 reconfigure/subprojects/sub1/meson.build @@ -0,0 +1,3 @@ +project('sub1') + +message('sub1:werror @0@'.format(get_option('werror'))) diff --git a/test cases/unit/48 testsetup default/envcheck.py b/test cases/unit/48 testsetup default/envcheck.py new file mode 100644 index 0000000..34ad76d --- /dev/null +++ b/test cases/unit/48 testsetup default/envcheck.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +import os + +assert 'ENV_A' in os.environ +assert 'ENV_B' in os.environ +assert 'ENV_C' in os.environ + +print('ENV_A is', os.environ['ENV_A']) +print('ENV_B is', os.environ['ENV_B']) +print('ENV_C is', os.environ['ENV_C']) diff --git a/test cases/unit/48 testsetup default/meson.build b/test cases/unit/48 testsetup default/meson.build new file mode 100644 index 0000000..bdd35b8 --- /dev/null +++ b/test cases/unit/48 testsetup default/meson.build @@ -0,0 +1,23 @@ +project('testsetup default', 'c') + +envcheck = find_program('envcheck.py') + +# Defining ENV_A in test-env should overwrite ENV_A from test setup +env_1 = environment() +env_1.set('ENV_A', '1') +test('test-env', envcheck, env: env_1) + +# Defining default env which is used unless --setup is given or the +# env variable is defined in the test. +env_2 = environment() +env_2.set('ENV_A', '2') +env_2.set('ENV_B', '2') +env_2.set('ENV_C', '2') +add_test_setup('mydefault', env: env_2, is_default: true) + +# Defining a test setup that will update some of the env variables +# from the default test setup. +env_3 = env_2 +env_3.set('ENV_A', '3') +env_3.set('ENV_B', '3') +add_test_setup('other', env: env_3) diff --git a/test cases/unit/49 pkgconfig csharp library/meson.build b/test cases/unit/49 pkgconfig csharp library/meson.build new file mode 100644 index 0000000..148d40f --- /dev/null +++ b/test cases/unit/49 pkgconfig csharp library/meson.build @@ -0,0 +1,10 @@ +project('pkgformat', 'cs', + version : '1.0') + +pkgg = import('pkgconfig') + +l = library('libsomething', 'somelib.cs') + +pkgg.generate(l, + version: '1.0', + description: 'A library that does something') diff --git a/test cases/unit/49 pkgconfig csharp library/somelib.cs b/test cases/unit/49 pkgconfig csharp library/somelib.cs new file mode 100644 index 0000000..24d37ed --- /dev/null +++ b/test cases/unit/49 pkgconfig csharp library/somelib.cs @@ -0,0 +1,12 @@ +using System; + +namespace Abc +{ + public static class Something + { + public static bool Api1(this String str) + { + return str == "foo"; + } + } +} diff --git a/test cases/unit/5 compiler detection/compiler wrapper.py b/test cases/unit/5 compiler detection/compiler wrapper.py new file mode 100644 index 0000000..fedd343 --- /dev/null +++ b/test cases/unit/5 compiler detection/compiler wrapper.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +import sys +import subprocess + +sys.exit(subprocess.call(sys.argv[1:])) diff --git a/test cases/unit/5 compiler detection/meson.build b/test cases/unit/5 compiler detection/meson.build new file mode 100644 index 0000000..8b47bd4 --- /dev/null +++ b/test cases/unit/5 compiler detection/meson.build @@ -0,0 +1,8 @@ +project('trivial test', + ['c', 'cpp', 'objc', 'objcpp'], + meson_version : '>=0.27.0') + +executable('trivialc', 'trivial.c') +executable('trivialcpp', 'trivial.cc') +executable('trivialobjc', 'trivial.m') +executable('trivialobjcpp', 'trivial.mm') diff --git a/test cases/unit/5 compiler detection/trivial.c b/test cases/unit/5 compiler detection/trivial.c new file mode 100644 index 0000000..24ac454 --- /dev/null +++ b/test cases/unit/5 compiler detection/trivial.c @@ -0,0 +1,6 @@ +#include<stdio.h> + +int main(int argc, char **argv) { + printf("Trivial test is working.\n"); + return 0; +} diff --git a/test cases/unit/5 compiler detection/trivial.cc b/test cases/unit/5 compiler detection/trivial.cc new file mode 100644 index 0000000..8aa907b --- /dev/null +++ b/test cases/unit/5 compiler detection/trivial.cc @@ -0,0 +1,6 @@ +#include<iostream> + +int main(int argc, char **argv) { + std::cout << "C++ seems to be working." << std::endl; + return 0; +} diff --git a/test cases/unit/5 compiler detection/trivial.m b/test cases/unit/5 compiler detection/trivial.m new file mode 100644 index 0000000..f2e2315 --- /dev/null +++ b/test cases/unit/5 compiler detection/trivial.m @@ -0,0 +1,5 @@ +#import<stdio.h> + +int main(int argc, char **argv) { + return 0; +}
\ No newline at end of file diff --git a/test cases/unit/5 compiler detection/trivial.mm b/test cases/unit/5 compiler detection/trivial.mm new file mode 100644 index 0000000..f9d4e19 --- /dev/null +++ b/test cases/unit/5 compiler detection/trivial.mm @@ -0,0 +1,8 @@ +#import<stdio.h> + +class MyClass { +}; + +int main(int argc, char **argv) { + return 0; +} diff --git a/test cases/unit/50 noncross options/meson.build b/test cases/unit/50 noncross options/meson.build new file mode 100644 index 0000000..6d479d6 --- /dev/null +++ b/test cases/unit/50 noncross options/meson.build @@ -0,0 +1,14 @@ +project('std_remains', 'c', default_options: ['c_std=c99']) + +executable('prog', 'prog.c') + +# Check that native: true does not affect the use of c_std in +# non-cross builds + +if not meson.is_cross_build() + executable('prog2', 'prog.c', native: true) + + # Check that even deps marked as native are found + # by default when not cross compiling. + dependency('ylib', method: 'pkg-config') +endif diff --git a/test cases/unit/50 noncross options/prog.c b/test cases/unit/50 noncross options/prog.c new file mode 100644 index 0000000..0314ff1 --- /dev/null +++ b/test cases/unit/50 noncross options/prog.c @@ -0,0 +1 @@ +int main(int argc, char **argv) { return 0; } diff --git a/test cases/unit/50 noncross options/ylib.pc b/test cases/unit/50 noncross options/ylib.pc new file mode 100644 index 0000000..afec2d3 --- /dev/null +++ b/test cases/unit/50 noncross options/ylib.pc @@ -0,0 +1,13 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${prefix}/lib/x86_64-linux-gnu +sharedlibdir=${libdir} +includedir=${prefix}/include + +Name: ylib +Description: ylib compression library +Version: 1.2.3 + +Requires: +Libs: -L${libdir} -L${sharedlibdir} -ly +Cflags: -I${includedir} diff --git a/test cases/unit/51 ldflagdedup/bob.c b/test cases/unit/51 ldflagdedup/bob.c new file mode 100644 index 0000000..a68d4b1 --- /dev/null +++ b/test cases/unit/51 ldflagdedup/bob.c @@ -0,0 +1,5 @@ +#include<gmodule.h> + +int func() { + return 0; +} diff --git a/test cases/unit/51 ldflagdedup/meson.build b/test cases/unit/51 ldflagdedup/meson.build new file mode 100644 index 0000000..0bbcc50 --- /dev/null +++ b/test cases/unit/51 ldflagdedup/meson.build @@ -0,0 +1,12 @@ +project('lddedup', 'c') + +# Chosen because its ldflags contains -Wl,--export-dynamic, +# which must be deduplicated. +gm = dependency('gmodule-2.0') + +lib = static_library('bob', 'bob.c', + dependencies: gm) + +executable('prog', 'prog.c', + link_with: lib, + dependencies: gm) diff --git a/test cases/unit/51 ldflagdedup/prog.c b/test cases/unit/51 ldflagdedup/prog.c new file mode 100644 index 0000000..02c599d --- /dev/null +++ b/test cases/unit/51 ldflagdedup/prog.c @@ -0,0 +1,7 @@ +#include<gmodule.h> + +int func(); + +int main(int argc, char **argv) { + return func(); +} diff --git a/test cases/unit/52 pkgconfig static link order/dummy.c b/test cases/unit/52 pkgconfig static link order/dummy.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/52 pkgconfig static link order/dummy.c diff --git a/test cases/unit/52 pkgconfig static link order/meson.build b/test cases/unit/52 pkgconfig static link order/meson.build new file mode 100644 index 0000000..31449e5 --- /dev/null +++ b/test cases/unit/52 pkgconfig static link order/meson.build @@ -0,0 +1,11 @@ +project('link order test', 'c') + +dep = library('dependency', 'dummy.c') +lib = static_library('something', 'dummy.c', link_with: dep) + +import('pkgconfig').generate( + name: 'libsomething', + description: 'test library', + libraries: lib, + version: '1' +) diff --git a/test cases/unit/53 clang-format/.clang-format b/test cases/unit/53 clang-format/.clang-format new file mode 100644 index 0000000..5c60ac9 --- /dev/null +++ b/test cases/unit/53 clang-format/.clang-format @@ -0,0 +1,5 @@ +--- +BasedOnStyle: LLVM +IndentWidth: 4 +UseTab: Never +--- diff --git a/test cases/unit/53 clang-format/dummydir.h/dummy.dat b/test cases/unit/53 clang-format/dummydir.h/dummy.dat new file mode 100644 index 0000000..80c6165 --- /dev/null +++ b/test cases/unit/53 clang-format/dummydir.h/dummy.dat @@ -0,0 +1 @@ +Placeholder to track enclosing directory in git. Not to be analyzed. diff --git a/test cases/unit/53 clang-format/header_expected_h b/test cases/unit/53 clang-format/header_expected_h new file mode 100644 index 0000000..4303176 --- /dev/null +++ b/test cases/unit/53 clang-format/header_expected_h @@ -0,0 +1,3 @@ +#pragma once + +int fun(int argc); diff --git a/test cases/unit/53 clang-format/header_orig_h b/test cases/unit/53 clang-format/header_orig_h new file mode 100644 index 0000000..f2222f3 --- /dev/null +++ b/test cases/unit/53 clang-format/header_orig_h @@ -0,0 +1,9 @@ +#pragma once + +int +fun +( +int +argc +) +; diff --git a/test cases/unit/53 clang-format/meson.build b/test cases/unit/53 clang-format/meson.build new file mode 100644 index 0000000..09973db --- /dev/null +++ b/test cases/unit/53 clang-format/meson.build @@ -0,0 +1,3 @@ +project('clangformat', 'c') + +executable('prog', 'prog.c') diff --git a/test cases/unit/53 clang-format/prog_expected_c b/test cases/unit/53 clang-format/prog_expected_c new file mode 100644 index 0000000..a045966 --- /dev/null +++ b/test cases/unit/53 clang-format/prog_expected_c @@ -0,0 +1,6 @@ +#include <stdio.h> + +int main(int argc, char **argv) { + printf("Awful.\n"); + return 0; +} diff --git a/test cases/unit/53 clang-format/prog_orig_c b/test cases/unit/53 clang-format/prog_orig_c new file mode 100644 index 0000000..23a2b57 --- /dev/null +++ b/test cases/unit/53 clang-format/prog_orig_c @@ -0,0 +1,20 @@ +#include <stdio.h> + + + + +int +main( +int +argc, +char** +argv) +{ +printf( +"Awful.\n" +) +; +return +0 +; +} diff --git a/test cases/unit/54 introspect buildoptions/subprojects/projectBad/meson.build b/test cases/unit/54 introspect buildoptions/subprojects/projectBad/meson.build new file mode 100644 index 0000000..4d0aeeb --- /dev/null +++ b/test cases/unit/54 introspect buildoptions/subprojects/projectBad/meson.build @@ -0,0 +1,9 @@ +pfggggaergaeg(sdgrgjgn)aga + +rgqeh +th +thtr +e +tb +tbqebt +tbqebttrtt diff --git a/test cases/unit/54 introspect buildoptions/subprojects/projectBad/meson_options.txt b/test cases/unit/54 introspect buildoptions/subprojects/projectBad/meson_options.txt new file mode 100644 index 0000000..f15d352 --- /dev/null +++ b/test cases/unit/54 introspect buildoptions/subprojects/projectBad/meson_options.txt @@ -0,0 +1 @@ +option('should_not_appear', type: 'integer', min: 0, value: 125) diff --git a/test cases/unit/55 dedup compiler libs/app/app.c b/test cases/unit/55 dedup compiler libs/app/app.c new file mode 100644 index 0000000..4e215b3 --- /dev/null +++ b/test cases/unit/55 dedup compiler libs/app/app.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <liba.h> +#include <libb.h> + +int +main(void) +{ + printf("start value = %d\n", liba_get()); + liba_add(2); + libb_mul(5); + printf("end value = %d\n", liba_get()); + return 0; +} diff --git a/test cases/unit/55 dedup compiler libs/app/meson.build b/test cases/unit/55 dedup compiler libs/app/meson.build new file mode 100644 index 0000000..82ac306 --- /dev/null +++ b/test cases/unit/55 dedup compiler libs/app/meson.build @@ -0,0 +1,2 @@ +executable('app', 'app.c', + dependencies: [liba_dep, libb_dep]) diff --git a/test cases/unit/55 dedup compiler libs/liba/liba.c b/test cases/unit/55 dedup compiler libs/liba/liba.c new file mode 100644 index 0000000..962d47f --- /dev/null +++ b/test cases/unit/55 dedup compiler libs/liba/liba.c @@ -0,0 +1,18 @@ +#include "liba.h" + +static int val; + +void liba_add(int x) +{ + val += x; +} + +void liba_sub(int x) +{ + val -= x; +} + +int liba_get(void) +{ + return val; +} diff --git a/test cases/unit/55 dedup compiler libs/liba/liba.h b/test cases/unit/55 dedup compiler libs/liba/liba.h new file mode 100644 index 0000000..a980cdc --- /dev/null +++ b/test cases/unit/55 dedup compiler libs/liba/liba.h @@ -0,0 +1,8 @@ +#ifndef LIBA_H_ +#define LIBA_H_ + +void liba_add(int x); +void liba_sub(int x); +int liba_get(void); + +#endif diff --git a/test cases/unit/55 dedup compiler libs/liba/meson.build b/test cases/unit/55 dedup compiler libs/liba/meson.build new file mode 100644 index 0000000..eccfa46 --- /dev/null +++ b/test cases/unit/55 dedup compiler libs/liba/meson.build @@ -0,0 +1,8 @@ +deps = [dependency('threads'), cc.find_library('dl'), cc.find_library('m')] + +liba = library('a', 'liba.c', + dependencies: deps) + +liba_dep = declare_dependency(link_with: liba, + include_directories: include_directories('.'), + dependencies: deps) diff --git a/test cases/unit/55 dedup compiler libs/libb/libb.c b/test cases/unit/55 dedup compiler libs/libb/libb.c new file mode 100644 index 0000000..3720868 --- /dev/null +++ b/test cases/unit/55 dedup compiler libs/libb/libb.c @@ -0,0 +1,7 @@ +#include <liba.h> +#include "libb.h" + +void libb_mul(int x) +{ + liba_add(liba_get() * (x - 1)); +} diff --git a/test cases/unit/55 dedup compiler libs/libb/libb.h b/test cases/unit/55 dedup compiler libs/libb/libb.h new file mode 100644 index 0000000..2e4ddd0 --- /dev/null +++ b/test cases/unit/55 dedup compiler libs/libb/libb.h @@ -0,0 +1,6 @@ +#ifndef _LIBB_H_ +#define _LIBB_H_ + +void libb_mul(int x); + +#endif diff --git a/test cases/unit/55 dedup compiler libs/libb/meson.build b/test cases/unit/55 dedup compiler libs/libb/meson.build new file mode 100644 index 0000000..d59206f --- /dev/null +++ b/test cases/unit/55 dedup compiler libs/libb/meson.build @@ -0,0 +1,6 @@ +libb = library('b', 'libb.c', + dependencies: liba_dep) + +libb_dep = declare_dependency(link_with: libb, + include_directories: include_directories('.'), + dependencies: liba_dep) diff --git a/test cases/unit/55 dedup compiler libs/meson.build b/test cases/unit/55 dedup compiler libs/meson.build new file mode 100644 index 0000000..fad0ed5 --- /dev/null +++ b/test cases/unit/55 dedup compiler libs/meson.build @@ -0,0 +1,7 @@ +project('temp', 'c') + +cc = meson.get_compiler('c') + +subdir('liba') +subdir('libb') +subdir('app') diff --git a/test cases/unit/56 introspection/cp.py b/test cases/unit/56 introspection/cp.py new file mode 100644 index 0000000..cb09cf3 --- /dev/null +++ b/test cases/unit/56 introspection/cp.py @@ -0,0 +1,5 @@ +#! /usr/bin/env python3 + +import sys +from shutil import copyfile +copyfile(*sys.argv[1:]) diff --git a/test cases/unit/56 introspection/meson.build b/test cases/unit/56 introspection/meson.build new file mode 100644 index 0000000..568d5cc --- /dev/null +++ b/test cases/unit/56 introspection/meson.build @@ -0,0 +1,72 @@ +project('introspection', ['c', 'cpp'], version: '1.2.3', default_options: ['cpp_std=c++11', 'buildtype=debug']) + +dep1 = dependency('threads') +dep2 = dependency('zlib', required: false) +dep3 = dependency('bugDep1', required: get_option('test_opt1')) + +b1 = get_option('test_opt1') +b2 = get_option('test_opt2') +test_bool = b1 or b2 +test_bool = b1 and b2 +test_bool = not test_bool + +set_variable('list_test_plusassign', []) +list_test_plusassign += ['bugs everywhere'] +dict_test = {list_test_plusassign[0]: 'even more bugs'} + +if not true + vers_str = '<=99.9.9' + dependency('somethingthatdoesnotexist', required: true, version: '>=1.2.3') + dependency('look_i_have_a_fallback', version: ['>=1.0.0', vers_str], fallback: ['oh_no', 'the_subproject_does_not_exist']) +endif + +subdir('sharedlib') +subdir('staticlib') + +var1 = '1' +var2 = 2.to_string() +var3 = 'test3' + +var4 = f'test @var1@ string' # TODO: Actually implement fstrings + +cus1 = custom_target('custom target test 1', output: 'file2', input: 'cp.py', + command: [find_program('cp.py'), '@INPUT@', '@OUTPUT@']) +cus2 = custom_target('custom target test 2', output: 'file3', input: cus1, + command: [find_program('cp.py'), '@INPUT@', '@OUTPUT@']) + +t1 = executable('test' + var1, ['t1.cpp'], link_with: [sharedlib], install: not false, build_by_default: get_option('test_opt2')) +t2 = executable('test@0@'.format('@0@'.format(var2)), sources: ['t2.cpp'], link_with: [staticlib]) +t3 = executable(var3, 't3.cpp', link_with: [sharedlib, staticlib], dependencies: [dep1]) + +cus3 = custom_target('custom target test 3', output: 'file4', input: t3, + command: [find_program('cp.py'), '@INPUT@', '@OUTPUT@']) + +### BEGIN: Test inspired by taisei: https://github.com/taisei-project/taisei/blob/master/meson.build#L293 +systype = '@0@'.format(host_machine.system()) +systype = '@0@, @1@, @2@'.format(systype, host_machine.cpu_family(), host_machine.cpu()) +message(systype) +### END: Test inspired by taisei + +# Minimal code version to produce bug #5376 +# Code inspired by https://github.com/mesa3d/mesa/blob/974c4d679c23373dbed386c696e3e3bc1bfa23ae/meson.build#L1341-L1347 +osmesa_lib_name = 'OSMesa' +osmesa_bits = '8' +osmesa_lib_name = osmesa_lib_name + osmesa_bits +message(osmesa_lib_name) # Infinite recursion gets triggered here when the parameter osmesa_lib_name is resolved + +test('test case 1', t1) +test('test case 2', t2, depends: t3) +benchmark('benchmark 1', t3, args: [cus1, cus2, cus3]) + +### Stuff to test the AST JSON printer +foreach x : ['a', 'b', 'c'] + if x == 'a' + message('a') + elif x == 'b' + message('a') + else + continue + endif + break + continue +endforeach diff --git a/test cases/unit/56 introspection/meson_options.txt b/test cases/unit/56 introspection/meson_options.txt new file mode 100644 index 0000000..fc5cb4d --- /dev/null +++ b/test cases/unit/56 introspection/meson_options.txt @@ -0,0 +1,2 @@ +option('test_opt1', type: 'boolean', value: false, description: 'simple boolean flag') +option('test_opt2', type: 'boolean', value: true, description: 'simple boolean flag') diff --git a/test cases/unit/56 introspection/sharedlib/meson.build b/test cases/unit/56 introspection/sharedlib/meson.build new file mode 100644 index 0000000..7640bc7 --- /dev/null +++ b/test cases/unit/56 introspection/sharedlib/meson.build @@ -0,0 +1,2 @@ +SRC_shared = ['shared.cpp'] +sharedlib = shared_library('sharedTestLib', SRC_shared, extra_files: ['shared.hpp']) diff --git a/test cases/unit/56 introspection/sharedlib/shared.cpp b/test cases/unit/56 introspection/sharedlib/shared.cpp new file mode 100644 index 0000000..5030ab7 --- /dev/null +++ b/test cases/unit/56 introspection/sharedlib/shared.cpp @@ -0,0 +1,9 @@ +#include "shared.hpp" + +void SharedClass::doStuff() { + number++; +} + +int SharedClass::getNumber() const { + return number; +} diff --git a/test cases/unit/56 introspection/sharedlib/shared.hpp b/test cases/unit/56 introspection/sharedlib/shared.hpp new file mode 100644 index 0000000..dc9b2da --- /dev/null +++ b/test cases/unit/56 introspection/sharedlib/shared.hpp @@ -0,0 +1,10 @@ +#pragma once + +class SharedClass { + private: + int number = 42; + public: + SharedClass() = default; + void doStuff(); + int getNumber() const; +};
\ No newline at end of file diff --git a/test cases/unit/56 introspection/staticlib/meson.build b/test cases/unit/56 introspection/staticlib/meson.build new file mode 100644 index 0000000..1cbb020 --- /dev/null +++ b/test cases/unit/56 introspection/staticlib/meson.build @@ -0,0 +1,3 @@ +SRC_static = ['static.c'] +extra_static = files(['static.h']) +staticlib = static_library('staticTestLib', SRC_static, extra_files: extra_static) diff --git a/test cases/unit/56 introspection/staticlib/static.c b/test cases/unit/56 introspection/staticlib/static.c new file mode 100644 index 0000000..37ebc0d --- /dev/null +++ b/test cases/unit/56 introspection/staticlib/static.c @@ -0,0 +1,5 @@ +#include "static.h" + +int add_numbers(int a, int b) { + return a + b; +}
\ No newline at end of file diff --git a/test cases/unit/56 introspection/staticlib/static.h b/test cases/unit/56 introspection/staticlib/static.h new file mode 100644 index 0000000..06da508 --- /dev/null +++ b/test cases/unit/56 introspection/staticlib/static.h @@ -0,0 +1,11 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +int add_numbers(int a, int b); + +#ifdef __cplusplus +} +#endif diff --git a/test cases/unit/56 introspection/t1.cpp b/test cases/unit/56 introspection/t1.cpp new file mode 100644 index 0000000..901e3f1 --- /dev/null +++ b/test cases/unit/56 introspection/t1.cpp @@ -0,0 +1,13 @@ +#include "sharedlib/shared.hpp" + +int main(void) { + SharedClass cl1; + if(cl1.getNumber() != 42) { + return 1; + } + cl1.doStuff(); + if(cl1.getNumber() != 43) { + return 2; + } + return 0; +} diff --git a/test cases/unit/56 introspection/t2.cpp b/test cases/unit/56 introspection/t2.cpp new file mode 100644 index 0000000..8323f46 --- /dev/null +++ b/test cases/unit/56 introspection/t2.cpp @@ -0,0 +1,8 @@ +#include "staticlib/static.h" + +int main(void) { + if(add_numbers(1, 2) != 3) { + return 1; + } + return 0; +} diff --git a/test cases/unit/56 introspection/t3.cpp b/test cases/unit/56 introspection/t3.cpp new file mode 100644 index 0000000..dd518e8 --- /dev/null +++ b/test cases/unit/56 introspection/t3.cpp @@ -0,0 +1,16 @@ +#include "sharedlib/shared.hpp" +#include "staticlib/static.h" + +int main(void) { + for(int i = 0; i < 1000; add_numbers(i, 1)) { + SharedClass cl1; + if(cl1.getNumber() != 42) { + return 1; + } + cl1.doStuff(); + if(cl1.getNumber() != 43) { + return 2; + } + } + return 0; +} diff --git a/test cases/unit/57 pkg_config_path option/build_extra_path/totally_made_up_dep.pc b/test cases/unit/57 pkg_config_path option/build_extra_path/totally_made_up_dep.pc new file mode 100644 index 0000000..5b149f6 --- /dev/null +++ b/test cases/unit/57 pkg_config_path option/build_extra_path/totally_made_up_dep.pc @@ -0,0 +1,7 @@ +prefix=/ +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: totally_made_up_dep +Description: completely and totally made up for a test case +Version: 4.5.6 diff --git a/test cases/unit/57 pkg_config_path option/host_extra_path/totally_made_up_dep.pc b/test cases/unit/57 pkg_config_path option/host_extra_path/totally_made_up_dep.pc new file mode 100644 index 0000000..6d08687 --- /dev/null +++ b/test cases/unit/57 pkg_config_path option/host_extra_path/totally_made_up_dep.pc @@ -0,0 +1,7 @@ +prefix=/ +libdir=${prefix}/lib +includedir=${prefix}/include + +Name: totally_made_up_dep +Description: completely and totally made up for a test case +Version: 1.2.3
\ No newline at end of file diff --git a/test cases/unit/57 pkg_config_path option/meson.build b/test cases/unit/57 pkg_config_path option/meson.build new file mode 100644 index 0000000..f9ceead --- /dev/null +++ b/test cases/unit/57 pkg_config_path option/meson.build @@ -0,0 +1,7 @@ +project('pkg_config_path option') + +build = dependency('totally_made_up_dep', native: true, method : 'pkg-config') +host = dependency('totally_made_up_dep', native: false, method : 'pkg-config') + +assert(build.version() == '4.5.6', 'wrong version for build machine dependency') +assert(host.version() == '1.2.3', 'wrong version for host machine dependency') diff --git a/test cases/unit/58 introspect buildoptions/c_compiler.py b/test cases/unit/58 introspect buildoptions/c_compiler.py new file mode 100644 index 0000000..c7241e7 --- /dev/null +++ b/test cases/unit/58 introspect buildoptions/c_compiler.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python3 + +print('c') diff --git a/test cases/unit/58 introspect buildoptions/main.c b/test cases/unit/58 introspect buildoptions/main.c new file mode 100644 index 0000000..709730f --- /dev/null +++ b/test cases/unit/58 introspect buildoptions/main.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +int main(void) { + printf("Hello World"); + return 0; +} diff --git a/test cases/unit/58 introspect buildoptions/meson.build b/test cases/unit/58 introspect buildoptions/meson.build new file mode 100644 index 0000000..36e03e0 --- /dev/null +++ b/test cases/unit/58 introspect buildoptions/meson.build @@ -0,0 +1,18 @@ +project('introspect buildargs', ['c'], default_options: ['c_std=c99', 'cpp_std=c++14', 'buildtype=release']) + +subA = subproject('projectA') + +target_name = 'MAIN' +target_src = ['main.c'] + +foo = false + +executable(target_name, target_src, build_by_default : foo) + +r = run_command(find_program('c_compiler.py'), check: false) +if r.returncode() != 0 + error('FAILED') +endif + +add_languages(r.stdout().strip(), required: true) +add_languages('afgggergearvearghergervergreaergaergasv', required: false) diff --git a/test cases/unit/58 introspect buildoptions/meson_options.txt b/test cases/unit/58 introspect buildoptions/meson_options.txt new file mode 100644 index 0000000..61f9a8d --- /dev/null +++ b/test cases/unit/58 introspect buildoptions/meson_options.txt @@ -0,0 +1,2 @@ +option('max_register_count', type: 'integer', min: 0, value: 125) +option('use_external_fmt', type: 'boolean', value: false) diff --git a/test cases/unit/58 introspect buildoptions/subprojects/evilFile.txt b/test cases/unit/58 introspect buildoptions/subprojects/evilFile.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/58 introspect buildoptions/subprojects/evilFile.txt diff --git a/test cases/unit/58 introspect buildoptions/subprojects/projectA/meson.build b/test cases/unit/58 introspect buildoptions/subprojects/projectA/meson.build new file mode 100644 index 0000000..1ab9ee8 --- /dev/null +++ b/test cases/unit/58 introspect buildoptions/subprojects/projectA/meson.build @@ -0,0 +1,3 @@ +project('introspect subproject A', 'c', default_options: ['cpp_std=c++11', 'buildtype=debug']) + +add_languages('cpp') diff --git a/test cases/unit/58 introspect buildoptions/subprojects/projectA/meson_options.txt b/test cases/unit/58 introspect buildoptions/subprojects/projectA/meson_options.txt new file mode 100644 index 0000000..fa77f95 --- /dev/null +++ b/test cases/unit/58 introspect buildoptions/subprojects/projectA/meson_options.txt @@ -0,0 +1 @@ +option('subproj_var', type: 'boolean', value: false) diff --git a/test cases/unit/58 introspect buildoptions/subprojects/projectBad/meson.build b/test cases/unit/58 introspect buildoptions/subprojects/projectBad/meson.build new file mode 100644 index 0000000..500c1b9 --- /dev/null +++ b/test cases/unit/58 introspect buildoptions/subprojects/projectBad/meson.build @@ -0,0 +1,9 @@ +pfggggaergaeg(sdgrgjgn)aga + +rgqeh +th +thtr +e +tb +tbqebt +tbqebttrtt
\ No newline at end of file diff --git a/test cases/unit/58 introspect buildoptions/subprojects/projectBad/meson_options.txt b/test cases/unit/58 introspect buildoptions/subprojects/projectBad/meson_options.txt new file mode 100644 index 0000000..f15d352 --- /dev/null +++ b/test cases/unit/58 introspect buildoptions/subprojects/projectBad/meson_options.txt @@ -0,0 +1 @@ +option('should_not_appear', type: 'integer', min: 0, value: 125) diff --git a/test cases/unit/59 native file override/crossfile b/test cases/unit/59 native file override/crossfile new file mode 100644 index 0000000..9dc4fbc --- /dev/null +++ b/test cases/unit/59 native file override/crossfile @@ -0,0 +1,16 @@ +[paths] +bindir = 'binbar' +datadir = 'databar' +includedir = 'includebar' +infodir = 'infobar' +libdir = 'libbar' +libexecdir = 'libexecbar' +localedir = 'localebar' +localstatedir = 'localstatebar' +mandir = 'manbar' +prefix = '/prefix' +sbindir = 'sbinbar' +sharedstatedir = 'sharedstatebar' +sysconfdir = 'sysconfbar' + +; vim: ft=dosini diff --git a/test cases/unit/59 native file override/crossfile2 b/test cases/unit/59 native file override/crossfile2 new file mode 100644 index 0000000..70946c9 --- /dev/null +++ b/test cases/unit/59 native file override/crossfile2 @@ -0,0 +1,4 @@ +[paths] +bindir = 'binbar2' + +; vim: ft=dosini diff --git a/test cases/unit/59 native file override/meson.build b/test cases/unit/59 native file override/meson.build new file mode 100644 index 0000000..6ada560 --- /dev/null +++ b/test cases/unit/59 native file override/meson.build @@ -0,0 +1,10 @@ +project('native file overrides') + +foreach o : ['bindir', 'datadir', 'includedir', 'infodir', 'libdir', + 'libexecdir', 'localedir', 'localstatedir', 'mandir', 'prefix', + 'sbindir', 'sharedstatedir', 'sysconfdir'] + expected = get_option('def_' + o) + actual = get_option(o) + assert(expected == actual, + '@0@ should have been @1@, but was @2@!'.format(o, expected, actual)) +endforeach diff --git a/test cases/unit/59 native file override/meson_options.txt b/test cases/unit/59 native file override/meson_options.txt new file mode 100644 index 0000000..4d2abf9 --- /dev/null +++ b/test cases/unit/59 native file override/meson_options.txt @@ -0,0 +1,13 @@ +option('def_bindir', type: 'string', value : 'binfoo',) +option('def_datadir', type: 'string', value : 'datafoo',) +option('def_includedir', type: 'string', value : 'includefoo',) +option('def_infodir', type: 'string', value : 'infofoo',) +option('def_libdir', type: 'string', value : 'libfoo',) +option('def_libexecdir', type: 'string', value : 'libexecfoo',) +option('def_localedir', type: 'string', value : 'localefoo',) +option('def_localstatedir', type: 'string', value : 'localstatefoo',) +option('def_mandir', type: 'string', value : 'manfoo',) +option('def_prefix', type: 'string', value : '/prefix',) +option('def_sbindir', type: 'string', value : 'sbinfoo',) +option('def_sharedstatedir', type: 'string', value : 'sharedstatefoo',) +option('def_sysconfdir', type: 'string', value : 'sysconffoo',) diff --git a/test cases/unit/59 native file override/nativefile b/test cases/unit/59 native file override/nativefile new file mode 100644 index 0000000..a390725 --- /dev/null +++ b/test cases/unit/59 native file override/nativefile @@ -0,0 +1,16 @@ +[paths] +bindir = 'binfoo' +datadir = 'datafoo' +includedir = 'includefoo' +infodir = 'infofoo' +libdir = 'libfoo' +libexecdir = 'libexecfoo' +localedir = 'localefoo' +localstatedir = 'localstatefoo' +mandir = 'manfoo' +prefix = '/prefix' +sbindir = 'sbinfoo' +sharedstatedir = 'sharedstatefoo' +sysconfdir = 'sysconffoo' + +; vim: ft=dosini diff --git a/test cases/unit/6 std override/meson.build b/test cases/unit/6 std override/meson.build new file mode 100644 index 0000000..0eac752 --- /dev/null +++ b/test cases/unit/6 std override/meson.build @@ -0,0 +1,10 @@ +project('cpp std override', 'cpp', + default_options : ['cpp_std=c++98', + 'werror=true']) + +executable('plain', 'progp.cpp', + override_options : 'cpp_std=none') +executable('v98', 'prog98.cpp', + override_options : 'werror=false') +executable('v11', 'prog11.cpp', + override_options : 'cpp_std=c++11') diff --git a/test cases/unit/6 std override/prog11.cpp b/test cases/unit/6 std override/prog11.cpp new file mode 100644 index 0000000..dde1fc0 --- /dev/null +++ b/test cases/unit/6 std override/prog11.cpp @@ -0,0 +1,6 @@ +#include<iostream> + +int main(int argc, char **argv) { + std::cout << "I am a C++11 test program.\n"; + return 0; +} diff --git a/test cases/unit/6 std override/prog98.cpp b/test cases/unit/6 std override/prog98.cpp new file mode 100644 index 0000000..67c326d --- /dev/null +++ b/test cases/unit/6 std override/prog98.cpp @@ -0,0 +1,6 @@ +#include<iostream> + +int main(int argc, char **argv) { + std::cout << "I am a c++98 test program.\n"; + return 0; +} diff --git a/test cases/unit/6 std override/progp.cpp b/test cases/unit/6 std override/progp.cpp new file mode 100644 index 0000000..b9bd97f --- /dev/null +++ b/test cases/unit/6 std override/progp.cpp @@ -0,0 +1,6 @@ +#include<iostream> + +int main(int argc, char **argv) { + std::cout << "I am a test program of undefined C++ standard.\n"; + return 0; +} diff --git a/test cases/unit/60 identity cross/build_wrapper.py b/test cases/unit/60 identity cross/build_wrapper.py new file mode 100755 index 0000000..15d5c07 --- /dev/null +++ b/test cases/unit/60 identity cross/build_wrapper.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +import subprocess, sys, platform + +# Meson does not yet support Studio cc on Solaris, only gcc or clang +if platform.system() == 'SunOS': + cc = 'gcc' +else: + cc = 'cc' + +subprocess.call([cc, "-DEXTERNAL_BUILD"] + sys.argv[1:]) diff --git a/test cases/unit/60 identity cross/host_wrapper.py b/test cases/unit/60 identity cross/host_wrapper.py new file mode 100755 index 0000000..a3a694a --- /dev/null +++ b/test cases/unit/60 identity cross/host_wrapper.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +import subprocess, sys, platform + +# Meson does not yet support Studio cc on Solaris, only gcc or clang +if platform.system() == 'SunOS': + cc = 'gcc' +else: + cc = 'cc' + +subprocess.call([cc, "-DEXTERNAL_HOST"] + sys.argv[1:]) diff --git a/test cases/unit/60 identity cross/meson.build b/test cases/unit/60 identity cross/meson.build new file mode 100644 index 0000000..950137a --- /dev/null +++ b/test cases/unit/60 identity cross/meson.build @@ -0,0 +1,15 @@ +project('identity cross test', 'c') + +assert(meson.get_compiler('c', native: true).get_define( + 'GOT', + args : [ '-DARG_BUILD' ], + prefix : '#include "stuff.h"', + include_directories: include_directories('.'), +) == 'BUILD', 'did not get BUILD from native: true compiler') + +assert(meson.get_compiler('c', native: false).get_define( + 'GOT', + args : [ '-DARG_HOST' ], + prefix : '#include "stuff.h"', + include_directories: include_directories('.'), +) == 'HOST', 'did not get HOST from native: false compiler') diff --git a/test cases/unit/60 identity cross/stuff.h b/test cases/unit/60 identity cross/stuff.h new file mode 100644 index 0000000..62f1cc9 --- /dev/null +++ b/test cases/unit/60 identity cross/stuff.h @@ -0,0 +1,27 @@ +#ifdef EXTERNAL_BUILD + #ifndef ARG_BUILD + #error "External is build but arg_build is not set." + #elif defined(ARG_HOST) + #error "External is build but arg_host is set." + #else + #define GOT BUILD + #endif +#endif + +#ifdef EXTERNAL_HOST + #ifndef ARG_HOST + #error "External is host but arg_host is not set." + #elif defined(ARG_BUILD) + #error "External is host but arg_build is set." + #else + #define GOT HOST + #endif +#endif + +#if defined(EXTERNAL_BUILD) && defined(EXTERNAL_HOST) + #error "Both external build and external host set." +#endif + +#if !defined(EXTERNAL_BUILD) && !defined(EXTERNAL_HOST) + #error "Neither external build nor external host is set." +#endif diff --git a/test cases/unit/61 pkgconfig relative paths/pkgconfig/librelativepath.pc b/test cases/unit/61 pkgconfig relative paths/pkgconfig/librelativepath.pc new file mode 100644 index 0000000..dae1eed --- /dev/null +++ b/test cases/unit/61 pkgconfig relative paths/pkgconfig/librelativepath.pc @@ -0,0 +1,9 @@ +prefix=../relativepath +exec_prefix=${prefix} +libdir=${exec_prefix}/lib + +Name: Relative path +Description: Relative path library +Version: 0.0.1 +Libs: -L${libdir} -lrelativepath +Cflags: diff --git a/test cases/unit/62 cmake_prefix_path/meson.build b/test cases/unit/62 cmake_prefix_path/meson.build new file mode 100644 index 0000000..442bbd3 --- /dev/null +++ b/test cases/unit/62 cmake_prefix_path/meson.build @@ -0,0 +1,4 @@ +project('cmake prefix path test') + +d = dependency('mesontest', method : 'cmake') +assert(d.version() == '1.2.3', 'Got the wrong version!') diff --git a/test cases/unit/62 cmake_prefix_path/prefix/lib/cmake/mesontest/mesontest-config.cmake b/test cases/unit/62 cmake_prefix_path/prefix/lib/cmake/mesontest/mesontest-config.cmake new file mode 100644 index 0000000..289b349 --- /dev/null +++ b/test cases/unit/62 cmake_prefix_path/prefix/lib/cmake/mesontest/mesontest-config.cmake @@ -0,0 +1,4 @@ +set(MESONTEST_VERSION "1.2.3") +set(MESONTEST_LIBRARIES "foo.so") +set(MESONTEST_INCLUDE_DIR "") +set(MESONTEST_FOUND "TRUE") diff --git a/test cases/unit/63 cmake parser/meson.build b/test cases/unit/63 cmake parser/meson.build new file mode 100644 index 0000000..472561d --- /dev/null +++ b/test cases/unit/63 cmake parser/meson.build @@ -0,0 +1,19 @@ +project('61 cmake parser') + +dep = dependency('mesontest') + +# Test a bunch of variations of the set() command +assert(dep.get_variable(cmake : 'VAR_WITHOUT_SPACES') == 'NoSpaces', 'set() without spaces incorrect') +assert(dep.get_variable(cmake : 'VAR_WITH_SPACES') == 'With Spaces', 'set() with spaces incorrect') + +assert(dep.get_variable(cmake : 'VAR_WITHOUT_SPACES_PS') == 'NoSpaces', 'set(PARENT_SCOPE) without spaces incorrect') +assert(dep.get_variable(cmake : 'VAR_WITH_SPACES_PS') == 'With Spaces', 'set(PARENT_SCOPE) with spaces incorrect') + +assert(dep.get_variable(cmake : 'VAR_THAT_IS_UNSET', default_value : 'sentinal') == 'sentinal', 'set() to unset is incorrect') +assert(dep.get_variable(cmake : 'CACHED_STRING_NS') == 'foo', 'set(CACHED) without spaces is incorrect') +assert(dep.get_variable(cmake : 'CACHED_STRING_WS') == 'foo bar', 'set(CACHED STRING) with spaces is incorrect') +assert(dep.get_variable(cmake : 'CACHED_STRING_ARRAY_NS') == 'foo;bar', 'set(CACHED STRING) without spaces is incorrect') +assert(dep.get_variable(cmake : 'CACHED_STRING_ARRAY_WS') == 'foo;foo bar;bar', 'set(CACHED STRING[]) with spaces is incorrect') + +# We don't support this, so it should be unset. +assert(dep.get_variable(cmake : 'ENV{var}', default_value : 'sentinal') == 'sentinal', 'set(ENV) should be ignored') diff --git a/test cases/unit/63 cmake parser/prefix/lib/cmake/mesontest/mesontest-config.cmake b/test cases/unit/63 cmake parser/prefix/lib/cmake/mesontest/mesontest-config.cmake new file mode 100644 index 0000000..7474eb7 --- /dev/null +++ b/test cases/unit/63 cmake parser/prefix/lib/cmake/mesontest/mesontest-config.cmake @@ -0,0 +1,63 @@ +# This should be enough to satisfy the basic parser +set(MESONTEST_VERSION "1.2.3") +set(MESONTEST_LIBRARIES "foo.so") +set(MESONTEST_INCLUDE_DIR "") +set(MESONTEST_FOUND "TRUE") + +## Tests for set() in its various forms + +# Basic usage +set(VAR_WITHOUT_SPACES "NoSpaces") +set(VAR_WITH_SPACES "With Spaces") + +# test of PARENT_SCOPE, requires a function to have a parent scope obviously... +function(foo) + set(VAR_WITHOUT_SPACES_PS "NoSpaces" PARENT_SCOPE) + set(VAR_WITH_SPACES_PS "With Spaces" PARENT_SCOPE) +endfunction(foo) +foo() + +# Using set() to unset values +set(VAR_THAT_IS_UNSET "foo") +set(VAR_THAT_IS_UNSET) + +# The more advanced form that uses CACHE +# XXX: Why don't we read the type and use that instead of always treat things as strings? +set(CACHED_STRING_NS "foo" CACHE STRING "docstring") +set(CACHED_STRING_WS "foo bar" CACHE STRING "docstring") +set(CACHED_STRING_ARRAY_NS "foo;bar" CACHE STRING "doc string") +set(CACHED_STRING_ARRAY_WS "foo;foo bar;bar" CACHE STRING "stuff" FORCE) + +set(CACHED_BOOL ON CACHE BOOL "docstring") + +set(CACHED_PATH_NS "foo/bar" CACHE PATH "docstring") +set(CACHED_PATH_WS "foo bar/fin" CACHE PATH "docstring") + +set(CACHED_FILEPATH_NS "foo/bar.txt" CACHE FILEPATH "docstring") +set(CACHED_FILEPATH_WS "foo bar/fin.txt" CACHE FILEPATH "docstring") + +# Set ENV, we don't support this so it shouldn't be showing up +set(ENV{var}, "foo") + + +## Tests for set_properties() +# We need something to attach properties too +add_custom_target(MESONTEST_FOO ALL) + +set_property(TARGET MESONTEST_FOO PROPERTY FOLDER "value") +set_property(TARGET MESONTEST_FOO APPEND PROPERTY FOLDER "name") +set_property(TARGET MESONTEST_FOO PROPERTY FOLDER "value") +set_property(TARGET MESONTEST_FOO APPEND_STRING PROPERTY FOLDER "name") + +set_property(TARGET MESONTEST_FOO PROPERTY FOLDER "value space") +set_property(TARGET MESONTEST_FOO PROPERTY FOLDER "value space") +set_property(TARGET MESONTEST_FOO APPEND PROPERTY FOLDER "name space") +set_property(TARGET MESONTEST_FOO PROPERTY FOLDER "value space") +set_property(TARGET MESONTEST_FOO APPEND_STRING PROPERTY FOLDER "name space") + +## Tests for set_target_properties() +set_target_properties(MESONTEST_FOO PROPERTIES FOLDER "value") +set_target_properties(MESONTEST_FOO PROPERTIES FOLDER "value space") +set_target_properties(MESONTEST_FOO PROPERTIES FOLDER "value" OUTPUT_NAME "another value") +set_target_properties(MESONTEST_FOO PROPERTIES FOLDER "value space" OUTPUT_NAME "another value") +set_target_properties(MESONTEST_FOO PROPERTIES FOLDER "value space" OUTPUT_NAME "value")
\ No newline at end of file diff --git a/test cases/unit/64 alias target/main.c b/test cases/unit/64 alias target/main.c new file mode 100644 index 0000000..0fb4389 --- /dev/null +++ b/test cases/unit/64 alias target/main.c @@ -0,0 +1,3 @@ +int main(int argc, char *argv[]) { + return 0; +} diff --git a/test cases/unit/64 alias target/meson.build b/test cases/unit/64 alias target/meson.build new file mode 100644 index 0000000..bcd4005 --- /dev/null +++ b/test cases/unit/64 alias target/meson.build @@ -0,0 +1,17 @@ +project('alias target', 'c') + +python3 = import('python').find_installation() + +exe_target = executable('prog', 'main.c', + build_by_default : false) + +custom_target = custom_target('custom-target', + output : 'hello.txt', + command : [python3, '-c', 'print("hello")'], + capture : true, + build_by_default : false +) + +alias_target('build-all', [exe_target, custom_target]) + +subdir('subdir') diff --git a/test cases/unit/64 alias target/subdir/meson.build b/test cases/unit/64 alias target/subdir/meson.build new file mode 100644 index 0000000..b3f5480 --- /dev/null +++ b/test cases/unit/64 alias target/subdir/meson.build @@ -0,0 +1,6 @@ +r = run_target('run-target', + command: [python3, '-c', 'print("a run target was here")'] +) + +alias_target('aliased-run', r) + diff --git a/test cases/unit/65 static archive stripping/app/appA.c b/test cases/unit/65 static archive stripping/app/appA.c new file mode 100644 index 0000000..e44b54a --- /dev/null +++ b/test cases/unit/65 static archive stripping/app/appA.c @@ -0,0 +1,4 @@ +#include <stdio.h> +#include <libA.h> + +int main(void) { printf("The answer is: %d\n", libA_func()); } diff --git a/test cases/unit/65 static archive stripping/app/appB.c b/test cases/unit/65 static archive stripping/app/appB.c new file mode 100644 index 0000000..0ec0b62 --- /dev/null +++ b/test cases/unit/65 static archive stripping/app/appB.c @@ -0,0 +1,4 @@ +#include <stdio.h> +#include <libB.h> + +int main(void) { printf("The answer is: %d\n", libB_func()); } diff --git a/test cases/unit/65 static archive stripping/app/meson.build b/test cases/unit/65 static archive stripping/app/meson.build new file mode 100644 index 0000000..118719d --- /dev/null +++ b/test cases/unit/65 static archive stripping/app/meson.build @@ -0,0 +1,7 @@ +project('app', ['c']) + +a = dependency('test-a') +b = dependency('test-b') + +executable('appA', files('appA.c'), dependencies : a) +executable('appB', files('appB.c'), dependencies : b) diff --git a/test cases/unit/65 static archive stripping/lib/libA.c b/test cases/unit/65 static archive stripping/lib/libA.c new file mode 100644 index 0000000..a97185e --- /dev/null +++ b/test cases/unit/65 static archive stripping/lib/libA.c @@ -0,0 +1,5 @@ +#include <libA.h> + +static int libA_func_impl(void) { return 0; } + +int libA_func(void) { return libA_func_impl(); } diff --git a/test cases/unit/65 static archive stripping/lib/libA.h b/test cases/unit/65 static archive stripping/lib/libA.h new file mode 100644 index 0000000..e6450cd --- /dev/null +++ b/test cases/unit/65 static archive stripping/lib/libA.h @@ -0,0 +1 @@ +int libA_func(void); diff --git a/test cases/unit/65 static archive stripping/lib/libB.c b/test cases/unit/65 static archive stripping/lib/libB.c new file mode 100644 index 0000000..0200b1f --- /dev/null +++ b/test cases/unit/65 static archive stripping/lib/libB.c @@ -0,0 +1,5 @@ +#include <libB.h> + +static int libB_func_impl(void) { return 0; } + +int libB_func(void) { return libB_func_impl(); } diff --git a/test cases/unit/65 static archive stripping/lib/libB.h b/test cases/unit/65 static archive stripping/lib/libB.h new file mode 100644 index 0000000..065a4a4 --- /dev/null +++ b/test cases/unit/65 static archive stripping/lib/libB.h @@ -0,0 +1 @@ +int libB_func(void); diff --git a/test cases/unit/65 static archive stripping/lib/meson.build b/test cases/unit/65 static archive stripping/lib/meson.build new file mode 100644 index 0000000..ae50fa7 --- /dev/null +++ b/test cases/unit/65 static archive stripping/lib/meson.build @@ -0,0 +1,23 @@ +project('lib', ['c']) + +pkg = import('pkgconfig') + +a = library('test-a', files('libA.c'), install: true) +install_headers(files('libA.h'), subdir: 'libA') +pkg.generate( + a, + version: '0.0', + description: 'test library libA', + filebase: 'test-a', + name: 'test library libA', + subdirs: 'libA') + +b = static_library('test-b', files('libB.c'), install: true) +install_headers(files('libB.h'), subdir: 'libB') +pkg.generate( + b, + version: '0.0', + description: 'test library libB', + filebase: 'test-b', + name: 'test library libB', + subdirs: 'libB') diff --git a/test cases/unit/66 static link/lib/func1.c b/test cases/unit/66 static link/lib/func1.c new file mode 100644 index 0000000..cc934ad --- /dev/null +++ b/test cases/unit/66 static link/lib/func1.c @@ -0,0 +1,9 @@ +int func1() +{ + return 1; +} + +int func1b() +{ + return 1; +} diff --git a/test cases/unit/66 static link/lib/func10.c b/test cases/unit/66 static link/lib/func10.c new file mode 100644 index 0000000..75a911f --- /dev/null +++ b/test cases/unit/66 static link/lib/func10.c @@ -0,0 +1,4 @@ +int func10() +{ + return 1; +} diff --git a/test cases/unit/66 static link/lib/func11.c b/test cases/unit/66 static link/lib/func11.c new file mode 100644 index 0000000..1d5119b --- /dev/null +++ b/test cases/unit/66 static link/lib/func11.c @@ -0,0 +1,6 @@ +int func10(); + +int func11() +{ + return func10() + 1; +} diff --git a/test cases/unit/66 static link/lib/func12.c b/test cases/unit/66 static link/lib/func12.c new file mode 100644 index 0000000..73db5c0 --- /dev/null +++ b/test cases/unit/66 static link/lib/func12.c @@ -0,0 +1,7 @@ +int func10(); +int func11(); + +int func12() +{ + return func10() + func11(); +} diff --git a/test cases/unit/66 static link/lib/func14.c b/test cases/unit/66 static link/lib/func14.c new file mode 100644 index 0000000..0277319 --- /dev/null +++ b/test cases/unit/66 static link/lib/func14.c @@ -0,0 +1,4 @@ +int func14() +{ + return 1; +} diff --git a/test cases/unit/66 static link/lib/func15.c b/test cases/unit/66 static link/lib/func15.c new file mode 100644 index 0000000..78303cc --- /dev/null +++ b/test cases/unit/66 static link/lib/func15.c @@ -0,0 +1,6 @@ +int func14(); + +int func15() +{ + return func14() + 1; +} diff --git a/test cases/unit/66 static link/lib/func16.c b/test cases/unit/66 static link/lib/func16.c new file mode 100644 index 0000000..379b682 --- /dev/null +++ b/test cases/unit/66 static link/lib/func16.c @@ -0,0 +1,6 @@ +int func15(); + +int func16() +{ + return func15() + 1; +} diff --git a/test cases/unit/66 static link/lib/func17.c b/test cases/unit/66 static link/lib/func17.c new file mode 100644 index 0000000..d1d8ec4 --- /dev/null +++ b/test cases/unit/66 static link/lib/func17.c @@ -0,0 +1,4 @@ +int func17() +{ + return 1; +} diff --git a/test cases/unit/66 static link/lib/func18.c b/test cases/unit/66 static link/lib/func18.c new file mode 100644 index 0000000..c149085 --- /dev/null +++ b/test cases/unit/66 static link/lib/func18.c @@ -0,0 +1,6 @@ +int func17(); + +int func18() +{ + return func17() + 1; +} diff --git a/test cases/unit/66 static link/lib/func19.c b/test cases/unit/66 static link/lib/func19.c new file mode 100644 index 0000000..69120e4 --- /dev/null +++ b/test cases/unit/66 static link/lib/func19.c @@ -0,0 +1,7 @@ +int func17(); +int func18(); + +int func19() +{ + return func17() + func18(); +} diff --git a/test cases/unit/66 static link/lib/func2.c b/test cases/unit/66 static link/lib/func2.c new file mode 100644 index 0000000..6b8f539 --- /dev/null +++ b/test cases/unit/66 static link/lib/func2.c @@ -0,0 +1,6 @@ +int func1(); + +int func2() +{ + return func1() + 1; +} diff --git a/test cases/unit/66 static link/lib/func3.c b/test cases/unit/66 static link/lib/func3.c new file mode 100644 index 0000000..04f9f89 --- /dev/null +++ b/test cases/unit/66 static link/lib/func3.c @@ -0,0 +1,4 @@ +int func3() +{ + return 1; +} diff --git a/test cases/unit/66 static link/lib/func4.c b/test cases/unit/66 static link/lib/func4.c new file mode 100644 index 0000000..c44c990 --- /dev/null +++ b/test cases/unit/66 static link/lib/func4.c @@ -0,0 +1,6 @@ +int func3(); + +int func4() +{ + return func3() + 1; +} diff --git a/test cases/unit/66 static link/lib/func5.c b/test cases/unit/66 static link/lib/func5.c new file mode 100644 index 0000000..8e07864 --- /dev/null +++ b/test cases/unit/66 static link/lib/func5.c @@ -0,0 +1,4 @@ +int func5() +{ + return 1; +} diff --git a/test cases/unit/66 static link/lib/func6.c b/test cases/unit/66 static link/lib/func6.c new file mode 100644 index 0000000..276fe7d --- /dev/null +++ b/test cases/unit/66 static link/lib/func6.c @@ -0,0 +1,6 @@ +int func5(); + +int func6() +{ + return func5() + 1; +} diff --git a/test cases/unit/66 static link/lib/func7.c b/test cases/unit/66 static link/lib/func7.c new file mode 100644 index 0000000..8c1a536 --- /dev/null +++ b/test cases/unit/66 static link/lib/func7.c @@ -0,0 +1,4 @@ +int func7() +{ + return 1; +} diff --git a/test cases/unit/66 static link/lib/func8.c b/test cases/unit/66 static link/lib/func8.c new file mode 100644 index 0000000..b7b6cd5 --- /dev/null +++ b/test cases/unit/66 static link/lib/func8.c @@ -0,0 +1,6 @@ +int func7(); + +int func8() +{ + return func7() + 1; +} diff --git a/test cases/unit/66 static link/lib/func9.c b/test cases/unit/66 static link/lib/func9.c new file mode 100644 index 0000000..852252d --- /dev/null +++ b/test cases/unit/66 static link/lib/func9.c @@ -0,0 +1,6 @@ +int func8(); + +int func9() +{ + return func8() + 1; +} diff --git a/test cases/unit/66 static link/lib/meson.build b/test cases/unit/66 static link/lib/meson.build new file mode 100644 index 0000000..8f95fc4 --- /dev/null +++ b/test cases/unit/66 static link/lib/meson.build @@ -0,0 +1,80 @@ +project('test static link libs', 'c') + +pkg = import('pkgconfig') + +# libfunc2 should contain both func1() and func2() symbols +libfunc1 = static_library('func1', 'func1.c', + install : false) +libfunc2 = static_library('func2', 'func2.c', + link_whole : libfunc1, + install : true) + +# Same as above, but with link_with instead of link_whole, +# libfunc4 should contain both func3() and func4() symbols +libfunc3 = static_library('func3', 'func3.c', + install : false) +libfunc4 = static_library('func4', 'func4.c', + link_with : libfunc3, + install : true) + +# Same as above, but also generate an pkg-config file. Use both_libraries() to +# make sure a complete .pc file gets generated. libfunc5 should not be mentioned +# into the .pc file because it's not installed. +libfunc5 = static_library('func5', 'func5.c', + install : false) +libfunc6 = both_libraries('func6', 'func6.c', + link_with : libfunc5, + install : true) +pkg.generate(libfunc6) + +# libfunc9 should contain both func8() and func9() but not func7() because that +# one gets installed. Also test that link_with and link_whole works the same way +# because libfunc8 is uninstalled. +libfunc7 = static_library('func7', 'func7.c', + install : true) +libfunc8 = static_library('func8', 'func8.c', + link_with : libfunc7, + install : false) +libfunc9_linkwith = static_library('func9_linkwith', 'func9.c', + link_with : libfunc8, + install : true) +libfunc9_linkwhole = static_library('func9_linkwhole', 'func9.c', + link_whole : libfunc8, + install : true) + +# Pattern found in mesa: +# - libfunc11 uses func10() +# - libfunc12 uses both func10() and func11() +# When a shared library link_whole on libfunc12, we ensure we don't include +# func10.c.o twice which would fail to link. +libfunc10 = static_library('func10', 'func10.c', + install : false) +libfunc11 = static_library('func11', 'func11.c', + link_with : libfunc10, + install : false) +libfunc12 = static_library('func12', 'func12.c', + link_with : [libfunc10, libfunc11], + install : false) +libfunc13 = shared_library('func13', link_whole : libfunc12) + +# libfunc16 should contain func14(), func15() and func16() +libfunc14 = static_library('func14', 'func14.c', + install : false) +libfunc15 = static_library('func15', 'func15.c', + link_with : libfunc14, + install : false) +libfunc16 = static_library('func16', 'func16.c', + link_with : libfunc15, + install : true) + +# Verify func17.c.o gets included only once into libfunc19, otherwise +# func19-shared would failed with duplicated symbol. +libfunc17 = static_library('func17', 'func17.c', + install : false) +libfunc18 = static_library('func18', 'func18.c', + link_with : libfunc17, + install : false) +libfunc19 = static_library('func19', 'func19.c', + link_whole : [libfunc17, libfunc18], + install : false) +shared_library('func19-shared', link_whole : [libfunc19]) diff --git a/test cases/unit/66 static link/meson.build b/test cases/unit/66 static link/meson.build new file mode 100644 index 0000000..dac17f8 --- /dev/null +++ b/test cases/unit/66 static link/meson.build @@ -0,0 +1,32 @@ +project('test static link', 'c') + +cc = meson.get_compiler('c') + +# Verify that installed libfunc2.a is usable +func2_dep = cc.find_library('func2') +test('test1', executable('test1', 'test1.c', dependencies : func2_dep)) + +# Verify that installed libfunc4.a is usable +func4_dep = cc.find_library('func4') +test('test2', executable('test2', 'test2.c', dependencies : func4_dep)) + +# Verify that installed pkg-config file is usable for both shared and static link +func6_static_dep = dependency('func6', static : true) +test('test3-static', executable('test3-static', 'test3.c', + dependencies : func6_static_dep)) +func6_shared_dep = dependency('func6', static : false) +test('test3-shared', executable('test3-shared', 'test3.c', + dependencies : func6_shared_dep)) + +# Verify that installed libfunc9.a contains func8() and func8() but not func7() +func7_dep = cc.find_library('func7') +func9_linkwhole_dep = cc.find_library('func9_linkwhole') +test('test4-linkwhole', executable('test4-linkwhole', 'test4.c', + dependencies : [func7_dep, func9_linkwhole_dep])) +func9_linkwith_dep = cc.find_library('func9_linkwith') +test('test4-linkwith', executable('test4-linkwith', 'test4.c', + dependencies : [func7_dep, func9_linkwith_dep])) + +# Verify that installed libfunc16.a is usable +libfunc16_dep = cc.find_library('func16') +test('test5', executable('test5', 'test5.c', dependencies: libfunc16_dep)) diff --git a/test cases/unit/66 static link/test1.c b/test cases/unit/66 static link/test1.c new file mode 100644 index 0000000..ffc9b9e --- /dev/null +++ b/test cases/unit/66 static link/test1.c @@ -0,0 +1,7 @@ +int func1b(); +int func2(); + +int main(int argc, char *argv[]) +{ + return func2() + func1b() == 3 ? 0 : 1; +} diff --git a/test cases/unit/66 static link/test2.c b/test cases/unit/66 static link/test2.c new file mode 100644 index 0000000..561422a --- /dev/null +++ b/test cases/unit/66 static link/test2.c @@ -0,0 +1,6 @@ +int func4(); + +int main(int argc, char *argv[]) +{ + return func4() == 2 ? 0 : 1; +} diff --git a/test cases/unit/66 static link/test3.c b/test cases/unit/66 static link/test3.c new file mode 100644 index 0000000..1216064 --- /dev/null +++ b/test cases/unit/66 static link/test3.c @@ -0,0 +1,6 @@ +int func6(); + +int main(int argc, char *argv[]) +{ + return func6() == 2 ? 0 : 1; +} diff --git a/test cases/unit/66 static link/test4.c b/test cases/unit/66 static link/test4.c new file mode 100644 index 0000000..7c281e0 --- /dev/null +++ b/test cases/unit/66 static link/test4.c @@ -0,0 +1,6 @@ +int func9(); + +int main(int argc, char *argv[]) +{ + return func9() == 3 ? 0 : 1; +} diff --git a/test cases/unit/66 static link/test5.c b/test cases/unit/66 static link/test5.c new file mode 100644 index 0000000..6020f0e --- /dev/null +++ b/test cases/unit/66 static link/test5.c @@ -0,0 +1,6 @@ +int func16(); + +int main(int argc, char *argv[]) +{ + return func16() == 3 ? 0 : 1; +} diff --git a/test cases/unit/67 test env value/meson.build b/test cases/unit/67 test env value/meson.build new file mode 100644 index 0000000..aa3dbc3 --- /dev/null +++ b/test cases/unit/67 test env value/meson.build @@ -0,0 +1,10 @@ +project('test env value') + +testpy = find_program('test.py') + +val = ['1', '2', '3'] +foreach v: val + test('check env', testpy, args: [v], env: {'TEST_VAR': v}) +endforeach +test('check env', testpy, args: ['4'], env: environment({'TEST_VAR': '4'})) +test('check env', testpy, args: ['5'], env: environment(['TEST_VAR=5'])) diff --git a/test cases/unit/67 test env value/test.py b/test cases/unit/67 test env value/test.py new file mode 100755 index 0000000..4adf62c --- /dev/null +++ b/test cases/unit/67 test env value/test.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +import os +import sys + +assert os.environ['TEST_VAR'] == sys.argv[1] diff --git a/test cases/unit/68 clang-tidy/.clang-tidy b/test cases/unit/68 clang-tidy/.clang-tidy new file mode 100644 index 0000000..3935294 --- /dev/null +++ b/test cases/unit/68 clang-tidy/.clang-tidy @@ -0,0 +1 @@ +Checks: '-*,modernize-use-bool-literals' diff --git a/test cases/unit/68 clang-tidy/cttest.cpp b/test cases/unit/68 clang-tidy/cttest.cpp new file mode 100644 index 0000000..07b35a6 --- /dev/null +++ b/test cases/unit/68 clang-tidy/cttest.cpp @@ -0,0 +1,7 @@ +#include<cstdio> + +int main(int, char**) { + bool intbool = 1; + printf("Intbool is %d\n", (int)intbool); + return 0; +} diff --git a/test cases/unit/68 clang-tidy/dummydir.h/dummy.dat b/test cases/unit/68 clang-tidy/dummydir.h/dummy.dat new file mode 100644 index 0000000..80c6165 --- /dev/null +++ b/test cases/unit/68 clang-tidy/dummydir.h/dummy.dat @@ -0,0 +1 @@ +Placeholder to track enclosing directory in git. Not to be analyzed. diff --git a/test cases/unit/68 clang-tidy/meson.build b/test cases/unit/68 clang-tidy/meson.build new file mode 100644 index 0000000..737474b --- /dev/null +++ b/test cases/unit/68 clang-tidy/meson.build @@ -0,0 +1,3 @@ +project('clangtidytest', 'cpp', default_options: 'cpp_std=c++14') + +executable('cttest', 'cttest.cpp') diff --git a/test cases/unit/69 cross/crossfile.in b/test cases/unit/69 cross/crossfile.in new file mode 100644 index 0000000..678e8d3 --- /dev/null +++ b/test cases/unit/69 cross/crossfile.in @@ -0,0 +1,5 @@ +[host_machine] +system = '@system@' +cpu_family = '@cpu_family@' +cpu = '@cpu@' +endian = '@endian@' diff --git a/test cases/unit/69 cross/meson.build b/test cases/unit/69 cross/meson.build new file mode 100644 index 0000000..acf4f0f --- /dev/null +++ b/test cases/unit/69 cross/meson.build @@ -0,0 +1,16 @@ +project('crosstest') + +if get_option('generate') + conf_data = configuration_data() + conf_data.set('system', build_machine.system()) + conf_data.set('cpu', build_machine.cpu()) + conf_data.set('cpu_family', build_machine.cpu_family()) + conf_data.set('endian', build_machine.endian()) + + configure_file(input: 'crossfile.in', + output: 'crossfile', + configuration: conf_data) + message('Written cross file') +else + assert(meson.is_cross_build(), 'not setup as cross build') +endif diff --git a/test cases/unit/69 cross/meson_options.txt b/test cases/unit/69 cross/meson_options.txt new file mode 100644 index 0000000..5896d63 --- /dev/null +++ b/test cases/unit/69 cross/meson_options.txt @@ -0,0 +1 @@ +option('generate', type : 'boolean', value : false) diff --git a/test cases/unit/7 run installed/foo/foo.c b/test cases/unit/7 run installed/foo/foo.c new file mode 100644 index 0000000..402c895 --- /dev/null +++ b/test cases/unit/7 run installed/foo/foo.c @@ -0,0 +1,3 @@ +int foo() { + return 0; +} diff --git a/test cases/unit/7 run installed/foo/meson.build b/test cases/unit/7 run installed/foo/meson.build new file mode 100644 index 0000000..772b181 --- /dev/null +++ b/test cases/unit/7 run installed/foo/meson.build @@ -0,0 +1,6 @@ +# Try to invoke linker constant string deduplication, +# to ensure we are not clobbering shared strings. +# Name everything possible just as "foo". +foolib = shared_library('foo', 'foo.c', + install_dir : 'foo', + install : true) diff --git a/test cases/unit/7 run installed/meson.build b/test cases/unit/7 run installed/meson.build new file mode 100644 index 0000000..af307f5 --- /dev/null +++ b/test cases/unit/7 run installed/meson.build @@ -0,0 +1,8 @@ +project('foo', 'c', + default_options : 'libdir=lib') + +subdir('foo') + +executable('prog', 'prog.c', + link_with : foolib, + install : true) diff --git a/test cases/unit/7 run installed/prog.c b/test cases/unit/7 run installed/prog.c new file mode 100644 index 0000000..8e61e6e --- /dev/null +++ b/test cases/unit/7 run installed/prog.c @@ -0,0 +1,5 @@ +int foo(); + +int main(int argc, char **argv) { + return foo(); +} diff --git a/test cases/unit/70 cross test passed/exewrapper.py b/test cases/unit/70 cross test passed/exewrapper.py new file mode 100755 index 0000000..2c15ed6 --- /dev/null +++ b/test cases/unit/70 cross test passed/exewrapper.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# Test that the MESON_EXE_WRAPPER environment variable is set + +import argparse +import os +import sys + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('binary') # unused, but needed for test behavior + parser.add_argument('--expected', action='store_true') + args = parser.parse_args() + + defined = 'MESON_EXE_WRAPPER' in os.environ + + if args.expected != defined: + print(os.environ, file=sys.stderr) + return 1 + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/test cases/unit/70 cross test passed/meson.build b/test cases/unit/70 cross test passed/meson.build new file mode 100644 index 0000000..4deb74b --- /dev/null +++ b/test cases/unit/70 cross test passed/meson.build @@ -0,0 +1,19 @@ +project( + 'cross test passed', + 'c', + version : '>= 0.51' +) + +e = executable('exec', 'src/main.c') + +py = import('python').find_installation() + +test('root', e) +test('main', py, args : [meson.current_source_dir() / 'script.py', e]) + +wrapper_args = [] +if get_option('expect') + wrapper_args += '--expected' +endif + +test('exe_wrapper in env', py, args : [meson.current_source_dir() / 'exewrapper.py', e, wrapper_args]) diff --git a/test cases/unit/70 cross test passed/meson_options.txt b/test cases/unit/70 cross test passed/meson_options.txt new file mode 100644 index 0000000..084c776 --- /dev/null +++ b/test cases/unit/70 cross test passed/meson_options.txt @@ -0,0 +1,5 @@ +option( + 'expect', + type : 'boolean', + value : false, +) diff --git a/test cases/unit/70 cross test passed/script.py b/test cases/unit/70 cross test passed/script.py new file mode 100644 index 0000000..257cd30 --- /dev/null +++ b/test cases/unit/70 cross test passed/script.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 + +import subprocess +import sys + +if __name__ == "__main__": + sys.exit(subprocess.run(sys.argv[1:]).returncode) diff --git a/test cases/unit/70 cross test passed/src/main.c b/test cases/unit/70 cross test passed/src/main.c new file mode 100644 index 0000000..490b4a6 --- /dev/null +++ b/test cases/unit/70 cross test passed/src/main.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +int main(int argc, char const *argv[]) +{ + return 0; +} diff --git a/test cases/unit/71 summary/meson.build b/test cases/unit/71 summary/meson.build new file mode 100644 index 0000000..ce97fb3 --- /dev/null +++ b/test cases/unit/71 summary/meson.build @@ -0,0 +1,24 @@ +project('My Project', version : '1.0') + +subproject('sub') +subproject('sub2', required : false) + +summary({'Some boolean': false, + 'Another boolean': true, + 'Some string': 'Hello World', + 'A list': ['string', 1, true], + 'empty list': [], + 'enabled_opt': get_option('enabled_opt'), + }, section: 'Configuration') +summary({'missing prog': find_program('xyzzy', required: false), + 'existing prog': import('python').find_installation(), + 'missing dep': dependency('', required: false), + 'external dep': dependency('zlib', required: false), + 'internal dep': declare_dependency(), + 'disabler': disabler(), + }, section: 'Stuff') +summary('A number', 1, section: 'Configuration') +summary('yes', true, bool_yn : true, section: 'Configuration') +summary('no', false, bool_yn : true, section: 'Configuration') +summary('comma list', ['a', 'b', 'c'], list_sep: ', ', section: 'Configuration') +summary('long comma list', ['alpha', 'alphacolor', 'apetag', 'audiofx', 'audioparsers', 'auparse', 'autodetect', 'avi'], list_sep: ', ', section: 'Plugins') diff --git a/test cases/unit/71 summary/meson_options.txt b/test cases/unit/71 summary/meson_options.txt new file mode 100644 index 0000000..281c3b6 --- /dev/null +++ b/test cases/unit/71 summary/meson_options.txt @@ -0,0 +1 @@ +option('enabled_opt', type: 'feature', value: 'auto') diff --git a/test cases/unit/71 summary/subprojects/sub/meson.build b/test cases/unit/71 summary/subprojects/sub/meson.build new file mode 100644 index 0000000..e7d7833 --- /dev/null +++ b/test cases/unit/71 summary/subprojects/sub/meson.build @@ -0,0 +1,4 @@ +project('Some Subproject', version : '2.0') + +summary('string', 'bar') +summary({'integer': 1, 'boolean': true}) diff --git a/test cases/unit/71 summary/subprojects/sub2/meson.build b/test cases/unit/71 summary/subprojects/sub2/meson.build new file mode 100644 index 0000000..2560bd0 --- /dev/null +++ b/test cases/unit/71 summary/subprojects/sub2/meson.build @@ -0,0 +1,6 @@ +project('sub2') + +subproject('subsub') + +summary('Section', 'Should not be seen') +error('This subproject failed') diff --git a/test cases/unit/71 summary/subprojects/sub2/subprojects/subsub/meson.build b/test cases/unit/71 summary/subprojects/sub2/subprojects/subsub/meson.build new file mode 100644 index 0000000..98a5a26 --- /dev/null +++ b/test cases/unit/71 summary/subprojects/sub2/subprojects/subsub/meson.build @@ -0,0 +1,3 @@ +project('subsub') + +summary('Something', 'Some value') diff --git a/test cases/unit/72 wrap file url/meson.build b/test cases/unit/72 wrap file url/meson.build new file mode 100644 index 0000000..3bd3b25 --- /dev/null +++ b/test cases/unit/72 wrap file url/meson.build @@ -0,0 +1,4 @@ +project('test wrap with file url') + +exe = subproject('foo').get_variable('foo_exe') +test('test1', exe) diff --git a/test cases/unit/72 wrap file url/subprojects/foo-patch.tar.xz b/test cases/unit/72 wrap file url/subprojects/foo-patch.tar.xz Binary files differnew file mode 100644 index 0000000..fdb026c --- /dev/null +++ b/test cases/unit/72 wrap file url/subprojects/foo-patch.tar.xz diff --git a/test cases/unit/72 wrap file url/subprojects/foo.tar.xz b/test cases/unit/72 wrap file url/subprojects/foo.tar.xz Binary files differnew file mode 100644 index 0000000..2ed6ab4 --- /dev/null +++ b/test cases/unit/72 wrap file url/subprojects/foo.tar.xz diff --git a/test cases/unit/73 dep files/foo.c b/test cases/unit/73 dep files/foo.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/73 dep files/foo.c diff --git a/test cases/unit/73 dep files/meson.build b/test cases/unit/73 dep files/meson.build new file mode 100644 index 0000000..4829f56 --- /dev/null +++ b/test cases/unit/73 dep files/meson.build @@ -0,0 +1,16 @@ +project('test', 'c') + +python = import('python').find_installation() + +lib = library('foo', 'foo.c') + +# The library does not yet exist but we can already use its path during +# configuration. This should not trigger a reconfigure when the library is +# rebuilt. +configure_file( + output: 'out.txt', + capture: true, + command: [python, '-c', 'import sys; print(sys.argv[1])', lib.full_path()], +) + +message('Project configured') diff --git a/test cases/unit/74 pkgconfig prefixes/client/client.c b/test cases/unit/74 pkgconfig prefixes/client/client.c new file mode 100644 index 0000000..be9bead --- /dev/null +++ b/test cases/unit/74 pkgconfig prefixes/client/client.c @@ -0,0 +1,8 @@ +#include <val2.h> +#include <stdio.h> + +int main(int argc, char **argv) +{ + printf("%d\n", val2()); + return 0; +} diff --git a/test cases/unit/74 pkgconfig prefixes/client/meson.build b/test cases/unit/74 pkgconfig prefixes/client/meson.build new file mode 100644 index 0000000..491937b --- /dev/null +++ b/test cases/unit/74 pkgconfig prefixes/client/meson.build @@ -0,0 +1,3 @@ +project('client', 'c') +val2_dep = dependency('val2') +executable('client', 'client.c', dependencies : [val2_dep], install: true) diff --git a/test cases/unit/74 pkgconfig prefixes/val1/meson.build b/test cases/unit/74 pkgconfig prefixes/val1/meson.build new file mode 100644 index 0000000..cc63e31 --- /dev/null +++ b/test cases/unit/74 pkgconfig prefixes/val1/meson.build @@ -0,0 +1,5 @@ +project('val1', 'c') +val1 = shared_library('val1', 'val1.c', install: true) +install_headers('val1.h') +pkgconfig = import('pkgconfig') +pkgconfig.generate(val1, libraries : ['-Wl,-rpath,${libdir}']) diff --git a/test cases/unit/74 pkgconfig prefixes/val1/val1.c b/test cases/unit/74 pkgconfig prefixes/val1/val1.c new file mode 100644 index 0000000..591e521 --- /dev/null +++ b/test cases/unit/74 pkgconfig prefixes/val1/val1.c @@ -0,0 +1,3 @@ +#include "val1.h" + +int val1(void) { return 1; } diff --git a/test cases/unit/74 pkgconfig prefixes/val1/val1.h b/test cases/unit/74 pkgconfig prefixes/val1/val1.h new file mode 100644 index 0000000..6bd435e --- /dev/null +++ b/test cases/unit/74 pkgconfig prefixes/val1/val1.h @@ -0,0 +1 @@ +int val1(void); diff --git a/test cases/unit/74 pkgconfig prefixes/val2/meson.build b/test cases/unit/74 pkgconfig prefixes/val2/meson.build new file mode 100644 index 0000000..ce69481 --- /dev/null +++ b/test cases/unit/74 pkgconfig prefixes/val2/meson.build @@ -0,0 +1,8 @@ +project('val2', 'c') +val1_dep = dependency('val1') +val2 = shared_library('val2', 'val2.c', + dependencies : [val1_dep], + install: true) +install_headers('val2.h') +pkgconfig = import('pkgconfig') +pkgconfig.generate(val2, libraries : ['-Wl,-rpath,${libdir}']) diff --git a/test cases/unit/74 pkgconfig prefixes/val2/val2.c b/test cases/unit/74 pkgconfig prefixes/val2/val2.c new file mode 100644 index 0000000..d7d4857 --- /dev/null +++ b/test cases/unit/74 pkgconfig prefixes/val2/val2.c @@ -0,0 +1,4 @@ +#include "val1.h" +#include "val2.h" + +int val2(void) { return val1() + 2; } diff --git a/test cases/unit/74 pkgconfig prefixes/val2/val2.h b/test cases/unit/74 pkgconfig prefixes/val2/val2.h new file mode 100644 index 0000000..995023d --- /dev/null +++ b/test cases/unit/74 pkgconfig prefixes/val2/val2.h @@ -0,0 +1 @@ +int val2(void); diff --git a/test cases/unit/75 subdir libdir/meson.build b/test cases/unit/75 subdir libdir/meson.build new file mode 100644 index 0000000..5099c91 --- /dev/null +++ b/test cases/unit/75 subdir libdir/meson.build @@ -0,0 +1,2 @@ +project('toplevel', 'c') +subproject('flub') diff --git a/test cases/unit/75 subdir libdir/subprojects/flub/meson.build b/test cases/unit/75 subdir libdir/subprojects/flub/meson.build new file mode 100644 index 0000000..7bfd2c5 --- /dev/null +++ b/test cases/unit/75 subdir libdir/subprojects/flub/meson.build @@ -0,0 +1 @@ +project('subflub', 'c') diff --git a/test cases/unit/76 as link whole/bar.c b/test cases/unit/76 as link whole/bar.c new file mode 100644 index 0000000..79dea9d --- /dev/null +++ b/test cases/unit/76 as link whole/bar.c @@ -0,0 +1,6 @@ +int bar(void); + +int bar(void) +{ + return 0; +} diff --git a/test cases/unit/76 as link whole/foo.c b/test cases/unit/76 as link whole/foo.c new file mode 100644 index 0000000..ffeee82 --- /dev/null +++ b/test cases/unit/76 as link whole/foo.c @@ -0,0 +1,6 @@ +int foo(void); + +int foo(void) +{ + return 0; +} diff --git a/test cases/unit/76 as link whole/meson.build b/test cases/unit/76 as link whole/meson.build new file mode 100644 index 0000000..6bc208f --- /dev/null +++ b/test cases/unit/76 as link whole/meson.build @@ -0,0 +1,11 @@ +project('as-link-whole', 'c') + +foo = static_library('foo', 'foo.c', install: true) +dep = declare_dependency(link_with: foo) +bar1 = library('bar1', 'bar.c', dependencies: dep) +bar2 = library('bar2', 'bar.c', dependencies: dep.as_link_whole()) + +# bar1.pc should have -lfoo but not bar2.pc +pkg = import('pkgconfig') +pkg.generate(bar1) +pkg.generate(bar2) diff --git a/test cases/unit/77 nostdlib/meson.build b/test cases/unit/77 nostdlib/meson.build new file mode 100644 index 0000000..9c5f949 --- /dev/null +++ b/test cases/unit/77 nostdlib/meson.build @@ -0,0 +1,14 @@ +project('own libc', 'c') + +# Not related to this test, but could not find a better place for this test. +assert(meson.get_cross_property('nonexisting', 'defaultvalue') == 'defaultvalue', + 'Cross prop getting is broken.') + +# A simple project that uses its own libc. + +# Note that we don't need to specify anything, the flags to use +# stdlib come from the cross file. + +exe = executable('selfcontained', 'prog.c') + +test('standalone test', exe) diff --git a/test cases/unit/77 nostdlib/prog.c b/test cases/unit/77 nostdlib/prog.c new file mode 100644 index 0000000..b9216ee --- /dev/null +++ b/test cases/unit/77 nostdlib/prog.c @@ -0,0 +1,7 @@ + +#include<stdio.h> + +int main(void) { + const char *message = "Hello without stdlib.\n"; + return simple_print(message, simple_strlen(message)); +} diff --git a/test cases/unit/77 nostdlib/subprojects/mylibc/libc.c b/test cases/unit/77 nostdlib/subprojects/mylibc/libc.c new file mode 100644 index 0000000..67261cb --- /dev/null +++ b/test cases/unit/77 nostdlib/subprojects/mylibc/libc.c @@ -0,0 +1,35 @@ +/* Do not use this as the basis of your own libc. + * The code is probably unoptimal or wonky, as I + * had no prior experience with this, but instead + * just fiddled with the code until it worked. + */ + +#include<stdio.h> + +#define STDOUT 1 +#define SYS_WRITE 4 + +int simple_print(const char *msg, const long bufsize) { + int count; + long total_written = 0; + while(total_written < bufsize) { + asm( + "int $0x80\n\t" + : "=a"(count) + : "0"(SYS_WRITE), "b"(STDOUT), "c"(msg+total_written), "d"(bufsize-total_written) + :); + if(count == 0) { + return 1; + } + total_written += count; + } + return 0; +} + +int simple_strlen(const char *str) { + int len = 0; + while(str[len] != '\0') { + len++; + } + return len; +} diff --git a/test cases/unit/77 nostdlib/subprojects/mylibc/meson.build b/test cases/unit/77 nostdlib/subprojects/mylibc/meson.build new file mode 100644 index 0000000..ff4bdb2 --- /dev/null +++ b/test cases/unit/77 nostdlib/subprojects/mylibc/meson.build @@ -0,0 +1,13 @@ +project('own libc', 'c') + +# A very simple libc implementation + +# Do not specify -nostdlib & co. They come from cross specifications. + +libc = static_library('c', 'libc.c', 'stubstart.s') + +mylibc_dep = declare_dependency(link_with : libc, + include_directories : include_directories('.') +) + +meson.override_dependency('c_stdlib', mylibc_dep) diff --git a/test cases/unit/77 nostdlib/subprojects/mylibc/stdio.h b/test cases/unit/77 nostdlib/subprojects/mylibc/stdio.h new file mode 100644 index 0000000..c3f8f56 --- /dev/null +++ b/test cases/unit/77 nostdlib/subprojects/mylibc/stdio.h @@ -0,0 +1,5 @@ +#pragma once + +int simple_print(const char *msg, const long bufsize); + +int simple_strlen(const char *str); diff --git a/test cases/unit/77 nostdlib/subprojects/mylibc/stubstart.s b/test cases/unit/77 nostdlib/subprojects/mylibc/stubstart.s new file mode 100644 index 0000000..0a6d972 --- /dev/null +++ b/test cases/unit/77 nostdlib/subprojects/mylibc/stubstart.s @@ -0,0 +1,8 @@ +.globl _start + +_start: + + call main + movl %eax, %ebx + movl $1, %eax + int $0x80 diff --git a/test cases/unit/78 user options for subproject/.gitignore b/test cases/unit/78 user options for subproject/.gitignore new file mode 100644 index 0000000..0bec5ea --- /dev/null +++ b/test cases/unit/78 user options for subproject/.gitignore @@ -0,0 +1 @@ +/subprojects diff --git a/test cases/unit/78 user options for subproject/75 user options for subproject/.gitignore b/test cases/unit/78 user options for subproject/75 user options for subproject/.gitignore new file mode 100644 index 0000000..4976afc --- /dev/null +++ b/test cases/unit/78 user options for subproject/75 user options for subproject/.gitignore @@ -0,0 +1 @@ +subprojects/* diff --git a/test cases/unit/78 user options for subproject/75 user options for subproject/meson.build b/test cases/unit/78 user options for subproject/75 user options for subproject/meson.build new file mode 100644 index 0000000..0bc395b --- /dev/null +++ b/test cases/unit/78 user options for subproject/75 user options for subproject/meson.build @@ -0,0 +1,3 @@ +project('user option for subproject') + +p = subproject('sub') diff --git a/test cases/unit/78 user options for subproject/subprojects/sub/meson.build b/test cases/unit/78 user options for subproject/subprojects/sub/meson.build new file mode 100644 index 0000000..2eccef7 --- /dev/null +++ b/test cases/unit/78 user options for subproject/subprojects/sub/meson.build @@ -0,0 +1,45 @@ +project('options', 'c') + +if get_option('testoption') != 'optval' + error('Incorrect value to test option') +endif + +if get_option('other_one') != false + error('Incorrect value to boolean option.') +endif + +if get_option('combo_opt') != 'combo' + error('Incorrect value to combo option.') +endif + +if get_option('array_opt') != ['one', 'two'] + message(get_option('array_opt')) + error('Incorrect value for array option') +endif + +# If the default changes, update test cases/unit/13 reconfigure +if get_option('b_lto') != false + error('Incorrect value in base option.') +endif + +if get_option('includedir') != 'include' + error('Incorrect value in builtin option.') +endif + +if get_option('integer_opt') != 3 + error('Incorrect value in integer option.') +endif + +if get_option('neg_int_opt') != -3 + error('Incorrect value in negative integer option.') +endif + +if get_option('CaseSenSiTivE') != 'Some CAPS' + error('Incorrect value in mixed caps option.') +endif + +if get_option('CASESENSITIVE') != 'ALL CAPS' + error('Incorrect value in all caps option.') +endif + +assert(get_option('wrap_mode') == 'default', 'Wrap mode option is broken.') diff --git a/test cases/unit/78 user options for subproject/subprojects/sub/meson_options.txt b/test cases/unit/78 user options for subproject/subprojects/sub/meson_options.txt new file mode 100644 index 0000000..8067eae --- /dev/null +++ b/test cases/unit/78 user options for subproject/subprojects/sub/meson_options.txt @@ -0,0 +1,9 @@ +option('testoption', type : 'string', value : 'optval', description : 'An option ' + 'to do something') +option('other_one', type : 'boolean', value : not (not (not (not false)))) +option('combo_opt', type : 'co' + 'mbo', choices : ['one', 'two', 'combo'], value : 'combo') +option('array_opt', type : 'array', choices : ['one', 'two', 'three'], value : ['one', 'two']) +option('free_array_opt', type : 'array') +option('integer_opt', type : 'integer', min : 0, max : -(-5), value : 3) +option('neg' + '_' + 'int' + '_' + 'opt', type : 'integer', min : -5, max : 5, value : -3) +option('CaseSenSiTivE', type : 'string', value: 'Some CAPS', description : 'An option with mixed capitaliziation') +option('CASESENSITIVE', type : 'string', value: 'ALL CAPS', description : 'An option with all caps') diff --git a/test cases/unit/79 global-rpath/meson.build b/test cases/unit/79 global-rpath/meson.build new file mode 100644 index 0000000..c67d9e0 --- /dev/null +++ b/test cases/unit/79 global-rpath/meson.build @@ -0,0 +1,3 @@ +project('global-rpath', 'cpp') +yonder_dep = dependency('yonder') +executable('rpathified', 'rpathified.cpp', dependencies: [yonder_dep], install: true) diff --git a/test cases/unit/79 global-rpath/rpathified.cpp b/test cases/unit/79 global-rpath/rpathified.cpp new file mode 100644 index 0000000..3788906 --- /dev/null +++ b/test cases/unit/79 global-rpath/rpathified.cpp @@ -0,0 +1,6 @@ +#include <yonder.h> +#include <string.h> +int main(int argc, char **argv) +{ + return strcmp(yonder(), "AB54 6BR"); +} diff --git a/test cases/unit/79 global-rpath/yonder/meson.build b/test cases/unit/79 global-rpath/yonder/meson.build new file mode 100644 index 0000000..e32f383 --- /dev/null +++ b/test cases/unit/79 global-rpath/yonder/meson.build @@ -0,0 +1,5 @@ +project('yonder', 'cpp') +yonder = shared_library('yonder', 'yonder.cpp', install: true) +install_headers('yonder.h') +pkgconfig = import('pkgconfig') +pkgconfig.generate(yonder) diff --git a/test cases/unit/79 global-rpath/yonder/yonder.cpp b/test cases/unit/79 global-rpath/yonder/yonder.cpp new file mode 100644 index 0000000..b182d34 --- /dev/null +++ b/test cases/unit/79 global-rpath/yonder/yonder.cpp @@ -0,0 +1,3 @@ +#include "yonder.h" + +char *yonder(void) { return "AB54 6BR"; } diff --git a/test cases/unit/79 global-rpath/yonder/yonder.h b/test cases/unit/79 global-rpath/yonder/yonder.h new file mode 100644 index 0000000..9d9ad16 --- /dev/null +++ b/test cases/unit/79 global-rpath/yonder/yonder.h @@ -0,0 +1 @@ +char *yonder(void); diff --git a/test cases/unit/8 -L -l order/first.pc b/test cases/unit/8 -L -l order/first.pc new file mode 100644 index 0000000..3b811b2 --- /dev/null +++ b/test cases/unit/8 -L -l order/first.pc @@ -0,0 +1,13 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${prefix}/lib/x86_64-linux-gnu +sharedlibdir=${libdir} +includedir=${prefix}/include + +Name: jonne +Description: jonne library +Version: 1.0.0 + +Requires: +Libs: -L/me/first -lfoo1 -L/me/second -lfoo2 +Cflags: -I${includedir} diff --git a/test cases/unit/8 -L -l order/meson.build b/test cases/unit/8 -L -l order/meson.build new file mode 100644 index 0000000..cfcf033 --- /dev/null +++ b/test cases/unit/8 -L -l order/meson.build @@ -0,0 +1,6 @@ +project('jonne', 'c') + +firstdep = dependency('first') +seconddep = dependency('second') + +executable('lprog', 'prog.c', dependencies : [firstdep, seconddep]) diff --git a/test cases/unit/8 -L -l order/prog.c b/test cases/unit/8 -L -l order/prog.c new file mode 100644 index 0000000..3a16ac3 --- /dev/null +++ b/test cases/unit/8 -L -l order/prog.c @@ -0,0 +1,5 @@ +#include<stdio.h> + +int main(int argc, char **argv) { + return 0; +} diff --git a/test cases/unit/8 -L -l order/second.pc b/test cases/unit/8 -L -l order/second.pc new file mode 100644 index 0000000..196824b --- /dev/null +++ b/test cases/unit/8 -L -l order/second.pc @@ -0,0 +1,13 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${prefix}/lib/x86_64-linux-gnu +sharedlibdir=${libdir} +includedir=${prefix}/include + +Name: jonne2 +Description: jonne2 library +Version: 1.0.0 + +Requires: +Libs: -L/me/third -lfoo3 -L/me/fourth -lfoo4 +Cflags: -I${includedir} diff --git a/test cases/unit/80 wrap-git/meson.build b/test cases/unit/80 wrap-git/meson.build new file mode 100644 index 0000000..b0af30a --- /dev/null +++ b/test cases/unit/80 wrap-git/meson.build @@ -0,0 +1,4 @@ +project('test-wrap-git') + +exe = subproject('wrap_git').get_variable('exe') +test('test1', exe) diff --git a/test cases/unit/80 wrap-git/subprojects/packagefiles/wrap_git_builddef/meson.build b/test cases/unit/80 wrap-git/subprojects/packagefiles/wrap_git_builddef/meson.build new file mode 100644 index 0000000..2570f77 --- /dev/null +++ b/test cases/unit/80 wrap-git/subprojects/packagefiles/wrap_git_builddef/meson.build @@ -0,0 +1,3 @@ +project('foo', 'c') + +exe = executable('app', 'main.c') diff --git a/test cases/unit/80 wrap-git/subprojects/wrap_git_upstream/main.c b/test cases/unit/80 wrap-git/subprojects/wrap_git_upstream/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/test cases/unit/80 wrap-git/subprojects/wrap_git_upstream/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/test cases/unit/81 meson version compare/meson.build b/test cases/unit/81 meson version compare/meson.build new file mode 100644 index 0000000..4affe21 --- /dev/null +++ b/test cases/unit/81 meson version compare/meson.build @@ -0,0 +1,19 @@ +project('version compare', meson_version: '>= 0.1') + +if meson.version().version_compare('>= 9999') + error('This should not be executed') +elif meson.version().version_compare('>= 0.55') and false + error('This should not be executed') +elif not meson.version().version_compare('>= 0.55') + error('This should not be executed') +elif meson.version().version_compare('>= 0.55') + # This Should not produce warning even when using function not available in + # meson 0.1. + foo_dep = declare_dependency() + meson.override_dependency('foo', foo_dep) +endif + +# This will error out if elif cause did not enter +assert(foo_dep.found(), 'meson.version_compare did not work') + +subproject('foo') diff --git a/test cases/unit/81 meson version compare/subprojects/foo/meson.build b/test cases/unit/81 meson version compare/subprojects/foo/meson.build new file mode 100644 index 0000000..4c66b70 --- /dev/null +++ b/test cases/unit/81 meson version compare/subprojects/foo/meson.build @@ -0,0 +1,8 @@ +project('foo', meson_version: '>= 0.1') + +if meson.version().version_compare('>= 0.55') + # This Should not produce warning even when using function not available in + # meson 0.1. + foo_dep = declare_dependency() + meson.override_dependency('foo2', foo_dep) +endif diff --git a/test cases/unit/82 cross only introspect/meson.build b/test cases/unit/82 cross only introspect/meson.build new file mode 100644 index 0000000..ed25441 --- /dev/null +++ b/test cases/unit/82 cross only introspect/meson.build @@ -0,0 +1,2 @@ +project('cross only introspect') +add_languages('c', native: false) diff --git a/test cases/unit/83 change option choices/meson.build b/test cases/unit/83 change option choices/meson.build new file mode 100644 index 0000000..d056d65 --- /dev/null +++ b/test cases/unit/83 change option choices/meson.build @@ -0,0 +1 @@ +project('change option choices') diff --git a/test cases/unit/83 change option choices/meson_options.1.txt b/test cases/unit/83 change option choices/meson_options.1.txt new file mode 100644 index 0000000..d0326a5 --- /dev/null +++ b/test cases/unit/83 change option choices/meson_options.1.txt @@ -0,0 +1,13 @@ +option( + 'combo', + type : 'combo', + choices : ['a', 'b', 'c'], + value : 'a', +) + +option( + 'array', + type : 'array', + choices : ['a', 'b', 'c'], + value : ['a'], +) diff --git a/test cases/unit/83 change option choices/meson_options.2.txt b/test cases/unit/83 change option choices/meson_options.2.txt new file mode 100644 index 0000000..4684673 --- /dev/null +++ b/test cases/unit/83 change option choices/meson_options.2.txt @@ -0,0 +1,13 @@ +option( + 'combo', + type : 'combo', + choices : ['b', 'c', 'd'], + value : 'b', +) + +option( + 'array', + type : 'array', + choices : ['b', 'c', 'd'], + value : ['b'], +) diff --git a/test cases/unit/84 nested subproject regenerate depends/main.c b/test cases/unit/84 nested subproject regenerate depends/main.c new file mode 100644 index 0000000..9b6bdc2 --- /dev/null +++ b/test cases/unit/84 nested subproject regenerate depends/main.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/test cases/unit/84 nested subproject regenerate depends/meson.build b/test cases/unit/84 nested subproject regenerate depends/meson.build new file mode 100644 index 0000000..a8d2138 --- /dev/null +++ b/test cases/unit/84 nested subproject regenerate depends/meson.build @@ -0,0 +1,10 @@ +project('nested subproject regenerate depends', 'c') + +if not find_program('cmake', required: false, version: '>=3.14').found() + error('MESON_SKIP_TEST cmake >= 3.14 not available.') +endif + +s = subproject('sub1') + +# This is needed to make msbuild noop check work correctly +executable('exe', 'main.c') diff --git a/test cases/unit/84 nested subproject regenerate depends/subprojects/sub1/meson.build b/test cases/unit/84 nested subproject regenerate depends/subprojects/sub1/meson.build new file mode 100644 index 0000000..a31db4a --- /dev/null +++ b/test cases/unit/84 nested subproject regenerate depends/subprojects/sub1/meson.build @@ -0,0 +1,4 @@ +project('sub1') + +cmake = import('cmake') +cmake.subproject('sub2') diff --git a/test cases/unit/84 nested subproject regenerate depends/subprojects/sub2/CMakeLists.txt b/test cases/unit/84 nested subproject regenerate depends/subprojects/sub2/CMakeLists.txt new file mode 100644 index 0000000..f91473a --- /dev/null +++ b/test cases/unit/84 nested subproject regenerate depends/subprojects/sub2/CMakeLists.txt @@ -0,0 +1 @@ +project(sub2) diff --git a/test cases/unit/85 cpp modules/gcc/main.cpp b/test cases/unit/85 cpp modules/gcc/main.cpp new file mode 100644 index 0000000..d825c7d --- /dev/null +++ b/test cases/unit/85 cpp modules/gcc/main.cpp @@ -0,0 +1,7 @@ +import M0; +#include<cstdio> + +int main() { + printf("The value is %d", func0()); + return 0; +} diff --git a/test cases/unit/85 cpp modules/gcc/meson.build b/test cases/unit/85 cpp modules/gcc/meson.build new file mode 100644 index 0000000..e405c56 --- /dev/null +++ b/test cases/unit/85 cpp modules/gcc/meson.build @@ -0,0 +1,19 @@ +# GCC does not recognize .ixx as a C++ source extension so +# we have to do this instead. + +e = executable('modtest', + 'main.cpp', + 'src0.cxx', + 'src1.cxx', + 'src2.cxx', + 'src3.cxx', + 'src4.cxx', + 'src5.cxx', + 'src6.cxx', + 'src7.cxx', + 'src8.cxx', + 'src9.cxx', + cpp_args: ['-fmodules-ts'], + ) + +test('modtest', e) diff --git a/test cases/unit/85 cpp modules/gcc/src0.cxx b/test cases/unit/85 cpp modules/gcc/src0.cxx new file mode 100644 index 0000000..3ca4d14 --- /dev/null +++ b/test cases/unit/85 cpp modules/gcc/src0.cxx @@ -0,0 +1,7 @@ +export module M0; + +import M1; + +export int func0() { + return func1(); +} diff --git a/test cases/unit/85 cpp modules/gcc/src1.cxx b/test cases/unit/85 cpp modules/gcc/src1.cxx new file mode 100644 index 0000000..cea6696 --- /dev/null +++ b/test cases/unit/85 cpp modules/gcc/src1.cxx @@ -0,0 +1,7 @@ +export module M1; + +import M2; + +export int func1() { + return func2(); +} diff --git a/test cases/unit/85 cpp modules/gcc/src2.cxx b/test cases/unit/85 cpp modules/gcc/src2.cxx new file mode 100644 index 0000000..415714c --- /dev/null +++ b/test cases/unit/85 cpp modules/gcc/src2.cxx @@ -0,0 +1,7 @@ +export module M2; + +import M3; + +export int func2() { + return func3(); +} diff --git a/test cases/unit/85 cpp modules/gcc/src3.cxx b/test cases/unit/85 cpp modules/gcc/src3.cxx new file mode 100644 index 0000000..96f135c --- /dev/null +++ b/test cases/unit/85 cpp modules/gcc/src3.cxx @@ -0,0 +1,7 @@ +export module M3; + +import M4; + +export int func3() { + return func4(); +} diff --git a/test cases/unit/85 cpp modules/gcc/src4.cxx b/test cases/unit/85 cpp modules/gcc/src4.cxx new file mode 100644 index 0000000..1ac1a6a --- /dev/null +++ b/test cases/unit/85 cpp modules/gcc/src4.cxx @@ -0,0 +1,7 @@ +export module M4; + +import M5; + +export int func4() { + return func5(); +} diff --git a/test cases/unit/85 cpp modules/gcc/src5.cxx b/test cases/unit/85 cpp modules/gcc/src5.cxx new file mode 100644 index 0000000..96cf707 --- /dev/null +++ b/test cases/unit/85 cpp modules/gcc/src5.cxx @@ -0,0 +1,7 @@ +export module M5; + +import M6; + +export int func5() { + return func6(); +} diff --git a/test cases/unit/85 cpp modules/gcc/src6.cxx b/test cases/unit/85 cpp modules/gcc/src6.cxx new file mode 100644 index 0000000..760b71c --- /dev/null +++ b/test cases/unit/85 cpp modules/gcc/src6.cxx @@ -0,0 +1,7 @@ +export module M6; + +import M7; + +export int func6() { + return func7(); +} diff --git a/test cases/unit/85 cpp modules/gcc/src7.cxx b/test cases/unit/85 cpp modules/gcc/src7.cxx new file mode 100644 index 0000000..8ce6608 --- /dev/null +++ b/test cases/unit/85 cpp modules/gcc/src7.cxx @@ -0,0 +1,7 @@ +export module M7; + +import M8; + +export int func7() { + return func8(); +} diff --git a/test cases/unit/85 cpp modules/gcc/src8.cxx b/test cases/unit/85 cpp modules/gcc/src8.cxx new file mode 100644 index 0000000..6a3ef96 --- /dev/null +++ b/test cases/unit/85 cpp modules/gcc/src8.cxx @@ -0,0 +1,7 @@ +export module M8; + +import M9; + +export int func8() { + return func9(); +} diff --git a/test cases/unit/85 cpp modules/gcc/src9.cxx b/test cases/unit/85 cpp modules/gcc/src9.cxx new file mode 100644 index 0000000..3ecb3be --- /dev/null +++ b/test cases/unit/85 cpp modules/gcc/src9.cxx @@ -0,0 +1,5 @@ +export module M9; + +export int func9() { + return 42; +} diff --git a/test cases/unit/85 cpp modules/meson.build b/test cases/unit/85 cpp modules/meson.build new file mode 100644 index 0000000..579ea9b --- /dev/null +++ b/test cases/unit/85 cpp modules/meson.build @@ -0,0 +1,11 @@ +project('cppmodules', 'cpp', default_options: ['cpp_std=c++latest']) + +cpp = meson.get_compiler('cpp') + +if cpp.get_id() == 'msvc' + subdir('vs') +elif cpp.get_id() == 'gcc' + subdir('gcc') +else + error('Unknown compiler') +endif diff --git a/test cases/unit/85 cpp modules/vs/main.cpp b/test cases/unit/85 cpp modules/vs/main.cpp new file mode 100644 index 0000000..d825c7d --- /dev/null +++ b/test cases/unit/85 cpp modules/vs/main.cpp @@ -0,0 +1,7 @@ +import M0; +#include<cstdio> + +int main() { + printf("The value is %d", func0()); + return 0; +} diff --git a/test cases/unit/85 cpp modules/vs/meson.build b/test cases/unit/85 cpp modules/vs/meson.build new file mode 100644 index 0000000..e3f6b83 --- /dev/null +++ b/test cases/unit/85 cpp modules/vs/meson.build @@ -0,0 +1,15 @@ +e = executable('modtest', + 'main.cpp', + 'src0.ixx', + 'src1.ixx', + 'src2.ixx', + 'src3.ixx', + 'src4.ixx', + 'src5.ixx', + 'src6.ixx', + 'src7.ixx', + 'src8.ixx', + 'src9.ixx', + ) + +test('modtest', e) diff --git a/test cases/unit/85 cpp modules/vs/src0.ixx b/test cases/unit/85 cpp modules/vs/src0.ixx new file mode 100644 index 0000000..3ca4d14 --- /dev/null +++ b/test cases/unit/85 cpp modules/vs/src0.ixx @@ -0,0 +1,7 @@ +export module M0; + +import M1; + +export int func0() { + return func1(); +} diff --git a/test cases/unit/85 cpp modules/vs/src1.ixx b/test cases/unit/85 cpp modules/vs/src1.ixx new file mode 100644 index 0000000..cea6696 --- /dev/null +++ b/test cases/unit/85 cpp modules/vs/src1.ixx @@ -0,0 +1,7 @@ +export module M1; + +import M2; + +export int func1() { + return func2(); +} diff --git a/test cases/unit/85 cpp modules/vs/src2.ixx b/test cases/unit/85 cpp modules/vs/src2.ixx new file mode 100644 index 0000000..415714c --- /dev/null +++ b/test cases/unit/85 cpp modules/vs/src2.ixx @@ -0,0 +1,7 @@ +export module M2; + +import M3; + +export int func2() { + return func3(); +} diff --git a/test cases/unit/85 cpp modules/vs/src3.ixx b/test cases/unit/85 cpp modules/vs/src3.ixx new file mode 100644 index 0000000..96f135c --- /dev/null +++ b/test cases/unit/85 cpp modules/vs/src3.ixx @@ -0,0 +1,7 @@ +export module M3; + +import M4; + +export int func3() { + return func4(); +} diff --git a/test cases/unit/85 cpp modules/vs/src4.ixx b/test cases/unit/85 cpp modules/vs/src4.ixx new file mode 100644 index 0000000..1ac1a6a --- /dev/null +++ b/test cases/unit/85 cpp modules/vs/src4.ixx @@ -0,0 +1,7 @@ +export module M4; + +import M5; + +export int func4() { + return func5(); +} diff --git a/test cases/unit/85 cpp modules/vs/src5.ixx b/test cases/unit/85 cpp modules/vs/src5.ixx new file mode 100644 index 0000000..96cf707 --- /dev/null +++ b/test cases/unit/85 cpp modules/vs/src5.ixx @@ -0,0 +1,7 @@ +export module M5; + +import M6; + +export int func5() { + return func6(); +} diff --git a/test cases/unit/85 cpp modules/vs/src6.ixx b/test cases/unit/85 cpp modules/vs/src6.ixx new file mode 100644 index 0000000..760b71c --- /dev/null +++ b/test cases/unit/85 cpp modules/vs/src6.ixx @@ -0,0 +1,7 @@ +export module M6; + +import M7; + +export int func6() { + return func7(); +} diff --git a/test cases/unit/85 cpp modules/vs/src7.ixx b/test cases/unit/85 cpp modules/vs/src7.ixx new file mode 100644 index 0000000..8ce6608 --- /dev/null +++ b/test cases/unit/85 cpp modules/vs/src7.ixx @@ -0,0 +1,7 @@ +export module M7; + +import M8; + +export int func7() { + return func8(); +} diff --git a/test cases/unit/85 cpp modules/vs/src8.ixx b/test cases/unit/85 cpp modules/vs/src8.ixx new file mode 100644 index 0000000..6a3ef96 --- /dev/null +++ b/test cases/unit/85 cpp modules/vs/src8.ixx @@ -0,0 +1,7 @@ +export module M8; + +import M9; + +export int func8() { + return func9(); +} diff --git a/test cases/unit/85 cpp modules/vs/src9.ixx b/test cases/unit/85 cpp modules/vs/src9.ixx new file mode 100644 index 0000000..3ecb3be --- /dev/null +++ b/test cases/unit/85 cpp modules/vs/src9.ixx @@ -0,0 +1,5 @@ +export module M9; + +export int func9() { + return 42; +} diff --git a/test cases/unit/86 prelinking/file1.c b/test cases/unit/86 prelinking/file1.c new file mode 100644 index 0000000..9f0e265 --- /dev/null +++ b/test cases/unit/86 prelinking/file1.c @@ -0,0 +1,14 @@ +#include<public_header.h> +#include<private_header.h> + +int public_func() { + return round1_a(); +} + +int round1_a() { + return round1_b(); +} + +int round2_a() { + return round2_b(); +} diff --git a/test cases/unit/86 prelinking/file2.c b/test cases/unit/86 prelinking/file2.c new file mode 100644 index 0000000..ce3b115 --- /dev/null +++ b/test cases/unit/86 prelinking/file2.c @@ -0,0 +1,9 @@ +#include<private_header.h> + +int round1_b() { + return round1_c(); +} + +int round2_b() { + return round2_c(); +} diff --git a/test cases/unit/86 prelinking/file3.c b/test cases/unit/86 prelinking/file3.c new file mode 100644 index 0000000..85052be --- /dev/null +++ b/test cases/unit/86 prelinking/file3.c @@ -0,0 +1,9 @@ +#include<private_header.h> + +int round1_c() { + return round1_d(); +} + +int round2_c() { + return round2_d(); +} diff --git a/test cases/unit/86 prelinking/file4.c b/test cases/unit/86 prelinking/file4.c new file mode 100644 index 0000000..622364e --- /dev/null +++ b/test cases/unit/86 prelinking/file4.c @@ -0,0 +1,9 @@ +#include<private_header.h> + +int round1_d() { + return round2_a(); +} + +int round2_d() { + return 42; +} diff --git a/test cases/unit/86 prelinking/main.c b/test cases/unit/86 prelinking/main.c new file mode 100644 index 0000000..09a2e5c --- /dev/null +++ b/test cases/unit/86 prelinking/main.c @@ -0,0 +1,10 @@ +#include<public_header.h> +#include<stdio.h> + +int main(int argc, char **argv) { + if(public_func() != 42) { + printf("Something failed.\n"); + return 1; + } + return 0; +} diff --git a/test cases/unit/86 prelinking/meson.build b/test cases/unit/86 prelinking/meson.build new file mode 100644 index 0000000..baa9008 --- /dev/null +++ b/test cases/unit/86 prelinking/meson.build @@ -0,0 +1,7 @@ +project('prelinking', 'c') + +liba = static_library('prelinked', 'file1.c', 'file2.c', 'file3.c', 'file4.c', + prelink: true) +exe = executable('testprog', 'main.c', + link_with: liba) +test('prelinked', exe) diff --git a/test cases/unit/86 prelinking/private_header.h b/test cases/unit/86 prelinking/private_header.h new file mode 100644 index 0000000..f24b621 --- /dev/null +++ b/test cases/unit/86 prelinking/private_header.h @@ -0,0 +1,11 @@ +#pragma once + +int round1_a(); +int round1_b(); +int round1_c(); +int round1_d(); + +int round2_a(); +int round2_b(); +int round2_c(); +int round2_d(); diff --git a/test cases/unit/86 prelinking/public_header.h b/test cases/unit/86 prelinking/public_header.h new file mode 100644 index 0000000..0cd6786 --- /dev/null +++ b/test cases/unit/86 prelinking/public_header.h @@ -0,0 +1,3 @@ +#pragma once + +int public_func(); diff --git a/test cases/unit/87 run native test/main.c b/test cases/unit/87 run native test/main.c new file mode 100644 index 0000000..3213780 --- /dev/null +++ b/test cases/unit/87 run native test/main.c @@ -0,0 +1,17 @@ +#include <stdio.h> + +int main (int argc, char * argv[]) +{ + const char *out = "SUCCESS!"; + + if (argc != 2) { + printf ("%s\n", out); + } else { + int ret; + FILE *f = fopen (argv[1], "w"); + ret = fwrite (out, sizeof (out), 1, f); + if (ret != 1) + return -1; + } + return 0; +} diff --git a/test cases/unit/87 run native test/meson.build b/test cases/unit/87 run native test/meson.build new file mode 100644 index 0000000..3bf419c --- /dev/null +++ b/test cases/unit/87 run native test/meson.build @@ -0,0 +1,6 @@ +project('run native test', ['c']) + +executable('terget_exe', 'main.c') + +native_exe = executable('native_exe', 'main.c', native: true) +test('native_exe', native_exe, args: ['native_test_has_run.stamp']) diff --git a/test cases/unit/88 multiple envvars/meson.build b/test cases/unit/88 multiple envvars/meson.build new file mode 100644 index 0000000..ac57611 --- /dev/null +++ b/test cases/unit/88 multiple envvars/meson.build @@ -0,0 +1,4 @@ +project('multienv', 'c', 'cpp') + +executable('cexe', 'prog.c') +executable('cppexe', 'prog.cpp') diff --git a/test cases/unit/88 multiple envvars/prog.c b/test cases/unit/88 multiple envvars/prog.c new file mode 100644 index 0000000..38d3c12 --- /dev/null +++ b/test cases/unit/88 multiple envvars/prog.c @@ -0,0 +1,18 @@ +#include<stdio.h> + +#ifndef CPPFLAG +#error CPPFLAG not set +#endif + +#ifndef CFLAG +#error CFLAGS not set +#endif + +#ifdef CXXFLAG +#error CXXFLAG is set +#endif + +int main(int argc, char **argv) { + printf("%d %s\n", argc, argv[0]); + return 0; +} diff --git a/test cases/unit/88 multiple envvars/prog.cpp b/test cases/unit/88 multiple envvars/prog.cpp new file mode 100644 index 0000000..61ccf3a --- /dev/null +++ b/test cases/unit/88 multiple envvars/prog.cpp @@ -0,0 +1,18 @@ +#include<cstdio> + +#ifndef CPPFLAG +#error CPPFLAG not set +#endif + +#ifdef CFLAG +#error CFLAG is set +#endif + +#ifndef CXXFLAG +#error CXXFLAG not set +#endif + +int main(int argc, char **argv) { + printf("%d %s\n", argc, argv[0]); + return 0; +} diff --git a/test cases/unit/89 pkgconfig build rpath order/dummy.pc b/test cases/unit/89 pkgconfig build rpath order/dummy.pc new file mode 100644 index 0000000..9e3048b --- /dev/null +++ b/test cases/unit/89 pkgconfig build rpath order/dummy.pc @@ -0,0 +1,7 @@ +prefix=/foo +libdir=${prefix}/dummy + +Name: dummy +Description: Nonexisting lib but add an rpath +Version: 1.0.0 +Libs: -Wl,-rpath,${libdir} diff --git a/test cases/unit/89 pkgconfig build rpath order/meson.build b/test cases/unit/89 pkgconfig build rpath order/meson.build new file mode 100644 index 0000000..76ed8de --- /dev/null +++ b/test cases/unit/89 pkgconfig build rpath order/meson.build @@ -0,0 +1,20 @@ +project('build rpath', 'c', 'cpp') + +subdir('sub') +pkgconf_dep = dependency('dummy') + +executable('prog', 'prog.c', + dependencies : pkgconf_dep, + link_with : l, + build_rpath : '/foo/bar', + install_rpath : '/baz', + install : true, + ) + +executable('progcxx', 'prog.cc', + dependencies : pkgconf_dep, + link_with : l, + build_rpath : '/foo/bar', + install_rpath : 'baz', + install : true, + ) diff --git a/test cases/unit/89 pkgconfig build rpath order/prog.c b/test cases/unit/89 pkgconfig build rpath order/prog.c new file mode 100644 index 0000000..45b2fa3 --- /dev/null +++ b/test cases/unit/89 pkgconfig build rpath order/prog.c @@ -0,0 +1,5 @@ +int get_stuff(); + +int main(int argc, char **argv) { + return get_stuff(); +} diff --git a/test cases/unit/89 pkgconfig build rpath order/prog.cc b/test cases/unit/89 pkgconfig build rpath order/prog.cc new file mode 100644 index 0000000..c7c2123 --- /dev/null +++ b/test cases/unit/89 pkgconfig build rpath order/prog.cc @@ -0,0 +1,8 @@ +#include <string> +#include <iostream> + +int main(int argc, char **argv) { + std::string* s = new std::string("Hello"); + delete s; + return 0; +} diff --git a/test cases/unit/89 pkgconfig build rpath order/sub/meson.build b/test cases/unit/89 pkgconfig build rpath order/sub/meson.build new file mode 100644 index 0000000..6879ec6 --- /dev/null +++ b/test cases/unit/89 pkgconfig build rpath order/sub/meson.build @@ -0,0 +1 @@ +l = shared_library('stuff', 'stuff.c') diff --git a/test cases/unit/89 pkgconfig build rpath order/sub/stuff.c b/test cases/unit/89 pkgconfig build rpath order/sub/stuff.c new file mode 100644 index 0000000..d56d8b0 --- /dev/null +++ b/test cases/unit/89 pkgconfig build rpath order/sub/stuff.c @@ -0,0 +1,3 @@ +int get_stuff() { + return 0; +} diff --git a/test cases/unit/9 d dedup/meson.build b/test cases/unit/9 d dedup/meson.build new file mode 100644 index 0000000..a7b6a82 --- /dev/null +++ b/test cases/unit/9 d dedup/meson.build @@ -0,0 +1,5 @@ +project('d dedup', 'c') + +add_project_arguments('-D', 'FOO', '-D', 'BAR', language : 'c') + +executable('prog', 'prog.c') diff --git a/test cases/unit/9 d dedup/prog.c b/test cases/unit/9 d dedup/prog.c new file mode 100644 index 0000000..505f122 --- /dev/null +++ b/test cases/unit/9 d dedup/prog.c @@ -0,0 +1,14 @@ +#include<stdio.h> + +#ifndef FOO +#error FOO is not defined. +#endif + +#ifndef BAR +#error BAR is not defined. +#endif + +int main(int argc, char **argv) { + printf("All is well.\n"); + return 0; +} diff --git a/test cases/unit/90 devenv/main.c b/test cases/unit/90 devenv/main.c new file mode 100644 index 0000000..2710593 --- /dev/null +++ b/test cases/unit/90 devenv/main.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +#ifdef _WIN32 + #define DO_IMPORT __declspec(dllimport) +#else + #define DO_IMPORT +#endif + +DO_IMPORT int foo(void); + +int main(void) { + printf("This is text.\n"); + return foo(); +} diff --git a/test cases/unit/90 devenv/meson.build b/test cases/unit/90 devenv/meson.build new file mode 100644 index 0000000..3b0bb6a --- /dev/null +++ b/test cases/unit/90 devenv/meson.build @@ -0,0 +1,17 @@ +project('devenv', 'c') + +meson.add_devenv('TEST_A=1') +foo_dep = dependency('foo', fallback: 'sub') + +env = environment() +env.append('TEST_B', ['2', '3'], separator: '+') +meson.add_devenv(env) + +meson.add_devenv({'TEST_B': '0'}, separator: '+', method: 'prepend') + +env = environment({'TEST_B': ['4']}, separator: '+', method: 'append') +meson.add_devenv(env) + +# This exe links on a library built in another directory. On Windows this means +# PATH must contain builddir/subprojects/sub to be able to run it. +executable('app', 'main.c', dependencies: foo_dep, install: true) diff --git a/test cases/unit/90 devenv/subprojects/sub/foo.c b/test cases/unit/90 devenv/subprojects/sub/foo.c new file mode 100644 index 0000000..46cb845 --- /dev/null +++ b/test cases/unit/90 devenv/subprojects/sub/foo.c @@ -0,0 +1,10 @@ +#ifdef _WIN32 + #define DO_EXPORT __declspec(dllexport) +#else + #define DO_EXPORT +#endif + +DO_EXPORT int foo(void) +{ + return 0; +} diff --git a/test cases/unit/90 devenv/subprojects/sub/meson.build b/test cases/unit/90 devenv/subprojects/sub/meson.build new file mode 100644 index 0000000..5cb1232 --- /dev/null +++ b/test cases/unit/90 devenv/subprojects/sub/meson.build @@ -0,0 +1,6 @@ +project('sub', 'c') + +meson.add_devenv({'TEST_B': '1'}) + +libfoo = shared_library('foo', 'foo.c') +meson.override_dependency('foo', declare_dependency(link_with: libfoo)) diff --git a/test cases/unit/90 devenv/test-devenv.py b/test cases/unit/90 devenv/test-devenv.py new file mode 100755 index 0000000..75497ff --- /dev/null +++ b/test cases/unit/90 devenv/test-devenv.py @@ -0,0 +1,8 @@ +#! /usr/bin/python + +import os + +assert os.environ['MESON_DEVENV'] == '1' +assert os.environ['MESON_PROJECT_NAME'] == 'devenv' +assert os.environ['TEST_A'] == '1' +assert os.environ['TEST_B'] == '0+1+2+3+4' diff --git a/test cases/unit/91 install skip subprojects/foo.c b/test cases/unit/91 install skip subprojects/foo.c new file mode 100644 index 0000000..25927f5 --- /dev/null +++ b/test cases/unit/91 install skip subprojects/foo.c @@ -0,0 +1,4 @@ +int main(int argc, char *argv[]) +{ + return 0; +} diff --git a/test cases/unit/91 install skip subprojects/foo.dat b/test cases/unit/91 install skip subprojects/foo.dat new file mode 100644 index 0000000..421376d --- /dev/null +++ b/test cases/unit/91 install skip subprojects/foo.dat @@ -0,0 +1 @@ +dummy diff --git a/test cases/unit/91 install skip subprojects/foo.h b/test cases/unit/91 install skip subprojects/foo.h new file mode 100644 index 0000000..a7e26ac --- /dev/null +++ b/test cases/unit/91 install skip subprojects/foo.h @@ -0,0 +1 @@ +#define FOO diff --git a/test cases/unit/91 install skip subprojects/foo/foofile b/test cases/unit/91 install skip subprojects/foo/foofile new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/91 install skip subprojects/foo/foofile diff --git a/test cases/unit/91 install skip subprojects/meson.build b/test cases/unit/91 install skip subprojects/meson.build new file mode 100644 index 0000000..cfbae94 --- /dev/null +++ b/test cases/unit/91 install skip subprojects/meson.build @@ -0,0 +1,8 @@ +project('foo', 'c') + +install_data('foo.dat') +install_headers('foo.h') +install_subdir('foo', install_dir: '') +executable('foo', 'foo.c', install: true) + +subproject('bar') diff --git a/test cases/unit/91 install skip subprojects/subprojects/bar/bar.c b/test cases/unit/91 install skip subprojects/subprojects/bar/bar.c new file mode 100644 index 0000000..25927f5 --- /dev/null +++ b/test cases/unit/91 install skip subprojects/subprojects/bar/bar.c @@ -0,0 +1,4 @@ +int main(int argc, char *argv[]) +{ + return 0; +} diff --git a/test cases/unit/91 install skip subprojects/subprojects/bar/bar.dat b/test cases/unit/91 install skip subprojects/subprojects/bar/bar.dat new file mode 100644 index 0000000..421376d --- /dev/null +++ b/test cases/unit/91 install skip subprojects/subprojects/bar/bar.dat @@ -0,0 +1 @@ +dummy diff --git a/test cases/unit/91 install skip subprojects/subprojects/bar/bar.h b/test cases/unit/91 install skip subprojects/subprojects/bar/bar.h new file mode 100644 index 0000000..a7e26ac --- /dev/null +++ b/test cases/unit/91 install skip subprojects/subprojects/bar/bar.h @@ -0,0 +1 @@ +#define FOO diff --git a/test cases/unit/91 install skip subprojects/subprojects/bar/bar/barfile b/test cases/unit/91 install skip subprojects/subprojects/bar/bar/barfile new file mode 100644 index 0000000..421376d --- /dev/null +++ b/test cases/unit/91 install skip subprojects/subprojects/bar/bar/barfile @@ -0,0 +1 @@ +dummy diff --git a/test cases/unit/91 install skip subprojects/subprojects/bar/meson.build b/test cases/unit/91 install skip subprojects/subprojects/bar/meson.build new file mode 100644 index 0000000..b5b0734 --- /dev/null +++ b/test cases/unit/91 install skip subprojects/subprojects/bar/meson.build @@ -0,0 +1,6 @@ +project('bar', 'c') + +install_data('bar.dat') +install_headers('bar.h') +install_subdir('bar', install_dir: '') +executable('bar', 'bar.c', install: true) diff --git a/test cases/unit/92 new subproject in configured project/meson.build b/test cases/unit/92 new subproject in configured project/meson.build new file mode 100644 index 0000000..b82aa41 --- /dev/null +++ b/test cases/unit/92 new subproject in configured project/meson.build @@ -0,0 +1,7 @@ +# SPDX-license-identifier: Apache-2.0 +# Copyright © 2021 Intel Corporation +project('existing project with new subproject', 'c') + +if get_option('use-sub') + dep = subproject('sub') +endif diff --git a/test cases/unit/92 new subproject in configured project/meson_options.txt b/test cases/unit/92 new subproject in configured project/meson_options.txt new file mode 100644 index 0000000..12d8395 --- /dev/null +++ b/test cases/unit/92 new subproject in configured project/meson_options.txt @@ -0,0 +1,3 @@ +# SPDX-license-identifier: Apache-2.0 +# Copyright © 2021 Intel Corporation +option('use-sub', type : 'boolean', value : false) diff --git a/test cases/unit/92 new subproject in configured project/subprojects/sub/foo.c b/test cases/unit/92 new subproject in configured project/subprojects/sub/foo.c new file mode 100644 index 0000000..9713d9f --- /dev/null +++ b/test cases/unit/92 new subproject in configured project/subprojects/sub/foo.c @@ -0,0 +1,6 @@ +/* SPDX-license-identifier: Apache-2.0 */ +/* Copyright © 2021 Intel Corporation */ + +int func(void) { + return 1; +} diff --git a/test cases/unit/92 new subproject in configured project/subprojects/sub/meson.build b/test cases/unit/92 new subproject in configured project/subprojects/sub/meson.build new file mode 100644 index 0000000..a833b0c --- /dev/null +++ b/test cases/unit/92 new subproject in configured project/subprojects/sub/meson.build @@ -0,0 +1,7 @@ +# SPDX-license-identifier: Apache-2.0 +# Copyright © 2021 Intel Corporation +project('new subproject', 'c') + +l = library('foo', 'foo.c') + +dep = declare_dependency(link_with : l) diff --git a/test cases/unit/93 clangformat/.clang-format b/test cases/unit/93 clangformat/.clang-format new file mode 100644 index 0000000..689bc60 --- /dev/null +++ b/test cases/unit/93 clangformat/.clang-format @@ -0,0 +1,4 @@ +--- +BasedOnStyle: Google + +... diff --git a/test cases/unit/93 clangformat/.clang-format-ignore b/test cases/unit/93 clangformat/.clang-format-ignore new file mode 100644 index 0000000..7fc4d5a --- /dev/null +++ b/test cases/unit/93 clangformat/.clang-format-ignore @@ -0,0 +1,3 @@ + +# Ignore C files +*.c diff --git a/test cases/unit/93 clangformat/.clang-format-include b/test cases/unit/93 clangformat/.clang-format-include new file mode 100644 index 0000000..f057c00 --- /dev/null +++ b/test cases/unit/93 clangformat/.clang-format-include @@ -0,0 +1,3 @@ + +# Only reformat in src/ +src/**/* diff --git a/test cases/unit/93 clangformat/meson.build b/test cases/unit/93 clangformat/meson.build new file mode 100644 index 0000000..8f4af98 --- /dev/null +++ b/test cases/unit/93 clangformat/meson.build @@ -0,0 +1 @@ +project('dummy', 'c', 'cpp') diff --git a/test cases/unit/93 clangformat/not-included/badformat.cpp b/test cases/unit/93 clangformat/not-included/badformat.cpp new file mode 100644 index 0000000..99a0ea6 --- /dev/null +++ b/test cases/unit/93 clangformat/not-included/badformat.cpp @@ -0,0 +1,2 @@ +class { +}; diff --git a/test cases/unit/93 clangformat/src/badformat.c b/test cases/unit/93 clangformat/src/badformat.c new file mode 100644 index 0000000..f1d18b7 --- /dev/null +++ b/test cases/unit/93 clangformat/src/badformat.c @@ -0,0 +1,2 @@ +struct { +}; diff --git a/test cases/unit/93 clangformat/src/badformat.cpp b/test cases/unit/93 clangformat/src/badformat.cpp new file mode 100644 index 0000000..99a0ea6 --- /dev/null +++ b/test cases/unit/93 clangformat/src/badformat.cpp @@ -0,0 +1,2 @@ +class { +}; diff --git a/test cases/unit/94 custominc/easytogrepfor/genh.py b/test cases/unit/94 custominc/easytogrepfor/genh.py new file mode 100644 index 0000000..48e033a --- /dev/null +++ b/test cases/unit/94 custominc/easytogrepfor/genh.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 + +import sys + +f = open(sys.argv[1], 'w') +f.write('#define RETURN_VALUE 0') +f.close() diff --git a/test cases/unit/94 custominc/easytogrepfor/meson.build b/test cases/unit/94 custominc/easytogrepfor/meson.build new file mode 100644 index 0000000..e749753 --- /dev/null +++ b/test cases/unit/94 custominc/easytogrepfor/meson.build @@ -0,0 +1,3 @@ +genh = custom_target('header', + output: 'generated.h', + command: [find_program('genh.py'), '@OUTPUT@']) diff --git a/test cases/unit/94 custominc/helper.c b/test cases/unit/94 custominc/helper.c new file mode 100644 index 0000000..3237441 --- /dev/null +++ b/test cases/unit/94 custominc/helper.c @@ -0,0 +1,5 @@ +#include<generated.h> + +int func(void) { + return RETURN_VALUE; +} diff --git a/test cases/unit/94 custominc/meson.build b/test cases/unit/94 custominc/meson.build new file mode 100644 index 0000000..bab1139 --- /dev/null +++ b/test cases/unit/94 custominc/meson.build @@ -0,0 +1,9 @@ +project('implicit custom dirs', 'c') + +subdir('easytogrepfor') + +l = static_library('helper', 'helper.c', genh) +d = declare_dependency(link_with: l, sources: genh) +executable('prog', 'prog.c', dependencies: d, implicit_include_directories: false) + +executable('prog2', 'prog2.c', dependencies: d) diff --git a/test cases/unit/94 custominc/prog.c b/test cases/unit/94 custominc/prog.c new file mode 100644 index 0000000..db9df9d --- /dev/null +++ b/test cases/unit/94 custominc/prog.c @@ -0,0 +1,9 @@ +#include<stdlib.h> + +int func(void); + +int main(int argc, char **argv) { + (void)argc; + (void)(argv); + return func(); +} diff --git a/test cases/unit/94 custominc/prog2.c b/test cases/unit/94 custominc/prog2.c new file mode 100644 index 0000000..e64b229 --- /dev/null +++ b/test cases/unit/94 custominc/prog2.c @@ -0,0 +1,10 @@ +#include<stdlib.h> +#include<generated.h> + +int func(void); + +int main(int argc, char **argv) { + (void)argc; + (void)(argv); + return func() + RETURN_VALUE; +} diff --git a/test cases/unit/95 implicit force fallback/meson.build b/test cases/unit/95 implicit force fallback/meson.build new file mode 100644 index 0000000..623a338 --- /dev/null +++ b/test cases/unit/95 implicit force fallback/meson.build @@ -0,0 +1,8 @@ +project('implicit force fallback') + +# The dependency 'something' is provided by a subproject. Normally this won't +# use the fallback subproject because required is false. However this unit test +# is configured with wrap_mode=forcefallback and force_fallback_for=something +# in which case we are expecting the fallback to be done. +d = dependency('something', required: false) +assert(d.found()) diff --git a/test cases/unit/95 implicit force fallback/subprojects/something/meson.build b/test cases/unit/95 implicit force fallback/subprojects/something/meson.build new file mode 100644 index 0000000..89a4727 --- /dev/null +++ b/test cases/unit/95 implicit force fallback/subprojects/something/meson.build @@ -0,0 +1,3 @@ +project('something') + +meson.override_dependency('something', declare_dependency()) diff --git a/test cases/unit/96 compiler.links file arg/meson.build b/test cases/unit/96 compiler.links file arg/meson.build new file mode 100644 index 0000000..c409dcb --- /dev/null +++ b/test cases/unit/96 compiler.links file arg/meson.build @@ -0,0 +1,11 @@ +project('test', ['c', 'cpp']) + +cc = meson.get_compiler('c') +cxx = meson.get_compiler('cpp') + +# used by run_unittests.py to grab the path to the C and C++ compilers +assert(cc.compiles(files('test.c'))) +assert(cxx.compiles(files('test.c'))) + +assert(cc.links(files('test.c'))) +assert(cxx.links(files('test.c'))) diff --git a/test cases/unit/96 compiler.links file arg/test.c b/test cases/unit/96 compiler.links file arg/test.c new file mode 100644 index 0000000..78f2de1 --- /dev/null +++ b/test cases/unit/96 compiler.links file arg/test.c @@ -0,0 +1 @@ +int main(void) { return 0; } diff --git a/test cases/unit/97 link full name/.gitignore b/test cases/unit/97 link full name/.gitignore new file mode 100644 index 0000000..8129601 --- /dev/null +++ b/test cases/unit/97 link full name/.gitignore @@ -0,0 +1,5 @@ +*.a +*.o +a.out +libtestprovider.a +build diff --git a/test cases/unit/97 link full name/libtestprovider/meson.build b/test cases/unit/97 link full name/libtestprovider/meson.build new file mode 100644 index 0000000..128c213 --- /dev/null +++ b/test cases/unit/97 link full name/libtestprovider/meson.build @@ -0,0 +1,20 @@ +project('libtestprovider','c') + +libtestprovider=static_library('testprovider', + files('./provider.c'), + install:true, + c_args:['-Wall','-Werror'], +) + +pkg = import('pkgconfig') + + +pkg.generate( + name:'testprovider', + filebase:'libtestprovider', + description: 'fortest', + requires: [], + libraries_private: ['-Wl,--whole-archive'] + + ['-L${libdir}','-l:libtestprovider.a']+ + ['-Wl,--no-whole-archive'] +) diff --git a/test cases/unit/97 link full name/libtestprovider/provider.c b/test cases/unit/97 link full name/libtestprovider/provider.c new file mode 100644 index 0000000..5e79966 --- /dev/null +++ b/test cases/unit/97 link full name/libtestprovider/provider.c @@ -0,0 +1,12 @@ +#include <stdio.h> +static int g_checked = 0; + +static void __attribute__((constructor(101), used)) init_checked(void) { + g_checked=100; + fprintf(stdout, "inited\n"); +} + + +int get_checked(void) { + return g_checked; +} diff --git a/test cases/unit/97 link full name/proguser/meson.build b/test cases/unit/97 link full name/proguser/meson.build new file mode 100644 index 0000000..5be5bc9 --- /dev/null +++ b/test cases/unit/97 link full name/proguser/meson.build @@ -0,0 +1,11 @@ +project('testprovider','c') + +deplib = dependency('libtestprovider', static:true) + +dprovidertest = executable('dprovidertest', + files('./receiver.c'), + dependencies:[deplib], + c_args:['-Wall','-Werror'], +) + +test('testprovider',dprovidertest) diff --git a/test cases/unit/97 link full name/proguser/receiver.c b/test cases/unit/97 link full name/proguser/receiver.c new file mode 100644 index 0000000..65e9d8e --- /dev/null +++ b/test cases/unit/97 link full name/proguser/receiver.c @@ -0,0 +1,18 @@ +#include <stdio.h> +int __attribute__((weak)) get_checked(void) { + return -1; +} + + +#define CHECK_VALUE (100) +#define TEST_SUCCESS (0) +#define TEST_FAILTURE (-1) + +int main(void) { + if (get_checked() == CHECK_VALUE) { + fprintf(stdout,"good\n"); + return TEST_SUCCESS; + } + fprintf(stdout,"bad\n"); + return TEST_FAILTURE; +} diff --git a/test cases/unit/98 install all targets/bar-custom.txt b/test cases/unit/98 install all targets/bar-custom.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/98 install all targets/bar-custom.txt diff --git a/test cases/unit/98 install all targets/bar-devel.h b/test cases/unit/98 install all targets/bar-devel.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/98 install all targets/bar-devel.h diff --git a/test cases/unit/98 install all targets/bar-notag.txt b/test cases/unit/98 install all targets/bar-notag.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/98 install all targets/bar-notag.txt diff --git a/test cases/unit/98 install all targets/custom_files/data.txt b/test cases/unit/98 install all targets/custom_files/data.txt new file mode 100644 index 0000000..557db03 --- /dev/null +++ b/test cases/unit/98 install all targets/custom_files/data.txt @@ -0,0 +1 @@ +Hello World diff --git a/test cases/unit/98 install all targets/foo.in b/test cases/unit/98 install all targets/foo.in new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/98 install all targets/foo.in diff --git a/test cases/unit/98 install all targets/foo1-devel.h b/test cases/unit/98 install all targets/foo1-devel.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/98 install all targets/foo1-devel.h diff --git a/test cases/unit/98 install all targets/lib.c b/test cases/unit/98 install all targets/lib.c new file mode 100644 index 0000000..2ea9c7d --- /dev/null +++ b/test cases/unit/98 install all targets/lib.c @@ -0,0 +1,9 @@ +#if defined _WIN32 || defined __CYGWIN__ +#define DLL_PUBLIC __declspec(dllexport) +#else +#define DLL_PUBLIC +#endif + +int DLL_PUBLIC foo(void) { + return 0; +} diff --git a/test cases/unit/98 install all targets/main.c b/test cases/unit/98 install all targets/main.c new file mode 100644 index 0000000..0fb4389 --- /dev/null +++ b/test cases/unit/98 install all targets/main.c @@ -0,0 +1,3 @@ +int main(int argc, char *argv[]) { + return 0; +} diff --git a/test cases/unit/98 install all targets/meson.build b/test cases/unit/98 install all targets/meson.build new file mode 100644 index 0000000..3065b5f --- /dev/null +++ b/test cases/unit/98 install all targets/meson.build @@ -0,0 +1,108 @@ +project('install tag', 'c') + +subdir('subdir') + +# Those files should not be tagged +configure_file(input: 'foo.in', output: 'foo-notag.h', + configuration: {'foo': 'bar'}, + install_dir: get_option('datadir'), + install: true, +) +install_data('bar-notag.txt', + install_dir: get_option('datadir') +) +custom_target('ct1', + output: ['out1-notag.txt', 'out2-notag.txt'], + command: ['script.py', '@OUTPUT@'], + install_dir: get_option('datadir'), + install: true, +) + +# Those files should be tagged as devel +install_headers('foo1-devel.h') +install_data('bar-devel.h', + install_dir: get_option('includedir'), +) +configure_file(input: 'foo.in', output: 'foo2-devel.h', + configuration: {'foo': 'bar'}, + install_dir: get_option('includedir'), + install: true, +) +static_library('static', 'lib.c', + install: true, +) +custom_target('ct-header1', + output: ['ct-header1.h'], + command: ['script.py', '@OUTPUT@'], + install_dir: get_option('includedir'), + install: true, +) +custom_target('ct-header2', + output: ['ct-header2.h', 'ct-header3.h'], + command: ['script.py', '@OUTPUT@'], + install_dir: [false, get_option('includedir')], + install: true, +) +install_emptydir(get_option('includedir') / 'subdir-devel') +install_subdir('custom_files', + install_dir: get_option('includedir'), +) + +# Those files should have 'runtime' tag +executable('app', 'main.c', + install: true, +) +executable('app-otherdir', 'main.c', + install: true, + install_dir: 'otherbin', +) +shared_library('shared', 'lib.c', + install: true, +) +both_libraries('both', 'lib.c', + install: true, +) + +# Unversioned .so file should have 'devel' tag, others should have 'runtime' tag +shared_library('versioned_shared', 'lib.c', + install: true, + version: '1.2.3', +) + +# Those files should have custom tag +install_data('bar-custom.txt', + install_dir: get_option('datadir'), + install_tag: 'custom') +configure_file(input: 'foo.in', output: 'foo-custom.h', + configuration: {'foo': 'bar'}, + install_dir: get_option('datadir'), + install_tag: 'custom', + install: true, +) +both_libraries('bothcustom', 'lib.c', + install_tag: 'custom', + install: true, +) +custom_target('ct2', + output: ['out1-custom.txt', 'out2-custom.txt'], + command: ['script.py', '@OUTPUT@'], + install_dir: get_option('datadir'), + install_tag: 'custom', + install: true, +) +install_subdir('custom_files', + install_dir: get_option('datadir'), + install_tag: 'custom', +) + +# First is custom, 2nd is devel, 3rd has no tag +custom_target('ct3', + output: ['out3-custom.txt', 'out-devel.h', 'out3-notag.txt'], + command: ['script.py', '@OUTPUT@'], + install_dir: [get_option('datadir'), get_option('includedir'), get_option('datadir')], + install_tag: ['custom', 'devel', false], + install: true, +) + +meson.add_install_script('script.py', install_tag: 'custom') +meson.add_install_script('script.py') diff --git a/test cases/unit/98 install all targets/script.py b/test cases/unit/98 install all targets/script.py new file mode 100644 index 0000000..c5f3be9 --- /dev/null +++ b/test cases/unit/98 install all targets/script.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 + +import sys + +for f in sys.argv[1:]: + with open(f, 'w') as f: + pass diff --git a/test cases/unit/98 install all targets/subdir/bar2-devel.h b/test cases/unit/98 install all targets/subdir/bar2-devel.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/98 install all targets/subdir/bar2-devel.h diff --git a/test cases/unit/98 install all targets/subdir/foo2.in b/test cases/unit/98 install all targets/subdir/foo2.in new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/98 install all targets/subdir/foo2.in diff --git a/test cases/unit/98 install all targets/subdir/foo3-devel.h b/test cases/unit/98 install all targets/subdir/foo3-devel.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/98 install all targets/subdir/foo3-devel.h diff --git a/test cases/unit/98 install all targets/subdir/lib.c b/test cases/unit/98 install all targets/subdir/lib.c new file mode 100644 index 0000000..2ea9c7d --- /dev/null +++ b/test cases/unit/98 install all targets/subdir/lib.c @@ -0,0 +1,9 @@ +#if defined _WIN32 || defined __CYGWIN__ +#define DLL_PUBLIC __declspec(dllexport) +#else +#define DLL_PUBLIC +#endif + +int DLL_PUBLIC foo(void) { + return 0; +} diff --git a/test cases/unit/98 install all targets/subdir/main.c b/test cases/unit/98 install all targets/subdir/main.c new file mode 100644 index 0000000..0fb4389 --- /dev/null +++ b/test cases/unit/98 install all targets/subdir/main.c @@ -0,0 +1,3 @@ +int main(int argc, char *argv[]) { + return 0; +} diff --git a/test cases/unit/98 install all targets/subdir/meson.build b/test cases/unit/98 install all targets/subdir/meson.build new file mode 100644 index 0000000..53c796a --- /dev/null +++ b/test cases/unit/98 install all targets/subdir/meson.build @@ -0,0 +1,21 @@ +configure_file(input: 'foo2.in', output: 'foo2.h', + configuration: {'foo': 'bar'}, + install_dir: get_option('datadir'), + install: true, +) +custom_target('ct4', + output: ['out1.txt', 'out2.txt'], + command: ['script.py', '@OUTPUT@'], + install_dir: get_option('datadir'), + install: true, +) +install_headers('foo3-devel.h') +install_data('bar2-devel.h', + install_dir: get_option('includedir'), +) +executable('app2', 'main.c', + install: true, +) +both_libraries('both2', 'lib.c', + install: true, +) diff --git a/test cases/unit/98 install all targets/subdir/script.py b/test cases/unit/98 install all targets/subdir/script.py new file mode 100644 index 0000000..c5f3be9 --- /dev/null +++ b/test cases/unit/98 install all targets/subdir/script.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 + +import sys + +for f in sys.argv[1:]: + with open(f, 'w') as f: + pass diff --git a/test cases/unit/99 custom target name/file.txt.in b/test cases/unit/99 custom target name/file.txt.in new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test cases/unit/99 custom target name/file.txt.in diff --git a/test cases/unit/99 custom target name/meson.build b/test cases/unit/99 custom target name/meson.build new file mode 100644 index 0000000..8d148a8 --- /dev/null +++ b/test cases/unit/99 custom target name/meson.build @@ -0,0 +1,14 @@ +project('custom target name', 'c') + +python = import('python').find_installation() + +# Name argument is optional and should default to 'file.txt' +custom_target( + input: 'file.txt.in', + output: '@BASENAME@', + command: [python, '--version'], + build_by_default: true, + capture: true, +) + +subdir('subdir') diff --git a/test cases/unit/99 custom target name/subdir/meson.build b/test cases/unit/99 custom target name/subdir/meson.build new file mode 100644 index 0000000..785a7b3 --- /dev/null +++ b/test cases/unit/99 custom target name/subdir/meson.build @@ -0,0 +1,9 @@ +# Name argument is optional and should default to 'file.txt', but should be +# displayed as 'subdir/file.txt' by ninja. +custom_target( + input: '../file.txt.in', + output: ['@BASENAME@'], + command: [python, '--version'], + build_by_default: true, + capture: true, +) |