def test03_Verify_Parent_Reset(self):
        # Remember number of NCP state changes (using "stat:ncp" property) per child
        child_num_state_changes = []
        for child in self.all_children:
            child_num_state_changes.append(
                len(wpan_table_parser.parse_list(child.get("stat:ncp"))))

        print child_num_state_changes

        # Reset the parent
        self.router.reset_thread_radio()
        self.wait_for_completion(self.device_list)

        def check_parent_is_associated():
            verify(is_associated(self.router))

        verify_within(check_parent_is_associated, 20, 3)

        # Verify that all the children are recovered and present in the parent's child table again (within 30 seconds).
        verify_within(self.check_child_table, 30, 5)

        # Verify that number of state changes on all children stays as before (indicating they did not get detached).
        for i in range(len(self.all_children)):
            verify(child_num_state_changes[i] == len(
                wpan_table_parser.parse_list(self.all_children[i].get(
                    "stat:ncp"))))
    def check_child_is_reattached(self):
        child_stat_ncp_changes = len(
            wpan_table_parser.parse_list(self.child1.get("stat:ncp")))
        print child_stat_ncp_changes

        verify(child_stat_ncp_changes > self.child_num_state_changes)

        verify(is_associated(self.child1))
Esempio n. 3
0
 def check_address_prefix_removed():
     # Verify that address is removed from r2
     verify(self.r2.find_ip6_address_with_prefix(IP6_PREFIX_1) == '')
     # Verify that the related prefix is also removed on all nodes
     for node in self.all_nodes:
         prefixes = wpan_table_parser.parse_on_mesh_prefix_result(
             node.get(wpan.WPAN_THREAD_ON_MESH_PREFIXES))
         for p in prefixes:
             verify(p.prefix != IP6_PREFIX_1)
    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)
    def test04_Verify_Add_Remove_Prefix(self):
        # Test `add-prefix` and `remove-prefix`

        self.r1.add_prefix(prefix4,
                           48,
                           priority="1",
                           stable=False,
                           on_mesh=True,
                           slaac=False,
                           dhcp=True,
                           configure=False,
                           default_route=True,
                           preferred=False)

        verify_prefix([self.r1],
                      prefix4,
                      48,
                      priority="high",
                      stable=False,
                      on_mesh=True,
                      slaac=False,
                      dhcp=True,
                      configure=False,
                      default_route=True,
                      preferred=False)

        # Remove prefix and verify that it is removed from list
        self.r1.remove_prefix(prefix4, 48)
        time.sleep(0.5)
        verify(
            self.r1.get(wpan.WPAN_THREAD_ON_MESH_PREFIXES).find(prefix4) < 0)

        self.r1.add_prefix(prefix4,
                           48,
                           priority="-1",
                           stable=True,
                           on_mesh=False,
                           slaac=True,
                           dhcp=False,
                           configure=True,
                           default_route=False,
                           preferred=True)

        verify_prefix([self.r1],
                      prefix4,
                      48,
                      priority="low",
                      stable=True,
                      on_mesh=False,
                      slaac=True,
                      dhcp=False,
                      configure=True,
                      default_route=False,
                      preferred=True)
Esempio n. 6
0
    def test03_Add_Mutilcast_Address(self):

        for node in self.device_list:
            node.add(wpan.WPAN_IP6_MULTICAST_ADDRESSES, MCAST_ADDR)
            addrs = wpan_table_parser.parse_list(
                node.get(wpan.WPAN_IP6_MULTICAST_ADDRESSES))
            verify(MCAST_ADDR in addrs)

            node.remove(wpan.WPAN_IP6_MULTICAST_ADDRESSES, MCAST_ADDR)
            addrs = wpan_table_parser.parse_list(
                node.get(wpan.WPAN_IP6_MULTICAST_ADDRESSES))
            verify(not MCAST_ADDR in addrs)
    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)
