mirror of
https://github.com/espressif/openthread.git
synced 2026-07-28 22:57:47 +00:00
Initial commit
This commit is contained in:
+68
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
|
||||
class Cert_5_1_01_RouterAttach(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(7)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
ED = 3
|
||||
SED = 4
|
||||
|
||||
class Cert_5_1_02_ChildAddressTimeout(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[SED].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].set_timeout(3)
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
self.nodes[SED].set_panid(0xface)
|
||||
self.nodes[SED].set_mode('sn')
|
||||
self.nodes[SED].set_timeout(3)
|
||||
self.nodes[SED].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[SED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
self.nodes[SED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[SED].get_state(), 'child')
|
||||
|
||||
ed_addrs = self.nodes[ED].get_addrs()
|
||||
sed_addrs = self.nodes[SED].get_addrs()
|
||||
|
||||
self.nodes[ED].stop()
|
||||
time.sleep(5)
|
||||
for addr in ed_addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
try:
|
||||
self.nodes[LEADER].ping(addr)
|
||||
self.assertFalse()
|
||||
except pexpect.TIMEOUT:
|
||||
pass
|
||||
|
||||
self.nodes[SED].stop()
|
||||
time.sleep(5)
|
||||
for addr in sed_addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
try:
|
||||
self.nodes[LEADER].ping(addr)
|
||||
self.assertFalse()
|
||||
except pexpect.TIMEOUT:
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
|
||||
class Cert_5_1_03_RouterAddressReallocation(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,4):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
rloc16 = self.nodes[ROUTER1].get_addr16()
|
||||
|
||||
self.nodes[ROUTER2].set_network_id_timeout(110)
|
||||
self.nodes[LEADER].stop()
|
||||
time.sleep(130)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'leader')
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
self.assertEqual(self.nodes[ROUTER1].get_addr16(), rloc16)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
|
||||
class Cert_5_1_04_RouterAddressReallocation(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,4):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
rloc16 = self.nodes[ROUTER1].get_addr16()
|
||||
|
||||
self.nodes[ROUTER2].set_network_id_timeout(200)
|
||||
self.nodes[LEADER].stop()
|
||||
time.sleep(210)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'leader')
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
self.assertEqual(self.nodes[ROUTER1].get_addr16(), rloc16)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
|
||||
class Cert_5_1_05_RouterAddressTimeout(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
rloc16 = self.nodes[ROUTER1].get_addr16()
|
||||
|
||||
self.nodes[ROUTER1].stop()
|
||||
time.sleep(200)
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
self.assertNotEqual(self.nodes[ROUTER1].get_addr16(), rloc16)
|
||||
|
||||
rloc16 = self.nodes[ROUTER1].get_addr16()
|
||||
|
||||
self.nodes[ROUTER1].stop()
|
||||
time.sleep(300)
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
self.assertEqual(self.nodes[ROUTER1].get_addr16(), rloc16)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
|
||||
class Cert_5_1_06_RemoveRouterId(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
rloc16 = self.nodes[ROUTER1].get_addr16()
|
||||
|
||||
for addr in self.nodes[ROUTER1].get_addrs():
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
self.nodes[LEADER].release_router_id(rloc16 >> 10)
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
for addr in self.nodes[ROUTER1].get_addrs():
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
ED = 3
|
||||
|
||||
class Cert_5_1_07_MaxChildCount(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,9):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
for i in range(4, 9):
|
||||
self.nodes[i].set_panid(0xface)
|
||||
self.nodes[i].set_mode('rsn')
|
||||
self.nodes[i].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[i].get_addr64())
|
||||
self.nodes[i].enable_whitelist()
|
||||
self.nodes[i].set_timeout(3)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
for i in range(4, 9):
|
||||
self.nodes[i].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[i].get_state(), 'child')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'detached')
|
||||
|
||||
self.nodes[ED].stop()
|
||||
for i in range(4, 9):
|
||||
self.nodes[i].stop()
|
||||
time.sleep(3)
|
||||
|
||||
self.nodes[LEADER].stop()
|
||||
time.sleep(100)
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'detached')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
ROUTER3 = 4
|
||||
ROUTER4 = 5
|
||||
|
||||
class Cert_5_1_08_RouterAttachConnectivity(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,6):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER4].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER3].set_panid(0xface)
|
||||
self.nodes[ROUTER3].set_mode('rsdn')
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER4].get_addr64())
|
||||
self.nodes[ROUTER3].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER4].set_panid(0xface)
|
||||
self.nodes[ROUTER4].set_mode('rsdn')
|
||||
self.nodes[ROUTER4].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER4].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ROUTER4].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
for i in range(2, 6):
|
||||
self.nodes[i].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[i].get_state(), 'router')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
REED0 = 3
|
||||
REED1 = 4
|
||||
ROUTER2 = 5
|
||||
|
||||
class Cert_5_1_09_REEDAttachConnectivity(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,6):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[REED0].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[REED1].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[REED1].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[REED0].set_panid(0xface)
|
||||
self.nodes[REED0].set_mode('rsdn')
|
||||
self.nodes[REED0].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[REED0].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[REED0].set_router_upgrade_threshold(0)
|
||||
self.nodes[REED0].enable_whitelist()
|
||||
|
||||
self.nodes[REED1].set_panid(0xface)
|
||||
self.nodes[REED1].set_mode('rsdn')
|
||||
self.nodes[REED1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[REED1].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[REED1].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[REED1].set_router_upgrade_threshold(0)
|
||||
self.nodes[REED1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[REED0].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[REED1].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[REED0].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[REED0].get_state(), 'child')
|
||||
|
||||
self.nodes[REED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[REED1].get_state(), 'child')
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(10)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
self.assertEqual(self.nodes[REED1].get_state(), 'router')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
ROUTER3 = 4
|
||||
|
||||
class Cert_5_1_10_RouterAttachLinkQuality(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER3].get_addr64(), rssi=-85)
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER3].set_panid(0xface)
|
||||
self.nodes[ROUTER3].set_mode('rsdn')
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER2].get_addr64(), rssi=-85)
|
||||
self.nodes[ROUTER3].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER3].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER3].get_state(), 'router')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
REED = 2
|
||||
ROUTER2 = 3
|
||||
ROUTER1 = 4
|
||||
|
||||
class Cert_5_1_11_REEDAttachLinkQuality(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[REED].set_panid(0xface)
|
||||
self.nodes[REED].set_mode('rsdn')
|
||||
self.nodes[REED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[REED].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[REED].set_router_upgrade_threshold(0)
|
||||
self.nodes[REED].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER1].get_addr64(), rssi=-85)
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER2].get_addr64(), rssi=-85)
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[REED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[REED].get_state(), 'child')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(10)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
self.assertEqual(self.nodes[REED].get_state(), 'router')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
|
||||
class Cert_5_1_12_NewRouterSync(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,4):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
|
||||
class Cert_5_1_13_RouterReset(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
rloc16 = self.nodes[ROUTER].get_addr16()
|
||||
|
||||
self.nodes[ROUTER].stop();
|
||||
time.sleep(3)
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
self.assertEqual(self.nodes[ROUTER].get_addr16(), rloc16)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
REED = 3
|
||||
|
||||
class Cert_5_2_1_BecomeActiveRouter(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,4):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[REED].set_panid(0xface)
|
||||
self.nodes[REED].set_mode('rsdn')
|
||||
self.nodes[REED].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[REED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[REED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[REED].get_state(), 'router')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
DUT = 33
|
||||
|
||||
class Cert_5_2_2_LeaderReject1Hop(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
|
||||
self.nodes[LEADER] = node.Node(LEADER)
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
for i in range(2,34):
|
||||
self.nodes[i] = node.Node(i)
|
||||
self.nodes[i].set_panid(0xface)
|
||||
self.nodes[i].set_mode('rsdn')
|
||||
self.nodes[i].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[i].get_addr64())
|
||||
self.nodes[i].enable_whitelist()
|
||||
self.nodes[i].set_router_upgrade_threshold(33)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
for i in range(2, 33):
|
||||
self.nodes[i].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[i].get_state(), 'router')
|
||||
|
||||
self.nodes[DUT].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[DUT].get_state(), 'child')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
DUT = 33
|
||||
|
||||
class Cert_5_2_3_LeaderReject2Hops(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
|
||||
self.nodes[LEADER] = node.Node(LEADER)
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
for i in range(2,33):
|
||||
self.nodes[i] = node.Node(i)
|
||||
self.nodes[i].set_panid(0xface)
|
||||
self.nodes[i].set_mode('rsdn')
|
||||
self.nodes[i].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[i].get_addr64())
|
||||
self.nodes[i].enable_whitelist()
|
||||
self.nodes[i].set_router_upgrade_threshold(33)
|
||||
|
||||
self.nodes[DUT] = node.Node(DUT)
|
||||
self.nodes[DUT].set_panid(0xface)
|
||||
self.nodes[DUT].set_mode('rsdn')
|
||||
self.nodes[DUT].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[DUT].get_addr64())
|
||||
self.nodes[DUT].enable_whitelist()
|
||||
self.nodes[DUT].set_router_upgrade_threshold(33)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
for i in range(2, 33):
|
||||
self.nodes[i].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[i].get_state(), 'router')
|
||||
|
||||
self.nodes[DUT].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[DUT].get_state(), 'child')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 16
|
||||
REED = 17
|
||||
ED = 18
|
||||
|
||||
class Cert_5_2_4_REEDUpgrade(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,19):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
for i in range(2,17):
|
||||
self.nodes[i].set_panid(0xface)
|
||||
self.nodes[i].set_mode('rsdn')
|
||||
self.nodes[i].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[i].get_addr64())
|
||||
self.nodes[i].enable_whitelist()
|
||||
|
||||
self.nodes[REED].set_panid(0xface)
|
||||
self.nodes[REED].set_mode('rsdn')
|
||||
self.nodes[REED].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[REED].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[REED].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsdn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
for i in range(2, 17):
|
||||
self.nodes[i].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[i].get_state(), 'router')
|
||||
|
||||
self.nodes[REED].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[REED].get_state(), 'child')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
self.assertEqual(self.nodes[REED].get_state(), 'router')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
ED1 = 1
|
||||
BR1 = 2
|
||||
LEADER = 3
|
||||
ROUTER2 = 4
|
||||
REED = 5
|
||||
ED2 = 6
|
||||
ED3 = 7
|
||||
|
||||
class Cert_5_2_5_AddressQuery(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,8):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[BR1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[BR1].set_panid(0xface)
|
||||
self.nodes[BR1].set_mode('rsdn')
|
||||
self.nodes[BR1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[BR1].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
self.nodes[BR1].enable_whitelist()
|
||||
|
||||
self.nodes[ED1].set_panid(0xface)
|
||||
self.nodes[ED1].set_mode('rsn')
|
||||
self.nodes[ED1].add_whitelist(self.nodes[BR1].get_addr64())
|
||||
self.nodes[ED1].enable_whitelist()
|
||||
|
||||
self.nodes[REED].set_panid(0xface)
|
||||
self.nodes[REED].set_mode('rsdn')
|
||||
self.nodes[REED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[REED].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[REED].set_router_upgrade_threshold(0)
|
||||
self.nodes[REED].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ED2].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ED3].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ED2].set_panid(0xface)
|
||||
self.nodes[ED2].set_mode('rsn')
|
||||
self.nodes[ED2].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ED2].enable_whitelist()
|
||||
|
||||
self.nodes[ED3].set_panid(0xface)
|
||||
self.nodes[ED3].set_mode('rsn')
|
||||
self.nodes[ED3].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ED3].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[BR1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[BR1].get_state(), 'router')
|
||||
|
||||
self.nodes[BR1].add_prefix('2003::/64', 'pvcrs')
|
||||
self.nodes[BR1].add_prefix('2004::/64', 'pvcrs')
|
||||
self.nodes[BR1].register_netdata()
|
||||
|
||||
self.nodes[ED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED1].get_state(), 'child')
|
||||
|
||||
self.nodes[REED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[REED].get_state(), 'child')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ED2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED2].get_state(), 'child')
|
||||
|
||||
self.nodes[ED3].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED3].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[REED].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[ED2].ping(addr)
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
REED = 3
|
||||
ROUTER2 = 4
|
||||
ROUTER3 = 5
|
||||
|
||||
class Cert_5_2_7_REEDSynchronization(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,6):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[REED].set_panid(0xface)
|
||||
self.nodes[REED].set_mode('rsdn')
|
||||
self.nodes[REED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[REED].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[REED].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[REED].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[REED].enable_whitelist()
|
||||
self.nodes[REED].set_router_upgrade_threshold(0)
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER3].set_panid(0xface)
|
||||
self.nodes[ROUTER3].set_mode('rsdn')
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER3].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[REED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[REED].get_state(), 'child')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER3].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER3].get_state(), 'router')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
|
||||
class Cert_5_3_1_LinkLocal(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
addrs = self.nodes[ROUTER1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == 'fe80':
|
||||
self.nodes[LEADER].ping(addr, size=256)
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
self.nodes[LEADER].ping('ff02::1', size=256)
|
||||
self.nodes[LEADER].ping('ff02::1')
|
||||
|
||||
self.nodes[LEADER].ping('ff02::2', size=256)
|
||||
self.nodes[LEADER].ping('ff02::2')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
SED1 = 4
|
||||
|
||||
class Cert_5_3_2_RealmLocal(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[SED1].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[SED1].set_panid(0xface)
|
||||
self.nodes[SED1].set_mode('sn')
|
||||
self.nodes[SED1].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[SED1].enable_whitelist()
|
||||
self.nodes[SED1].set_timeout(3)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[SED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[SED1].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[ROUTER2].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[LEADER].ping(addr, size=256)
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
self.nodes[LEADER].ping('ff03::1', size=256)
|
||||
self.nodes[LEADER].ping('ff03::1')
|
||||
|
||||
self.nodes[LEADER].ping('ff03::2', size=256)
|
||||
self.nodes[LEADER].ping('ff03::2')
|
||||
|
||||
self.nodes[LEADER].ping('ff33:0040:fdde:ad00:beef:0:0:1', size=256)
|
||||
self.nodes[LEADER].ping('ff33:0040:fdde:ad00:beef:0:0:1')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
BR = 1
|
||||
LEADER = 2
|
||||
ROUTER2 = 3
|
||||
ROUTER3 = 4
|
||||
ED2 = 5
|
||||
|
||||
class Cert_5_3_3_AddressQuery(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,6):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[BR].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[BR].set_panid(0xface)
|
||||
self.nodes[BR].set_mode('rsdn')
|
||||
self.nodes[BR].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[BR].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ED2].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER3].set_panid(0xface)
|
||||
self.nodes[ROUTER3].set_mode('rsdn')
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER3].enable_whitelist()
|
||||
|
||||
self.nodes[ED2].set_panid(0xface)
|
||||
self.nodes[ED2].set_mode('rsn')
|
||||
self.nodes[ED2].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ED2].set_timeout(3)
|
||||
self.nodes[ED2].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[BR].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[BR].get_state(), 'router')
|
||||
|
||||
self.nodes[BR].add_prefix('2003::/64', 'pvcrs')
|
||||
self.nodes[BR].add_prefix('2004::/64', 'pvcrs')
|
||||
self.nodes[BR].register_netdata()
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER3].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER3].get_state(), 'router')
|
||||
|
||||
self.nodes[ED2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED2].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[ROUTER3].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[ED2].ping(addr)
|
||||
time.sleep(1)
|
||||
|
||||
addrs = self.nodes[ED2].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
time.sleep(1)
|
||||
|
||||
addrs = self.nodes[BR].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[ED2].ping(addr)
|
||||
time.sleep(1)
|
||||
|
||||
addrs = self.nodes[ROUTER3].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[ED2].ping(addr)
|
||||
time.sleep(1)
|
||||
|
||||
addrs = self.nodes[ROUTER3].get_addrs()
|
||||
self.nodes[ROUTER3].stop()
|
||||
time.sleep(130)
|
||||
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
try:
|
||||
self.nodes[ED2].ping(addr)
|
||||
self.assertFalse()
|
||||
except pexpect.TIMEOUT:
|
||||
pass
|
||||
|
||||
addrs = self.nodes[ED2].get_addrs()
|
||||
self.nodes[ED2].stop()
|
||||
time.sleep(10)
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
try:
|
||||
self.nodes[BR].ping(addr)
|
||||
self.assertFalse()
|
||||
except pexpect.TIMEOUT:
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
SED1 = 3
|
||||
ED2 = 4
|
||||
ED3 = 5
|
||||
ED4 = 6
|
||||
ED5 = 7
|
||||
|
||||
class Cert_5_3_4_AddressMapCache(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,8):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED2].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED3].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED4].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED5].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[SED1].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[SED1].set_panid(0xface)
|
||||
self.nodes[SED1].set_mode('rsn')
|
||||
self.nodes[SED1].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[SED1].enable_whitelist()
|
||||
|
||||
self.nodes[ED2].set_panid(0xface)
|
||||
self.nodes[ED2].set_mode('rsn')
|
||||
self.nodes[ED2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED2].enable_whitelist()
|
||||
|
||||
self.nodes[ED3].set_panid(0xface)
|
||||
self.nodes[ED3].set_mode('rsn')
|
||||
self.nodes[ED3].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED3].enable_whitelist()
|
||||
|
||||
self.nodes[ED4].set_panid(0xface)
|
||||
self.nodes[ED4].set_mode('rsn')
|
||||
self.nodes[ED4].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED4].enable_whitelist()
|
||||
|
||||
self.nodes[ED5].set_panid(0xface)
|
||||
self.nodes[ED5].set_mode('rsn')
|
||||
self.nodes[ED5].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED5].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[SED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[SED1].get_state(), 'child')
|
||||
|
||||
self.nodes[ED2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED2].get_state(), 'child')
|
||||
|
||||
self.nodes[ED3].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED3].get_state(), 'child')
|
||||
|
||||
self.nodes[ED4].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED4].get_state(), 'child')
|
||||
|
||||
self.nodes[ED5].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED5].get_state(), 'child')
|
||||
|
||||
for i in range(4, 8):
|
||||
addrs = self.nodes[i].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[SED1].ping(addr)
|
||||
|
||||
for i in range(4, 8):
|
||||
addrs = self.nodes[i].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[SED1].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
ROUTER3 = 4
|
||||
|
||||
class Cert_5_3_5_RoutingLinkQuality(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER3].set_panid(0xface)
|
||||
self.nodes[ROUTER3].set_mode('rsdn')
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER3].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER3].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER3].get_state(), 'router')
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
addrs = self.nodes[ROUTER3].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64(), rssi=-95)
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64(), rssi=-95)
|
||||
|
||||
time.sleep(70)
|
||||
|
||||
addrs = self.nodes[ROUTER3].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64(), rssi=-85)
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64(), rssi=-85)
|
||||
|
||||
time.sleep(70)
|
||||
|
||||
addrs = self.nodes[ROUTER3].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64(), rssi=-100)
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64(), rssi=-100)
|
||||
|
||||
time.sleep(70)
|
||||
|
||||
addrs = self.nodes[ROUTER3].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
|
||||
class Cert_5_3_6_RouterIdMask(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,4):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].stop()
|
||||
|
||||
time.sleep(300)
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER1].stop()
|
||||
|
||||
time.sleep(300)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
ED1 = 4
|
||||
ED2 = 5
|
||||
ED3 = 6
|
||||
|
||||
class Cert_5_3_7_DuplicateAddress(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,7):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED3].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ED2].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ED1].set_panid(0xface)
|
||||
self.nodes[ED1].set_mode('rsn')
|
||||
self.nodes[ED1].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ED1].enable_whitelist()
|
||||
|
||||
self.nodes[ED2].set_panid(0xface)
|
||||
self.nodes[ED2].set_mode('rsn')
|
||||
self.nodes[ED2].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ED2].enable_whitelist()
|
||||
|
||||
self.nodes[ED3].set_panid(0xface)
|
||||
self.nodes[ED3].set_mode('rsn')
|
||||
self.nodes[ED3].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED3].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED1].get_state(), 'child')
|
||||
|
||||
self.nodes[ED2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED2].get_state(), 'child')
|
||||
|
||||
self.nodes[ED3].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED3].get_state(), 'child')
|
||||
|
||||
self.nodes[ROUTER2].add_prefix('2001::/64', 'pvcrs')
|
||||
self.nodes[ROUTER2].register_netdata()
|
||||
|
||||
self.nodes[ED1].add_ipaddr('2001::1')
|
||||
self.nodes[ED2].add_ipaddr('2001::1')
|
||||
time.sleep(3)
|
||||
|
||||
self.nodes[ED3].ping('2001::1')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ED1 = 2
|
||||
ED2 = 3
|
||||
ED3 = 4
|
||||
ED4 = 5
|
||||
|
||||
class Cert_5_3_8_ChildAddressSet(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,6):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED2].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED3].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED4].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ED1].set_panid(0xface)
|
||||
self.nodes[ED1].set_mode('rsn')
|
||||
self.nodes[ED1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED1].enable_whitelist()
|
||||
|
||||
self.nodes[ED2].set_panid(0xface)
|
||||
self.nodes[ED2].set_mode('rsn')
|
||||
self.nodes[ED2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED2].enable_whitelist()
|
||||
|
||||
self.nodes[ED3].set_panid(0xface)
|
||||
self.nodes[ED3].set_mode('rsn')
|
||||
self.nodes[ED3].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED3].enable_whitelist()
|
||||
|
||||
self.nodes[ED4].set_panid(0xface)
|
||||
self.nodes[ED4].set_mode('rsn')
|
||||
self.nodes[ED4].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED4].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED1].get_state(), 'child')
|
||||
|
||||
self.nodes[ED2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED2].get_state(), 'child')
|
||||
|
||||
self.nodes[ED3].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED3].get_state(), 'child')
|
||||
|
||||
self.nodes[ED4].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED4].get_state(), 'child')
|
||||
|
||||
for i in range(2,6):
|
||||
addrs = self.nodes[i].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
BR = 2
|
||||
ROUTER2 = 3
|
||||
ROUTER3 = 4
|
||||
SED2 = 5
|
||||
|
||||
class Cert_5_3_9_AddressQuery(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,6):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[BR].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[BR].set_panid(0xface)
|
||||
self.nodes[BR].set_mode('rsdn')
|
||||
self.nodes[BR].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[BR].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[SED2].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER3].set_panid(0xface)
|
||||
self.nodes[ROUTER3].set_mode('rsdn')
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER3].enable_whitelist()
|
||||
|
||||
self.nodes[SED2].set_panid(0xface)
|
||||
self.nodes[SED2].set_mode('sn')
|
||||
self.nodes[SED2].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[SED2].set_timeout(3)
|
||||
self.nodes[SED2].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[BR].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[BR].get_state(), 'router')
|
||||
|
||||
self.nodes[BR].add_prefix('2003::/64', 'pvcrs')
|
||||
self.nodes[BR].add_prefix('2004::/64', 'pvcrs')
|
||||
self.nodes[BR].register_netdata()
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER3].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER3].get_state(), 'router')
|
||||
|
||||
self.nodes[SED2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[SED2].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[ROUTER3].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[SED2].ping(addr)
|
||||
|
||||
addrs = self.nodes[SED2].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[BR].ping(addr)
|
||||
|
||||
addrs = self.nodes[ROUTER3].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[SED2].ping(addr)
|
||||
|
||||
self.nodes[ROUTER3].stop()
|
||||
time.sleep(300)
|
||||
|
||||
addrs = self.nodes[ROUTER3].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
try:
|
||||
self.nodes[SED2].ping(addr)
|
||||
self.assertFalse()
|
||||
except pexpect.TIMEOUT:
|
||||
pass
|
||||
|
||||
self.nodes[SED2].stop()
|
||||
time.sleep(10)
|
||||
|
||||
addrs = self.nodes[SED2].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
try:
|
||||
self.nodes[BR].ping(addr)
|
||||
self.assertFalse()
|
||||
except pexpect.TIMEOUT:
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
|
||||
class Cert_5_5_1_LeaderReset(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
rloc16 = self.nodes[LEADER].get_addr16()
|
||||
|
||||
self.nodes[LEADER].stop();
|
||||
time.sleep(3)
|
||||
|
||||
self.nodes[LEADER].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_addr16(), rloc16)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
ED = 3
|
||||
|
||||
class Cert_5_5_2_LeaderReboot(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,4):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
self.nodes[LEADER].stop()
|
||||
time.sleep(130)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'leader')
|
||||
|
||||
self.nodes[LEADER].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'router')
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
for addr in addrs:
|
||||
self.nodes[ROUTER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
ED1 = 4
|
||||
ED2 = 5
|
||||
ED3 = 6
|
||||
|
||||
class Cert_5_5_3_SplitMergeChildren(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,7):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ED2].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ED3].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ED1].set_panid(0xface)
|
||||
self.nodes[ED1].set_mode('rsn')
|
||||
self.nodes[ED1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED1].enable_whitelist()
|
||||
|
||||
self.nodes[ED2].set_panid(0xface)
|
||||
self.nodes[ED2].set_mode('rsn')
|
||||
self.nodes[ED2].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ED2].enable_whitelist()
|
||||
|
||||
self.nodes[ED3].set_panid(0xface)
|
||||
self.nodes[ED3].set_mode('rsn')
|
||||
self.nodes[ED3].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ED3].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED1].get_state(), 'child')
|
||||
|
||||
self.nodes[ED2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED2].get_state(), 'child')
|
||||
|
||||
self.nodes[ED3].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED3].get_state(), 'child')
|
||||
|
||||
self.nodes[LEADER].stop()
|
||||
|
||||
self.nodes[ED1].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
|
||||
time.sleep(130)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'leader')
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'leader')
|
||||
|
||||
self.nodes[LEADER].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'router')
|
||||
|
||||
time.sleep(30)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[ROUTER2].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER1 = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
ROUTER3 = 4
|
||||
ROUTER4 = 5
|
||||
ED1 = 6
|
||||
|
||||
class Cert_5_5_4_SplitMergeRouters(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,7):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER1].set_panid(0xface)
|
||||
self.nodes[LEADER1].set_mode('rsdn')
|
||||
self.nodes[LEADER1].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER1].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER1].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
self.nodes[LEADER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER1].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER1].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER4].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER3].set_panid(0xface)
|
||||
self.nodes[ROUTER3].set_mode('rsdn')
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER3].enable_whitelist()
|
||||
self.nodes[ROUTER3].set_network_id_timeout(110)
|
||||
|
||||
self.nodes[ROUTER4].set_panid(0xface)
|
||||
self.nodes[ROUTER4].set_mode('rsdn')
|
||||
self.nodes[ROUTER4].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER4].enable_whitelist()
|
||||
|
||||
self.nodes[ED1].set_panid(0xface)
|
||||
self.nodes[ED1].set_mode('rsn')
|
||||
self.nodes[ED1].add_whitelist(self.nodes[LEADER1].get_addr64())
|
||||
self.nodes[ED1].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER1].start()
|
||||
self.nodes[LEADER1].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER1].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER3].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER3].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER4].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER4].get_state(), 'router')
|
||||
|
||||
self.nodes[ED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED1].get_state(), 'child')
|
||||
|
||||
self.nodes[LEADER1].stop()
|
||||
|
||||
self.nodes[ED1].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
|
||||
time.sleep(130)
|
||||
#self.assertEqual(self.nodes[ROUTER3].get_state(), 'leader')
|
||||
#self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[LEADER1].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[LEADER1].get_state(), 'router')
|
||||
|
||||
time.sleep(60)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[ROUTER2].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER1 = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
ROUTER3 = 4
|
||||
REED2 = 5
|
||||
|
||||
class Cert_5_5_5_SplitMergeREED(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,6):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER1].set_panid(0xface)
|
||||
self.nodes[LEADER1].set_mode('rsdn')
|
||||
self.nodes[LEADER1].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER1].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[LEADER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[REED2].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER1].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[REED2].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER3].set_panid(0xface)
|
||||
self.nodes[ROUTER3].set_mode('rsdn')
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[LEADER1].get_addr64())
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER3].enable_whitelist()
|
||||
|
||||
self.nodes[REED2].set_panid(0xface)
|
||||
self.nodes[REED2].set_mode('rsdn')
|
||||
self.nodes[REED2].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[REED2].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[REED2].enable_whitelist()
|
||||
self.nodes[REED2].set_router_upgrade_threshold(0)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER1].start()
|
||||
self.nodes[LEADER1].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER1].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[REED2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[REED2].get_state(), 'child')
|
||||
|
||||
self.nodes[ROUTER3].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER3].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER3].stop()
|
||||
time.sleep(150)
|
||||
|
||||
self.assertEqual(self.nodes[REED2].get_state(), 'router')
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
addrs = self.nodes[LEADER1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[ROUTER1].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER1 = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
|
||||
class Cert_5_5_6_SplitWeight(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,4):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER1].set_panid(0xface)
|
||||
self.nodes[LEADER1].set_mode('rsdn')
|
||||
self.nodes[LEADER1].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER1].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER1].enable_whitelist()
|
||||
self.nodes[LEADER1].set_weight(2)
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER1].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
self.nodes[ROUTER1].set_weight(1)
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER1].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
self.nodes[ROUTER2].set_weight(0)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER1].start()
|
||||
self.nodes[LEADER1].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER1].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[LEADER1].stop()
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
time.sleep(140)
|
||||
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'leader')
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
addrs = self.nodes[ROUTER2].get_addrs()
|
||||
for addr in addrs:
|
||||
self.nodes[ROUTER1].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER1 = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
ROUTER3 = 4
|
||||
|
||||
class Cert_5_5_7_SplitMergeThreeWay(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER1].set_panid(0xface)
|
||||
self.nodes[LEADER1].set_mode('rsdn')
|
||||
self.nodes[LEADER1].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER1].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER1].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[LEADER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER1].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER1].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER3].set_panid(0xface)
|
||||
self.nodes[ROUTER3].set_mode('rsdn')
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[LEADER1].get_addr64())
|
||||
self.nodes[ROUTER3].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER1].start()
|
||||
self.nodes[LEADER1].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER1].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER3].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER3].get_state(), 'router')
|
||||
|
||||
self.nodes[LEADER1].stop()
|
||||
time.sleep(130)
|
||||
|
||||
self.nodes[LEADER1].start()
|
||||
time.sleep(30)
|
||||
|
||||
addrs = self.nodes[LEADER1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[ROUTER1].ping(addr)
|
||||
|
||||
addrs = self.nodes[ROUTER2].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[ROUTER1].ping(addr)
|
||||
|
||||
addrs = self.nodes[ROUTER3].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[ROUTER1].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER1 = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
ROUTER3 = 4
|
||||
ED1 = 5
|
||||
|
||||
class Cert_5_5_8_SplitRoutersLostLeader(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,6):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER1].set_panid(0xface)
|
||||
self.nodes[LEADER1].set_mode('rsdn')
|
||||
self.nodes[LEADER1].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[LEADER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER3].set_panid(0xface)
|
||||
self.nodes[ROUTER3].set_mode('rsdn')
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[LEADER1].get_addr64())
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER3].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ED1].set_panid(0xface)
|
||||
self.nodes[ED1].set_mode('rsn')
|
||||
self.nodes[ED1].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ED1].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER1].start()
|
||||
self.nodes[LEADER1].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER1].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER3].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER3].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED1].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[LEADER1].ping(addr)
|
||||
|
||||
self.nodes[ROUTER3].stop()
|
||||
time.sleep(130)
|
||||
|
||||
self.nodes[ROUTER3].start()
|
||||
time.sleep(60)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[LEADER1].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
ED1 = 3
|
||||
SED1 = 4
|
||||
|
||||
class Cert_5_6_1_NetworkDataLeaderAsBr(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[SED1].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[ED1].set_panid(0xface)
|
||||
self.nodes[ED1].set_mode('rsn')
|
||||
self.nodes[ED1].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ED1].enable_whitelist()
|
||||
|
||||
self.nodes[SED1].set_panid(0xface)
|
||||
self.nodes[SED1].set_mode('s')
|
||||
self.nodes[SED1].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[SED1].enable_whitelist()
|
||||
self.nodes[SED1].set_timeout(3)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[LEADER].add_prefix('2001::/64', 'pvcrs')
|
||||
self.nodes[LEADER].add_prefix('2002::/64', 'pvcr')
|
||||
self.nodes[LEADER].register_netdata()
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[ED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED1].get_state(), 'child')
|
||||
|
||||
self.nodes[SED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[SED1].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
addrs = self.nodes[SED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
ED1 = 3
|
||||
SED1 = 4
|
||||
|
||||
class Cert_5_6_2_NetworkDataRouterAsBr(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[SED1].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[ED1].set_panid(0xface)
|
||||
self.nodes[ED1].set_mode('rsn')
|
||||
self.nodes[ED1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED1].enable_whitelist()
|
||||
|
||||
self.nodes[SED1].set_panid(0xface)
|
||||
self.nodes[SED1].set_mode('s')
|
||||
self.nodes[SED1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[SED1].enable_whitelist()
|
||||
self.nodes[SED1].set_timeout(3)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER].add_prefix('2001::/64', 'pvcrs')
|
||||
self.nodes[ROUTER].add_prefix('2002::/64', 'pvcr')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
self.nodes[ED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED1].get_state(), 'child')
|
||||
|
||||
self.nodes[SED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[SED1].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
addrs = self.nodes[SED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
ED1 = 3
|
||||
SED1 = 4
|
||||
|
||||
class Cert_5_6_3_NetworkDataRegisterAfterAttachLeader(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[SED1].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[ED1].set_panid(0xface)
|
||||
self.nodes[ED1].set_mode('rsn')
|
||||
self.nodes[ED1].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ED1].enable_whitelist()
|
||||
|
||||
self.nodes[SED1].set_panid(0xface)
|
||||
self.nodes[SED1].set_mode('s')
|
||||
self.nodes[SED1].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[SED1].enable_whitelist()
|
||||
self.nodes[SED1].set_timeout(3)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[ED1].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[ED1].get_state(), 'child')
|
||||
|
||||
self.nodes[SED1].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[SED1].get_state(), 'child')
|
||||
|
||||
self.nodes[LEADER].add_prefix('2001::/64', 'pvcrs')
|
||||
self.nodes[LEADER].add_prefix('2002::/64', 'pvcr')
|
||||
self.nodes[LEADER].register_netdata()
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
addrs = self.nodes[SED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
ED1 = 3
|
||||
SED1 = 4
|
||||
|
||||
class Cert_5_6_4_NetworkDataRegisterAfterAttachRouter(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[SED1].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[ED1].set_panid(0xface)
|
||||
self.nodes[ED1].set_mode('rsn')
|
||||
self.nodes[ED1].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ED1].enable_whitelist()
|
||||
|
||||
self.nodes[SED1].set_panid(0xface)
|
||||
self.nodes[SED1].set_mode('s')
|
||||
self.nodes[SED1].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[SED1].enable_whitelist()
|
||||
self.nodes[SED1].set_timeout(3)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[ED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED1].get_state(), 'child')
|
||||
|
||||
self.nodes[SED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[SED1].get_state(), 'child')
|
||||
|
||||
self.nodes[ROUTER].add_prefix('2001::/64', 'pvcrs')
|
||||
self.nodes[ROUTER].add_prefix('2002::/64', 'pvcr')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
addrs = self.nodes[SED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
ED1 = 3
|
||||
SED1 = 4
|
||||
|
||||
class Cert_5_6_5_NetworkDataRegisterAfterAttachRouter(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[SED1].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[ED1].set_panid(0xface)
|
||||
self.nodes[ED1].set_mode('rsn')
|
||||
self.nodes[ED1].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ED1].enable_whitelist()
|
||||
|
||||
self.nodes[SED1].set_panid(0xface)
|
||||
self.nodes[SED1].set_mode('s')
|
||||
self.nodes[SED1].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[SED1].enable_whitelist()
|
||||
self.nodes[SED1].set_timeout(3)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[ED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED1].get_state(), 'child')
|
||||
|
||||
self.nodes[SED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[SED1].get_state(), 'child')
|
||||
|
||||
self.nodes[ROUTER].add_prefix('2001::/64', 'pvcrs')
|
||||
self.nodes[ROUTER].add_prefix('2002::/64', 'pvcr')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:3] == '200':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
addrs = self.nodes[SED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:3] == '200':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
self.nodes[ROUTER].add_prefix('2003::/64', 'pvcs')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:3] == '200':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
addrs = self.nodes[SED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:3] == '200':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,139 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
ED1 = 3
|
||||
SED1 = 4
|
||||
|
||||
class Cert_5_6_6_NetworkDataExpiration(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[SED1].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[ED1].set_panid(0xface)
|
||||
self.nodes[ED1].set_mode('rsn')
|
||||
self.nodes[ED1].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ED1].enable_whitelist()
|
||||
|
||||
self.nodes[SED1].set_panid(0xface)
|
||||
self.nodes[SED1].set_mode('s')
|
||||
self.nodes[SED1].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[SED1].enable_whitelist()
|
||||
self.nodes[SED1].set_timeout(3)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[ED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED1].get_state(), 'child')
|
||||
|
||||
self.nodes[SED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[SED1].get_state(), 'child')
|
||||
|
||||
self.nodes[ROUTER].add_prefix('2001::/64', 'pvcrs')
|
||||
self.nodes[ROUTER].add_prefix('2002::/64', 'pvcr')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:3] == '200':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
addrs = self.nodes[SED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:3] == '200':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
self.nodes[ROUTER].add_prefix('2003::/64', 'pvcs')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:3] == '200':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
addrs = self.nodes[SED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:3] == '200':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
self.nodes[ROUTER].remove_prefix('2003::/64')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
time.sleep(10)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:3] == '200':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
addrs = self.nodes[SED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:3] == '200':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
self.nodes[ROUTER].stop()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
REED = 3
|
||||
|
||||
class Cert_5_6_7_NetworkDataRequestREED(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,4):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[REED].set_panid(0xface)
|
||||
self.nodes[REED].set_mode('rsdn')
|
||||
self.nodes[REED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[REED].enable_whitelist()
|
||||
self.nodes[REED].set_router_upgrade_threshold(0)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[REED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[REED].get_state(), 'child')
|
||||
|
||||
self.nodes[LEADER].remove_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[REED].remove_whitelist(self.nodes[LEADER].get_addr64())
|
||||
|
||||
self.nodes[ROUTER].add_prefix('2003::/64', 'pvcrs')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[REED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
addrs = self.nodes[REED].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:3] == '200':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
ED = 3
|
||||
|
||||
class Cert_5_6_8_ContextManagement(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,4):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
self.nodes[LEADER].set_context_reuse_delay(10)
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
self.nodes[ROUTER].add_prefix('2001::/64', 'pvcrs')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
time.sleep(2)
|
||||
|
||||
addrs = self.nodes[LEADER].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:3] == '200':
|
||||
self.nodes[ED].ping(addr)
|
||||
|
||||
self.nodes[ROUTER].remove_prefix('2001::/64')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
time.sleep(5)
|
||||
|
||||
addrs = self.nodes[LEADER].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:3] == '200':
|
||||
self.nodes[ED].ping(addr)
|
||||
|
||||
self.nodes[ROUTER].add_prefix('2002::/64', 'pvcrs')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
time.sleep(5)
|
||||
|
||||
addrs = self.nodes[LEADER].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:3] == '200':
|
||||
self.nodes[ED].ping(addr)
|
||||
|
||||
time.sleep(5)
|
||||
self.nodes[ROUTER].add_prefix('2003::/64', 'pvcrs')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
time.sleep(5)
|
||||
|
||||
addrs = self.nodes[LEADER].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:3] == '200':
|
||||
self.nodes[ED].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,143 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
ED = 4
|
||||
SED = 5
|
||||
|
||||
class Cert_5_6_9_NetworkDataForwarding(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,6):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[SED].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
self.nodes[SED].set_panid(0xface)
|
||||
self.nodes[SED].set_mode('s')
|
||||
self.nodes[SED].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[SED].enable_whitelist()
|
||||
self.nodes[SED].set_timeout(3)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
self.nodes[SED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[SED].get_state(), 'child')
|
||||
|
||||
self.nodes[LEADER].add_prefix('2001::/64', 'pvcrs', 'med')
|
||||
self.nodes[LEADER].add_route('2002::/64', 'med')
|
||||
self.nodes[LEADER].register_netdata()
|
||||
time.sleep(10)
|
||||
|
||||
self.nodes[ROUTER2].add_prefix('2001::/64', 'pvcrs', 'low')
|
||||
self.nodes[ROUTER2].add_route('2002::/64', 'high')
|
||||
self.nodes[ROUTER2].register_netdata()
|
||||
time.sleep(10)
|
||||
|
||||
try:
|
||||
self.nodes[SED].ping('2002::1')
|
||||
except pexpect.TIMEOUT:
|
||||
pass
|
||||
|
||||
try:
|
||||
self.nodes[SED].ping('2007::1')
|
||||
except pexpect.TIMEOUT:
|
||||
pass
|
||||
|
||||
self.nodes[ROUTER2].remove_prefix('2001::/64')
|
||||
self.nodes[ROUTER2].add_prefix('2001::/64', 'pvcrs', 'high')
|
||||
self.nodes[ROUTER2].register_netdata()
|
||||
time.sleep(10)
|
||||
|
||||
try:
|
||||
self.nodes[SED].ping('2007::1')
|
||||
except pexpect.TIMEOUT:
|
||||
pass
|
||||
|
||||
self.nodes[ROUTER2].remove_prefix('2001::/64')
|
||||
self.nodes[ROUTER2].add_prefix('2001::/64', 'pvcrs', 'med')
|
||||
self.nodes[ROUTER2].register_netdata()
|
||||
time.sleep(10)
|
||||
|
||||
try:
|
||||
self.nodes[SED].ping('2007::1')
|
||||
except pexpect.TIMEOUT:
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ED = 2
|
||||
|
||||
class Cert_5_8_1_KeySynchronization(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[LEADER].get_addrs()
|
||||
for addr in addrs:
|
||||
if 'ff:fe00' not in addr:
|
||||
self.nodes[ED].ping(addr)
|
||||
|
||||
key_sequence = self.nodes[ED].get_key_sequence()
|
||||
self.nodes[ED].set_key_sequence(key_sequence + 10)
|
||||
|
||||
addrs = self.nodes[LEADER].get_addrs()
|
||||
for addr in addrs:
|
||||
if 'ff:fe00' not in addr:
|
||||
try:
|
||||
self.nodes[ED].ping(addr)
|
||||
except pexpect.TIMEOUT:
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
|
||||
class Cert_5_8_2_KeyIncrement(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), "router")
|
||||
|
||||
addrs = self.nodes[ROUTER].get_addrs()
|
||||
for addr in addrs:
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
key_sequence = self.nodes[LEADER].get_key_sequence()
|
||||
self.nodes[LEADER].set_key_sequence(key_sequence + 1)
|
||||
|
||||
addrs = self.nodes[ROUTER].get_addrs()
|
||||
for addr in addrs:
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
|
||||
class Cert_5_8_3_KeyIncrementRollOver(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
self.nodes[LEADER].set_key_sequence(127)
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
addrs = self.nodes[ROUTER].get_addrs()
|
||||
for addr in addrs:
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
key_sequence = self.nodes[LEADER].get_key_sequence()
|
||||
self.nodes[LEADER].set_key_sequence(key_sequence + 1)
|
||||
|
||||
addrs = self.nodes[ROUTER].get_addrs()
|
||||
for addr in addrs:
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ED = 2
|
||||
|
||||
class Cert_6_1_1_RouterAttach(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
REED = 2
|
||||
ED = 3
|
||||
|
||||
class Cert_6_1_2_REEDAttach(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,4):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[REED].set_panid(0xface)
|
||||
self.nodes[REED].set_mode('rsdn')
|
||||
self.nodes[REED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[REED].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[REED].enable_whitelist()
|
||||
self.nodes[REED].set_router_upgrade_threshold(0)
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[REED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[REED].get_state(), 'child')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
self.assertEqual(self.nodes[REED].get_state(), 'router')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
ROUTER3 = 4
|
||||
ED = 5
|
||||
|
||||
class Cert_6_1_3_RouterAttachConnectivity(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,6):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER3].set_panid(0xface)
|
||||
self.nodes[ROUTER3].set_mode('rsdn')
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ROUTER3].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsdn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
for i in range(2, 6):
|
||||
self.nodes[i].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[i].get_state(), 'router')
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
for addr in addrs:
|
||||
self.nodes[ROUTER3].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
REED0 = 3
|
||||
REED1 = 4
|
||||
ED = 5
|
||||
|
||||
class Cert_6_1_4_REEDAttachConnectivity(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,6):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[REED0].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[REED1].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[REED1].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[REED0].set_panid(0xface)
|
||||
self.nodes[REED0].set_mode('rsdn')
|
||||
self.nodes[REED0].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[REED0].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[REED0].set_router_upgrade_threshold(0)
|
||||
self.nodes[REED0].enable_whitelist()
|
||||
|
||||
self.nodes[REED1].set_panid(0xface)
|
||||
self.nodes[REED1].set_mode('rsdn')
|
||||
self.nodes[REED1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[REED1].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[REED1].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[REED1].set_router_upgrade_threshold(0)
|
||||
self.nodes[REED1].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[REED0].get_addr64())
|
||||
self.nodes[ED].add_whitelist(self.nodes[REED1].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[REED0].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[REED0].get_state(), 'child')
|
||||
|
||||
self.nodes[REED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[REED1].get_state(), 'child')
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(10)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
self.assertEqual(self.nodes[REED1].get_state(), 'router')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
ED = 4
|
||||
|
||||
class Cert_6_1_5_RouterAttachLinkQuality(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ED].get_addr64(), rssi=-85)
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER2].get_addr64(), rssi=-85)
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
REED = 2
|
||||
ROUTER2 = 3
|
||||
ED = 4
|
||||
|
||||
class Cert_6_1_6_REEDAttachLinkQuality(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[REED].set_panid(0xface)
|
||||
self.nodes[REED].set_mode('rsdn')
|
||||
self.nodes[REED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[REED].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[REED].set_router_upgrade_threshold(0)
|
||||
self.nodes[REED].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ED].get_addr64(), rssi=-85)
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[REED].get_addr64())
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER2].get_addr64(), rssi=-85)
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[REED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[REED].get_state(), 'child')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(10)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
self.assertEqual(self.nodes[REED].get_state(), 'router')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ED = 3
|
||||
ROUTER2 = 4
|
||||
ROUTER3 = 5
|
||||
|
||||
class Cert_6_1_7_EDSynchronization(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,6):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER3].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER3].set_panid(0xface)
|
||||
self.nodes[ROUTER3].set_mode('rsdn')
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER3].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER3].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER3].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER3].get_state(), 'router')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ED = 3
|
||||
|
||||
class Cert_6_2_1_NewPartition(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,4):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
self.nodes[LEADER].stop()
|
||||
time.sleep(130)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'leader')
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
for addr in addrs:
|
||||
self.nodes[ROUTER1].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER1 = 2
|
||||
ROUTER2 = 3
|
||||
ED = 4
|
||||
|
||||
class Cert_6_2_2_NewPartition(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER1].set_panid(0xface)
|
||||
self.nodes[ROUTER1].set_mode('rsdn')
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ROUTER2].get_addr64())
|
||||
self.nodes[ROUTER1].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ROUTER1].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER2].set_panid(0xface)
|
||||
self.nodes[ROUTER2].set_mode('rsdn')
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER2].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER2].enable_whitelist()
|
||||
self.nodes[ROUTER2].set_network_id_timeout(110)
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
self.nodes[LEADER].stop()
|
||||
time.sleep(130)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'leader')
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
for addr in addrs:
|
||||
self.nodes[ROUTER1].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
ED = 3
|
||||
|
||||
class Cert_6_3_1_OrphanReattach(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,4):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
self.nodes[ED].set_timeout(10)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
self.nodes[ROUTER].stop()
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
time.sleep(20)
|
||||
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
for addr in addrs:
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ED = 2
|
||||
|
||||
class Cert_5_6_2_NetworkDataUpdate(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
self.nodes[ED].set_timeout(10)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
self.nodes[LEADER].add_prefix('2001::/64', 'pvcrs')
|
||||
self.nodes[LEADER].register_netdata()
|
||||
time.sleep(3)
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
self.nodes[LEADER].remove_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ED].remove_whitelist(self.nodes[LEADER].get_addr64())
|
||||
|
||||
self.nodes[LEADER].add_prefix('2002::/64', 'pvcrs')
|
||||
self.nodes[LEADER].register_netdata()
|
||||
time.sleep(3)
|
||||
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
time.sleep(10)
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ED = 2
|
||||
|
||||
class Cert_6_4_1_LinkLocal(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == 'fe80':
|
||||
self.nodes[LEADER].ping(addr, size=256)
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
self.nodes[LEADER].ping('ff02::1', size=256)
|
||||
self.nodes[LEADER].ping('ff02::1')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
ED = 3
|
||||
|
||||
class Cert_5_3_2_RealmLocal(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] != 'fe80':
|
||||
self.nodes[LEADER].ping(addr, size=256)
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
self.nodes[LEADER].ping('ff03::1', size=256)
|
||||
self.nodes[LEADER].ping('ff03::1')
|
||||
|
||||
self.nodes[LEADER].ping('ff33:0040:fdde:ad00:beef:0:0:1', size=256)
|
||||
self.nodes[LEADER].ping('ff33:0040:fdde:ad00:beef:0:0:1')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ED = 2
|
||||
|
||||
class Cert_6_5_1_ChildResetSynchronize(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].set_timeout(3)
|
||||
self.nodes[ED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
self.nodes[ED].stop()
|
||||
time.sleep(5)
|
||||
|
||||
self.nodes[ED].set_timeout(100)
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
self.nodes[ED].stop()
|
||||
time.sleep(3)
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == 'fe80':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ED = 2
|
||||
|
||||
class Cert_6_5_2_ChildResetReattach(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
self.nodes[LEADER].remove_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ED].remove_whitelist(self.nodes[LEADER].get_addr64())
|
||||
|
||||
self.nodes[ED].stop()
|
||||
time.sleep(3)
|
||||
self.nodes[ED].start()
|
||||
|
||||
time.sleep(3)
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
time.sleep(5)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == 'fe80':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ED = 2
|
||||
|
||||
class Cert_6_6_1_KeyIncrement(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), "child")
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
for addr in addrs:
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
key_sequence = self.nodes[LEADER].get_key_sequence()
|
||||
self.nodes[LEADER].set_key_sequence(key_sequence + 1)
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
for addr in addrs:
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ED = 2
|
||||
|
||||
class Cert_6_6_2_KeyIncrement1(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
self.nodes[LEADER].set_key_sequence(127)
|
||||
|
||||
self.nodes[ED].set_panid(0xface)
|
||||
self.nodes[ED].set_mode('rsn')
|
||||
self.nodes[ED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ED].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
for addr in addrs:
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
key_sequence = self.nodes[LEADER].get_key_sequence()
|
||||
self.nodes[LEADER].set_key_sequence(key_sequence + 1)
|
||||
|
||||
addrs = self.nodes[ED].get_addrs()
|
||||
for addr in addrs:
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
SED1 = 3
|
||||
ED1 = 4
|
||||
|
||||
class Cert_7_1_1_BorderRouterAsLeader(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[SED1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[SED1].set_panid(0xface)
|
||||
self.nodes[SED1].set_mode('s')
|
||||
self.nodes[SED1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[SED1].enable_whitelist()
|
||||
self.nodes[SED1].set_timeout(3)
|
||||
|
||||
self.nodes[ED1].set_panid(0xface)
|
||||
self.nodes[ED1].set_mode('rsn')
|
||||
self.nodes[ED1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED1].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[LEADER].add_prefix('2001::/64', 'pvcrs')
|
||||
self.nodes[LEADER].add_prefix('2002::/64', 'pvcr')
|
||||
self.nodes[LEADER].register_netdata()
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[SED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[SED1].get_state(), 'child')
|
||||
|
||||
self.nodes[ED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED1].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[SED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
ED2 = 3
|
||||
SED2 = 4
|
||||
|
||||
class Cert_7_1_2_BorderRouterAsRouter(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[ED2].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[SED2].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[ED2].set_panid(0xface)
|
||||
self.nodes[ED2].set_mode('rsn')
|
||||
self.nodes[ED2].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ED2].enable_whitelist()
|
||||
|
||||
self.nodes[SED2].set_panid(0xface)
|
||||
self.nodes[SED2].set_mode('s')
|
||||
self.nodes[SED2].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[SED2].enable_whitelist()
|
||||
self.nodes[SED2].set_timeout(3)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[ROUTER].add_prefix('2001::/64', 'pvcrs')
|
||||
self.nodes[ROUTER].add_prefix('2002::/64', 'pvcr')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
|
||||
self.nodes[ED2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED2].get_state(), 'child')
|
||||
|
||||
self.nodes[SED2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[SED2].get_state(), 'child')
|
||||
|
||||
addrs = self.nodes[ED2].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
addrs = self.nodes[SED2].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,107 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
SED1 = 3
|
||||
ED1 = 4
|
||||
|
||||
class Cert_7_1_3_BorderRouterAsLeader(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[SED1].get_addr64())
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED1].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[SED1].set_panid(0xface)
|
||||
self.nodes[SED1].set_mode('s')
|
||||
self.nodes[SED1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[SED1].enable_whitelist()
|
||||
self.nodes[SED1].set_timeout(3)
|
||||
|
||||
self.nodes[ED1].set_panid(0xface)
|
||||
self.nodes[ED1].set_mode('rsn')
|
||||
self.nodes[ED1].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ED1].enable_whitelist()
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[SED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[SED1].get_state(), 'child')
|
||||
|
||||
self.nodes[ED1].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED1].get_state(), 'child')
|
||||
|
||||
self.nodes[LEADER].add_prefix('2001::/64', 'pvcrs')
|
||||
self.nodes[LEADER].add_prefix('2002::/64', 'pvcr')
|
||||
self.nodes[LEADER].register_netdata()
|
||||
time.sleep(3)
|
||||
|
||||
addrs = self.nodes[SED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
addrs = self.nodes[ED1].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,107 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
ED2 = 3
|
||||
SED2 = 4
|
||||
|
||||
class Cert_7_1_4_BorderRouterAsRouter(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[ED2].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[SED2].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[ED2].set_panid(0xface)
|
||||
self.nodes[ED2].set_mode('rsn')
|
||||
self.nodes[ED2].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ED2].enable_whitelist()
|
||||
|
||||
self.nodes[SED2].set_panid(0xface)
|
||||
self.nodes[SED2].set_mode('s')
|
||||
self.nodes[SED2].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[SED2].enable_whitelist()
|
||||
self.nodes[SED2].set_timeout(3)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[ED2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED2].get_state(), 'child')
|
||||
|
||||
self.nodes[SED2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[SED2].get_state(), 'child')
|
||||
|
||||
self.nodes[ROUTER].add_prefix('2001::/64', 'pvcrs')
|
||||
self.nodes[ROUTER].add_prefix('2002::/64', 'pvcr')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
time.sleep(3)
|
||||
|
||||
addrs = self.nodes[ED2].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
addrs = self.nodes[SED2].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -0,0 +1,121 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import pexpect
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
ED2 = 3
|
||||
SED2 = 4
|
||||
|
||||
class Cert_7_1_5_BorderRouterAsRouter(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,5):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[ED2].get_addr64())
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[SED2].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
|
||||
self.nodes[ED2].set_panid(0xface)
|
||||
self.nodes[ED2].set_mode('rsn')
|
||||
self.nodes[ED2].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[ED2].enable_whitelist()
|
||||
|
||||
self.nodes[SED2].set_panid(0xface)
|
||||
self.nodes[SED2].set_mode('s')
|
||||
self.nodes[SED2].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[SED2].enable_whitelist()
|
||||
self.nodes[SED2].set_timeout(3)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[ED2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ED2].get_state(), 'child')
|
||||
|
||||
self.nodes[SED2].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[SED2].get_state(), 'child')
|
||||
|
||||
self.nodes[ROUTER].add_prefix('2001::/64', 'pvcrs')
|
||||
self.nodes[ROUTER].add_prefix('2002::/64', 'pvcr')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
time.sleep(3)
|
||||
|
||||
addrs = self.nodes[ED2].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
addrs = self.nodes[SED2].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
self.nodes[ROUTER].add_prefix('2003::/64', 'pvcrs')
|
||||
self.nodes[ROUTER].register_netdata()
|
||||
time.sleep(3)
|
||||
|
||||
addrs = self.nodes[ED2].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002' or addr[0:4] == '2003':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
addrs = self.nodes[SED2].get_addrs()
|
||||
for addr in addrs:
|
||||
if addr[0:4] == '2001' or addr[0:4] == '2002' or addr[0:4] == '2003':
|
||||
self.nodes[LEADER].ping(addr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
|
||||
class Cert_Cli(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
self.nodes[LEADER] = node.Node(LEADER)
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
commands = self.nodes[LEADER].get_commands()
|
||||
|
||||
for command in commands:
|
||||
self.nodes[LEADER].send_command(command + ' -h')
|
||||
self.nodes[LEADER].pexpect.expect('Done')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Executable
+75
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import node
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
|
||||
class Test_MacScan(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.nodes = {}
|
||||
for i in range(1,3):
|
||||
self.nodes[i] = node.Node(i)
|
||||
|
||||
self.nodes[LEADER].set_panid(0xface)
|
||||
self.nodes[LEADER].set_mode('rsdn')
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ROUTER].get_addr64())
|
||||
self.nodes[LEADER].enable_whitelist()
|
||||
self.nodes[LEADER].set_channel(12)
|
||||
self.nodes[LEADER].set_network_name('OpenThread')
|
||||
|
||||
self.nodes[ROUTER].set_panid(0xface)
|
||||
self.nodes[ROUTER].set_mode('rsdn')
|
||||
self.nodes[ROUTER].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
self.nodes[ROUTER].enable_whitelist()
|
||||
self.nodes[ROUTER].set_channel(12)
|
||||
self.nodes[ROUTER].set_network_name('OpenThread')
|
||||
|
||||
def tearDown(self):
|
||||
for node in self.nodes.itervalues():
|
||||
node.stop()
|
||||
del self.nodes
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.nodes[LEADER].set_state('leader')
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
time.sleep(3)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
results = self.nodes[LEADER].scan()
|
||||
self.assertEqual(len(results), 16)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
Executable
+319
@@ -0,0 +1,319 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
import pexpect
|
||||
import unittest
|
||||
|
||||
class Node:
|
||||
def __init__(self, nodeid):
|
||||
self.nodeid = nodeid
|
||||
self.verbose = int(float(os.getenv('VERBOSE', 0)))
|
||||
self.node_type = os.getenv('NODE_TYPE', 'sim')
|
||||
|
||||
if self.node_type == 'soc':
|
||||
self.__init_soc(nodeid)
|
||||
else:
|
||||
self.__init_sim(nodeid)
|
||||
|
||||
if self.verbose:
|
||||
self.pexpect.logfile_read = sys.stdout
|
||||
|
||||
self.clear_whitelist()
|
||||
self.disable_whitelist()
|
||||
self.set_timeout(100)
|
||||
|
||||
def __init_sim(self, nodeid):
|
||||
""" Initialize a simulation node. """
|
||||
if "top_srcdir" in os.environ.keys():
|
||||
srcdir = os.environ['top_srcdir']
|
||||
cmd = '%s/examples/cli/soc' % srcdir
|
||||
else:
|
||||
cmd = './soc'
|
||||
cmd += ' --nodeid=%d -S' % nodeid
|
||||
print cmd
|
||||
|
||||
self.pexpect = pexpect.spawn(cmd, timeout=2)
|
||||
|
||||
def __init_soc(self, nodeid):
|
||||
""" Initialize a System-on-a-chip node connected via UART. """
|
||||
import fdpexpect
|
||||
serialPort = '/dev/ttyUSB%d' % ((nodeid-1)*2)
|
||||
self.pexpect = fdpexpect.fdspawn(os.open(serialPort, os.O_RDWR|os.O_NONBLOCK|os.O_NOCTTY))
|
||||
|
||||
def __del__(self):
|
||||
if self.node_type == 'sim':
|
||||
self.send_command('shutdown')
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
self.pexpect.terminate()
|
||||
self.pexpect.close(force=True)
|
||||
|
||||
def send_command(self, cmd):
|
||||
print self.nodeid, ":", cmd
|
||||
self.pexpect.sendline(cmd)
|
||||
|
||||
def get_commands(self):
|
||||
self.send_command('?')
|
||||
self.pexpect.expect('Commands:')
|
||||
commands = []
|
||||
while True:
|
||||
i = self.pexpect.expect(['Done', '(\S+)'])
|
||||
if i != 0:
|
||||
commands.append(self.pexpect.match.groups()[0])
|
||||
else:
|
||||
break
|
||||
return commands
|
||||
|
||||
def set_mode(self, mode):
|
||||
cmd = 'mode ' + mode
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def start(self):
|
||||
self.send_command('start')
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def stop(self):
|
||||
self.send_command('stop')
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def clear_whitelist(self):
|
||||
self.send_command('whitelist clear')
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def enable_whitelist(self):
|
||||
self.send_command('whitelist enable')
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def disable_whitelist(self):
|
||||
self.send_command('whitelist disable')
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def add_whitelist(self, addr, rssi=None):
|
||||
cmd = 'whitelist add ' + addr
|
||||
if rssi != None:
|
||||
cmd += ' ' + str(rssi)
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def remove_whitelist(self, addr):
|
||||
cmd = 'whitelist remove ' + addr
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def get_addr16(self):
|
||||
self.send_command('rloc16')
|
||||
i = self.pexpect.expect('([0-9a-fA-F]{4})')
|
||||
if i == 0:
|
||||
addr16 = int(self.pexpect.match.groups()[0], 16)
|
||||
self.pexpect.expect('Done')
|
||||
return addr16
|
||||
|
||||
def get_addr64(self):
|
||||
self.send_command('extaddr')
|
||||
i = self.pexpect.expect('([0-9a-fA-F]{16})')
|
||||
if i == 0:
|
||||
addr64 = self.pexpect.match.groups()[0]
|
||||
self.pexpect.expect('Done')
|
||||
return addr64
|
||||
|
||||
def set_channel(self, channel):
|
||||
cmd = 'channel %d' % channel
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def get_key_sequence(self):
|
||||
self.send_command('keysequence')
|
||||
i = self.pexpect.expect('(\d+)')
|
||||
if i == 0:
|
||||
key_sequence = int(self.pexpect.match.groups()[0])
|
||||
self.pexpect.expect('Done')
|
||||
return key_sequence
|
||||
|
||||
def set_key_sequence(self, key_sequence):
|
||||
cmd = 'keysequence %d' % key_sequence
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def set_network_id_timeout(self, network_id_timeout):
|
||||
cmd = 'networkidtimeout %d' % network_id_timeout
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def set_network_name(self, network_name):
|
||||
cmd = 'networkname ' + network_name
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def get_panid(self):
|
||||
self.send_command('panid')
|
||||
i = self.pexpect.expect('([0-9a-fA-F]{16})')
|
||||
if i == 0:
|
||||
panid = self.pexpect.match.groups()[0]
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def set_panid(self, panid):
|
||||
cmd = 'panid %d' % panid
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def set_router_upgrade_threshold(self, threshold):
|
||||
cmd = 'routerupgradethreshold %d' % threshold
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def release_router_id(self, router_id):
|
||||
cmd = 'releaserouterid %d' % router_id
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def get_state(self):
|
||||
states = ['detached', 'child', 'router', 'leader']
|
||||
self.send_command('state')
|
||||
match = self.pexpect.expect(states)
|
||||
self.pexpect.expect('Done')
|
||||
return states[match]
|
||||
|
||||
def set_state(self, state):
|
||||
cmd = 'state ' + state
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def get_timeout(self):
|
||||
self.send_command('childtimeout')
|
||||
i = self.pexpect.expect('(\d+)')
|
||||
if i == 0:
|
||||
timeout = self.pexpect.match.groups()[0]
|
||||
self.pexpect.expect('Done')
|
||||
return timeout
|
||||
|
||||
def set_timeout(self, timeout):
|
||||
cmd = 'childtimeout %d' % timeout
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def get_weight(self):
|
||||
self.send_command('leaderweight')
|
||||
i = self.pexpect.expect('(\d+)')
|
||||
if i == 0:
|
||||
weight = self.pexpect.match.groups()[0]
|
||||
self.pexpect.expect('Done')
|
||||
return weight
|
||||
|
||||
def set_weight(self, weight):
|
||||
cmd = 'leaderweight %d' % weight
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def add_ipaddr(self, ipaddr):
|
||||
cmd = 'ipaddr add ' + ipaddr
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def get_addrs(self):
|
||||
addrs = []
|
||||
self.send_command('ipaddr')
|
||||
|
||||
while True:
|
||||
i = self.pexpect.expect(['(\S+:\S+)', 'Done'])
|
||||
if i == 0:
|
||||
addrs.append(self.pexpect.match.groups()[0])
|
||||
elif i == 1:
|
||||
break
|
||||
|
||||
return addrs
|
||||
|
||||
def get_context_reuse_delay(self):
|
||||
self.send_command('contextreusedelay')
|
||||
i = self.pexpect.expect('(\d+)')
|
||||
if i == 0:
|
||||
timeout = self.pexpect.match.groups()[0]
|
||||
self.pexpect.expect('Done')
|
||||
return timeout
|
||||
|
||||
def set_context_reuse_delay(self, delay):
|
||||
cmd = 'contextreusedelay %d' % delay
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def add_prefix(self, prefix, flags, prf = 'med'):
|
||||
cmd = 'prefix add ' + prefix + ' ' + flags + ' ' + prf
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def remove_prefix(self, prefix):
|
||||
cmd = ' prefix remove ' + prefix
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def add_route(self, prefix, prf = 'med'):
|
||||
cmd = 'route add ' + prefix + ' ' + prf
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def remove_route(self, prefix):
|
||||
cmd = 'route remove ' + prefix
|
||||
self.send_command(cmd)
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def register_netdata(self):
|
||||
self.send_command('netdataregister')
|
||||
self.pexpect.expect('Done')
|
||||
|
||||
def scan(self):
|
||||
self.send_command('scan')
|
||||
|
||||
results = []
|
||||
while True:
|
||||
i = self.pexpect.expect(['\|\s(\S+)\s+\|\s(\S+)\s+\|\s([0-9a-fA-F]{4})\s\|\s([0-9a-fA-F]{16})\s\|\s(\d+)',
|
||||
'Done'])
|
||||
if i == 0:
|
||||
results.append(self.pexpect.match.groups())
|
||||
else:
|
||||
break
|
||||
|
||||
return results
|
||||
|
||||
def ping(self, ipaddr, num_responses=1, size=None):
|
||||
cmd = 'ping ' + ipaddr
|
||||
if size != None:
|
||||
cmd += ' ' + str(size)
|
||||
|
||||
self.send_command(cmd)
|
||||
responders = {}
|
||||
while len(responders) < num_responses:
|
||||
i = self.pexpect.expect(['from (\S+):'])
|
||||
if i == 0:
|
||||
responders[self.pexpect.match.groups()[0]] = 1
|
||||
self.pexpect.expect('\n')
|
||||
return responders
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user