From 30db14f42930d97fbcd68b845d549d1102e495ba Mon Sep 17 00:00:00 2001 From: Buke Po Date: Wed, 22 Feb 2017 15:19:34 +0800 Subject: [PATCH] detect harness configuration (#1367) --- .../autothreadharness/harness_case.py | 8 +++++++- .../autothreadharness/harness_controller.py | 12 ++++++++++-- .../autothreadharness/settings_sample.py | 3 --- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tools/harness-automation/autothreadharness/harness_case.py b/tools/harness-automation/autothreadharness/harness_case.py index f383ca5bb..2082fb491 100644 --- a/tools/harness-automation/autothreadharness/harness_case.py +++ b/tools/harness-automation/autothreadharness/harness_case.py @@ -27,6 +27,7 @@ # POSSIBILITY OF SUCH DAMAGE. # +import ConfigParser import json import logging import os @@ -223,7 +224,12 @@ class HarnessCase(unittest.TestCase): time.sleep(1) self._hc.start() time.sleep(2) - os.system('taskkill /t /f /im chrome.exe') + + harness_config = ConfigParser.ConfigParser() + harness_config.read('%s\\Config\\Configuration.ini' % settings.HARNESS_HOME) + if harness_config.has_option('THREAD_HARNESS_CONFIG', 'BrowserAutoNavigate') and \ + harness_config.getboolean('THREAD_HARNESS_CONFIG', 'BrowserAutoNavigate'): + os.system('taskkill /t /f /im chrome.exe') def _destroy_harness(self): """Stop harness backend service diff --git a/tools/harness-automation/autothreadharness/harness_controller.py b/tools/harness-automation/autothreadharness/harness_controller.py index c6dbeae78..f70f69db0 100644 --- a/tools/harness-automation/autothreadharness/harness_controller.py +++ b/tools/harness-automation/autothreadharness/harness_controller.py @@ -28,6 +28,7 @@ # +import ConfigParser import logging import os import subprocess @@ -37,6 +38,9 @@ from autothreadharness import settings logger = logging.getLogger(__name__) +HARNESS_SVN_VERSION_R44 = 1471 +"""int: this is the first published release that miniweb was removed from Harness""" + def _try_kill(proc): logger.info('Try kill process') times = 1 @@ -71,6 +75,10 @@ class HarnessController(object): self.result_dir = result_dir self.harness_file = '' + harness_info = ConfigParser.ConfigParser() + harness_info.read('%s\\info.ini' % settings.HARNESS_HOME) + self.version = harness_info.getint('Thread_Harness_Info', 'SVN') + def start(self): logger.info('Starting harness service') if self.harness: @@ -89,7 +97,7 @@ class HarnessController(object): env=env) time.sleep(2) - if settings.HARNESS_VERSION > 33: + if self.version >= HARNESS_SVN_VERSION_R44: return if self.miniweb: @@ -110,7 +118,7 @@ class HarnessController(object): else: logger.warning('Harness not started yet') - if settings.HARNESS_VERSION > 33: + if self.version >= HARNESS_SVN_VERSION_R44: return if self.miniweb: diff --git a/tools/harness-automation/autothreadharness/settings_sample.py b/tools/harness-automation/autothreadharness/settings_sample.py index 6d7d1944e..647eb2381 100644 --- a/tools/harness-automation/autothreadharness/settings_sample.py +++ b/tools/harness-automation/autothreadharness/settings_sample.py @@ -116,6 +116,3 @@ Example parameters for the 'APC_PDU_CONTROLLER': Example parameters for the 'NORDIC_BOARD_PDU_CONTOLLER': {'boards_serial_numbers': ('12345123', ...)} """ - -HARNESS_VERSION = 35 -"""int: Version of the installed Thread Harness."""