aboutsummaryrefslogtreecommitdiff
path: root/src/com/android/tradefed/targetprep
diff options
context:
space:
mode:
authorYuchao Zhou <superzhou@google.com>2016-04-07 21:05:06 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-04-07 21:05:06 +0000
commitf66021a4e8818f19a906e9e72a4c5bfc8d154feb (patch)
treee49a114155bfe6a5d57799232eb2e5a2c3363ed4 /src/com/android/tradefed/targetprep
parent726170bc30f1cc306e5804b909a0057a0452565d (diff)
parent347da2c537c447664ef6400f367d096c73ddfcbc (diff)
downloadtradefederation-f66021a4e8818f19a906e9e72a4c5bfc8d154feb.tar.gz
Merge "Adding a new preparer to initialize attenuator"
Diffstat (limited to 'src/com/android/tradefed/targetprep')
-rw-r--r--src/com/android/tradefed/targetprep/AttenuatorPreparer.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/com/android/tradefed/targetprep/AttenuatorPreparer.java b/src/com/android/tradefed/targetprep/AttenuatorPreparer.java
new file mode 100644
index 000000000..6027d9fc0
--- /dev/null
+++ b/src/com/android/tradefed/targetprep/AttenuatorPreparer.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2016 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;
+import com.android.tradefed.util.AttenuatorUtil;
+import com.android.tradefed.util.RunUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@OptionClass(alias = "attenuator")
+public class AttenuatorPreparer implements ITargetPreparer {
+ @Option(name = "attenuator-value", description = "Initial value for the attenuator")
+ private int initValue = 0;
+
+ @Option(name = "disable", description = "Disable this preparer")
+ private boolean mDisable = true;
+
+ @Option(name = "attenuator-ip", description = "IP address for attenuators")
+ private List<String> mIpAddresses = new ArrayList<String>();
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setUp(ITestDevice device, IBuildInfo buildInfo) throws TargetSetupError,
+ DeviceNotAvailableException {
+ if (mDisable)
+ return;
+ for (String ipAddress : mIpAddresses) {
+ CLog.v("Initialize attenuator %s to %d at setup", mIpAddresses, initValue);
+ AttenuatorUtil att = new AttenuatorUtil(ipAddress);
+ att.setValue(initValue);
+ }
+ }
+}
+