From e662fe827fe86c943f9df070440bebca93ccceab Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 9 Dec 2014 15:13:50 +0000 Subject: Support complex types in rows and parameters --- Jamroot.jam | 7 ++- project2/ice/Jamfile.jam | 2 + project2/ice/iceClient.h | 1 - project2/ice/iceConvert.h | 14 +---- project2/ice/iceModule.h | 1 + project2/ice/slice2Daemon.cpp | 10 +--- project2/ice/unittests/Jamfile.jam | 32 ++++++++--- project2/ice/unittests/conversions.cpp | 44 +++++++++++++++ project2/ice/unittests/data/unittest-data.xml | 5 ++ .../ice/unittests/expected/clientPresenter.log | 9 +++ project2/ice/unittests/lib/testrows.xml | 7 +++ .../ComplexInterface/ComplexParam.xml | 8 +++ project2/ice/unittests/testClient.cpp | 50 ++++++++++++++++- project2/ice/unittests/testClient.xml | 6 ++ project2/ice/unittests/testClientCompile.cpp | 10 +++- project2/ice/unittests/testDaemon.cpp | 65 +++++++++++++++++++++- project2/ice/unittests/testDaemonCompile.cpp | 5 +- project2/ice/unittests/unittestComplex.ice | 30 ++++++++++ .../ComplexInterface/ComplexRow.xml | 5 ++ 19 files changed, 272 insertions(+), 39 deletions(-) create mode 100644 project2/ice/unittests/conversions.cpp create mode 100644 project2/ice/unittests/tasks/UnitTestComplex/ComplexInterface/ComplexParam.xml create mode 100644 project2/ice/unittests/unittestComplex.ice create mode 100644 project2/ice/unittests/views/UnitTestComplex/ComplexInterface/ComplexRow.xml diff --git a/Jamroot.jam b/Jamroot.jam index 396dfd0..fe9fa3f 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -3,11 +3,16 @@ import slice ; using gcc : : [ os.environ CXX ] ; +variant component ; + project : requirements release:"-std=c++0x" + release:"-Wl,-z,defs,--warn-once" debug:"-W -Wall -Werror -Wwrite-strings -std=c++0x" - "-Wl,-z,defs,--warn-once" + debug:"-Wl,-z,defs,--warn-once" + component:"-W -Wall -Werror -Wwrite-strings -std=c++0x -fPIC" + component:"-Wl,-z,lazy,--warn-once,-fPIC" ; diff --git a/project2/ice/Jamfile.jam b/project2/ice/Jamfile.jam index fe224b2..d90ec9f 100644 --- a/project2/ice/Jamfile.jam +++ b/project2/ice/Jamfile.jam @@ -75,5 +75,7 @@ lib p2ice : slicer IceUtil boost_filesystem + : : + -rdynamic ; diff --git a/project2/ice/iceClient.h b/project2/ice/iceClient.h index 93042fd..1d198f1 100644 --- a/project2/ice/iceClient.h +++ b/project2/ice/iceClient.h @@ -3,7 +3,6 @@ #include #include -#include #include "iceDataSource.h" class IceClientBase { diff --git a/project2/ice/iceConvert.h b/project2/ice/iceConvert.h index 86e42d4..7d68b9f 100644 --- a/project2/ice/iceConvert.h +++ b/project2/ice/iceConvert.h @@ -2,8 +2,7 @@ #define ICECONVERT_H #include -#include -#include +#include template class IceConvert { @@ -32,16 +31,5 @@ class IceConvert> { } }; -typedef boost::function IceEachDataMemberName; -typedef boost::function IceEachDataMemberValue; - -template -class IceType { - public: - static void CreateColumns(const IceEachDataMemberName & func); - static void ForEachDataMember(const IceInternal::Handle< RowType > & ptr, const IceEachDataMemberValue & func); - static void ForEachDataMember(const RowType & ptr, const IceEachDataMemberValue & func); -}; - #endif diff --git a/project2/ice/iceModule.h b/project2/ice/iceModule.h index 168e134..fcdd3e4 100644 --- a/project2/ice/iceModule.h +++ b/project2/ice/iceModule.h @@ -8,6 +8,7 @@ #include #include #include +#include "iceConvert.h" typedef std::map ParamMap; class IceDaemon; diff --git a/project2/ice/slice2Daemon.cpp b/project2/ice/slice2Daemon.cpp index 05be959..98a3883 100644 --- a/project2/ice/slice2Daemon.cpp +++ b/project2/ice/slice2Daemon.cpp @@ -88,14 +88,8 @@ Slice2Daemon::visitParameterMap(const Slice::OperationPtr & o) fprintf(code, "\t\t\t\tParamMap params {\n"); BOOST_FOREACH(const auto & p, o->parameters()) { Slice::StructPtr s = dynamic_cast(p->type().get()); - if (s) { - BOOST_FOREACH(const auto & m, s->dataMembers()) { - fprintf(code, "\t\t\t\t\t\t{\"%s.%s\", %s.%s},\n", p->name().c_str(), m->name().c_str(), p->name().c_str(), m->name().c_str()); - } - } - else { - fprintf(code, "\t\t\t\t\t\t{\"%s\", %s},\n", p->name().c_str(), p->name().c_str()); - } + fprintf(code, "\t\t\t\t\t\t{\"%s\", IceConvert< %s >::ToVariable(%s) },\n", + p->name().c_str(), Slice::typeToString(p->type()).c_str(), p->name().c_str()); } fprintf(code, "\t\t\t\t\t};\n"); } diff --git a/project2/ice/unittests/Jamfile.jam b/project2/ice/unittests/Jamfile.jam index ee31919..8e83b1c 100644 --- a/project2/ice/unittests/Jamfile.jam +++ b/project2/ice/unittests/Jamfile.jam @@ -1,25 +1,37 @@ import testing ; +lib unittestc : + unittestComplex.ice conversions.cpp + : + yes + ..//slicer + component + .. + ../../common + ../../lib + ../../../libmisc + ..//glibmm + : : + . + ; + lib unittest : - [ glob *.ice ] + unittest.ice unittestTypes.ice : no - ..//Ice - ..//IceUtil - ..//pthread + ..//slicer + component : : . ..//pthread ; lib unittestr : - [ glob *.ice ] + unittest.ice unittestTypes.ice : yes - ..//Ice ..//slicer - ..//IceUtil - ..//pthread + component : : . ..//pthread @@ -49,6 +61,7 @@ unit-test testClient : ROOT=\"$(me)\" unittest.ice unittestr + unittestc unittestr ..//p2iceclient ../../ut//p2ut @@ -81,6 +94,7 @@ unit-test testDaemon : ROOT=\"$(me)\" unittest.ice unittestr + unittestc unittestr ..//p2icedaemon ../../ut//p2ut @@ -95,5 +109,7 @@ unit-test testDaemon : tasks/UnitTest/SimpleInterface/SomeTaskParams.xml views/UnitTest/SimpleInterface/SomeRows.xml views/UnitTest/SimpleInterface/SomeRowsParams.xml + views/UnitTestComplex/ComplexInterface/ComplexRow.xml + tasks/UnitTestComplex/ComplexInterface/ComplexParam.xml ; diff --git a/project2/ice/unittests/conversions.cpp b/project2/ice/unittests/conversions.cpp new file mode 100644 index 0000000..e6be3f8 --- /dev/null +++ b/project2/ice/unittests/conversions.cpp @@ -0,0 +1,44 @@ +#include +#include "iceConvert.h" +#include + +namespace Slicer { + boost::posix_time::ptime + dateTimeToPTime(const UnitTestComplex::DatePtr & dt) + { + Logger()->messagebf(LOG_DEBUG, "%s", __PRETTY_FUNCTION__); + return boost::posix_time::ptime( + boost::gregorian::date(dt->year, dt->month, dt->day), + boost::posix_time::time_duration(dt->hours, dt->minutes, dt->seconds)); + } + + UnitTestComplex::DatePtr + ptimeToDateTime(const boost::posix_time::ptime & pt) + { + Logger()->messagebf(LOG_DEBUG, "%s", __PRETTY_FUNCTION__); + return new UnitTestComplex::Date { + pt.date().year(), + pt.date().month(), + pt.date().day(), + pt.time_of_day().hours(), + pt.time_of_day().minutes(), + pt.time_of_day().seconds() }; + } +} + +template<> +::UnitTestComplex::DatePtr +IceConvert< ::UnitTestComplex::DatePtr >::FromVariable(const VariableType & vt) +{ + Logger()->messagebf(LOG_DEBUG, "%s", __PRETTY_FUNCTION__); + return Slicer::ptimeToDateTime(vt); +} + +template<> +VariableType +IceConvert< ::UnitTestComplex::DatePtr >::ToVariable(const ::UnitTestComplex::DatePtr & d) +{ + Logger()->messagebf(LOG_DEBUG, "%s", __PRETTY_FUNCTION__); + return Slicer::dateTimeToPTime(d); +} + diff --git a/project2/ice/unittests/data/unittest-data.xml b/project2/ice/unittests/data/unittest-data.xml index d4b76df..9b4b474 100644 --- a/project2/ice/unittests/data/unittest-data.xml +++ b/project2/ice/unittests/data/unittest-data.xml @@ -1,5 +1,10 @@ + + 4 + complex + 1980-07-09 01:02:03 + 1 first diff --git a/project2/ice/unittests/expected/clientPresenter.log b/project2/ice/unittests/expected/clientPresenter.log index cebd0bf..6114459 100644 --- a/project2/ice/unittests/expected/clientPresenter.log +++ b/project2/ice/unittests/expected/clientPresenter.log @@ -35,3 +35,12 @@ addNamedValue: b=after finishRow finishArray: (1) finishRowSet +addNewRowSet: complex +addNewArray: rec(1) +addNewRow: rec +addNamedValue: a=3 +addNamedValue: b=single +addNamedValue: d=1980-Jul-09 01:02:03 +finishRow +finishArray: (1) +finishRowSet diff --git a/project2/ice/unittests/lib/testrows.xml b/project2/ice/unittests/lib/testrows.xml index 75578d6..e6d1af6 100644 --- a/project2/ice/unittests/lib/testrows.xml +++ b/project2/ice/unittests/lib/testrows.xml @@ -2,6 +2,13 @@ /unittest-data.xml + + + + + + + diff --git a/project2/ice/unittests/tasks/UnitTestComplex/ComplexInterface/ComplexParam.xml b/project2/ice/unittests/tasks/UnitTestComplex/ComplexInterface/ComplexParam.xml new file mode 100644 index 0000000..4d81c9e --- /dev/null +++ b/project2/ice/unittests/tasks/UnitTestComplex/ComplexInterface/ComplexParam.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/project2/ice/unittests/testClient.cpp b/project2/ice/unittests/testClient.cpp index 4c89184..687ba73 100644 --- a/project2/ice/unittests/testClient.cpp +++ b/project2/ice/unittests/testClient.cpp @@ -2,6 +2,8 @@ #include #include #include "iceClient.h" +#include +#include #include #include #include @@ -10,13 +12,17 @@ #include #include #include +#include #define XSTR(s) STR(s) #define STR(s) #s const auto bindir = boost::filesystem::canonical("/proc/self/exe").parent_path(); +const auto componentdir = bindir.parent_path() / "component"; const boost::filesystem::path iceroot(XSTR(ROOT)); const auto headers = iceroot.parent_path().parent_path(); +BOOST_TEST_DONT_PRINT_LOG_VALUE( ::UnitTestComplex::Date ); + class Dummy : public UnitTest::SimpleInterface { public: Dummy() : @@ -55,8 +61,38 @@ class Dummy : public UnitTest::SimpleInterface { execCount += 1; } - void SomeTaskParams(Ice::Int, const std::string&, const Ice::Current&) + void SomeTaskParams(Ice::Int a, const std::string & b, const Ice::Current&) + { + BOOST_REQUIRE_EQUAL(a, 1); + BOOST_REQUIRE_EQUAL(b, "first"); + execCount += 1; + } + + unsigned int execCount; +}; + +class DummyComplex : public UnitTestComplex::ComplexInterface { + public: + DummyComplex() : + execCount(0) + { + } + + UnitTestComplex::ComplexPtr ComplexRow(const Ice::Current&) + { + return new UnitTestComplex::Complex { 3, "single", new UnitTestComplex::Date { 1980, 7, 9, 1, 2, 3 } }; + } + + void ComplexParam(Ice::Int a, const std::string & b, const UnitTestComplex::DatePtr & d, const Ice::Current&) { + BOOST_REQUIRE_EQUAL(a, 1); + BOOST_REQUIRE_EQUAL(b, "first"); + BOOST_REQUIRE_EQUAL(d->year, 1980); + BOOST_REQUIRE_EQUAL(d->month, 7); + BOOST_REQUIRE_EQUAL(d->day, 9); + BOOST_REQUIRE_EQUAL(d->hours, 1); + BOOST_REQUIRE_EQUAL(d->minutes, 2); + BOOST_REQUIRE_EQUAL(d->seconds, 3); execCount += 1; } @@ -74,6 +110,8 @@ commonTests() BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SingleRow")); BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRows")); BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRowsParams")); + BOOST_REQUIRE(ElementLoader::getFor("UnitTestComplex-ComplexInterface-ComplexParam")); + BOOST_REQUIRE(ElementLoader::getFor("UnitTestComplex-ComplexInterface-ComplexRow")); BOOST_TEST_CHECKPOINT("Load test script"); ScriptReaderPtr r = new XmlScriptParser(iceroot / "testClient.xml"); @@ -83,15 +121,19 @@ commonTests() Ice::CommunicatorPtr ic = Ice::initialize(paramCount, NULL); auto adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12000"); IceUtil::Handle dummy = new Dummy(); + IceUtil::Handle dummyComplex = new DummyComplex(); adapter->add(dummy, ic->stringToIdentity("testObject")); + adapter->add(dummyComplex, ic->stringToIdentity("testObjectComplex")); adapter->activate(); ScopeObject _([&ic]{ ic->destroy(); }); BOOST_TEST_CHECKPOINT("Execute test script"); boost::intrusive_ptr sr = new TestScriptHost(r); BOOST_REQUIRE_EQUAL(dummy->execCount, 0); + BOOST_REQUIRE_EQUAL(dummyComplex->execCount, 0); sr->process(NULL); BOOST_REQUIRE_EQUAL(dummy->execCount, 4); + BOOST_REQUIRE_EQUAL(dummyComplex->execCount, 1); BOOST_REQUIRE_EQUAL(sr->GetPresenterData(), iceroot / "expected" / "clientPresenter.log"); } @@ -105,6 +147,8 @@ unloadTests() BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SingleRow"), NotSupported); BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRows"), NotSupported); BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRowsParams"), NotSupported); + BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTestComplex-ComplexInterface-ComplexParam"), NotSupported); + BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTestComplex-ComplexInterface-ComplexRow"), NotSupported); } void test_client_run(const boost::filesystem::path & tmpdir); @@ -122,10 +166,10 @@ void test_client_run(const boost::filesystem::path & tmpdir) { BOOST_TEST_CHECKPOINT("Configure, compile, link, load"); TestOptionsSource::LoadTestOptions({ - { "library", (bindir / "slicer-yes" / "libunittestr.so").string() }, { "common.datasourceRoot", iceroot.string() }, { "ice.compile.tmpdir", tmpdir.string() }, { "ice.compile.headers", headers.string() }, + { "ice.client.slicerclient", (iceroot / "unittestComplex.ice").string() }, { "ice.client.slicerclient", (iceroot / "unittestTypes.ice").string() }, { "ice.client.slicerclient", (iceroot / "unittest.ice").string() } }); @@ -133,6 +177,8 @@ void test_client_run(const boost::filesystem::path & tmpdir) BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittest.client.so")); BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.so")); BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.client.so")); + BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestComplex.so")); + BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittestComplex.client.so")); commonTests(); TestOptionsSource::LoadTestOptions({ }); diff --git a/project2/ice/unittests/testClient.xml b/project2/ice/unittests/testClient.xml index c8fb208..9a9d6f0 100644 --- a/project2/ice/unittests/testClient.xml +++ b/project2/ice/unittests/testClient.xml @@ -6,7 +6,13 @@ + + + + + + diff --git a/project2/ice/unittests/testClientCompile.cpp b/project2/ice/unittests/testClientCompile.cpp index 213497e..2792ef0 100644 --- a/project2/ice/unittests/testClientCompile.cpp +++ b/project2/ice/unittests/testClientCompile.cpp @@ -12,6 +12,7 @@ #define XSTR(s) STR(s) #define STR(s) #s const auto bindir = boost::filesystem::canonical("/proc/self/exe").parent_path(); +const auto componentdir = bindir.parent_path() / "component"; const boost::filesystem::path iceroot(XSTR(ROOT)); const auto headers = iceroot.parent_path().parent_path(); @@ -22,6 +23,7 @@ commonTests() BOOST_TEST_CHECKPOINT("Verify loaded"); BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTask")); BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTaskParams")); + BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SingleRow")); BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRows")); BOOST_REQUIRE(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRowsParams")); } @@ -33,12 +35,15 @@ unloadTests() BOOST_TEST_CHECKPOINT("Verify unloaded"); BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTask"), NotSupported); BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeTaskParams"), NotSupported); + BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SingleRow"), NotSupported); BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRows"), NotSupported); BOOST_REQUIRE_THROW(ElementLoader::getFor("UnitTest-SimpleInterface-SomeRowsParams"), NotSupported); } BOOST_AUTO_TEST_CASE( compile_client_full ) { + TestOptionsSource::LoadTestOptions({ }); + const boost::filesystem::path tmpdir = "/tmp/ut/project2.slice-clientCompile/full"; BOOST_TEST_CHECKPOINT("Clean up"); boost::filesystem::remove_all(tmpdir); @@ -69,7 +74,7 @@ BOOST_AUTO_TEST_CASE( compile_client_clientOnly ) BOOST_TEST_CHECKPOINT("Configure, compile, link, load"); TestOptionsSource::LoadTestOptions({ - { "library", (bindir / "libunittest.so").string() }, + { "library", (componentdir / "libunittest.so").string() }, { "common.datasourceRoot", iceroot.string() }, { "ice.compile.tmpdir", tmpdir.string() }, { "ice.compile.headers", headers.string() }, @@ -88,13 +93,14 @@ BOOST_AUTO_TEST_CASE( compile_client_clientOnly ) BOOST_AUTO_TEST_CASE( compile_client_slicer ) { + TestOptionsSource::LoadTestOptions({ }); const boost::filesystem::path tmpdir = "/tmp/ut/project2.slice-clientCompile/slicer"; BOOST_TEST_CHECKPOINT("Clean up"); boost::filesystem::remove_all(tmpdir); BOOST_TEST_CHECKPOINT("Configure, compile, link, load"); TestOptionsSource::LoadTestOptions({ - { "library", (bindir / "slicer-yes" / "libunittestr.so").string() }, + { "library", (componentdir / "slicer-yes" / "libunittestr.so").string() }, { "common.datasourceRoot", iceroot.string() }, { "ice.compile.tmpdir", tmpdir.string() }, { "ice.compile.headers", headers.string() }, diff --git a/project2/ice/unittests/testDaemon.cpp b/project2/ice/unittests/testDaemon.cpp index e1b1b9e..1c53d6c 100644 --- a/project2/ice/unittests/testDaemon.cpp +++ b/project2/ice/unittests/testDaemon.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -11,6 +12,7 @@ #define XSTR(s) STR(s) #define STR(s) #s const auto bindir = boost::filesystem::canonical("/proc/self/exe").parent_path(); +const auto componentdir = bindir.parent_path() / "component"; const boost::filesystem::path iceroot(XSTR(ROOT)); const auto headers = iceroot.parent_path().parent_path(); @@ -56,23 +58,60 @@ unsigned int DummyParamTask::execCount = 0; VariableType DummyParamTask::execA; VariableType DummyParamTask::execB; +class DummyComplexParamTask : public Task { + public: + DummyComplexParamTask(ScriptNodePtr n) : + SourceObject(n), + Task(n), + a(n, "a"), + b(n, "b"), + d(n, "d") + { } + void execute(ExecContext * ec) const + { + Logger()->messagebf(LOG_DEBUG, "%s: %d", __PRETTY_FUNCTION__, __LINE__); + execCount += 1; + execA = a(ec); + execB = b(ec); + execD = d(ec); + } + + const Variable a; + const Variable b; + const Variable d; + + static unsigned int execCount; + static VariableType execA; + static VariableType execB; + static VariableType execD; +}; +DECLARE_LOADER("DummyComplexParamTask", DummyComplexParamTask); +unsigned int DummyComplexParamTask::execCount = 0; +VariableType DummyComplexParamTask::execA; +VariableType DummyComplexParamTask::execB; +VariableType DummyComplexParamTask::execD; + static void commonTests() { BOOST_TEST_CHECKPOINT("Verify loaded"); BOOST_REQUIRE(IceDaemonAdapterHandlerLoader::getFor("UnitTest-SimpleInterface")); + BOOST_REQUIRE(IceDaemonAdapterHandlerLoader::getFor("UnitTestComplex-ComplexInterface")); int dummy = 0; BOOST_TEST_CHECKPOINT("Run daemon"); DaemonPtr id = new IceDaemon(dummy, NULL); std::thread run(&Daemon::run, id.get()); - BOOST_TEST_CHECKPOINT("Create and verify proxy"); + BOOST_TEST_CHECKPOINT("Create and verify proxies"); Ice::CommunicatorPtr ic = Ice::initialize(dummy, NULL); UnitTest::SimpleInterfacePrx si = UnitTest::SimpleInterfacePrx::checkedCast(ic->stringToProxy("UnitTestSimpleInterface:tcp -p 12024")); BOOST_REQUIRE(si); si->ice_ping(); + UnitTestComplex::ComplexInterfacePrx sic = UnitTestComplex::ComplexInterfacePrx::checkedCast(ic->stringToProxy("UnitTestComplexComplexInterface:tcp -p 12024")); + BOOST_REQUIRE(sic); + sic->ice_ping(); BOOST_TEST_CHECKPOINT("Call view (single)"); auto single = si->SingleRow(); @@ -124,6 +163,26 @@ commonTests() BOOST_REQUIRE_EQUAL(2, DummyParamTask::execA.as()); BOOST_REQUIRE_EQUAL("second", DummyParamTask::execB.as()); + BOOST_TEST_CHECKPOINT("Call complex rows"); + auto comp = sic->ComplexRow(); + BOOST_REQUIRE_EQUAL(4, comp->a); + BOOST_REQUIRE_EQUAL("complex", comp->b); + BOOST_REQUIRE_EQUAL(1980, comp->d->year); + BOOST_REQUIRE_EQUAL(7, comp->d->month); + BOOST_REQUIRE_EQUAL(9, comp->d->day); + BOOST_REQUIRE_EQUAL(1, comp->d->hours); + BOOST_REQUIRE_EQUAL(2, comp->d->minutes); + BOOST_REQUIRE_EQUAL(3, comp->d->seconds); + + BOOST_TEST_CHECKPOINT("Call with complex param"); + BOOST_REQUIRE_EQUAL(0, DummyComplexParamTask::execCount); + sic->ComplexParam(4, "complex", new UnitTestComplex::Date { 1980, 7, 9, 1, 2, 3}); + BOOST_REQUIRE_EQUAL(1, DummyComplexParamTask::execCount); + BOOST_REQUIRE_EQUAL(4, DummyComplexParamTask::execA.as()); + BOOST_REQUIRE_EQUAL("complex", DummyComplexParamTask::execB.as()); + BOOST_REQUIRE_EQUAL(boost::posix_time::ptime(boost::gregorian::date(1980, 7, 9), boost::posix_time::time_duration(1, 2, 3)), + DummyComplexParamTask::execD.as()); + id->shutdown(); run.join(); } @@ -146,12 +205,12 @@ BOOST_AUTO_TEST_CASE( test_daemon ) TestOptionsSource::LoadTestOptions({ }); TestOptionsSource::LoadTestOptions({ { "application.dataroot", "file://" + (iceroot / "data").string() }, - { "library", (bindir / "slicer-yes" / "libunittestr.so").string() }, { "ice.daemon.adapterEndpoint", "tcp -p 12024" }, { "ice.daemon.viewRoot", (iceroot / "views").string() }, { "ice.daemon.taskRoot", (iceroot / "tasks").string() }, { "ice.compile.tmpdir", tmpdir.string() }, { "ice.compile.headers", headers.string() }, + { "ice.daemon.slicerdaemon", (iceroot / "unittestComplex.ice").string() }, { "ice.daemon.slicerdaemon", (iceroot / "unittestTypes.ice").string() }, { "ice.daemon.slicerdaemon", (iceroot / "unittest.ice").string() } }); @@ -159,6 +218,8 @@ BOOST_AUTO_TEST_CASE( test_daemon ) BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittest.daemon.so")); BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.so")); BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestTypes.daemon.so")); + BOOST_REQUIRE(!boost::filesystem::exists(tmpdir / "unittestComplex.so")); + BOOST_REQUIRE(boost::filesystem::exists(tmpdir / "unittestComplex.daemon.so")); commonTests(); TestOptionsSource::LoadTestOptions({ }); diff --git a/project2/ice/unittests/testDaemonCompile.cpp b/project2/ice/unittests/testDaemonCompile.cpp index ecbef13..0f6b4fa 100644 --- a/project2/ice/unittests/testDaemonCompile.cpp +++ b/project2/ice/unittests/testDaemonCompile.cpp @@ -8,6 +8,7 @@ #define XSTR(s) STR(s) #define STR(s) #s const auto bindir = boost::filesystem::canonical("/proc/self/exe").parent_path(); +const auto componentdir = bindir.parent_path() / "component"; const boost::filesystem::path iceroot(XSTR(ROOT)); const auto headers = iceroot.parent_path().parent_path(); @@ -58,7 +59,7 @@ BOOST_AUTO_TEST_CASE( compile_daemon_daemonOnly ) BOOST_TEST_CHECKPOINT("Configure, compile, link, load"); TestOptionsSource::LoadTestOptions({ - { "library", (bindir / "libunittest.so").string() }, + { "library", (componentdir / "libunittest.so").string() }, { "ice.compile.tmpdir", tmpdir.string() }, { "ice.compile.headers", headers.string() }, { "ice.daemon.slicedaemon", (iceroot / "unittestTypes.ice").string() }, @@ -82,7 +83,7 @@ BOOST_AUTO_TEST_CASE( compile_daemon_slicer ) BOOST_TEST_CHECKPOINT("Configure, compile, link, load"); TestOptionsSource::LoadTestOptions({ - { "library", (bindir / "slicer-yes" / "libunittestr.so").string() }, + { "library", (componentdir / "slicer-yes" / "libunittestr.so").string() }, { "ice.compile.tmpdir", tmpdir.string() }, { "ice.compile.headers", headers.string() }, { "ice.daemon.slicerdaemon", (iceroot / "unittestTypes.ice").string() }, diff --git a/project2/ice/unittests/unittestComplex.ice b/project2/ice/unittests/unittestComplex.ice new file mode 100644 index 0000000..a22b294 --- /dev/null +++ b/project2/ice/unittests/unittestComplex.ice @@ -0,0 +1,30 @@ +[["cpp:include:boost/date_time/posix_time/posix_time_types.hpp"]] + +module UnitTestComplex { + class Date { + int year; + int month; + int day; + int hours; + int minutes; + int seconds; + }; + + class Complex { + int a; + string b; + [ "slicer:conversion:boost.posix_time.ptime:ptimeToDateTime:dateTimeToPTime" ] + Date d; + }; + + interface ComplexInterface { + ["project2:rows"] + Complex ComplexRow(); + + ["project2:task"] + void ComplexParam(int a, string b, Date d); + }; + + sequence Complexes; +}; + diff --git a/project2/ice/unittests/views/UnitTestComplex/ComplexInterface/ComplexRow.xml b/project2/ice/unittests/views/UnitTestComplex/ComplexInterface/ComplexRow.xml new file mode 100644 index 0000000..a5e7f42 --- /dev/null +++ b/project2/ice/unittests/views/UnitTestComplex/ComplexInterface/ComplexRow.xml @@ -0,0 +1,5 @@ + + + + + -- cgit v1.2.3