Revert "Add misc target preparers plus testing for contrib"

This reverts commit 90512d398cab5cbca6fc5ff74f4b38ed953b52de.

Change-Id: Icd17b8763ca72b31535fdd4aab72f180ae62b510
diff --git a/src/com/android/tradefed/targetprep/FillStorageTargetPreparer.java b/src/com/android/tradefed/targetprep/FillStorageTargetPreparer.java
deleted file mode 100644
index e28faf3..0000000
--- a/src/com/android/tradefed/targetprep/FillStorageTargetPreparer.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.Option;
-import com.android.tradefed.config.OptionClass;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
-
-@OptionClass(alias = "fill-storage")
-public class FillStorageTargetPreparer implements ITargetCleaner {
-
-    private static final String FILL_STORAGE_FILENAME = "/data/bigfile";
-
-    @Option(name = "free-bytes",
-            description = "Number of bytes that should be left free on the device.")
-    private long mFreeBytesRequested;
-
-    private long getDataFreeSpace(ITestDevice device) throws DeviceNotAvailableException {
-        String output = device.executeShellCommand("df /data");
-        String[] lines = output.split("\n");
-        String[] splitLines = lines[1].split("\\s+");
-        return Long.parseLong(splitLines[3]) * 1024L;
-    }
-
-    @Override
-    public void setUp(ITestDevice device, IBuildInfo buildInfo)
-            throws TargetSetupError, BuildError, DeviceNotAvailableException {
-        long freeSpace = getDataFreeSpace(device);
-        if (freeSpace > mFreeBytesRequested) {
-            long bytesToWrite = freeSpace - mFreeBytesRequested;
-            device.executeShellCommand(
-                    String.format("fallocate -l %d %s", bytesToWrite, FILL_STORAGE_FILENAME));
-            CLog.i("Wrote %d bytes to %s", bytesToWrite, FILL_STORAGE_FILENAME);
-        } else {
-            CLog.i("Not enough free space (%d bytes requested free, %d bytes actually free)",
-                    mFreeBytesRequested, freeSpace);
-        }
-    }
-
-    @Override
-    public void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable e)
-            throws DeviceNotAvailableException {
-        device.executeShellCommand("rm -f " + FILL_STORAGE_FILENAME);
-    }
-}
diff --git a/src/com/android/tradefed/targetprep/RestartSystemServerTargetPreparer.java b/src/com/android/tradefed/targetprep/RestartSystemServerTargetPreparer.java
index e8cf053..e4bb872 100644
--- a/src/com/android/tradefed/targetprep/RestartSystemServerTargetPreparer.java
+++ b/src/com/android/tradefed/targetprep/RestartSystemServerTargetPreparer.java
@@ -20,12 +20,11 @@
 import com.android.tradefed.config.OptionClass;
 import com.android.tradefed.device.DeviceNotAvailableException;
 import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.log.LogUtil.CLog;
 import com.android.tradefed.util.IRunUtil;
 import com.android.tradefed.util.RunUtil;
 
 @OptionClass(alias = "restart-system-server")
-public class RestartSystemServerTargetPreparer implements ITargetCleaner {
+public class RestartSystemServerTargetPreparer implements ITargetPreparer {
     @Option(name = "poll-interval-millis",
             description = "Time interval to poll if system server has restarted")
     private long mPollIntervalMillis = 3000L;
@@ -33,12 +32,6 @@
             description = "Max number of tries to poll")
     private int mMaxTries = 10;
 
-    @Option(name = "restart-before")
-    private boolean mRestartBefore = true;
-
-    @Option(name = "restart-after")
-    private boolean mRestartAfter = false;
-
     private IRunUtil mRunUtil;
 
     public RestartSystemServerTargetPreparer() {
@@ -49,7 +42,9 @@
         this.mRunUtil = runUtil;
     }
 
-    private boolean restartSystemServer(ITestDevice device) throws DeviceNotAvailableException {
+    @Override
+    public void setUp(ITestDevice device, IBuildInfo buildInfo)
+            throws TargetSetupError, BuildError, DeviceNotAvailableException {
         device.executeShellCommand("setprop sys.boot_completed 0");
         String pid = device.executeShellCommand("pidof system_server");
         device.executeShellCommand("kill " + pid);
@@ -61,31 +56,9 @@
             }
             mRunUtil.sleep(mPollIntervalMillis);
         }
-        return success;
-    }
-
-    @Override
-    public void setUp(ITestDevice device, IBuildInfo buildInfo)
-            throws TargetSetupError, BuildError, DeviceNotAvailableException {
-        if (!mRestartBefore) {
-            return;
-        }
-        boolean success = restartSystemServer(device);
         if (!success) {
             throw new TargetSetupError("Gave up on waiting for system server to restart",
                     device.getDeviceDescriptor());
         }
     }
