diff options
-rw-r--r-- | testing/android/native_test_launcher.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/testing/android/native_test_launcher.cc b/testing/android/native_test_launcher.cc index 1bf9cc7..68180917 100644 --- a/testing/android/native_test_launcher.cc +++ b/testing/android/native_test_launcher.cc @@ -89,13 +89,17 @@ void ParseArgsFromCommandLineFile(std::vector<std::string>* args) { } } -void ArgsToArgv(const std::vector<std::string>& args, +int ArgsToArgv(const std::vector<std::string>& args, std::vector<char*>* argv) { // We need to pass in a non-const char**. int argc = args.size(); - argv->resize(argc); + + argv->resize(argc + 1); for (int i = 0; i < argc; ++i) (*argv)[i] = const_cast<char*>(args[i].c_str()); + (*argv)[argc] = NULL; // argv must be NULL terminated. + + return argc; } // As we are the native side of an Android app, we don't have any 'console', so @@ -193,9 +197,8 @@ static void RunTests(JNIEnv* env, // We need to pass in a non-const char**. std::vector<char*> argv; - ArgsToArgv(args, &argv); + int argc = ArgsToArgv(args, &argv); - int argc = argv.size(); // This object is owned by gtest. AndroidLogPrinter* log = new AndroidLogPrinter(); log->Init(&argc, &argv[0]); |