Merge "Added 5G SA components to ACTS"
diff --git a/acts/framework/acts/controllers/fuchsia_device.py b/acts/framework/acts/controllers/fuchsia_device.py
index 96bd26c..402ae5e 100644
--- a/acts/framework/acts/controllers/fuchsia_device.py
+++ b/acts/framework/acts/controllers/fuchsia_device.py
@@ -229,7 +229,7 @@
             "take_bug_report_on_fail", False)
         self.device_pdu_config = fd_conf_data.get("PduDevice", None)
         self.config_country_code = fd_conf_data.get(
-            'country_code', FUCHSIA_DEFAULT_COUNTRY_CODE_US)
+            'country_code', FUCHSIA_DEFAULT_COUNTRY_CODE_US).upper()
         self._persistent_ssh_conn = None
 
         # Whether to use 'policy' or 'drivers' for WLAN connect/disconnect calls
@@ -1042,6 +1042,7 @@
         if self.ssh_config:
             # Country code can be None, from ACTS config.
             if desired_country_code:
+                desired_country_code = desired_country_code.upper()
                 response = self.regulatory_region_lib.setRegion(
                     desired_country_code)
                 if response.get('error'):
@@ -1051,13 +1052,13 @@
                 end_time = time.time() + FUCHSIA_COUNTRY_CODE_TIMEOUT
                 while time.time() < end_time:
                     ascii_cc = self.wlan_lib.wlanGetCountry(0).get('result')
-                    str_cc = ''.join(chr(c) for c in ascii_cc)
-                    if str_cc == desired_country_code:
+                    # Convert ascii_cc to string, then compare
+                    if ascii_cc and (''.join(chr(c) for c in ascii_cc).upper()
+                                     == desired_country_code):
                         self.log.debug('Country code successfully set to %s.' %
                                        desired_country_code)
                         return
-                    self.log.debug(
-                        'Country code is still set to %s. Retrying.' % str_cc)
+                    self.log.debug('Country code not yet updated. Retrying.')
                     time.sleep(1)
                 raise FuchsiaDeviceError('Country code never updated to %s' %
                                          desired_country_code)
diff --git a/acts_tests/acts_contrib/test_utils/tel/tel_test_utils.py b/acts_tests/acts_contrib/test_utils/tel/tel_test_utils.py
index a3bfe7f..91de5b1 100644
--- a/acts_tests/acts_contrib/test_utils/tel/tel_test_utils.py
+++ b/acts_tests/acts_contrib/test_utils/tel/tel_test_utils.py
@@ -9468,7 +9468,7 @@
         try:
             radio_simulate_data = json.load(f)
         except Exception as e:
-            self.log.error("Exception error to load %s: %s", f, e)
+            ad.log.error("Exception error to load %s: %s", f, e)
             return False
 
     for item in radio_simulate_data:
@@ -10776,7 +10776,7 @@
             try:
                 get_value = datetime_list[5]
             except Exception as e:
