Пример #1
0
    def test_bt_pairing(self):
        '''Use bluetoothctl to pair IoT device with host
        @fn test_bt_pairing
        @param self
        @return
        '''
        # On IoT target, start pair_slave in back-ground 
        (status, host_btmac) = shell_cmd_timeout("hciconfig | grep 'BD Address' | awk '{print $3}'")
        slave_exp = os.path.join(os.path.dirname(__file__), "files/bt_pair_slave_on_iot.exp")
        cmd = "%s %s %s" % (slave_exp, self.target.ip, host_btmac)
        subprocess.Popen(cmd, shell=True)
 
        # On Host, get to know target BT mac and perform pair_master
        master_exp = os.path.join(os.path.dirname(__file__), "files/bt_pair_master.exp")
        (status, target_btmac) = self.target.run("hciconfig | grep 'BD Address' | awk '{print $3}'")
        cmd = "expect %s %s" % (master_exp, target_btmac)
        status, output = shell_cmd_timeout(cmd, timeout=200)
        ##
        # TESTPOINT: #1, test_bt_pairing
        #
        self.assertEqual(status, 2, msg="expect excution fail: %s" % output)

        # On Host, check paired devices to see if IoT is in
        check_exp = os.path.join(os.path.dirname(__file__), "files/bt_list_paired_device.exp")
        status, output = shell_cmd_timeout("%s | grep '^Device %s'" % (check_exp, target_btmac), timeout=200)
        ##
        # TESTPOINT: #2, test_bt_pairing
        #
        self.assertEqual(status, 0, msg="Not found IoT device paired")
Пример #2
0
    def test_bt_pairing(self):
        '''Use bluetoothctl to pair IoT device with host
        @fn test_bt_pairing
        @param self
        @return
        '''
        # On remote, start pair_slave in back-ground
        slave_exp = os.path.join(os.path.dirname(__file__), "files/bt_pair_slave_on_iot.exp")
        cmd = "%s %s %s" % (slave_exp, self.bt2.target.ip, self.bt1.get_bt_mac())
        subprocess.Popen(cmd, shell=True)

        # On target, perform pair_master
        master_exp = os.path.join(os.path.dirname(__file__), "files/bt_pair_master.exp")
        cmd = "expect %s %s %s" % (master_exp, self.bt1.target.ip, self.bt2.get_bt_mac())
        for i in range(3):
            (status, output) = shell_cmd_timeout(cmd, timeout=200)
            if status == 2:
                break
        if type(output) is bytes:
            output = output.decode("utf-8")
        self.assertEqual(status, 2, msg="expect excution fail: %s" % output)

        # On target, check paired devices to see if IoT is in
        check_exp = os.path.join(os.path.dirname(__file__), "files/bt_list_paired_device.exp")
        (status, output) = shell_cmd_timeout("%s %s | grep '^Device %s'" % (check_exp, self.bt1.target.ip, self.bt2.get_bt_mac()), timeout=20)
        self.assertEqual(status, 0, msg="Not found IoT device paired")
Пример #3
0
    def test_power(self):
        """Measure power consumption
        @fn test_power
        @param self
        @return
        """
        self._setup()
        filename = os.path.basename(__file__)
        casename = os.path.splitext(filename)[0]
        
        powermonitor="/dev/ttyUSB0"
        resistance=0
        voltage=12
        measure_time=120

        (status, output) = shell_cmd_timeout("timeout %d rs2 %s %d %d > /tmp/power.log" 
                % (measure_time, powermonitor, resistance, voltage))
        (status, output) = shell_cmd_timeout("cat /tmp/power.log | "
                "awk '{sum+=$4} END {print sum/NR}'")
        ##
        # TESTPOINT: #1, test_power
        #
        self.assertEqual(status, 0, output)
        collect_pnp_log(casename, casename, output)
        print "\n%s:%s\n" % (casename, output)

        (status, output) = shell_cmd_timeout(
            "cat /tmp/power.log")
        logname = casename + "-detail"
        collect_pnp_log(casename, logname, output) 
Пример #4
0
    def test_power(self):
        """Measure power consumption
        @fn test_power
        @param self
        @return
        """
        self._setup()
        filename = os.path.basename(__file__)
        casename = os.path.splitext(filename)[0]

        powermonitor = "/dev/ttyUSB0"
        resistance = 0
        voltage = 12
        measure_time = 120

        (status, output) = shell_cmd_timeout(
            "timeout %d rs2 %s %d %d > /tmp/power.log" %
            (measure_time, powermonitor, resistance, voltage))
        (status,
         output) = shell_cmd_timeout("cat /tmp/power.log | "
                                     "awk '{sum+=$4} END {print sum/NR}'")
        ##
        # TESTPOINT: #1, test_power
        #
        self.assertEqual(status, 0, output)
        collect_pnp_log(casename, casename, output)
        print "\n%s:%s\n" % (casename, output)

        (status, output) = shell_cmd_timeout("cat /tmp/power.log")
        logname = casename + "-detail"
        collect_pnp_log(casename, logname, output)
Пример #5
0
    def test_bt_pairing(self):
        '''Use bluetoothctl to pair IoT device with host
        @fn test_bt_pairing
        @param self
        @return
        '''
        # On remote, start pair_slave in back-ground
        slave_exp = os.path.join(os.path.dirname(__file__), "files/bt_pair_slave_on_iot.exp")
        cmd = "%s %s %s" % (slave_exp, self.bt2.target.ip, self.bt1.get_bt_mac())
        subprocess.Popen(cmd, shell=True)

        # On target, perform pair_master
        master_exp = os.path.join(os.path.dirname(__file__), "files/bt_pair_master.exp")
        cmd = "expect %s %s %s" % (master_exp, self.bt1.target.ip, self.bt2.get_bt_mac())
        for i in range(3):
            (status, output) = shell_cmd_timeout(cmd, timeout=200)
            if status == 2:
                break
        if type(output) is bytes:
            output = output.decode("utf-8")
        self.assertEqual(status, 2, msg="expect excution fail: %s" % output)

        # On target, check paired devices to see if IoT is in
        check_exp = os.path.join(os.path.dirname(__file__), "files/bt_list_paired_device.exp")
        (status, output) = shell_cmd_timeout("%s %s | grep '^Device %s'" % (check_exp, self.bt1.target.ip, self.bt2.get_bt_mac()), timeout=20)
        self.assertEqual(status, 0, msg="Not found IoT device paired")
