コード例 #1
0
    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"))))
コード例 #2
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)
コード例 #3
0
    def test03_Change_Parent(self):
        # Remove the `child` from whitelist of `parent2` and add it to whitelist of `parent1` instead.
        self.child_num_state_changes = len(
            wpan_table_parser.parse_list(self.child1.get("stat:ncp")))

        print self.child_num_state_changes

        self.parent1.whitelist_node(self.child1)
        self.parent2.un_whitelist_node(self.child1)

        # Enable supervision check on the `child` and also on `parent1`.

        self.child1.setprop(wpan.WPAN_CHILD_SUPERVISION_CHECK_TIMEOUT,
                            str(CHILD_SUPERVISION_CHECK_TIMEOUT))
        self.parent1.setprop(wpan.WPAN_CHILD_SUPERVISION_INTERVAL,
                             str(PARENT_SUPERVISION_INTERVAL))

        # Since child supervision is not enabled on `parent2` and the `child` is
        # removed from whitelist on `parent2`, after the supervision check timeout
        # the `child` should realize that it can no longer talk to its current
        # parent (`parent2`) and try to reattach. All re-attach attempts to `parent2`
        # should fail (due to whitelist) and cause the `child` to get detached and
        # search for a new parent and then attach to `parent1`.
        #
        # To verify that the `child` does get detached and attach to a new parent, we
        # monitor the number of state changes using wpantund property "stat:ncp".

        verify_within(self.check_child_is_reattached, 60, 5)
コード例 #4
0
    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))
コード例 #5
0
 def find_ip6_address_with_prefix(self, prefix):
     """Find an IPv6 address on node matching a given prefix.
        `prefix` should be an string containing the prefix.
        Returns a string containing the IPv6 address matching the prefix or empty string if no address found.
     """
     if len(prefix) > 2 and prefix[-1] == ':' and prefix[-2] == ':':
         prefix = prefix[:-1]
     all_addrs = wpan_table_parser.parse_list(
         self.get(wpan.WPAN_IP6_ALL_ADDRESSES))
     matched_addr = [addr for addr in all_addrs if addr.startswith(prefix)]
     return matched_addr[0] if len(matched_addr) >= 1 else ''
コード例 #6
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)
コード例 #7
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)