From 8d68181e730ad4987d0478979eed78acbde3cb0a Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 24 Sep 2016 12:47:12 +0100 Subject: Build test case libs with bjam, not a messy set of tests --- slicer/db/Jamfile.jam | 6 +++--- slicer/json/Jamfile.jam | 2 +- slicer/test/Jamfile.jam | 51 ++++++++++++++++++++++++++++++-------------- slicer/test/helpers.cpp | 36 ------------------------------- slicer/test/helpers.h | 12 ----------- slicer/test/preprocessor.cpp | 46 --------------------------------------- slicer/tool/Jamfile.jam | 1 + slicer/xml/Jamfile.jam | 2 +- 8 files changed, 41 insertions(+), 115 deletions(-) diff --git a/slicer/db/Jamfile.jam b/slicer/db/Jamfile.jam index 9b51b82..c6915ef 100644 --- a/slicer/db/Jamfile.jam +++ b/slicer/db/Jamfile.jam @@ -40,7 +40,7 @@ run testSelect.cpp boost_system boost_filesystem boost_utf - ../test//slicer-test + ../test//types ../test//common ../slicer//slicer ../slicer//slicer @@ -60,7 +60,7 @@ run testInsert.cpp boost_system boost_filesystem boost_utf - ../test//slicer-test + ../test//types ../test//common ../slicer//slicer ../slicer//slicer @@ -81,7 +81,7 @@ run testUpdate.cpp boost_system boost_filesystem boost_utf - ../test//slicer-test + ../test//types ../test//common ../slicer//slicer ../slicer//slicer diff --git a/slicer/json/Jamfile.jam b/slicer/json/Jamfile.jam index 34ca153..05b5228 100644 --- a/slicer/json/Jamfile.jam +++ b/slicer/json/Jamfile.jam @@ -31,7 +31,7 @@ run testSpecifics.cpp BOOST_TEST_DYN_LINK slicer-json boost_utf - ../test//slicer-test + ../test//types ../test//common ../slicer//slicer .. diff --git a/slicer/test/Jamfile.jam b/slicer/test/Jamfile.jam index 253ab2b..7bf0b05 100644 --- a/slicer/test/Jamfile.jam +++ b/slicer/test/Jamfile.jam @@ -1,4 +1,8 @@ import testing ; +import generators ; +import type ; +import feature ; +import toolset ; lib dl ; lib pthread ; @@ -6,44 +10,68 @@ lib Ice ; lib IceUtil ; lib boost_system ; lib boost_filesystem ; +lib boost_date_time ; lib boost_utf : : boost_unit_test_framework ; -lib slicer-test : : slicertypes bin/slicer ; lib adhocutil : : : : /usr/include/adhocutil ; +generators.register-standard $(__name__).slicer : SLICE : CPP : pure ; +generators.override $(__name__).slicer : slice.slicer.pure ; +feature.feature slicerbin : : free dependency ; +toolset.flags slicer SLICERBIN ; +toolset.flags slicer INCLUDES ; +toolset.flags slicer ALLOWICE yes : --ice ; + +actions slicer bind SLICERBIN +{ + truncate -c -s 0 $(1[1]) + "$(SLICERBIN)" -I"$(INCLUDES)" $(2) $(1[1]) $(ALLOWICE[1]) --headerPrefix="\"\"" +} + +cpp stypes : + types.ice + : + pure + ../tool//slicer + ../tool//slicer + included + ; + lib types : types.ice + stypes + conversions.cpp : . pthread Ice IceUtil adhocutil + boost_date_time included//included + ../slicer//slicer included//included + ../slicer//slicer : : . pthread Ice IceUtil included//included + ../slicer//slicer ; path-constant me : . ; lib common : helpers.cpp - conversions.cpp fileStructure.cpp : - dl - types + adhocutil boost_system boost_filesystem boost_utf - types ROOT=\"$(me)\" : : - types boost_filesystem boost_system BOOST_TEST_DYN_LINK @@ -53,14 +81,10 @@ lib common : run preprocessor.cpp : : : - -rdynamic - dl common adhocutil .. - ../slicer//slicer ../tool//slicer-compiler - ../tool//slicer : preprocess ; @@ -70,19 +94,14 @@ run compilation.cpp .. ../slicer//slicer types - preprocess - slicer-test common - .. - ../slicer//slicer : compilation ; run serializers.cpp : : : - preprocess - slicer-test + types common ../slicer//slicer ../slicer//slicer diff --git a/slicer/test/helpers.cpp b/slicer/test/helpers.cpp index 73f3aa7..956b626 100644 --- a/slicer/test/helpers.cpp +++ b/slicer/test/helpers.cpp @@ -1,21 +1,7 @@ #include "helpers.h" -#include -#include -#include #include #include -void -system(const std::string & cmd) -{ - if (system(cmd.c_str())) { - // LCOV_EXCL_START - fprintf(stderr, "Failed to execute:\n\t%s\n", cmd.c_str()); - throw std::runtime_error(cmd); - // LCOV_EXCL_STOP - } -} - void diff(const boost::filesystem::path & left, const boost::filesystem::path & right) { @@ -29,25 +15,3 @@ diff(const boost::filesystem::path & left, const boost::filesystem::path & right BOOST_REQUIRE_EQUAL(l, r); } -void * -loadlib(const boost::filesystem::path & so) -{ - auto handle = dlopen(so.string().c_str(), RTLD_NOW | RTLD_GLOBAL); - if (!handle) { - // LCOV_EXCL_START - throw std::runtime_error(dlerror()); - // LCOV_EXCL_STOP - } - return handle; -} - -void -closelib(void * handle) -{ - if (dlclose(handle)) { - // LCOV_EXCL_START - throw std::runtime_error(dlerror()); - // LCOV_EXCL_STOP - } -} - diff --git a/slicer/test/helpers.h b/slicer/test/helpers.h index aba4974..95dbd4d 100644 --- a/slicer/test/helpers.h +++ b/slicer/test/helpers.h @@ -6,18 +6,6 @@ #include // These are just thin wrappers that throw exceptions -DLL_PUBLIC -void -system(const std::string &); - -DLL_PUBLIC -void * -loadlib(const boost::filesystem::path &); - -DLL_PUBLIC -void -closelib(void *); - DLL_PUBLIC void diff(const boost::filesystem::path & left, const boost::filesystem::path & right); diff --git a/slicer/test/preprocessor.cpp b/slicer/test/preprocessor.cpp index b715d50..fadbac9 100644 --- a/slicer/test/preprocessor.cpp +++ b/slicer/test/preprocessor.cpp @@ -2,12 +2,8 @@ #include #include -#include -#include #include -#include #include -#include #include "helpers.h" #include "fileStructure.h" @@ -63,47 +59,5 @@ BOOST_AUTO_TEST_CASE( slicer_test_counts_interfacesOnly ) BOOST_REQUIRE_EQUAL(0, count); } -BOOST_AUTO_TEST_CASE( slicer_test_ice ) -{ - const fs::path cpp = fs::change_extension(tmp / base, ".cpp"); - BOOST_TEST_CHECKPOINT("cpp: " << cpp); - fs::remove(cpp); - const std::string doslice = stringbf( - "%s -I%s --headerPrefix='\"\"' %s %s", - root.parent_path() / "tool" / bjamout / "slicer", - included, - slice, cpp); - BOOST_TEST_CHECKPOINT("slicer: " << doslice); - system(doslice); - - const fs::path obj = fs::change_extension(tmp / base, ".o"); - const std::string compile = stringbf( - "g++ -Os -fPIC -c -std=c++1y -fvisibility=hidden -I%s -I tmp -I /usr/include/adhocutil -I /usr/include/Ice -I /usr/include/IceUtil -I %s -I %s -I %s -I %s -I %s %s -o %s", - root.parent_path() / "slicer", - root / bjamout, - root, - included / bjamout, - root.parent_path(), - root.parent_path() / "slicer" / bjamout, - cpp, obj); - BOOST_TEST_CHECKPOINT("compile: " << compile); - system(compile); - - const fs::path so = fs::change_extension(tmp / ("libslicer" + slice.filename().string()), ".so"); - const std::string link = stringbf( - "g++ -shared -Wl,--strip-all,--gc-sections -lboost_date_time -lIce -lIceUtil %s/lib%s.so %s/lib%s.so %s -o %s", - root / bjamout, base, - included / bjamout, included.leaf(), - obj, so); - BOOST_TEST_CHECKPOINT("link: " << link); - system(link); - - BOOST_TEST_CHECKPOINT("load: " << so); - auto handle = loadlib(so); - - BOOST_TEST_CHECKPOINT("unload: " << handle); - closelib(handle); -} - BOOST_AUTO_TEST_SUITE_END(); diff --git a/slicer/tool/Jamfile.jam b/slicer/tool/Jamfile.jam index c5f94a3..cc0ace7 100644 --- a/slicer/tool/Jamfile.jam +++ b/slicer/tool/Jamfile.jam @@ -22,6 +22,7 @@ lib slicer-compiler : .. : : .. + ../slicer//slicer ; exe slicer : diff --git a/slicer/xml/Jamfile.jam b/slicer/xml/Jamfile.jam index 0d170da..d16fc8a 100644 --- a/slicer/xml/Jamfile.jam +++ b/slicer/xml/Jamfile.jam @@ -33,7 +33,7 @@ run testSpecifics.cpp slicer-xml slicer-xml boost_utf - ../test//slicer-test + ../test//types ../test//common ../slicer//slicer .. -- cgit v1.2.3