1#!/usr/bin/env python3 2# 3# Copyright (C) 2016 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); you may not 6# use this file except in compliance with the License. You may obtain a copy of 7# 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, WITHOUT 13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14# License for the specific language governing permissions and limitations under 15# the License. 16 17from queue import Empty 18from acts.base_test import BaseTestClass 19from acts.test_utils.wifi.wifi_test_utils import wifi_toggle_state 20from acts.test_utils.wifi.wifi_test_utils import WifiEnums 21 22 23class Sl4aSanityTest(BaseTestClass): 24 """Tests for sl4a basic sanity. 25 26 Run these tests individually with option -r 100. 27 """ 28 29 def __init__(self, controllers): 30 BaseTestClass.__init__(self, controllers) 31 self.tests = ("test_bring_up_and_shutdown", 32 "test_message_then_shutdown_stress") 33 34 def test_bring_up_and_shutdown(self): 35 """Constantly start and terminate sl4a sessions. 36 37 Verify in log that the "manager map key" is always empty before a 38 session starts. 39 Verify in log by looking at timestamps that after the test finishes, no 40 more message regarding sl4a happens. 41 """ 42 ad = self.android_devices[0] 43 for i in range(100): 44 self.log.info("Iteration %d, terminating." % i) 45 ad.terminate_all_sessions() 46 self.log.info("Iteration %d, starting." % i) 47 droid, ed = ad.get_droid() 48 return True 49 50 def test_message_then_shutdown_stress(self): 51 ad = self.android_devices[0] 52 for i in range(10): 53 assert wifi_toggle_state(ad.droid, ad.ed, False) 54 assert wifi_toggle_state(ad.droid, ad.ed, True) 55 return True 56