diff options
author | Aníbal Limón <anibal.limon@linux.intel.com> | 2017-05-26 15:37:41 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-02 13:36:14 +0100 |
commit | a4eef558c9933eb32413b61ff80a11b999951b40 (patch) | |
tree | 9ef0eb53a16d94db3e0213e13d760107eb9facc8 /meta/lib | |
parent | f9102ab1ede53c9c2e4b296566a58a398322d28c (diff) | |
download | poky-a4eef558c9933eb32413b61ff80a11b999951b40.tar.gz |
oeqa/core/tests: Add tests of OEQA Threaded mode
Add needed tests to validate the OEQA Threaded mode, the remaining
parts are tested by the OEQA without Threaded mode.
- test_loader.py: Add a test to validate rules when creating the
list of test suites.
- test_decorators.py: Add oetimeout test because the threaded mode
uses Timer instead of signal.
[YOCTO #11450]
(From OE-Core rev: fb9d91ca34c1b5d3e0034f5135e71f964fca5b82)
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
7 files changed, 93 insertions, 1 deletions
diff --git a/meta/lib/oeqa/core/tests/cases/loader/threaded/threaded.py b/meta/lib/oeqa/core/tests/cases/loader/threaded/threaded.py new file mode 100644 index 0000000000..0fe4cb3f11 --- /dev/null +++ b/meta/lib/oeqa/core/tests/cases/loader/threaded/threaded.py | |||
@@ -0,0 +1,12 @@ | |||
1 | # Copyright (C) 2017 Intel Corporation | ||
2 | # Released under the MIT license (see COPYING.MIT) | ||
3 | |||
4 | from oeqa.core.case import OETestCase | ||
5 | |||
6 | class ThreadedTest(OETestCase): | ||
7 | def test_threaded_no_depends(self): | ||
8 | self.assertTrue(True, msg='How is this possible?') | ||
9 | |||
10 | class ThreadedTest2(OETestCase): | ||
11 | def test_threaded_same_module(self): | ||
12 | self.assertTrue(True, msg='How is this possible?') | ||
diff --git a/meta/lib/oeqa/core/tests/cases/loader/threaded/threaded_alone.py b/meta/lib/oeqa/core/tests/cases/loader/threaded/threaded_alone.py new file mode 100644 index 0000000000..905f397846 --- /dev/null +++ b/meta/lib/oeqa/core/tests/cases/loader/threaded/threaded_alone.py | |||
@@ -0,0 +1,8 @@ | |||
1 | # Copyright (C) 2017 Intel Corporation | ||
2 | # Released under the MIT license (see COPYING.MIT) | ||
3 | |||
4 | from oeqa.core.case import OETestCase | ||
5 | |||
6 | class ThreadedTestAlone(OETestCase): | ||
7 | def test_threaded_alone(self): | ||
8 | self.assertTrue(True, msg='How is this possible?') | ||
diff --git a/meta/lib/oeqa/core/tests/cases/loader/threaded/threaded_depends.py b/meta/lib/oeqa/core/tests/cases/loader/threaded/threaded_depends.py new file mode 100644 index 0000000000..0c158d3bac --- /dev/null +++ b/meta/lib/oeqa/core/tests/cases/loader/threaded/threaded_depends.py | |||
@@ -0,0 +1,10 @@ | |||
1 | # Copyright (C) 2017 Intel Corporation | ||
2 | # Released under the MIT license (see COPYING.MIT) | ||
3 | |||
4 | from oeqa.core.case import OETestCase | ||
5 | from oeqa.core.decorator.depends import OETestDepends | ||
6 | |||
7 | class ThreadedTest3(OETestCase): | ||
8 | @OETestDepends(['threaded.ThreadedTest.test_threaded_no_depends']) | ||
9 | def test_threaded_depends(self): | ||
10 | self.assertTrue(True, msg='How is this possible?') | ||
diff --git a/meta/lib/oeqa/core/tests/cases/loader/threaded/threaded_module.py b/meta/lib/oeqa/core/tests/cases/loader/threaded/threaded_module.py new file mode 100644 index 0000000000..63d17e0401 --- /dev/null +++ b/meta/lib/oeqa/core/tests/cases/loader/threaded/threaded_module.py | |||
@@ -0,0 +1,12 @@ | |||
1 | # Copyright (C) 2017 Intel Corporation | ||
2 | # Released under the MIT license (see COPYING.MIT) | ||
3 | |||
4 | from oeqa.core.case import OETestCase | ||
5 | |||
6 | class ThreadedTestModule(OETestCase): | ||
7 | def test_threaded_module(self): | ||
8 | self.assertTrue(True, msg='How is this possible?') | ||
9 | |||
10 | class ThreadedTestModule2(OETestCase): | ||
11 | def test_threaded_module2(self): | ||
12 | self.assertTrue(True, msg='How is this possible?') | ||
diff --git a/meta/lib/oeqa/core/tests/common.py b/meta/lib/oeqa/core/tests/common.py index 52b18a1c3e..1932323409 100644 --- a/meta/lib/oeqa/core/tests/common.py +++ b/meta/lib/oeqa/core/tests/common.py | |||
@@ -33,3 +33,13 @@ class TestBase(unittest.TestCase): | |||
33 | tc.loadTests(self.cases_path, modules=modules, tests=tests, | 33 | tc.loadTests(self.cases_path, modules=modules, tests=tests, |
34 | filters=filters) | 34 | filters=filters) |
35 | return tc | 35 | return tc |
36 | |||
37 | def _testLoaderThreaded(self, d={}, modules=[], | ||
38 | tests=[], filters={}): | ||
39 | from oeqa.core.threaded import OETestContextThreaded | ||
40 | |||
41 | tc = OETestContextThreaded(d, self.logger) | ||
42 | tc.loadTests(self.cases_path, modules=modules, tests=tests, | ||
43 | filters=filters) | ||
44 | |||
45 | return tc | ||
diff --git a/meta/lib/oeqa/core/tests/test_decorators.py b/meta/lib/oeqa/core/tests/test_decorators.py index f7d11e885a..cf99e0d72d 100755 --- a/meta/lib/oeqa/core/tests/test_decorators.py +++ b/meta/lib/oeqa/core/tests/test_decorators.py | |||
@@ -131,5 +131,17 @@ class TestTimeoutDecorator(TestBase): | |||
131 | msg = "OETestTimeout didn't restore SIGALRM" | 131 | msg = "OETestTimeout didn't restore SIGALRM" |
132 | self.assertIs(alarm_signal, signal.getsignal(signal.SIGALRM), msg=msg) | 132 | self.assertIs(alarm_signal, signal.getsignal(signal.SIGALRM), msg=msg) |
133 | 133 | ||
134 | def test_timeout_thread(self): | ||
135 | tests = ['timeout.TimeoutTest.testTimeoutPass'] | ||
136 | msg = 'Failed to run test using OETestTimeout' | ||
137 | tc = self._testLoaderThreaded(modules=self.modules, tests=tests) | ||
138 | self.assertTrue(tc.runTests().wasSuccessful(), msg=msg) | ||
139 | |||
140 | def test_timeout_threaded_fail(self): | ||
141 | tests = ['timeout.TimeoutTest.testTimeoutFail'] | ||
142 | msg = "OETestTimeout test didn't timeout as expected" | ||
143 | tc = self._testLoaderThreaded(modules=self.modules, tests=tests) | ||
144 | self.assertFalse(tc.runTests().wasSuccessful(), msg=msg) | ||
145 | |||
134 | if __name__ == '__main__': | 146 | if __name__ == '__main__': |
135 | unittest.main() | 147 | unittest.main() |
diff --git a/meta/lib/oeqa/core/tests/test_loader.py b/meta/lib/oeqa/core/tests/test_loader.py index b79b8bad4d..e0d917d317 100755 --- a/meta/lib/oeqa/core/tests/test_loader.py +++ b/meta/lib/oeqa/core/tests/test_loader.py | |||
@@ -1,6 +1,6 @@ | |||
1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
2 | 2 | ||
3 | # Copyright (C) 2016 Intel Corporation | 3 | # Copyright (C) 2016-2017 Intel Corporation |
4 | # Released under the MIT license (see COPYING.MIT) | 4 | # Released under the MIT license (see COPYING.MIT) |
5 | 5 | ||
6 | import os | 6 | import os |
@@ -82,5 +82,33 @@ class TestLoader(TestBase): | |||
82 | msg = 'Expected modules from two different paths' | 82 | msg = 'Expected modules from two different paths' |
83 | self.assertEqual(modules, expected_modules, msg=msg) | 83 | self.assertEqual(modules, expected_modules, msg=msg) |
84 | 84 | ||
85 | def test_loader_threaded(self): | ||
86 | cases_path = self.cases_path | ||
87 | |||
88 | self.cases_path = [os.path.join(self.cases_path, 'loader', 'threaded')] | ||
89 | |||
90 | tc = self._testLoaderThreaded() | ||
91 | self.assertEqual(len(tc.suites), 3, "Expected to be 3 suites") | ||
92 | |||
93 | case_ids = ['threaded.ThreadedTest.test_threaded_no_depends', | ||
94 | 'threaded.ThreadedTest2.test_threaded_same_module', | ||
95 | 'threaded_depends.ThreadedTest3.test_threaded_depends'] | ||
96 | for case in tc.suites[0]._tests: | ||
97 | self.assertEqual(case.id(), | ||
98 | case_ids[tc.suites[0]._tests.index(case)]) | ||
99 | |||
100 | case_ids = ['threaded_alone.ThreadedTestAlone.test_threaded_alone'] | ||
101 | for case in tc.suites[1]._tests: | ||
102 | self.assertEqual(case.id(), | ||
103 | case_ids[tc.suites[1]._tests.index(case)]) | ||
104 | |||
105 | case_ids = ['threaded_module.ThreadedTestModule.test_threaded_module', | ||
106 | 'threaded_module.ThreadedTestModule2.test_threaded_module2'] | ||
107 | for case in tc.suites[2]._tests: | ||
108 | self.assertEqual(case.id(), | ||
109 | case_ids[tc.suites[2]._tests.index(case)]) | ||
110 | |||
111 | self.cases_path = cases_path | ||
112 | |||
85 | if __name__ == '__main__': | 113 | if __name__ == '__main__': |
86 | unittest.main() | 114 | unittest.main() |