コード例 #1
0
    def test02_Verify_ChildTable(self):
        childTable = self.parent2.wpanctl(
            "get", "get " + wpan.WPAN_THREAD_CHILD_TABLE, 2)
        childTable = wpan_table_parser.parse_child_table_result(childTable)

        print childTable

        self.assertEqual(len(childTable), 1)

        childTable = self.parent1.wpanctl(
            "get", "get " + wpan.WPAN_THREAD_CHILD_TABLE, 2)
        childTable = wpan_table_parser.parse_child_table_result(childTable)
        self.assertEqual(len(childTable), 0)
コード例 #2
0
    def verify_child_table(self, parent, children):
        """
        This function verifies that child table on `parent` node contains all the entries in `children` list and the child
        table entry's mode value matches the children Thread mode.
        """
        child_table = wpan_table_parser.parse_child_table_result(
            parent.wpanctl("get", "get " + wpan.WPAN_THREAD_CHILD_TABLE, 2))
        print child_table

        verify(len(child_table) == len(children))
        for child in children:
            ext_addr = child.get(wpan.WPAN_EXT_ADDRESS)[1:-1]
            for entry in child_table:
                if entry.ext_address == ext_addr:
                    break
            else:
                raise VerifyError(
                    'Failed to find a child entry for extended address {} in table'
                    .format(ext_addr))

            verify(
                int(entry.rloc16, 16) == int(
                    child.get(wpan.WPAN_THREAD_RLOC16), 16))
            mode = int(child.get(wpan.WPAN_THREAD_DEVICE_MODE), 0)
            verify(entry.is_rx_on_when_idle() == (
                mode & wpan.THREAD_MODE_FLAG_RX_ON_WHEN_IDLE != 0))
            verify(entry.is_ftd() == (
                mode & wpan.THREAD_MODE_FLAG_FULL_THREAD_DEV != 0))
            verify(entry.is_full_net_data() == (
                mode & wpan.THREAD_MODE_FLAG_FULL_NETWORK_DATA != 0))
            verify(entry.is_sec_data_req() == (
                mode & wpan.THREAD_MODE_FLAG_SECURE_DATA_REQUEST != 0))
コード例 #3
0
    def test06_enable_whitelist(self):
        self.router.setprop(wpan.WPAN_MAC_WHITELIST_ENABLED, '1')

        print self.router.getprop(wpan.WPAN_MAC_WHITELIST_ENABLED)

        self.assertEqual(self.router.getprop(wpan.WPAN_MAC_WHITELIST_ENABLED),
                         'true')

        time.sleep(CHILD_TIMEOUT + 3)

        childTable = self.router.wpanctl("get", "get Thread:ChildTable", 2)
        print 'Child Table:'
        print childTable
        childTable = wpan_table_parser.parse_child_table_result(childTable)
        sed_ext_address = self.sed.wpanctl("get", "get NCP:ExtendedAddress",
                                           2).split('=')[-1].strip()[1:-1]

        print childTable

        for e in childTable:
            self.assertNotEqual(
                e.ext_address, sed_ext_address,
                'SED MAC {} still still in Router ChildTable'.format(
                    e.ext_address))

        # verify the sed is still associated since data polls are acked by radio driver) and
        # supervision check is disabled on the child
        self.assertTrue(wpan_table_parser.is_associated(self.sed),
                        'SED is not associated !!!')
コード例 #4
0
ファイル: ot_test_child_table.py プロジェクト: qilinkang/silk
    def test02_Verify_ChildTable(self):
        childTable = self.router.wpanctl("get",
                                         "get " + wpan.WPAN_THREAD_CHILD_TABLE,
                                         2)
        childTable = wpan_table_parser.parse_child_table_result(childTable)

        print childTable

        self.assertEqual(len(childTable), len(self.joiner_list))

        counter = 0
        for i, child in enumerate(self.joiner_list):
            ext_addr = child.getprop(wpan.WPAN_EXT_ADDRESS)[1:-1]

            for entry in childTable:
                if entry.ext_address == ext_addr:
                    self.assertEqual(
                        int(entry.rloc16, 16),
                        int(child.getprop(wpan.WPAN_THREAD_RLOC16), 16))
                    self.assertEqual(
                        int(entry.timeout),
                        int(child.getprop(wpan.WPAN_THREAD_CHILD_TIMEOUT)))

                    if i == len(self.joiner_list) - 1:
                        self.assertTrue(entry.is_ftd())
                        self.assertTrue(entry.is_rx_on_when_idle())
                    else:
                        self.assertFalse(entry.is_ftd())
                        self.assertFalse(entry.is_rx_on_when_idle())
                    counter += 1

        missing_entry = len(self.joiner_list) - counter
        self.assertEqual(
            missing_entry, 0,
            'Missing {} child entry in Child table'.format(str(missing_entry)))
コード例 #5
0
    def check_child_table(self):
        # Checks the child table includes the expected number of children.
        child_table = self.router.wpanctl(
            "get", "get " + wpan.WPAN_THREAD_CHILD_TABLE, 2)
        child_table = wpan_table_parser.parse_child_table_result(child_table)

        print child_table

        verify(len(child_table) == NUM_CHILDREN)
コード例 #6
0
    def test04_Verify_New_Parent(self):
        # Verify that the `child` is now attached to `parent1`
        child_table = self.parent1.wpanctl(
            "get", "get " + wpan.WPAN_THREAD_CHILD_TABLE, 2)
        child_table = wpan_table_parser.parse_child_table_result(child_table)
        verify(len(child_table) == 1)

        # Finally verify that the `child` is removed from previous parent's child
        # table (which indicates that the `child` did indeed inform its previous
        # parent).

        verify_within(self.check_child_is_removed_from_parent2_table, 1)
コード例 #7
0
    def test05_verify_childTable(self):
        childTable = self.router.wpanctl("get", "get Thread:ChildTable", 2)
        childTable = wpan_table_parser.parse_child_table_result(childTable)
        sed_ext_address = self.sed.wpanctl("get", "get NCP:ExtendedAddress",
                                           2).split('=')[-1].strip()[1:-1]

        for e in childTable:
            if e.ext_address == sed_ext_address:
                break
        else:
            msg = 'Failed to find a child entry for extended address {} in table'.format(
                sed_ext_address)
            print msg

        self.assertEqual(
            int(e.rloc16, 16),
            int(
                self.sed.wpanctl("get", "get " + wpan.WPAN_THREAD_RLOC16,
                                 2).split('=')[-1].strip(), 16))
        self.assertEqual(int(e.timeout, 0), CHILD_TIMEOUT)
        self.assertEqual(e.is_rx_on_when_idle(), False)
        self.assertEqual(e.is_ftd(), False)