support interop and harness r34 (#1092)

This commit is contained in:
Buke Po
2016-12-19 21:47:57 -08:00
committed by Jonathan Hui
parent d4cd57f904
commit 97fbca2063
5 changed files with 70 additions and 110 deletions
@@ -172,6 +172,9 @@ class HarnessCase(unittest.TestCase):
logger.warning('All golden devices may not be resetted')
return
if settings.AUTO_DUT:
return
for device in settings.GOLDEN_DEVICES:
try:
with OpenThreadController(device) as otc:
@@ -213,6 +216,7 @@ class HarnessCase(unittest.TestCase):
time.sleep(1)
self._hc.start()
time.sleep(2)
os.system('taskkill /t /f /im chrome.exe')
def _destroy_harness(self):
"""Stop harness backend service
@@ -231,7 +235,7 @@ class HarnessCase(unittest.TestCase):
self.dut = None
return
dut_port = settings.DUT_DEVICE
dut_port = settings.DUT_DEVICE[0]
dut = OpenThreadController(dut_port)
self.dut = dut
@@ -262,7 +266,8 @@ class HarnessCase(unittest.TestCase):
browser.maximize_window()
browser.get(settings.HARNESS_URL)
self._browser = browser
self.assertIn('Thread', browser.title)
if not self.wait_until(lambda: 'Thread' in browser.title, 30):
self.assertIn('Thread', browser.title)
def _destroy_browser(self):
"""Close the browser.
@@ -345,6 +350,14 @@ class HarnessCase(unittest.TestCase):
time.sleep(1)
try:
skip_button = self._browser.find_element_by_id('SkipPrepareDevice')
if skip_button.is_enabled():
skip_button.click()
time.sleep(1)
except:
logger.info('Still detecting sniffers')
try:
next_button = self._browser.find_element_by_id('nextButton')
except:
@@ -389,6 +402,29 @@ class HarnessCase(unittest.TestCase):
connect_all = self._browser.find_element_by_link_text('Connect All')
connect_all.click()
def _add_device(self, port, device_type_id):
browser = self._browser
test_bed = browser.find_element_by_id('test-bed')
device = browser.find_element_by_id(device_type_id)
# drag
action_chains = ActionChains(browser)
action_chains.click_and_hold(device)
action_chains.move_to_element(test_bed).perform()
time.sleep(1)
# drop
drop_hw = browser.find_element_by_class_name('drop-hw')
action_chains = ActionChains(browser)
action_chains.move_to_element(drop_hw)
action_chains.release(drop_hw).perform()
time.sleep(0.5)
selected_hw = browser.find_element_by_class_name('selected-hw')
form_inputs = selected_hw.find_elements_by_tag_name('input')
form_port = form_inputs[0]
form_port.clear()
form_port.send_keys(port)
def _test_bed(self):
"""Set up the test bed.
@@ -406,43 +442,29 @@ class HarnessCase(unittest.TestCase):
remove_button.click()
selected_hw_num = selected_hw_num - 1
devices = filter(lambda port: not (self.history.is_bad_golden_device(port) or (not self.auto_dut and port == settings.DUT_DEVICE )),
settings.GOLDEN_DEVICES)
devices = list(settings.GOLDEN_DEVICES)
for index, device in enumerate(devices):
port = device[0]
if (self.history.is_bad_golden_device(port) or (settings.DUT_DEVICE and port == settings.DUT_DEVICE[0])):
devices.remove(device)
logger.info('Available golden devices: %s', json.dumps(devices, indent=2))
golden_devices_required = self.golden_devices_required
if self.auto_dut:
golden_devices_required = golden_devices_required + 1
if self.auto_dut and not settings.DUT_DEVICE:
golden_devices_required += 1
if len(devices) < golden_devices_required:
raise Exception('Golden devices is not enough')
device_type_id = settings.GOLDEN_DEVICE_TYPE
# add golden devices
while golden_devices_required:
device = browser.find_element_by_id(device_type_id)
# drag
action_chains = ActionChains(browser)
action_chains.click_and_hold(device)
action_chains.move_to_element(test_bed).perform()
time.sleep(1)
# drop
drop_hw = browser.find_element_by_class_name('drop-hw')
action_chains = ActionChains(browser)
action_chains.move_to_element(drop_hw)
action_chains.release(drop_hw).perform()
time.sleep(0.5)
self._add_device(*devices.pop())
golden_devices_required = golden_devices_required - 1
selected_hw_set = test_bed.find_elements_by_class_name('selected-hw')
for selected_hw in selected_hw_set:
form_inputs = selected_hw.find_elements_by_tag_name('input')
form_port = form_inputs[0]
form_port.clear()
device = devices.pop()
form_port.send_keys(device)
# add DUT
if settings.DUT_DEVICE:
self._add_device(*settings.DUT_DEVICE)
while True:
try:
@@ -459,6 +481,9 @@ class HarnessCase(unittest.TestCase):
for selected_hw in bad_ones:
port = form_port.get_attribute('value').encode('utf8')
if settings.DUT_DEVICE and port == settings.DUT_DEVICE[0]:
raise Exception('DUT device failed')
if not settings.APC_HOST:
# port cannot recover without power off
self.history.mark_bad_golden_device(port)
@@ -467,28 +492,8 @@ class HarnessCase(unittest.TestCase):
selected_hw.find_element_by_class_name('removeSelectedDevice').click()
time.sleep(0.1)
device = browser.find_element_by_id(device_type_id)
# drag
action_chains = ActionChains(browser)
action_chains.click_and_hold(device)
action_chains.move_to_element(test_bed).perform()
time.sleep(1)
# drop
drop_hw = browser.find_element_by_class_name('drop-hw')
action_chains = ActionChains(browser)
action_chains.move_to_element(drop_hw)
action_chains.release(drop_hw).perform()
time.sleep(0.5)
selected_hw = browser.find_element_by_class_name('selected-hw')
form_inputs = selected_hw.find_elements_by_tag_name('input')
form_port = form_inputs[0]
if devices:
device = devices.pop()
form_port.clear()
form_port.send_keys(device)
if len(devices):
self._add_device(*devices.pop())
else:
devices = None
@@ -70,14 +70,17 @@ class HarnessController(object):
env=env)
time.sleep(2)
if settings.HARNESS_VERSION > 33:
return
if self.miniweb:
logger.warning('Miniweb already started')
else:
with open('%s\\miniweb-%s.log' % (self.result_dir, time.strftime('%Y%m%d%H%M%S')), 'w') as miniwebOut:
self.miniweb = subprocess.Popen([settings.HARNESS_HOME + '\\miniweb\\miniweb.exe'],
self.miniweb = subprocess.Popen([settings.HARNESS_HOME + '\\MiniWeb\\miniweb.exe'],
stdout=miniwebOut,
stderr=miniwebOut,
cwd=settings.HARNESS_HOME + '\\miniweb')
cwd=settings.HARNESS_HOME + '\\MiniWeb')
def stop(self):
logger.info('Stopping harness service')
@@ -88,6 +91,9 @@ class HarnessController(object):
else:
logger.warning('Harness not started yet')
if settings.HARNESS_VERSION > 33:
return
if self.miniweb:
self._try_kill(self.miniweb)
self.miniweb = None
@@ -31,8 +31,9 @@
AUTO_DUT = False
"""bool: Whether use the auto DUT feature of thread harness."""
DUT_DEVICE = 'COM16'
"""str: Serial port of the DUT, must be set if AUTO_DUT=False."""
DUT_DEVICE = ('COM16', 'OpenThread')
"""(str,str): The first element is serial port of the DUT, and the second is
the device type. This must be set if AUTO_DUT=False."""
DUT_VERSION = 'g12345'
"""str: Version of DUT, must be set if AUTO_DUT=False."""
@@ -79,19 +80,10 @@ TESTER_NAME = 'Thread Open'
TESTER_REMARKS = 'OpenThread is great'
"""str: Any comments in the final PDF"""
SER2NET_HOSTNAME = '192.168.1.1'
"""str: ser2net hostname, used by items in `GOLDEN_DEVICES` with prefix `NET`."""
SER2NET_PORTBASE = 9000
"""str: ser2net port base, `NET1` will be mapped to `SER2NET_PORTBASE + 1`."""
GOLDEN_DEVICE_TYPE = 'OpenThread'
"""str: Golden device type. Possible values are: `OpenThread`, `ARM`, `SiLabs` and `Freescale`."""
GOLDEN_DEVICES = []
"""[str]: Golden devices list.
"""[(str, str)]: devices list.
It should be something like ['COM1', 'COM2'] on Windows and can be found on Windows Device Manager."""
It should be something like [('COM1', 'OpenThread'), ('COM2', 'ARM')] on Windows and can be found on Windows Device Manager."""
OUTPUT_PATH = '.\\output'
"""str: Path to store results and logs, MUST be writable."""
@@ -1,43 +0,0 @@
#!/usr/bin/env python
#
# Copyright (c) 2016, The OpenThread Authors.
# 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 unittest
from autothreadharness.harness_case import HarnessCase
class Router_5_2_7(HarnessCase):
role = HarnessCase.ROLE_ROUTER
case = '5 2 7'
golden_devices_required = 16
def on_dialog(self, dialog, title):
pass
if __name__ == '__main__':
unittest.main()
+1 -1
View File
@@ -13,7 +13,7 @@
hint="eg: 115200">115200
</ITEM>
</DEVICE>
<DEVICE name="Freescale" thumbnail="USB-KW24.jpg" description = " NXP(Freescale): USB-KW24D512 Dongles">
<DEVICE name="NXP" thumbnail="USB-KW24.jpg" description = " NXP(Freescale): USB-KW24D512 Dongles">
<ITEM label="Serial Line"
type="text"
forParam="SerialPort"