Skip to content

Commit

Permalink
Upstream: Fix the native test launcher for Chrome on Android.
Browse files Browse the repository at this point in the history
We need to terminate our own constructed argv[] before passing
it into gtest as gtest requires a null-terminated argv.

BUG=
TEST=


Review URL: https://chromiumcodereview.appspot.com/10692095

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145525 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jknotten@chromium.org committed Jul 5, 2012
1 parent d037f9a commit c30192f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions testing/android/native_test_launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit c30192f

Please sign in to comment.