1#!/usr/bin/env python3 2# 3# Copyright 2019 - The Android secure Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17from acts import signals 18 19from acts.base_test import BaseTestClass 20from acts_contrib.test_utils.abstract_devices.wlan_device import create_wlan_device 21from acts_contrib.test_utils.abstract_devices.wlan_device_lib.AbstractDeviceWlanDeviceBaseTest import AbstractDeviceWlanDeviceBaseTest 22 23 24class WlanInterfaceTest(AbstractDeviceWlanDeviceBaseTest): 25 def setup_class(self): 26 super().setup_class() 27 dut = self.user_params.get('dut', None) 28 if dut: 29 if dut == 'fuchsia_devices': 30 self.dut = create_wlan_device(self.fuchsia_devices[0]) 31 elif dut == 'android_devices': 32 self.dut = create_wlan_device(self.android_devices[0]) 33 else: 34 raise ValueError('Invalid DUT specified in config. (%s)' % 35 self.user_params['dut']) 36 else: 37 # Default is an Fuchsia device 38 self.dut = create_wlan_device(self.fuchsia_devices[0]) 39 40 def on_fail(self, test_name, begin_time): 41 super().on_fail(test_name, begin_time) 42 43 def test_destroy_iface(self): 44 """Test that we don't error out when destroying the WLAN interface. 45 46 Steps: 47 1. Find a wlan interface 48 2. Destroy it 49 50 Expected Result: 51 Verify there are no errors in destroying the wlan interface. 52 53 Returns: 54 signals.TestPass if no errors 55 signals.TestFailure if there are any errors during the test. 56 57 TAGS: WLAN 58 Priority: 1 59 """ 60 wlan_interfaces = self.dut.get_wlan_interface_id_list() 61 if len(wlan_interfaces) < 1: 62 raise signals.TestFailure("Not enough wlan interfaces for test") 63 if not self.dut.destroy_wlan_interface(wlan_interfaces[0]): 64 raise signals.TestFailure("Failed to destroy WLAN interface") 65 raise signals.TestPass("Success") 66