diff options
author | Joe Onorato <joeo@google.com> | 2016-11-12 16:34:25 -0800 |
---|---|---|
committer | Joe Onorato <joeo@google.com> | 2016-11-29 17:36:36 -0800 |
commit | 6592c3cc8f37aae2058021b7971c33b94fc7ce5d (patch) | |
tree | 8effe0397dbcacfebf3e59bf3406077e771221ae /tools/bit | |
parent | 43518242a35abef019057081d827ae3a1330ae2f (diff) |
Add an option to bit to not restart.
Test: build & restart
Change-Id: Ia925053f04046d7fb91a47cfd5fd17a5d4fecf10
Diffstat (limited to 'tools/bit')
-rw-r--r-- | tools/bit/main.cpp | 62 |
1 files changed, 36 insertions, 26 deletions
diff --git a/tools/bit/main.cpp b/tools/bit/main.cpp index 4974a447be91..868d90a1188d 100644 --- a/tools/bit/main.cpp +++ b/tools/bit/main.cpp @@ -79,6 +79,7 @@ struct Options { string tabPattern; // For build/install/test + bool noRestart; bool reboot; vector<Target*> targets; @@ -89,6 +90,7 @@ struct Options { Options::Options() :runHelp(false), runTab(false), + noRestart(false), reboot(false), targets() { @@ -285,6 +287,7 @@ print_usage(FILE* out) { fprintf(out, " -i Install the targets\n"); fprintf(out, " -t Run the tests\n"); fprintf(out, "\n"); + fprintf(out, " -n Don't reboot or restart\n"); fprintf(out, " -r If the runtime needs to be restarted, do a full reboot\n"); fprintf(out, " instead\n"); fprintf(out, "\n"); @@ -431,6 +434,9 @@ parse_args(Options* options, int argc, const char** argv) flagTest = true; anyPhases = true; break; + case 'n': + options->noRestart = true; + break; case 'r': options->reboot = true; break; @@ -558,7 +564,7 @@ check_device_property(const string& property, const string& expected) * Run the build, install, and test actions. */ void -run_phases(vector<Target*> targets, bool reboot) +run_phases(vector<Target*> targets, const Options& options) { int err = 0; @@ -676,40 +682,44 @@ run_phases(vector<Target*> targets, bool reboot) check_device_property("ro.build.id", buildId); // Stop & Sync - err = run_adb("shell", "stop", NULL); - check_error(err); + if (!options.noRestart) { + err = run_adb("shell", "stop", NULL); + check_error(err); + } err = run_adb("remount", NULL); check_error(err); err = run_adb("sync", "system", NULL); check_error(err); - if (reboot) { - print_status("Rebooting"); + if (!options.noRestart) { + if (options.reboot) { + print_status("Rebooting"); - err = run_adb("reboot", NULL); - check_error(err); - err = run_adb("wait-for-device", NULL); - check_error(err); - } else { - print_status("Restarting the runtime"); + err = run_adb("reboot", NULL); + check_error(err); + err = run_adb("wait-for-device", NULL); + check_error(err); + } else { + print_status("Restarting the runtime"); - err = run_adb("shell", "setprop", "sys.boot_completed", "0", NULL); - check_error(err); - err = run_adb("shell", "start", NULL); - check_error(err); - } + err = run_adb("shell", "setprop", "sys.boot_completed", "0", NULL); + check_error(err); + err = run_adb("shell", "start", NULL); + check_error(err); + } - while (true) { - string completed = get_system_property("sys.boot_completed", &err); - check_error(err); - if (completed == "1") { - break; + while (true) { + string completed = get_system_property("sys.boot_completed", &err); + check_error(err); + if (completed == "1") { + break; + } + sleep(2); } - sleep(2); + sleep(1); + err = run_adb("shell", "wm", "dismiss-keyguard", NULL); + check_error(err); } - sleep(1); - err = run_adb("shell", "wm", "dismiss-keyguard", NULL); - check_error(err); } } @@ -976,7 +986,7 @@ main(int argc, const char** argv) exit(0); } else { // Normal run - run_phases(options.targets, options.reboot); + run_phases(options.targets, options); } return 0; |