From: Donghoon Shin Date: Tue, 27 Sep 2016 06:17:29 +0000 (+0900) Subject: Rename mock device type to standalone device type X-Git-Tag: 0.3.3~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=91fd7123270975524da0a4a8eb521dbeecbf1f84;p=tools%2Flitmus.git Rename mock device type to standalone device type --- diff --git a/CHANGES.txt b/CHANGES.txt index d5af636..a219c42 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -16,21 +16,21 @@ Version 0.1.1 27 Jun 2016 Version 0.2.0 9 Sep 2016 --------------------------- - Remove acmlock routine to improve test performance -- Support flash function for mock device type +- Support flash function for standalone device type - Update test helper functions Version 0.2.1 9 Sep 2016 --------------------------- - Update import command to use shell-like path expansions -- Update mock device type to avoid sdb error +- Update standalone device type to avoid sdb error - Update default templates for u3 and xu3 Version 0.3.0 21 Sep 2016 --------------------------- - Update projects/topology file location - Add projects/topology param at command prompt -- Support multiple mock devices in topology -- Add global lock for mock device type +- Support multiple standalone devices in topology +- Add global lock for standalone device type Version 0.3.1 22 Sep 2016 --------------------------- diff --git a/README.md b/README.md index 98cb6f7..3200545 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Prerequisite Litmus uses sdb to communicate with device. sdb is not released on download.tizen.org/tools but you can find it from sdk. -Installing sdb from tizen sdk or download binary from below url. +Install sdb from tizen sdk or download binary from below url. 32bit: http://download.tizen.org/sdk/sdk-packages/official/binary/sdb_2.2.83_ubuntu-32.zip diff --git a/debian/changelog b/debian/changelog index 6c83b99..842a097 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,15 +8,15 @@ litmus (0.3.0-1) unstable; urgency=low * Update projects/topology file location * Add projects/topology param at command prompt - * Support multiple mock devices in topology - * Add global lock for mock device type + * Support multiple standalone devices in topology + * Add global lock for standalone device type -- Donghoon Shin Wed, 21 Sep 2016 15:08:00 +0900 litmus (0.2.1-1) unstable; urgency=low * Update import command to use shell-like path expansions - * Update mock device type to avoid sdb error + * Update standalone device type to avoid sdb error * Update default templates for u3 and xu3 -- Donghoon Shin Fri, 9 Sep 2016 15:00:00 +0900 @@ -24,7 +24,7 @@ litmus (0.2.1-1) unstable; urgency=low litmus (0.2.0-1) unstable; urgency=low * Remove acmlock routine to imporve test performance - * Support flash function for mock device type + * Support flash function for standalone device type * Update test helper functions -- Donghoon Shin Fri, 9 Sep 2016 10:03:05 +0900 diff --git a/litmus/__init__.py b/litmus/__init__.py index 3cb3ccd..abbddaf 100644 --- a/litmus/__init__.py +++ b/litmus/__init__.py @@ -21,4 +21,4 @@ _duts_ = os.path.join(_confdir_, 'topology') _projects_ = os.path.join(_confdir_, 'projects') _tmpdir_ = '/tmp' _path_for_locks_ = '/var/lock/litmus/' -_dev_types_ = ('u3', 'xu3', 'mock', 'empty') +_dev_types_ = ('u3', 'xu3', 'standalone', 'empty') diff --git a/litmus/core/manager.py b/litmus/core/manager.py index 183d8c3..b0b27a4 100644 --- a/litmus/core/manager.py +++ b/litmus/core/manager.py @@ -312,15 +312,3 @@ Lightweight test manager for tizen automated testing # Append items self._all_devices.append(items) - - if not next((d for d in self._all_devices if d['dev_type'] == 'mock'), - None): - # Add mock device - mock_devicename = 'MOCK_001' - mock_ilock_filename = os.path.join(self._path_for_locks, - mock_devicename) - mock = {'devicename': mock_devicename, - 'dev_type': 'mock', - 'tlock': Lock(), - 'ilock': fasteners.InterProcessLock(mock_ilock_filename)} - self._all_devices.append(mock) diff --git a/litmus/device/devicemock.py b/litmus/device/devicemock.py deleted file mode 100644 index 8d9669c..0000000 --- a/litmus/device/devicemock.py +++ /dev/null @@ -1,156 +0,0 @@ -#!/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 devicemock(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('You can\'t turn off mock type 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.py b/litmus/device/devicestandalone.py new file mode 100644 index 0000000..08611d8 --- /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('You can\'t turn off standalone type 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/templates/mock/__init__.py b/litmus/templates/mock/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/litmus/templates/mock/conf.yaml b/litmus/templates/mock/conf.yaml deleted file mode 100644 index 072e0d7..0000000 --- a/litmus/templates/mock/conf.yaml +++ /dev/null @@ -1,4 +0,0 @@ -binary_urls: - - http://download.tizen.org/snapshots/tizen/mobile/latest/images/target-TM1/mobile-wayland-armv7l-tm1/ -username: -password: diff --git a/litmus/templates/mock/tc.yaml b/litmus/templates/mock/tc.yaml deleted file mode 100644 index 44ed8a2..0000000 --- a/litmus/templates/mock/tc.yaml +++ /dev/null @@ -1,23 +0,0 @@ -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/mock/userscript.py b/litmus/templates/mock/userscript.py deleted file mode 100755 index 2abe0c9..0000000 --- a/litmus/templates/mock/userscript.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/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.yaml') - - username = project_info['username'] - password = project_info['password'] - binary_urls = project_info['binary_urls'] - - # 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('mock', 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.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 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: +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: +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: +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)