From: Lukasz Pawelczyk Date: Thu, 4 Aug 2016 11:15:50 +0000 (+0200) Subject: YACA: Use local test-vectors when available X-Git-Tag: security-manager_5.5_testing~38 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2b092db01a87d72651cc6b67a1e747b565004fd0;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git YACA: Use local test-vectors when available Copy test-vectors to the local build dir and use them instead if available. This makes possible to run the tests without "make install" directly in the cmake build directory. Change-Id: I4041cf669960e4b199aa14adfb8c17a9c991be2c --- diff --git a/src/yaca/CMakeLists.txt b/src/yaca/CMakeLists.txt index 38d66517..303e75f7 100644 --- a/src/yaca/CMakeLists.txt +++ b/src/yaca/CMakeLists.txt @@ -29,6 +29,10 @@ FILE(GLOB yaca_test_SRCS *.cpp) SET(YACA_TEST "yaca-test") ADD_EXECUTABLE(${YACA_TEST} ${yaca_test_SRCS}) +ADD_CUSTOM_TARGET(copy-test-vectors ALL + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/test-vectors ${CMAKE_CURRENT_BINARY_DIR}/test-vectors + DEPENDS ${YACA_TEST}) + IF(NOT DEFINED YACA_TEST_DIR) SET(YACA_TEST_DIR "${SHARE_INSTALL_PREFIX}/${YACA_TEST}") ENDIF(NOT DEFINED YACA_TEST_DIR) @@ -49,4 +53,4 @@ TARGET_LINK_LIBRARIES(${YACA_TEST} ## Install ##################################################################### INSTALL(TARGETS ${YACA_TEST} DESTINATION bin) -INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test-vectors DESTINATION ${YACA_TEST_DIR}) \ No newline at end of file +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test-vectors DESTINATION ${YACA_TEST_DIR}) diff --git a/src/yaca/yaca-test-vector.cpp b/src/yaca/yaca-test-vector.cpp index b0c2087d..5b2011d9 100644 --- a/src/yaca/yaca-test-vector.cpp +++ b/src/yaca/yaca-test-vector.cpp @@ -183,13 +183,16 @@ std::string TestVector::value(const std::string &key) const TestVectorVector loadTestVector(const std::string &filename) { - std::string path = std::string(YACA_TEST_DIR"/test-vectors/") + filename; + std::string path_local = std::string("./test-vectors/") + filename; + std::string path_shared = std::string(YACA_TEST_DIR"/test-vectors/") + filename; TestVectorVector tvv; - std::ifstream ifs(path, std::ifstream::in); + std::ifstream ifs(path_local, std::ifstream::in); + if (!ifs) + ifs.open(path_shared, std::ifstream::in); - RUNNER_ASSERT_MSG(ifs, "Failed to open " << path); + RUNNER_ASSERT_MSG(ifs, "Failed to open " << filename); std::string line; TestVector tv; while (std::getline(ifs, line)) @@ -215,7 +218,7 @@ TestVectorVector loadTestVector(const std::string &filename) if (ifs.eof()) break; } - RUNNER_ASSERT_MSG(ifs.eof(), "Failed to read " << path); + RUNNER_ASSERT_MSG(ifs.eof(), "Failed to read " << filename); if (!tv.empty()) tvv.push_back(tv); return tvv;