OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #ifndef O_BINARY | 59 #ifndef O_BINARY |
60 #ifdef _O_BINARY | 60 #ifdef _O_BINARY |
61 #define O_BINARY _O_BINARY | 61 #define O_BINARY _O_BINARY |
62 #else | 62 #else |
63 #define O_BINARY 0 // If this isn't defined, the platform doesn't need it. | 63 #define O_BINARY 0 // If this isn't defined, the platform doesn't need it. |
64 #endif | 64 #endif |
65 #endif | 65 #endif |
66 | 66 |
67 string TestSourceDir() { | 67 string TestSourceDir() { |
68 #ifndef GOOGLE_THIRD_PARTY_PROTOBUF | 68 #ifndef GOOGLE_THIRD_PARTY_PROTOBUF |
| 69 #ifdef GOOGLE_PROTOBUF_TEST_SOURCE_PATH |
| 70 return GOOGLE_PROTOBUF_TEST_SOURCE_PATH; |
| 71 #else |
69 #ifndef _MSC_VER | 72 #ifndef _MSC_VER |
70 // automake sets the "srcdir" environment variable. | 73 // automake sets the "srcdir" environment variable. |
71 char* result = getenv("srcdir"); | 74 char* result = getenv("srcdir"); |
72 if (result != NULL) { | 75 if (result != NULL) { |
73 return result; | 76 return result; |
74 } | 77 } |
75 #endif // _MSC_VER | 78 #endif // _MSC_VER |
76 | 79 |
77 // Look for the "src" directory. | 80 // Look for the "src" directory. |
78 string prefix = "."; | 81 string prefix = "."; |
79 | 82 |
80 while (!File::Exists(prefix + "/src/google/protobuf")) { | 83 while (!File::Exists(prefix + "/src/google/protobuf")) { |
81 if (!File::Exists(prefix)) { | 84 if (!File::Exists(prefix)) { |
82 GOOGLE_LOG(FATAL) | 85 GOOGLE_LOG(FATAL) |
83 << "Could not find protobuf source code. Please run tests from " | 86 << "Could not find protobuf source code. Please run tests from " |
84 "somewhere within the protobuf source package."; | 87 "somewhere within the protobuf source package."; |
85 } | 88 } |
86 prefix += "/.."; | 89 prefix += "/.."; |
87 } | 90 } |
88 return prefix + "/src"; | 91 return prefix + "/src"; |
| 92 #endif // GOOGLE_PROTOBUF_TEST_SOURCE_PATH |
89 #else | 93 #else |
90 return "third_party/protobuf/src"; | 94 return "third_party/protobuf/src"; |
91 #endif // GOOGLE_THIRD_PARTY_PROTOBUF | 95 #endif // GOOGLE_THIRD_PARTY_PROTOBUF |
92 } | 96 } |
93 | 97 |
94 namespace { | 98 namespace { |
95 | 99 |
96 string GetTemporaryDirectoryName() { | 100 string GetTemporaryDirectoryName() { |
97 // Tests run under Bazel "should not" use /tmp. Bazel sets this environment | 101 // Tests run under Bazel "should not" use /tmp. Bazel sets this environment |
98 // variable for tests to use instead. | 102 // variable for tests to use instead. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 struct ForceShutdown { | 262 struct ForceShutdown { |
259 ~ForceShutdown() { | 263 ~ForceShutdown() { |
260 ShutdownProtobufLibrary(); | 264 ShutdownProtobufLibrary(); |
261 } | 265 } |
262 } force_shutdown; | 266 } force_shutdown; |
263 | 267 |
264 } // namespace | 268 } // namespace |
265 | 269 |
266 } // namespace protobuf | 270 } // namespace protobuf |
267 } // namespace google | 271 } // namespace google |
OLD | NEW |