def __init__(self, *args, **kwargs):
"""
:param str topology: topology file path
- :param str project_path: project path. If this is None then cwd will be used as project path
+ :param str project_path: project path. If this is None then cwd will \
+ be used as project path
:param bool verbose: init logger to print all logs
"""
super(manager, self).__init__()
os.chdir(self._workingdir)
else:
workingdir_name = str((hashlib.sha1(str(datetime.now())
- .encode()).hexdigest()))
+ .encode()).hexdigest()))
workspace_path = os.path.join(self._tmpdir, workingdir_name)
os.mkdir(workspace_path)
os.chdir(workspace_path)
class device(object):
"""
Litmus device class.
- User can control device in topology by this class methods.
+ User can control device in topology by these class methods.
"""
_baudrate = 115200
def on(self, powercut_delay=1):
"""
- Turn on the device acquired.
+ Turn on the acquired device.
:param float powercut_delay: power-cut delay for cutter
+
+ Example:
+ >>> dut.on()
+
"""
logging.debug('=================Turn on device {}=================='
.format(self.get_name()))
def off(self, powercut_delay=1):
"""
- Trun off the device acquired.
+ Trun off the acquired device.
:param float powercut_delay: power-cut delay for cutter
+
+ Example:
+ >>> dut.off()
+
"""
logging.debug('=================Turn off device {}================='
.format(self.get_name()))
def _screenshot_wayland(self, filename):
"""docstring for _screenshot_wayland"""
# Find all viewable window id
- p_winid = '.*(0x[a-zA-Z0-9]{8})\s+\d+\s+\d+\s+\d+\s+\d+\s+(\d+)\s+(\d+).*\sViewable.*'
+ p_winid = '.*(0x[a-zA-Z0-9]{8})\s+\d+\s+\d+\s+\d+' \
+ '\s+\d+\s+(\d+)\s+(\d+).*\sViewable.*'
winids = find_all_pattern(p_winid,
self.run_cmd('enlightenment_info -topvwins',
timeout=20))
logging.debug(tar_cmd)
call(tar_cmd, shell=True, timeout=30)
- heimdall_cmd = 'heimdall flash --usbbus {0} --usbdevaddr {1}'.format(busaddr, devaddr)
+ heimdall_cmd = 'heimdall flash --usbbus {0}' \
+ ' --usbdevaddr {1}'.format(busaddr, devaddr)
for key, elem in partition_bin_mappings.items():
heimdall_cmd += ' --{}'.format(key)
heimdall_cmd += ' {}'.format(elem)
pass
def sdb_root_on(self):
- """docstring for sdb_root_on"""
+ """
+ Set root mode of device
+
+ Example:
+ >>> dut.sdb_root_on()
+
+ """
logging.debug('=================sdb root on for {}=================='
.format(self.get_name()))
call('sdb -s {} root on'.format(self.get_id()).split(), timeout=10)
class devicestandalone(device):
"""
Litmus device class.
- User can control device in topology by this class methods.
+ User can control device in topology by these class methods.
"""
_booting_time = 60
: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
+ :param dict partition_bin_mappings: partition table for device which \
+ use heimdall flasher
Example:
>>> dut.flash(['boot.tar.gz','platform.tar.gz'])
self.run_cmd('reboot -f download', timeout=20)
time.sleep(waiting)
if flasher == 'lthor':
- if self._usbid == None:
+ if self._usbid is None:
busid = self._find_usb_busid()
else:
busid = self._usbid
p = '.*Microchip Technology.*'
try:
smartpower_names = ['/dev/{}'.format(s)
- for s in check_output('ls /dev | grep hidraw',
+ for s in check_output('ls /dev '
+ '| grep hidraw',
shell=True).split()
if find_pattern(p, check_output(['cat',
- '/sys/class/hidraw/{}/device/uevent'.format(s)]))]
+ '/sys/'
+ 'class/'
+ 'hidraw/'
+ '{}/'
+ 'device/'
+ 'uevent'
+ .format(s)
+ ]))]
except AttributeError:
smartpower_names = []
logging.debug('smart powers : {0}'.format(smartpower_names))
"""docstring for enter_bootloader_prompt"""
# create threads for entering bootloader prompt
- delay = (5 + (len(self.cleware4s) * 2 * 4 + len(self.smartpowers) * 2 * 2)) * 30
+ delay = (5 + (len(self.cleware4s) * 2 * 4 +
+ len(self.smartpowers) * 2 * 2)) * 30
threads = []
for l in self.uarts:
# recognize device type
for l in self.uarts:
- logging.debug('[Recognize device type for uart : {}]'.format(l.name))
+ logging.debug('[Recognize device type for uart : '
+ '{}]'.format(l.name))
cfg = self.recognize_device(config, l)
if cfg:
cfgs.append(cfg)
import re
import sys
import time
+import shutil
import logging
import requests
+import tempfile
import urllib.parse
+from subprocess import DEVNULL
from bs4 import BeautifulSoup
from litmus.core.util import find_pattern, find_all_pattern
from litmus.core.util import call
def tizen_snapshot_downloader(url, pattern_bin='tar.gz$',
username='', password='',
- pattern_version='tizen[a-zA-Z0-9-_.^/]*[0-9]{8}.[0-9]{1,2}',
+ pattern_version='tizen[a-zA-Z0-9-_.^/]'
+ '*[0-9]{8}.[0-9]{1,2}',
version=None,
timeout=10,
maxretry=20,
"""
Download snapshot images from web server.
- :param str url: url for downloading binaries. This has to include 'latest' string
- :param str pattern_bin: filename pattern to find correct binary under the url
+ :param str url: url for downloading binaries. This has to include \
+ 'latest' string
+ :param str pattern_bin: filename pattern to find correct binary \
+ under the url
:param str username: username to access http server
:param str password: password to access http server
:param str pattern_version: pattern of tizen snapshot version string
- :param str version: specific version string of tizen snapshot what you want to download
+ :param str version: specific version string of tizen snapshot \
+ what you want to download
:param float timeout: timeout
:param int maxretry: max retry count to attempt the url for downloading
:param float waiting_for_retry: delay for each retry
Example:
>>> from litmus.helper.helper import tizen_snapshot_downloader
- >>> tizen_snapshot_downloader(url=\'http://download.tizen.org/snapshots/tizen/tv/latest/images/arm-wayland/tv-wayland-armv7l-odroidu3/\')
+ >>> tizen_snapshot_downloader(
+ url='http://download.tizen.org/snapshots/tizen/tv/latest/images/arm-wayland/tv-wayland-armv7l-odroidu3/')
[\'tizen-tv_20160516.2_tv-wayland-armv7l-odroidu3.tar.gz\']
:returns list: filenames of downloaded binaries
soup = BeautifulSoup(f.text, 'html.parser')
filenames = []
- for l in soup.findAll('a', attrs={'href': re.compile(pattern_bin)}):
+ for l in soup.findAll('a',
+ attrs={'href': re.compile(pattern_bin)}):
filename = l['href']
fileurl = urllib.parse.urljoin(url, filename)
logging.debug(fileurl)
stream=True)
total_length = resp.headers.get('Content-Length')
-
+ cs = 1024 * 1024
if total_length is None:
f.write(resp.content)
else:
downloaded_data = 0
total_length = int(total_length)
- for download_data in resp.iter_content(chunk_size=1024 * 1024):
+ for download_data in resp.iter_content(chunk_size=cs):
downloaded_data += len(download_data)
f.write(download_data)
done = int(50 * downloaded_data / total_length)
sys.stdout.write('\r[{0}{1}]'.format('#'*done,
- ' '*(50-done)))
+ ' '*(50-done)
+ ))
sys.stdout.flush()
logging.debug('')
filenames.append(filename)
return filenames
-import tempfile
-import shutil
-from subprocess import DEVNULL
-
-
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.
+ Clone a git project which include tizen plugins and install the plugins \
+ on device.
This helper function turn on device and turn off device automatically.
:param device dut: device instance
:param float timeout: timeout
:param str commitid: commitid which you want to clone
- .. note:: You have to configure your open-ssh key if you want to use ssh protocol to clone the git project.
+ .. note:: You have to configure your open-ssh key if you want to use ssh \
+ protocol to clone the git project.
Example:
>>> from litmus.helper.helper import install_plugin_from_git
call('git --git-dir={0}/.git checkout {1}'.format(tmpdir, commitid),
shell=True)
- 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)
+ 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_path = '/'.join(script.split('/')[:-1])
script_name = script.split('/')[-1]
import os
import re
import sys
+import time
+import queue
import logging
import subprocess
+from threading import Thread
+from litmus.core.util import convert_single_item_to_list
def add_test_helper(dut, testcases):
tc.yaml example:
>>> 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: verify_dmesg
- from: litmus.helper.tests
- result_dir : result
- plan:
- -
- name: panel_is_alive
- param: panel
- pattern: .*panel is dead.*
+ - 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: verify_dmesg
+ from: litmus.helper.tests
+ result_dir: result
+ plan:
+ - name: panel_is_alive
+ param: panel
+ pattern: .*panel is dead.*
"""
Example:
>>> from litmus.helper.tests import verify_process_is_running
>>> verify_wifi_is_working(dut,
- [{\'name\': \'dbus_is_running\',
- \'param\': \'dbus\',
- \'pattern\': \'.*/usr/bin/dbus-daemon.*\'},
- {\'name\': \'deviced_is_runing\',
- \'param\': \'deviced\',
- \'pattern\': \'.*/usr/bin/deviced.*\'},
+ [{'name': 'dbus_is_running',
+ 'param': 'dbus',
+ 'pattern': '.*/usr/bin/dbus-daemon.*'},
+ {'name': 'deviced_is_runing',
+ 'param': 'deviced',
+ 'pattern': '.*/usr/bin/deviced.*'},
],
- \'result\')
+ 'result')
"""
test_name = 'verify_process_is_running'
def _save_result(result, result_dir):
"""docstring for _save_result"""
- with open(os.path.join(result_dir, 'testresult_process_is_running.xml'), 'w') as f:
+ with open(os.path.join(result_dir,
+ 'testresult_process_is_running.xml'), 'w') as f:
f.write(result)
_save_result(_run(), os.path.abspath(result_dir))
_save_result(_run(), os.path.abspath(result_dir))
-import time
-import queue
-from threading import Thread
-from litmus.core.util import convert_single_item_to_list
-
-
def verify_wifi_is_working(dut, wifi_apname, wifi_password, result_dir):
"""
Try to connect wifi ap and publish the test result as a xml file.
if wifi_password and wifi_password != '':
_write_cmd(wifi_password,
'Connection step finished',
- ['Wi-Fi Activation Failed! error : OPERATION_FAILED',
- 'Device state changed callback, state : Deactivated',
+ ['Wi-Fi Activation Failed! error : '
+ 'OPERATION_FAILED',
+ 'Device state changed callback, state : '
+ 'Deactivated',
'Operation failed!'])
_write_cmd('6',
['Success to get connection state : Connected',
'Device state changed callback, state : Deactivated',
'Operation failed!',
'Success to get connection state : Disconnected',
- 'Connection state changed callback, state : Disconnected, AP name : {}'.format(wifi_apname)])
+ 'Connection state changed callback, state : '
+ 'Disconnected, AP name : {}'.format(wifi_apname)])
_write_cmd('0', 'exit', None)
dict_for_output = {'tc_name': test_name,
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
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 adhoc_parser(parser):
"""run litmus project which is not imported.
- This will run litmus project which is not imported help you to use CI for
- testing. If you use seperated worker node of CI for running test project,
- just copy project directory to worker node and use this command. If not,
- you have to import litmus project on worker node before run it.
+ This will run litmus test project which is not imported. This command helps
+ you to use litmus with CI tool for testing. If you use seperated worker
+ node of CI tool for running test project, just copy project directory to
+ worker node and use this command. If not, you have to import litmus project
+ on worker node before running test.
Examples:
$ litmus adhoc <project_path>
def mk_parser(parser):
"""make new litmus project.
- This will create a new directory for project and copy default templates.
- You can locate more files and test scripts under this project directory
- and run it with project name.
+ This will create new directory for project based on default templates.
+ You can locate more files and test scripts under new project directory to
+ customize your test project.
Examples:
$ litmus mk <project_name>
def rm_parser(parser):
"""remove litmus project.
- This will remove both of your litmus project and project directory from
- your host. WARNING: You can not recover your test project sources after
- run this command.
+ This will remove both of your litmus project from project list and project
+ directory from your host file system.
+ WARNING: You can't recover your test project after run this command.
Examples:
$ litmus rm <project_name>
def run_parser(parser):
"""run litmus project.
- This will run your litmus project. Project entry point is userscript.py in
- your project directory. You can pass argument to project with -p option.
+ This will run your litmus project. Project's entry point is userscript.py
+ in your project directory. You can pass argument to project with -p option.
You can also set working directory with -d option. If you don't set working
directory then litmus creates a temporary directory under /tmp and run test
on it, and remove it if test has done. Hence you have to use -d option to
- keep test result and workspace.
+ keep test result and test workspace.
Examples:
$ litmus run <project_name>
def ls_parser(parser):
"""list all litmus projects.
- This will list all litmus projects on your host. Default project list is
- located in ~/.litmus/projects.
+ This will list all litmus projects on your host. Default project list file
+ is located at ~/.litmus/projects.
Examples:
$ litmus ls
This will list all available test devices in topology configuration.
If you want to run test with real device, you have to set up topology
- configuration. Default topology file is located in ~/.litmus/topology.
+ configuration properly before testing.
+ Default topology file is located at ~/.litmus/topology.
Topology file example for standalone_tm1 is:
def gt_parser(parser):
"""generate topology configuration.
- This is a helper to generate topology configuration for non-standalone
- devices. non-standalone device means that device is controlled by external
- uart and power supply. xu3 and u3 device types are non-standard device.
- This will find proper uart port and power supply node from your system.
- Do not run this command if you use standalone type devices.
+ This is a helper to generate topology configuration automatically
+ for non-standalone devices. non-standalone device means that device is
+ controlled by external uart and power supply.
+ xu3 and u3 device types are non-standard devices.
+ This will find proper uart port and power supply node for your
+ non-standalone device from your system and make configurations.
+ Don't run this command if you use standalone type devices only. This
+ regenerate topology file then you will lose your configuration.
Examples:
$ litmus gt
def cp_parser(parser):
"""copy litmus project.
- This will create new litmus project from existed one. New project has
- duplicated project directory from origin project and does not use default
- template for project.
+ This will create new litmus project from existed one. New project duplicate
+ files from origin project directory.
Examples:
$ litmus cp <origin project name> <new project name>
"""import litmus project.
This command will import litmus project. Import means that add new project
- authored by others into project list on your host.
+ which authored by others to project list on your host. If you get new test
+ project from remote git or archive, You can use this command to import it.
Examples:
$ litmus imp <project name>