aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArthur Eubanks <aeubanks@google.com>2017-10-11 11:10:28 -0700
committerArthur Eubanks <aeubanks@google.com>2017-10-11 15:40:52 -0700
commitbcff3fdb8cf4eff1035261dee2b09d6af502de80 (patch)
treec338d1970362b5d364046bc7407bd94b6f581299 /src
parent95829fe95fa0047223633aee98d05064c1b8ce3d (diff)
downloadcontrib-bcff3fdb8cf4eff1035261dee2b09d6af502de80.tar.gz
Add some target preparers and add tests
One target preparer that just reboot One target preparer that restarts the system server Also added contrib tests as part of google-tradefed-all Test: run_tradefed_tests.sh Change-Id: I2a24e08e7c86199e9cab66a602417c18be0b4c1a
Diffstat (limited to 'src')
-rw-r--r--src/com/android/tradefed/targetprep/RebootTargetPreparer.java30
-rw-r--r--src/com/android/tradefed/targetprep/RestartSystemServerTargetPreparer.java46
2 files changed, 76 insertions, 0 deletions
diff --git a/src/com/android/tradefed/targetprep/RebootTargetPreparer.java b/src/com/android/tradefed/targetprep/RebootTargetPreparer.java
new file mode 100644
index 0000000..fb7f3f0
--- /dev/null
+++ b/src/com/android/tradefed/targetprep/RebootTargetPreparer.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.tradefed.targetprep;
+
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.config.OptionClass;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+
+@OptionClass(alias = "reboot")
+public class RebootTargetPreparer implements ITargetPreparer {
+ @Override
+ public void setUp(ITestDevice device, IBuildInfo buildInfo)
+ throws TargetSetupError, BuildError, DeviceNotAvailableException {
+ device.reboot();
+ }
+}
diff --git a/src/com/android/tradefed/targetprep/RestartSystemServerTargetPreparer.java b/src/com/android/tradefed/targetprep/RestartSystemServerTargetPreparer.java
new file mode 100644
index 0000000..18d9027
--- /dev/null
+++ b/src/com/android/tradefed/targetprep/RestartSystemServerTargetPreparer.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.tradefed.targetprep;
+
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.config.OptionClass;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.util.IRunUtil;
+import com.android.tradefed.util.RunUtil;
+
+@OptionClass(alias = "restart-system-server")
+public class RestartSystemServerTargetPreparer implements ITargetPreparer {
+ private static final long SLEEP_MILLIS = 5000L;
+
+ private IRunUtil mRunUtil;
+
+ public RestartSystemServerTargetPreparer() {
+ this(RunUtil.getDefault());
+ }
+
+ public RestartSystemServerTargetPreparer(IRunUtil runUtil) {
+ this.mRunUtil = runUtil;
+ }
+
+ @Override
+ public void setUp(ITestDevice device, IBuildInfo buildInfo)
+ throws TargetSetupError, BuildError, DeviceNotAvailableException {
+ String pid = device.executeShellCommand("pidof system_server");
+ device.executeShellCommand("kill " + pid);
+ mRunUtil.sleep(SLEEP_MILLIS);
+ }
+}