summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/contrib/tts/toasteruitest/run_toastertests.py
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-10-28 18:48:45 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-11-04 12:50:55 +0000
commit5bc6fa01e0581c703808597878244cf9a38cefba (patch)
treec4ead257ecf58e3937c3c354636466a7ebdbf163 /bitbake/lib/toaster/contrib/tts/toasteruitest/run_toastertests.py
parent953b2f50f003a53fc387edfdeb8aa96d904526b2 (diff)
downloadpoky-5bc6fa01e0581c703808597878244cf9a38cefba.tar.gz
bitbake: toaster: Remove contrib tts
Remove the "Toaster test system". We don't need a home brew test "framework" as the django test runner is more than adequate. None of these tests here are currently working and have been obsoleted by the work done on unit and browser tests in ./tests/. (Bitbake rev: 7a82e45ca5c4d470f62f83e72d00cbe45baa1537) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/contrib/tts/toasteruitest/run_toastertests.py')
-rwxr-xr-xbitbake/lib/toaster/contrib/tts/toasteruitest/run_toastertests.py155
1 files changed, 0 insertions, 155 deletions
diff --git a/bitbake/lib/toaster/contrib/tts/toasteruitest/run_toastertests.py b/bitbake/lib/toaster/contrib/tts/toasteruitest/run_toastertests.py
deleted file mode 100755
index 8ca45a8136..0000000000
--- a/bitbake/lib/toaster/contrib/tts/toasteruitest/run_toastertests.py
+++ /dev/null
@@ -1,155 +0,0 @@
1#!/usr/bin/python
2
3# Copyright
4
5# DESCRIPTION
6# This is script for running all selected toaster cases on
7# selected web browsers manifested in toaster_test.cfg.
8
9# 1. How to start toaster in yocto:
10# $ source poky/oe-init-build-env
11# $ source toaster start
12# $ bitbake core-image-minimal
13
14# 2. How to install selenium on Ubuntu:
15# $ sudo apt-get install scrot python-pip
16# $ sudo pip install selenium
17
18# 3. How to install selenium addon in firefox:
19# Download the lastest firefox addon from http://release.seleniumhq.org/selenium-ide/
20# Then install it. You can also install firebug and firepath addon
21
22# 4. How to start writing a new case:
23# All you need to do is to implement the function test_xxx() and pile it on.
24
25# 5. How to test with Chrome browser
26# Download/install chrome on host
27# Download chromedriver from https://code.google.com/p/chromedriver/downloads/list according to your host type
28# put chromedriver in PATH, (e.g. /usr/bin/, bear in mind to chmod)
29# For windows host, you may put chromedriver.exe in the same directory as chrome.exe
30
31import unittest, sys, os, platform
32import ConfigParser
33import argparse
34from toaster_automation_test import toaster_cases
35
36
37def get_args_parser():
38 description = "Script that runs toaster auto tests."
39 parser = argparse.ArgumentParser(description=description)
40 parser.add_argument('--run-all-tests', required=False, action="store_true", dest="run_all_tests", default=False,
41 help='Run all tests.')
42 parser.add_argument('--run-suite', required=False, dest='run_suite', default=False,
43 help='run suite (defined in cfg file)')
44
45 return parser
46
47
48def get_tests():
49 testslist = []
50
51 prefix = 'toaster_automation_test.toaster_cases'
52
53 for t in dir(toaster_cases):
54 if t.startswith('test_'):
55 testslist.append('.'.join((prefix, t)))
56
57 return testslist
58
59
60def get_tests_from_cfg(suite=None):
61
62 testslist = []
63 config = ConfigParser.SafeConfigParser()
64 config.read('toaster_test.cfg')
65
66 if suite is not None:
67 target_suite = suite.lower()
68
69 # TODO: if suite is valid suite
70
71 else:
72 target_suite = platform.system().lower()
73
74 try:
75 tests_from_cfg = eval(config.get('toaster_test_' + target_suite, 'test_cases'))
76 except:
77 print('Failed to get test cases from cfg file. Make sure the format is correct.')
78 return None
79
80 prefix = 'toaster_automation_test.toaster_cases.test_'
81 for t in tests_from_cfg:
82 testslist.append(prefix + str(t))
83
84 return testslist
85
86def main():
87
88 # In case this script is called from other directory
89 os.chdir(os.path.abspath(sys.path[0]))
90
91 parser = get_args_parser()
92 args = parser.parse_args()
93
94 if args.run_all_tests:
95 testslist = get_tests()
96 elif args.run_suite:
97 testslist = get_tests_from_cfg(args.run_suite)
98 os.environ['TOASTER_SUITE'] = args.run_suite
99 else:
100 testslist = get_tests_from_cfg()
101
102 if not testslist:
103 print('Failed to get test cases.')
104 exit(1)
105
106 suite = unittest.TestSuite()
107 loader = unittest.TestLoader()
108 loader.sortTestMethodsUsing = None
109 runner = unittest.TextTestRunner(verbosity=2, resultclass=buildResultClass(args))
110
111 for test in testslist:
112 try:
113 suite.addTests(loader.loadTestsFromName(test))
114 except:
115 return 1
116
117 result = runner.run(suite)
118
119 if result.wasSuccessful():
120 return 0
121 else:
122 return 1
123
124
125def buildResultClass(args):
126 """Build a Result Class to use in the testcase execution"""
127
128 class StampedResult(unittest.TextTestResult):
129 """
130 Custom TestResult that prints the time when a test starts. As toaster-auto
131 can take a long time (ie a few hours) to run, timestamps help us understand
132 what tests are taking a long time to execute.
133 """
134 def startTest(self, test):
135 import time
136 self.stream.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + " - ")
137 super(StampedResult, self).startTest(test)
138
139 return StampedResult
140
141
142if __name__ == "__main__":
143
144 try:
145 ret = main()
146 except:
147 ret = 1
148 import traceback
149 traceback.print_exc()
150 finally:
151 if os.getenv('TOASTER_SUITE'):
152 del os.environ['TOASTER_SUITE']
153 sys.exit(ret)
154
155