aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests/main.cpp
diff options
context:
space:
mode:
authorredfish <redfish@galactica.pw>2017-09-25 02:46:14 +0000
committerredfish <redfish@galactica.pw>2017-09-28 01:41:44 -0400
commit540d6fa3d5757e30bc251cbe9f2474e67c0a5d74 (patch)
tree83baac57511623349caccfb636d1ffcd536e25b6 /tests/unit_tests/main.cpp
parentMerge pull request #2496 (diff)
downloadmonero-540d6fa3d5757e30bc251cbe9f2474e67c0a5d74.tar.xz
tests: pass data dir as arg
This fixes test failure on builds that happen to be built in 'build/' instead of 'build/release'. Use boost filesystem path type.
Diffstat (limited to 'tests/unit_tests/main.cpp')
-rw-r--r--tests/unit_tests/main.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/unit_tests/main.cpp b/tests/unit_tests/main.cpp
index b470249a3..b2abad942 100644
--- a/tests/unit_tests/main.cpp
+++ b/tests/unit_tests/main.cpp
@@ -30,14 +30,32 @@
#include "gtest/gtest.h"
+#include <boost/filesystem.hpp>
+
#include "include_base_utils.h"
+#include "unit_tests_utils.h"
+
+boost::filesystem::path unit_test::data_dir;
int main(int argc, char** argv)
{
- epee::string_tools::set_module_name_and_folder(argv[0]);
mlog_configure(mlog_get_default_log_path("unit_tests.log"), true);
epee::debug::get_set_enable_assert(true, false);
::testing::InitGoogleTest(&argc, argv);
+
+ // Process remaining arguments
+ if (argc == 2 && argv[1] != NULL) { // one arg: path to dir with test data
+ unit_test::data_dir = argv[1];
+ } else if (argc == 1) { // legacy: assume test binaries in 'build/release'
+ epee::string_tools::set_module_name_and_folder(argv[0]);
+ unit_test::data_dir = boost::filesystem::path(epee::string_tools::get_current_module_folder())
+ .parent_path().parent_path().parent_path().parent_path()
+ .append("tests").append("data");
+ } else {
+ std::cerr << "Usage: " << argv[0] << " [<path-to-test-data-dir>]" << std::endl;
+ return 1;
+ }
+
return RUN_ALL_TESTS();
}