Merge "Display variance and max deviation on iperf result"
diff --git a/acts/framework/acts/test_utils/power/tel_simulations/LteSimulation.py b/acts/framework/acts/test_utils/power/tel_simulations/LteSimulation.py
index 1fd3dc0..7e86547 100644
--- a/acts/framework/acts/test_utils/power/tel_simulations/LteSimulation.py
+++ b/acts/framework/acts/test_utils/power/tel_simulations/LteSimulation.py
@@ -329,24 +329,25 @@
             self.sim_ul_power = power
 
         # Setup downlink power
-        try:
-            values = self.consume_parameter(parameters, self.PARAM_DL_PW, 1)
+        values = self.consume_parameter(parameters, self.PARAM_DL_PW, 1)
 
+        if values:
             if values[1] not in self.downlink_rsrp_dictionary:
-                raise ValueError("Invalid signal level value.")
+                self.log.error("Invalid signal level value {}.".format(
+                    values[1]))
+                return False
             else:
                 power = self.downlink_rsrp_dictionary[values[1]]
-        except:
-            self.log.error(
-                "The test name needs to include parameter {} followed by one "
-                "the following values: {}.".format(self.PARAM_DL_PW, [
-                    "\n" + val for val in self.downlink_rsrp_dictionary.keys()
-                ]))
-            return False
         else:
-            # Power is not set on the callbox until after the simulation is
-            # started. Will save this value in a variable and use it later
-            self.sim_dl_power = power
+            # Use default value
+            power = self.downlink_rsrp_dictionary['excellent']
+            self.log.error(
+                "No DL signal level value was indicated in the test parameters."
+                " Using default value of {} RSRP.".format(power))
+
+        # Power is not set on the callbox until after the simulation is
+        # started. Will save this value in a variable and use it later
+        self.sim_dl_power = power
 
         # No errors were found
         return True
diff --git a/acts/framework/acts/test_utils/power/tel_simulations/UmtsSimulation.py b/acts/framework/acts/test_utils/power/tel_simulations/UmtsSimulation.py
index 985f15e..7ecdb0a 100644
--- a/acts/framework/acts/test_utils/power/tel_simulations/UmtsSimulation.py
+++ b/acts/framework/acts/test_utils/power/tel_simulations/UmtsSimulation.py
@@ -177,28 +177,26 @@
 
             # Setup downlink power
 
-            try:
-                values = self.consume_parameter(parameters, self.PARAM_DL_PW,
-                                                1)
+            values = self.consume_parameter(parameters, self.PARAM_DL_PW, 1)
 
+            if values:
                 if values[1] not in self.downlink_rscp_dictionary:
-                    raise ValueError("Invalid signal level value.")
+                    self.log.error("Invalid signal level value {}.".format(
+                        values[1]))
+                    return False
                 else:
                     power = self.downlink_rscp_dictionary[values[1]]
-
-            except:
-                self.log.error(
-                    "The test name needs to include parameter {} followed by "
-                    "one of the following values: {}.".format(
-                        self.PARAM_DL_PW, [
-                            "\n" + val
-                            for val in self.downlink_rscp_dictionary.keys()
-                        ]))
-                return False
             else:
-                # Power is not set on the callbox until after the simulation is
-                # started. Will save this value in a variable and use it later
-                self.sim_dl_power = power
+                # Use default value
+                power = self.downlink_rscp_dictionary['excellent']
+                self.log.error(
+                    "No DL signal level value was indicated in the test "
+                    "parameters. Using default value of {} RSRP.".format(
+                        power))
+
+            # Power is not set on the callbox until after the simulation is
+            # started. Will save this value in a variable and use it later
+            self.sim_dl_power = power
 
         # No errors were found
         return True
diff --git a/acts/tests/google/power/tel/lab/PowerTelTrafficTest.py b/acts/tests/google/power/tel/lab/PowerTelTrafficTest.py
index 21a9e8c..fa42f2d 100644
--- a/acts/tests/google/power/tel/lab/PowerTelTrafficTest.py
+++ b/acts/tests/google/power/tel/lab/PowerTelTrafficTest.py
@@ -129,11 +129,32 @@
 
         # Collect throughput measurement
         throughput = []
+
         for iph in client_iperf_helper:
-            print('Setting: {}\n'.format(iph.iperf_args))
-            throughput.append(
-                iph.process_iperf_results(self.dut, self.log,
-                                          self.iperf_servers, self.test_name))
+            self.log.info("Getting {} throughput".format(
+                iph.traffic_direction))
+            iperf_result = iph.process_iperf_results(
+                self.dut, self.log, self.iperf_servers, self.test_name)
+            try:
+                if iph.traffic_direction == "UL":
+                    expected_t = self.simulation.maximum_uplink_throughput()
+                elif iph.traffic_direction == "DL":
+                    expected_t = self.simulation.maximum_downlink_throughput()
+                else:
+                    raise RuntimeError("Unexpected traffic direction value.")
+
+                if not 0.90 < iperf_result / expected_t < 1.10:
+                    self.log.warning("Throughput differed more than 10% from "
+                                     "the expected value!. {}/{} = {}".format(
+                                         iperf_result, expected_t,
+                                         iperf_result / expected_t))
+            except NotImplementedError:
+                # Some simulation classes might not have implemented the max
+                # throughput calculation yet
+                self.log.debug("Expected throughput is not available for the "
+                               "current simulation class.")
+
+            throughput.append(iperf_result)
 
         # Check if power measurement is below the required value
         # self.pass_fail_check()