diff options
| author | Joey Jiao <joeyjiaojg@gmail.com> | 2021-03-29 14:37:22 +0800 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2021-04-14 19:04:39 +0200 |
| commit | e40a490e9c5e71bb3c0aca2a1ddcf7af4845635d (patch) | |
| tree | 96fb8d65e2b684cd46c579a58a7c20dd5f0e3e39 /vm/adb | |
| parent | 5c9ed2bcc8d10336c1389d63db51a4bde97b16a0 (diff) | |
vm/adb: add startup_script config
Diffstat (limited to 'vm/adb')
| -rw-r--r-- | vm/adb/adb.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/vm/adb/adb.go b/vm/adb/adb.go index cbd5109b1..92e49c346 100644 --- a/vm/adb/adb.go +++ b/vm/adb/adb.go @@ -40,7 +40,8 @@ type Config struct { BatteryCheck bool `json:"battery_check"` // If this option is set (default), the device is rebooted after each crash. // Set it to false to disable reboots. - TargetReboot bool `json:"target_reboot"` + TargetReboot bool `json:"target_reboot"` + StartupScript string `json:"startup_script"` // script to execute after each startup } type Pool struct { @@ -283,7 +284,21 @@ func (inst *instance) repair() error { } // Switch to root for userdebug builds. inst.adb("root") - return inst.waitForSSH() + inst.waitForSSH() + if inst.cfg.StartupScript != "" { + log.Logf(2, "adb: executing startup_script") + // Execute the contents of the StartupScript on the DUT. + contents, err := ioutil.ReadFile(inst.cfg.StartupScript) + if err != nil { + return fmt.Errorf("unable to read startup_script: %v", err) + } + c := string(contents) + if _, err := inst.adb("shell", fmt.Sprintf("sh -c \"%v\"", vmimpl.EscapeDoubleQuotes(c))); err != nil { + return fmt.Errorf("failed to execute startup_script: %v", err) + } + log.Logf(2, "adb: done executing startup_script") + } + return nil } func (inst *instance) waitForSSH() error { |