Пример #6
0
    def get_interface(self):
        """
        @fn get_interface
        @param self
        @return
        """
        # if user takes -s option, it is host's IP, directly use it
        if '192.168.7.1' == self.target.server_ip:
            # Get target ip address prefix of LAN, for example, 192.168.8.100 is 192.168.8
            ipv4 = self.get_ipv4().split('.')
            prefix = "%s.%s.%s" % (ipv4[0], ipv4[1], ipv4[2])
        else:
            prefix = self.target.server_ip
        # Use this prefix to get corresponding interface of the host
        (status, ifconfig) = shell_cmd_timeout('ifconfig')
        for line in ifconfig.splitlines():
            if type(line) is bytes:
                linetemp = line.decode('ascii')
            if "inet addr:%s" % prefix in linetemp:
                index = ifconfig.splitlines().index(line)
                interface = ifconfig.splitlines()[index - 1]
                if type(interface) is bytes:
                    interface = interface.decode('ascii')
                return interface.split()[0]

        # if above return is not OK, there might be error, return Blank
        self.assertEqual(1, 0, msg="Host interface with %s is not found" % prefix)
Пример #7
0
    def test_wifi_connect(self):
        '''connmanctl to connect WPA2-PSK wifi AP
        @fn test_wifi_connect
        @param self
        @return
        '''
        target_ip = self.target.ip 
        ssid = ssid_config.get("Connect","ssid")
        pwd = ssid_config.get("Connect","passwd")

        # Do connection
        m_type = ssid_config.get("Connect","type")
        if (m_type == "broadcast"):
            exp = os.path.join(os.path.dirname(__file__), "files/wifi_connect.exp")
            cmd = "expect %s %s %s %s %s" % (exp, target_ip, "connmanctl", self.service, pwd)
        else:
            exp = os.path.join(os.path.dirname(__file__), "files/wifi_hidden_connect.exp")
            cmd = "expect %s %s %s %s %s %s" % (exp, target_ip, "connmanctl", self.service, ssid, pwd)
        status, output = shell_cmd_timeout(cmd, timeout=60)
        ##
        # TESTPOINT: #1, test_wifi_connect
        #
        self.assertEqual(status, 2, msg="Error messages: %s" % output)
        # Check ip address by ifconfig command
        time.sleep(3)
        (status, wifi_interface) = self.target.run("ifconfig | grep '^wlp' | awk '{print $1}'")
        (status, output) = self.target.run("ifconfig %s | grep 'inet addr:'" % wifi_interface)

        # Collect info
        self.target_collect_info("ifconfig")
        ##
        # TESTPOINT: #2, test_wifi_connect
        #
        self.assertEqual(status, 0, msg="IP check failed" + self.log)
Пример #8
0
    def test_group(self):
        '''
            groupclient has 4 main operations. Only option1 is doable.
            In option (user inputs 1), it will set ActionSet value of rep. This case
            is to check if the set operation is done. 
        @fn test_group
        @param self
        @return
        '''
        # start light server and group server
        lightserver_cmd = "/opt/iotivity/examples/resource/cpp/lightserver > /tmp/svr_output &"
        (status, output) = self.target.run(lightserver_cmd, timeout=20)
        time.sleep(2)
        ssh_cmd = "ssh root@%s -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR" % self.target.ip
        groupserver_cmd = "/opt/iotivity/examples/resource/cpp/groupserver > /dev/null 2>&1"
        subprocess.Popen("%s %s" % (ssh_cmd, groupserver_cmd), shell=True)
        time.sleep(3)

        # start client to get info, here needs user input. So use expect
        exp_cmd = os.path.join(os.path.dirname(__file__),
                               "files/group_client.exp")
        status, output = shell_cmd_timeout("expect %s %s" %
                                           (exp_cmd, self.target.ip),
                                           timeout=200)
        # kill server and client
        self.target.run("killall lightserver groupserver groupclient")
        time.sleep(3)
        ##
        # TESTPOINT: #1, test_group
        #
        if type(output) is bytes:
            output = output.decode("ascii")
        self.assertEqual(status, 2, msg="expect excution fail\n %s" % output)
Пример #9
0
 def test_bt_le_scan(self):
     '''Another device (host) does LE advertising, target scans it
     @fn test_bt_le_scan
     @param self
     @return
     '''
     for i in range(3):
         # close legacy iscan mode
         self.bt2.target.run('hciconfig hci0 noscan')
         # begin low-energy scan
         self.bt2.target.run('hciconfig hci0 leadv')
         time.sleep(1)
         # Device starts bluetoothctl to scan others
         exp = os.path.join(os.path.dirname(__file__), "files/bt_scan.exp")
         cmd = "expect %s %s %s" % (exp, self.bt1.target.ip,
                                    self.bt2.get_bt_mac())
         status, output = shell_cmd_timeout(cmd, timeout=100)
         if status == 2:
             break
         else:
             self.bt2.target.run('hciconfig hci0 reset')
             time.sleep(3)
     if type(output) is bytes:
         output = output.decode("utf-8")
     self.assertEqual(status, 2, msg="LE Scan other fails: %s" % output)
Пример #10
0
 def connect_wifi(self, ap_type, ssid, pwd):
     '''connmanctl to connect wifi AP
     @fn connect_wifi
     @param self
     @return
     '''
     target_ip = self.target.ip
     for i in range(3):
         service = self.scan_wifi(ap_type, ssid)
         # Do connection
         if (ap_type == "broadcast"):
             exp = os.path.join(os.path.dirname(__file__), "files/wifi_connect.exp")
             cmd = "expect %s %s %s %s %s" % (exp, target_ip, "connmanctl", service, pwd)
         elif "hidden" in ap_type:
             exp = os.path.join(os.path.dirname(__file__), "files/wifi_hidden_connect.exp")
             cmd = "expect %s %s %s %s %s %s" % (exp, target_ip, "connmanctl", service, ssid, pwd)
         else:
             assert False, "ap_type must be broadcast or hidden, check config"
         # execute connection expect script
         status, output = shell_cmd_timeout(cmd, timeout=60)
         if status == 2:
             break       
     if type(output) is bytes:
         output = output.decode("ascii")
     assert status == 2, "Error messages: %s" % output 