-                self.log.error("Fail to get year from datetime: %s. " \
+                ad.log.error("Fail to get year from datetime: %s. " \
                                 "Exception error: %s", datetime_list
                                 , str(e))
                 raise signals.TestSkip("Fail to get year from datetime" \
diff --git a/acts_tests/tests/OWNERS b/acts_tests/tests/OWNERS
index 6f15a8d..7e2f8ea 100644
--- a/acts_tests/tests/OWNERS
+++ b/acts_tests/tests/OWNERS
@@ -11,6 +11,7 @@
 mrtyler@google.com
 codycaldwell@google.com
 chaoyangf@google.com
+wju@google.com
 
 # Pixel GTW
 jasonkmlu@google.com
diff --git a/acts_tests/tests/google/fuchsia/wlan/functional/WlanRebootTest.py b/acts_tests/tests/google/fuchsia/wlan/functional/WlanRebootTest.py
index 02b2350..59060bd 100644
--- a/acts_tests/tests/google/fuchsia/wlan/functional/WlanRebootTest.py
+++ b/acts_tests/tests/google/fuchsia/wlan/functional/WlanRebootTest.py
@@ -50,6 +50,7 @@
 IPV4_ONLY = {IPV4: True, IPV6: False}
 IPV6_ONLY = {IPV4: False, IPV6: True}
 INTERRUPTS = [True, False]
+DEFAULT_IPERF_TIMEOUT = 30
 
 DUT_NETWORK_CONNECTION_TIMEOUT = 60
 DUT_IP_ADDRESS_TIMEOUT = 15
@@ -365,7 +366,9 @@
             'Attempting to pass traffic from DUT to IPerf server (%s).' %
             iperf_server_ip_address)
         tx_file = iperf_client_on_dut.start(iperf_server_ip_address,
-                                            '-i 1 -t 3 -J', 'reboot_tx')
+                                            '-i 1 -t 3 -J',
+                                            'reboot_tx',
+                                            timeout=DEFAULT_IPERF_TIMEOUT)
         tx_results = iperf_server.IPerfResult(tx_file)
         if not tx_results.avg_receive_rate or tx_results.avg_receive_rate == 0:
             raise ConnectionError(
@@ -380,7 +383,9 @@
             'Attempting to pass traffic from IPerf server (%s) to DUT.' %
             iperf_server_ip_address)
         rx_file = iperf_client_on_dut.start(iperf_server_ip_address,
-                                            '-i 1 -t 3 -R -J', 'reboot_rx')
+                                            '-i 1 -t 3 -R -J',
+                                            'reboot_rx',
+                                            timeout=DEFAULT_IPERF_TIMEOUT)
         rx_results = iperf_server.IPerfResult(rx_file)
         if not rx_results.avg_receive_rate or rx_results.avg_receive_rate == 0:
             raise ConnectionError(
diff --git a/acts_tests/tests/google/fuchsia/wlan/performance/ChannelSweepTest.py b/acts_tests/tests/google/fuchsia/wlan/performance/ChannelSweepTest.py
index 91606d4..a674911 100644
--- a/acts_tests/tests/google/fuchsia/wlan/performance/ChannelSweepTest.py
+++ b/acts_tests/tests/google/fuchsia/wlan/performance/ChannelSweepTest.py
@@ -57,6 +57,7 @@
 
 DEFAULT_MIN_THROUGHPUT = 0
 DEFAULT_MAX_STD_DEV = 1
+DEFAULT_IPERF_TIMEOUT = 30
 
 DEFAULT_TIME_TO_WAIT_FOR_IP_ADDR = 30
 GRAPH_CIRCLE_SIZE = 10
@@ -334,13 +335,19 @@
                 'Running IPerf traffic from server (%s) to dut (%s).' %
                 (iperf_server_address, iperf_client_address))
             iperf_results_file = self.iperf_client.start(
-                iperf_server_address, '-i 1 -t 10 -R -J', 'channel_sweep_rx')
+                iperf_server_address,
+                '-i 1 -t 10 -R -J',
+                'channel_sweep_rx',
+                timeout=DEFAULT_IPERF_TIMEOUT)
         else:
             self.log.info(
                 'Running IPerf traffic from dut (%s) to server (%s).' %
                 (iperf_client_address, iperf_server_address))
             iperf_results_file = self.iperf_client.start(
-                iperf_server_address, '-i 1 -t 10 -J', 'channel_sweep_tx')
+                iperf_server_address,
+                '-i 1 -t 10 -J',
+                'channel_sweep_tx',
+                timeout=DEFAULT_IPERF_TIMEOUT)
         if iperf_results_file:
             iperf_results = IPerfResult(
                 iperf_results_file, reporting_speed_units=MEGABITS_PER_SECOND)
@@ -657,7 +664,8 @@
             base_message = (
                 'Actual throughput (on channel: %s, channel bandwidth: '
                 '%s, security: %s)' % (channel, channel_bandwidth, security))
-            if (tx_throughput < min_tx_throughput
+            if (not tx_throughput or not rx_throughput
+                    or tx_throughput < min_tx_throughput
                     or rx_throughput < min_rx_throughput):
                 asserts.fail('%s below the minimum threshold.' % base_message)
             asserts.explicit_pass('%s above the minimum threshold.' %