diff options
author | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
---|---|---|
committer | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
commit | af1a266670d040d2f4083ff309d732d648afba2a (patch) | |
tree | 2fc46203448ddcc6f81546d379abfaeb323575e9 /meson/test cases/unit | |
parent | e02cda008591317b1625707ff8e115a4841aa889 (diff) |
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'meson/test cases/unit')
449 files changed, 3575 insertions, 0 deletions
diff --git a/meson/test cases/unit/1 soname/CMakeLists.txt b/meson/test cases/unit/1 soname/CMakeLists.txt new file mode 100644 index 000000000..c4f2e3eb9 --- /dev/null +++ b/meson/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/meson/test cases/unit/1 soname/meson.build b/meson/test cases/unit/1 soname/meson.build new file mode 100644 index 000000000..950dadc5d --- /dev/null +++ b/meson/test cases/unit/1 soname/meson.build @@ -0,0 +1,22 @@ +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') diff --git a/meson/test cases/unit/1 soname/versioned.c b/meson/test cases/unit/1 soname/versioned.c new file mode 100644 index 000000000..f48d2b0b8 --- /dev/null +++ b/meson/test cases/unit/1 soname/versioned.c @@ -0,0 +1,3 @@ +int versioned_func() { + return 0; +} diff --git a/meson/test cases/unit/10 build_rpath/meson.build b/meson/test cases/unit/10 build_rpath/meson.build new file mode 100644 index 000000000..c0bc3bd27 --- /dev/null +++ b/meson/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/meson/test cases/unit/10 build_rpath/prog.c b/meson/test cases/unit/10 build_rpath/prog.c new file mode 100644 index 000000000..45b2fa3df --- /dev/null +++ b/meson/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/meson/test cases/unit/10 build_rpath/prog.cc b/meson/test cases/unit/10 build_rpath/prog.cc new file mode 100644 index 000000000..c7c212370 --- /dev/null +++ b/meson/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/meson/test cases/unit/10 build_rpath/sub/meson.build b/meson/test cases/unit/10 build_rpath/sub/meson.build new file mode 100644 index 000000000..6879ec666 --- /dev/null +++ b/meson/test cases/unit/10 build_rpath/sub/meson.build @@ -0,0 +1 @@ +l = shared_library('stuff', 'stuff.c') diff --git a/meson/test cases/unit/10 build_rpath/sub/stuff.c b/meson/test cases/unit/10 build_rpath/sub/stuff.c new file mode 100644 index 000000000..d56d8b0ea --- /dev/null +++ b/meson/test cases/unit/10 build_rpath/sub/stuff.c @@ -0,0 +1,3 @@ +int get_stuff() { + return 0; +} diff --git a/meson/test cases/unit/100 rlib linkage/lib2.rs b/meson/test cases/unit/100 rlib linkage/lib2.rs new file mode 100644 index 000000000..3487bc5a9 --- /dev/null +++ b/meson/test cases/unit/100 rlib linkage/lib2.rs @@ -0,0 +1,5 @@ +use lib; + +pub fn fun() { + lib::fun(); +} diff --git a/meson/test cases/unit/100 rlib linkage/main.rs b/meson/test cases/unit/100 rlib linkage/main.rs new file mode 100644 index 000000000..d0f82e4e1 --- /dev/null +++ b/meson/test cases/unit/100 rlib linkage/main.rs @@ -0,0 +1,5 @@ +use lib2::fun; + +fn main() { + fun(); +} diff --git a/meson/test cases/unit/100 rlib linkage/meson.build b/meson/test cases/unit/100 rlib linkage/meson.build new file mode 100644 index 000000000..2d15b2a14 --- /dev/null +++ b/meson/test cases/unit/100 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/meson/test cases/unit/11 cross prog/meson.build b/meson/test cases/unit/11 cross prog/meson.build new file mode 100644 index 000000000..a7adeb284 --- /dev/null +++ b/meson/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).stdout().strip() +cross_out = run_command(cross_exe).stdout().strip() +cross_other_out = run_command(cross_other_exe).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/meson/test cases/unit/11 cross prog/some_cross_tool.py b/meson/test cases/unit/11 cross prog/some_cross_tool.py new file mode 100755 index 000000000..6c01b1a60 --- /dev/null +++ b/meson/test cases/unit/11 cross prog/some_cross_tool.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 + + +print('cross') diff --git a/meson/test cases/unit/11 cross prog/sometool.py b/meson/test cases/unit/11 cross prog/sometool.py new file mode 100755 index 000000000..06bcdc8ed --- /dev/null +++ b/meson/test cases/unit/11 cross prog/sometool.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 + + +print('native') diff --git a/meson/test cases/unit/12 promote/meson.build b/meson/test cases/unit/12 promote/meson.build new file mode 100644 index 000000000..066cf36cf --- /dev/null +++ b/meson/test cases/unit/12 promote/meson.build @@ -0,0 +1,5 @@ +project('promotion test', 'c') + +subproject('s1') +subproject('s2') + diff --git a/meson/test cases/unit/12 promote/subprojects/s1/meson.build b/meson/test cases/unit/12 promote/subprojects/s1/meson.build new file mode 100644 index 000000000..88c467bf4 --- /dev/null +++ b/meson/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/meson/test cases/unit/12 promote/subprojects/s1/s1.c b/meson/test cases/unit/12 promote/subprojects/s1/s1.c new file mode 100644 index 000000000..7d1d775c1 --- /dev/null +++ b/meson/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/meson/test cases/unit/12 promote/subprojects/s1/subprojects/s3/meson.build b/meson/test cases/unit/12 promote/subprojects/s1/subprojects/s3/meson.build new file mode 100644 index 000000000..894fe265b --- /dev/null +++ b/meson/test cases/unit/12 promote/subprojects/s1/subprojects/s3/meson.build @@ -0,0 +1,4 @@ +project('s3', 'c') + +l = static_library('s3', 's3.c') + diff --git a/meson/test cases/unit/12 promote/subprojects/s1/subprojects/s3/s3.c b/meson/test cases/unit/12 promote/subprojects/s1/subprojects/s3/s3.c new file mode 100644 index 000000000..0166603e5 --- /dev/null +++ b/meson/test cases/unit/12 promote/subprojects/s1/subprojects/s3/s3.c @@ -0,0 +1,3 @@ +int func2() { + return -42; +} diff --git a/meson/test cases/unit/12 promote/subprojects/s1/subprojects/scommon/meson.build b/meson/test cases/unit/12 promote/subprojects/s1/subprojects/scommon/meson.build new file mode 100644 index 000000000..231f2757b --- /dev/null +++ b/meson/test cases/unit/12 promote/subprojects/s1/subprojects/scommon/meson.build @@ -0,0 +1,4 @@ +project('scommon', 'c') + +clib = static_library('scommon', 'scommon_broken.c') + diff --git a/meson/test cases/unit/12 promote/subprojects/s1/subprojects/scommon/scommon_broken.c b/meson/test cases/unit/12 promote/subprojects/s1/subprojects/scommon/scommon_broken.c new file mode 100644 index 000000000..3665a9cbc --- /dev/null +++ b/meson/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/meson/test cases/unit/12 promote/subprojects/s2/meson.build b/meson/test cases/unit/12 promote/subprojects/s2/meson.build new file mode 100644 index 000000000..32bcf8f39 --- /dev/null +++ b/meson/test cases/unit/12 promote/subprojects/s2/meson.build @@ -0,0 +1,6 @@ +project('s2', 'c') + +sc = subproject('scommon') + +executable('s2', 's2.c', link_with : sc.get_variable('clib')) + diff --git a/meson/test cases/unit/12 promote/subprojects/s2/s2.c b/meson/test cases/unit/12 promote/subprojects/s2/s2.c new file mode 100644 index 000000000..2a6d1e63d --- /dev/null +++ b/meson/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/meson/test cases/unit/12 promote/subprojects/s2/subprojects/athing.wrap b/meson/test cases/unit/12 promote/subprojects/s2/subprojects/athing.wrap new file mode 100644 index 000000000..11b217878 --- /dev/null +++ b/meson/test cases/unit/12 promote/subprojects/s2/subprojects/athing.wrap @@ -0,0 +1 @@ +[wrap-file] diff --git a/meson/test cases/unit/12 promote/subprojects/s2/subprojects/scommon/meson.build b/meson/test cases/unit/12 promote/subprojects/s2/subprojects/scommon/meson.build new file mode 100644 index 000000000..e0d8c7ddc --- /dev/null +++ b/meson/test cases/unit/12 promote/subprojects/s2/subprojects/scommon/meson.build @@ -0,0 +1,4 @@ +project('scommon', 'c') + +clib = static_library('scommon', 'scommon_ok.c') + diff --git a/meson/test cases/unit/12 promote/subprojects/s2/subprojects/scommon/scommon_ok.c b/meson/test cases/unit/12 promote/subprojects/s2/subprojects/scommon/scommon_ok.c new file mode 100644 index 000000000..652f4eb13 --- /dev/null +++ b/meson/test cases/unit/12 promote/subprojects/s2/subprojects/scommon/scommon_ok.c @@ -0,0 +1,3 @@ +int func() { + return 42; +} diff --git a/meson/test cases/unit/13 reconfigure/meson.build b/meson/test cases/unit/13 reconfigure/meson.build new file mode 100644 index 000000000..453644a02 --- /dev/null +++ b/meson/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/meson/test cases/unit/14 testsetup selection/main.c b/meson/test cases/unit/14 testsetup selection/main.c new file mode 100644 index 000000000..9b6bdc2ec --- /dev/null +++ b/meson/test cases/unit/14 testsetup selection/main.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/meson/test cases/unit/14 testsetup selection/meson.build b/meson/test cases/unit/14 testsetup selection/meson.build new file mode 100644 index 000000000..ae996c5be --- /dev/null +++ b/meson/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/meson/test cases/unit/14 testsetup selection/subprojects/bar/bar.c b/meson/test cases/unit/14 testsetup selection/subprojects/bar/bar.c new file mode 100644 index 000000000..9b6bdc2ec --- /dev/null +++ b/meson/test cases/unit/14 testsetup selection/subprojects/bar/bar.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/meson/test cases/unit/14 testsetup selection/subprojects/bar/meson.build b/meson/test cases/unit/14 testsetup selection/subprojects/bar/meson.build new file mode 100644 index 000000000..1155a88aa --- /dev/null +++ b/meson/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/meson/test cases/unit/14 testsetup selection/subprojects/foo/foo.c b/meson/test cases/unit/14 testsetup selection/subprojects/foo/foo.c new file mode 100644 index 000000000..9b6bdc2ec --- /dev/null +++ b/meson/test cases/unit/14 testsetup selection/subprojects/foo/foo.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/meson/test cases/unit/14 testsetup selection/subprojects/foo/meson.build b/meson/test cases/unit/14 testsetup selection/subprojects/foo/meson.build new file mode 100644 index 000000000..2eef840cd --- /dev/null +++ b/meson/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/meson/test cases/unit/15 prebuilt object/main.c b/meson/test cases/unit/15 prebuilt object/main.c new file mode 100644 index 000000000..480bda5f4 --- /dev/null +++ b/meson/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/meson/test cases/unit/15 prebuilt object/meson.build b/meson/test cases/unit/15 prebuilt object/meson.build new file mode 100644 index 000000000..92f966b97 --- /dev/null +++ b/meson/test cases/unit/15 prebuilt object/meson.build @@ -0,0 +1,25 @@ +# 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 = executable('prog', 'main.c', +objects : prebuilt) + +test('objtest', e) diff --git a/meson/test cases/unit/15 prebuilt object/source.c b/meson/test cases/unit/15 prebuilt object/source.c new file mode 100644 index 000000000..f39b4f366 --- /dev/null +++ b/meson/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/meson/test cases/unit/16 prebuilt static/libdir/best.c b/meson/test cases/unit/16 prebuilt static/libdir/best.c new file mode 100644 index 000000000..ab774e1f5 --- /dev/null +++ b/meson/test cases/unit/16 prebuilt static/libdir/best.c @@ -0,0 +1,3 @@ +const char *msg() { + return "I am the best."; +} diff --git a/meson/test cases/unit/16 prebuilt static/libdir/best.h b/meson/test cases/unit/16 prebuilt static/libdir/best.h new file mode 100644 index 000000000..063017f86 --- /dev/null +++ b/meson/test cases/unit/16 prebuilt static/libdir/best.h @@ -0,0 +1,3 @@ +#pragma once + +const char *msg(); diff --git a/meson/test cases/unit/16 prebuilt static/libdir/meson.build b/meson/test cases/unit/16 prebuilt static/libdir/meson.build new file mode 100644 index 000000000..8d74ccf3f --- /dev/null +++ b/meson/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/meson/test cases/unit/16 prebuilt static/main.c b/meson/test cases/unit/16 prebuilt static/main.c new file mode 100644 index 000000000..d172625b9 --- /dev/null +++ b/meson/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/meson/test cases/unit/16 prebuilt static/meson.build b/meson/test cases/unit/16 prebuilt static/meson.build new file mode 100644 index 000000000..9ea1d0dc7 --- /dev/null +++ b/meson/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/meson/test cases/unit/17 prebuilt shared/alexandria.c b/meson/test cases/unit/17 prebuilt shared/alexandria.c new file mode 100644 index 000000000..2d6b84831 --- /dev/null +++ b/meson/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/meson/test cases/unit/17 prebuilt shared/alexandria.h b/meson/test cases/unit/17 prebuilt shared/alexandria.h new file mode 100644 index 000000000..6e507c5ae --- /dev/null +++ b/meson/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/meson/test cases/unit/17 prebuilt shared/another_visitor.c b/meson/test cases/unit/17 prebuilt shared/another_visitor.c new file mode 100644 index 000000000..18e5f150e --- /dev/null +++ b/meson/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/meson/test cases/unit/17 prebuilt shared/meson.build b/meson/test cases/unit/17 prebuilt shared/meson.build new file mode 100644 index 000000000..41c11c656 --- /dev/null +++ b/meson/test cases/unit/17 prebuilt shared/meson.build @@ -0,0 +1,14 @@ +project('prebuilt shared library', 'c') + +cc = meson.get_compiler('c') +shlib = cc.find_library('alexandria', dirs : meson.current_source_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) + diff --git a/meson/test cases/unit/17 prebuilt shared/patron.c b/meson/test cases/unit/17 prebuilt shared/patron.c new file mode 100644 index 000000000..461d7b487 --- /dev/null +++ b/meson/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/meson/test cases/unit/18 pkgconfig static/foo.c b/meson/test cases/unit/18 pkgconfig static/foo.c new file mode 100644 index 000000000..bf7fbddf3 --- /dev/null +++ b/meson/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/meson/test cases/unit/18 pkgconfig static/foo.pc.in b/meson/test cases/unit/18 pkgconfig static/foo.pc.in new file mode 100644 index 000000000..b26c0b0a2 --- /dev/null +++ b/meson/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/meson/test cases/unit/18 pkgconfig static/include/foo.h b/meson/test cases/unit/18 pkgconfig static/include/foo.h new file mode 100644 index 000000000..88ef55494 --- /dev/null +++ b/meson/test cases/unit/18 pkgconfig static/include/foo.h @@ -0,0 +1,3 @@ +#pragma once + +int power_level (void); diff --git a/meson/test cases/unit/18 pkgconfig static/main.c b/meson/test cases/unit/18 pkgconfig static/main.c new file mode 100644 index 000000000..cc4649f71 --- /dev/null +++ b/meson/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/meson/test cases/unit/18 pkgconfig static/meson.build b/meson/test cases/unit/18 pkgconfig static/meson.build new file mode 100644 index 000000000..d1b0fd5ac --- /dev/null +++ b/meson/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/meson/test cases/unit/19 array option/meson.build b/meson/test cases/unit/19 array option/meson.build new file mode 100644 index 000000000..2b44181fb --- /dev/null +++ b/meson/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/meson/test cases/unit/19 array option/meson_options.txt b/meson/test cases/unit/19 array option/meson_options.txt new file mode 100644 index 000000000..0ccdcc4ad --- /dev/null +++ b/meson/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/meson/test cases/unit/2 testsetups/buggy.c b/meson/test cases/unit/2 testsetups/buggy.c new file mode 100644 index 000000000..d23883017 --- /dev/null +++ b/meson/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/meson/test cases/unit/2 testsetups/envcheck.py b/meson/test cases/unit/2 testsetups/envcheck.py new file mode 100755 index 000000000..af39c4e23 --- /dev/null +++ b/meson/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/meson/test cases/unit/2 testsetups/impl.c b/meson/test cases/unit/2 testsetups/impl.c new file mode 100644 index 000000000..d87f3de51 --- /dev/null +++ b/meson/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/meson/test cases/unit/2 testsetups/impl.h b/meson/test cases/unit/2 testsetups/impl.h new file mode 100644 index 000000000..7a08cb329 --- /dev/null +++ b/meson/test cases/unit/2 testsetups/impl.h @@ -0,0 +1,3 @@ +#pragma once + +void do_nasty(char *ptr); diff --git a/meson/test cases/unit/2 testsetups/meson.build b/meson/test cases/unit/2 testsetups/meson.build new file mode 100644 index 000000000..1e8f0184f --- /dev/null +++ b/meson/test cases/unit/2 testsetups/meson.build @@ -0,0 +1,26 @@ +project('testsetups', 'c') + +vg = find_program('valgrind') + +# 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/meson/test cases/unit/20 subproj dep variables/meson.build b/meson/test cases/unit/20 subproj dep variables/meson.build new file mode 100644 index 000000000..954463b5d --- /dev/null +++ b/meson/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/meson/test cases/unit/20 subproj dep variables/subprojects/failingsubproj/meson.build b/meson/test cases/unit/20 subproj dep variables/subprojects/failingsubproj/meson.build new file mode 100644 index 000000000..3a84bd20c --- /dev/null +++ b/meson/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/meson/test cases/unit/20 subproj dep variables/subprojects/nestedsubproj/meson.build b/meson/test cases/unit/20 subproj dep variables/subprojects/nestedsubproj/meson.build new file mode 100644 index 000000000..4bf549e6a --- /dev/null +++ b/meson/test cases/unit/20 subproj dep variables/subprojects/nestedsubproj/meson.build @@ -0,0 +1,3 @@ +project('dep', 'c') + +subproject('subsubproject') diff --git a/meson/test cases/unit/20 subproj dep variables/subprojects/nestedsubproj/subprojects/subsubproject.wrap b/meson/test cases/unit/20 subproj dep variables/subprojects/nestedsubproj/subprojects/subsubproject.wrap new file mode 100644 index 000000000..11b217878 --- /dev/null +++ b/meson/test cases/unit/20 subproj dep variables/subprojects/nestedsubproj/subprojects/subsubproject.wrap @@ -0,0 +1 @@ +[wrap-file] diff --git a/meson/test cases/unit/20 subproj dep variables/subprojects/somesubproj/meson.build b/meson/test cases/unit/20 subproj dep variables/subprojects/somesubproj/meson.build new file mode 100644 index 000000000..dd65c99f7 --- /dev/null +++ b/meson/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/meson/test cases/unit/21 exit status/meson.build b/meson/test cases/unit/21 exit status/meson.build new file mode 100644 index 000000000..4f5485bfd --- /dev/null +++ b/meson/test cases/unit/21 exit status/meson.build @@ -0,0 +1,2 @@ +project('exit status') +exception() diff --git a/meson/test cases/unit/22 warning location/a.c b/meson/test cases/unit/22 warning location/a.c new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/meson/test cases/unit/22 warning location/a.c diff --git a/meson/test cases/unit/22 warning location/b.c b/meson/test cases/unit/22 warning location/b.c new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/meson/test cases/unit/22 warning location/b.c diff --git a/meson/test cases/unit/22 warning location/conf.in b/meson/test cases/unit/22 warning location/conf.in new file mode 100644 index 000000000..a2903ed38 --- /dev/null +++ b/meson/test cases/unit/22 warning location/conf.in @@ -0,0 +1 @@ +@MISSING@ diff --git a/meson/test cases/unit/22 warning location/main.c b/meson/test cases/unit/22 warning location/main.c new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/meson/test cases/unit/22 warning location/main.c diff --git a/meson/test cases/unit/22 warning location/meson.build b/meson/test cases/unit/22 warning location/meson.build new file mode 100644 index 000000000..52a93d18c --- /dev/null +++ b/meson/test cases/unit/22 warning location/meson.build @@ -0,0 +1,11 @@ +project('warning location', 'c', invalid: 'cheese') +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/meson/test cases/unit/22 warning location/sub/c.c b/meson/test cases/unit/22 warning location/sub/c.c new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/meson/test cases/unit/22 warning location/sub/c.c diff --git a/meson/test cases/unit/22 warning location/sub/d.c b/meson/test cases/unit/22 warning location/sub/d.c new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/meson/test cases/unit/22 warning location/sub/d.c diff --git a/meson/test cases/unit/22 warning location/sub/meson.build b/meson/test cases/unit/22 warning location/sub/meson.build new file mode 100644 index 000000000..27f67783c --- /dev/null +++ b/meson/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/meson/test cases/unit/22 warning location/sub/sub.c b/meson/test cases/unit/22 warning location/sub/sub.c new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/meson/test cases/unit/22 warning location/sub/sub.c diff --git a/meson/test cases/unit/23 unfound pkgconfig/meson.build b/meson/test cases/unit/23 unfound pkgconfig/meson.build new file mode 100644 index 000000000..1285c0a10 --- /dev/null +++ b/meson/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/meson/test cases/unit/23 unfound pkgconfig/some.c b/meson/test cases/unit/23 unfound pkgconfig/some.c new file mode 100644 index 000000000..fb765fb1f --- /dev/null +++ b/meson/test cases/unit/23 unfound pkgconfig/some.c @@ -0,0 +1,3 @@ +int some() { + return 6; +} diff --git a/meson/test cases/unit/24 compiler run_command/meson.build b/meson/test cases/unit/24 compiler run_command/meson.build new file mode 100644 index 000000000..6d9e0b969 --- /dev/null +++ b/meson/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') +if result.stdout() == '' and result.stderr() == '' + error('No output in stdout and stderr. Did the compiler run at all?') +endif diff --git a/meson/test cases/unit/25 non-permitted kwargs/meson.build b/meson/test cases/unit/25 non-permitted kwargs/meson.build new file mode 100644 index 000000000..287acfd87 --- /dev/null +++ b/meson/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/meson/test cases/unit/26 install umask/datafile.cat b/meson/test cases/unit/26 install umask/datafile.cat new file mode 100644 index 000000000..53d81fc2a --- /dev/null +++ b/meson/test cases/unit/26 install umask/datafile.cat @@ -0,0 +1 @@ +Installed cat is installed. diff --git a/meson/test cases/unit/26 install umask/meson.build b/meson/test cases/unit/26 install umask/meson.build new file mode 100644 index 000000000..225f71c67 --- /dev/null +++ b/meson/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/meson/test cases/unit/26 install umask/myinstall.py b/meson/test cases/unit/26 install umask/myinstall.py new file mode 100644 index 000000000..db6a51c2b --- /dev/null +++ b/meson/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/meson/test cases/unit/26 install umask/prog.1 b/meson/test cases/unit/26 install umask/prog.1 new file mode 100644 index 000000000..08ef7da62 --- /dev/null +++ b/meson/test cases/unit/26 install umask/prog.1 @@ -0,0 +1 @@ +Man up, you. diff --git a/meson/test cases/unit/26 install umask/prog.c b/meson/test cases/unit/26 install umask/prog.c new file mode 100644 index 000000000..0f0061d2a --- /dev/null +++ b/meson/test cases/unit/26 install umask/prog.c @@ -0,0 +1,3 @@ +int main(int argc, char **arv) { + return 0; +} diff --git a/meson/test cases/unit/26 install umask/sample.h b/meson/test cases/unit/26 install umask/sample.h new file mode 100644 index 000000000..dc030dac1 --- /dev/null +++ b/meson/test cases/unit/26 install umask/sample.h @@ -0,0 +1,6 @@ +#ifndef SAMPLE_H +#define SAMPLE_H + +int wackiness(); + +#endif diff --git a/meson/test cases/unit/26 install umask/subdir/datafile.dog b/meson/test cases/unit/26 install umask/subdir/datafile.dog new file mode 100644 index 000000000..7a5bcb765 --- /dev/null +++ b/meson/test cases/unit/26 install umask/subdir/datafile.dog @@ -0,0 +1 @@ +Installed dog is installed. diff --git a/meson/test cases/unit/26 install umask/subdir/sayhello b/meson/test cases/unit/26 install umask/subdir/sayhello new file mode 100755 index 000000000..1e1c90a85 --- /dev/null +++ b/meson/test cases/unit/26 install umask/subdir/sayhello @@ -0,0 +1,2 @@ +#!/bin/sh +echo 'Hello, World!' diff --git a/meson/test cases/unit/27 pkgconfig usage/dependee/meson.build b/meson/test cases/unit/27 pkgconfig usage/dependee/meson.build new file mode 100644 index 000000000..beb446c18 --- /dev/null +++ b/meson/test cases/unit/27 pkgconfig usage/dependee/meson.build @@ -0,0 +1,7 @@ +project('pkgconfig user', 'c') + +pkgdep = dependency('libpkgdep') + +executable('pkguser', 'pkguser.c', + dependencies : pkgdep) + diff --git a/meson/test cases/unit/27 pkgconfig usage/dependee/pkguser.c b/meson/test cases/unit/27 pkgconfig usage/dependee/pkguser.c new file mode 100644 index 000000000..2bff316f1 --- /dev/null +++ b/meson/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/meson/test cases/unit/27 pkgconfig usage/dependency/meson.build b/meson/test cases/unit/27 pkgconfig usage/dependency/meson.build new file mode 100644 index 000000000..89fae8e00 --- /dev/null +++ b/meson/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/meson/test cases/unit/27 pkgconfig usage/dependency/pkgdep.c b/meson/test cases/unit/27 pkgconfig usage/dependency/pkgdep.c new file mode 100644 index 000000000..bd5c3f4d3 --- /dev/null +++ b/meson/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/meson/test cases/unit/27 pkgconfig usage/dependency/pkgdep.h b/meson/test cases/unit/27 pkgconfig usage/dependency/pkgdep.h new file mode 100644 index 000000000..16d622eb1 --- /dev/null +++ b/meson/test cases/unit/27 pkgconfig usage/dependency/pkgdep.h @@ -0,0 +1,3 @@ +#pragma once + +int pkgdep(); diff --git a/meson/test cases/unit/27 pkgconfig usage/dependency/privatelib.c b/meson/test cases/unit/27 pkgconfig usage/dependency/privatelib.c new file mode 100644 index 000000000..71d2179c3 --- /dev/null +++ b/meson/test cases/unit/27 pkgconfig usage/dependency/privatelib.c @@ -0,0 +1,3 @@ +int internal_thingy() { + return 99; +} diff --git a/meson/test cases/unit/28 ndebug if-release/main.c b/meson/test cases/unit/28 ndebug if-release/main.c new file mode 100644 index 000000000..70b3d044a --- /dev/null +++ b/meson/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/meson/test cases/unit/28 ndebug if-release/meson.build b/meson/test cases/unit/28 ndebug if-release/meson.build new file mode 100644 index 000000000..4af2406d2 --- /dev/null +++ b/meson/test cases/unit/28 ndebug if-release/meson.build @@ -0,0 +1,3 @@ +project('ndebug enabled', 'c') + +executable('main', 'main.c') diff --git a/meson/test cases/unit/29 guessed linker dependencies/exe/app.c b/meson/test cases/unit/29 guessed linker dependencies/exe/app.c new file mode 100644 index 000000000..29c8d9c9a --- /dev/null +++ b/meson/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/meson/test cases/unit/29 guessed linker dependencies/exe/meson.build b/meson/test cases/unit/29 guessed linker dependencies/exe/meson.build new file mode 100644 index 000000000..8bb1bd7f6 --- /dev/null +++ b/meson/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/meson/test cases/unit/29 guessed linker dependencies/lib/lib.c b/meson/test cases/unit/29 guessed linker dependencies/lib/lib.c new file mode 100644 index 000000000..1a8f94ddb --- /dev/null +++ b/meson/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/meson/test cases/unit/29 guessed linker dependencies/lib/meson.build b/meson/test cases/unit/29 guessed linker dependencies/lib/meson.build new file mode 100644 index 000000000..36df112b2 --- /dev/null +++ b/meson/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/meson/test cases/unit/29 guessed linker dependencies/lib/meson_options.txt b/meson/test cases/unit/29 guessed linker dependencies/lib/meson_options.txt new file mode 100644 index 000000000..2123e457a --- /dev/null +++ b/meson/test cases/unit/29 guessed linker dependencies/lib/meson_options.txt @@ -0,0 +1 @@ +option('more_exports', type : 'boolean', value : false) diff --git a/meson/test cases/unit/3 subproject defaults/meson.build b/meson/test cases/unit/3 subproject defaults/meson.build new file mode 100644 index 000000000..3bf05d036 --- /dev/null +++ b/meson/test cases/unit/3 subproject defaults/meson.build @@ -0,0 +1,11 @@ +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/meson/test cases/unit/3 subproject defaults/meson_options.txt b/meson/test cases/unit/3 subproject defaults/meson_options.txt new file mode 100644 index 000000000..b63f512e2 --- /dev/null +++ b/meson/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/meson/test cases/unit/3 subproject defaults/subprojects/foob/meson.build b/meson/test cases/unit/3 subproject defaults/subprojects/foob/meson.build new file mode 100644 index 000000000..69f01d1ba --- /dev/null +++ b/meson/test cases/unit/3 subproject defaults/subprojects/foob/meson.build @@ -0,0 +1,12 @@ +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/meson/test cases/unit/3 subproject defaults/subprojects/foob/meson_options.txt b/meson/test cases/unit/3 subproject defaults/subprojects/foob/meson_options.txt new file mode 100644 index 000000000..a9a615e5e --- /dev/null +++ b/meson/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/meson/test cases/unit/30 shared_mod linking/libfile.c b/meson/test cases/unit/30 shared_mod linking/libfile.c new file mode 100644 index 000000000..44f7667d4 --- /dev/null +++ b/meson/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/meson/test cases/unit/30 shared_mod linking/main.c b/meson/test cases/unit/30 shared_mod linking/main.c new file mode 100644 index 000000000..12f9c984b --- /dev/null +++ b/meson/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/meson/test cases/unit/30 shared_mod linking/meson.build b/meson/test cases/unit/30 shared_mod linking/meson.build new file mode 100644 index 000000000..994a5d390 --- /dev/null +++ b/meson/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/meson/test cases/unit/31 forcefallback/meson.build b/meson/test cases/unit/31 forcefallback/meson.build new file mode 100644 index 000000000..8d84a6035 --- /dev/null +++ b/meson/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/meson/test cases/unit/31 forcefallback/subprojects/notzlib/meson.build b/meson/test cases/unit/31 forcefallback/subprojects/notzlib/meson.build new file mode 100644 index 000000000..254a1367b --- /dev/null +++ b/meson/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/meson/test cases/unit/31 forcefallback/subprojects/notzlib/notzlib.c b/meson/test cases/unit/31 forcefallback/subprojects/notzlib/notzlib.c new file mode 100644 index 000000000..c3b6bf9c2 --- /dev/null +++ b/meson/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/meson/test cases/unit/31 forcefallback/subprojects/notzlib/notzlib.h b/meson/test cases/unit/31 forcefallback/subprojects/notzlib/notzlib.h new file mode 100644 index 000000000..695921d75 --- /dev/null +++ b/meson/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/meson/test cases/unit/31 forcefallback/test_not_zlib.c b/meson/test cases/unit/31 forcefallback/test_not_zlib.c new file mode 100644 index 000000000..36256af32 --- /dev/null +++ b/meson/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/meson/test cases/unit/32 pkgconfig use libraries/app/app.c b/meson/test cases/unit/32 pkgconfig use libraries/app/app.c new file mode 100644 index 000000000..7b8d8fa13 --- /dev/null +++ b/meson/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/meson/test cases/unit/32 pkgconfig use libraries/app/meson.build b/meson/test cases/unit/32 pkgconfig use libraries/app/meson.build new file mode 100644 index 000000000..3d85a32f4 --- /dev/null +++ b/meson/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/meson/test cases/unit/32 pkgconfig use libraries/lib/liba.c b/meson/test cases/unit/32 pkgconfig use libraries/lib/liba.c new file mode 100644 index 000000000..e98906b9c --- /dev/null +++ b/meson/test cases/unit/32 pkgconfig use libraries/lib/liba.c @@ -0,0 +1,2 @@ +void liba_func() { +} diff --git a/meson/test cases/unit/32 pkgconfig use libraries/lib/libb.c b/meson/test cases/unit/32 pkgconfig use libraries/lib/libb.c new file mode 100644 index 000000000..3160e5f52 --- /dev/null +++ b/meson/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/meson/test cases/unit/32 pkgconfig use libraries/lib/meson.build b/meson/test cases/unit/32 pkgconfig use libraries/lib/meson.build new file mode 100644 index 000000000..748adf47a --- /dev/null +++ b/meson/test cases/unit/32 pkgconfig use libraries/lib/meson.build @@ -0,0 +1,16 @@ +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/meson/test cases/unit/33 cross file overrides always args/meson.build b/meson/test cases/unit/33 cross file overrides always args/meson.build new file mode 100644 index 000000000..ef6556e54 --- /dev/null +++ b/meson/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/meson/test cases/unit/33 cross file overrides always args/test.c b/meson/test cases/unit/33 cross file overrides always args/test.c new file mode 100644 index 000000000..315f92e96 --- /dev/null +++ b/meson/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/meson/test cases/unit/33 cross file overrides always args/ubuntu-armhf-overrides.txt b/meson/test cases/unit/33 cross file overrides always args/ubuntu-armhf-overrides.txt new file mode 100644 index 000000000..a00a7d136 --- /dev/null +++ b/meson/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/meson/test cases/unit/34 command line/meson.build b/meson/test cases/unit/34 command line/meson.build new file mode 100644 index 000000000..6207ca5e2 --- /dev/null +++ b/meson/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/meson/test cases/unit/34 command line/meson_options.txt b/meson/test cases/unit/34 command line/meson_options.txt new file mode 100644 index 000000000..244f57067 --- /dev/null +++ b/meson/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/meson/test cases/unit/34 command line/subprojects/subp/meson.build b/meson/test cases/unit/34 command line/subprojects/subp/meson.build new file mode 100644 index 000000000..cf79fa42a --- /dev/null +++ b/meson/test cases/unit/34 command line/subprojects/subp/meson.build @@ -0,0 +1,3 @@ +project('subp', + default_options : ['subp_opt=default2'] +) diff --git a/meson/test cases/unit/34 command line/subprojects/subp/meson_options.txt b/meson/test cases/unit/34 command line/subprojects/subp/meson_options.txt new file mode 100644 index 000000000..8c50615dd --- /dev/null +++ b/meson/test cases/unit/34 command line/subprojects/subp/meson_options.txt @@ -0,0 +1 @@ +option('subp_opt', type : 'string', value : 'default1') diff --git a/meson/test cases/unit/35 dist script/meson.build b/meson/test cases/unit/35 dist script/meson.build new file mode 100644 index 000000000..8db42358a --- /dev/null +++ b/meson/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/meson/test cases/unit/35 dist script/prog.c b/meson/test cases/unit/35 dist script/prog.c new file mode 100644 index 000000000..1bb6b053e --- /dev/null +++ b/meson/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/meson/test cases/unit/35 dist script/replacer.py b/meson/test cases/unit/35 dist script/replacer.py new file mode 100755 index 000000000..96ccdcc8b --- /dev/null +++ b/meson/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/meson/test cases/unit/35 dist script/subprojects/sub/dist-script.py b/meson/test cases/unit/35 dist script/subprojects/sub/dist-script.py new file mode 100644 index 000000000..1274f291b --- /dev/null +++ b/meson/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/meson/test cases/unit/35 dist script/subprojects/sub/meson.build b/meson/test cases/unit/35 dist script/subprojects/sub/meson.build new file mode 100644 index 000000000..612861310 --- /dev/null +++ b/meson/test cases/unit/35 dist script/subprojects/sub/meson.build @@ -0,0 +1,11 @@ +project('sub') + +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/meson/test cases/unit/35 dist script/subprojects/sub/meson_options.txt b/meson/test cases/unit/35 dist script/subprojects/sub/meson_options.txt new file mode 100644 index 000000000..8f52e0f87 --- /dev/null +++ b/meson/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/meson/test cases/unit/35 dist script/subprojects/sub/prog.c b/meson/test cases/unit/35 dist script/subprojects/sub/prog.c new file mode 100644 index 000000000..049b36ab2 --- /dev/null +++ b/meson/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/meson/test cases/unit/36 exe_wrapper behaviour/broken-cross.txt b/meson/test cases/unit/36 exe_wrapper behaviour/broken-cross.txt new file mode 100644 index 000000000..a5a39318d --- /dev/null +++ b/meson/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/meson/test cases/unit/36 exe_wrapper behaviour/meson.build b/meson/test cases/unit/36 exe_wrapper behaviour/meson.build new file mode 100644 index 000000000..d0817babe --- /dev/null +++ b/meson/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/meson/test cases/unit/36 exe_wrapper behaviour/meson_options.txt b/meson/test cases/unit/36 exe_wrapper behaviour/meson_options.txt new file mode 100644 index 000000000..e5645a033 --- /dev/null +++ b/meson/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/meson/test cases/unit/36 exe_wrapper behaviour/prog.c b/meson/test cases/unit/36 exe_wrapper behaviour/prog.c new file mode 100644 index 000000000..3213780df --- /dev/null +++ b/meson/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/meson/test cases/unit/37 mixed command line args/meson.build b/meson/test cases/unit/37 mixed command line args/meson.build new file mode 100644 index 000000000..af5cdc790 --- /dev/null +++ b/meson/test cases/unit/37 mixed command line args/meson.build @@ -0,0 +1 @@ +project('Mixed command line arguments') diff --git a/meson/test cases/unit/37 mixed command line args/meson_options.txt b/meson/test cases/unit/37 mixed command line args/meson_options.txt new file mode 100644 index 000000000..5a4bc22bf --- /dev/null +++ b/meson/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/meson/test cases/unit/38 pkgconfig format/meson.build b/meson/test cases/unit/38 pkgconfig format/meson.build new file mode 100644 index 000000000..ea00f5df4 --- /dev/null +++ b/meson/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/meson/test cases/unit/38 pkgconfig format/somelib.c b/meson/test cases/unit/38 pkgconfig format/somelib.c new file mode 100644 index 000000000..0558024b3 --- /dev/null +++ b/meson/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/meson/test cases/unit/38 pkgconfig format/someret.c b/meson/test cases/unit/38 pkgconfig format/someret.c new file mode 100644 index 000000000..69f429928 --- /dev/null +++ b/meson/test cases/unit/38 pkgconfig format/someret.c @@ -0,0 +1,3 @@ +int get_returnvalue (void) { + return 0; +} diff --git a/meson/test cases/unit/39 python extmodule/blaster.py b/meson/test cases/unit/39 python extmodule/blaster.py new file mode 100755 index 000000000..163b6d426 --- /dev/null +++ b/meson/test cases/unit/39 python extmodule/blaster.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +import sys +import tachyon + +result = tachyon.phaserize('shoot') + +if not isinstance(result, int): + print('Returned result not an integer.') + sys.exit(1) + +if result != 1: + print('Returned result {} is not 1.'.format(result)) + sys.exit(1) diff --git a/meson/test cases/unit/39 python extmodule/ext/meson.build b/meson/test cases/unit/39 python extmodule/ext/meson.build new file mode 100644 index 000000000..b13bb326f --- /dev/null +++ b/meson/test cases/unit/39 python extmodule/ext/meson.build @@ -0,0 +1,6 @@ +pylib = py.extension_module('tachyon', + 'tachyon_module.c', + dependencies : py_dep, +) + +pypathdir = meson.current_build_dir() diff --git a/meson/test cases/unit/39 python extmodule/ext/tachyon_module.c b/meson/test cases/unit/39 python extmodule/ext/tachyon_module.c new file mode 100644 index 000000000..68eda5380 --- /dev/null +++ b/meson/test cases/unit/39 python extmodule/ext/tachyon_module.c @@ -0,0 +1,59 @@ +/* + Copyright 2018 The Meson development team + + 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. +*/ + +/* A very simple Python extension module. */ + +#include <Python.h> +#include <string.h> + +static PyObject* phaserize(PyObject *self, PyObject *args) { + const char *message; + int result; + + if(!PyArg_ParseTuple(args, "s", &message)) + return NULL; + + result = strcmp(message, "shoot") ? 0 : 1; +#if PY_VERSION_HEX < 0x03000000 + return PyInt_FromLong(result); +#else + return PyLong_FromLong(result); +#endif +} + +static PyMethodDef TachyonMethods[] = { + {"phaserize", phaserize, METH_VARARGS, + "Shoot tachyon cannons."}, + {NULL, NULL, 0, NULL} +}; + +#if PY_VERSION_HEX < 0x03000000 +PyMODINIT_FUNC inittachyon(void) { + Py_InitModule("tachyon", TachyonMethods); +} +#else +static struct PyModuleDef tachyonmodule = { + PyModuleDef_HEAD_INIT, + "tachyon", + NULL, + -1, + TachyonMethods +}; + +PyMODINIT_FUNC PyInit_tachyon(void) { + return PyModule_Create(&tachyonmodule); +} +#endif diff --git a/meson/test cases/unit/39 python extmodule/meson.build b/meson/test cases/unit/39 python extmodule/meson.build new file mode 100644 index 000000000..5b443944b --- /dev/null +++ b/meson/test cases/unit/39 python extmodule/meson.build @@ -0,0 +1,26 @@ +project('Python extension module', 'c', + default_options : ['buildtype=release']) + +py_mod = import('python') + +py = py_mod.find_installation(get_option('python'), required : false) + +if py.found() + py_dep = py.dependency(required : false) + + if py_dep.found() + subdir('ext') + + test('extmod', + py, + args : files('blaster.py'), + env : ['PYTHONPATH=' + pypathdir]) + else + error('MESON_SKIP_TEST: Python libraries not found, skipping test.') + endif +else + error('MESON_SKIP_TEST: Python not found, skipping test.') +endif + +py = py_mod.find_installation(get_option('python'), required : get_option('disabled_opt')) +assert(not py.found(), 'find_installation not working with disabled feature') diff --git a/meson/test cases/unit/39 python extmodule/meson_options.txt b/meson/test cases/unit/39 python extmodule/meson_options.txt new file mode 100644 index 000000000..c85110d03 --- /dev/null +++ b/meson/test cases/unit/39 python extmodule/meson_options.txt @@ -0,0 +1,4 @@ +option('python', type: 'string', + description: 'Name of or path to the python executable' +) +option('disabled_opt', type: 'feature', value: 'disabled') diff --git a/meson/test cases/unit/4 suite selection/failing_test.c b/meson/test cases/unit/4 suite selection/failing_test.c new file mode 100644 index 000000000..393344d05 --- /dev/null +++ b/meson/test cases/unit/4 suite selection/failing_test.c @@ -0,0 +1 @@ +int main(void) { return -1 ; } diff --git a/meson/test cases/unit/4 suite selection/meson.build b/meson/test cases/unit/4 suite selection/meson.build new file mode 100644 index 000000000..ea6db923c --- /dev/null +++ b/meson/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/meson/test cases/unit/4 suite selection/subprojects/subprjfail/failing_test.c b/meson/test cases/unit/4 suite selection/subprojects/subprjfail/failing_test.c new file mode 100644 index 000000000..393344d05 --- /dev/null +++ b/meson/test cases/unit/4 suite selection/subprojects/subprjfail/failing_test.c @@ -0,0 +1 @@ +int main(void) { return -1 ; } diff --git a/meson/test cases/unit/4 suite selection/subprojects/subprjfail/meson.build b/meson/test cases/unit/4 suite selection/subprojects/subprjfail/meson.build new file mode 100644 index 000000000..e6270a8cf --- /dev/null +++ b/meson/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/meson/test cases/unit/4 suite selection/subprojects/subprjmix/failing_test.c b/meson/test cases/unit/4 suite selection/subprojects/subprjmix/failing_test.c new file mode 100644 index 000000000..393344d05 --- /dev/null +++ b/meson/test cases/unit/4 suite selection/subprojects/subprjmix/failing_test.c @@ -0,0 +1 @@ +int main(void) { return -1 ; } diff --git a/meson/test cases/unit/4 suite selection/subprojects/subprjmix/meson.build b/meson/test cases/unit/4 suite selection/subprojects/subprjmix/meson.build new file mode 100644 index 000000000..1d0eeff2e --- /dev/null +++ b/meson/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/meson/test cases/unit/4 suite selection/subprojects/subprjmix/successful_test.c b/meson/test cases/unit/4 suite selection/subprojects/subprjmix/successful_test.c new file mode 100644 index 000000000..8842fc122 --- /dev/null +++ b/meson/test cases/unit/4 suite selection/subprojects/subprjmix/successful_test.c @@ -0,0 +1 @@ +int main(void) { return 0 ; } diff --git a/meson/test cases/unit/4 suite selection/subprojects/subprjsucc/meson.build b/meson/test cases/unit/4 suite selection/subprojects/subprjsucc/meson.build new file mode 100644 index 000000000..b5ffaa461 --- /dev/null +++ b/meson/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/meson/test cases/unit/4 suite selection/subprojects/subprjsucc/successful_test.c b/meson/test cases/unit/4 suite selection/subprojects/subprjsucc/successful_test.c new file mode 100644 index 000000000..8842fc122 --- /dev/null +++ b/meson/test cases/unit/4 suite selection/subprojects/subprjsucc/successful_test.c @@ -0,0 +1 @@ +int main(void) { return 0 ; } diff --git a/meson/test cases/unit/4 suite selection/successful_test.c b/meson/test cases/unit/4 suite selection/successful_test.c new file mode 100644 index 000000000..8842fc122 --- /dev/null +++ b/meson/test cases/unit/4 suite selection/successful_test.c @@ -0,0 +1 @@ +int main(void) { return 0 ; } diff --git a/meson/test cases/unit/40 external, internal library rpath/built library/bar.c b/meson/test cases/unit/40 external, internal library rpath/built library/bar.c new file mode 100644 index 000000000..4f5662ebd --- /dev/null +++ b/meson/test cases/unit/40 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/meson/test cases/unit/40 external, internal library rpath/built library/meson.build b/meson/test cases/unit/40 external, internal library rpath/built library/meson.build new file mode 100644 index 000000000..07fe7bb2b --- /dev/null +++ b/meson/test cases/unit/40 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/meson/test cases/unit/40 external, internal library rpath/built library/meson_options.txt b/meson/test cases/unit/40 external, internal library rpath/built library/meson_options.txt new file mode 100644 index 000000000..aa1d2ec9b --- /dev/null +++ b/meson/test cases/unit/40 external, internal library rpath/built library/meson_options.txt @@ -0,0 +1 @@ +option('foo_system_path', type: 'string', value: '') diff --git a/meson/test cases/unit/40 external, internal library rpath/built library/prog.c b/meson/test cases/unit/40 external, internal library rpath/built library/prog.c new file mode 100644 index 000000000..e3d4cf63f --- /dev/null +++ b/meson/test cases/unit/40 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/meson/test cases/unit/40 external, internal library rpath/external library/bar.c b/meson/test cases/unit/40 external, internal library rpath/external library/bar.c new file mode 100644 index 000000000..c6f42d651 --- /dev/null +++ b/meson/test cases/unit/40 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/meson/test cases/unit/40 external, internal library rpath/external library/faa.c b/meson/test cases/unit/40 external, internal library rpath/external library/faa.c new file mode 100644 index 000000000..473357516 --- /dev/null +++ b/meson/test cases/unit/40 external, internal library rpath/external library/faa.c @@ -0,0 +1,4 @@ +int faa_system_value (void) +{ + return 1969; +} diff --git a/meson/test cases/unit/40 external, internal library rpath/external library/foo.c b/meson/test cases/unit/40 external, internal library rpath/external library/foo.c new file mode 100644 index 000000000..a34e4a885 --- /dev/null +++ b/meson/test cases/unit/40 external, internal library rpath/external library/foo.c @@ -0,0 +1,4 @@ +int foo_system_value (void) +{ + return 42; +} diff --git a/meson/test cases/unit/40 external, internal library rpath/external library/meson.build b/meson/test cases/unit/40 external, internal library rpath/external library/meson.build new file mode 100644 index 000000000..06ffa0f72 --- /dev/null +++ b/meson/test cases/unit/40 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/meson/test cases/unit/41 featurenew subprojects/meson.build b/meson/test cases/unit/41 featurenew subprojects/meson.build new file mode 100644 index 000000000..d136bed1c --- /dev/null +++ b/meson/test cases/unit/41 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/meson/test cases/unit/41 featurenew subprojects/subprojects/bar/meson.build b/meson/test cases/unit/41 featurenew subprojects/subprojects/bar/meson.build new file mode 100644 index 000000000..712a125f7 --- /dev/null +++ b/meson/test cases/unit/41 featurenew subprojects/subprojects/bar/meson.build @@ -0,0 +1,3 @@ +project('foo subproject', meson_version: '>=0.46') + +import('python') diff --git a/meson/test cases/unit/41 featurenew subprojects/subprojects/baz/meson.build b/meson/test cases/unit/41 featurenew subprojects/subprojects/baz/meson.build new file mode 100644 index 000000000..811e7aa4b --- /dev/null +++ b/meson/test cases/unit/41 featurenew subprojects/subprojects/baz/meson.build @@ -0,0 +1,3 @@ +project('baz subproject', meson_version: '!=0.40') + +disabler() diff --git a/meson/test cases/unit/41 featurenew subprojects/subprojects/foo/meson.build b/meson/test cases/unit/41 featurenew subprojects/subprojects/foo/meson.build new file mode 100644 index 000000000..0ef4472bd --- /dev/null +++ b/meson/test cases/unit/41 featurenew subprojects/subprojects/foo/meson.build @@ -0,0 +1,3 @@ +project('foo subproject', meson_version: '>=0.40') + +disabler() diff --git a/meson/test cases/unit/42 rpath order/meson.build b/meson/test cases/unit/42 rpath order/meson.build new file mode 100644 index 000000000..a722894e5 --- /dev/null +++ b/meson/test cases/unit/42 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/meson/test cases/unit/42 rpath order/myexe.c b/meson/test cases/unit/42 rpath order/myexe.c new file mode 100644 index 000000000..03b2213bb --- /dev/null +++ b/meson/test cases/unit/42 rpath order/myexe.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/meson/test cases/unit/42 rpath order/subprojects/sub1/lib.c b/meson/test cases/unit/42 rpath order/subprojects/sub1/lib.c new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/meson/test cases/unit/42 rpath order/subprojects/sub1/lib.c diff --git a/meson/test cases/unit/42 rpath order/subprojects/sub1/meson.build b/meson/test cases/unit/42 rpath order/subprojects/sub1/meson.build new file mode 100644 index 000000000..4dd5d0843 --- /dev/null +++ b/meson/test cases/unit/42 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/meson/test cases/unit/42 rpath order/subprojects/sub2/lib.c b/meson/test cases/unit/42 rpath order/subprojects/sub2/lib.c new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/meson/test cases/unit/42 rpath order/subprojects/sub2/lib.c diff --git a/meson/test cases/unit/42 rpath order/subprojects/sub2/meson.build b/meson/test cases/unit/42 rpath order/subprojects/sub2/meson.build new file mode 100644 index 000000000..bc3510db3 --- /dev/null +++ b/meson/test cases/unit/42 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/meson/test cases/unit/43 dep order/lib1.c b/meson/test cases/unit/43 dep order/lib1.c new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/meson/test cases/unit/43 dep order/lib1.c diff --git a/meson/test cases/unit/43 dep order/lib2.c b/meson/test cases/unit/43 dep order/lib2.c new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/meson/test cases/unit/43 dep order/lib2.c diff --git a/meson/test cases/unit/43 dep order/meson.build b/meson/test cases/unit/43 dep order/meson.build new file mode 100644 index 000000000..17cf9dfba --- /dev/null +++ b/meson/test cases/unit/43 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/meson/test cases/unit/43 dep order/myexe.c b/meson/test cases/unit/43 dep order/myexe.c new file mode 100644 index 000000000..8f4c045ee --- /dev/null +++ b/meson/test cases/unit/43 dep order/myexe.c @@ -0,0 +1,3 @@ +int main(int ac, char** av) { + return 0; +} diff --git a/meson/test cases/unit/44 promote wrap/meson.build b/meson/test cases/unit/44 promote wrap/meson.build new file mode 100644 index 000000000..066cf36cf --- /dev/null +++ b/meson/test cases/unit/44 promote wrap/meson.build @@ -0,0 +1,5 @@ +project('promotion test', 'c') + +subproject('s1') +subproject('s2') + diff --git a/meson/test cases/unit/44 promote wrap/subprojects/s1/meson.build b/meson/test cases/unit/44 promote wrap/subprojects/s1/meson.build new file mode 100644 index 000000000..3d1f5bc35 --- /dev/null +++ b/meson/test cases/unit/44 promote wrap/subprojects/s1/meson.build @@ -0,0 +1,2 @@ +project('s1', 'c') + diff --git a/meson/test cases/unit/44 promote wrap/subprojects/s1/subprojects/ambiguous/meson.build b/meson/test cases/unit/44 promote wrap/subprojects/s1/subprojects/ambiguous/meson.build new file mode 100644 index 000000000..296adff4c --- /dev/null +++ b/meson/test cases/unit/44 promote wrap/subprojects/s1/subprojects/ambiguous/meson.build @@ -0,0 +1,2 @@ +project('ambiguous', 'c') + diff --git a/meson/test cases/unit/44 promote wrap/subprojects/s2/meson.build b/meson/test cases/unit/44 promote wrap/subprojects/s2/meson.build new file mode 100644 index 000000000..b5db63429 --- /dev/null +++ b/meson/test cases/unit/44 promote wrap/subprojects/s2/meson.build @@ -0,0 +1,2 @@ +project('s2', 'c') + diff --git a/meson/test cases/unit/44 promote wrap/subprojects/s2/subprojects/ambiguous.wrap b/meson/test cases/unit/44 promote wrap/subprojects/s2/subprojects/ambiguous.wrap new file mode 100644 index 000000000..09ba4e87f --- /dev/null +++ b/meson/test cases/unit/44 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/meson/test cases/unit/45 vscpp17/main.cpp b/meson/test cases/unit/45 vscpp17/main.cpp new file mode 100644 index 000000000..3d07d4cb1 --- /dev/null +++ b/meson/test cases/unit/45 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/meson/test cases/unit/45 vscpp17/meson.build b/meson/test cases/unit/45 vscpp17/meson.build new file mode 100644 index 000000000..afe740bbc --- /dev/null +++ b/meson/test cases/unit/45 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/meson/test cases/unit/46 native dep pkgconfig var/cross_pkgconfig.py b/meson/test cases/unit/46 native dep pkgconfig var/cross_pkgconfig.py new file mode 100755 index 000000000..f0d89ee3e --- /dev/null +++ b/meson/test cases/unit/46 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/meson/test cases/unit/46 native dep pkgconfig var/cross_pkgconfig/dep_tester.pc b/meson/test cases/unit/46 native dep pkgconfig var/cross_pkgconfig/dep_tester.pc new file mode 100644 index 000000000..67d7afa62 --- /dev/null +++ b/meson/test cases/unit/46 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/meson/test cases/unit/46 native dep pkgconfig var/meson.build b/meson/test cases/unit/46 native dep pkgconfig var/meson.build new file mode 100644 index 000000000..d95dbcdbe --- /dev/null +++ b/meson/test cases/unit/46 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/meson/test cases/unit/46 native dep pkgconfig var/meson_options.txt b/meson/test cases/unit/46 native dep pkgconfig var/meson_options.txt new file mode 100644 index 000000000..37006ddfd --- /dev/null +++ b/meson/test cases/unit/46 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/meson/test cases/unit/46 native dep pkgconfig var/native_pkgconfig/dep_tester.pc b/meson/test cases/unit/46 native dep pkgconfig var/native_pkgconfig/dep_tester.pc new file mode 100644 index 000000000..affaa97b5 --- /dev/null +++ b/meson/test cases/unit/46 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/meson/test cases/unit/47 native file binary/meson.build b/meson/test cases/unit/47 native file binary/meson.build new file mode 100644 index 000000000..c9b6e5de4 --- /dev/null +++ b/meson/test cases/unit/47 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']) + 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']) + 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']) + assert(result.stdout().strip().endswith('12345'), 'Didn\'t load python from config file') +endif diff --git a/meson/test cases/unit/47 native file binary/meson_options.txt b/meson/test cases/unit/47 native file binary/meson_options.txt new file mode 100644 index 000000000..651da0ebe --- /dev/null +++ b/meson/test cases/unit/47 native file binary/meson_options.txt @@ -0,0 +1,5 @@ +option( + 'case', + type : 'combo', + choices : ['find_program', 'config_dep', 'python3', 'python'] +) diff --git a/meson/test cases/unit/48 reconfigure/main.c b/meson/test cases/unit/48 reconfigure/main.c new file mode 100644 index 000000000..25927f5a1 --- /dev/null +++ b/meson/test cases/unit/48 reconfigure/main.c @@ -0,0 +1,4 @@ +int main(int argc, char *argv[]) +{ + return 0; +} diff --git a/meson/test cases/unit/48 reconfigure/meson.build b/meson/test cases/unit/48 reconfigure/meson.build new file mode 100644 index 000000000..4f35458a8 --- /dev/null +++ b/meson/test cases/unit/48 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/meson/test cases/unit/48 reconfigure/meson_options.txt b/meson/test cases/unit/48 reconfigure/meson_options.txt new file mode 100644 index 000000000..728f7b782 --- /dev/null +++ b/meson/test cases/unit/48 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/meson/test cases/unit/48 reconfigure/subprojects/sub1/meson.build b/meson/test cases/unit/48 reconfigure/subprojects/sub1/meson.build new file mode 100644 index 000000000..4f3d2fc4e --- /dev/null +++ b/meson/test cases/unit/48 reconfigure/subprojects/sub1/meson.build @@ -0,0 +1,3 @@ +project('sub1') + +message('sub1:werror', get_option('werror')) diff --git a/meson/test cases/unit/49 testsetup default/envcheck.py b/meson/test cases/unit/49 testsetup default/envcheck.py new file mode 100644 index 000000000..6ba3093ff --- /dev/null +++ b/meson/test cases/unit/49 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/meson/test cases/unit/49 testsetup default/meson.build b/meson/test cases/unit/49 testsetup default/meson.build new file mode 100644 index 000000000..bdd35b807 --- /dev/null +++ b/meson/test cases/unit/49 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/meson/test cases/unit/5 compiler detection/compiler wrapper.py b/meson/test cases/unit/5 compiler detection/compiler wrapper.py new file mode 100644 index 000000000..fedd3434d --- /dev/null +++ b/meson/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/meson/test cases/unit/5 compiler detection/meson.build b/meson/test cases/unit/5 compiler detection/meson.build new file mode 100644 index 000000000..8b47bd47b --- /dev/null +++ b/meson/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/meson/test cases/unit/5 compiler detection/trivial.c b/meson/test cases/unit/5 compiler detection/trivial.c new file mode 100644 index 000000000..24ac454c3 --- /dev/null +++ b/meson/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/meson/test cases/unit/5 compiler detection/trivial.cc b/meson/test cases/unit/5 compiler detection/trivial.cc new file mode 100644 index 000000000..8aa907b48 --- /dev/null +++ b/meson/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/meson/test cases/unit/5 compiler detection/trivial.m b/meson/test cases/unit/5 compiler detection/trivial.m new file mode 100644 index 000000000..f2e2315eb --- /dev/null +++ b/meson/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/meson/test cases/unit/5 compiler detection/trivial.mm b/meson/test cases/unit/5 compiler detection/trivial.mm new file mode 100644 index 000000000..927e8104e --- /dev/null +++ b/meson/test cases/unit/5 compiler detection/trivial.mm @@ -0,0 +1,9 @@ +#import<stdio.h> + +class MyClass { +}; + +int main(int argc, char **argv) { + return 0; +} + diff --git a/meson/test cases/unit/50 pkgconfig csharp library/meson.build b/meson/test cases/unit/50 pkgconfig csharp library/meson.build new file mode 100644 index 000000000..148d40fe4 --- /dev/null +++ b/meson/test cases/unit/50 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/meson/test cases/unit/50 pkgconfig csharp library/somelib.cs b/meson/test cases/unit/50 pkgconfig csharp library/somelib.cs new file mode 100644 index 000000000..24d37edf6 --- /dev/null +++ b/meson/test cases/unit/50 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/meson/test cases/unit/51 noncross options/meson.build b/meson/test cases/unit/51 noncross options/meson.build new file mode 100644 index 000000000..42e2cbb55 --- /dev/null +++ b/meson/test cases/unit/51 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/meson/test cases/unit/51 noncross options/prog.c b/meson/test cases/unit/51 noncross options/prog.c new file mode 100644 index 000000000..0314ff17b --- /dev/null +++ b/meson/test cases/unit/51 noncross options/prog.c @@ -0,0 +1 @@ +int main(int argc, char **argv) { return 0; } diff --git a/meson/test cases/unit/51 noncross options/ylib.pc b/meson/test cases/unit/51 noncross options/ylib.pc new file mode 100644 index 000000000..afec2d3f7 --- /dev/null +++ b/meson/test cases/unit/51 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/meson/test cases/unit/52 ldflagdedup/bob.c b/meson/test cases/unit/52 ldflagdedup/bob.c new file mode 100644 index 000000000..a68d4b170 --- /dev/null +++ b/meson/test cases/unit/52 ldflagdedup/bob.c @@ -0,0 +1,5 @@ +#include<gmodule.h> + +int func() { + return 0; +} diff --git a/meson/test cases/unit/52 ldflagdedup/meson.build b/meson/test cases/unit/52 ldflagdedup/meson.build new file mode 100644 index 000000000..0bbcc503d --- /dev/null +++ b/meson/test cases/unit/52 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/meson/test cases/unit/52 ldflagdedup/prog.c b/meson/test cases/unit/52 ldflagdedup/prog.c new file mode 100644 index 000000000..02c599de3 --- /dev/null +++ b/meson/test cases/unit/52 ldflagdedup/prog.c @@ -0,0 +1,7 @@ +#include<gmodule.h> + +int func(); + +int main(int argc, char **argv) { + return func(); +} diff --git a/meson/test cases/unit/53 pkgconfig static link order/meson.build b/meson/test cases/unit/53 pkgconfig static link order/meson.build new file mode 100644 index 000000000..b61de9ab1 --- /dev/null +++ b/meson/test cases/unit/53 pkgconfig static link order/meson.build @@ -0,0 +1,11 @@ +project('link order test', 'c') + +dep = library('dependency', []) +lib = static_library('something', [], link_with: dep) + +import('pkgconfig').generate( + name: 'libsomething', + description: 'test library', + libraries: lib, + version: '1' +) diff --git a/meson/test cases/unit/54 clang-format/.clang-format b/meson/test cases/unit/54 clang-format/.clang-format new file mode 100644 index 000000000..5c60ac9f3 --- /dev/null +++ b/meson/test cases/unit/54 clang-format/.clang-format @@ -0,0 +1,5 @@ +--- +BasedOnStyle: LLVM +IndentWidth: 4 +UseTab: Never +--- diff --git a/meson/test cases/unit/54 clang-format/dummydir.h/dummy.dat b/meson/test cases/unit/54 clang-format/dummydir.h/dummy.dat new file mode 100644 index 000000000..80c6165f3 --- /dev/null +++ b/meson/test cases/unit/54 clang-format/dummydir.h/dummy.dat @@ -0,0 +1 @@ +Placeholder to track enclosing directory in git. Not to be analyzed. diff --git a/meson/test cases/unit/54 clang-format/header_expected_h b/meson/test cases/unit/54 clang-format/header_expected_h new file mode 100644 index 000000000..430317604 --- /dev/null +++ b/meson/test cases/unit/54 clang-format/header_expected_h @@ -0,0 +1,3 @@ +#pragma once + +int fun(int argc); diff --git a/meson/test cases/unit/54 clang-format/header_orig_h b/meson/test cases/unit/54 clang-format/header_orig_h new file mode 100644 index 000000000..f2222f305 --- /dev/null +++ b/meson/test cases/unit/54 clang-format/header_orig_h @@ -0,0 +1,9 @@ +#pragma once + +int +fun +( +int +argc +) +; diff --git a/meson/test cases/unit/54 clang-format/meson.build b/meson/test cases/unit/54 clang-format/meson.build new file mode 100644 index 000000000..1b93cd54d --- /dev/null +++ b/meson/test cases/unit/54 clang-format/meson.build @@ -0,0 +1,4 @@ +project('clangformat', 'c') + +executable('prog', 'prog.c') + diff --git a/meson/test cases/unit/54 clang-format/prog_expected_c b/meson/test cases/unit/54 clang-format/prog_expected_c new file mode 100644 index 000000000..a045966a7 --- /dev/null +++ b/meson/test cases/unit/54 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/meson/test cases/unit/54 clang-format/prog_orig_c b/meson/test cases/unit/54 clang-format/prog_orig_c new file mode 100644 index 000000000..f098bbcce --- /dev/null +++ b/meson/test cases/unit/54 clang-format/prog_orig_c @@ -0,0 +1,21 @@ +#include <stdio.h> + + + + +int +main( +int +argc, +char** +argv) +{ +printf( +"Awful.\n" +) +; +return +0 +; +} + diff --git a/meson/test cases/unit/55 introspect buildoptions/subprojects/projectBad/meson.build b/meson/test cases/unit/55 introspect buildoptions/subprojects/projectBad/meson.build new file mode 100644 index 000000000..4d0aeebb9 --- /dev/null +++ b/meson/test cases/unit/55 introspect buildoptions/subprojects/projectBad/meson.build @@ -0,0 +1,9 @@ +pfggggaergaeg(sdgrgjgn)aga + +rgqeh +th +thtr +e +tb +tbqebt +tbqebttrtt diff --git a/meson/test cases/unit/55 introspect buildoptions/subprojects/projectBad/meson_options.txt b/meson/test cases/unit/55 introspect buildoptions/subprojects/projectBad/meson_options.txt new file mode 100644 index 000000000..f15d3529f --- /dev/null +++ b/meson/test cases/unit/55 introspect buildoptions/subprojects/projectBad/meson_options.txt @@ -0,0 +1 @@ +option('should_not_appear', type: 'integer', min: 0, value: 125) diff --git a/meson/test cases/unit/56 dedup compiler libs/app/app.c b/meson/test cases/unit/56 dedup compiler libs/app/app.c new file mode 100644 index 000000000..4e215b30b --- /dev/null +++ b/meson/test cases/unit/56 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/meson/test cases/unit/56 dedup compiler libs/app/meson.build b/meson/test cases/unit/56 dedup compiler libs/app/meson.build new file mode 100644 index 000000000..82ac3069d --- /dev/null +++ b/meson/test cases/unit/56 dedup compiler libs/app/meson.build @@ -0,0 +1,2 @@ +executable('app', 'app.c', + dependencies: [liba_dep, libb_dep]) diff --git a/meson/test cases/unit/56 dedup compiler libs/liba/liba.c b/meson/test cases/unit/56 dedup compiler libs/liba/liba.c new file mode 100644 index 000000000..962d47f30 --- /dev/null +++ b/meson/test cases/unit/56 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/meson/test cases/unit/56 dedup compiler libs/liba/liba.h b/meson/test cases/unit/56 dedup compiler libs/liba/liba.h new file mode 100644 index 000000000..a980cdc6b --- /dev/null +++ b/meson/test cases/unit/56 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/meson/test cases/unit/56 dedup compiler libs/liba/meson.build b/meson/test cases/unit/56 dedup compiler libs/liba/meson.build new file mode 100644 index 000000000..eccfa46c3 --- /dev/null +++ b/meson/test cases/unit/56 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/meson/test cases/unit/56 dedup compiler libs/libb/libb.c b/meson/test cases/unit/56 dedup compiler libs/libb/libb.c new file mode 100644 index 000000000..372086878 --- /dev/null +++ b/meson/test cases/unit/56 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/meson/test cases/unit/56 dedup compiler libs/libb/libb.h b/meson/test cases/unit/56 dedup compiler libs/libb/libb.h new file mode 100644 index 000000000..2e4ddd0c7 --- /dev/null +++ b/meson/test cases/unit/56 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/meson/test cases/unit/56 dedup compiler libs/libb/meson.build b/meson/test cases/unit/56 dedup compiler libs/libb/meson.build new file mode 100644 index 000000000..d59206f8d --- /dev/null +++ b/meson/test cases/unit/56 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/meson/test cases/unit/56 dedup compiler libs/meson.build b/meson/test cases/unit/56 dedup compiler libs/meson.build new file mode 100644 index 000000000..fad0ed556 --- /dev/null +++ b/meson/test cases/unit/56 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/meson/test cases/unit/57 introspection/cp.py b/meson/test cases/unit/57 introspection/cp.py new file mode 100644 index 000000000..cb09cf399 --- /dev/null +++ b/meson/test cases/unit/57 introspection/cp.py @@ -0,0 +1,5 @@ +#! /usr/bin/env python3 + +import sys +from shutil import copyfile +copyfile(*sys.argv[1:]) diff --git a/meson/test cases/unit/57 introspection/meson.build b/meson/test cases/unit/57 introspection/meson.build new file mode 100644 index 000000000..568d5ccd7 --- /dev/null +++ b/meson/test cases/unit/57 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/meson/test cases/unit/57 introspection/meson_options.txt b/meson/test cases/unit/57 introspection/meson_options.txt new file mode 100644 index 000000000..fc5cb4d2d --- /dev/null +++ b/meson/test cases/unit/57 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/meson/test cases/unit/57 introspection/sharedlib/meson.build b/meson/test cases/unit/57 introspection/sharedlib/meson.build new file mode 100644 index 000000000..7640bc70a --- /dev/null +++ b/meson/test cases/unit/57 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/meson/test cases/unit/57 introspection/sharedlib/shared.cpp b/meson/test cases/unit/57 introspection/sharedlib/shared.cpp new file mode 100644 index 000000000..5030ab75e --- /dev/null +++ b/meson/test cases/unit/57 introspection/sharedlib/shared.cpp @@ -0,0 +1,9 @@ +#include "shared.hpp" + +void SharedClass::doStuff() { + number++; +} + +int SharedClass::getNumber() const { + return number; +} diff --git a/meson/test cases/unit/57 introspection/sharedlib/shared.hpp b/meson/test cases/unit/57 introspection/sharedlib/shared.hpp new file mode 100644 index 000000000..dc9b2da28 --- /dev/null +++ b/meson/test cases/unit/57 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/meson/test cases/unit/57 introspection/staticlib/meson.build b/meson/test cases/unit/57 introspection/staticlib/meson.build new file mode 100644 index 000000000..1cbb02039 --- /dev/null +++ b/meson/test cases/unit/57 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/meson/test cases/unit/57 introspection/staticlib/static.c b/meson/test cases/unit/57 introspection/staticlib/static.c new file mode 100644 index 000000000..37ebc0d80 --- /dev/null +++ b/meson/test cases/unit/57 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/meson/test cases/unit/57 introspection/staticlib/static.h b/meson/test cases/unit/57 introspection/staticlib/static.h new file mode 100644 index 000000000..06da5089c --- /dev/null +++ b/meson/test cases/unit/57 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/meson/test cases/unit/57 introspection/t1.cpp b/meson/test cases/unit/57 introspection/t1.cpp new file mode 100644 index 000000000..901e3f1ac --- /dev/null +++ b/meson/test cases/unit/57 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/meson/test cases/unit/57 introspection/t2.cpp b/meson/test cases/unit/57 introspection/t2.cpp new file mode 100644 index 000000000..8323f4681 --- /dev/null +++ b/meson/test cases/unit/57 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/meson/test cases/unit/57 introspection/t3.cpp b/meson/test cases/unit/57 introspection/t3.cpp new file mode 100644 index 000000000..dd518e809 --- /dev/null +++ b/meson/test cases/unit/57 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/meson/test cases/unit/58 pkg_config_path option/build_extra_path/totally_made_up_dep.pc b/meson/test cases/unit/58 pkg_config_path option/build_extra_path/totally_made_up_dep.pc new file mode 100644 index 000000000..5b149f672 --- /dev/null +++ b/meson/test cases/unit/58 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/meson/test cases/unit/58 pkg_config_path option/host_extra_path/totally_made_up_dep.pc b/meson/test cases/unit/58 pkg_config_path option/host_extra_path/totally_made_up_dep.pc new file mode 100644 index 000000000..6d0868720 --- /dev/null +++ b/meson/test cases/unit/58 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/meson/test cases/unit/58 pkg_config_path option/meson.build b/meson/test cases/unit/58 pkg_config_path option/meson.build new file mode 100644 index 000000000..f9ceead06 --- /dev/null +++ b/meson/test cases/unit/58 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/meson/test cases/unit/59 introspect buildoptions/c_compiler.py b/meson/test cases/unit/59 introspect buildoptions/c_compiler.py new file mode 100644 index 000000000..c7241e7e0 --- /dev/null +++ b/meson/test cases/unit/59 introspect buildoptions/c_compiler.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python3 + +print('c') diff --git a/meson/test cases/unit/59 introspect buildoptions/main.c b/meson/test cases/unit/59 introspect buildoptions/main.c new file mode 100644 index 000000000..709730f19 --- /dev/null +++ b/meson/test cases/unit/59 introspect buildoptions/main.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +int main(void) { + printf("Hello World"); + return 0; +} diff --git a/meson/test cases/unit/59 introspect buildoptions/meson.build b/meson/test cases/unit/59 introspect buildoptions/meson.build new file mode 100644 index 000000000..9cfdc2c96 --- /dev/null +++ b/meson/test cases/unit/59 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')) +if r.returncode() != 0 + error('FAILED') +endif + +add_languages(r.stdout().strip(), required: true) +add_languages('afgggergearvearghergervergreaergaergasv', required: false) diff --git a/meson/test cases/unit/59 introspect buildoptions/meson_options.txt b/meson/test cases/unit/59 introspect buildoptions/meson_options.txt new file mode 100644 index 000000000..61f9a8db4 --- /dev/null +++ b/meson/test cases/unit/59 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/meson/test cases/unit/59 introspect buildoptions/subprojects/evilFile.txt b/meson/test cases/unit/59 introspect buildoptions/subprojects/evilFile.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/meson/test cases/unit/59 introspect buildoptions/subprojects/evilFile.txt diff --git a/meson/test cases/unit/59 introspect buildoptions/subprojects/projectA/meson.build b/meson/test cases/unit/59 introspect buildoptions/subprojects/projectA/meson.build new file mode 100644 index 000000000..1ab9ee8a5 --- /dev/null +++ b/meson/test cases/unit/59 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/meson/test cases/unit/59 introspect buildoptions/subprojects/projectA/meson_options.txt b/meson/test cases/unit/59 introspect buildoptions/subprojects/projectA/meson_options.txt new file mode 100644 index 000000000..fa77f954a --- /dev/null +++ b/meson/test cases/unit/59 introspect buildoptions/subprojects/projectA/meson_options.txt @@ -0,0 +1 @@ +option('subproj_var', type: 'boolean', value: false) diff --git a/meson/test cases/unit/59 introspect buildoptions/subprojects/projectBad/meson.build b/meson/test cases/unit/59 introspect buildoptions/subprojects/projectBad/meson.build new file mode 100644 index 000000000..500c1b9cc --- /dev/null +++ b/meson/test cases/unit/59 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/meson/test cases/unit/59 introspect buildoptions/subprojects/projectBad/meson_options.txt b/meson/test cases/unit/59 introspect buildoptions/subprojects/projectBad/meson_options.txt new file mode 100644 index 000000000..f15d3529f --- /dev/null +++ b/meson/test cases/unit/59 introspect buildoptions/subprojects/projectBad/meson_options.txt @@ -0,0 +1 @@ +option('should_not_appear', type: 'integer', min: 0, value: 125) diff --git a/meson/test cases/unit/6 std override/meson.build b/meson/test cases/unit/6 std override/meson.build new file mode 100644 index 000000000..0eac75222 --- /dev/null +++ b/meson/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/meson/test cases/unit/6 std override/prog11.cpp b/meson/test cases/unit/6 std override/prog11.cpp new file mode 100644 index 000000000..dde1fc020 --- /dev/null +++ b/meson/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/meson/test cases/unit/6 std override/prog98.cpp b/meson/test cases/unit/6 std override/prog98.cpp new file mode 100644 index 000000000..67c326d29 --- /dev/null +++ b/meson/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/meson/test cases/unit/6 std override/progp.cpp b/meson/test cases/unit/6 std override/progp.cpp new file mode 100644 index 000000000..b9bd97fc0 --- /dev/null +++ b/meson/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/meson/test cases/unit/60 native file override/crossfile b/meson/test cases/unit/60 native file override/crossfile new file mode 100644 index 000000000..9dc4fbcfc --- /dev/null +++ b/meson/test cases/unit/60 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/meson/test cases/unit/60 native file override/crossfile2 b/meson/test cases/unit/60 native file override/crossfile2 new file mode 100644 index 000000000..70946c9e7 --- /dev/null +++ b/meson/test cases/unit/60 native file override/crossfile2 @@ -0,0 +1,4 @@ +[paths] +bindir = 'binbar2' + +; vim: ft=dosini diff --git a/meson/test cases/unit/60 native file override/meson.build b/meson/test cases/unit/60 native file override/meson.build new file mode 100644 index 000000000..8318abaef --- /dev/null +++ b/meson/test cases/unit/60 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/meson/test cases/unit/60 native file override/meson_options.txt b/meson/test cases/unit/60 native file override/meson_options.txt new file mode 100644 index 000000000..4d2abf9c6 --- /dev/null +++ b/meson/test cases/unit/60 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/meson/test cases/unit/60 native file override/nativefile b/meson/test cases/unit/60 native file override/nativefile new file mode 100644 index 000000000..a39072579 --- /dev/null +++ b/meson/test cases/unit/60 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/meson/test cases/unit/61 identity cross/build_wrapper.py b/meson/test cases/unit/61 identity cross/build_wrapper.py new file mode 100755 index 000000000..15d5c07dd --- /dev/null +++ b/meson/test cases/unit/61 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/meson/test cases/unit/61 identity cross/host_wrapper.py b/meson/test cases/unit/61 identity cross/host_wrapper.py new file mode 100755 index 000000000..a3a694a4c --- /dev/null +++ b/meson/test cases/unit/61 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/meson/test cases/unit/61 identity cross/meson.build b/meson/test cases/unit/61 identity cross/meson.build new file mode 100644 index 000000000..950137a18 --- /dev/null +++ b/meson/test cases/unit/61 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/meson/test cases/unit/61 identity cross/stuff.h b/meson/test cases/unit/61 identity cross/stuff.h new file mode 100644 index 000000000..62f1cc9e6 --- /dev/null +++ b/meson/test cases/unit/61 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/meson/test cases/unit/62 pkgconfig relative paths/pkgconfig/librelativepath.pc b/meson/test cases/unit/62 pkgconfig relative paths/pkgconfig/librelativepath.pc new file mode 100644 index 000000000..dae1eed75 --- /dev/null +++ b/meson/test cases/unit/62 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/meson/test cases/unit/63 cmake_prefix_path/meson.build b/meson/test cases/unit/63 cmake_prefix_path/meson.build new file mode 100644 index 000000000..442bbd396 --- /dev/null +++ b/meson/test cases/unit/63 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/meson/test cases/unit/63 cmake_prefix_path/prefix/lib/cmake/mesontest/mesontest-config.cmake b/meson/test cases/unit/63 cmake_prefix_path/prefix/lib/cmake/mesontest/mesontest-config.cmake new file mode 100644 index 000000000..289b349b8 --- /dev/null +++ b/meson/test cases/unit/63 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/meson/test cases/unit/64 cmake parser/meson.build b/meson/test cases/unit/64 cmake parser/meson.build new file mode 100644 index 000000000..061bab0b6 --- /dev/null +++ b/meson/test cases/unit/64 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')
\ No newline at end of file diff --git a/meson/test cases/unit/64 cmake parser/prefix/lib/cmake/mesontest/mesontest-config.cmake b/meson/test cases/unit/64 cmake parser/prefix/lib/cmake/mesontest/mesontest-config.cmake new file mode 100644 index 000000000..7474eb78d --- /dev/null +++ b/meson/test cases/unit/64 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/meson/test cases/unit/65 alias target/main.c b/meson/test cases/unit/65 alias target/main.c new file mode 100644 index 000000000..0fb4389f7 --- /dev/null +++ b/meson/test cases/unit/65 alias target/main.c @@ -0,0 +1,3 @@ +int main(int argc, char *argv[]) { + return 0; +} diff --git a/meson/test cases/unit/65 alias target/meson.build b/meson/test cases/unit/65 alias target/meson.build new file mode 100644 index 000000000..6934cc79b --- /dev/null +++ b/meson/test cases/unit/65 alias target/meson.build @@ -0,0 +1,15 @@ +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]) diff --git a/meson/test cases/unit/66 static archive stripping/app/appA.c b/meson/test cases/unit/66 static archive stripping/app/appA.c new file mode 100644 index 000000000..e44b54a92 --- /dev/null +++ b/meson/test cases/unit/66 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/meson/test cases/unit/66 static archive stripping/app/appB.c b/meson/test cases/unit/66 static archive stripping/app/appB.c new file mode 100644 index 000000000..0ec0b629e --- /dev/null +++ b/meson/test cases/unit/66 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/meson/test cases/unit/66 static archive stripping/app/meson.build b/meson/test cases/unit/66 static archive stripping/app/meson.build new file mode 100644 index 000000000..118719dec --- /dev/null +++ b/meson/test cases/unit/66 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/meson/test cases/unit/66 static archive stripping/lib/libA.c b/meson/test cases/unit/66 static archive stripping/lib/libA.c new file mode 100644 index 000000000..a97185e56 --- /dev/null +++ b/meson/test cases/unit/66 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/meson/test cases/unit/66 static archive stripping/lib/libA.h b/meson/test cases/unit/66 static archive stripping/lib/libA.h new file mode 100644 index 000000000..e6450cd1e --- /dev/null +++ b/meson/test cases/unit/66 static archive stripping/lib/libA.h @@ -0,0 +1 @@ +int libA_func(void); diff --git a/meson/test cases/unit/66 static archive stripping/lib/libB.c b/meson/test cases/unit/66 static archive stripping/lib/libB.c new file mode 100644 index 000000000..0200b1f05 --- /dev/null +++ b/meson/test cases/unit/66 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/meson/test cases/unit/66 static archive stripping/lib/libB.h b/meson/test cases/unit/66 static archive stripping/lib/libB.h new file mode 100644 index 000000000..065a4a411 --- /dev/null +++ b/meson/test cases/unit/66 static archive stripping/lib/libB.h @@ -0,0 +1 @@ +int libB_func(void); diff --git a/meson/test cases/unit/66 static archive stripping/lib/meson.build b/meson/test cases/unit/66 static archive stripping/lib/meson.build new file mode 100644 index 000000000..ae50fa7b4 --- /dev/null +++ b/meson/test cases/unit/66 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/meson/test cases/unit/67 static link/lib/func1.c b/meson/test cases/unit/67 static link/lib/func1.c new file mode 100644 index 000000000..cc934ad04 --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func1.c @@ -0,0 +1,9 @@ +int func1() +{ + return 1; +} + +int func1b() +{ + return 1; +} diff --git a/meson/test cases/unit/67 static link/lib/func10.c b/meson/test cases/unit/67 static link/lib/func10.c new file mode 100644 index 000000000..75a911fb7 --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func10.c @@ -0,0 +1,4 @@ +int func10() +{ + return 1; +} diff --git a/meson/test cases/unit/67 static link/lib/func11.c b/meson/test cases/unit/67 static link/lib/func11.c new file mode 100644 index 000000000..1d5119b47 --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func11.c @@ -0,0 +1,6 @@ +int func10(); + +int func11() +{ + return func10() + 1; +} diff --git a/meson/test cases/unit/67 static link/lib/func12.c b/meson/test cases/unit/67 static link/lib/func12.c new file mode 100644 index 000000000..73db5c073 --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func12.c @@ -0,0 +1,7 @@ +int func10(); +int func11(); + +int func12() +{ + return func10() + func11(); +} diff --git a/meson/test cases/unit/67 static link/lib/func14.c b/meson/test cases/unit/67 static link/lib/func14.c new file mode 100644 index 000000000..0277319fc --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func14.c @@ -0,0 +1,4 @@ +int func14() +{ + return 1; +} diff --git a/meson/test cases/unit/67 static link/lib/func15.c b/meson/test cases/unit/67 static link/lib/func15.c new file mode 100644 index 000000000..78303cc2f --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func15.c @@ -0,0 +1,6 @@ +int func14(); + +int func15() +{ + return func14() + 1; +} diff --git a/meson/test cases/unit/67 static link/lib/func16.c b/meson/test cases/unit/67 static link/lib/func16.c new file mode 100644 index 000000000..379b6829f --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func16.c @@ -0,0 +1,6 @@ +int func15(); + +int func16() +{ + return func15() + 1; +} diff --git a/meson/test cases/unit/67 static link/lib/func17.c b/meson/test cases/unit/67 static link/lib/func17.c new file mode 100644 index 000000000..d1d8ec498 --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func17.c @@ -0,0 +1,4 @@ +int func17() +{ + return 1; +} diff --git a/meson/test cases/unit/67 static link/lib/func18.c b/meson/test cases/unit/67 static link/lib/func18.c new file mode 100644 index 000000000..c149085ba --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func18.c @@ -0,0 +1,6 @@ +int func17(); + +int func18() +{ + return func17() + 1; +} diff --git a/meson/test cases/unit/67 static link/lib/func19.c b/meson/test cases/unit/67 static link/lib/func19.c new file mode 100644 index 000000000..69120e4bf --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func19.c @@ -0,0 +1,7 @@ +int func17(); +int func18(); + +int func19() +{ + return func17() + func18(); +} diff --git a/meson/test cases/unit/67 static link/lib/func2.c b/meson/test cases/unit/67 static link/lib/func2.c new file mode 100644 index 000000000..6b8f53935 --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func2.c @@ -0,0 +1,6 @@ +int func1(); + +int func2() +{ + return func1() + 1; +} diff --git a/meson/test cases/unit/67 static link/lib/func3.c b/meson/test cases/unit/67 static link/lib/func3.c new file mode 100644 index 000000000..04f9f8939 --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func3.c @@ -0,0 +1,4 @@ +int func3() +{ + return 1; +} diff --git a/meson/test cases/unit/67 static link/lib/func4.c b/meson/test cases/unit/67 static link/lib/func4.c new file mode 100644 index 000000000..c44c99099 --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func4.c @@ -0,0 +1,6 @@ +int func3(); + +int func4() +{ + return func3() + 1; +} diff --git a/meson/test cases/unit/67 static link/lib/func5.c b/meson/test cases/unit/67 static link/lib/func5.c new file mode 100644 index 000000000..8e078641c --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func5.c @@ -0,0 +1,4 @@ +int func5() +{ + return 1; +} diff --git a/meson/test cases/unit/67 static link/lib/func6.c b/meson/test cases/unit/67 static link/lib/func6.c new file mode 100644 index 000000000..276fe7d48 --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func6.c @@ -0,0 +1,6 @@ +int func5(); + +int func6() +{ + return func5() + 1; +} diff --git a/meson/test cases/unit/67 static link/lib/func7.c b/meson/test cases/unit/67 static link/lib/func7.c new file mode 100644 index 000000000..8c1a5368d --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func7.c @@ -0,0 +1,4 @@ +int func7() +{ + return 1; +} diff --git a/meson/test cases/unit/67 static link/lib/func8.c b/meson/test cases/unit/67 static link/lib/func8.c new file mode 100644 index 000000000..b7b6cd545 --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func8.c @@ -0,0 +1,6 @@ +int func7(); + +int func8() +{ + return func7() + 1; +} diff --git a/meson/test cases/unit/67 static link/lib/func9.c b/meson/test cases/unit/67 static link/lib/func9.c new file mode 100644 index 000000000..852252d1a --- /dev/null +++ b/meson/test cases/unit/67 static link/lib/func9.c @@ -0,0 +1,6 @@ +int func8(); + +int func9() +{ + return func8() + 1; +} diff --git a/meson/test cases/unit/67 static link/lib/meson.build b/meson/test cases/unit/67 static link/lib/meson.build new file mode 100644 index 000000000..8f95fc454 --- /dev/null +++ b/meson/test cases/unit/67 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/meson/test cases/unit/67 static link/meson.build b/meson/test cases/unit/67 static link/meson.build new file mode 100644 index 000000000..dac17f810 --- /dev/null +++ b/meson/test cases/unit/67 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/meson/test cases/unit/67 static link/test1.c b/meson/test cases/unit/67 static link/test1.c new file mode 100644 index 000000000..ffc9b9eb9 --- /dev/null +++ b/meson/test cases/unit/67 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/meson/test cases/unit/67 static link/test2.c b/meson/test cases/unit/67 static link/test2.c new file mode 100644 index 000000000..561422af0 --- /dev/null +++ b/meson/test cases/unit/67 static link/test2.c @@ -0,0 +1,6 @@ +int func4(); + +int main(int argc, char *argv[]) +{ + return func4() == 2 ? 0 : 1; +} diff --git a/meson/test cases/unit/67 static link/test3.c b/meson/test cases/unit/67 static link/test3.c new file mode 100644 index 000000000..1216064dc --- /dev/null +++ b/meson/test cases/unit/67 static link/test3.c @@ -0,0 +1,6 @@ +int func6(); + +int main(int argc, char *argv[]) +{ + return func6() == 2 ? 0 : 1; +} diff --git a/meson/test cases/unit/67 static link/test4.c b/meson/test cases/unit/67 static link/test4.c new file mode 100644 index 000000000..7c281e026 --- /dev/null +++ b/meson/test cases/unit/67 static link/test4.c @@ -0,0 +1,6 @@ +int func9(); + +int main(int argc, char *argv[]) +{ + return func9() == 3 ? 0 : 1; +} diff --git a/meson/test cases/unit/67 static link/test5.c b/meson/test cases/unit/67 static link/test5.c new file mode 100644 index 000000000..6020f0e7c --- /dev/null +++ b/meson/test cases/unit/67 static link/test5.c @@ -0,0 +1,6 @@ +int func16(); + +int main(int argc, char *argv[]) +{ + return func16() == 3 ? 0 : 1; +} diff --git a/meson/test cases/unit/68 test env value/meson.build b/meson/test cases/unit/68 test env value/meson.build new file mode 100644 index 000000000..aa3dbc35d --- /dev/null +++ b/meson/test cases/unit/68 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/meson/test cases/unit/68 test env value/test.py b/meson/test cases/unit/68 test env value/test.py new file mode 100755 index 000000000..0cc7645e7 --- /dev/null +++ b/meson/test cases/unit/68 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/meson/test cases/unit/69 clang-tidy/.clang-tidy b/meson/test cases/unit/69 clang-tidy/.clang-tidy new file mode 100644 index 000000000..393529479 --- /dev/null +++ b/meson/test cases/unit/69 clang-tidy/.clang-tidy @@ -0,0 +1 @@ +Checks: '-*,modernize-use-bool-literals' diff --git a/meson/test cases/unit/69 clang-tidy/cttest.cpp b/meson/test cases/unit/69 clang-tidy/cttest.cpp new file mode 100644 index 000000000..07b35a666 --- /dev/null +++ b/meson/test cases/unit/69 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/meson/test cases/unit/69 clang-tidy/dummydir.h/dummy.dat b/meson/test cases/unit/69 clang-tidy/dummydir.h/dummy.dat new file mode 100644 index 000000000..80c6165f3 --- /dev/null +++ b/meson/test cases/unit/69 clang-tidy/dummydir.h/dummy.dat @@ -0,0 +1 @@ +Placeholder to track enclosing directory in git. Not to be analyzed. diff --git a/meson/test cases/unit/69 clang-tidy/meson.build b/meson/test cases/unit/69 clang-tidy/meson.build new file mode 100644 index 000000000..737474b02 --- /dev/null +++ b/meson/test cases/unit/69 clang-tidy/meson.build @@ -0,0 +1,3 @@ +project('clangtidytest', 'cpp', default_options: 'cpp_std=c++14') + +executable('cttest', 'cttest.cpp') diff --git a/meson/test cases/unit/7 run installed/foo/foo.c b/meson/test cases/unit/7 run installed/foo/foo.c new file mode 100644 index 000000000..402c89527 --- /dev/null +++ b/meson/test cases/unit/7 run installed/foo/foo.c @@ -0,0 +1,3 @@ +int foo() { + return 0; +} diff --git a/meson/test cases/unit/7 run installed/foo/meson.build b/meson/test cases/unit/7 run installed/foo/meson.build new file mode 100644 index 000000000..082f98529 --- /dev/null +++ b/meson/test cases/unit/7 run installed/foo/meson.build @@ -0,0 +1,7 @@ +# 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/meson/test cases/unit/7 run installed/meson.build b/meson/test cases/unit/7 run installed/meson.build new file mode 100644 index 000000000..46236fa83 --- /dev/null +++ b/meson/test cases/unit/7 run installed/meson.build @@ -0,0 +1,9 @@ +project('foo', 'c', + default_options : 'libdir=lib') + +subdir('foo') + +executable('prog', 'prog.c', + link_with : foolib, + install : true) + diff --git a/meson/test cases/unit/7 run installed/prog.c b/meson/test cases/unit/7 run installed/prog.c new file mode 100644 index 000000000..8e61e6ef3 --- /dev/null +++ b/meson/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/meson/test cases/unit/70 cross/crossfile.in b/meson/test cases/unit/70 cross/crossfile.in new file mode 100644 index 000000000..678e8d3a3 --- /dev/null +++ b/meson/test cases/unit/70 cross/crossfile.in @@ -0,0 +1,5 @@ +[host_machine] +system = '@system@' +cpu_family = '@cpu_family@' +cpu = '@cpu@' +endian = '@endian@' diff --git a/meson/test cases/unit/70 cross/meson.build b/meson/test cases/unit/70 cross/meson.build new file mode 100644 index 000000000..6c85cf73b --- /dev/null +++ b/meson/test cases/unit/70 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/meson/test cases/unit/70 cross/meson_options.txt b/meson/test cases/unit/70 cross/meson_options.txt new file mode 100644 index 000000000..5896d63c8 --- /dev/null +++ b/meson/test cases/unit/70 cross/meson_options.txt @@ -0,0 +1 @@ +option('generate', type : 'boolean', value : false) diff --git a/meson/test cases/unit/71 cross test passed/exewrapper.py b/meson/test cases/unit/71 cross test passed/exewrapper.py new file mode 100755 index 000000000..2c15ed6f3 --- /dev/null +++ b/meson/test cases/unit/71 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/meson/test cases/unit/71 cross test passed/meson.build b/meson/test cases/unit/71 cross test passed/meson.build new file mode 100644 index 000000000..4deb74baf --- /dev/null +++ b/meson/test cases/unit/71 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/meson/test cases/unit/71 cross test passed/meson_options.txt b/meson/test cases/unit/71 cross test passed/meson_options.txt new file mode 100644 index 000000000..084c77625 --- /dev/null +++ b/meson/test cases/unit/71 cross test passed/meson_options.txt @@ -0,0 +1,5 @@ +option( + 'expect', + type : 'boolean', + value : false, +) diff --git a/meson/test cases/unit/71 cross test passed/script.py b/meson/test cases/unit/71 cross test passed/script.py new file mode 100644 index 000000000..257cd30d8 --- /dev/null +++ b/meson/test cases/unit/71 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/meson/test cases/unit/71 cross test passed/src/main.c b/meson/test cases/unit/71 cross test passed/src/main.c new file mode 100644 index 000000000..490b4a619 --- /dev/null +++ b/meson/test cases/unit/71 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/meson/test cases/unit/72 summary/meson.build b/meson/test cases/unit/72 summary/meson.build new file mode 100644 index 000000000..6e0f69ad3 --- /dev/null +++ b/meson/test cases/unit/72 summary/meson.build @@ -0,0 +1,23 @@ +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(), + }, 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('coma list', ['a', 'b', 'c'], list_sep: ', ', section: 'Configuration') +summary('long coma list', ['alpha', 'alphacolor', 'apetag', 'audiofx', 'audioparsers', 'auparse', 'autodetect', 'avi'], list_sep: ', ', section: 'Plugins') diff --git a/meson/test cases/unit/72 summary/meson_options.txt b/meson/test cases/unit/72 summary/meson_options.txt new file mode 100644 index 000000000..f2c41f8fb --- /dev/null +++ b/meson/test cases/unit/72 summary/meson_options.txt @@ -0,0 +1 @@ +option('enabled_opt', type: 'feature', value: 'enabled') diff --git a/meson/test cases/unit/72 summary/subprojects/sub/meson.build b/meson/test cases/unit/72 summary/subprojects/sub/meson.build new file mode 100644 index 000000000..e7d783384 --- /dev/null +++ b/meson/test cases/unit/72 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/meson/test cases/unit/72 summary/subprojects/sub2/meson.build b/meson/test cases/unit/72 summary/subprojects/sub2/meson.build new file mode 100644 index 000000000..2560bd05d --- /dev/null +++ b/meson/test cases/unit/72 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/meson/test cases/unit/72 summary/subprojects/sub2/subprojects/subsub/meson.build b/meson/test cases/unit/72 summary/subprojects/sub2/subprojects/subsub/meson.build new file mode 100644 index 000000000..98a5a269d --- /dev/null +++ b/meson/test cases/unit/72 summary/subprojects/sub2/subprojects/subsub/meson.build @@ -0,0 +1,3 @@ +project('subsub') + +summary('Something', 'Some value') diff --git a/meson/test cases/unit/73 wrap file url/meson.build b/meson/test cases/unit/73 wrap file url/meson.build new file mode 100644 index 000000000..3bd3b250f --- /dev/null +++ b/meson/test cases/unit/73 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/meson/test cases/unit/73 wrap file url/subprojects/foo-patch.tar.xz b/meson/test cases/unit/73 wrap file url/subprojects/foo-patch.tar.xz Binary files differnew file mode 100644 index 000000000..fdb026ca7 --- /dev/null +++ b/meson/test cases/unit/73 wrap file url/subprojects/foo-patch.tar.xz diff --git a/meson/test cases/unit/73 wrap file url/subprojects/foo.tar.xz b/meson/test cases/unit/73 wrap file url/subprojects/foo.tar.xz Binary files differnew file mode 100644 index 000000000..2ed6ab475 --- /dev/null +++ b/meson/test cases/unit/73 wrap file url/subprojects/foo.tar.xz diff --git a/meson/test cases/unit/74 dep files/foo.c b/meson/test cases/unit/74 dep files/foo.c new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/meson/test cases/unit/74 dep files/foo.c diff --git a/meson/test cases/unit/74 dep files/meson.build b/meson/test cases/unit/74 dep files/meson.build new file mode 100644 index 000000000..4829f563f --- /dev/null +++ b/meson/test cases/unit/74 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/meson/test cases/unit/75 pkgconfig prefixes/client/client.c b/meson/test cases/unit/75 pkgconfig prefixes/client/client.c new file mode 100644 index 000000000..be9beadb0 --- /dev/null +++ b/meson/test cases/unit/75 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/meson/test cases/unit/75 pkgconfig prefixes/client/meson.build b/meson/test cases/unit/75 pkgconfig prefixes/client/meson.build new file mode 100644 index 000000000..491937b7b --- /dev/null +++ b/meson/test cases/unit/75 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/meson/test cases/unit/75 pkgconfig prefixes/val1/meson.build b/meson/test cases/unit/75 pkgconfig prefixes/val1/meson.build new file mode 100644 index 000000000..cc63e3143 --- /dev/null +++ b/meson/test cases/unit/75 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/meson/test cases/unit/75 pkgconfig prefixes/val1/val1.c b/meson/test cases/unit/75 pkgconfig prefixes/val1/val1.c new file mode 100644 index 000000000..591e52162 --- /dev/null +++ b/meson/test cases/unit/75 pkgconfig prefixes/val1/val1.c @@ -0,0 +1,3 @@ +#include "val1.h" + +int val1(void) { return 1; } diff --git a/meson/test cases/unit/75 pkgconfig prefixes/val1/val1.h b/meson/test cases/unit/75 pkgconfig prefixes/val1/val1.h new file mode 100644 index 000000000..6bd435eb9 --- /dev/null +++ b/meson/test cases/unit/75 pkgconfig prefixes/val1/val1.h @@ -0,0 +1 @@ +int val1(void); diff --git a/meson/test cases/unit/75 pkgconfig prefixes/val2/meson.build b/meson/test cases/unit/75 pkgconfig prefixes/val2/meson.build new file mode 100644 index 000000000..ce69481ec --- /dev/null +++ b/meson/test cases/unit/75 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/meson/test cases/unit/75 pkgconfig prefixes/val2/val2.c b/meson/test cases/unit/75 pkgconfig prefixes/val2/val2.c new file mode 100644 index 000000000..d7d485730 --- /dev/null +++ b/meson/test cases/unit/75 pkgconfig prefixes/val2/val2.c @@ -0,0 +1,4 @@ +#include "val1.h" +#include "val2.h" + +int val2(void) { return val1() + 2; } diff --git a/meson/test cases/unit/75 pkgconfig prefixes/val2/val2.h b/meson/test cases/unit/75 pkgconfig prefixes/val2/val2.h new file mode 100644 index 000000000..995023da2 --- /dev/null +++ b/meson/test cases/unit/75 pkgconfig prefixes/val2/val2.h @@ -0,0 +1 @@ +int val2(void); diff --git a/meson/test cases/unit/76 subdir libdir/meson.build b/meson/test cases/unit/76 subdir libdir/meson.build new file mode 100644 index 000000000..5099c91c7 --- /dev/null +++ b/meson/test cases/unit/76 subdir libdir/meson.build @@ -0,0 +1,2 @@ +project('toplevel', 'c') +subproject('flub') diff --git a/meson/test cases/unit/76 subdir libdir/subprojects/flub/meson.build b/meson/test cases/unit/76 subdir libdir/subprojects/flub/meson.build new file mode 100644 index 000000000..7bfd2c553 --- /dev/null +++ b/meson/test cases/unit/76 subdir libdir/subprojects/flub/meson.build @@ -0,0 +1 @@ +project('subflub', 'c') diff --git a/meson/test cases/unit/77 as link whole/bar.c b/meson/test cases/unit/77 as link whole/bar.c new file mode 100644 index 000000000..79dea9d0f --- /dev/null +++ b/meson/test cases/unit/77 as link whole/bar.c @@ -0,0 +1,6 @@ +int bar(void); + +int bar(void) +{ + return 0; +} diff --git a/meson/test cases/unit/77 as link whole/foo.c b/meson/test cases/unit/77 as link whole/foo.c new file mode 100644 index 000000000..ffeee82fe --- /dev/null +++ b/meson/test cases/unit/77 as link whole/foo.c @@ -0,0 +1,6 @@ +int foo(void); + +int foo(void) +{ + return 0; +} diff --git a/meson/test cases/unit/77 as link whole/meson.build b/meson/test cases/unit/77 as link whole/meson.build new file mode 100644 index 000000000..6bc208f1b --- /dev/null +++ b/meson/test cases/unit/77 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/meson/test cases/unit/78 nostdlib/meson.build b/meson/test cases/unit/78 nostdlib/meson.build new file mode 100644 index 000000000..9c5f949b2 --- /dev/null +++ b/meson/test cases/unit/78 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/meson/test cases/unit/78 nostdlib/prog.c b/meson/test cases/unit/78 nostdlib/prog.c new file mode 100644 index 000000000..b9216ee81 --- /dev/null +++ b/meson/test cases/unit/78 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/meson/test cases/unit/78 nostdlib/subprojects/mylibc/libc.c b/meson/test cases/unit/78 nostdlib/subprojects/mylibc/libc.c new file mode 100644 index 000000000..67261cb1d --- /dev/null +++ b/meson/test cases/unit/78 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/meson/test cases/unit/78 nostdlib/subprojects/mylibc/meson.build b/meson/test cases/unit/78 nostdlib/subprojects/mylibc/meson.build new file mode 100644 index 000000000..ff4bdb20f --- /dev/null +++ b/meson/test cases/unit/78 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/meson/test cases/unit/78 nostdlib/subprojects/mylibc/stdio.h b/meson/test cases/unit/78 nostdlib/subprojects/mylibc/stdio.h new file mode 100644 index 000000000..c3f8f56ca --- /dev/null +++ b/meson/test cases/unit/78 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/meson/test cases/unit/78 nostdlib/subprojects/mylibc/stubstart.s b/meson/test cases/unit/78 nostdlib/subprojects/mylibc/stubstart.s new file mode 100644 index 000000000..0a6d9729a --- /dev/null +++ b/meson/test cases/unit/78 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/meson/test cases/unit/79 user options for subproject/.gitignore b/meson/test cases/unit/79 user options for subproject/.gitignore new file mode 100644 index 000000000..0bec5eac1 --- /dev/null +++ b/meson/test cases/unit/79 user options for subproject/.gitignore @@ -0,0 +1 @@ +/subprojects diff --git a/meson/test cases/unit/79 user options for subproject/75 user options for subproject/.gitignore b/meson/test cases/unit/79 user options for subproject/75 user options for subproject/.gitignore new file mode 100644 index 000000000..4976afc58 --- /dev/null +++ b/meson/test cases/unit/79 user options for subproject/75 user options for subproject/.gitignore @@ -0,0 +1 @@ +subprojects/* diff --git a/meson/test cases/unit/79 user options for subproject/75 user options for subproject/meson.build b/meson/test cases/unit/79 user options for subproject/75 user options for subproject/meson.build new file mode 100644 index 000000000..0bc395b4b --- /dev/null +++ b/meson/test cases/unit/79 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/meson/test cases/unit/8 -L -l order/first.pc b/meson/test cases/unit/8 -L -l order/first.pc new file mode 100644 index 000000000..3b811b2e2 --- /dev/null +++ b/meson/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/meson/test cases/unit/8 -L -l order/meson.build b/meson/test cases/unit/8 -L -l order/meson.build new file mode 100644 index 000000000..cfcf033fa --- /dev/null +++ b/meson/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/meson/test cases/unit/8 -L -l order/prog.c b/meson/test cases/unit/8 -L -l order/prog.c new file mode 100644 index 000000000..3a16ac3dc --- /dev/null +++ b/meson/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/meson/test cases/unit/8 -L -l order/second.pc b/meson/test cases/unit/8 -L -l order/second.pc new file mode 100644 index 000000000..196824b74 --- /dev/null +++ b/meson/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/meson/test cases/unit/80 global-rpath/meson.build b/meson/test cases/unit/80 global-rpath/meson.build new file mode 100644 index 000000000..c67d9e08b --- /dev/null +++ b/meson/test cases/unit/80 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/meson/test cases/unit/80 global-rpath/rpathified.cpp b/meson/test cases/unit/80 global-rpath/rpathified.cpp new file mode 100644 index 000000000..3788906dc --- /dev/null +++ b/meson/test cases/unit/80 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/meson/test cases/unit/80 global-rpath/yonder/meson.build b/meson/test cases/unit/80 global-rpath/yonder/meson.build new file mode 100644 index 000000000..e32f38330 --- /dev/null +++ b/meson/test cases/unit/80 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/meson/test cases/unit/80 global-rpath/yonder/yonder.cpp b/meson/test cases/unit/80 global-rpath/yonder/yonder.cpp new file mode 100644 index 000000000..b182d34e3 --- /dev/null +++ b/meson/test cases/unit/80 global-rpath/yonder/yonder.cpp @@ -0,0 +1,3 @@ +#include "yonder.h" + +char *yonder(void) { return "AB54 6BR"; } diff --git a/meson/test cases/unit/80 global-rpath/yonder/yonder.h b/meson/test cases/unit/80 global-rpath/yonder/yonder.h new file mode 100644 index 000000000..9d9ad1617 --- /dev/null +++ b/meson/test cases/unit/80 global-rpath/yonder/yonder.h @@ -0,0 +1 @@ +char *yonder(void); diff --git a/meson/test cases/unit/81 wrap-git/meson.build b/meson/test cases/unit/81 wrap-git/meson.build new file mode 100644 index 000000000..b0af30a3f --- /dev/null +++ b/meson/test cases/unit/81 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/meson/test cases/unit/81 wrap-git/subprojects/packagefiles/wrap_git_builddef/meson.build b/meson/test cases/unit/81 wrap-git/subprojects/packagefiles/wrap_git_builddef/meson.build new file mode 100644 index 000000000..2570f7777 --- /dev/null +++ b/meson/test cases/unit/81 wrap-git/subprojects/packagefiles/wrap_git_builddef/meson.build @@ -0,0 +1,3 @@ +project('foo', 'c') + +exe = executable('app', 'main.c') diff --git a/meson/test cases/unit/81 wrap-git/subprojects/wrap_git_upstream/main.c b/meson/test cases/unit/81 wrap-git/subprojects/wrap_git_upstream/main.c new file mode 100644 index 000000000..8488f4e58 --- /dev/null +++ b/meson/test cases/unit/81 wrap-git/subprojects/wrap_git_upstream/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/meson/test cases/unit/82 meson version compare/meson.build b/meson/test cases/unit/82 meson version compare/meson.build new file mode 100644 index 000000000..4affe21df --- /dev/null +++ b/meson/test cases/unit/82 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/meson/test cases/unit/82 meson version compare/subprojects/foo/meson.build b/meson/test cases/unit/82 meson version compare/subprojects/foo/meson.build new file mode 100644 index 000000000..4c66b70b3 --- /dev/null +++ b/meson/test cases/unit/82 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/meson/test cases/unit/83 cross only introspect/meson.build b/meson/test cases/unit/83 cross only introspect/meson.build new file mode 100644 index 000000000..ed25441bf --- /dev/null +++ b/meson/test cases/unit/83 cross only introspect/meson.build @@ -0,0 +1,2 @@ +project('cross only introspect') +add_languages('c', native: false) diff --git a/meson/test cases/unit/84 change option choices/meson.build b/meson/test cases/unit/84 change option choices/meson.build new file mode 100644 index 000000000..d056d6594 --- /dev/null +++ b/meson/test cases/unit/84 change option choices/meson.build @@ -0,0 +1 @@ +project('change option choices') diff --git a/meson/test cases/unit/84 change option choices/meson_options.1.txt b/meson/test cases/unit/84 change option choices/meson_options.1.txt new file mode 100644 index 000000000..d0326a55b --- /dev/null +++ b/meson/test cases/unit/84 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/meson/test cases/unit/84 change option choices/meson_options.2.txt b/meson/test cases/unit/84 change option choices/meson_options.2.txt new file mode 100644 index 000000000..4684673e1 --- /dev/null +++ b/meson/test cases/unit/84 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/meson/test cases/unit/85 nested subproject regenerate depends/main.c b/meson/test cases/unit/85 nested subproject regenerate depends/main.c new file mode 100644 index 000000000..9b6bdc2ec --- /dev/null +++ b/meson/test cases/unit/85 nested subproject regenerate depends/main.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/meson/test cases/unit/85 nested subproject regenerate depends/meson.build b/meson/test cases/unit/85 nested subproject regenerate depends/meson.build new file mode 100644 index 000000000..569888164 --- /dev/null +++ b/meson/test cases/unit/85 nested subproject regenerate depends/meson.build @@ -0,0 +1,6 @@ +project('nested subproject regenerate depends', 'c') + +s = subproject('sub1') + +# This is needed to make msbuild noop check work correctly +executable('exe', 'main.c') diff --git a/meson/test cases/unit/85 nested subproject regenerate depends/subprojects/sub1/meson.build b/meson/test cases/unit/85 nested subproject regenerate depends/subprojects/sub1/meson.build new file mode 100644 index 000000000..a31db4ade --- /dev/null +++ b/meson/test cases/unit/85 nested subproject regenerate depends/subprojects/sub1/meson.build @@ -0,0 +1,4 @@ +project('sub1') + +cmake = import('cmake') +cmake.subproject('sub2') diff --git a/meson/test cases/unit/85 nested subproject regenerate depends/subprojects/sub2/CMakeLists.txt b/meson/test cases/unit/85 nested subproject regenerate depends/subprojects/sub2/CMakeLists.txt new file mode 100644 index 000000000..f91473a6a --- /dev/null +++ b/meson/test cases/unit/85 nested subproject regenerate depends/subprojects/sub2/CMakeLists.txt @@ -0,0 +1 @@ +project(sub2) diff --git a/meson/test cases/unit/86 cpp modules/main.cpp b/meson/test cases/unit/86 cpp modules/main.cpp new file mode 100644 index 000000000..d825c7d49 --- /dev/null +++ b/meson/test cases/unit/86 cpp modules/main.cpp @@ -0,0 +1,7 @@ +import M0; +#include<cstdio> + +int main() { + printf("The value is %d", func0()); + return 0; +} diff --git a/meson/test cases/unit/86 cpp modules/meson.build b/meson/test cases/unit/86 cpp modules/meson.build new file mode 100644 index 000000000..cdc296f43 --- /dev/null +++ b/meson/test cases/unit/86 cpp modules/meson.build @@ -0,0 +1,17 @@ +project('cppmodules', 'cpp', default_options: ['cpp_std=c++latest']) + +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/meson/test cases/unit/86 cpp modules/src0.ixx b/meson/test cases/unit/86 cpp modules/src0.ixx new file mode 100644 index 000000000..3ca4d1448 --- /dev/null +++ b/meson/test cases/unit/86 cpp modules/src0.ixx @@ -0,0 +1,7 @@ +export module M0; + +import M1; + +export int func0() { + return func1(); +} diff --git a/meson/test cases/unit/86 cpp modules/src1.ixx b/meson/test cases/unit/86 cpp modules/src1.ixx new file mode 100644 index 000000000..cea6696de --- /dev/null +++ b/meson/test cases/unit/86 cpp modules/src1.ixx @@ -0,0 +1,7 @@ +export module M1; + +import M2; + +export int func1() { + return func2(); +} diff --git a/meson/test cases/unit/86 cpp modules/src2.ixx b/meson/test cases/unit/86 cpp modules/src2.ixx new file mode 100644 index 000000000..415714cc0 --- /dev/null +++ b/meson/test cases/unit/86 cpp modules/src2.ixx @@ -0,0 +1,7 @@ +export module M2; + +import M3; + +export int func2() { + return func3(); +} diff --git a/meson/test cases/unit/86 cpp modules/src3.ixx b/meson/test cases/unit/86 cpp modules/src3.ixx new file mode 100644 index 000000000..96f135c00 --- /dev/null +++ b/meson/test cases/unit/86 cpp modules/src3.ixx @@ -0,0 +1,7 @@ +export module M3; + +import M4; + +export int func3() { + return func4(); +} diff --git a/meson/test cases/unit/86 cpp modules/src4.ixx b/meson/test cases/unit/86 cpp modules/src4.ixx new file mode 100644 index 000000000..1ac1a6a64 --- /dev/null +++ b/meson/test cases/unit/86 cpp modules/src4.ixx @@ -0,0 +1,7 @@ +export module M4; + +import M5; + +export int func4() { + return func5(); +} diff --git a/meson/test cases/unit/86 cpp modules/src5.ixx b/meson/test cases/unit/86 cpp modules/src5.ixx new file mode 100644 index 000000000..96cf70761 --- /dev/null +++ b/meson/test cases/unit/86 cpp modules/src5.ixx @@ -0,0 +1,7 @@ +export module M5; + +import M6; + +export int func5() { + return func6(); +} diff --git a/meson/test cases/unit/86 cpp modules/src6.ixx b/meson/test cases/unit/86 cpp modules/src6.ixx new file mode 100644 index 000000000..760b71cbb --- /dev/null +++ b/meson/test cases/unit/86 cpp modules/src6.ixx @@ -0,0 +1,7 @@ +export module M6; + +import M7; + +export int func6() { + return func7(); +} diff --git a/meson/test cases/unit/86 cpp modules/src7.ixx b/meson/test cases/unit/86 cpp modules/src7.ixx new file mode 100644 index 000000000..8ce660801 --- /dev/null +++ b/meson/test cases/unit/86 cpp modules/src7.ixx @@ -0,0 +1,7 @@ +export module M7; + +import M8; + +export int func7() { + return func8(); +} diff --git a/meson/test cases/unit/86 cpp modules/src8.ixx b/meson/test cases/unit/86 cpp modules/src8.ixx new file mode 100644 index 000000000..6a3ef96f5 --- /dev/null +++ b/meson/test cases/unit/86 cpp modules/src8.ixx @@ -0,0 +1,7 @@ +export module M8; + +import M9; + +export int func8() { + return func9(); +} diff --git a/meson/test cases/unit/86 cpp modules/src9.ixx b/meson/test cases/unit/86 cpp modules/src9.ixx new file mode 100644 index 000000000..3ecb3be68 --- /dev/null +++ b/meson/test cases/unit/86 cpp modules/src9.ixx @@ -0,0 +1,5 @@ +export module M9; + +export int func9() { + return 42; +} diff --git a/meson/test cases/unit/87 prelinking/file1.c b/meson/test cases/unit/87 prelinking/file1.c new file mode 100644 index 000000000..9f0e26523 --- /dev/null +++ b/meson/test cases/unit/87 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/meson/test cases/unit/87 prelinking/file2.c b/meson/test cases/unit/87 prelinking/file2.c new file mode 100644 index 000000000..ce3b11550 --- /dev/null +++ b/meson/test cases/unit/87 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/meson/test cases/unit/87 prelinking/file3.c b/meson/test cases/unit/87 prelinking/file3.c new file mode 100644 index 000000000..85052beb4 --- /dev/null +++ b/meson/test cases/unit/87 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/meson/test cases/unit/87 prelinking/file4.c b/meson/test cases/unit/87 prelinking/file4.c new file mode 100644 index 000000000..622364e78 --- /dev/null +++ b/meson/test cases/unit/87 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/meson/test cases/unit/87 prelinking/main.c b/meson/test cases/unit/87 prelinking/main.c new file mode 100644 index 000000000..09a2e5c3d --- /dev/null +++ b/meson/test cases/unit/87 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/meson/test cases/unit/87 prelinking/meson.build b/meson/test cases/unit/87 prelinking/meson.build new file mode 100644 index 000000000..3dbf88e5f --- /dev/null +++ b/meson/test cases/unit/87 prelinking/meson.build @@ -0,0 +1,8 @@ +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) +
\ No newline at end of file diff --git a/meson/test cases/unit/87 prelinking/private_header.h b/meson/test cases/unit/87 prelinking/private_header.h new file mode 100644 index 000000000..f24b621a0 --- /dev/null +++ b/meson/test cases/unit/87 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/meson/test cases/unit/87 prelinking/public_header.h b/meson/test cases/unit/87 prelinking/public_header.h new file mode 100644 index 000000000..0cd67862a --- /dev/null +++ b/meson/test cases/unit/87 prelinking/public_header.h @@ -0,0 +1,3 @@ +#pragma once + +int public_func(); diff --git a/meson/test cases/unit/88 run native test/main.c b/meson/test cases/unit/88 run native test/main.c new file mode 100644 index 000000000..3213780df --- /dev/null +++ b/meson/test cases/unit/88 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/meson/test cases/unit/88 run native test/meson.build b/meson/test cases/unit/88 run native test/meson.build new file mode 100644 index 000000000..3bf419c14 --- /dev/null +++ b/meson/test cases/unit/88 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/meson/test cases/unit/89 multiple envvars/meson.build b/meson/test cases/unit/89 multiple envvars/meson.build new file mode 100644 index 000000000..ac57611c8 --- /dev/null +++ b/meson/test cases/unit/89 multiple envvars/meson.build @@ -0,0 +1,4 @@ +project('multienv', 'c', 'cpp') + +executable('cexe', 'prog.c') +executable('cppexe', 'prog.cpp') diff --git a/meson/test cases/unit/89 multiple envvars/prog.c b/meson/test cases/unit/89 multiple envvars/prog.c new file mode 100644 index 000000000..38d3c123b --- /dev/null +++ b/meson/test cases/unit/89 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/meson/test cases/unit/89 multiple envvars/prog.cpp b/meson/test cases/unit/89 multiple envvars/prog.cpp new file mode 100644 index 000000000..61ccf3a45 --- /dev/null +++ b/meson/test cases/unit/89 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/meson/test cases/unit/9 d dedup/meson.build b/meson/test cases/unit/9 d dedup/meson.build new file mode 100644 index 000000000..08f3a6c67 --- /dev/null +++ b/meson/test cases/unit/9 d dedup/meson.build @@ -0,0 +1,6 @@ +project('d dedup', 'c') + +add_project_arguments('-D', 'FOO', '-D', 'BAR', language : 'c') + +executable('prog', 'prog.c') + diff --git a/meson/test cases/unit/9 d dedup/prog.c b/meson/test cases/unit/9 d dedup/prog.c new file mode 100644 index 000000000..505f12280 --- /dev/null +++ b/meson/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/meson/test cases/unit/90 pkgconfig build rpath order/dummy.pc b/meson/test cases/unit/90 pkgconfig build rpath order/dummy.pc new file mode 100644 index 000000000..9e3048b24 --- /dev/null +++ b/meson/test cases/unit/90 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/meson/test cases/unit/90 pkgconfig build rpath order/meson.build b/meson/test cases/unit/90 pkgconfig build rpath order/meson.build new file mode 100644 index 000000000..76ed8de25 --- /dev/null +++ b/meson/test cases/unit/90 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/meson/test cases/unit/90 pkgconfig build rpath order/prog.c b/meson/test cases/unit/90 pkgconfig build rpath order/prog.c new file mode 100644 index 000000000..45b2fa3df --- /dev/null +++ b/meson/test cases/unit/90 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/meson/test cases/unit/90 pkgconfig build rpath order/prog.cc b/meson/test cases/unit/90 pkgconfig build rpath order/prog.cc new file mode 100644 index 000000000..c7c212370 --- /dev/null +++ b/meson/test cases/unit/90 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/meson/test cases/unit/90 pkgconfig build rpath order/sub/meson.build b/meson/test cases/unit/90 pkgconfig build rpath order/sub/meson.build new file mode 100644 index 000000000..6879ec666 --- /dev/null +++ b/meson/test cases/unit/90 pkgconfig build rpath order/sub/meson.build @@ -0,0 +1 @@ +l = shared_library('stuff', 'stuff.c') diff --git a/meson/test cases/unit/90 pkgconfig build rpath order/sub/stuff.c b/meson/test cases/unit/90 pkgconfig build rpath order/sub/stuff.c new file mode 100644 index 000000000..d56d8b0ea --- /dev/null +++ b/meson/test cases/unit/90 pkgconfig build rpath order/sub/stuff.c @@ -0,0 +1,3 @@ +int get_stuff() { + return 0; +} diff --git a/meson/test cases/unit/91 devenv/main.c b/meson/test cases/unit/91 devenv/main.c new file mode 100644 index 000000000..271059356 --- /dev/null +++ b/meson/test cases/unit/91 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/meson/test cases/unit/91 devenv/meson.build b/meson/test cases/unit/91 devenv/meson.build new file mode 100644 index 000000000..40b9c861d --- /dev/null +++ b/meson/test cases/unit/91 devenv/meson.build @@ -0,0 +1,12 @@ +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) + +# 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/meson/test cases/unit/91 devenv/subprojects/sub/foo.c b/meson/test cases/unit/91 devenv/subprojects/sub/foo.c new file mode 100644 index 000000000..46cb845f9 --- /dev/null +++ b/meson/test cases/unit/91 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/meson/test cases/unit/91 devenv/subprojects/sub/meson.build b/meson/test cases/unit/91 devenv/subprojects/sub/meson.build new file mode 100644 index 000000000..5cb123209 --- /dev/null +++ b/meson/test cases/unit/91 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/meson/test cases/unit/91 devenv/test-devenv.py b/meson/test cases/unit/91 devenv/test-devenv.py new file mode 100755 index 000000000..4e5be9776 --- /dev/null +++ b/meson/test cases/unit/91 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'] == '1+2+3') diff --git a/meson/test cases/unit/92 install skip subprojects/foo.c b/meson/test cases/unit/92 install skip subprojects/foo.c new file mode 100644 index 000000000..25927f5a1 --- /dev/null +++ b/meson/test cases/unit/92 install skip subprojects/foo.c @@ -0,0 +1,4 @@ +int main(int argc, char *argv[]) +{ + return 0; +} diff --git a/meson/test cases/unit/92 install skip subprojects/foo.dat b/meson/test cases/unit/92 install skip subprojects/foo.dat new file mode 100644 index 000000000..421376db9 --- /dev/null +++ b/meson/test cases/unit/92 install skip subprojects/foo.dat @@ -0,0 +1 @@ +dummy diff --git a/meson/test cases/unit/92 install skip subprojects/foo.h b/meson/test cases/unit/92 install skip subprojects/foo.h new file mode 100644 index 000000000..a7e26ac6c --- /dev/null +++ b/meson/test cases/unit/92 install skip subprojects/foo.h @@ -0,0 +1 @@ +#define FOO diff --git a/meson/test cases/unit/92 install skip subprojects/foo/foofile b/meson/test cases/unit/92 install skip subprojects/foo/foofile new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/meson/test cases/unit/92 install skip subprojects/foo/foofile diff --git a/meson/test cases/unit/92 install skip subprojects/meson.build b/meson/test cases/unit/92 install skip subprojects/meson.build new file mode 100644 index 000000000..cfbae9483 --- /dev/null +++ b/meson/test cases/unit/92 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/meson/test cases/unit/92 install skip subprojects/subprojects/bar/bar.c b/meson/test cases/unit/92 install skip subprojects/subprojects/bar/bar.c new file mode 100644 index 000000000..25927f5a1 --- /dev/null +++ b/meson/test cases/unit/92 install skip subprojects/subprojects/bar/bar.c @@ -0,0 +1,4 @@ +int main(int argc, char *argv[]) +{ + return 0; +} diff --git a/meson/test cases/unit/92 install skip subprojects/subprojects/bar/bar.dat b/meson/test cases/unit/92 install skip subprojects/subprojects/bar/bar.dat new file mode 100644 index 000000000..421376db9 --- /dev/null +++ b/meson/test cases/unit/92 install skip subprojects/subprojects/bar/bar.dat @@ -0,0 +1 @@ +dummy diff --git a/meson/test cases/unit/92 install skip subprojects/subprojects/bar/bar.h b/meson/test cases/unit/92 install skip subprojects/subprojects/bar/bar.h new file mode 100644 index 000000000..a7e26ac6c --- /dev/null +++ b/meson/test cases/unit/92 install skip subprojects/subprojects/bar/bar.h @@ -0,0 +1 @@ +#define FOO diff --git a/meson/test cases/unit/92 install skip subprojects/subprojects/bar/bar/barfile b/meson/test cases/unit/92 install skip subprojects/subprojects/bar/bar/barfile new file mode 100644 index 000000000..421376db9 --- /dev/null +++ b/meson/test cases/unit/92 install skip subprojects/subprojects/bar/bar/barfile @@ -0,0 +1 @@ +dummy diff --git a/meson/test cases/unit/92 install skip subprojects/subprojects/bar/meson.build b/meson/test cases/unit/92 install skip subprojects/subprojects/bar/meson.build new file mode 100644 index 000000000..b5b073408 --- /dev/null +++ b/meson/test cases/unit/92 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/meson/test cases/unit/93 new subproject in configured project/meson.build b/meson/test cases/unit/93 new subproject in configured project/meson.build new file mode 100644 index 000000000..b82aa4173 --- /dev/null +++ b/meson/test cases/unit/93 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/meson/test cases/unit/93 new subproject in configured project/meson_options.txt b/meson/test cases/unit/93 new subproject in configured project/meson_options.txt new file mode 100644 index 000000000..12d8395d4 --- /dev/null +++ b/meson/test cases/unit/93 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/meson/test cases/unit/93 new subproject in configured project/subprojects/sub/foo.c b/meson/test cases/unit/93 new subproject in configured project/subprojects/sub/foo.c new file mode 100644 index 000000000..9713d9f7f --- /dev/null +++ b/meson/test cases/unit/93 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/meson/test cases/unit/93 new subproject in configured project/subprojects/sub/meson.build b/meson/test cases/unit/93 new subproject in configured project/subprojects/sub/meson.build new file mode 100644 index 000000000..a833b0c35 --- /dev/null +++ b/meson/test cases/unit/93 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/meson/test cases/unit/94 clangformat/.clang-format b/meson/test cases/unit/94 clangformat/.clang-format new file mode 100644 index 000000000..689bc6047 --- /dev/null +++ b/meson/test cases/unit/94 clangformat/.clang-format @@ -0,0 +1,4 @@ +--- +BasedOnStyle: Google + +... diff --git a/meson/test cases/unit/94 clangformat/.clang-format-ignore b/meson/test cases/unit/94 clangformat/.clang-format-ignore new file mode 100644 index 000000000..7fc4d5a95 --- /dev/null +++ b/meson/test cases/unit/94 clangformat/.clang-format-ignore @@ -0,0 +1,3 @@ + +# Ignore C files +*.c diff --git a/meson/test cases/unit/94 clangformat/.clang-format-include b/meson/test cases/unit/94 clangformat/.clang-format-include new file mode 100644 index 000000000..f057c0033 --- /dev/null +++ b/meson/test cases/unit/94 clangformat/.clang-format-include @@ -0,0 +1,3 @@ + +# Only reformat in src/ +src/**/* diff --git a/meson/test cases/unit/94 clangformat/meson.build b/meson/test cases/unit/94 clangformat/meson.build new file mode 100644 index 000000000..8f4af981b --- /dev/null +++ b/meson/test cases/unit/94 clangformat/meson.build @@ -0,0 +1 @@ +project('dummy', 'c', 'cpp') diff --git a/meson/test cases/unit/94 clangformat/not-included/badformat.cpp b/meson/test cases/unit/94 clangformat/not-included/badformat.cpp new file mode 100644 index 000000000..99a0ea60c --- /dev/null +++ b/meson/test cases/unit/94 clangformat/not-included/badformat.cpp @@ -0,0 +1,2 @@ +class { +}; diff --git a/meson/test cases/unit/94 clangformat/src/badformat.c b/meson/test cases/unit/94 clangformat/src/badformat.c new file mode 100644 index 000000000..f1d18b7ed --- /dev/null +++ b/meson/test cases/unit/94 clangformat/src/badformat.c @@ -0,0 +1,2 @@ +struct { +}; diff --git a/meson/test cases/unit/94 clangformat/src/badformat.cpp b/meson/test cases/unit/94 clangformat/src/badformat.cpp new file mode 100644 index 000000000..99a0ea60c --- /dev/null +++ b/meson/test cases/unit/94 clangformat/src/badformat.cpp @@ -0,0 +1,2 @@ +class { +}; diff --git a/meson/test cases/unit/95 custominc/easytogrepfor/genh.py b/meson/test cases/unit/95 custominc/easytogrepfor/genh.py new file mode 100644 index 000000000..48e033a72 --- /dev/null +++ b/meson/test cases/unit/95 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/meson/test cases/unit/95 custominc/easytogrepfor/meson.build b/meson/test cases/unit/95 custominc/easytogrepfor/meson.build new file mode 100644 index 000000000..e749753bc --- /dev/null +++ b/meson/test cases/unit/95 custominc/easytogrepfor/meson.build @@ -0,0 +1,3 @@ +genh = custom_target('header', + output: 'generated.h', + command: [find_program('genh.py'), '@OUTPUT@']) diff --git a/meson/test cases/unit/95 custominc/helper.c b/meson/test cases/unit/95 custominc/helper.c new file mode 100644 index 000000000..3237441bc --- /dev/null +++ b/meson/test cases/unit/95 custominc/helper.c @@ -0,0 +1,5 @@ +#include<generated.h> + +int func(void) { + return RETURN_VALUE; +} diff --git a/meson/test cases/unit/95 custominc/meson.build b/meson/test cases/unit/95 custominc/meson.build new file mode 100644 index 000000000..bab113908 --- /dev/null +++ b/meson/test cases/unit/95 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/meson/test cases/unit/95 custominc/prog.c b/meson/test cases/unit/95 custominc/prog.c new file mode 100644 index 000000000..db9df9d5e --- /dev/null +++ b/meson/test cases/unit/95 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/meson/test cases/unit/95 custominc/prog2.c b/meson/test cases/unit/95 custominc/prog2.c new file mode 100644 index 000000000..e64b22919 --- /dev/null +++ b/meson/test cases/unit/95 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/meson/test cases/unit/96 implicit force fallback/meson.build b/meson/test cases/unit/96 implicit force fallback/meson.build new file mode 100644 index 000000000..623a338db --- /dev/null +++ b/meson/test cases/unit/96 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/meson/test cases/unit/96 implicit force fallback/subprojects/something/meson.build b/meson/test cases/unit/96 implicit force fallback/subprojects/something/meson.build new file mode 100644 index 000000000..89a4727dc --- /dev/null +++ b/meson/test cases/unit/96 implicit force fallback/subprojects/something/meson.build @@ -0,0 +1,3 @@ +project('something') + +meson.override_dependency('something', declare_dependency()) diff --git a/meson/test cases/unit/97 link full name/.gitignore b/meson/test cases/unit/97 link full name/.gitignore new file mode 100644 index 000000000..812960172 --- /dev/null +++ b/meson/test cases/unit/97 link full name/.gitignore @@ -0,0 +1,5 @@ +*.a +*.o +a.out +libtestprovider.a +build diff --git a/meson/test cases/unit/97 link full name/libtestprovider/meson.build b/meson/test cases/unit/97 link full name/libtestprovider/meson.build new file mode 100644 index 000000000..5855c8180 --- /dev/null +++ b/meson/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/meson/test cases/unit/97 link full name/libtestprovider/provider.c b/meson/test cases/unit/97 link full name/libtestprovider/provider.c new file mode 100644 index 000000000..5e79966f7 --- /dev/null +++ b/meson/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/meson/test cases/unit/97 link full name/proguser/meson.build b/meson/test cases/unit/97 link full name/proguser/meson.build new file mode 100644 index 000000000..5be5bc998 --- /dev/null +++ b/meson/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/meson/test cases/unit/97 link full name/proguser/receiver.c b/meson/test cases/unit/97 link full name/proguser/receiver.c new file mode 100644 index 000000000..594601cc8 --- /dev/null +++ b/meson/test cases/unit/97 link full name/proguser/receiver.c @@ -0,0 +1,19 @@ +#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; +} + |