-
-    @Override
-    public void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable e)
-            throws DeviceNotAvailableException {
-        if (!mRestartAfter) {
-            return;
-        }
-        boolean success = restartSystemServer(device);
-        if (!success) {
-            CLog.i("Failed to restart system server on tearDown.");
-        }
-    }
 }
diff --git a/src/com/android/tradefed/targetprep/RootTargetPreparer.java b/src/com/android/tradefed/targetprep/RootTargetPreparer.java
deleted file mode 100644
index 0035376..0000000
--- a/src/com/android/tradefed/targetprep/RootTargetPreparer.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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 = "root")
-public class RootTargetPreparer implements ITargetPreparer {
-    @Override
-    public void setUp(ITestDevice device, IBuildInfo buildInfo)
-            throws TargetSetupError, BuildError, DeviceNotAvailableException {
-        if (!device.enableAdbRoot()) {
-            throw new TargetSetupError("Failed to adb root device", device.getDeviceDescriptor());
-        }
-    }
-}
diff --git a/src/com/android/tradefed/targetprep/SaveAndRestoreTimeTargetPreparer.java b/src/com/android/tradefed/targetprep/SaveAndRestoreTimeTargetPreparer.java
deleted file mode 100644
index 922efa7..0000000
--- a/src/com/android/tradefed/targetprep/SaveAndRestoreTimeTargetPreparer.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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.Option;
-import com.android.tradefed.config.OptionClass;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-
-import java.util.concurrent.TimeUnit;
-
-// Remembers the time at the beginning and resets it (plus time elapsed) on cleanup.
-// Can also optionally set the time at the beginning.
-@OptionClass(alias = "save-restore-time")
-public class SaveAndRestoreTimeTargetPreparer implements ITargetCleaner {
-
-    @Option(name = "set-time",
-            description = "Whether or not to set the time")
-    private boolean mSetTime = false;
-
-    @Option(name = "time",
-            description = "Time to set")
-    private long mTimeToSet;
-
-    public interface ITimeGetter {
-        long getTime();
-    }
-
-    public static class RealTimeGetter implements ITimeGetter {
-        @Override
-        public long getTime() {
-            return System.nanoTime();
-        }
-    }
-
-    private long mStartNanoTime, mDeviceStartTimeMillis;
-    private ITimeGetter mTimeGetter;
-
-    public SaveAndRestoreTimeTargetPreparer(ITimeGetter timeGetter) {
-        this.mTimeGetter = timeGetter;
-    }
-
-    public SaveAndRestoreTimeTargetPreparer() {
-        this(new RealTimeGetter());
-    }
-
-    private long getDeviceTime(ITestDevice device) throws DeviceNotAvailableException {
-        return Long.parseLong(device.executeShellCommand("date +\"%s\"").trim());
-    }
-
-    private void setDeviceTime(ITestDevice device, long time) throws DeviceNotAvailableException {
-        device.executeShellCommand("date @" + time);
-    }
-
-    @Override
-    public void setUp(ITestDevice device, IBuildInfo buildInfo)
-            throws TargetSetupError, BuildError, DeviceNotAvailableException {
-        mStartNanoTime = mTimeGetter.getTime();
-        mDeviceStartTimeMillis = getDeviceTime(device);
-        if (mSetTime) {
-            setDeviceTime(device, mTimeToSet);
-        }
-    }
-
-    @Override
-    public void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable e)
-            throws DeviceNotAvailableException {
-        long elapsedNanos = mTimeGetter.getTime() - mStartNanoTime;
-        long newTime = mDeviceStartTimeMillis + TimeUnit.NANOSECONDS.toMillis(elapsedNanos);
-        setDeviceTime(device, newTime);
-    }
-}
diff --git a/src/com/android/tradefed/targetprep/SetAndRestoreSystemPropertyTargetPreparer.java b/src/com/android/tradefed/targetprep/SetAndRestoreSystemPropertyTargetPreparer.java
deleted file mode 100644
index 5637876..0000000
--- a/src/com/android/tradefed/targetprep/SetAndRestoreSystemPropertyTargetPreparer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.Option;
-import com.android.tradefed.config.OptionClass;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-
-import java.util.HashMap;
-import java.util.Map;
-
-@OptionClass(alias = "set-restore-sys-prop")
-public class SetAndRestoreSystemPropertyTargetPreparer implements ITargetCleaner {
-
-    @Option(name = "set-property",
-            description = "Property to set then restore on cleanup")
-    private Map<String, String> mProperties = new HashMap<>();
-
-    private Map<String, String> mOldProperties = new HashMap<>();
-
-    private void setProperty(ITestDevice device, String prop, String newValue)
-            throws DeviceNotAvailableException {
-        device.executeShellCommand(String.format("setprop \"%s\" \"%s\"", prop, newValue));
-    }
-
-    private String getProperty(ITestDevice device, String prop)
-            throws DeviceNotAvailableException {
-        return device.executeShellCommand(String.format("getprop \"%s\"", prop)).trim();
-    }
-
-    @Override
-    public void setUp(ITestDevice device, IBuildInfo buildInfo)
-            throws TargetSetupError, BuildError, DeviceNotAvailableException {
-        for (String prop : mProperties.keySet()) {
-            String oldValue = getProperty(device, prop);
-            mOldProperties.put(prop, oldValue);
-            String newValue = mProperties.get(prop);
-            setProperty(device, prop, newValue);
-            if (!getProperty(device, prop).equals(newValue)) {
-                throw new TargetSetupError("Failed to set property " + prop,
-                        device.getDeviceDescriptor());
-            }
-        }
-    }
-
-    @Override
-    public void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable e)
-            throws DeviceNotAvailableException {
-        for (Map.Entry<String, String> entry : mOldProperties.entrySet()) {
-            setProperty(device, entry.getKey(), entry.getValue());
-        }
-    }
-}
diff --git a/src/com/android/tradefed/targetprep/WriteAndRestoreFileTargetPreparer.java b/src/com/android/tradefed/targetprep/WriteAndRestoreFileTargetPreparer.java
deleted file mode 100644
index 53cb3ba..0000000
--- a/src/com/android/tradefed/targetprep/WriteAndRestoreFileTargetPreparer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.Option;
-import com.android.tradefed.config.OptionClass;
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
-
-import java.io.File;
-
-@OptionClass(alias = "write-restore-file")
-public class WriteAndRestoreFileTargetPreparer implements ITargetCleaner {
-    @Option(name = "file-name",
-            description = "Name of file to write")
-    private String mFileName;
-
-    @Option(name = "contents",
-            description = "Contents to write to file")
-    private String mContents;
-
-    private File mOldContents;
-
-    @Override
-    public void setUp(ITestDevice device, IBuildInfo buildInfo)
-            throws TargetSetupError, BuildError, DeviceNotAvailableException {
-        if (device.doesFileExist(mFileName)) {
-            mOldContents = device.pullFile(mFileName);
-        }
-        if (!device.pushString(mContents, mFileName)) {
-            throw new TargetSetupError("Failed to push string to file",
-                    device.getDeviceDescriptor());
-        }
-    }
-
-    @Override
-    public void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable e)
-            throws DeviceNotAvailableException {
-        if (mOldContents == null) {
-            device.executeShellCommand(String.format("rm -f %s", mFileName));
-        } else {
-            device.pushFile(mOldContents, mFileName);
-        }
-    }
-}
diff --git a/tests/src/com/android/tradefed/ContribUnitTests.java b/tests/src/com/android/tradefed/ContribUnitTests.java
deleted file mode 100644
index 6e098d7..0000000
--- a/tests/src/com/android/tradefed/ContribUnitTests.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2010 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;
-
-import com.android.tradefed.targetprep.FillStorageTargetPreparerTest;
-import com.android.tradefed.targetprep.RebootTargetPreparerTest;
-import com.android.tradefed.targetprep.RestartSystemServerTargetPreparerTest;
-import com.android.tradefed.targetprep.RootTargetPreparerTest;
-import com.android.tradefed.targetprep.SaveAndRestoreTimeTargetPreparerTest;
-import com.android.tradefed.targetprep.SetAndRestoreSystemPropertyTargetPreparerTest;
-import com.android.tradefed.targetprep.WriteAndRestoreFileTargetPreparerTest;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * A test suite for all Trade Federation unit tests running under Junit4.
- *
- * <p>All tests listed here should be self-contained, and should not require any external
- * dependencies.
- */
-@RunWith(Suite.class)
-@SuiteClasses({
-    // targetprep
-    FillStorageTargetPreparerTest.class,
-    RebootTargetPreparerTest.class,
-    RestartSystemServerTargetPreparerTest.class,
-    RootTargetPreparerTest.class,
-    SaveAndRestoreTimeTargetPreparerTest.class,
-    SetAndRestoreSystemPropertyTargetPreparerTest.class,
-    WriteAndRestoreFileTargetPreparerTest.class,
-})
-public class ContribUnitTests {
-    // empty of purpose
-}
diff --git a/tests/src/com/android/tradefed/targetprep/FillStorageTargetPreparerTest.java b/tests/src/com/android/tradefed/targetprep/FillStorageTargetPreparerTest.java
deleted file mode 100644
index 69d7fc3..0000000
--- a/tests/src/com/android/tradefed/targetprep/FillStorageTargetPreparerTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.OptionSetter;
-import com.android.tradefed.device.ITestDevice;
-
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-/**
- * Unit Tests for {@link FillStorageTargetPreparer}.
- */
-@RunWith(JUnit4.class)
-public class FillStorageTargetPreparerTest {
-    private FillStorageTargetPreparer mFillStorageTargetPreparer;
-    private ITestDevice mMockDevice;
-    private IBuildInfo mMockBuildInfo;
-
-    @Before
-    public void setUp() {
-        mFillStorageTargetPreparer = new FillStorageTargetPreparer();
-        mMockDevice = EasyMock.createMock(ITestDevice.class);
-        mMockBuildInfo = EasyMock.createMock(IBuildInfo.class);
-    }
-
-    @Test
-    public void testSetUpWriteFile() throws Exception {
-        OptionSetter optionSetter = new OptionSetter(mFillStorageTargetPreparer);
-        optionSetter.setOptionValue("free-bytes", "50");
-        EasyMock.expect(mMockDevice.executeShellCommand(EasyMock.anyObject())).andReturn(
-                "a\n0 0 0 75 0\n").once();
-        EasyMock.expect(mMockDevice.executeShellCommand(EasyMock.anyObject())).andReturn(
-                null).once();
-        EasyMock.replay(mMockDevice, mMockBuildInfo);
-
-        mFillStorageTargetPreparer.setUp(mMockDevice, mMockBuildInfo);
-        EasyMock.verify(mMockBuildInfo, mMockDevice);
-    }
-
-    @Test
-    public void testSetUpSkip() throws Exception {
-        OptionSetter optionSetter = new OptionSetter(mFillStorageTargetPreparer);
-        optionSetter.setOptionValue("free-bytes", "50000");
-        EasyMock.expect(mMockDevice.executeShellCommand(EasyMock.anyObject())).andReturn(
-                "a\n0 0 0 25 0\n").once();
-        EasyMock.replay(mMockDevice, mMockBuildInfo);
-
-        mFillStorageTargetPreparer.setUp(mMockDevice, mMockBuildInfo);
-        EasyMock.verify(mMockBuildInfo, mMockDevice);
-    }
-
-    @Test
-    public void testTearDown() throws Exception {
-        EasyMock.expect(mMockDevice.executeShellCommand(EasyMock.anyObject())).andReturn(
-                null).once();
-        EasyMock.replay(mMockDevice, mMockBuildInfo);
-
-        mFillStorageTargetPreparer.tearDown(mMockDevice, mMockBuildInfo, null);
-        EasyMock.verify(mMockBuildInfo, mMockDevice);
-    }
-}
diff --git a/tests/src/com/android/tradefed/targetprep/RestartSystemServerTargetPreparerTest.java b/tests/src/com/android/tradefed/targetprep/RestartSystemServerTargetPreparerTest.java
index e3383d5..c76f109 100644
--- a/tests/src/com/android/tradefed/targetprep/RestartSystemServerTargetPreparerTest.java
+++ b/tests/src/com/android/tradefed/targetprep/RestartSystemServerTargetPreparerTest.java
@@ -114,33 +114,4 @@
         EasyMock.verify(mMockDevice, mMockBuildInfo);
     }
 