Пример #11
0
    def lowpan0_izchat_check(self, remote_ip):
        ''' On main target, run izchat to communicate with each other 
        @fn lowpan0_izchat_check
        @param self
        @param remote_ip: the ipv4 address of the remote device
        @return
        '''
        # By own ip6 address, identify src and tag
        if self.get_lowpan0_ip().split(':')[-1] == "1":
            src = "8001"
            tar = "8002"
        elif self.get_lowpan0_ip().split(':')[-1] == "2":
            src = "8002"
            tar = "8001"
        print '\n'
        # Setup remote device to send a string for 5 times
        send_expect = os.path.join(os.path.dirname(__file__),
                                   "files/izchat_send.exp")
        send_cmd = "expect %s 777 %s %s %s" % (send_expect, tar, src,
                                               remote_ip)
        subprocess.Popen(send_cmd, shell=True)

        # Setup device to receive the string
        receive_expect = os.path.join(os.path.dirname(__file__),
                                      "files/izchat_receive.exp")
        (status, output) = shell_cmd_timeout(
            "expect %s 777 %s %s %s" %
            (receive_expect, src, tar, self.target.ip))
        assert status == 2, "Izchat with each other fails: %s" % output
Пример #12
0
    def get_interface(self):
        """
        @fn get_interface
        @param self
        @return
        """
        # if user takes -s option, it is host's IP, directly use it
        if '192.168.7.1' == self.target.server_ip:
            # Get target ip address prefix of LAN, for example, 192.168.8.100 is 192.168.8
            ipv4 = self.get_ipv4().split('.')
            prefix = "%s.%s.%s" % (ipv4[0], ipv4[1], ipv4[2])
        else:
            prefix = self.target.server_ip
        # Use this prefix to get corresponding interface of the host
        (status, ifconfig) = shell_cmd_timeout('ifconfig')
        for line in ifconfig.splitlines():
            if type(line) is bytes:
                linetemp = line.decode('ascii')
            if "inet addr:%s" % prefix in linetemp:
                index = ifconfig.splitlines().index(line)
                interface = ifconfig.splitlines()[index - 1]
                if type(interface) is bytes:
                    interface = interface.decode('ascii')
                return interface.split()[0]

        # if above return is not OK, there might be error, return Blank
        self.assertEqual(1,
                         0,
                         msg="Host interface with %s is not found" % prefix)
Пример #13
0
 def test_mnode_group(self):
     '''
         groupclient has 4 main operations. Only option1 is doable.
         In option (user inputs 1), it will set ActionSet value of rep. This case
         is to check if the set operation is done. 
     @fn test_group
     @param self
     @return
     '''
     # start light server and group server
     lightserver_cmd = "/opt/iotivity/examples/resource/cpp/lightserver > /tmp/svr_output &"
     (status, output) = run_as("root", lightserver_cmd, target=self.targets[1])
     time.sleep(2)
     ssh_cmd = "ssh root@%s -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR" % self.targets[1].ip
     groupserver_cmd = "/opt/iotivity/examples/resource/cpp/groupserver > /dev/null 2>&1"
     subprocess.Popen("%s %s" % (ssh_cmd, groupserver_cmd), shell=True)
     time.sleep(3)
     
     # start client to get info, here needs user input. So use expect
     exp_cmd = os.path.join(os.path.dirname(__file__), "files/group_client.exp")
     status, output = shell_cmd_timeout("expect %s %s" % (exp_cmd, self.target.ip), timeout=200)
     # kill server and client
     run_as("root", "killall lightserver groupserver groupclient", target=self.targets[0])        
     run_as("root", "killall lightserver groupserver groupclient", target=self.targets[1])        
     time.sleep(3)       
     ##
     # TESTPOINT: #1, test_group
     #
     if type(output) is bytes:
         output = output.decode('ascii')
     self.assertEqual(status, 2, msg="expect excution fail\n %s" % output)
Пример #14
0
 def test_bt_visable_on(self):
     '''enable visibility
     @fn test_bt_visable_on
     @param self
     @return
     '''
     self.target.run('hciconfig hci0 noscan')
     # start bluetoothctl, then input 'discoverable on'
     exp = os.path.join(os.path.dirname(__file__),
                        "files/discoverable_on.exp")
     target_ip = self.target.ip
     status, output = shell_cmd_timeout('expect %s %s' % (exp, target_ip),
                                        timeout=200)
     ##
     # TESTPOINT: #1, test_bt_visable_on
     #
     self.assertEqual(status,
                      2,
                      msg="discoverable on command fails: %s" % output)
     # check it again with hciconfig
     (status, output) = self.target.run("hciconfig hci0 | grep 'ISCAN'")
     ##
     # TESTPOINT: #2, test_bt_visable_on
     #
     self.assertEqual(status, 0, msg="%s" % output)
Пример #15
0
    def gatt_basic_check(self, btmac, point):
        '''Do basic gatt tool check points.
        @fn gatt_basic_check
        @param self
        @param btmac: remote advertising device BT MAC address
        @param point: a string for basic checking points.
        @return
        '''
        # Local does gatttool commands
        if point == "connect":
            exp = os.path.join(os.path.dirname(__file__),
                               "files/gatt_connect.exp")
            cmd = "expect %s %s %s" % (exp, self.target.ip, btmac)
            return shell_cmd_timeout(cmd, timeout=100)

        if point == "primary":
            cmd = "/tmp/gatttool -b %s --%s | grep '^attr handle'" % (btmac,
                                                                      point)
        elif point == "characteristics":
            cmd = "/tmp/gatttool -b %s --%s | grep '^handle'" % (btmac, point)
        elif point == "handle":
            cmd = "/tmp/gatttool -b %s --char-read -a 0x0002 | grep '02 03 00 00 2a'" % btmac
        else:
            assert False, "Wrong check point name, please check case"

        return self.target.run(cmd, timeout=20)
Пример #16
0
 def test_bt_target_gatt_read_characteristics(self):
     '''Use gatttool to show host characteristics handles
     @fn test_bt_target_gatt_read_characteristics
     @param self
     @return
     '''
     # On host, do LE advertising
     shell_cmd_timeout('hciconfig hci0 leadv')
     time.sleep(1)
     # Target does gatttool commands
     (status, host_btmac) = shell_cmd_timeout("hciconfig | grep 'BD Address' | awk '{print $3}'")
     cmd = "gatttool --characteristics -b %s | grep '^handle'" % host_btmac.strip("\n")
     status, output = self.target.run(cmd, timeout=200)
     ##
     # TESTPOINT: #1, test_bt_target_gatt_read_characteristics
     #
     self.assertEqual(status, 0, msg="Host characteristics info is wrong")
