summaryrefslogtreecommitdiffstats
path: root/test cases/frameworks/1 boost
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
commit7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch)
tree4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/frameworks/1 boost
parentInitial commit. (diff)
downloadmeson-upstream.tar.xz
meson-upstream.zip
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test cases/frameworks/1 boost')
-rw-r--r--test cases/frameworks/1 boost/extralib.cpp27
-rw-r--r--test cases/frameworks/1 boost/linkexe.cc18
-rw-r--r--test cases/frameworks/1 boost/meson.build74
-rw-r--r--test cases/frameworks/1 boost/meson_options.txt1
-rw-r--r--test cases/frameworks/1 boost/nomod.cpp18
-rw-r--r--test cases/frameworks/1 boost/partial_dep/foo.cpp20
-rw-r--r--test cases/frameworks/1 boost/partial_dep/foo.hpp27
-rw-r--r--test cases/frameworks/1 boost/partial_dep/main.cpp27
-rw-r--r--test cases/frameworks/1 boost/partial_dep/meson.build31
-rw-r--r--test cases/frameworks/1 boost/python_module.cpp22
-rw-r--r--test cases/frameworks/1 boost/test.json22
-rw-r--r--test cases/frameworks/1 boost/test_python_module.py27
-rw-r--r--test cases/frameworks/1 boost/unit_test.cpp9
13 files changed, 323 insertions, 0 deletions
diff --git a/test cases/frameworks/1 boost/extralib.cpp b/test cases/frameworks/1 boost/extralib.cpp
new file mode 100644
index 0000000..e5ab1b0
--- /dev/null
+++ b/test cases/frameworks/1 boost/extralib.cpp
@@ -0,0 +1,27 @@
+#define _XOPEN_SOURCE 500
+
+#include <iostream>
+#include <boost/log/trivial.hpp>
+#include <boost/log/expressions.hpp>
+#include <boost/log/utility/setup/console.hpp>
+#include <boost/log/utility/setup/common_attributes.hpp>
+
+using namespace std;
+namespace logging = boost::log;
+
+void InitLogger() {
+ logging::add_common_attributes();
+ logging::register_simple_formatter_factory<logging::trivial::severity_level, char>("Severity");
+ string log_format = "%TimeStamp% [%Severity%] - %Message%";
+
+ logging::add_console_log(
+ cout,
+ logging::keywords::format = log_format
+ );
+}
+
+int main(int argc, char **argv) {
+ InitLogger();
+ BOOST_LOG_TRIVIAL(trace) << "SOMETHING";
+ return 0;
+}
diff --git a/test cases/frameworks/1 boost/linkexe.cc b/test cases/frameworks/1 boost/linkexe.cc
new file mode 100644
index 0000000..e00edee
--- /dev/null
+++ b/test cases/frameworks/1 boost/linkexe.cc
@@ -0,0 +1,18 @@
+#define _XOPEN_SOURCE 500
+
+#include<boost/thread.hpp>
+
+boost::recursive_mutex m;
+
+struct callable {
+ void operator()() {
+ boost::recursive_mutex::scoped_lock l(m);
+ };
+};
+
+int main(int argc, char **argv) {
+ callable x;
+ boost::thread thr(x);
+ thr.join();
+ return 0;
+}
diff --git a/test cases/frameworks/1 boost/meson.build b/test cases/frameworks/1 boost/meson.build
new file mode 100644
index 0000000..821bb62
--- /dev/null
+++ b/test cases/frameworks/1 boost/meson.build
@@ -0,0 +1,74 @@
+# this test requires the following on Ubuntu: libboost-{system,python,log,thread,test}-dev
+project('boosttest', 'cpp',
+ default_options : ['cpp_std=c++14'])
+
+s = get_option('static')
+
+dep = dependency('boost', static: s, required: false)
+if not dep.found()
+ error('MESON_SKIP_TEST boost not found.')
+endif
+
+# We want to have multiple separate configurations of Boost
+# within one project. The need to be independent of each other.
+# Use one without a library dependency and one with it.
+
+linkdep = dependency('boost', static: s, modules : ['thread', 'system', 'date_time'])
+testdep = dependency('boost', static: s, modules : ['unit_test_framework'])
+nomoddep = dependency('boost', static: s)
+extralibdep = dependency('boost', static: s, modules : ['thread', 'system', 'date_time', 'log_setup', 'log', 'filesystem', 'regex'])
+notfound = dependency('boost', static: s, modules : ['this_should_not_exist_on_any_systen'], required: false)
+
+assert(not notfound.found())
+
+require_bp = host_machine.system() in ['linux', 'darwin']
+pymod = import('python')
+python2 = pymod.find_installation('python2', required: false , disabler: true)
+python3 = pymod.find_installation('python3', required: require_bp , disabler: true)
+python2dep = python2.dependency(required: false , embed: true, disabler: true)
+python3dep = python3.dependency(required: require_bp, embed: true, disabler: true)
+
+# compile python 2/3 modules only if we found a corresponding python version
+if(python2dep.found() and require_bp and not s)
+ bpython2dep = dependency('boost', static: s, modules : ['python'], required: false, disabler: true)
+else
+ python2dep = disabler()
+ bpython2dep = disabler()
+endif
+
+if(python3dep.found() and require_bp and not s)
+ bpython3dep = dependency('boost', static: s, modules : ['python3'])
+else
+ python3dep = disabler()
+ bpython3dep = disabler()
+endif
+
+linkexe = executable('linkedexe', 'linkexe.cc', dependencies : linkdep)
+unitexe = executable('utf', 'unit_test.cpp', dependencies: testdep)
+nomodexe = executable('nomod', 'nomod.cpp', dependencies : nomoddep)
+extralibexe = executable('extralibexe', 'extralib.cpp', dependencies : extralibdep)
+
+# python modules are shared libraries
+python2module = python2.extension_module('python2_module', ['python_module.cpp'], dependencies: [python2dep, bpython2dep], cpp_args: ['-DMOD_NAME=python2_module'])
+python3module = python3.extension_module('python3_module', ['python_module.cpp'], dependencies: [python3dep, bpython3dep], cpp_args: ['-DMOD_NAME=python3_module'])
+
+
+test('Boost linktest', linkexe, timeout: 60)
+test('Boost UTF test', unitexe, timeout: 60)
+test('Boost nomod', nomodexe)
+if host_machine.system() != 'darwin' or s
+ # Segfaults on macOS with dynamic linking since Boost 1.73
+ # https://github.com/mesonbuild/meson/issues/7535
+ test('Boost extralib test', extralibexe)
+endif
+
+# explicitly use the correct python interpreter so that we don't have to provide two different python scripts that have different shebang lines
+python2interpreter = find_program(python2.path(), required: false, disabler: true)
+test('Boost Python2', python2interpreter, args: ['./test_python_module.py', meson.current_build_dir()], workdir: meson.current_source_dir(), depends: python2module)
+python3interpreter = find_program(python3.path(), required: false, disabler: true)
+test('Boost Python3', python3interpreter, args: ['./test_python_module.py', meson.current_build_dir()], workdir: meson.current_source_dir(), depends: python3module)
+
+subdir('partial_dep')
+
+# check we can apply a version constraint
+dependency('boost', static: s, version: '>=@0@'.format(dep.version()))
diff --git a/test cases/frameworks/1 boost/meson_options.txt b/test cases/frameworks/1 boost/meson_options.txt
new file mode 100644
index 0000000..019feaf
--- /dev/null
+++ b/test cases/frameworks/1 boost/meson_options.txt
@@ -0,0 +1 @@
+option('static', type: 'boolean', value: false)
diff --git a/test cases/frameworks/1 boost/nomod.cpp b/test cases/frameworks/1 boost/nomod.cpp
new file mode 100644
index 0000000..55c95b2
--- /dev/null
+++ b/test cases/frameworks/1 boost/nomod.cpp
@@ -0,0 +1,18 @@
+#include<boost/any.hpp>
+#include<iostream>
+
+boost::any get_any() {
+ boost::any foobar = 3;
+ return foobar;
+}
+
+int main(int argc, char **argv) {
+ boost::any result = get_any();
+ if(boost::any_cast<int>(result) == 3) {
+ std::cout << "Everything is fine in the world.\n";
+ return 0;
+ } else {
+ std::cout << "Mathematics stopped working.\n";
+ return 1;
+ }
+}
diff --git a/test cases/frameworks/1 boost/partial_dep/foo.cpp b/test cases/frameworks/1 boost/partial_dep/foo.cpp
new file mode 100644
index 0000000..da58703
--- /dev/null
+++ b/test cases/frameworks/1 boost/partial_dep/foo.cpp
@@ -0,0 +1,20 @@
+/* Copyright © 2018 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.
+ */
+
+#include "foo.hpp"
+
+vec Foo::vector() {
+ return myvec;
+}
diff --git a/test cases/frameworks/1 boost/partial_dep/foo.hpp b/test cases/frameworks/1 boost/partial_dep/foo.hpp
new file mode 100644
index 0000000..393d3f6
--- /dev/null
+++ b/test cases/frameworks/1 boost/partial_dep/foo.hpp
@@ -0,0 +1,27 @@
+/* Copyright © 2018 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.
+ */
+
+#include <boost/fusion/container/vector.hpp>
+
+typedef boost::fusion::vector<int> vec;
+
+
+class Foo {
+ public:
+ Foo() {};
+ vec vector();
+ private:
+ const vec myvec = vec(4);
+};
diff --git a/test cases/frameworks/1 boost/partial_dep/main.cpp b/test cases/frameworks/1 boost/partial_dep/main.cpp
new file mode 100644
index 0000000..b22ce3a
--- /dev/null
+++ b/test cases/frameworks/1 boost/partial_dep/main.cpp
@@ -0,0 +1,27 @@
+/* Copyright © 2018 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.
+ */
+
+#include <iostream>
+#include <boost/fusion/include/at_c.hpp>
+#include "foo.hpp"
+
+
+int main(void) {
+ auto foo = Foo();
+ vec v = foo.vector();
+ std::cout << boost::fusion::at_c<0>(v) << std::endl;
+
+ return 0;
+}
diff --git a/test cases/frameworks/1 boost/partial_dep/meson.build b/test cases/frameworks/1 boost/partial_dep/meson.build
new file mode 100644
index 0000000..9d481bb
--- /dev/null
+++ b/test cases/frameworks/1 boost/partial_dep/meson.build
@@ -0,0 +1,31 @@
+# Copyright © 2018 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.
+
+dep_boost = dependency('boost')
+dep_boost_headers = dep_boost.partial_dependency(compile_args : true)
+
+libfoo = static_library(
+ 'foo',
+ 'foo.cpp',
+ dependencies : dep_boost_headers,
+)
+
+exe_external_dep = executable(
+ 'external_dep',
+ 'main.cpp',
+ dependencies : dep_boost,
+ link_with : libfoo
+)
+
+test('External Dependency', exe_external_dep)
diff --git a/test cases/frameworks/1 boost/python_module.cpp b/test cases/frameworks/1 boost/python_module.cpp
new file mode 100644
index 0000000..a0f010b
--- /dev/null
+++ b/test cases/frameworks/1 boost/python_module.cpp
@@ -0,0 +1,22 @@
+#define PY_SSIZE_T_CLEAN
+#include <Python.h>
+#include <boost/python.hpp>
+
+struct World
+{
+ void set(std::string msg) { this->msg = msg; }
+ std::string greet() { return msg; }
+ std::string version() { return std::to_string(PY_MAJOR_VERSION) + "." + std::to_string(PY_MINOR_VERSION); }
+ std::string msg;
+};
+
+
+BOOST_PYTHON_MODULE(MOD_NAME)
+{
+ using namespace boost::python;
+ class_<World>("World")
+ .def("greet", &World::greet)
+ .def("set", &World::set)
+ .def("version", &World::version)
+ ;
+}
diff --git a/test cases/frameworks/1 boost/test.json b/test cases/frameworks/1 boost/test.json
new file mode 100644
index 0000000..2c5b857
--- /dev/null
+++ b/test cases/frameworks/1 boost/test.json
@@ -0,0 +1,22 @@
+{
+ "matrix": {
+ "options": {
+ "static": [
+ { "val": "true", "skip_on_env": [ "SKIP_STATIC_BOOST" ] },
+ { "val": "false" }
+ ],
+ "b_vscrt": [
+ { "val": null },
+ { "val": "md", "compilers": { "cpp": "msvc" } },
+ { "val": "mdd", "compilers": { "cpp": "msvc" } },
+ { "val": "mt", "compilers": { "cpp": "msvc" } },
+ { "val": "mtd", "compilers": { "cpp": "msvc" } }
+ ]
+ },
+ "exclude": [
+ { "static": "false", "b_vscrt": "mt" },
+ { "static": "false", "b_vscrt": "mtd" }
+ ]
+ },
+ "skip_on_jobname": ["azure", "msys2"]
+}
diff --git a/test cases/frameworks/1 boost/test_python_module.py b/test cases/frameworks/1 boost/test_python_module.py
new file mode 100644
index 0000000..8ef96d2
--- /dev/null
+++ b/test cases/frameworks/1 boost/test_python_module.py
@@ -0,0 +1,27 @@
+import sys
+sys.path.append(sys.argv[1])
+
+# import compiled python module depending on version of python we are running with
+if sys.version_info[0] == 2:
+ import python2_module
+
+if sys.version_info[0] == 3:
+ import python3_module
+
+
+def run():
+ msg = 'howdy'
+ if sys.version_info[0] == 2:
+ w = python2_module.World()
+
+ if sys.version_info[0] == 3:
+ w = python3_module.World()
+
+ w.set(msg)
+
+ assert msg == w.greet()
+ version_string = str(sys.version_info[0]) + "." + str(sys.version_info[1])
+ assert version_string == w.version()
+
+if __name__ == '__main__':
+ run()
diff --git a/test cases/frameworks/1 boost/unit_test.cpp b/test cases/frameworks/1 boost/unit_test.cpp
new file mode 100644
index 0000000..fa1fbaa
--- /dev/null
+++ b/test cases/frameworks/1 boost/unit_test.cpp
@@ -0,0 +1,9 @@
+#define BOOST_TEST_MODULE "MesonTest"
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+BOOST_AUTO_TEST_CASE(m_test) {
+ int x = 2+2;
+ BOOST_CHECK(true);
+ BOOST_CHECK_EQUAL(x, 4);
+}