-    @Test
-    public void testTearDown_restart() throws Exception {
-        OptionSetter optionSetter = new OptionSetter(mRestartSystemServerTargetPreparer);
-        optionSetter.setOptionValue("restart-before", "false");
-        optionSetter.setOptionValue("restart-after", "true");
-
-        EasyMock.expect(mMockDevice.executeShellCommand("setprop sys.boot_completed 0")).andReturn(
-                null).once();
-        EasyMock.expect(mMockDevice.executeShellCommand("pidof system_server")).andReturn(
-                "123").once();
-        EasyMock.expect(mMockDevice.executeShellCommand("kill 123")).andReturn(null).once();
-        EasyMock.expect(mMockDevice.executeShellCommand("getprop sys.boot_completed")).andReturn(
-                "1").once();
-        EasyMock.replay(mMockDevice, mMockBuildInfo);
-
-        mRestartSystemServerTargetPreparer.tearDown(mMockDevice, mMockBuildInfo, null);
-        EasyMock.verify(mMockDevice, mMockBuildInfo);
-    }
-
-    @Test
-    public void testNone() throws Exception {
-        OptionSetter optionSetter = new OptionSetter(mRestartSystemServerTargetPreparer);
-        optionSetter.setOptionValue("restart-before", "false");
-        optionSetter.setOptionValue("restart-after", "false");
-        EasyMock.replay(mMockDevice, mMockBuildInfo);
-
-        mRestartSystemServerTargetPreparer.setUp(mMockDevice, mMockBuildInfo);
-        EasyMock.verify(mMockDevice, mMockBuildInfo);
-    }
 }