Esempio n. 8
0
    def test02_Verify_Child_Mode(self):
        # Disable child supervision on all devices
        self.parent.set(wpan.WPAN_CHILD_SUPERVISION_INTERVAL, '0')
        self.child1.set(wpan.WPAN_CHILD_SUPERVISION_CHECK_TIMEOUT, '0')
        self.child2.set(wpan.WPAN_CHILD_SUPERVISION_CHECK_TIMEOUT, '0')

        # Verify Thread Device Mode on both children
        verify(
            int(self.child1.get(wpan.WPAN_THREAD_DEVICE_MODE), 0) ==
            DEVICE_MODE_END_DEVICE)
        verify(
            int(self.child2.get(wpan.WPAN_THREAD_DEVICE_MODE), 0) ==
            DEVICE_MODE_SLEEPY_END_DEVICE)

        verify_within(self.check_child_table, WAIT_INTERVAL)
    def find_string_in_log_file(self):
        filename = os.path.join(self.current_output_directory, 'src.log')

        cmd = 'grep ' + '"' + self.child_supervision_msg + '" ' + filename
        ret = subprocess.check_output(cmd, shell=True)
        print ret
        return verify(self.child_supervision_msg in ret)
Esempio n. 10
0
    def test04_Verify_Child_Mode_Change(self):

        # Change mode on both children (make child1 sleepy, and child2 non-sleepy)
        self.child1.set(wpan.WPAN_THREAD_DEVICE_MODE,
                        str(DEVICE_MODE_SLEEPY_END_DEVICE))
        verify(
            int(self.child1.get(wpan.WPAN_THREAD_DEVICE_MODE), 0) ==
            DEVICE_MODE_SLEEPY_END_DEVICE)

        self.child2.set(wpan.WPAN_THREAD_DEVICE_MODE,
                        str(DEVICE_MODE_END_DEVICE))
        verify(
            int(self.child2.get(wpan.WPAN_THREAD_DEVICE_MODE), 0) ==
            DEVICE_MODE_END_DEVICE)

        # Verify that the child table on parent is also updated
        verify_within(self.check_child_table, WAIT_INTERVAL)
Esempio n. 11
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))
 def check_child_is_removed_from_parent2_table(self):
     child_table = wpan_table_parser.parse_list(
         self.parent2.get(wpan.WPAN_THREAD_CHILD_TABLE))
     verify(len(child_table) == 0)
Esempio n. 13
0
    def check_addresses_and_prefixes(self):
        # Verify that the addresses are present in "IPv6:AllAddresses" wpantund property on the corresponding node.
        verify(
            self.r2.find_ip6_address_with_prefix(IP6_PREFIX_1) == IP6_ADDR_1)
        verify(
            self.fed1.find_ip6_address_with_prefix(IP6_PREFIX_2) == IP6_ADDR_2)
        verify(
            self.sed2.find_ip6_address_with_prefix(IP6_PREFIX_3) == IP6_ADDR_3)

        for node in self.all_nodes:
            node_on_mesh_prefixes = node.get(wpan.WPAN_THREAD_ON_MESH_PREFIXES)
            print node
            print node_on_mesh_prefixes

        print '#' * 30
        # Verify that all prefixes are present in network data on all nodes (with correct flags).
        for prefix in [IP6_PREFIX_1, IP6_PREFIX_2, IP6_PREFIX_3]:
            for node in self.all_nodes:
                node_on_mesh_prefixes = node.get(
                    wpan.WPAN_THREAD_ON_MESH_PREFIXES)
                print node_on_mesh_prefixes
                prefixes = wpan_table_parser.parse_on_mesh_prefix_result(
                    node_on_mesh_prefixes)
                print prefixes
                for p in prefixes:
                    if p.prefix == prefix:
                        verify(p.prefix_len == '64')
                        verify(p.is_stable())
                        verify(p.is_on_mesh() == True)
                        verify(p.is_preferred() == True)
                        verify(p.is_def_route() == False)
                        verify(p.is_slaac() == False)
                        verify(p.is_dhcp() == False)
                        verify(p.is_config() == False)
                        verify(p.priority == "med")
                        break
                else:  # `for` loop finished without finding the prefix.
                    raise wpan_util.VerifyError(
                        'Did not find prefix {} on node {}'.format(
                            prefix, node))

        # Verify that IPv6 address of `sed2` is present on `r2` (its parent) "Thread:ChildTable:Addresses".
        addr_str = self.r2.get(wpan.WPAN_THREAD_CHILD_TABLE_ADDRESSES)
        # search for index on address in the `addr_str` and ensure it is non-negative.
        verify(addr_str.find(IP6_ADDR_3) >= 0)
