From f277f368a1fe3f6d0bc4f88a19eaaf8e958036cc Mon Sep 17 00:00:00 2001 From: Rick V Date: Wed, 30 Jan 2019 11:24:02 -0600 Subject: [PATCH] win32 g++ is set to c++17 by default, so we use the _real_ string_view class --- CMakeLists.txt | 2 ++ daemon/main.cpp | 16 ++++++++++------ test/crypto/test_llarp_crypto_types.cpp | 5 +++++ test/util/test_llarp_util_ini.cpp | 6 +++++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 067059477..2ac032570 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,6 +104,8 @@ else() endif(DEBIAN) # only needed if using AVX2 +# TODO: generate a config-time test for this +# in cmake if(AMD_RYZEN_HACK AND USE_AVX2) set(CRYPTO_FLAGS -march=native -mfpmath=sse -mavx -mavx2 -mfma) endif(AMD_RYZEN_HACK AND USE_AVX2) diff --git a/daemon/main.cpp b/daemon/main.cpp index b2dae2afa..6c82249c8 100644 --- a/daemon/main.cpp +++ b/daemon/main.cpp @@ -6,7 +6,10 @@ #include #include + +#ifndef _WIN32 #include +#endif #include #include @@ -62,6 +65,7 @@ handle_signal_win32(DWORD fdwCtrlType) std::string resolvePath(std::string conffname) { +#ifndef _WIN32 wordexp_t exp_result; wordexp(conffname.c_str(), &exp_result, 0); char *resolvedPath = realpath(exp_result.we_wordv[0], NULL); @@ -71,6 +75,11 @@ resolvePath(std::string conffname) return ""; } return resolvedPath; +#else + // TODO(despair): dig through LLVM local patch set + // one of these exists deep in the bowels of LLVMSupport + return conffname; // eww, easier said than done outside of cygwin +#endif } int @@ -110,11 +119,6 @@ main(int argc, char *argv[]) genconfigOnly = true; break; case 'r': -#ifdef _WIN32 - llarp::LogWarn( - "please don't try this at home, the relay feature is untested on " - "windows server --R."); -#endif asRouter = true; break; case 'f': @@ -227,7 +231,7 @@ main(int argc, char *argv[]) } // this is important, can downgrade from Info though - llarp::LogInfo("Running from: ", cpp17::filesystem::current_path()); + llarp::LogInfo("Running from: ", fs::current_path()); llarp::LogInfo("Using config file: ", conffname); ctx = llarp_main_init(conffname.c_str(), multiThreaded); int code = 1; diff --git a/test/crypto/test_llarp_crypto_types.cpp b/test/crypto/test_llarp_crypto_types.cpp index e2d703d1e..549fa0dc3 100644 --- a/test/crypto/test_llarp_crypto_types.cpp +++ b/test/crypto/test_llarp_crypto_types.cpp @@ -256,8 +256,13 @@ TEST_F(TestCryptoTypesSecret, secret_key_to_missing_file) // Verify writing to an unwritable file fails. // Assume we're not running as root, so can't write to / // if we are root just skip this test + // TODO(despair): check elevation status, return if running + // as someone who can write to C:/ + // (normal users cannot write to C:/) +#ifndef _WIN32 if(getuid() == 0) return; +#endif filename = "/" + filename; p = filename; ASSERT_FALSE(fs::exists(fs::status(p))); diff --git a/test/util/test_llarp_util_ini.cpp b/test/util/test_llarp_util_ini.cpp index 0caf871e7..d7dc5db0b 100644 --- a/test/util/test_llarp_util_ini.cpp +++ b/test/util/test_llarp_util_ini.cpp @@ -31,7 +31,11 @@ TEST_F(TestINIParser, TestParseOneSection) ASSERT_EQ(itr, sect.end()); itr = sect.find("key"); ASSERT_NE(itr, sect.end()); +#if __cplusplus >= 201703L + ASSERT_STREQ(itr->second.data(), "val"); +#else ASSERT_STREQ(itr->second.c_str(), "val"); +#endif } TEST_F(TestINIParser, TestParseSectionDuplicateKeys) @@ -49,4 +53,4 @@ TEST_F(TestINIParser, TestParseSectionDuplicateKeys) TEST_F(TestINIParser, TestParseInvalid) { ASSERT_FALSE(parser.LoadString("srged5ghe5\nf34wtge5\nw34tgfs4ygsd5yg=4;\n#g4syhgd5\n")); -} \ No newline at end of file +}