diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-11-04 06:45:21 -0800 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-11-04 06:45:21 -0800 |
commit | 885d61e5def90678c89235e7b79750375f180220 (patch) | |
tree | b04ab803030049cce966a0090aee0ca8184e479a /test | |
parent | 67eae5724a8e1caa36ca492ebe5f7e0d01b42ce1 (diff) | |
download | qtlocation-mapboxgl-885d61e5def90678c89235e7b79750375f180220.tar.gz |
use dirname() on copies of the parameter only
glibc's dirname() modifies the parameter
Diffstat (limited to 'test')
-rw-r--r-- | test/headless.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/test/headless.cpp b/test/headless.cpp index 361f3a9fc7..657bab4c35 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -55,7 +55,11 @@ ServerEnvironment* env = nullptr; GTEST_API_ int main(int argc, char *argv[]) { - base_directory = std::string(dirname(argv[0])) + "/" + dirname(const_cast<char *>(__FILE__)) + "/suite/"; + // Note: glibc's dirname() **modifies** the argument and can't handle static strings. + std::string argv0 { argv[0] }; argv0 = dirname(const_cast<char *>(argv0.c_str())); + std::string file { __FILE__ }; file = dirname(const_cast<char *>(file.c_str())); + base_directory = argv0 + "/" + file + "/suite/"; + testing::InitGoogleTest(&argc, argv); env = new ServerEnvironment(); ::testing::AddGlobalTestEnvironment(env); |