Esempio n. 14
0
 def check_r4_router_table():
     router_table = wpan_table_parser.parse_router_table_result(self.r4.get(wpan.WPAN_THREAD_ROUTER_TABLE))
     verify(len(router_table) == 4)
     for entry in router_table:
         if entry.rloc16 == r1_rloc:
             # r4's next hop towards r1 should be through r3.
             verify(not entry.is_link_established())
             verify(entry.next_hop == r3_id)
         elif entry.rloc16 == r2_rloc:
             # r4's next hop towards r2 should be through r3.
             verify(not entry.is_link_established())
             verify(entry.next_hop == r3_id)
         elif entry.rloc16 == r3_rloc:
             # r4 should be directly connected to r3.
             verify(entry.is_link_established())
             verify(entry.ext_address == r3_ext_addr)
         elif entry.rloc16 == r4_rloc:
             pass
         else:
             raise (VerifyError("unknown entry in the router table of r4"))
Esempio n. 15
0
 def check_r3_router_table():
     router_table = wpan_table_parser.parse_router_table_result(self.r3.get(wpan.WPAN_THREAD_ROUTER_TABLE))
     verify(len(router_table) == 4)
     for entry in router_table:
         if entry.rloc16 == r1_rloc:
             # r3 should be directly connected to r1.
             verify(entry.is_link_established())
             verify(entry.ext_address == r1_ext_addr)
         elif entry.rloc16 == r2_rloc:
             # r3 should be directly connected to r2.
             verify(entry.is_link_established())
             verify(entry.ext_address == r2_ext_addr)
         elif entry.rloc16 == r3_rloc:
             pass
         elif entry.rloc16 == r4_rloc:
             # r3 should be directly connected to r4.
             verify(entry.is_link_established())
             verify(entry.ext_address == r4_ext_addr)
         else:
             raise (VerifyError("unknown entry in the router table of r3"))
Esempio n. 16
0
 def test02_Verify_Node_Type(self):
     verify(self.r1.get(wpan.WPAN_NODE_TYPE) == wpan.NODE_TYPE_LEADER)
     verify(self.r2.get(wpan.WPAN_NODE_TYPE) == wpan.NODE_TYPE_ROUTER)
     verify(self.r3.get(wpan.WPAN_NODE_TYPE) == wpan.NODE_TYPE_ROUTER)
     verify(self.r4.get(wpan.WPAN_NODE_TYPE) == wpan.NODE_TYPE_ROUTER)
Esempio n. 17
0
    def check_multicast_addresses(self, node, mcast_addr_list):
        addrs = wpan_table_parser.parse_list(
            node.get(wpan.WPAN_IP6_MULTICAST_ADDRESSES))

        for addr in mcast_addr_list:
            verify(addr in addrs)
Esempio n. 18
0
 def check_empty_prefix_list():
     for node in [self.r1, self.r2]:
         prefixes = wpan_table_parser.parse_on_mesh_prefix_result(
             node.get(wpan.WPAN_THREAD_ON_MESH_PREFIXES))
         print len(prefixes), prefixes_len_before_remove[node]
         verify(len(prefixes) == prefixes_len_before_remove[node] - 3)
 def check_parent_is_associated():
     verify(is_associated(self.router))