Пример #17
0
 def test_bt_target_gatt_connect(self):
     '''Use gatttool interactive mode to do connect to host
     @fn test_bt_target_gatt_connect
     @param self
     @return
     '''
     # On target, do LE advertising
     shell_cmd_timeout('hciconfig hci0 leadv')
     time.sleep(1)
     # Target does gatttool commands
     (status, host_btmac) = shell_cmd_timeout("hciconfig | grep 'BD Address' | awk '{print $3}'")
     connect_exp = os.path.join(os.path.dirname(__file__), "files/gatt_connect_target.exp")
     cmd = "expect %s %s %s" % (connect_exp, self.target.ip, host_btmac)
     status, output = shell_cmd_timeout(cmd, timeout=200)
     ##
     # TESTPOINT: #1, test_bt_target_gatt_connect
     #
     self.assertEqual(status, 2, msg="gatttool connect host fails: %s" % output) 
Пример #18
0
 def host_hciconfig_init(self):
     ''' init host bluetooth by hciconfig commands 
     @fn host_hciconfig_init
     @param self
     @return
     '''
     shell_cmd_timeout('hciconfig hci0 reset', timeout=200)
     time.sleep(1)
     shell_cmd_timeout('hciconfig hci0 up', timeout=100)
     shell_cmd_timeout('hciconfig hci0 piscan', timeout=100)
     shell_cmd_timeout('hciconfig hci0 noleadv', timeout=100)
     time.sleep(1)
Пример #19
0
 def test_bt_target_gatt_read_characteristics(self):
     '''Use gatttool to show host characteristics handles
     @fn test_bt_target_gatt_read_characteristics
     @param self
     @return
     '''
     # On host, do LE advertising
     shell_cmd_timeout('hciconfig hci0 leadv')
     time.sleep(1)
     # Target does gatttool commands
     (status, host_btmac) = shell_cmd_timeout(
         "hciconfig | grep 'BD Address' | awk '{print $3}'")
     cmd = "gatttool --characteristics -b %s | grep '^handle'" % host_btmac.strip(
         "\n")
     status, output = self.target.run(cmd, timeout=200)
     ##
     # TESTPOINT: #1, test_bt_target_gatt_read_characteristics
     #
     self.assertEqual(status, 0, msg="Host characteristics info is wrong")
Пример #20
0
 def test_bt_target_gatt_read_handle(self):
     '''Use gatttool to read host handle value
     @fn test_bt_target_gatt_read_handle
     @param self
     @return
     '''
     # On target, do LE advertising
     shell_cmd_timeout('hciconfig hci0 leadv')
     time.sleep(1)
     # Target does gatttool commands
     (status, host_btmac) = shell_cmd_timeout("hciconfig | grep 'BD Address' | awk '{print $3}'")
     print host_btmac
     cmd = "gatttool --char-read -a 0x0002 -b %s | grep '02 03 00 00 2a'" % host_btmac.strip("\n")
     print cmd
     status, output = self.target.run(cmd, timeout=200)
     ##
     # TESTPOINT: #1, test_bt_target_gatt_read_handle
     #
     self.assertEqual(status, 0, msg="Host handle 0x0002 value is wrong")
Пример #21
0
 def host_hciconfig_init(self):
     ''' init host bluetooth by hciconfig commands 
     @fn host_hciconfig_init
     @param self
     @return
     '''
     shell_cmd_timeout('hciconfig hci0 reset', timeout=200)
     time.sleep(1)
     shell_cmd_timeout('hciconfig hci0 up', timeout=100)
     shell_cmd_timeout('hciconfig hci0 piscan', timeout=100)
     shell_cmd_timeout('hciconfig hci0 noleadv', timeout=100)
     time.sleep(1)
Пример #22
0
 def ctl_power_off(self):
     '''bluetoothctl power off bluetooth device
     @fn ctl_power_off
     @param self
     @return
     '''
     # start bluetoothctl, then input 'power off'
     exp = os.path.join(os.path.dirname(__file__), "files/power_off.exp")
     target_ip = self.target.ip
     status, output = shell_cmd_timeout('expect %s %s' % (exp, target_ip), timeout=200)
     assert status == 2, "power off command fails: %s" % output
Пример #23
0
 def test_bt_le_scan(self):
     '''Another device (host) does LE advertising, target scan
     @fn test_bt_le_scan
     @param self
     @return
     '''
     # close host piscan firstly, and then enable leadv
     status, output = shell_cmd_timeout('hciconfig hci0 leadv 3', timeout=100)
     time.sleep(1)
     (status, host_btmac) = shell_cmd_timeout("hciconfig | grep 'BD Address' | awk '{print $3}'", timeout=100)
     # From target, start bluetoothctl to scan host
     exp = os.path.join(os.path.dirname(__file__), "files/bt_target_lescan.exp")
     cmd = "expect %s %s %s" % (exp, self.target.ip, host_btmac)
     status, output = shell_cmd_timeout(cmd, timeout=100)
     shell_cmd_timeout('hciconfig hci0 reset', timeout=100)
     self.target.run('hciconfig hci0 reset')
     ##
     # TESTPOINT: #1, test_bt_le_scan
     #
     self.assertEqual(status, 2, msg="scan host leadv fails: %s" % output) 
Пример #24
0
 def test_bt_leadv(self):
     '''Target does LE advertising, Host scan target
     @fn test_bt_leadv
     @param self
     @return
     '''
     # close target piscan firstly, and then enable leadv
     self.target.run('hciconfig hci0 leadv')
     time.sleep(1)
     (status, target_btmac) = self.target.run("hciconfig | grep 'BD Address' | awk '{print $3}'")
     # start bluetoothctl to scan target 
     exp = os.path.join(os.path.dirname(__file__), "files/bt_lescan.exp")
     cmd = "expect %s %s" % (exp, target_btmac)
     status, output = shell_cmd_timeout(cmd, timeout=100)
     shell_cmd_timeout('hciconfig hci0 reset', timeout=100)
     self.target.run('hciconfig hci0 reset')
     ##
     # TESTPOINT: #1, test_bt_leadv
     #
     self.assertEqual(status, 2, msg="scan target leadv fails: %s" % output) 
Пример #25
0
 def ctl_visable_off(self):
     '''bluetoothctl disable visibility
     @fn ctl_visable_off
     @param self
     @return
     '''
     # start bluetoothctl, then input 'discoverable off'
     exp = os.path.join(os.path.dirname(__file__), "files/discoverable_off.exp")
     target_ip = self.target.ip
     status, output = shell_cmd_timeout('expect %s %s' % (exp, target_ip), timeout=200)
     assert status == 2, "discoverable off command fails: %s" % output
