File tree 2 files changed +25
-3
lines changed
2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -272,11 +272,13 @@ int main(int argc, char **argv) {
272
272
273
273
#ifdef WIN32
274
274
#include < direct.h>
275
- _chdir (hardwarePrefix[productFamily]);
275
+ if (_chdir (hardwarePrefix[productFamily])) {
276
+ std::cout << " chdir into " << hardwarePrefix[productFamily] << " directory failed.\n This might cause test failures." << std::endl;
277
+ }
276
278
#elif defined(__linux__)
277
279
#include < unistd.h>
278
280
if (chdir (hardwarePrefix[productFamily]) != 0 ) {
279
- std::cout << " chdir failed! Ignoring ." << std::endl;
281
+ std::cout << " chdir into " << hardwarePrefix[productFamily] << " directory failed. \n This might cause test failures ." << std::endl;
280
282
}
281
283
#endif
282
284
Original file line number Diff line number Diff line change @@ -43,7 +43,15 @@ std::string getRunPath(char *argv0) {
43
43
44
44
auto pos = res.rfind (fSeparator );
45
45
if (pos != std::string::npos)
46
- return res.substr (0 , pos);
46
+ res = res.substr (0 , pos);
47
+
48
+ if (res == " ." || pos == std::string::npos) {
49
+ #if defined(__linux__)
50
+ res = getcwd (nullptr , 0 );
51
+ #else
52
+ res = _getcwd (nullptr , 0 );
53
+ #endif
54
+ }
47
55
48
56
return res;
49
57
}
@@ -96,6 +104,18 @@ int main(int argc, char **argv) {
96
104
nTestFiles.append (testFiles);
97
105
testFiles = nTestFiles;
98
106
107
+ #ifdef WIN32
108
+ #include < direct.h>
109
+ if (_chdir (devicePrefix.c_str ())) {
110
+ std::cout << " chdir into " << devicePrefix << " directory failed.\n This might cause test failures." << std::endl;
111
+ }
112
+ #elif defined(__linux__)
113
+ #include < unistd.h>
114
+ if (chdir (devicePrefix.c_str ()) != 0 ) {
115
+ std::cout << " chdir into " << devicePrefix << " directory failed.\n This might cause test failures." << std::endl;
116
+ }
117
+ #endif
118
+
99
119
if (useDefaultListener == false ) {
100
120
::testing::TestEventListeners &listeners = ::testing::UnitTest::GetInstance ()->listeners ();
101
121
::testing::TestEventListener *defaultListener = listeners.default_result_printer ();
You can’t perform that action at this time.
0 commit comments