diff --git a/tests/src/com/android/tradefed/targetprep/RootTargetPreparerTest.java b/tests/src/com/android/tradefed/targetprep/RootTargetPreparerTest.java
deleted file mode 100644
index b483545..0000000
--- a/tests/src/com/android/tradefed/targetprep/RootTargetPreparerTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.device.ITestDevice;
-
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-/**
- * Unit Tests for {@link RootTargetPreparer}.
- */
-@RunWith(JUnit4.class)
-public class RootTargetPreparerTest {
-
-    private RootTargetPreparer mRootTargetPreparer;
-    private ITestDevice mMockDevice;
-    private IBuildInfo mMockBuildInfo;
-
-    @Before
-    public void setUp() {
-        mRootTargetPreparer = new RootTargetPreparer();
-        mMockDevice = EasyMock.createMock(ITestDevice.class);
-        mMockBuildInfo = EasyMock.createMock(IBuildInfo.class);
-    }
-
-    @Test
-    public void testSetUpSuccess() throws Exception {
-        EasyMock.expect(mMockDevice.enableAdbRoot()).andReturn(true).once();
-        EasyMock.replay(mMockDevice, mMockBuildInfo);
-
-        mRootTargetPreparer.setUp(mMockDevice, mMockBuildInfo);
-        EasyMock.verify(mMockDevice, mMockBuildInfo);
-    }
-
-    @Test(expected = TargetSetupError.class)
-    public void testSetUpFail() throws Exception {
-        EasyMock.expect(mMockDevice.enableAdbRoot()).andReturn(false).once();
-        EasyMock.expect(mMockDevice.getDeviceDescriptor()).andReturn(null).once();
-        EasyMock.replay(mMockDevice, mMockBuildInfo);
-
-        mRootTargetPreparer.setUp(mMockDevice, mMockBuildInfo);
-        EasyMock.verify(mMockDevice, mMockBuildInfo);
-    }
-
-}
diff --git a/tests/src/com/android/tradefed/targetprep/SaveAndRestoreTimeTargetPreparerTest.java b/tests/src/com/android/tradefed/targetprep/SaveAndRestoreTimeTargetPreparerTest.java
deleted file mode 100644
index b5b1bfd..0000000
--- a/tests/src/com/android/tradefed/targetprep/SaveAndRestoreTimeTargetPreparerTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.OptionSetter;
-import com.android.tradefed.device.ITestDevice;
-
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * Unit Tests for {@link FillStorageTargetPreparer}.
- */
-@RunWith(JUnit4.class)
-public class SaveAndRestoreTimeTargetPreparerTest {
-    private SaveAndRestoreTimeTargetPreparer mSaveAndRestoreTimeTargetPreparer;
-    private SaveAndRestoreTimeTargetPreparer.ITimeGetter mMockTimeGetter;
-    private ITestDevice mMockDevice;
-    private IBuildInfo mMockBuildInfo;
-
-    @Before
-    public void setUp() {
-        mMockDevice = EasyMock.createMock(ITestDevice.class);
-        mMockBuildInfo = EasyMock.createMock(IBuildInfo.class);
-        mMockTimeGetter = EasyMock.createMock(SaveAndRestoreTimeTargetPreparer.ITimeGetter.class);
-        mSaveAndRestoreTimeTargetPreparer = new SaveAndRestoreTimeTargetPreparer(mMockTimeGetter);
-    }
-
-    @Test
-    public void testSaveTime() throws Exception {
-        EasyMock.expect(mMockTimeGetter.getTime()).andReturn(TimeUnit.MILLISECONDS.toNanos(2)).once();
-        EasyMock.expect(mMockDevice.executeShellCommand(EasyMock.anyObject())).andReturn(
-                "123\n").once();
-        EasyMock.expect(mMockTimeGetter.getTime()).andReturn(TimeUnit.MILLISECONDS.toNanos(7)).once();
-        EasyMock.expect(mMockDevice.executeShellCommand("date @128")).andReturn(
-                null).once();
-        EasyMock.replay(mMockDevice, mMockBuildInfo, mMockTimeGetter);
-
-        mSaveAndRestoreTimeTargetPreparer.setUp(mMockDevice, mMockBuildInfo);
-        mSaveAndRestoreTimeTargetPreparer.tearDown(mMockDevice, mMockBuildInfo, null);
-        EasyMock.verify(mMockBuildInfo, mMockDevice);
-    }
-
-    @Test
-    public void testSaveTime_setTimeAtBeginning() throws Exception {
-        OptionSetter optionSetter = new OptionSetter(mSaveAndRestoreTimeTargetPreparer);
-        optionSetter.setOptionValue("set-time", "true");
-        optionSetter.setOptionValue("time", "555");
-        EasyMock.expect(mMockTimeGetter.getTime()).andReturn(TimeUnit.MILLISECONDS.toNanos(2)).once();
-        EasyMock.expect(mMockDevice.executeShellCommand(EasyMock.anyObject())).andReturn(
-                "123\n").once();
-        EasyMock.expect(mMockDevice.executeShellCommand("date @555")).andReturn(null).once();
-        EasyMock.expect(mMockTimeGetter.getTime()).andReturn(TimeUnit.MILLISECONDS.toNanos(7)).once();
-        EasyMock.expect(mMockDevice.executeShellCommand("date @128")).andReturn(null).once();
-        EasyMock.replay(mMockDevice, mMockBuildInfo, mMockTimeGetter);
-
-        mSaveAndRestoreTimeTargetPreparer.setUp(mMockDevice, mMockBuildInfo);
-        mSaveAndRestoreTimeTargetPreparer.tearDown(mMockDevice, mMockBuildInfo, null);
-        EasyMock.verify(mMockBuildInfo, mMockDevice);
-    }
-}
diff --git a/tests/src/com/android/tradefed/targetprep/SetAndRestoreSystemPropertyTargetPreparerTest.java b/tests/src/com/android/tradefed/targetprep/SetAndRestoreSystemPropertyTargetPreparerTest.java
deleted file mode 100644
index d574edd..0000000
--- a/tests/src/com/android/tradefed/targetprep/SetAndRestoreSystemPropertyTargetPreparerTest.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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.OptionSetter;
-import com.android.tradefed.device.ITestDevice;
-
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-/**
- * Unit Tests for {@link FillStorageTargetPreparer}.
- */
-@RunWith(JUnit4.class)
-public class SetAndRestoreSystemPropertyTargetPreparerTest {
-    private SetAndRestoreSystemPropertyTargetPreparer mSetAndRestoreSystemPropertyTargetPreparer;
-    private ITestDevice mMockDevice;
-    private IBuildInfo mMockBuildInfo;
-
-    @Before
-    public void setUp() {
-        mSetAndRestoreSystemPropertyTargetPreparer = new SetAndRestoreSystemPropertyTargetPreparer();
-        mMockDevice = EasyMock.createMock(ITestDevice.class);
-        mMockBuildInfo = EasyMock.createMock(IBuildInfo.class);
-    }
-
-    @Test(expected = TargetSetupError.class)
-    public void testOneProp_fail() throws Exception {
-        OptionSetter optionSetter = new OptionSetter(mSetAndRestoreSystemPropertyTargetPreparer);
-        optionSetter.setOptionValue("set-property", "a", "new");
-        EasyMock.expect(mMockDevice.executeShellCommand("getprop \"a\"")).andReturn("old").once();
-        EasyMock.expect(mMockDevice.executeShellCommand("setprop \"a\" \"new\"")).andReturn(null).once();
-        EasyMock.expect(mMockDevice.executeShellCommand("getprop \"a\"")).andReturn("old").once();
-        EasyMock.expect(mMockDevice.getDeviceDescriptor()).andReturn(null).once();
-        EasyMock.replay(mMockDevice, mMockBuildInfo);
-
-        mSetAndRestoreSystemPropertyTargetPreparer.setUp(mMockDevice, mMockBuildInfo);
-        EasyMock.verify(mMockBuildInfo, mMockDevice);
-    }
-
-    @Test
-    public void testZeroProps() throws Exception {
-        EasyMock.replay(mMockDevice, mMockBuildInfo);
-
-        mSetAndRestoreSystemPropertyTargetPreparer.setUp(mMockDevice, mMockBuildInfo);
-        mSetAndRestoreSystemPropertyTargetPreparer.tearDown(mMockDevice, mMockBuildInfo, null);
-        EasyMock.verify(mMockBuildInfo, mMockDevice);
-    }
-
-    @Test
-    public void testOneProp() throws Exception {
-        OptionSetter optionSetter = new OptionSetter(mSetAndRestoreSystemPropertyTargetPreparer);
-        optionSetter.setOptionValue("set-property", "a", "new");
-        EasyMock.expect(mMockDevice.executeShellCommand("getprop \"a\"")).andReturn("old").once();
-        EasyMock.expect(mMockDevice.executeShellCommand("setprop \"a\" \"new\"")).andReturn(null).once();
-        EasyMock.expect(mMockDevice.executeShellCommand("getprop \"a\"")).andReturn("new").once();
-        EasyMock.expect(mMockDevice.executeShellCommand("setprop \"a\" \"old\"")).andReturn(null).once();
-        EasyMock.replay(mMockDevice, mMockBuildInfo);
-
-        mSetAndRestoreSystemPropertyTargetPreparer.setUp(mMockDevice, mMockBuildInfo);
-        mSetAndRestoreSystemPropertyTargetPreparer.tearDown(mMockDevice, mMockBuildInfo, null);
-        EasyMock.verify(mMockBuildInfo, mMockDevice);
-    }
-
-    @Test
-    public void testTwoProps() throws Exception {
-        OptionSetter optionSetter = new OptionSetter(mSetAndRestoreSystemPropertyTargetPreparer);
-        optionSetter.setOptionValue("set-property", "a", "new");
-        optionSetter.setOptionValue("set-property", "b", "newb");
-        EasyMock.expect(mMockDevice.executeShellCommand("getprop \"a\"")).andReturn("old").once();
-        EasyMock.expect(mMockDevice.executeShellCommand("setprop \"a\" \"new\"")).andReturn(null).once();
-        EasyMock.expect(mMockDevice.executeShellCommand("getprop \"a\"")).andReturn("new").once();
-        EasyMock.expect(mMockDevice.executeShellCommand("getprop \"b\"")).andReturn("oldb").once();
-        EasyMock.expect(mMockDevice.executeShellCommand("setprop \"b\" \"newb\"")).andReturn(null).once();
-        EasyMock.expect(mMockDevice.executeShellCommand("getprop \"b\"")).andReturn("newb").once();
-        EasyMock.expect(mMockDevice.executeShellCommand("setprop \"a\" \"old\"")).andReturn(null).once();
-        EasyMock.expect(mMockDevice.executeShellCommand("setprop \"b\" \"oldb\"")).andReturn(null).once();
-        EasyMock.replay(mMockDevice, mMockBuildInfo);
-
-        mSetAndRestoreSystemPropertyTargetPreparer.setUp(mMockDevice, mMockBuildInfo);
-        mSetAndRestoreSystemPropertyTargetPreparer.tearDown(mMockDevice, mMockBuildInfo, null);
-        EasyMock.verify(mMockBuildInfo, mMockDevice);
-    }
-
-}
diff --git a/tests/src/com/android/tradefed/targetprep/WriteAndRestoreFileTargetPreparerTest.java b/tests/src/com/android/tradefed/targetprep/WriteAndRestoreFileTargetPreparerTest.java
deleted file mode 100644
index c0fb972..0000000
--- a/tests/src/com/android/tradefed/targetprep/WriteAndRestoreFileTargetPreparerTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.OptionSetter;
-import com.android.tradefed.device.ITestDevice;
-
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-import java.io.File;
-
-/**
- * Unit Tests for {@link WriteAndRestoreFileTargetPreparer}.
- */
-@RunWith(JUnit4.class)
-public class WriteAndRestoreFileTargetPreparerTest {
-    private WriteAndRestoreFileTargetPreparer mWriteAndRestoreFileTargetPreparer;
-    private ITestDevice mMockDevice;
-    private IBuildInfo mMockBuildInfo;
-
-    @Before
-    public void setUp() {
-        mWriteAndRestoreFileTargetPreparer = new WriteAndRestoreFileTargetPreparer();
-        mMockDevice = EasyMock.createMock(ITestDevice.class);
-        mMockBuildInfo = EasyMock.createMock(IBuildInfo.class);
-    }
-
-    @Test(expected = TargetSetupError.class)
-    public void testFail() throws Exception {
-        OptionSetter optionSetter = new OptionSetter(mWriteAndRestoreFileTargetPreparer);
-        optionSetter.setOptionValue("file-name", "file");
-        optionSetter.setOptionValue("contents", "hi");
-        EasyMock.expect(mMockDevice.doesFileExist("file")).andReturn(false).once();
-        EasyMock.expect(mMockDevice.pushString("hi", "file")).andReturn(false).once();
-        EasyMock.expect(mMockDevice.getDeviceDescriptor()).andReturn(null).once();
-        EasyMock.replay(mMockDevice, mMockBuildInfo);
-
-        mWriteAndRestoreFileTargetPreparer.setUp(mMockDevice, mMockBuildInfo);
-        mWriteAndRestoreFileTargetPreparer.tearDown(mMockDevice, mMockBuildInfo, null);
-        EasyMock.verify(mMockBuildInfo, mMockDevice);
-    }
-
-    @Test
-    public void testDoesntExist() throws Exception {
-        OptionSetter optionSetter = new OptionSetter(mWriteAndRestoreFileTargetPreparer);
-        optionSetter.setOptionValue("file-name", "file");
-        optionSetter.setOptionValue("contents", "hi");
-        EasyMock.expect(mMockDevice.doesFileExist("file")).andReturn(false).once();
-        EasyMock.expect(mMockDevice.pushString("hi", "file")).andReturn(true).once();
-        EasyMock.expect(mMockDevice.executeShellCommand("rm -f file")).andReturn(null).once();
-        EasyMock.replay(mMockDevice, mMockBuildInfo);
-
-        mWriteAndRestoreFileTargetPreparer.setUp(mMockDevice, mMockBuildInfo);
-        mWriteAndRestoreFileTargetPreparer.tearDown(mMockDevice, mMockBuildInfo, null);
-        EasyMock.verify(mMockBuildInfo, mMockDevice);
-    }
-
-    @Test
-    public void testAlreadyExists() throws Exception {
-        OptionSetter optionSetter = new OptionSetter(mWriteAndRestoreFileTargetPreparer);
-        File file = new File("a");
-        optionSetter.setOptionValue("file-name", "file");
-        optionSetter.setOptionValue("contents", "hi");
-        EasyMock.expect(mMockDevice.doesFileExist("file")).andReturn(true).once();
-        EasyMock.expect(mMockDevice.pullFile("file")).andReturn(file).once();
-        EasyMock.expect(mMockDevice.pushString("hi", "file")).andReturn(true).once();
-        EasyMock.expect(mMockDevice.pushFile(file, "file")).andReturn(true).once();
-        EasyMock.replay(mMockDevice, mMockBuildInfo);
-
-        mWriteAndRestoreFileTargetPreparer.setUp(mMockDevice, mMockBuildInfo);
-        mWriteAndRestoreFileTargetPreparer.tearDown(mMockDevice, mMockBuildInfo, null);
-        EasyMock.verify(mMockBuildInfo, mMockDevice);
-    }
-
-}