diff options
author | Donghoon Shin <dhs.shin@samsung.com> | 2016-10-07 12:53:26 +0900 |
---|---|---|
committer | Donghoon Shin <dhs.shin@samsung.com> | 2016-10-07 12:54:03 +0900 |
commit | 0a59fcecd3b8d699b481e2e1f426b5a2b3d1a814 (patch) | |
tree | c99c02168e3e3f4dddf44c7015b5a73bba61220e | |
parent | d18421dd4559c5f334539fe5936a7e4182376e96 (diff) | |
download | litmus-0a59fcecd3b8d699b481e2e1f426b5a2b3d1a814.tar.gz litmus-0a59fcecd3b8d699b481e2e1f426b5a2b3d1a814.tar.bz2 litmus-0a59fcecd3b8d699b481e2e1f426b5a2b3d1a814.zip |
Support artik devices and more standalone devices
Change-Id: Ie555ec9b25496b307b2570cee2fd62e0cba3345b
38 files changed, 925 insertions, 23 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index a219c42..5655b55 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -13,13 +13,13 @@ Version 0.1.1 27 Jun 2016 - Turn off device if keyboard interrupt is raised while flashing or turning on device - Add timeout for all call/check_output to avoid hang issue -Version 0.2.0 9 Sep 2016 +Version 0.2.0 09 Sep 2016 --------------------------- - Remove acmlock routine to improve test performance - Support flash function for standalone device type - Update test helper functions -Version 0.2.1 9 Sep 2016 +Version 0.2.1 09 Sep 2016 --------------------------- - Update import command to use shell-like path expansions - Update standalone device type to avoid sdb error @@ -35,3 +35,7 @@ Version 0.3.0 21 Sep 2016 Version 0.3.1 22 Sep 2016 --------------------------- - Update cmd_rm handler + +Version 0.3.2 07 Oct 2016 +--------------------------- +- Support artik and more standalone device types @@ -31,7 +31,7 @@ Buliding & installing $ debuild -2. Install the deb package using dpkg +2. Install the deb package by using dpkg $ cd .. @@ -43,13 +43,13 @@ Getting started 1. Create a litmus project: - $ litmus mk <new_project_name> + $ litmus mk [project_name] -2. Modify <project_path>/userscript.py and <project_path>/conf.yaml +2. Modify [project_path]/userscript.py and [project_path]/conf.yaml 3. Run the litmus project - $ litmus run <new_project_name> + $ litmus run [project_name] Please refer to litmus wiki for more details. diff --git a/debian/changelog b/debian/changelog index 842a097..48b9aa1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +litmus (0.3.2-1) unstable; urgency=low + + * Support artik and more standalone device types + + -- Donghoon Shin <dhs.shin@samsung.com> Fri, 7 Oct 2016 11:14:00 +0900 + litmus (0.3.1-1) unstable; urgency=low * Update cmd_rm handler diff --git a/docs/source/litmus.core.rst b/docs/source/litmus.core.rst index 4c82e86..1f9e8c8 100644 --- a/docs/source/litmus.core.rst +++ b/docs/source/litmus.core.rst @@ -12,6 +12,7 @@ litmus.core.manager module :undoc-members: :show-inheritance: + litmus.core.util module ----------------------- diff --git a/litmus/__init__.py b/litmus/__init__.py index abbddaf..131d9e3 100644 --- a/litmus/__init__.py +++ b/litmus/__init__.py @@ -14,11 +14,11 @@ # limitations under the License. import os -__version__ = '0.3.1' +__version__ = '0.3.2' _homedir_ = os.path.expanduser('~') _confdir_ = os.path.join(_homedir_, '.litmus') _duts_ = os.path.join(_confdir_, 'topology') _projects_ = os.path.join(_confdir_, 'projects') _tmpdir_ = '/tmp' _path_for_locks_ = '/var/lock/litmus/' -_dev_types_ = ('u3', 'xu3', 'standalone', 'empty') +_dev_types_ = ('u3', 'xu3', 'artik5', 'artik10', 'standalone', 'empty') diff --git a/litmus/core/util.py b/litmus/core/util.py index 7851bdb..809c7af 100644 --- a/litmus/core/util.py +++ b/litmus/core/util.py @@ -182,6 +182,6 @@ def load_yaml(filename): :returns dict: parsed yaml data """ - with open(filename, 'r') as stream: + with open(os.path.expanduser(filename), 'r') as stream: data = yaml.load(stream) return data diff --git a/litmus/device/device.py b/litmus/device/device.py index 19c700c..981f7d5 100644 --- a/litmus/device/device.py +++ b/litmus/device/device.py @@ -214,7 +214,7 @@ class device(object): busid = self._find_usb_busid() self._release_global_lock() self._lthor(filenames=filenames, busid=busid) - self._cutter.off() + self.off() except (Exception, KeyboardInterrupt) as e: self._release_global_lock() logging.debug(e) @@ -520,14 +520,8 @@ class device(object): time.sleep(0.3) self._write_uart(b''.join([b'echo 1 > ', usb0_path, b'/enable'])) time.sleep(0.3) - - def check_funcs_sconf(): - """docstring for check_funcs_sconf""" - self._write_uart(b''.join([b'cat ', usb0_path, b'/funcs_sconf'])) - time.sleep(0.3) self._write_uart(b''.join([b'cat ', usb0_path, b'/enable'])) time.sleep(0.3) - self._read_uart(bufsize=1000) def get_serialnumber(): """docstring for get_serialnumber""" @@ -538,7 +532,6 @@ class device(object): retrycnt = 0 while retrycnt < 10: set_serialnumber(deviceid=self.get_id().encode()) - check_funcs_sconf() serialnumber = get_serialnumber() if find_pattern(pattern, serialnumber): return diff --git a/litmus/device/deviceartik10.py b/litmus/device/deviceartik10.py new file mode 100644 index 0000000..d8990c2 --- /dev/null +++ b/litmus/device/deviceartik10.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python3 +# Copyright 2015-2016 Samsung Electronics Co., Ltd. +# +# 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. + +import time +import logging +from threading import Thread +from litmus.device.device import device +from litmus.core.util import find_pattern +from litmus.core.exceptions import BootError + + +class deviceartik10(device): + """docstring for device""" + + _booting_time = 60 + _pattern_shellprompt = r'root.*> .*' + _pattern_bootprompt = r'ARTIK.*# .*' + + def __init__(self, *args, **kwargs): + self.args = args + self.kwargs = kwargs + self._name = kwargs['devicename'] + + self._open_uart() + self._manager = kwargs['manager'] + + def _release(self): + """docstring for _release""" + self._close_uart() + + def _wait_uart_shell_login_prompt(self): + """docstring for _wait_uart_shell_login_prompt""" + super(deviceartik10, self)._wait_uart_shell_login_prompt() + + def _set_sdb_deviceid(self): + """docstring for _set_sdb_deviceid""" + usb0_path = b'/sys/class/usb_mode/usb0' + pattern = '.*{0}'.format(self.get_id()) + + def set_serialnumber(deviceid): + """docstring for set_serialnumber""" + self._write_uart(b''.join([b'echo 0 > ', usb0_path, b'/enable'])) + time.sleep(0.3) + self._write_uart(b''.join([b'echo ', + b'-n ', + deviceid, + b' > ', usb0_path, + b'/iSerial'])) + time.sleep(0.3) + self._write_uart(b'direct_set_debug.sh --sdb-set') + time.sleep(0.5) + + def get_serialnumber(): + """docstring for get_serialnumber""" + self._write_uart(b''.join([b'cat ', usb0_path, b'/enable'])) + time.sleep(0.3) + self._write_uart(b''.join([b'cat ', usb0_path, b'/iSerial'])) + time.sleep(0.3) + return self._read_uart(1000) + + retrycnt = 0 + while retrycnt < 10: + set_serialnumber(deviceid=self.get_id().encode()) + serialnumber = get_serialnumber() + if find_pattern(pattern, serialnumber): + return + retrycnt += 1 + else: + raise Exception('Can\'t configure sdb deviceid') + + def _reboot(self): + """docstring for _reboot""" + status = self._current_uart_status() + + if status == 'LOGGED_IN': + self._write_uart(b'reboot') + time.sleep(3) + elif status == 'BOOT_PROMPT': + self._write_uart(b'reset') + time.sleep(3) + elif status == 'NOT_LOGGED_IN': + self._wait_uart_shell_login_prompt() + self._login_uart_shell() + self._write_uart(b'reboot') + time.sleep(3) + + def _current_uart_status(self): + """docstring for _current_uart_status""" + self._flush_uart_buffer() + for loop in range(3): + self._write_uart(b'') + readdata = self._read_uart(500) + if find_pattern(self._pattern_bootprompt, readdata): + return 'BOOT_PROMPT' + if find_pattern(self._pattern_shellprompt, readdata): + return 'LOGGED_IN' + else: + return 'NOT_LOGGED_IN' + + def _enter_download_mode(self, cmd, power_cut_delay=1, thread_param=10): + """docstring for _enter_download_mode""" + t = Thread(target=self._thread_for_enter_download_mode, + args=(cmd, thread_param, )) + status = self._current_uart_status() + if status == 'NOT_LOGGED_IN': + self._wait_uart_shell_login_prompt() + self._login_uart_shell() + t.start() + self._reboot() + t.join() + + def on(self, powercut_delay=3): + """ + Turn on the device acquired. + + :param float powercut_delay: power-cut delay for cutter + """ + logging.debug('=================Turn on device {}==================' + .format(self.get_name())) + retry_cnt = 0 + time.sleep(powercut_delay) + while retry_cnt <= self._max_attempt_boot_retry: + try: + self._reboot() + self._wait_uart_shell_login_prompt() + self._login_uart_shell() + self._set_sdb_deviceid() + self._attach_sdb() + self._sdb_root_on() + return + except KeyboardInterrupt: + raise Exception('Keyboard interrupt.') + except Exception as e: + logging.debug(e) + retry_cnt += 1 + else: + raise BootError('Cant\'t turn on dut.') + + def off(self, powercut_delay=2): + """ + Trun off the device acquired. + + :param float powercut_delay: power-cut delay for cutter + """ + logging.debug('off function is not supported for Artik device') diff --git a/litmus/device/deviceartik5.py b/litmus/device/deviceartik5.py new file mode 100644 index 0000000..bc4323e --- /dev/null +++ b/litmus/device/deviceartik5.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# Copyright 2015-2016 Samsung Electronics Co., Ltd. +# +# 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 litmus.device.deviceartik10 import deviceartik10 + + +class deviceartik5(deviceartik10): + """docstring for device""" + _pattern_bootprompt = r'ARITK.*# .*' diff --git a/litmus/device/devicestandalone.py b/litmus/device/devicestandalone.py new file mode 100644 index 0000000..a720896 --- /dev/null +++ b/litmus/device/devicestandalone.py @@ -0,0 +1,156 @@ +#!/usr/bin/env python3 +# Copyright 2015-2016 Samsung Electronics Co., Ltd. +# +# 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. + +import time +import logging +from litmus.device.device import device +from litmus.core.util import check_output, find_pattern +from litmus.core.util import call + + +class devicestandalone(device): + """ + Litmus device class. + User can control device in topology by this class methods. + """ + + _booting_time = 60 + + def __init__(self, *args, **kwargs): + self.args = args + self.kwargs = kwargs + self._name = kwargs['devicename'] + if 'serialno' in kwargs: + self._id = kwargs['serialno'] + else: + self._id = self._find_device_id() + + self._manager = kwargs['manager'] + + def _release(self): + """docstring for _release""" + pass + + def _find_device_id(self): + """docstring for _find_device_id""" + self.start_sdb_server() + outs = check_output(['sdb', 'devices'], timeout=10) + pattern = '.*List of devices attached \n([a-zA-Z0-9]*).*device.*' + found = find_pattern(pattern, outs, groupindex=1) + if found: + return found + + # public methods. + + def get_id(self): + """ + Return the id of acquired device. + Device instance uses this id for sdb connection. + + Example: + >>> dut = mgr.acquire_dut('xu3') + >>> dut.get_id() + 'XU3_001' + + :returns str: device id + """ + return self._id + + def on(self, booting_time=None): + """ + Turn on the device acquired. + + :param float powercut_delay: power-cut delay for cutter + """ + logging.debug('=================Turn on device {}==================' + .format(self.get_name())) + + self.start_sdb_server() + if self.is_on(): + self._sdb_root_on() + self.run_cmd('reboot -f', timeout=20) + wait_for_boot = booting_time if booting_time else self._booting_time + for loop in range(wait_for_boot): + logging.debug('Wait {} seconds......' + .format(wait_for_boot - loop)) + time.sleep(1) + self.start_sdb_server() + self._sdb_root_on() + + def off(self, powercut_delay=2): + """ + Trun off the device acquired. + + :param float powercut_delay: power-cut delay for cutter + """ + logging.debug('off function is not supported for standalone device') + + def flash(self, filenames, flasher='lthor', waiting=5, + partition_bin_mappings={'BOOT': 'zImage', + 'ROOTFS': 'rootfs.img', + 'USER': 'user.img', + 'SYSTEM-DATA': 'system-data.img'}): + """ + Flash binaries to device. + This function turn on device and turn off device automatically. + + :param dict filenames: filename string or dict + :param string flasher: external flashing tool name + :param float waiting: waiting time to acquire cdc_acm device + :param dict partition_bin_mappings: partition table for device which use heimdall flasher + + Example: + >>> dut.flash(['boot.tar.gz','platform.tar.gz']) + >>> or + >>> dut.flash('platform.tar.gz') + + """ + logging.debug('================Flash binaries to device============') + logging.debug(filenames) + + self.start_sdb_server() + + if not filenames: + raise Exception('There\'s no file to flash.') + try: + self._sdb_root_on() + self._acquire_global_lock() + self.run_cmd('reboot -f download', timeout=20) + time.sleep(waiting) + if flasher == 'lthor': + busid = self._find_usb_busid() + self._release_global_lock() + self._lthor(filenames=filenames, busid=busid) + elif flasher == 'heimdall': + (busaddr, devaddr) = self._find_usb_bus_and_device_address() + self._release_global_lock() + self._heimdall(filenames=filenames, + busaddr=busaddr, + devaddr=devaddr, + partition_bin_mappings=partition_bin_mappings) + except (Exception, KeyboardInterrupt) as e: + self._release_global_lock() + logging.debug(e) + raise Exception('Can\'t flash files : {}.'.format(filenames)) + + def refresh_sdb_server(self): + """docstring for refresh_sdb_server""" + call('sdb kill-server; sdb start-server', shell=True, timeout=10) + time.sleep(1) + + def start_sdb_server(self): + """docstring for start_sdb_server""" + call('sdb start-server', shell=True, timeout=10) + time.sleep(1) diff --git a/litmus/device/devicestandalone_m0.py b/litmus/device/devicestandalone_m0.py new file mode 100644 index 0000000..41cc556 --- /dev/null +++ b/litmus/device/devicestandalone_m0.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# Copyright 2015-2016 Samsung Electronics Co., Ltd. +# +# 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 litmus.device.devicestandalone import devicestandalone + + +class devicestandalone_m0(devicestandalone): + """docstring for device""" + pass + diff --git a/litmus/device/devicestandalone_tm1.py b/litmus/device/devicestandalone_tm1.py new file mode 100644 index 0000000..0cada07 --- /dev/null +++ b/litmus/device/devicestandalone_tm1.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# Copyright 2015-2016 Samsung Electronics Co., Ltd. +# +# 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 litmus.device.devicestandalone import devicestandalone + + +class devicestandalone_tm1(devicestandalone): + """docstring for device""" + pass + diff --git a/litmus/device/devicestandalone_tm2.py b/litmus/device/devicestandalone_tm2.py new file mode 100644 index 0000000..79cb68b --- /dev/null +++ b/litmus/device/devicestandalone_tm2.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# Copyright 2015-2016 Samsung Electronics Co., Ltd. +# +# 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 litmus.device.devicestandalone import devicestandalone + + +class devicestandalone_tm2(devicestandalone): + """docstring for device""" + pass + diff --git a/litmus/device/devicestandalone_tw1.py b/litmus/device/devicestandalone_tw1.py new file mode 100644 index 0000000..fe459e8 --- /dev/null +++ b/litmus/device/devicestandalone_tw1.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# Copyright 2015-2016 Samsung Electronics Co., Ltd. +# +# 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 litmus.device.devicestandalone import devicestandalone + + +class devicestandalone_tw1(devicestandalone): + """docstring for device""" + pass + diff --git a/litmus/device/devicestandalone_u3.py b/litmus/device/devicestandalone_u3.py new file mode 100644 index 0000000..9517b1e --- /dev/null +++ b/litmus/device/devicestandalone_u3.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# Copyright 2015-2016 Samsung Electronics Co., Ltd. +# +# 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 litmus.device.devicestandalone import devicestandalone + + +class devicestandalone_u3(devicestandalone): + """docstring for device""" + pass + diff --git a/litmus/device/devicestandalone_xu3.py b/litmus/device/devicestandalone_xu3.py new file mode 100644 index 0000000..08bc420 --- /dev/null +++ b/litmus/device/devicestandalone_xu3.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# Copyright 2015-2016 Samsung Electronics Co., Ltd. +# +# 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 litmus.device.devicestandalone import devicestandalone + + +class devicestandalone_xu3(devicestandalone): + """docstring for device""" + pass + diff --git a/litmus/device/devicestandalone_z1.py b/litmus/device/devicestandalone_z1.py new file mode 100644 index 0000000..8a85f76 --- /dev/null +++ b/litmus/device/devicestandalone_z1.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# Copyright 2015-2016 Samsung Electronics Co., Ltd. +# +# 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 litmus.device.devicestandalone import devicestandalone + + +class devicestandalone_z1(devicestandalone): + """docstring for device""" + pass + diff --git a/litmus/helper/helper.py b/litmus/helper/helper.py index 2665a12..26a8cf2 100644 --- a/litmus/helper/helper.py +++ b/litmus/helper/helper.py @@ -18,6 +18,7 @@ import sys import time import logging import requests +import litmus import urllib.parse from bs4 import BeautifulSoup from litmus.core.util import find_pattern, find_all_pattern @@ -173,10 +174,11 @@ def install_plugin(dut, script, waiting=5, timeout=180): import os +import tempfile import shutil from subprocess import DEVNULL -def install_plugin_from_git(dut, url, branch, script, tmpdir='repo', +def install_plugin_from_git(dut, url, branch, script, waiting=5, timeout=180, commitid=None): """ Clone a git project which include tizen plugins and install the plugins on device. @@ -186,7 +188,6 @@ def install_plugin_from_git(dut, url, branch, script, tmpdir='repo', :param str url: url for git project :param str branch: branch name of the git project :param str script: script path to install plugins on device - :param str tmpdir: temporary directory to clone the git project :param float waiting: wait time before installing plugins :param float timeout: timeout :param str commitid: commitid which you want to clone @@ -210,6 +211,8 @@ def install_plugin_from_git(dut, url, branch, script, tmpdir='repo', logging.debug('plugin install script : {}'.format(script)) dut.on() + tmpdir = next(tempfile._get_candidate_names()) + call('git clone {0} {1} --branch {2}'.format(url, tmpdir, branch), shell=True) @@ -220,15 +223,13 @@ def install_plugin_from_git(dut, url, branch, script, tmpdir='repo', call('find ./{0} -exec perl -pi -e "s/sdb\s+(-d\s+)*(root|shell|push|pull)/sdb -s {1} \\2/g" {{}} \;'.format(tmpdir, dut.get_id()), stderr=DEVNULL, shell=True) call('find ./{0} -exec perl -pi -e "s/sdb\s+.*reboot.*//g" {{}} \;'.format(tmpdir), stderr=DEVNULL, shell=True) - script = os.path.join(tmpdir, script) - script_path = '/'.join(script.split('/')[:-1]) script_name = script.split('/')[-1] - call('cp -R {0}/* .'.format(script_path), shell=True) time.sleep(waiting) - call('sh {0}'.format(script_name).split(), timeout=timeout) + call('cd {0}/{1} && sh {2}'.format(tmpdir, script_path, script_name), + shell=True, timeout=timeout) shutil.rmtree(tmpdir) dut.off() diff --git a/litmus/templates/artik10/__init__.py b/litmus/templates/artik10/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/litmus/templates/artik10/__init__.py diff --git a/litmus/templates/artik10/conf.yaml b/litmus/templates/artik10/conf.yaml new file mode 100644 index 0000000..5b81875 --- /dev/null +++ b/litmus/templates/artik10/conf.yaml @@ -0,0 +1,5 @@ +binary_urls: + - http://download.tizen.org/snapshots/tizen/common/latest/images/arm-wayland/common-wayland-3parts-armv7l-artik/ + - http://download.tizen.org/snapshots/tizen/common/latest/images/arm-wayland/common-boot-armv7l-artik10/ +username: <username> +password: <password> diff --git a/litmus/templates/artik10/misc/autoinput b/litmus/templates/artik10/misc/autoinput Binary files differnew file mode 100755 index 0000000..88d78e3 --- /dev/null +++ b/litmus/templates/artik10/misc/autoinput diff --git a/litmus/templates/artik10/misc/getevent b/litmus/templates/artik10/misc/getevent Binary files differnew file mode 100755 index 0000000..66e2c2a --- /dev/null +++ b/litmus/templates/artik10/misc/getevent diff --git a/litmus/templates/artik10/tc.yaml b/litmus/templates/artik10/tc.yaml new file mode 100644 index 0000000..abaa181 --- /dev/null +++ b/litmus/templates/artik10/tc.yaml @@ -0,0 +1,32 @@ +testcases: + - name: verify_process_is_running + from: litmus.helper.tests + result_dir: result + plan: + - name: dbus_is_running + param: dbus + pattern: .*/usr/bin/dbus-daemon.* + - name: enlightenment_is_running + param: enlightenment + pattern: .*/usr/bin/enlightenment.* + - name: sensord_is_running + param: sensord + pattern: .*/usr/bin/sensord.* + - name: deviced_is_running + param: deviced + pattern: .*/usr/bin/deviced.* + - name: pulseaudio_is_running + param: pulseaudio + pattern: .*/usr/bin/pulseaudio.* + - name: sdbd_is_running + param: sdbd + pattern: .*/usr/sbin/sdbd.* + - name: alarm-server_is_running + param: alarm-server + pattern: .*/usr/bin/alarm-server.* + - name: sound_server_is_running + param: sound_server + pattern: .*/usr/bin/sound_server.* + - name: media-server_is_running + param: media-server + pattern: .*/usr/bin/media-server.* diff --git a/litmus/templates/artik10/userscript.py b/litmus/templates/artik10/userscript.py new file mode 100755 index 0000000..be6c41a --- /dev/null +++ b/litmus/templates/artik10/userscript.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +import os +from litmus.core.util import load_yaml +from litmus.core.manager import manager +from litmus.helper.helper import tizen_snapshot_downloader as downloader +from litmus.helper.helper import install_plugin_from_git +from litmus.helper.tests import add_test_helper + + +def main(*args, **kwargs): + + # init manager instance + mgr = manager(*args, **kwargs) + + # init working directory + mgr.init_workingdir() + + # get projectinfo + project_info = load_yaml('conf.yaml') + + username = project_info['username'] + password = project_info['password'] + binary_urls = project_info['binary_urls'] + plugin_info = project_info['plugin_info'] + + # get version from parameter + try: + version = kwargs['param'][0] + except (IndexError, TypeError): + version = None + + # download binaries from snapshot download server + filenames = [] + for url in binary_urls: + filenames.extend(downloader(url=url, + username=username, + password=password, + version=version)) + + # get an available device for testing. + dut = mgr.acquire_dut('artik10', max_retry_times=180) + + # flashing binaries to device. + dut.flash(filenames) + + # install plugins + install_plugin_from_git(dut, + plugin_info['url'].format(username=username), + plugin_info['branch'], + plugin_info['script']) + + # turn on dut. + dut.on() + + # run helper functions for testing. + if not os.path.exists('result'): + os.mkdir('result') + + testcases = load_yaml('tc.yaml') + add_test_helper(dut, testcases) + dut.run_tests() + + # turn off dut. + dut.off() + + # release a device + mgr.release_dut(dut) diff --git a/litmus/templates/artik5/__init__.py b/litmus/templates/artik5/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/litmus/templates/artik5/__init__.py diff --git a/litmus/templates/artik5/conf.yaml b/litmus/templates/artik5/conf.yaml new file mode 100644 index 0000000..7e90ffe --- /dev/null +++ b/litmus/templates/artik5/conf.yaml @@ -0,0 +1,5 @@ +binary_urls: + - http://download.tizen.org/snapshots/tizen/common/latest/images/arm-wayland/common-wayland-3parts-armv7l-artik/ + - http://download.tizen.org/snapshots/tizen/common/latest/images/arm-wayland/common-boot-armv7l-artik5/ +username: <username> +password: <password> diff --git a/litmus/templates/artik5/misc/autoinput b/litmus/templates/artik5/misc/autoinput Binary files differnew file mode 100755 index 0000000..88d78e3 --- /dev/null +++ b/litmus/templates/artik5/misc/autoinput diff --git a/litmus/templates/artik5/misc/getevent b/litmus/templates/artik5/misc/getevent Binary files differnew file mode 100755 index 0000000..66e2c2a --- /dev/null +++ b/litmus/templates/artik5/misc/getevent diff --git a/litmus/templates/artik5/tc.yaml b/litmus/templates/artik5/tc.yaml new file mode 100644 index 0000000..abaa181 --- /dev/null +++ b/litmus/templates/artik5/tc.yaml @@ -0,0 +1,32 @@ +testcases: + - name: verify_process_is_running + from: litmus.helper.tests + result_dir: result + plan: + - name: dbus_is_running + param: dbus + pattern: .*/usr/bin/dbus-daemon.* + - name: enlightenment_is_running + param: enlightenment + pattern: .*/usr/bin/enlightenment.* + - name: sensord_is_running + param: sensord + pattern: .*/usr/bin/sensord.* + - name: deviced_is_running + param: deviced + pattern: .*/usr/bin/deviced.* + - name: pulseaudio_is_running + param: pulseaudio + pattern: .*/usr/bin/pulseaudio.* + - name: sdbd_is_running + param: sdbd + pattern: .*/usr/sbin/sdbd.* + - name: alarm-server_is_running + param: alarm-server + pattern: .*/usr/bin/alarm-server.* + - name: sound_server_is_running + param: sound_server + pattern: .*/usr/bin/sound_server.* + - name: media-server_is_running + param: media-server + pattern: .*/usr/bin/media-server.* diff --git a/litmus/templates/artik5/userscript.py b/litmus/templates/artik5/userscript.py new file mode 100755 index 0000000..ccfb88e --- /dev/null +++ b/litmus/templates/artik5/userscript.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +import os +from litmus.core.util import load_yaml +from litmus.core.manager import manager +from litmus.helper.helper import tizen_snapshot_downloader as downloader +from litmus.helper.helper import install_plugin_from_git +from litmus.helper.tests import add_test_helper + + +def main(*args, **kwargs): + + # init manager instance + mgr = manager(*args, **kwargs) + + # init working directory + mgr.init_workingdir() + + # get projectinfo + project_info = load_yaml('conf.yaml') + + username = project_info['username'] + password = project_info['password'] + binary_urls = project_info['binary_urls'] + plugin_info = project_info['plugin_info'] + + # get version from parameter + try: + version = kwargs['param'][0] + except (IndexError, TypeError): + version = None + + # download binaries from snapshot download server + filenames = [] + for url in binary_urls: + filenames.extend(downloader(url=url, + username=username, + password=password, + version=version)) + + # get an available device for testing. + dut = mgr.acquire_dut('artik5', max_retry_times=180) + + # flashing binaries to device. + dut.flash(filenames) + + # install plugins + install_plugin_from_git(dut, + plugin_info['url'].format(username=username), + plugin_info['branch'], + plugin_info['script']) + + # turn on dut. + dut.on() + + # run helper functions for testing. + if not os.path.exists('result'): + os.mkdir('result') + + testcases = load_yaml('tc.yaml') + add_test_helper(dut, testcases) + dut.run_tests() + + # turn off dut. + dut.off() + + # release a device + mgr.release_dut(dut) diff --git a/litmus/templates/standalone/__init__.py b/litmus/templates/standalone/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/litmus/templates/standalone/__init__.py diff --git a/litmus/templates/standalone/conf_mobile.yaml b/litmus/templates/standalone/conf_mobile.yaml new file mode 100644 index 0000000..072e0d7 --- /dev/null +++ b/litmus/templates/standalone/conf_mobile.yaml @@ -0,0 +1,4 @@ +binary_urls: + - http://download.tizen.org/snapshots/tizen/mobile/latest/images/target-TM1/mobile-wayland-armv7l-tm1/ +username: <username> +password: <password> diff --git a/litmus/templates/standalone/conf_tv.yaml b/litmus/templates/standalone/conf_tv.yaml new file mode 100644 index 0000000..43a1164 --- /dev/null +++ b/litmus/templates/standalone/conf_tv.yaml @@ -0,0 +1,5 @@ +binary_urls: + - http://download.tizen.org/snapshots/tizen/tv/latest/images/arm-wayland/tv-boot-armv7l-odroidxu3/ + - http://download.tizen.org/snapshots/tizen/tv/latest/images/arm-wayland/tv-wayland-armv7l-odroidu3/ +username: <username> +password: <password> diff --git a/litmus/templates/standalone/conf_wearable.yaml b/litmus/templates/standalone/conf_wearable.yaml new file mode 100644 index 0000000..eb9cbca --- /dev/null +++ b/litmus/templates/standalone/conf_wearable.yaml @@ -0,0 +1,4 @@ +binary_urls: + - http://download.tizen.org/snapshots/tizen/wearable/latest/images/target-circle/wearable-wayland-armv7l-circle/ +username: <username> +password: <password> diff --git a/litmus/templates/standalone/tc_mobile.yaml b/litmus/templates/standalone/tc_mobile.yaml new file mode 100644 index 0000000..7932170 --- /dev/null +++ b/litmus/templates/standalone/tc_mobile.yaml @@ -0,0 +1,50 @@ +testcases: + - name: verify_process_is_running + from: litmus.helper.tests + result_dir: result + plan: + - name: dbus_is_running + param: dbus + pattern: .*/usr/bin/dbus-daemon.* + - name: enlightenment_is_running + param: enlightenment + pattern: .*/usr/bin/enlightenment.* + - name: sensord_is_running + param: sensord + pattern: .*/usr/bin/sensord.* + - name: deviced_is_running + param: deviced + pattern: .*/usr/bin/deviced.* + - name: pulseaudio_is_running + param: pulseaudio + pattern: .*/usr/bin/pulseaudio.* + - name: sdbd_is_running + param: sdbd + pattern: .*/usr/sbin/sdbd.* + - name: msg-server_is_running + param: msg-server + pattern: .*/usr/bin/msg-server.* + - name: connmand_is_running + param: connmand + pattern: .*/usr/sbin/connmand.* + - name: callmgrd_is_running + param: callmgrd + pattern: .*/usr/bin/callmgrd.* + - name: alarm-server_is_running + param: alarm-server + pattern: .*/usr/bin/alarm-server.* + - name: media-server_is_running + param: media-server + pattern: .*/usr/bin/media-server.* + - name: verify_dmesg + from: litmus.helper.tests + result_dir: result + plan: + - name: panel_is_alive + param: panel + pattern: .*panel is dead.* + - name: verify_wifi_is_working + from: litmus.helper.tests + wifi_apname: setup + wifi_password: + result_dir: result diff --git a/litmus/templates/standalone/tc_tv.yaml b/litmus/templates/standalone/tc_tv.yaml new file mode 100644 index 0000000..44ed8a2 --- /dev/null +++ b/litmus/templates/standalone/tc_tv.yaml @@ -0,0 +1,23 @@ +testcases: + - name: verify_process_is_running + from: litmus.helper.tests + result_dir: result + plan: + - name: enlightenment_is_running + param: enlightenment + pattern: .*/usr/bin/enlightenment.* + - name: deviced_is_running + param: deviced + pattern: .*/usr/bin/deviced.* + - name: pulseaudio_is_running + param: pulseaudio + pattern: .*/usr/bin/pulseaudio.* + - name: sdbd_is_running + param: sdbd + pattern: .*/usr/sbin/sdbd.* + - name: alarm-server_is_running + param: alarm-server + pattern: .*/usr/bin/alarm-server.* + - name: media-server_is_running + param: media-server + pattern: .*/usr/bin/media-server.* diff --git a/litmus/templates/standalone/tc_wearable.yaml b/litmus/templates/standalone/tc_wearable.yaml new file mode 100644 index 0000000..f1c099f --- /dev/null +++ b/litmus/templates/standalone/tc_wearable.yaml @@ -0,0 +1,50 @@ +testcases: + - name: verify_process_is_running + from: litmus.helper.tests + result_dir: result + plan: + - name: dbus_is_running + param: dbus + pattern: .*/usr/bin/dbus-daemon.* + - name: enlightenment_is_running + param: enlightenment + pattern: .*/usr/bin/enlightenment.* + - name: sensord_is_running + param: sensord + pattern: .*/usr/bin/sensord.* + - name: deviced_is_running + param: deviced + pattern: .*/usr/bin/deviced.* + - name: pulseaudio_is_running + param: pulseaudio + pattern: .*/usr/bin/pulseaudio.* + - name: sdbd_is_running + param: sdbd + pattern: .*/usr/sbin/sdbd.* + - name: msg-server_is_running + param: msg-server + pattern: .*/usr/bin/msg-server.* + - name: connmand_is_running + param: connmand + pattern: .*/usr/sbin/connmand.* + - name: alarm-server_is_running + param: alarm-server + pattern: .*/usr/bin/alarm-server.* + - name: sound_server_is_running + param: sound_server + pattern: .*/usr/bin/sound_server.* + - name: media-server_is_running + param: media-server + pattern: .*/usr/bin/media-server.* + - name: verify_dmesg + from: litmus.helper.tests + result_dir: result + plan: + - name: panel_is_alive + param: panel + pattern: .*panel is dead.* + - name: verify_wifi_is_working + from: litmus.helper.tests + wifi_apname: setup + wifi_password: + result_dir: result diff --git a/litmus/templates/standalone/userscript.py b/litmus/templates/standalone/userscript.py new file mode 100755 index 0000000..b799b63 --- /dev/null +++ b/litmus/templates/standalone/userscript.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +import os +from litmus.core.util import load_yaml +from litmus.core.manager import manager +from litmus.helper.helper import tizen_snapshot_downloader as downloader +from litmus.helper.tests import add_test_helper + + +def main(*args, **kwargs): + + # init manager instance + mgr = manager(*args, **kwargs) + + # init working directory + mgr.init_workingdir() + + # get projectinfo + project_info = load_yaml('conf_mobile.yaml') + #project_info = load_yaml('conf_wearable.yaml') + #project_info = load_yaml('conf_tv.yaml') + + username = project_info['username'] + password = project_info['password'] + binary_urls = project_info['binary_urls'] + + # get version from parameter + # ex) 20160923.3 + try: + version = kwargs['param'][0] + except (IndexError, TypeError): + version = None + + # download binaries from snapshot download server + filenames = [] + for url in binary_urls: + filenames.extend(downloader(url=url, + username=username, + password=password, + version=version)) + + # get an available device for testing. + dut = mgr.acquire_dut('standalone', max_retry_times=180) + #dut = mgr.acquire_dut_by_name('MyTM1', max_retry_times=180) + + # flashing binaries to device. + dut.flash(filenames) + + # turn on dut. + dut.on() + + # run helper functions for testing. + if not os.path.exists('result'): + os.mkdir('result') + + testcases = load_yaml('tc_mobile.yaml') + #testcases = load_yaml('tc_wearable.yaml') + #testcases = load_yaml('tc_tv.yaml') + add_test_helper(dut, testcases) + dut.run_tests() + + # turn off dut. + dut.off() + + # release a device + mgr.release_dut(dut) |