d19dc35e47fd8f7c8e91f70545664dddc8ab76cb
[tools/litmus.git] / litmus / templates / standalone_xu3 / userscript.py
1 #!/usr/bin/env python3
2 import os
3 from litmus.core.util import load_yaml
4 from litmus.core.manager import manager
5 from litmus.helper.helper import tizen_snapshot_downloader as downloader
6 from litmus.helper.tests import add_test_helper
7
8
9 def main(*args, **kwargs):
10
11     # init manager instance
12     mgr = manager(*args, **kwargs)
13
14     # init working directory
15     mgr.init_workingdir()
16
17     # get projectinfo
18     project_info = load_yaml('conf_tv.yaml')
19
20     username = project_info['username']
21     password = project_info['password']
22     binary_urls = project_info['binary_urls']
23
24     # get version from parameter
25     # ex) 20160923.3
26     try:
27         version = kwargs['param'][0]
28     except (IndexError, TypeError):
29         version = None
30
31     # download binaries from snapshot download server
32     filenames = []
33     for url in binary_urls:
34         filenames.extend(downloader(url=url,
35                                     username=username,
36                                     password=password,
37                                     version=version))
38
39     # get an available device for testing.
40     dut = mgr.acquire_dut('standalone_xu3', max_retry_times=180)
41
42     # flashing binaries to device.
43     dut.flash(filenames)
44
45     # turn on dut.
46     dut.on()
47
48     # run helper functions for testing.
49     if not os.path.exists('result'):
50         os.mkdir('result')
51
52     testcases = load_yaml('tc_tv.yaml')
53     add_test_helper(dut, testcases)
54     dut.run_tests()
55
56     # turn off dut.
57     dut.off()
58
59     # release a device
60     mgr.release_dut(dut)