From 5c55818362334130da61bc9df7622d1bb1265853 Mon Sep 17 00:00:00 2001 From: cyjseagull Date: Fri, 6 Sep 2024 22:45:47 +0800 Subject: [PATCH] fix ut --- cpp/cmake/IncludeDirectories.cmake | 1 + cpp/ppc-framework/front/IFront.h | 1 + .../ppc-cem/tests/TestCEMService.cpp | 2 +- .../ppc-cem/tests/data/config.ini | 2 +- .../ppc-mpc/tests/TestMPCService.cpp | 2 +- .../ppc-pir/tests/FakeOtPIRFactory.h | 70 ++-- .../ppc-pir/tests/TestBaseOT.cpp | 384 +++++++++--------- cpp/wedpr-computing/ppc-pir/tests/test.json | 2 +- cpp/wedpr-computing/ppc-psi/src/PSIConfig.h | 7 + .../tests/bs-ecdh-psi/TestBsEcdhCache.cpp | 7 +- .../tests/cm2020-psi/TestCM2020Impl.cpp | 66 +-- .../tests/labeled-psi/TestLabeledPSIImpl.cpp | 15 +- .../tests/ra2018-psi/TestEcdhPSIImpl.cpp | 21 +- .../tests/ra2018-psi/TestRA2018Impl.cpp | 15 +- .../ppc-io/tests/TestLineReader.cpp | 6 +- cpp/wedpr-transport/ppc-front/CMakeLists.txt | 10 +- .../ppc-front/test/CMakeLists.txt | 2 +- .../ppc-gateway/test/CMakeLists.txt | 2 +- 18 files changed, 331 insertions(+), 284 deletions(-) diff --git a/cpp/cmake/IncludeDirectories.cmake b/cpp/cmake/IncludeDirectories.cmake index 5d1643be..4c0e78d4 100644 --- a/cpp/cmake/IncludeDirectories.cmake +++ b/cpp/cmake/IncludeDirectories.cmake @@ -7,6 +7,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-computing) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-crypto) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-storage) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-helper) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-transport) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-crypto/sdk) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-transport/ppc-front) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-transport/ppc-gateway) diff --git a/cpp/ppc-framework/front/IFront.h b/cpp/ppc-framework/front/IFront.h index 8de9ab09..27e9bfe0 100644 --- a/cpp/ppc-framework/front/IFront.h +++ b/cpp/ppc-framework/front/IFront.h @@ -123,6 +123,7 @@ class IFront : virtual public IFrontClient * @param topic the topic to unregister */ virtual void unRegisterTopic(std::string const& topic) = 0; + }; class IFrontBuilder diff --git a/cpp/wedpr-computing/ppc-cem/tests/TestCEMService.cpp b/cpp/wedpr-computing/ppc-cem/tests/TestCEMService.cpp index cbcfc668..5214af38 100644 --- a/cpp/wedpr-computing/ppc-cem/tests/TestCEMService.cpp +++ b/cpp/wedpr-computing/ppc-cem/tests/TestCEMService.cpp @@ -33,7 +33,7 @@ BOOST_FIXTURE_TEST_SUITE(cMServiceTest, TestPromptFixture) BOOST_AUTO_TEST_CASE(testCEMService) { auto cemService = std::make_shared(); - std::string configPath{"../../../ppc-cem/tests/data/config.ini"}; + std::string configPath{"../../../../wedpr-computing/ppc-cem/tests/data/config.ini"}; boost::property_tree::ptree pt; boost::property_tree::read_ini(configPath, pt); // load the cm config diff --git a/cpp/wedpr-computing/ppc-cem/tests/data/config.ini b/cpp/wedpr-computing/ppc-cem/tests/data/config.ini index c5a93e32..5cf1c6f8 100644 --- a/cpp/wedpr-computing/ppc-cem/tests/data/config.ini +++ b/cpp/wedpr-computing/ppc-cem/tests/data/config.ini @@ -6,7 +6,7 @@ [cem] use_mysql = false dataset_hdfs_path = /user/ppc/admin - dataset_file_path = ../../../ppc-cem/tests/data + dataset_file_path = ../../../../wedpr-computing/ppc-cem/tests/data ciphertext_suffix = -encrypted read_per_batch_lines = 100000 diff --git a/cpp/wedpr-computing/ppc-mpc/tests/TestMPCService.cpp b/cpp/wedpr-computing/ppc-mpc/tests/TestMPCService.cpp index 51277660..75e427cc 100644 --- a/cpp/wedpr-computing/ppc-mpc/tests/TestMPCService.cpp +++ b/cpp/wedpr-computing/ppc-mpc/tests/TestMPCService.cpp @@ -34,7 +34,7 @@ BOOST_FIXTURE_TEST_SUITE(MPCServiceTest, TestPromptFixture) BOOST_AUTO_TEST_CASE(testMPCService) { auto mpcService = std::make_shared(); - std::string configPath{"../../../ppc-mpc/tests/data/config.ini"}; + std::string configPath{"../../../../wedpr-computing/ppc-mpc/tests/data/config.ini"}; boost::property_tree::ptree pt; boost::property_tree::read_ini(configPath, pt); // load the mpc config diff --git a/cpp/wedpr-computing/ppc-pir/tests/FakeOtPIRFactory.h b/cpp/wedpr-computing/ppc-pir/tests/FakeOtPIRFactory.h index c38a1b71..23ee2179 100644 --- a/cpp/wedpr-computing/ppc-pir/tests/FakeOtPIRFactory.h +++ b/cpp/wedpr-computing/ppc-pir/tests/FakeOtPIRFactory.h @@ -38,51 +38,55 @@ using namespace ppc::io; using namespace ppc::front; using namespace ppc::tools; -namespace ppc::test { - -class FakeOtPIRImpl : public OtPIRImpl { +namespace ppc::test +{ +class FakeOtPIRImpl : public OtPIRImpl +{ public: - using Ptr = std::shared_ptr; - FakeOtPIRImpl(OtPIRConfig::Ptr const &_config, unsigned _idleTimeMs = 0) - : OtPIRImpl(_config, _idleTimeMs) { - m_enableOutputExists = true; - } - ~FakeOtPIRImpl() override = default; + using Ptr = std::shared_ptr; + FakeOtPIRImpl(OtPIRConfig::Ptr const& _config, unsigned _idleTimeMs = 0) + : OtPIRImpl(_config, _idleTimeMs) + { + m_enableOutputExists = true; + } + ~FakeOtPIRImpl() override = default; }; -class FakeOtPIRFactory : public OtPIRFactory { +class FakeOtPIRFactory : public OtPIRFactory +{ public: - using Ptr = std::shared_ptr; + using Ptr = std::shared_ptr; - FakeOtPIRFactory() + FakeOtPIRFactory() : m_front(std::make_shared()), m_dataResourceLoader(std::make_shared( nullptr, nullptr, nullptr, nullptr, nullptr, nullptr)), - m_threadPool(std::make_shared("ot-pir", 4)) { - auto hashImpl = std::make_shared(); - auto eccCrypto = std::make_shared( - hashImpl, ppc::protocol::ECCCurve::P256); - m_cryptoBox = std::make_shared(hashImpl, eccCrypto); - } + m_threadPool(std::make_shared("ot-pir", 4)) + { + auto hashImpl = std::make_shared(); + auto eccCrypto = + std::make_shared(hashImpl, ppc::protocol::ECCCurve::P256); + m_cryptoBox = std::make_shared(hashImpl, eccCrypto); + } - ~FakeOtPIRFactory() override = default; + ~FakeOtPIRFactory() override = default; - OtPIRImpl::Ptr createOtPIR(std::string const &_selfParty) { - auto config = - std::make_shared(_selfParty, m_front, m_cryptoBox, - m_threadPool, m_dataResourceLoader, 1); + OtPIRImpl::Ptr createOtPIR(std::string const& _selfParty) + { + auto config = std::make_shared( + _selfParty, m_front, m_cryptoBox, m_threadPool, m_dataResourceLoader, 1); - return std::make_shared(config); - } + return std::make_shared(config); + } - DataResourceLoaderImpl::Ptr resourceLoader() { return m_dataResourceLoader; } - FakeFront::Ptr front() { return m_front; } - CryptoBox::Ptr cryptoBox() { return m_cryptoBox; } + DataResourceLoaderImpl::Ptr resourceLoader() { return m_dataResourceLoader; } + FakeFront::Ptr front() { return m_front; } + CryptoBox::Ptr cryptoBox() { return m_cryptoBox; } private: - FakeFront::Ptr m_front; - DataResourceLoaderImpl::Ptr m_dataResourceLoader; - ThreadPool::Ptr m_threadPool; - CryptoBox::Ptr m_cryptoBox; + FakeFront::Ptr m_front; + DataResourceLoaderImpl::Ptr m_dataResourceLoader; + ThreadPool::Ptr m_threadPool; + CryptoBox::Ptr m_cryptoBox; }; -} // namespace ppc::test \ No newline at end of file +} // namespace ppc::test \ No newline at end of file diff --git a/cpp/wedpr-computing/ppc-pir/tests/TestBaseOT.cpp b/cpp/wedpr-computing/ppc-pir/tests/TestBaseOT.cpp index 9f5477fb..b76d867b 100644 --- a/cpp/wedpr-computing/ppc-pir/tests/TestBaseOT.cpp +++ b/cpp/wedpr-computing/ppc-pir/tests/TestBaseOT.cpp @@ -37,216 +37,216 @@ using namespace ppc::pir; using namespace bcos; using namespace bcos::test; -namespace ppc::test { +namespace ppc::test +{ BOOST_FIXTURE_TEST_SUITE(OtPIRest, TestPromptFixture) -BOOST_AUTO_TEST_CASE(testBaseOT) { - // 统计函数执行时间 - std::cout << "testBaseOT" << std::endl; - - auto eccFactory = std::make_shared(); - auto hashFactory = std::make_shared(); - auto hash = - hashFactory->createHashImpl((int8_t)ppc::protocol::HashImplName::SHA512); - EccCrypto::Ptr ecc = - eccFactory->createEccCrypto((int8_t)ppc::protocol::ECCCurve::P256, hash); - // auto aysService = std::make_shared(); - // auto aes = std::make_shared( - // OpenSSLAES::AESType::AES128, - // SymCrypto::OperationMode::CBC, _seed, bcos::bytes()); - - std::string datasetPath = "../../../ppc-pir/tests/data/AysPreDataset.csv"; - // std::cout<< "aysService->prepareDataset" << std::endl; - std::string prefix = "testmsg1"; - bcos::bytes sendObfuscatedHash(prefix.begin(), prefix.end()); - - uint32_t obfuscatedOrder = 10; - auto baseOT = std::make_shared(ecc, hash); - auto messageKeypair = baseOT->prepareDataset(sendObfuscatedHash, datasetPath); - // for(auto iter = messageKeypair.begin(); iter != messageKeypair.end(); - // ++iter) - // { - // std::string pairKey(iter->first.begin(), iter->first.end()); - // std::string pairValue(iter->second.begin(), iter->second.end()); - // // for(uint32_t i = 0; i < messageKeypair.size(); ++i) { - // // std::cout<< "pairKey:"<< pairKey << std::endl; - // // std::cout<< "pairValue:"<< pairValue << std::endl; - // } - auto start = std::chrono::high_resolution_clock::now(); - - std::string choice = "testmsg1100"; - // std::cout<< "baseOT->senderGenerateCipher" << std::endl; - auto senderMessage = baseOT->senderGenerateCipher( - bcos::bytes(choice.begin(), choice.end()), obfuscatedOrder); - // std::cout<< "baseOT->receiverGenerateMessage" << std::endl; - auto receiverMessage = baseOT->receiverGenerateMessage( - senderMessage.pointX, senderMessage.pointY, messageKeypair, - senderMessage.pointZ); - - // std::cout<< "baseOT->finishSender" << std::endl; - auto result = baseOT->finishSender( - senderMessage.scalarBlidingB, receiverMessage.pointWList, - receiverMessage.encryptMessagePair, receiverMessage.encryptCipher); - - auto end = std::chrono::high_resolution_clock::now(); - - auto duration = - std::chrono::duration_cast(end - start); - std::cout << "执行时间 time: " << duration.count() << " microseconds" - << std::endl; - - if (result.size() == 0) { - std::cout << "final result: message not found" << std::endl; - } else { - std::cout << "final result: " << std::string(result.begin(), result.end()) - << std::endl; - } - // for(uint32_t i = 0; i < result.size(); ++i) - // { - // std::cout<< std::string(result[i].begin(), result[i].end()) << - // std::endl; - // } - - BOOST_CHECK(true); +BOOST_AUTO_TEST_CASE(testBaseOT) +{ + // 统计函数执行时间 + std::cout << "testBaseOT" << std::endl; + + auto eccFactory = std::make_shared(); + auto hashFactory = std::make_shared(); + auto hash = hashFactory->createHashImpl((int8_t)ppc::protocol::HashImplName::SHA512); + EccCrypto::Ptr ecc = eccFactory->createEccCrypto((int8_t)ppc::protocol::ECCCurve::P256, hash); + // auto aysService = std::make_shared(); + // auto aes = std::make_shared( + // OpenSSLAES::AESType::AES128, + // SymCrypto::OperationMode::CBC, _seed, bcos::bytes()); + + std::string datasetPath = "../../../../wedpr-computing/ppc-pir/tests/data/AysPreDataset.csv"; + // std::cout<< "aysService->prepareDataset" << std::endl; + std::string prefix = "testmsg1"; + bcos::bytes sendObfuscatedHash(prefix.begin(), prefix.end()); + + uint32_t obfuscatedOrder = 10; + auto baseOT = std::make_shared(ecc, hash); + auto messageKeypair = baseOT->prepareDataset(sendObfuscatedHash, datasetPath); + // for(auto iter = messageKeypair.begin(); iter != messageKeypair.end(); + // ++iter) + // { + // std::string pairKey(iter->first.begin(), iter->first.end()); + // std::string pairValue(iter->second.begin(), iter->second.end()); + // // for(uint32_t i = 0; i < messageKeypair.size(); ++i) { + // // std::cout<< "pairKey:"<< pairKey << std::endl; + // // std::cout<< "pairValue:"<< pairValue << std::endl; + // } + auto start = std::chrono::high_resolution_clock::now(); + + std::string choice = "testmsg1100"; + // std::cout<< "baseOT->senderGenerateCipher" << std::endl; + auto senderMessage = + baseOT->senderGenerateCipher(bcos::bytes(choice.begin(), choice.end()), obfuscatedOrder); + // std::cout<< "baseOT->receiverGenerateMessage" << std::endl; + auto receiverMessage = baseOT->receiverGenerateMessage( + senderMessage.pointX, senderMessage.pointY, messageKeypair, senderMessage.pointZ); + + // std::cout<< "baseOT->finishSender" << std::endl; + auto result = baseOT->finishSender(senderMessage.scalarBlidingB, receiverMessage.pointWList, + receiverMessage.encryptMessagePair, receiverMessage.encryptCipher); + + auto end = std::chrono::high_resolution_clock::now(); + + auto duration = std::chrono::duration_cast(end - start); + std::cout << "执行时间 time: " << duration.count() << " microseconds" << std::endl; + + if (result.size() == 0) + { + std::cout << "final result: message not found" << std::endl; + } + else + { + std::cout << "final result: " << std::string(result.begin(), result.end()) << std::endl; + } + // for(uint32_t i = 0; i < result.size(); ++i) + // { + // std::cout<< std::string(result[i].begin(), result[i].end()) << + // std::endl; + // } + + BOOST_CHECK(true); } -void testOTPIR(FakeOtPIRFactory::Ptr _factory, OtPIRImpl::Ptr _sender, - OtPIRImpl::Ptr _receiver, - ppc::protocol::Task::ConstPtr _senderPirTask, - ppc::protocol::Task::ConstPtr _receiverPirTask, - std::vector const &_expectedPIRResult, - bool _expectedSuccess, int _expectedErrorCode = 0) { - std::atomic flag = 0; - - _sender->asyncRunTask( - _senderPirTask, [_senderPirTask, _expectedSuccess, _expectedErrorCode, - &flag](ppc::protocol::TaskResult::Ptr &&_response) { - if (_expectedSuccess) { - BOOST_CHECK(_response->error() == nullptr || - _response->error()->errorCode() == 0); - BOOST_CHECK(_response->taskID() == _senderPirTask->id()); - auto result = _response->error(); - BOOST_CHECK(result == nullptr || result->errorCode() == 0); - } else { - BOOST_CHECK(_response->error() != nullptr); - auto result = _response->error(); - BOOST_CHECK(result != nullptr); - BOOST_CHECK(_response->error()->errorCode() == _expectedErrorCode); +void testOTPIR(FakeOtPIRFactory::Ptr _factory, OtPIRImpl::Ptr _sender, OtPIRImpl::Ptr _receiver, + ppc::protocol::Task::ConstPtr _senderPirTask, ppc::protocol::Task::ConstPtr _receiverPirTask, + std::vector const& _expectedPIRResult, bool _expectedSuccess, + int _expectedErrorCode = 0) +{ + std::atomic flag = 0; + + _sender->asyncRunTask(_senderPirTask, [_senderPirTask, _expectedSuccess, _expectedErrorCode, + &flag](ppc::protocol::TaskResult::Ptr&& _response) { + if (_expectedSuccess) + { + BOOST_CHECK(_response->error() == nullptr || _response->error()->errorCode() == 0); + BOOST_CHECK(_response->taskID() == _senderPirTask->id()); + auto result = _response->error(); + BOOST_CHECK(result == nullptr || result->errorCode() == 0); } - flag++; - }); - _sender->start(); - - _receiver->asyncRunTask( - _receiverPirTask, [_receiverPirTask, _expectedSuccess, - &flag](ppc::protocol::TaskResult::Ptr &&_response) { - if (_expectedSuccess) { - BOOST_CHECK(_response->error() == nullptr || - _response->error()->errorCode() == 0); - BOOST_CHECK(_response->taskID() == _receiverPirTask->id()); - auto result = _response->error(); - BOOST_CHECK(result == nullptr || result->errorCode() == 0); - } else { - BOOST_CHECK(_response->error() != nullptr); - auto result = _response->error(); - BOOST_CHECK(result != nullptr); + else + { + BOOST_CHECK(_response->error() != nullptr); + auto result = _response->error(); + BOOST_CHECK(result != nullptr); + BOOST_CHECK(_response->error()->errorCode() == _expectedErrorCode); } flag++; - }); - _receiver->start(); - - // wait for the task finish and check - while (flag < 2) { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - } - - _sender->stop(); - _receiver->stop(); - - // if (_expectedSuccess && !_expectedPIRResult.empty()) - // { - // checkTaskPIRResult(_factory->resourceLoader(), _receiverPirTask, - // _expectedPIRResult.size(), - // _expectedPIRResult); - // } + }); + _sender->start(); + + _receiver->asyncRunTask(_receiverPirTask, + [_receiverPirTask, _expectedSuccess, &flag](ppc::protocol::TaskResult::Ptr&& _response) { + if (_expectedSuccess) + { + BOOST_CHECK(_response->error() == nullptr || _response->error()->errorCode() == 0); + BOOST_CHECK(_response->taskID() == _receiverPirTask->id()); + auto result = _response->error(); + BOOST_CHECK(result == nullptr || result->errorCode() == 0); + } + else + { + BOOST_CHECK(_response->error() != nullptr); + auto result = _response->error(); + BOOST_CHECK(result != nullptr); + } + flag++; + }); + _receiver->start(); + + // wait for the task finish and check + while (flag < 2) + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + + _sender->stop(); + _receiver->stop(); + + // if (_expectedSuccess && !_expectedPIRResult.empty()) + // { + // checkTaskPIRResult(_factory->resourceLoader(), _receiverPirTask, + // _expectedPIRResult.size(), + // _expectedPIRResult); + // } } -void testOTPIRImplFunc(const std::string &_taskID, const std::string &_params, - bool _syncResults, PartyResource::Ptr _senderParty, - PartyResource::Ptr _receiverParty, - std::vector const &_expectedPIRResult, - bool _expectedSuccess, int _expectedErrorCode = 0) { - auto factory = std::make_shared(); - - // fake the sender - std::string senderAgencyName = "sender"; - auto senderPIR = factory->createOtPIR("sender"); - - // fake the receiver - std::string receiverAgencyName = _receiverParty->id(); - auto receiverPIR = factory->createOtPIR(receiverAgencyName); - - // register the server-pir into the front - factory->front()->registerOTPIR(senderAgencyName, senderPIR); - factory->front()->registerOTPIR(receiverAgencyName, receiverPIR); - - // trigger the pir task - auto senderPIRTask = std::make_shared(senderAgencyName); - senderPIRTask->setId(_taskID); - senderPIRTask->setParam(_params); - senderPIRTask->setSelf(_senderParty); - senderPIRTask->addParty(_receiverParty); - senderPIRTask->setSyncResultToPeer(_syncResults); - senderPIRTask->setAlgorithm((uint8_t)PSIAlgorithmType::OT_PIR_2PC); - senderPIRTask->setType((uint8_t)ppc::protocol::TaskType::PIR); - - auto receiverPIRTask = std::make_shared(receiverAgencyName); - receiverPIRTask->setId(_taskID); - receiverPIRTask->setParam(_params); - receiverPIRTask->setSelf(_receiverParty); - receiverPIRTask->addParty(_senderParty); - receiverPIRTask->setSyncResultToPeer(_syncResults); - receiverPIRTask->setAlgorithm((uint8_t)PSIAlgorithmType::OT_PIR_2PC); - receiverPIRTask->setType((uint8_t)ppc::protocol::TaskType::PIR); - - testOTPIR(factory, senderPIR, receiverPIR, senderPIRTask, receiverPIRTask, - _expectedPIRResult, _expectedSuccess, _expectedErrorCode); +void testOTPIRImplFunc(const std::string& _taskID, const std::string& _params, bool _syncResults, + PartyResource::Ptr _senderParty, PartyResource::Ptr _receiverParty, + std::vector const& _expectedPIRResult, bool _expectedSuccess, + int _expectedErrorCode = 0) +{ + auto factory = std::make_shared(); + + // fake the sender + std::string senderAgencyName = "sender"; + auto senderPIR = factory->createOtPIR("sender"); + + // fake the receiver + std::string receiverAgencyName = _receiverParty->id(); + auto receiverPIR = factory->createOtPIR(receiverAgencyName); + + // register the server-pir into the front + factory->front()->registerOTPIR(senderAgencyName, senderPIR); + factory->front()->registerOTPIR(receiverAgencyName, receiverPIR); + + // trigger the pir task + auto senderPIRTask = std::make_shared(senderAgencyName); + senderPIRTask->setId(_taskID); + senderPIRTask->setParam(_params); + senderPIRTask->setSelf(_senderParty); + senderPIRTask->addParty(_receiverParty); + senderPIRTask->setSyncResultToPeer(_syncResults); + senderPIRTask->setAlgorithm((uint8_t)PSIAlgorithmType::OT_PIR_2PC); + senderPIRTask->setType((uint8_t)ppc::protocol::TaskType::PIR); + + auto receiverPIRTask = std::make_shared(receiverAgencyName); + receiverPIRTask->setId(_taskID); + receiverPIRTask->setParam(_params); + receiverPIRTask->setSelf(_receiverParty); + receiverPIRTask->addParty(_senderParty); + receiverPIRTask->setSyncResultToPeer(_syncResults); + receiverPIRTask->setAlgorithm((uint8_t)PSIAlgorithmType::OT_PIR_2PC); + receiverPIRTask->setType((uint8_t)ppc::protocol::TaskType::PIR); + + testOTPIR(factory, senderPIR, receiverPIR, senderPIRTask, receiverPIRTask, _expectedPIRResult, + _expectedSuccess, _expectedErrorCode); } -BOOST_AUTO_TEST_CASE(testNormalOtPIRCase) { - std::string otSearchPath = "../../../ppc-pir/tests/data/AysPreDataset.csv"; - std::string outputPath = "../../../ppc-pir/tests/data/output.csv"; +BOOST_AUTO_TEST_CASE(testNormalOtPIRCase) +{ + std::string otSearchPath = "../../../../wedpr-computing/ppc-pir/tests/data/AysPreDataset.csv"; + std::string outputPath = "../../../../wedpr-computing/ppc-pir/tests/data/output.csv"; - uint32_t count = 513; - // prepareInputs(senderPath, count, receiverPath, count, count); + uint32_t count = 513; + // prepareInputs(senderPath, count, receiverPath, count, count); - auto senderParty = mockParty((uint16_t)ppc::protocol::PartyType::Client, - "sender", "senderPartyResource", "sender_inputs", - protocol::DataResourceType::FILE, ""); - auto senderOutputDesc = std::make_shared(); - senderOutputDesc->setPath(outputPath); - senderParty->mutableDataResource()->setOutputDesc(senderOutputDesc); + auto senderParty = mockParty((uint16_t)ppc::protocol::PartyType::Client, "sender", + "senderPartyResource", "sender_inputs", protocol::DataResourceType::FILE, ""); + auto senderOutputDesc = std::make_shared(); + senderOutputDesc->setPath(outputPath); + senderParty->mutableDataResource()->setOutputDesc(senderOutputDesc); - auto receiverParty = - mockParty((uint16_t)ppc::protocol::PartyType::Server, "receiver", - "receiverPartyResource", "receiver_inputs", - DataResourceType::FILE, otSearchPath); + auto receiverParty = mockParty((uint16_t)ppc::protocol::PartyType::Server, "receiver", + "receiverPartyResource", "receiver_inputs", DataResourceType::FILE, otSearchPath); - // auto receiverOutputDesc = std::make_shared(); - // receiverOutputDesc->setPath(outputPath); - // receiverParty->mutableDataResource()->setOutputDesc(receiverOutputDesc); + // auto receiverOutputDesc = std::make_shared(); + // receiverOutputDesc->setPath(outputPath); + // receiverParty->mutableDataResource()->setOutputDesc(receiverOutputDesc); - std::vector expectedResult; - for (uint32_t i = 0; i < count; i++) { - expectedResult.emplace_back(std::to_string(100000 + i)); - } + std::vector expectedResult; + for (uint32_t i = 0; i < count; i++) + { + expectedResult.emplace_back(std::to_string(100000 + i)); + } - std::string jobParams = "{\"searchId\":\"testmsg1100\",\"requestAgencyId\":" - "\"receiver\",\"prefixLength\":6}"; + std::string jobParams = + "{\"searchId\":\"testmsg1100\",\"requestAgencyId\":" + "\"receiver\",\"prefixLength\":6}"; - testOTPIRImplFunc("0x12345678", jobParams, true, senderParty, receiverParty, - expectedResult, true, 0); + testOTPIRImplFunc( + "0x12345678", jobParams, true, senderParty, receiverParty, expectedResult, true, 0); } BOOST_AUTO_TEST_SUITE_END() -} // namespace ppc::test +} // namespace ppc::test diff --git a/cpp/wedpr-computing/ppc-pir/tests/test.json b/cpp/wedpr-computing/ppc-pir/tests/test.json index 08df6b4d..37bf327b 100644 --- a/cpp/wedpr-computing/ppc-pir/tests/test.json +++ b/cpp/wedpr-computing/ppc-pir/tests/test.json @@ -1,6 +1,6 @@ { "searchId": "testmsg1100", "requestAgencyId": "1002", - "requestAgencyDataset": "../../../ppc-pir/tests/data/AysPreDataset.csv", + "requestAgencyDataset": "../../../../wedpr-computing/ppc-pir/tests/data/AysPreDataset.csv", "prefixLength": 6 } \ No newline at end of file diff --git a/cpp/wedpr-computing/ppc-psi/src/PSIConfig.h b/cpp/wedpr-computing/ppc-psi/src/PSIConfig.h index 7ee7dd80..72ee8bbe 100644 --- a/cpp/wedpr-computing/ppc-psi/src/PSIConfig.h +++ b/cpp/wedpr-computing/ppc-psi/src/PSIConfig.h @@ -120,6 +120,13 @@ class PSIConfig return m_agencyList; } + // for ut + void setAgencyList(std::vector const& agencyList) + { + bcos::WriteGuard l(x_agencyList); + m_agencyList = agencyList; + } + protected: ppc::front::PPCMessageFace::Ptr generatePPCMsg( std::string const& _taskID, PSIMessageInterface::Ptr const& _msg, uint32_t _seq) diff --git a/cpp/wedpr-computing/ppc-psi/tests/bs-ecdh-psi/TestBsEcdhCache.cpp b/cpp/wedpr-computing/ppc-psi/tests/bs-ecdh-psi/TestBsEcdhCache.cpp index 82409479..05eb185d 100644 --- a/cpp/wedpr-computing/ppc-psi/tests/bs-ecdh-psi/TestBsEcdhCache.cpp +++ b/cpp/wedpr-computing/ppc-psi/tests/bs-ecdh-psi/TestBsEcdhCache.cpp @@ -83,9 +83,10 @@ BOOST_AUTO_TEST_CASE(testEcdhEnc) BOOST_AUTO_TEST_CASE(testBsEcdh) { - auto inputPath = "../../../ppc-psi/tests/bs-ecdh-psi/data/inputs.csv"; - auto outputPath = "../../../ppc-psi/tests/bs-ecdh-psi/data/outputs.csv"; - boost::filesystem::create_directory("../../../ppc-psi/tests/bs-ecdh-psi/data"); + auto inputPath = "../../../../wedpr-computing/ppc-psi/tests/bs-ecdh-psi/data/inputs.csv"; + auto outputPath = "../../../../../wedpr-computing/ppc-psi/tests/bs-ecdh-psi/data/outputs.csv"; + boost::filesystem::create_directory( + "../../../../wedpr-computing/ppc-psi/tests/bs-ecdh-psi/data"); auto count = 123456; prepareInputs(inputPath, count); diff --git a/cpp/wedpr-computing/ppc-psi/tests/cm2020-psi/TestCM2020Impl.cpp b/cpp/wedpr-computing/ppc-psi/tests/cm2020-psi/TestCM2020Impl.cpp index 95ff82e3..bb9f5bf6 100644 --- a/cpp/wedpr-computing/ppc-psi/tests/cm2020-psi/TestCM2020Impl.cpp +++ b/cpp/wedpr-computing/ppc-psi/tests/cm2020-psi/TestCM2020Impl.cpp @@ -169,13 +169,18 @@ void testCM2020PSIImplFunc(const std::string& _taskID, const std::string& _param BOOST_AUTO_TEST_CASE(testNormalCM2020PSICase) { - std::string senderPath = "../../../ppc-psi/tests/cm2020-psi/data/sender_inputs.csv"; - std::string receiverPath = "../../../ppc-psi/tests/cm2020-psi/data/receiver_inputs.csv"; - std::string senderOutputPath = "../../../ppc-psi/tests/cm2020-psi/data/sender_out.csv"; - std::string receiverOutputPath = "../../../ppc-psi/tests/cm2020-psi/data/receiver_out.csv"; + std::string senderPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/sender_inputs.csv"; + std::string receiverPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/receiver_inputs.csv"; + std::string senderOutputPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/sender_out.csv"; + std::string receiverOutputPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/receiver_out.csv"; uint32_t count = 513; - boost::filesystem::create_directory("../../../ppc-psi/tests/cm2020-psi/data"); + boost::filesystem::create_directory( + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data"); prepareInputs(senderPath, count, receiverPath, count, count); auto senderParty = mockParty((uint16_t)ppc::protocol::PartyType::Server, "sender", @@ -208,14 +213,19 @@ BOOST_AUTO_TEST_CASE(testNormalCM2020PSICase) BOOST_AUTO_TEST_CASE(testBigDataCM2020PSICase) { - std::string senderPath = "../../../ppc-psi/tests/cm2020-psi/data/sender_inputs.csv"; - std::string receiverPath = "../../../ppc-psi/tests/cm2020-psi/data/receiver_inputs.csv"; - std::string senderOutputPath = "../../../ppc-psi/tests/cm2020-psi/data/sender_out.csv"; - std::string receiverOutputPath = "../../../ppc-psi/tests/cm2020-psi/data/receiver_out.csv"; + std::string senderPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/sender_inputs.csv"; + std::string receiverPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/receiver_inputs.csv"; + std::string senderOutputPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/sender_out.csv"; + std::string receiverOutputPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/receiver_out.csv"; uint32_t count = 1000000, common = 100; - boost::filesystem::create_directory("../../../ppc-psi/tests/cm2020-psi/data"); + boost::filesystem::create_directory( + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data"); prepareInputs(senderPath, count, receiverPath, count, common); auto senderParty = mockParty(uint16_t(PartyType::Server), "sender", "senderPartyResource", @@ -242,18 +252,23 @@ BOOST_AUTO_TEST_CASE(testBigDataCM2020PSICase) BOOST_AUTO_TEST_CASE(testErrorCM2020PSICase) { - std::string senderPath = "../../../ppc-psi/tests/cm2020-psi/data/sender_inputs.csv"; - std::string receiverPath = "../../../ppc-psi/tests/cm2020-psi/data/receiver_inputs.csv"; - std::string senderOutputPath = "../../../ppc-psi/tests/cm2020-psi/data/sender_out.csv"; - std::string receiverOutputPath = "../../../ppc-psi/tests/cm2020-psi/data/receiver_out.csv"; + std::string senderPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/sender_inputs.csv"; + std::string receiverPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/receiver_inputs.csv"; + std::string senderOutputPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/sender_out.csv"; + std::string receiverOutputPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/receiver_out.csv"; uint32_t count = 1234; - boost::filesystem::create_directory("../../../ppc-psi/tests/cm2020-psi/data"); + boost::filesystem::create_directory( + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data"); prepareInputs(senderPath, count, receiverPath, count, count); - auto senderParty = - mockParty(uint16_t(PartyType::Server), "sender", "senderPartyResource", "sender_inputs", - DataResourceType::FILE, "../../../ppc-psi/tests/cm2020-psi/data/not_existed.csv"); + auto senderParty = mockParty(uint16_t(PartyType::Server), "sender", "senderPartyResource", + "sender_inputs", DataResourceType::FILE, + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/not_existed.csv"); auto senderOutputDesc = std::make_shared(); senderOutputDesc->setPath(senderOutputPath); @@ -271,13 +286,18 @@ BOOST_AUTO_TEST_CASE(testErrorCM2020PSICase) BOOST_AUTO_TEST_CASE(testRawDataCM2020PSICase) { - std::string senderPath = "../../../ppc-psi/tests/cm2020-psi/data/sender_inputs.csv"; - std::string receiverPath = "../../../ppc-psi/tests/cm2020-psi/data/receiver_inputs.csv"; - std::string senderOutputPath = "../../../ppc-psi/tests/cm2020-psi/data/sender_out.csv"; - std::string receiverOutputPath = "../../../ppc-psi/tests/cm2020-psi/data/receiver_out.csv"; + std::string senderPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/sender_inputs.csv"; + std::string receiverPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/receiver_inputs.csv"; + std::string senderOutputPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/sender_out.csv"; + std::string receiverOutputPath = + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data/receiver_out.csv"; uint32_t count = 1234; - boost::filesystem::create_directory("../../../ppc-psi/tests/cm2020-psi/data"); + boost::filesystem::create_directory( + "../../../../wedpr-computing/ppc-psi/tests/cm2020-psi/data"); prepareInputs(senderPath, count, receiverPath, count, count); auto reader = std::make_shared(senderPath); diff --git a/cpp/wedpr-computing/ppc-psi/tests/labeled-psi/TestLabeledPSIImpl.cpp b/cpp/wedpr-computing/ppc-psi/tests/labeled-psi/TestLabeledPSIImpl.cpp index 77b1a7ac..3a030eae 100644 --- a/cpp/wedpr-computing/ppc-psi/tests/labeled-psi/TestLabeledPSIImpl.cpp +++ b/cpp/wedpr-computing/ppc-psi/tests/labeled-psi/TestLabeledPSIImpl.cpp @@ -42,10 +42,12 @@ BOOST_FIXTURE_TEST_SUITE(LabeledPSIImplTest, TestPromptFixture) void runSetup(LabeledPSIImpl::Ptr _sender) { - std::string senderPath = "../../../ppc-psi/tests/labeled-psi/data/sender.csv"; + std::string senderPath = + "../../../../wedpr-computing/ppc-psi/tests/labeled-psi/data/sender.csv"; uint32_t count = 10000; - boost::filesystem::create_directory("../../../ppc-psi/tests/labeled-psi/data"); + boost::filesystem::create_directory( + "../../../../wedpr-computing/ppc-psi/tests/labeled-psi/data"); prepareItemsAndLabels(senderPath, count); auto senderParty = mockParty(uint16_t(PartyType::Server), "sender", "senderPartyResource", @@ -77,8 +79,10 @@ void runSetup(LabeledPSIImpl::Ptr _sender) void saveCache(LabeledPSIImpl::Ptr _sender) { - std::string cachePath = "../../../ppc-psi/tests/labeled-psi/data/sender_cache.txt"; - boost::filesystem::create_directory("../../../ppc-psi/tests/labeled-psi/data"); + std::string cachePath = + "../../../../wedpr-computing/ppc-psi/tests/labeled-psi/data/sender_cache.txt"; + boost::filesystem::create_directory( + "../../../../wedpr-computing/ppc-psi/tests/labeled-psi/data"); auto senderParty = mockParty(uint16_t(PartyType::Server), "sender", "senderPartyResource", "sender_inputs", DataResourceType::FILE, ""); @@ -111,7 +115,8 @@ void saveCache(LabeledPSIImpl::Ptr _sender) void loadCache(LabeledPSIImpl::Ptr _sender) { - std::string cachePath = "../../../ppc-psi/tests/labeled-psi/data/sender_cache.txt"; + std::string cachePath = + "../../../../wedpr-computing/ppc-psi/tests/labeled-psi/data/sender_cache.txt"; auto senderParty = mockParty(uint16_t(PartyType::Server), "sender", "senderPartyResource", "sender_inputs", DataResourceType::FILE, cachePath); diff --git a/cpp/wedpr-computing/ppc-psi/tests/ra2018-psi/TestEcdhPSIImpl.cpp b/cpp/wedpr-computing/ppc-psi/tests/ra2018-psi/TestEcdhPSIImpl.cpp index 766aa7df..a7df31a2 100644 --- a/cpp/wedpr-computing/ppc-psi/tests/ra2018-psi/TestEcdhPSIImpl.cpp +++ b/cpp/wedpr-computing/ppc-psi/tests/ra2018-psi/TestEcdhPSIImpl.cpp @@ -61,8 +61,8 @@ void testEcdhImplFunc(int64_t _dataBatchSize, std::string const& _serverPSIDataS auto clientPSI = factory->createEcdhPSI(clientAgencyName, clientConfig); std::vector agencyList = {serverAgencyName, clientAgencyName}; - // serverPSI->psiConfig()->updateAgenyList(agencyList); - // clientPSI->psiConfig()->updateAgenyList(agencyList); + serverPSI->psiConfig()->setAgencyList(agencyList); + clientPSI->psiConfig()->setAgencyList(agencyList); // register the server-psi into the front factory->front()->registerEcdhPSI(serverAgencyName, serverPSI); @@ -109,8 +109,10 @@ void testEcdhImplFunc(int64_t _dataBatchSize, std::string const& _serverPSIDataS void testNormalCase(std::string const& _outputPrefix, int64_t _dataBatchSize) { - std::string serverDataPath = "../../../ppc-psi/tests/ra2018-psi/mock-data/fullevaluate.txt"; - std::string clientDataPath = "../../../ppc-psi/tests/ra2018-psi/mock-data/psi.txt"; + std::string serverDataPath = + "../../../../wedpr-computing/ppc-psi/tests/ra2018-psi/mock-data/fullevaluate.txt"; + std::string clientDataPath = + "../../../../wedpr-computing/ppc-psi/tests/ra2018-psi/mock-data/psi.txt"; std::string outputPath = _outputPrefix + "psiResult.txt"; std::vector expectedResult; for (int i = 1; i < 49; i++) @@ -135,8 +137,9 @@ BOOST_AUTO_TEST_CASE(testNormalEcdhPSICase) BOOST_AUTO_TEST_CASE(testECDHMissingResourceDataCase) { std::string serverPSIDataPath = - "../../../ppc-psi/tests/ra2018-psi/mock-data/fullevaluate-missing.txt"; - std::string clientPSIDataPath = "../../../ppc-psi/tests/ra2018-psi/mock-data/psi.txt"; + "../../../../wedpr-computing/ppc-psi/tests/ra2018-psi/mock-data/fullevaluate-missing.txt"; + std::string clientPSIDataPath = + "../../../../wedpr-computing/ppc-psi/tests/ra2018-psi/mock-data/psi.txt"; std::string outputPath = "psiResult_MissingResourceData.txt"; std::vector expectedResult; testEcdhImplFunc(1000, serverPSIDataPath, clientPSIDataPath, outputPath, true, false, @@ -144,8 +147,10 @@ BOOST_AUTO_TEST_CASE(testECDHMissingResourceDataCase) } BOOST_AUTO_TEST_CASE(testECDHMisMatchTaskID) { - std::string serverPSIDataPath = "../../../ppc-psi/tests/ra2018-psi/mock-data/fullevaluate.txt"; - std::string clientPSIDataPath = "../../../ppc-psi/tests/ra2018-psi/mock-data/psi.txt"; + std::string serverPSIDataPath = + "../../../../wedpr-computing/ppc-psi/tests/ra2018-psi/mock-data/fullevaluate.txt"; + std::string clientPSIDataPath = + "../../../../wedpr-computing/ppc-psi/tests/ra2018-psi/mock-data/psi.txt"; std::string outputPath = "psiResult_MismatchTaskID.txt"; std::vector expectedResult; testEcdhImplFunc(1000, serverPSIDataPath, clientPSIDataPath, outputPath, true, false, diff --git a/cpp/wedpr-computing/ppc-psi/tests/ra2018-psi/TestRA2018Impl.cpp b/cpp/wedpr-computing/ppc-psi/tests/ra2018-psi/TestRA2018Impl.cpp index f25504ae..074766ea 100644 --- a/cpp/wedpr-computing/ppc-psi/tests/ra2018-psi/TestRA2018Impl.cpp +++ b/cpp/wedpr-computing/ppc-psi/tests/ra2018-psi/TestRA2018Impl.cpp @@ -187,9 +187,11 @@ void testRA2018PSIImplFunc(int _dataBatchSize, CuckoofilterOption::Ptr option, void testNormalCase(std::string const& _outputPrefix, CuckoofilterOption::Ptr option, uint64_t _dataBatchSize = 10000) { - std::string dataPath = "../../../ppc-psi/tests/ra2018-psi/mock-data/fullevaluate.txt"; - std::string psiPath = "../../../ppc-psi/tests/ra2018-psi/mock-data/psi.txt"; - std::string appendPath = "../../../ppc-psi/tests/ra2018-psi/mock-data/append-full-evaluate.txt"; + std::string dataPath = + "../../../../wedpr-computing/ppc-psi/tests/ra2018-psi/mock-data/fullevaluate.txt"; + std::string psiPath = "../../../../wedpr-computing/ppc-psi/tests/ra2018-psi/mock-data/psi.txt"; + std::string appendPath = + "../../../../wedpr-computing/ppc-psi/tests/ra2018-psi/mock-data/append-full-evaluate.txt"; std::string outputPath = _outputPrefix + "psiResult.txt"; std::vector expectedResult; for (int i = 1; i < 49; i++) @@ -200,7 +202,7 @@ void testNormalCase(std::string const& _outputPrefix, CuckoofilterOption::Ptr op expectedResult, 0, false, appendPath, std::vector()); // with psi2.txt as input - psiPath = "../../../ppc-psi/tests/ra2018-psi/mock-data/psi2.txt"; + psiPath = "../../../../wedpr-computing/ppc-psi/tests/ra2018-psi/mock-data/psi2.txt"; expectedResult.clear(); for (int i = 2000; i < 4000; i += 3) { @@ -224,8 +226,9 @@ BOOST_AUTO_TEST_CASE(testMisMatchResourceIDCase) option->tagBits = 32; option->maxKickOutCount = 10; option->capacity = 200000; - std::string dataPath = "../../../ppc-psi/tests/ra2018-psi/mock-data/fullevaluate.txt"; - std::string psiPath = "../../../ppc-psi/tests/ra2018-psi/mock-data/psi.txt"; + std::string dataPath = + "../../../../wedpr-computing/ppc-psi/tests/ra2018-psi/mock-data/fullevaluate.txt"; + std::string psiPath = "../../../../wedpr-computing/ppc-psi/tests/ra2018-psi/mock-data/psi.txt"; std::string outputPath = "psiResult_MismatchResource.txt"; std::vector expectedResult; testRA2018PSIImplFunc(10000, option, dataPath, psiPath, outputPath, true, false, expectedResult, diff --git a/cpp/wedpr-storage/ppc-io/tests/TestLineReader.cpp b/cpp/wedpr-storage/ppc-io/tests/TestLineReader.cpp index 47c0a074..2050a9c9 100644 --- a/cpp/wedpr-storage/ppc-io/tests/TestLineReader.cpp +++ b/cpp/wedpr-storage/ppc-io/tests/TestLineReader.cpp @@ -146,7 +146,7 @@ BOOST_AUTO_TEST_CASE(testDataBatch) } BOOST_AUTO_TEST_CASE(testFileLineReader) { - std::string filePath = "../../../ppc-io/tests/data/testData"; + std::string filePath = "../../../../wedpr-storage/ppc-io/tests/data/testData"; uint64_t fileTotalLine = 10000; std::vector fileData; for (uint64_t i = 1; i <= fileTotalLine; i++) @@ -173,11 +173,11 @@ BOOST_AUTO_TEST_CASE(testFileLineReader) << ", pageSize:" << pageSize << std::endl; // case4: the windows file - auto windowsFilePath = "../../../ppc-io/tests/data/windows_file.txt"; + auto windowsFilePath = "../../../../wedpr-storage/ppc-io/tests/data/windows_file.txt"; auto lineReader = factory->createLineReader(windowsFilePath, pageSize, '\n'); auto windowsDataBatch = lineReader->next(-1, DataSchema::Bytes); - auto linuxFilePath = "../../../ppc-io/tests/data/linux_file.txt"; + auto linuxFilePath = "../../../../wedpr-storage/ppc-io/tests/data/linux_file.txt"; lineReader = factory->createLineReader(linuxFilePath, pageSize, '\n'); auto linuxDataBatch = lineReader->next(-1, DataSchema::Bytes); BOOST_CHECK(windowsDataBatch->size() == linuxDataBatch->size()); diff --git a/cpp/wedpr-transport/ppc-front/CMakeLists.txt b/cpp/wedpr-transport/ppc-front/CMakeLists.txt index ae55348b..efd94094 100644 --- a/cpp/wedpr-transport/ppc-front/CMakeLists.txt +++ b/cpp/wedpr-transport/ppc-front/CMakeLists.txt @@ -6,8 +6,8 @@ aux_source_directory(ppc-front SRCS) add_library(${FRONT_TARGET} ${SRCS}) target_link_libraries(${FRONT_TARGET} PUBLIC ${TARS_PROTOCOL_TARGET} TBB::tbb TCMalloc) -if (TESTS) - enable_testing() - set(CTEST_OUTPUT_ON_FAILURE TRUE) - add_subdirectory(test) -endif () \ No newline at end of file +#if (TESTS) +# enable_testing() +# set(CTEST_OUTPUT_ON_FAILURE TRUE) +# add_subdirectory(test) +#endif () \ No newline at end of file diff --git a/cpp/wedpr-transport/ppc-front/test/CMakeLists.txt b/cpp/wedpr-transport/ppc-front/test/CMakeLists.txt index d1b76fd6..af0aa6db 100644 --- a/cpp/wedpr-transport/ppc-front/test/CMakeLists.txt +++ b/cpp/wedpr-transport/ppc-front/test/CMakeLists.txt @@ -10,4 +10,4 @@ target_compile_options(${FRONT_TEST_BINARY_NAME} PRIVATE -Wno-error -Wno-unused- target_link_libraries(${FRONT_TEST_BINARY_NAME} ${FRONT_TARGET} ${PROTOCOL_TARGET} ${BOOST_UNIT_TEST}) -add_test(NAME test-front WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/ppc-front/test/unittests COMMAND ${FRONT_TEST_BINARY_NAME}) \ No newline at end of file +add_test(NAME test-front WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${FRONT_TEST_BINARY_NAME}) \ No newline at end of file diff --git a/cpp/wedpr-transport/ppc-gateway/test/CMakeLists.txt b/cpp/wedpr-transport/ppc-gateway/test/CMakeLists.txt index 8a952e2f..8b5234a0 100644 --- a/cpp/wedpr-transport/ppc-gateway/test/CMakeLists.txt +++ b/cpp/wedpr-transport/ppc-gateway/test/CMakeLists.txt @@ -14,4 +14,4 @@ target_compile_options(${GATEWAY_TEST_BINARY_NAME} PRIVATE -Wno-error -Wno-unuse target_link_libraries(${GATEWAY_TEST_BINARY_NAME} ${GATEWAY_TARGET} ${FRONT_TARGET} ${PROTOCOL_TARGET} ${BOOST_UNIT_TEST}) -add_test(NAME test-gateway WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/ppc-gateway/test/unittests COMMAND ${GATEWAY_TEST_BINARY_NAME}) \ No newline at end of file +add_test(NAME test-gateway WORKING_DIRECTORY WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${GATEWAY_TEST_BINARY_NAME}) \ No newline at end of file