Пример #26
0
 def test_bt_visible_scan(self):
     '''Scan nearby bluetooth devices (not ble scan)
     @fn test_bt_visible_scan
     @param self
     @return
     '''
     # Close target's leadv
     self.target.run('hciconfig hci0 noleadv')
     self.target.run('hciconfig hci0 piscan')
     time.sleep(1)
     (status, target_btmac) = self.target.run("hciconfig | grep 'BD Address' | awk '{print $3}'")
     # start bluetoothctl to scan target 
     exp = os.path.join(os.path.dirname(__file__), "files/bt_scan.exp")
     cmd = "expect %s %s" % (exp, target_btmac)
     status, output = shell_cmd_timeout(cmd, timeout=100)
     shell_cmd_timeout('hciconfig hci0 reset', timeout=100)
     self.target.run('hciconfig hci0 reset')
     ##
     # TESTPOINT: #1, test_bt_visible_scan
     #
     self.assertEqual(status, 2, msg="scan target fails: %s" % output) 
Пример #27
0
 def ctl_power_on(self):
     """
     Use bluetoothctl to power on bluetooth device
     """
     # start bluetoothctl, then input 'power on'
     exp = os.path.join(os.path.dirname(__file__), "files/power_on.exp")
     target_ip = self.target.ip
     status, output = shell_cmd_timeout('expect %s %s' % (exp, target_ip),
                                        timeout=200)
     if type(output) is bytes:
         output = output.decode("ascii")
     assert status == 2, "power on command fails: %s" % output
Пример #28
0
 def test_bt_leadv(self):
     '''Target does LE advertising, Host scan target
     @fn test_bt_leadv
     @param self
     @return
     '''
     # close target piscan firstly, and then enable leadv
     self.target.run('hciconfig hci0 leadv')
     time.sleep(1)
     (status, target_btmac) = self.target.run(
         "hciconfig | grep 'BD Address' | awk '{print $3}'")
     # start bluetoothctl to scan target
     exp = os.path.join(os.path.dirname(__file__), "files/bt_lescan.exp")
     cmd = "expect %s %s" % (exp, target_btmac)
     status, output = shell_cmd_timeout(cmd, timeout=100)
     shell_cmd_timeout('hciconfig hci0 reset', timeout=100)
     self.target.run('hciconfig hci0 reset')
     ##
     # TESTPOINT: #1, test_bt_leadv
     #
     self.assertEqual(status, 2, msg="scan target leadv fails: %s" % output)
Пример #29
0
 def test_bt_target_gatt_read_handle(self):
     '''Use gatttool to read host handle value
     @fn test_bt_target_gatt_read_handle
     @param self
     @return
     '''
     # On target, do LE advertising
     shell_cmd_timeout('hciconfig hci0 leadv')
     time.sleep(1)
     # Target does gatttool commands
     (status, host_btmac) = shell_cmd_timeout(
         "hciconfig | grep 'BD Address' | awk '{print $3}'")
     print host_btmac
     cmd = "gatttool --char-read -a 0x0002 -b %s | grep '02 03 00 00 2a'" % host_btmac.strip(
         "\n")
     print cmd
     status, output = self.target.run(cmd, timeout=200)
     ##
     # TESTPOINT: #1, test_bt_target_gatt_read_handle
     #
     self.assertEqual(status, 0, msg="Host handle 0x0002 value is wrong")
Пример #30
0
 def ctl_power_off(self):
     '''bluetoothctl power off bluetooth device
     @fn ctl_power_off
     @param self
     @return
     '''
     # start bluetoothctl, then input 'power off'
     exp = os.path.join(os.path.dirname(__file__), "files/power_off.exp")
     target_ip = self.target.ip
     status, output = shell_cmd_timeout('expect %s %s' % (exp, target_ip),
                                        timeout=200)
     assert status == 2, "power off command fails: %s" % output
Пример #31
0
 def test_bt_scan(self):
     '''Scan nearby bluetooth devices (not ble scan)
     @fn test_bt_scan
     @param self
     @return
     '''
     self.bt2.target.run('hciconfig hci0 noleadv')
     # For init function already set visible status, directly be scanned.  
     exp = os.path.join(os.path.dirname(__file__), "files/bt_scan.exp")
     cmd = "expect %s %s %s" % (exp, self.bt1.target.ip, self.bt2.get_bt_mac())
     status, output = shell_cmd_timeout(cmd, timeout=100)
     self.assertEqual(status, 2, msg="Scan remote device fails: %s" % output) 
Пример #32
0
 def ctl_visable_on(self):
     '''bluetoothctl enable visibility
     @fn ctl_visable_on
     @param self
     @return
     '''
     # start bluetoothctl, then input 'discoverable on'
     exp = os.path.join(os.path.dirname(__file__), "files/discoverable_on.exp")
     target_ip = self.target.ip
     status, output = shell_cmd_timeout('expect %s %s' % (exp, target_ip), timeout=200)
     if type(output) is bytes:
         output = output.decode("ascii")
     assert status == 2, "discoverable on command fails: %s" % output
Пример #33
0
 def test_bt_target_gatt_connect(self):
     '''Use gatttool interactive mode to do connect to host
     @fn test_bt_target_gatt_connect
     @param self
     @return
     '''
     # On target, do LE advertising
     shell_cmd_timeout('hciconfig hci0 leadv')
     time.sleep(1)
     # Target does gatttool commands
     (status, host_btmac) = shell_cmd_timeout(
         "hciconfig | grep 'BD Address' | awk '{print $3}'")
     connect_exp = os.path.join(os.path.dirname(__file__),
                                "files/gatt_connect_target.exp")
     cmd = "expect %s %s %s" % (connect_exp, self.target.ip, host_btmac)
     status, output = shell_cmd_timeout(cmd, timeout=200)
     ##
     # TESTPOINT: #1, test_bt_target_gatt_connect
     #
     self.assertEqual(status,
                      2,
                      msg="gatttool connect host fails: %s" % output)
