mirror of https://github.com/ARMmbed/mbed-os.git
Host test plugins: Added MPS2 and Firfox copy methods (both not stable and require further development)
Host test plugins: Added 'stable' attribute to each plugin, by default all plugins are not stable Moved all MPS2 related functions to MPS2 plugins in host test directorypull/597/head
parent
6a1bdb588e
commit
17f42519f0
|
@ -26,7 +26,6 @@ import os
|
|||
from sys import stdout
|
||||
from time import sleep, time
|
||||
from optparse import OptionParser
|
||||
from subprocess import call
|
||||
|
||||
import host_tests_plugins
|
||||
|
||||
|
|
|
@ -17,12 +17,13 @@ limitations under the License.
|
|||
|
||||
import host_test_registry
|
||||
|
||||
# This plugins provide 'flashing' methods to host test scripts
|
||||
import module_copy_mbed
|
||||
import module_copy_shell
|
||||
import module_copy_firefox
|
||||
import module_copy_silabs
|
||||
|
||||
# Plugins used to
|
||||
# Plugins used to reset certain platform
|
||||
import module_reset_mbed
|
||||
import module_reset_mps2
|
||||
import module_reset_silabs
|
||||
|
|
|
@ -29,8 +29,10 @@ class HostTestPluginBase:
|
|||
# Interface attributes defining plugin name, type etc.
|
||||
###########################################################################
|
||||
name = "HostTestPluginBase" # Plugin name, can be plugin class name
|
||||
type = "BasePlugin" # Plugin type: ResetMethod, Copymethod etc.
|
||||
capabilities = [] # Capabilities names: what plugin can achieve (e.g. reset using some external command line tool)
|
||||
type = "BasePlugin" # Plugin type: ResetMethod, Copymethod etc.
|
||||
capabilities = [] # Capabilities names: what plugin can achieve
|
||||
# (e.g. reset using some external command line tool)
|
||||
stable = False # Determine if plugin is stable and can be used
|
||||
|
||||
###########################################################################
|
||||
# Interface methods
|
||||
|
|
|
@ -63,14 +63,15 @@ class HostTestRegistry:
|
|||
""" User friendly printing method to show hooked plugins
|
||||
"""
|
||||
from prettytable import PrettyTable
|
||||
column_names = ['name', 'type', 'capabilities']
|
||||
column_names = ['name', 'type', 'capabilities', 'stable']
|
||||
pt = PrettyTable(column_names)
|
||||
for column in column_names:
|
||||
pt.align[column] = 'l'
|
||||
for plugin_name in self.PLUGINS:
|
||||
for plugin_name in sorted(self.PLUGINS.keys()):
|
||||
name = self.PLUGINS[plugin_name].name
|
||||
type = self.PLUGINS[plugin_name].type
|
||||
stable = self.PLUGINS[plugin_name].stable
|
||||
capabilities = ', '.join(self.PLUGINS[plugin_name].capabilities)
|
||||
row = [name, type, capabilities]
|
||||
row = [name, type, capabilities, stable]
|
||||
pt.add_row(row)
|
||||
return pt.get_string()
|
||||
|
|
|
@ -22,17 +22,20 @@ from host_test_plugins import HostTestPluginBase
|
|||
class HostTestPluginCopyMethod_Firefox(HostTestPluginBase):
|
||||
|
||||
def file_store_firefox(self, file_path, dest_disk):
|
||||
from selenium import webdriver
|
||||
profile = webdriver.FirefoxProfile()
|
||||
profile.set_preference('browser.download.folderList', 2) # custom location
|
||||
profile.set_preference('browser.download.manager.showWhenStarting', False)
|
||||
profile.set_preference('browser.download.dir', dest_disk)
|
||||
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'application/octet-stream')
|
||||
# Launch browser with profile and get file
|
||||
browser = webdriver.Firefox(profile)
|
||||
browser.get(file_path)
|
||||
browser.close()
|
||||
|
||||
try:
|
||||
from selenium import webdriver
|
||||
profile = webdriver.FirefoxProfile()
|
||||
profile.set_preference('browser.download.folderList', 2) # custom location
|
||||
profile.set_preference('browser.download.manager.showWhenStarting', False)
|
||||
profile.set_preference('browser.download.dir', dest_disk)
|
||||
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'application/octet-stream')
|
||||
# Launch browser with profile and get file
|
||||
browser = webdriver.Firefox(profile)
|
||||
browser.get(file_path)
|
||||
browser.close()
|
||||
except:
|
||||
return False
|
||||
return True
|
||||
|
||||
# Plugin interface
|
||||
name = 'HostTestPluginCopyMethod_Firefox'
|
||||
|
|
|
@ -39,6 +39,7 @@ class HostTestPluginCopyMethod_Mbed(HostTestPluginBase):
|
|||
# Plugin interface
|
||||
name = 'HostTestPluginCopyMethod_Mbed'
|
||||
type = 'CopyMethod'
|
||||
stable = True
|
||||
capabilities = ['default']
|
||||
required_parameters = ['image_path', 'destination_disk']
|
||||
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
"""
|
||||
mbed SDK
|
||||
Copyright (c) 2011-2013 ARM Limited
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from shutil import copy
|
||||
from os.path import join
|
||||
from host_test_plugins import HostTestPluginBase
|
||||
|
||||
|
||||
class HostTestPluginCopyMethod_MPS2(HostTestPluginBase):
|
||||
|
||||
# MPS2 specific flashing / binary setup funcitons
|
||||
def mps2_set_board_image_file(self, disk, images_cfg_path, image0file_path, image_name='images.txt'):
|
||||
""" This function will alter image cfg file.
|
||||
Main goal of this function is to change number of images to 1, comment all
|
||||
existing image entries and append at the end of file new entry with test path.
|
||||
@return True when all steps succeed.
|
||||
"""
|
||||
MBED_SDK_TEST_STAMP = 'test suite entry'
|
||||
image_path = join(disk, images_cfg_path, image_name)
|
||||
new_file_lines = [] # New configuration file lines (entries)
|
||||
|
||||
# Check each line of the image configuration file
|
||||
try:
|
||||
with open(image_path, 'r') as file:
|
||||
for line in file:
|
||||
if re.search('^TOTALIMAGES', line):
|
||||
# Check number of total images, should be 1
|
||||
new_file_lines.append(re.sub('^TOTALIMAGES:[\t ]*[\d]+', 'TOTALIMAGES: 1', line))
|
||||
pass
|
||||
elif re.search('; - %s[\n\r]*$'% MBED_SDK_TEST_STAMP, line):
|
||||
# Look for test suite entries and remove them
|
||||
pass # Omit all test suite entries
|
||||
elif re.search('^IMAGE[\d]+FILE', line):
|
||||
# Check all image entries and mark the ';'
|
||||
new_file_lines.append(';' + line) # Comment non test suite lines
|
||||
else:
|
||||
# Append line to new file
|
||||
new_file_lines.append(line)
|
||||
except IOError as e:
|
||||
return False
|
||||
|
||||
# Add new image entry with proper commented stamp
|
||||
new_file_lines.append('IMAGE0FILE: %s ; - %s\r\n'% (image0file_path, MBED_SDK_TEST_STAMP))
|
||||
|
||||
# Write all lines to file
|
||||
try:
|
||||
with open(image_path, 'w') as file:
|
||||
for line in new_file_lines:
|
||||
file.write(line),
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def mps2_select_core(self, disk, mobo_config_name=""):
|
||||
""" Function selects actual core
|
||||
"""
|
||||
# TODO: implement core selection
|
||||
pass
|
||||
|
||||
def mps2_switch_usb_auto_mounting_after_restart(self, disk, usb_config_name=""):
|
||||
""" Function alters configuration to allow USB MSD to be mounted after restarts
|
||||
"""
|
||||
# TODO: implement USB MSD restart detection
|
||||
pass
|
||||
|
||||
# Plugin interface
|
||||
name = 'HostTestPluginCopyMethod_MPS2'
|
||||
type = 'CopyMethod'
|
||||
capabilities = ['mps2']
|
||||
required_parameters = ['image_path', 'destination_disk']
|
||||
|
||||
def setup(self, *args, **kwargs):
|
||||
""" Configure plugin, this function should be called before plugin execute() method is used.
|
||||
"""
|
||||
return True
|
||||
|
||||
def execute(self, capabilitity, *args, **kwargs):
|
||||
""" Executes capability by name.
|
||||
Each capability may directly just call some command line
|
||||
program or execute building pythonic function
|
||||
"""
|
||||
result = False
|
||||
if self.check_parameters(capabilitity, *args, **kwargs) is True:
|
||||
if capabilitity == 'mps2':
|
||||
# TODO: Implement MPS2 firmware setup here
|
||||
pass
|
||||
return result
|
||||
|
||||
|
||||
def load_plugin():
|
||||
""" Returns plugin available in this module
|
||||
"""
|
||||
return HostTestPluginCopyMethod_MPS2()
|
|
@ -16,7 +16,6 @@ limitations under the License.
|
|||
"""
|
||||
|
||||
from os.path import join, basename
|
||||
from subprocess import call
|
||||
from host_test_plugins import HostTestPluginBase
|
||||
|
||||
|
||||
|
@ -25,6 +24,7 @@ class HostTestPluginCopyMethod_Shell(HostTestPluginBase):
|
|||
# Plugin interface
|
||||
name = 'HostTestPluginCopyMethod_Shell'
|
||||
type = 'CopyMethod'
|
||||
stable = True
|
||||
capabilities = ['cp', 'copy', 'xcopy']
|
||||
required_parameters = ['image_path', 'destination_disk']
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
"""
|
||||
|
||||
from os.path import join, basename
|
||||
from subprocess import call
|
||||
from host_test_plugins import HostTestPluginBase
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
"""
|
||||
|
||||
from subprocess import call
|
||||
from host_test_plugins import HostTestPluginBase
|
||||
|
||||
|
||||
|
@ -45,6 +44,7 @@ class HostTestPluginResetMethod_Mbed(HostTestPluginBase):
|
|||
# Plugin interface
|
||||
name = 'HostTestPluginResetMethod_Mbed'
|
||||
type = 'ResetMethod'
|
||||
stable = True
|
||||
capabilities = ['default']
|
||||
required_parameters = ['serial']
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ class HostTestPluginResetMethod_SiLabs(HostTestPluginBase):
|
|||
# Plugin interface
|
||||
name = 'HostTestPluginResetMethod_SiLabs'
|
||||
type = 'ResetMethod'
|
||||
stable = True
|
||||
capabilities = ['eACommander', 'eACommander-usb']
|
||||
required_parameters = ['disk']
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ from time import sleep, time
|
|||
from Queue import Queue, Empty
|
||||
from os.path import join, exists, basename
|
||||
from threading import Thread
|
||||
from subprocess import Popen, PIPE, call
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
# Imports related to mbed build api
|
||||
from workspace_tools.tests import TESTS
|
||||
|
@ -1255,64 +1255,6 @@ def singletest_in_cli_mode(single_test):
|
|||
report_exporter.report_to_file(test_summary_ext, single_test.opts_report_junit_file_name, test_suite_properties=test_suite_properties_ext)
|
||||
|
||||
|
||||
def mps2_set_board_image_file(disk, images_cfg_path, image0file_path, image_name='images.txt'):
|
||||
""" This function will alter image cfg file.
|
||||
Main goal of this function is to change number of images to 1, comment all
|
||||
existing image entries and append at the end of file new entry with test path.
|
||||
@return True when all steps succeed.
|
||||
"""
|
||||
MBED_SDK_TEST_STAMP = 'test suite entry'
|
||||
image_path = os.path.join(disk, images_cfg_path, image_name)
|
||||
new_file_lines = [] # New configuration file lines (entries)
|
||||
|
||||
# Check each line of the image configuration file
|
||||
try:
|
||||
with open(image_path, 'r') as file:
|
||||
for line in file:
|
||||
if re.search('^TOTALIMAGES', line):
|
||||
# Check number of total images, should be 1
|
||||
new_file_lines.append(re.sub('^TOTALIMAGES:[\t ]*[\d]+', 'TOTALIMAGES: 1', line))
|
||||
pass
|
||||
elif re.search('; - %s[\n\r]*$'% MBED_SDK_TEST_STAMP, line):
|
||||
# Look for test suite entries and remove them
|
||||
pass # Omit all test suite entries
|
||||
elif re.search('^IMAGE[\d]+FILE', line):
|
||||
# Check all image entries and mark the ';'
|
||||
new_file_lines.append(';' + line) # Comment non test suite lines
|
||||
else:
|
||||
# Append line to new file
|
||||
new_file_lines.append(line)
|
||||
except IOError as e:
|
||||
return False
|
||||
|
||||
# Add new image entry with proper commented stamp
|
||||
new_file_lines.append('IMAGE0FILE: %s ; - %s\r\n'% (image0file_path, MBED_SDK_TEST_STAMP))
|
||||
|
||||
# Write all lines to file
|
||||
try:
|
||||
with open(image_path, 'w') as file:
|
||||
for line in new_file_lines:
|
||||
file.write(line),
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def mps2_select_core(disk, mobo_config_name=""):
|
||||
""" Function selects actual core
|
||||
"""
|
||||
# TODO: implement core selection
|
||||
pass
|
||||
|
||||
|
||||
def mps2_switch_usb_auto_mounting_after_restart(disk, usb_config_name=""):
|
||||
""" Function alters configuration to allow USB MSD to be mounted after restarts
|
||||
"""
|
||||
# TODO: implement USB MSD restart detection
|
||||
pass
|
||||
|
||||
|
||||
class TestLogger():
|
||||
""" Super-class for logging and printing ongoing events for test suite pass
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue