summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/runcmd.py
diff options
context:
space:
mode:
authorJose Perez Carranza <jose.perez.carranza@linux.intel.com>2017-09-01 13:30:24 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-09-11 17:30:28 +0100
commit1d5d4165a5bc257650a4c136dfa4a58ade3e404e (patch)
treedbaa78002561ec127e8615988fcf9d35c51acca8 /meta/lib/oeqa/selftest/cases/runcmd.py
parent3c492afe4f3c8d1cf7e1fef0e83a71dd1557c62e (diff)
downloadpoky-1d5d4165a5bc257650a4c136dfa4a58ade3e404e.tar.gz
oeqa/selftest: Add missing IDs to various test cases
Add decorator @OETestID() with Tesopia TC-ID to the test cases that did not have it properly set. [YOCTO #11873] (From OE-Core rev: aa5b9edbd9c4495befe1912a5b401b536be39d5b) Signed-off-by: Jose Perez Carranza <jose.perez.carranza@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/runcmd.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/runcmd.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/runcmd.py b/meta/lib/oeqa/selftest/cases/runcmd.py
index 6c785caadc..d76d7063c6 100644
--- a/meta/lib/oeqa/selftest/cases/runcmd.py
+++ b/meta/lib/oeqa/selftest/cases/runcmd.py
@@ -1,6 +1,7 @@
1from oeqa.selftest.case import OESelftestTestCase 1from oeqa.selftest.case import OESelftestTestCase
2from oeqa.utils.commands import runCmd 2from oeqa.utils.commands import runCmd
3from oeqa.utils import CommandError 3from oeqa.utils import CommandError
4from oeqa.core.decorator.oeid import OETestID
4 5
5import subprocess 6import subprocess
6import threading 7import threading
@@ -26,49 +27,60 @@ class RunCmdTests(OESelftestTestCase):
26 TIMEOUT = 2 27 TIMEOUT = 2
27 DELTA = 1 28 DELTA = 1
28 29
30 @OETestID(1916)
29 def test_result_okay(self): 31 def test_result_okay(self):
30 result = runCmd("true") 32 result = runCmd("true")
31 self.assertEqual(result.status, 0) 33 self.assertEqual(result.status, 0)
32 34
35 @OETestID(1915)
33 def test_result_false(self): 36 def test_result_false(self):
34 result = runCmd("false", ignore_status=True) 37 result = runCmd("false", ignore_status=True)
35 self.assertEqual(result.status, 1) 38 self.assertEqual(result.status, 1)
36 39
40 @OETestID(1917)
37 def test_shell(self): 41 def test_shell(self):
38 # A shell is used for all string commands. 42 # A shell is used for all string commands.
39 result = runCmd("false; true", ignore_status=True) 43 result = runCmd("false; true", ignore_status=True)
40 self.assertEqual(result.status, 0) 44 self.assertEqual(result.status, 0)
41 45
46 @OETestID(1910)
42 def test_no_shell(self): 47 def test_no_shell(self):
43 self.assertRaises(FileNotFoundError, 48 self.assertRaises(FileNotFoundError,
44 runCmd, "false; true", shell=False) 49 runCmd, "false; true", shell=False)
45 50
51 @OETestID(1906)
46 def test_list_not_found(self): 52 def test_list_not_found(self):
47 self.assertRaises(FileNotFoundError, 53 self.assertRaises(FileNotFoundError,
48 runCmd, ["false; true"]) 54 runCmd, ["false; true"])
49 55
56 @OETestID(1907)
50 def test_list_okay(self): 57 def test_list_okay(self):
51 result = runCmd(["true"]) 58 result = runCmd(["true"])
52 self.assertEqual(result.status, 0) 59 self.assertEqual(result.status, 0)
53 60
61 @OETestID(1913)
54 def test_result_assertion(self): 62 def test_result_assertion(self):
55 self.assertRaisesRegexp(AssertionError, "Command 'echo .* false' returned non-zero exit status 1:\nfoobar", 63 self.assertRaisesRegexp(AssertionError, "Command 'echo .* false' returned non-zero exit status 1:\nfoobar",
56 runCmd, "echo foobar >&2; false", shell=True) 64 runCmd, "echo foobar >&2; false", shell=True)
57 65
66 @OETestID(1914)
58 def test_result_exception(self): 67 def test_result_exception(self):
59 self.assertRaisesRegexp(CommandError, "Command 'echo .* false' returned non-zero exit status 1 with output: foobar", 68 self.assertRaisesRegexp(CommandError, "Command 'echo .* false' returned non-zero exit status 1 with output: foobar",
60 runCmd, "echo foobar >&2; false", shell=True, assert_error=False) 69 runCmd, "echo foobar >&2; false", shell=True, assert_error=False)
61 70
71 @OETestID(1911)
62 def test_output(self): 72 def test_output(self):
63 result = runCmd("echo stdout; echo stderr >&2", shell=True) 73 result = runCmd("echo stdout; echo stderr >&2", shell=True)
64 self.assertEqual("stdout\nstderr", result.output) 74 self.assertEqual("stdout\nstderr", result.output)
65 self.assertEqual("", result.error) 75 self.assertEqual("", result.error)
66 76
77 @OETestID(1912)
67 def test_output_split(self): 78 def test_output_split(self):
68 result = runCmd("echo stdout; echo stderr >&2", shell=True, stderr=subprocess.PIPE) 79 result = runCmd("echo stdout; echo stderr >&2", shell=True, stderr=subprocess.PIPE)
69 self.assertEqual("stdout", result.output) 80 self.assertEqual("stdout", result.output)
70 self.assertEqual("stderr", result.error) 81 self.assertEqual("stderr", result.error)
71 82
83 @OETestID(1920)
72 def test_timeout(self): 84 def test_timeout(self):
73 numthreads = threading.active_count() 85 numthreads = threading.active_count()
74 start = time.time() 86 start = time.time()
@@ -79,6 +91,7 @@ class RunCmdTests(OESelftestTestCase):
79 self.assertLess(end - start, self.TIMEOUT + self.DELTA) 91 self.assertLess(end - start, self.TIMEOUT + self.DELTA)
80 self.assertEqual(numthreads, threading.active_count()) 92 self.assertEqual(numthreads, threading.active_count())
81 93
94 @OETestID(1921)
82 def test_timeout_split(self): 95 def test_timeout_split(self):
83 numthreads = threading.active_count() 96 numthreads = threading.active_count()
84 start = time.time() 97 start = time.time()
@@ -89,12 +102,14 @@ class RunCmdTests(OESelftestTestCase):
89 self.assertLess(end - start, self.TIMEOUT + self.DELTA) 102 self.assertLess(end - start, self.TIMEOUT + self.DELTA)
90 self.assertEqual(numthreads, threading.active_count()) 103 self.assertEqual(numthreads, threading.active_count())
91 104
105 @OETestID(1918)
92 def test_stdin(self): 106 def test_stdin(self):
93 numthreads = threading.active_count() 107 numthreads = threading.active_count()
94 result = runCmd("cat", data=b"hello world", timeout=self.TIMEOUT) 108 result = runCmd("cat", data=b"hello world", timeout=self.TIMEOUT)
95 self.assertEqual("hello world", result.output) 109 self.assertEqual("hello world", result.output)
96 self.assertEqual(numthreads, threading.active_count()) 110 self.assertEqual(numthreads, threading.active_count())
97 111
112 @OETestID(1919)
98 def test_stdin_timeout(self): 113 def test_stdin_timeout(self):
99 numthreads = threading.active_count() 114 numthreads = threading.active_count()
100 start = time.time() 115 start = time.time()
@@ -104,12 +119,14 @@ class RunCmdTests(OESelftestTestCase):
104 self.assertLess(end - start, self.TIMEOUT + self.DELTA) 119 self.assertLess(end - start, self.TIMEOUT + self.DELTA)
105 self.assertEqual(numthreads, threading.active_count()) 120 self.assertEqual(numthreads, threading.active_count())
106 121
122 @OETestID(1908)
107 def test_log(self): 123 def test_log(self):
108 log = MemLogger() 124 log = MemLogger()
109 result = runCmd("echo stdout; echo stderr >&2", shell=True, output_log=log) 125 result = runCmd("echo stdout; echo stderr >&2", shell=True, output_log=log)
110 self.assertEqual(["Running: echo stdout; echo stderr >&2", "stdout", "stderr"], log.info_msgs) 126 self.assertEqual(["Running: echo stdout; echo stderr >&2", "stdout", "stderr"], log.info_msgs)
111 self.assertEqual([], log.error_msgs) 127 self.assertEqual([], log.error_msgs)
112 128
129 @OETestID(1909)
113 def test_log_split(self): 130 def test_log_split(self):
114 log = MemLogger() 131 log = MemLogger()
115 result = runCmd("echo stdout; echo stderr >&2", shell=True, output_log=log, stderr=subprocess.PIPE) 132 result = runCmd("echo stdout; echo stderr >&2", shell=True, output_log=log, stderr=subprocess.PIPE)