Пример #34
0
 def test_bt_visible_scan(self):
     '''Scan nearby bluetooth devices (not ble scan)
     @fn test_bt_visible_scan
     @param self
     @return
     '''
     # Close target's leadv
     self.target.run('hciconfig hci0 noleadv')
     self.target.run('hciconfig hci0 piscan')
     time.sleep(1)
     (status, target_btmac) = self.target.run(
         "hciconfig | grep 'BD Address' | awk '{print $3}'")
     # start bluetoothctl to scan target
     exp = os.path.join(os.path.dirname(__file__), "files/bt_scan.exp")
     cmd = "expect %s %s" % (exp, target_btmac)
     status, output = shell_cmd_timeout(cmd, timeout=100)
     shell_cmd_timeout('hciconfig hci0 reset', timeout=100)
     self.target.run('hciconfig hci0 reset')
     ##
     # TESTPOINT: #1, test_bt_visible_scan
     #
     self.assertEqual(status, 2, msg="scan target fails: %s" % output)
Пример #35
0
 def ctl_visable_on(self):
     '''bluetoothctl enable visibility
     @fn ctl_visable_on
     @param self
     @return
     '''
     # start bluetoothctl, then input 'discoverable on'
     exp = os.path.join(os.path.dirname(__file__),
                        "files/discoverable_on.exp")
     target_ip = self.target.ip
     status, output = shell_cmd_timeout('expect %s %s' % (exp, target_ip),
                                        timeout=200)
     assert status == 2, "discoverable on command fails: %s" % output
Пример #36
0
 def ctl_visible_off(self):
     """
     Use bluetoothctl to disable visibility
     """
     # start bluetoothctl, then input 'discoverable off'
     exp = os.path.join(os.path.dirname(__file__),
                        "files/discoverable_off.exp")
     target_ip = self.target.ip
     status, output = shell_cmd_timeout('expect %s %s' % (exp, target_ip),
                                        timeout=200)
     if type(output) is bytes:
         output = output.decode("ascii")
     assert status == 2, "discoverable off command fails: %s" % output
Пример #37
0
 def _setup(self):
     """The test requires power control program:rs2
     @fn _setup
     @param self
     @return
     """
     (status, output) = self.target.run("reboot &")
     time.sleep(100)
     ret = shell_cmd_timeout("ping -c 1 %s" %self.target.ip, 4)[0]
     if ret != 0:
         return False
     else:
         time.sleep(10)
Пример #38
0
 def _setup(self):
     """The test requires power control program:rs2
     @fn _setup
     @param self
     @return
     """
     (status, output) = self.target.run("reboot &")
     time.sleep(100)
     ret = shell_cmd_timeout("ping -c 1 %s" % self.target.ip, 4)[0]
     if ret != 0:
         return False
     else:
         time.sleep(10)
Пример #39
0
 def test_bt_le_scan(self):
     '''Another device (host) does LE advertising, target scan
     @fn test_bt_le_scan
     @param self
     @return
     '''
     # close host piscan firstly, and then enable leadv
     status, output = shell_cmd_timeout('hciconfig hci0 leadv 3',
                                        timeout=100)
     time.sleep(1)
     (status, host_btmac) = shell_cmd_timeout(
         "hciconfig | grep 'BD Address' | awk '{print $3}'", timeout=100)
     # From target, start bluetoothctl to scan host
     exp = os.path.join(os.path.dirname(__file__),
                        "files/bt_target_lescan.exp")
     cmd = "expect %s %s %s" % (exp, self.target.ip, host_btmac)
     status, output = shell_cmd_timeout(cmd, timeout=100)
     shell_cmd_timeout('hciconfig hci0 reset', timeout=100)
     self.target.run('hciconfig hci0 reset')
     ##
     # TESTPOINT: #1, test_bt_le_scan
     #
     self.assertEqual(status, 2, msg="scan host leadv fails: %s" % output)
Пример #40
0
    def ipv4_ssh_to(self, ipv4):
        ''' On main target, ssh to second
        @fn ipv4_ssh_to
        @param self
        @param ipv4: second target ipv4 address
        @return
        '''
        ssh_key = os.path.join(os.path.dirname(__file__), "../bluetooth/files/ostro_qa_rsa")
        self.target.copy_to(ssh_key, "/tmp/")

        exp = os.path.join(os.path.dirname(__file__), "files/ssh_to.exp")
        exp_cmd = 'expect %s %s %s' % (exp, self.target.ip, ipv4)
        (status, output) = shell_cmd_timeout(exp_cmd)
        assert status == 2, "Error messages: %s" % output
Пример #41
0
 def test_bt_scan(self):
     """
     Scan nearby bluetooth devices (not ble scan)
     """
     self.bt2.target.run('hciconfig hci0 noleadv')
     for i in range(3):
         # For init function already set visible status, directly be scanned.
         exp = os.path.join(os.path.dirname(__file__), "files/bt_scan.exp")
         cmd = "expect %s %s %s" % (exp, self.bt1.target.ip, self.bt2.get_bt_mac())
         status, output = shell_cmd_timeout(cmd, timeout=100)
         if status == 2:
             break
     if type(output) is bytes:
         output = output.decode("ascii")
     self.assertEqual(status, 2, msg="Scan remote device fails: %s" % output)
Пример #42
0
    def test_bt_pairing(self):
        '''Use bluetoothctl to pair IoT device with host
        @fn test_bt_pairing
        @param self
        @return
        '''
        # On IoT target, start pair_slave in back-ground
        (status, host_btmac) = shell_cmd_timeout(
            "hciconfig | grep 'BD Address' | awk '{print $3}'")
        slave_exp = os.path.join(os.path.dirname(__file__),
                                 "files/bt_pair_slave_on_iot.exp")
        cmd = "%s %s %s" % (slave_exp, self.target.ip, host_btmac)
        subprocess.Popen(cmd, shell=True)

        # On Host, get to know target BT mac and perform pair_master
        master_exp = os.path.join(os.path.dirname(__file__),
                                  "files/bt_pair_master.exp")
        (status, target_btmac) = self.target.run(
            "hciconfig | grep 'BD Address' | awk '{print $3}'")
        cmd = "expect %s %s" % (master_exp, target_btmac)
        status, output = shell_cmd_timeout(cmd, timeout=200)
        ##
        # TESTPOINT: #1, test_bt_pairing
        #
        self.assertEqual(status, 2, msg="expect excution fail: %s" % output)

        # On Host, check paired devices to see if IoT is in
        check_exp = os.path.join(os.path.dirname(__file__),
                                 "files/bt_list_paired_device.exp")
        status, output = shell_cmd_timeout("%s | grep '^Device %s'" %
                                           (check_exp, target_btmac),
                                           timeout=200)
        ##
        # TESTPOINT: #2, test_bt_pairing
        #
        self.assertEqual(status, 0, msg="Not found IoT device paired")
