OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This class sets up the environment for running the native tests inside an | 5 // This class sets up the environment for running the native tests inside an |
6 // android application. It outputs (to a fifo) markers identifying the | 6 // android application. It outputs (to a fifo) markers identifying the |
7 // START/PASSED/CRASH of the test suite, FAILURE/SUCCESS of individual tests, | 7 // START/PASSED/CRASH of the test suite, FAILURE/SUCCESS of individual tests, |
8 // etc. | 8 // etc. |
9 // These markers are read by the test runner script to generate test results. | 9 // These markers are read by the test runner script to generate test results. |
10 // It installs signal handlers to detect crashes. | 10 // It installs signal handlers to detect crashes. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 argv->resize(argc + 1); | 111 argv->resize(argc + 1); |
112 for (int i = 0; i < argc; ++i) | 112 for (int i = 0; i < argc; ++i) |
113 (*argv)[i] = const_cast<char*>(args[i].c_str()); | 113 (*argv)[i] = const_cast<char*>(args[i].c_str()); |
114 (*argv)[argc] = NULL; // argv must be NULL terminated. | 114 (*argv)[argc] = NULL; // argv must be NULL terminated. |
115 | 115 |
116 return argc; | 116 return argc; |
117 } | 117 } |
118 | 118 |
119 void CreateFIFO(const char* fifo_path) { | 119 void CreateFIFO(const char* fifo_path) { |
120 unlink(fifo_path); | 120 unlink(fifo_path); |
121 if (mkfifo(fifo_path, 0666)) { | 121 // Default permissions for mkfifo is ignored, chmod is required. |
| 122 if (mkfifo(fifo_path, 0666) || chmod(fifo_path, 0666)) { |
122 AndroidLogError("Failed to create fifo %s: %s\n", | 123 AndroidLogError("Failed to create fifo %s: %s\n", |
123 fifo_path, strerror(errno)); | 124 fifo_path, strerror(errno)); |
124 exit(EXIT_FAILURE); | 125 exit(EXIT_FAILURE); |
125 } | 126 } |
126 } | 127 } |
127 | 128 |
128 void Redirect(FILE* stream, const char* path, const char* mode) { | 129 void Redirect(FILE* stream, const char* path, const char* mode) { |
129 if (!freopen(path, mode, stream)) { | 130 if (!freopen(path, mode, stream)) { |
130 AndroidLogError("Failed to redirect stream to file: %s: %s\n", | 131 AndroidLogError("Failed to redirect stream to file: %s: %s\n", |
131 path, strerror(errno)); | 132 path, strerror(errno)); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 InstallHandlers(); | 228 InstallHandlers(); |
228 | 229 |
229 base::android::InitVM(vm); | 230 base::android::InitVM(vm); |
230 JNIEnv* env = base::android::AttachCurrentThread(); | 231 JNIEnv* env = base::android::AttachCurrentThread(); |
231 if (!RegisterNativesImpl(env)) { | 232 if (!RegisterNativesImpl(env)) { |
232 return -1; | 233 return -1; |
233 } | 234 } |
234 | 235 |
235 return JNI_VERSION_1_4; | 236 return JNI_VERSION_1_4; |
236 } | 237 } |
OLD | NEW |