Пример #43
0
    def ipv4_ssh_to(self, ipv4):
        ''' On main target, ssh to second
        @fn ipv4_ssh_to
        @param self
        @param ipv4: second target ipv4 address
        @return
        '''
        ssh_key = os.path.join(os.path.dirname(__file__),
                               "../bluetooth/files/ostro_qa_rsa")
        self.target.copy_to(ssh_key, "/tmp/")

        exp = os.path.join(os.path.dirname(__file__), "files/ssh_to.exp")
        exp_cmd = 'expect %s %s %s' % (exp, self.target.ip, ipv4)
        (status, output) = shell_cmd_timeout(exp_cmd)
        assert status == 2, "Error messages: %s" % output
Пример #44
0
    def bt0_ssh_check(self, ipv6):
        ''' On main target, ssh to second
        @fn bt0_ssh_check
        @param self
        @param ipv6: second target ipv6 address
        @return
        '''
        # ssh root@<ipv6 address>%bt0
        ssh_key = os.path.join(os.path.dirname(__file__), "files/ostro_qa_rsa")
        self.target.copy_to(ssh_key, "/tmp/")

        exp = os.path.join(os.path.dirname(__file__), "files/target_ssh.exp")
        exp_cmd = 'expect %s %s %s' % (exp, self.target.ip, ipv6)
        (status, output) = shell_cmd_timeout(exp_cmd)
        assert status == 2, "Error messages: %s" % output
Пример #45
0
 def test_bt_visible(self):
     '''Do traditional visible and be scanned by other (not ble scan)
     @fn test_bt_visible
     @param self
     @return
     '''
     self.bt1.target.run('hciconfig hci0 noleadv')
     for i in range(3):
         # For init function already set visible status, directly be scanned.  
         exp = os.path.join(os.path.dirname(__file__), "files/bt_scan.exp")
         cmd = "expect %s %s %s" % (exp, self.bt2.target.ip, self.bt1.get_bt_mac())
         status, output = shell_cmd_timeout(cmd, timeout=100)
         if status == 2:
             break
     self.assertEqual(status, 2, msg="Scan remote device fails: %s" % output) 
Пример #46
0
 def get_name(self):
     ''' Get bt0 device name by bluetoothctl
     @fn get_name
     @param self
     @return
     '''
     exp = os.path.join(os.path.dirname(__file__), "files/bt_get_name.exp")
     btmac = self.get_bt_mac()
     cmd = 'expect %s %s %s' % (exp, self.target.ip, btmac)
     (status, output) = shell_cmd_timeout(cmd)
     assert status == 0, "Get hci0 name fails: %s" % output
     for line in output.splitlines():
         if "Controller %s" % btmac in line:
             return line.split()[3]
     return ""
Пример #47
0
 def get_name(self):
     ''' Get bt0 device name by bluetoothctl
     @fn get_name
     @param self
     @return
     '''
     exp = os.path.join(os.path.dirname(__file__), "files/bt_get_name.exp")
     btmac = self.get_bt_mac()
     cmd = 'expect %s %s %s' % (exp, self.target.ip, btmac)
     (status, output) = shell_cmd_timeout(cmd)
     assert status == 0, "Get hci0 name fails: %s" % output
     for line in output.splitlines():
         if "Controller %s" % btmac in line:
             return line.split()[3]
     return ""
Пример #48
0
    def ipv4_ssh_to(self, ipv4):
        '''
        On main target, ssh to second
        '''
        ssh_key = os.path.join(os.path.dirname(__file__),
                               "../bluetooth/files/refkit_qa_rsa")
        self.target.copy_to(ssh_key, "/tmp/")
        self.target.run("chmod 400 /tmp/refkit_qa_rsa")

        exp = os.path.join(os.path.dirname(__file__), "files/ssh_to.exp")
        exp_cmd = 'expect %s %s %s' % (exp, self.target.ip, ipv4)
        (status, output) = shell_cmd_timeout(exp_cmd)
        if type(output) is bytes:
            output = output.decode("ascii")
        assert status == 2, "Error messages: %s" % output
Пример #49
0
 def test_bt_le_advertising(self):
     '''Target does LE advertising, another device scans it
     @fn test_bt_le_advertising
     @param self
     @return
     '''
     # close legacy iscan mode
     self.bt1.target.run('hciconfig hci0 noscan')
     # begin low-energy scan
     self.bt1.target.run('hciconfig hci0 leadv')
     time.sleep(1)
     # Another device starts bluetoothctl to scan target 
     exp = os.path.join(os.path.dirname(__file__), "files/bt_scan.exp")
     cmd = "expect %s %s %s" % (exp, self.bt2.target.ip, self.bt1.get_bt_mac())
     status, output = shell_cmd_timeout(cmd, timeout=100)
     self.assertEqual(status, 2, msg="Be LE-scanned fails: %s" % output) 
Пример #50
0
    def bt0_ssh_check(self, ipv6):
        ''' On main target, ssh to second
        @fn bt0_ssh_check
        @param self
        @param ipv6: second target ipv6 address
        @return
        '''
        # ssh root@<ipv6 address>%bt0
        ssh_key = os.path.join(os.path.dirname(__file__), "files/ostro_qa_rsa")
        self.target.copy_to(ssh_key, "/tmp/")        
        self.target.run("chmod 400 /tmp/ostro_qa_rsa")        

        exp = os.path.join(os.path.dirname(__file__), "files/target_ssh.exp")
        exp_cmd = 'expect %s %s %s' % (exp, self.target.ip, ipv6)
        (status, output) = shell_cmd_timeout(exp_cmd)
        assert status == 2, "Error messages: %s" % output
Пример #51
0
 def get_name(self):
     """
     Get bt0 device name by bluetoothctl
     """
     exp = os.path.join(os.path.dirname(__file__), "files/bt_get_name.exp")
     btmac = self.get_bt_mac()
     cmd = 'expect %s %s %s' % (exp, self.target.ip, btmac)
     (status, output) = shell_cmd_timeout(cmd)
     if type(output) is bytes:
         output = output.decode("ascii")
     assert status == 0, "Get hci0 name fails: %s" % output
     for line in output.splitlines():
         if type(line) is bytes:
             line = line.decode('ascii')
         if "Controller %s" % btmac in line:
             return line.split()[3]
     return ""
Пример #52
0
    def bt0_ssh_check(self, ipv6):
        """ On main target, ssh to second

        @param ipv6: second target ipv6 address
        """
        # ssh root@<ipv6 address>%bt0
        ssh_key = os.path.join(os.path.dirname(__file__),
                               "files/refkit_qa_rsa")
        self.target.copy_to(ssh_key, "/tmp/")
        self.target.run("chmod 400 /tmp/refkit_qa_rsa")

        exp = os.path.join(os.path.dirname(__file__), "files/target_ssh.exp")
        exp_cmd = 'expect %s %s %s' % (exp, self.target.ip, ipv6)
        (status, output) = shell_cmd_timeout(exp_cmd)
        if type(output) is bytes:
            output = output.decode("ascii")
        assert status == 2, "Error messages: %s" % output
Пример #53
0
 def test_bt_gatt_read_primary(self):
     '''Use gatttool to show target primary attr handles
     @fn test_bt_gatt_read_primary
     @param self
     @return
     '''
     # On target, do LE advertising
     self.target.run('hciconfig hci0 leadv')
     time.sleep(1)
     # Host does gatttool commands
     (status, target_btmac) = self.target.run("hciconfig | grep 'BD Address' | awk '{print $3}'")
     cmd = "gatttool -b %s --primary | grep '^attr handle'" % target_btmac
     status, output = shell_cmd_timeout(cmd, timeout=200)
     ##
     # TESTPOINT: #1, test_bt_gatt_read_primary
     #
     self.assertEqual(status, 0, msg="Primary info is wrong")
Пример #54
0
 def test_ethernet_ipv6_ping(self):
     '''Ping other device via ipv6 address of the ethernet
     @fn test_ethernet_ipv6_ping
     @param self
     @return
     '''
     # Get target ipv6 address
     ip6_address = self.get_ipv6()
     # ping6 needs host's ethernet interface by -I,
     # because default gateway is only for ipv4
     host_eth = eth_config.get("Ethernet", "interface")
     cmd = "ping6 -I %s %s -c 1" % (host_eth, ip6_address)
     status, output = shell_cmd_timeout(cmd, timeout=60)
     ##
     # TESTPOINT: #1, test_ethernet_ipv6_ping
     #
     self.assertEqual(status, 0, msg="Error messages: %s" % output)
Пример #55
0
 def test_ethernet_ipv6_ping(self):
     '''Ping other device via ipv6 address of the ethernet
     @fn test_ethernet_ipv6_ping
     @param self
     @return
     '''
     # Get target ipv6 address
     ip6_address = self.get_ipv6()
     # ping6 needs host's ethernet interface by -I, 
     # because default gateway is only for ipv4
     host_eth = self.get_interface()
     cmd = "ping6 -I %s %s -c 1" % (host_eth, ip6_address) 
     status, output = shell_cmd_timeout(cmd, timeout=60)
     ##
     # TESTPOINT: #1, test_ethernet_ipv6_ping
     #
     self.assertEqual(status, 0, msg="Error messages: %s" % output)
Пример #56
0
    def get_interface(self):
        """
        @fn get_interface
        @param self
        @return
        """
        # Get target ip address prefix of LAN, for example, 192.168.8.100 is 192.168.8
        ipv4 = self.get_ipv4().split('.')
        prefix = "%s.%s.%s" % (ipv4[0], ipv4[1], ipv4[2])
        # Use this prefix to get corresponding interface of the host
        (status, ifconfig) = shell_cmd_timeout('ifconfig')
        for line in ifconfig.splitlines():
            if "inet addr:%s" % prefix in line:
                index = ifconfig.splitlines().index(line)
                return ifconfig.splitlines()[index - 1].split()[0]

        # if above return is not OK, there might be error, return Blank
        self.assertEqual(1, 0, msg="Target with address %s is not connectable" % ipv4)
Пример #57
0
 def test_ethernet_ipv6_ssh(self):
     '''SSH other device via ipv6 address of the ethernet
     @fn test_ethernet_ipv6_ssh
     @param self
     @return
     '''
     # Get target ipv6 address
     ip6_address = self.get_ipv6()
     # Same as ping6, ssh with ipv6 also need host's ethernet interface
     # ssh root@<ipv6 address>%<eth>
     host_eth = eth_config.get("Ethernet","interface")
     exp = os.path.join(os.path.dirname(__file__), "files/ipv6_ssh.exp")
     cmd = "expect %s %s %s %s" % (exp, ip6_address, "ostro", host_eth)
     status, output = shell_cmd_timeout(cmd, timeout=60)
     # In expect, it will input yes and password while login. And do 'ls /'
     # If see /home folder, it will return 2 as successful status.
     ##
     # TESTPOINT: #1, test_ethernet_ipv6_ssh
     #
     self.assertEqual(status, 2, msg="Error messages: %s" % output)
Пример #58
0
 def test_bt_power_on(self):
     '''enable bluetooth device
     @fn test_bt_power_on
     @param self
     @return
     '''
     self.target.run('hciconfig hci0 down')
     # start bluetoothctl, then input 'power on'
     exp = os.path.join(os.path.dirname(__file__), "files/power_on.exp")
     target_ip = self.target.ip
     status, output = shell_cmd_timeout('expect %s %s' % (exp, target_ip), timeout=200)
     ##
     # TESTPOINT: #1, test_bt_power_on
     #
     self.assertEqual(status, 2, msg="power on command fails: %s" % output)
     # check it again with hciconfig
     (status, output) = self.target.run("hciconfig hci0 | grep 'UP RUNNING'")
     ##
     # TESTPOINT: #2, test_bt_power_on
     #
     self.assertEqual(status, 0, msg="%s" % output)
Пример #59
0
 def test_bt_visable_on(self):
     '''enable visibility
     @fn test_bt_visable_on
     @param self
     @return
     '''
     self.target.run('hciconfig hci0 noscan')
     # start bluetoothctl, then input 'discoverable on'
     exp = os.path.join(os.path.dirname(__file__), "files/discoverable_on.exp")
     target_ip = self.target.ip
     status, output = shell_cmd_timeout('expect %s %s' % (exp, target_ip), timeout=200)
     ##
     # TESTPOINT: #1, test_bt_visable_on
     #
     self.assertEqual(status, 2, msg="discoverable on command fails: %s" % output)
     # check it again with hciconfig
     (status, output) = self.target.run("hciconfig hci0 | grep 'ISCAN'")
     ##
     # TESTPOINT: #2, test_bt_visable_on
     #
     self.assertEqual(status, 0, msg="%s" % output)