summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/runcmd.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/runcmd.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/runcmd.py17
1 files changed, 0 insertions, 17 deletions
diff --git a/meta/lib/oeqa/selftest/cases/runcmd.py b/meta/lib/oeqa/selftest/cases/runcmd.py
index a1615cfd20..ed4ba8a465 100644
--- a/meta/lib/oeqa/selftest/cases/runcmd.py
+++ b/meta/lib/oeqa/selftest/cases/runcmd.py
@@ -1,7 +1,6 @@
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
5 4
6import subprocess 5import subprocess
7import threading 6import threading
@@ -27,60 +26,49 @@ class RunCmdTests(OESelftestTestCase):
27 TIMEOUT = 5 26 TIMEOUT = 5
28 DELTA = 3 27 DELTA = 3
29 28
30 @OETestID(1916)
31 def test_result_okay(self): 29 def test_result_okay(self):
32 result = runCmd("true") 30 result = runCmd("true")
33 self.assertEqual(result.status, 0) 31 self.assertEqual(result.status, 0)
34 32
35 @OETestID(1915)
36 def test_result_false(self): 33 def test_result_false(self):
37 result = runCmd("false", ignore_status=True) 34 result = runCmd("false", ignore_status=True)
38 self.assertEqual(result.status, 1) 35 self.assertEqual(result.status, 1)
39 36
40 @OETestID(1917)
41 def test_shell(self): 37 def test_shell(self):
42 # A shell is used for all string commands. 38 # A shell is used for all string commands.
43 result = runCmd("false; true", ignore_status=True) 39 result = runCmd("false; true", ignore_status=True)
44 self.assertEqual(result.status, 0) 40 self.assertEqual(result.status, 0)
45 41
46 @OETestID(1910)
47 def test_no_shell(self): 42 def test_no_shell(self):
48 self.assertRaises(FileNotFoundError, 43 self.assertRaises(FileNotFoundError,
49 runCmd, "false; true", shell=False) 44 runCmd, "false; true", shell=False)
50 45
51 @OETestID(1906)
52 def test_list_not_found(self): 46 def test_list_not_found(self):
53 self.assertRaises(FileNotFoundError, 47 self.assertRaises(FileNotFoundError,
54 runCmd, ["false; true"]) 48 runCmd, ["false; true"])
55 49
56 @OETestID(1907)
57 def test_list_okay(self): 50 def test_list_okay(self):
58 result = runCmd(["true"]) 51 result = runCmd(["true"])
59 self.assertEqual(result.status, 0) 52 self.assertEqual(result.status, 0)
60 53
61 @OETestID(1913)
62 def test_result_assertion(self): 54 def test_result_assertion(self):
63 self.assertRaisesRegexp(AssertionError, "Command 'echo .* false' returned non-zero exit status 1:\nfoobar", 55 self.assertRaisesRegexp(AssertionError, "Command 'echo .* false' returned non-zero exit status 1:\nfoobar",
64 runCmd, "echo foobar >&2; false", shell=True) 56 runCmd, "echo foobar >&2; false", shell=True)
65 57
66 @OETestID(1914)
67 def test_result_exception(self): 58 def test_result_exception(self):
68 self.assertRaisesRegexp(CommandError, "Command 'echo .* false' returned non-zero exit status 1 with output: foobar", 59 self.assertRaisesRegexp(CommandError, "Command 'echo .* false' returned non-zero exit status 1 with output: foobar",
69 runCmd, "echo foobar >&2; false", shell=True, assert_error=False) 60 runCmd, "echo foobar >&2; false", shell=True, assert_error=False)
70 61
71 @OETestID(1911)
72 def test_output(self): 62 def test_output(self):
73 result = runCmd("echo stdout; echo stderr >&2", shell=True) 63 result = runCmd("echo stdout; echo stderr >&2", shell=True)
74 self.assertEqual("stdout\nstderr", result.output) 64 self.assertEqual("stdout\nstderr", result.output)
75 self.assertEqual("", result.error) 65 self.assertEqual("", result.error)
76 66
77 @OETestID(1912)
78 def test_output_split(self): 67 def test_output_split(self):
79 result = runCmd("echo stdout; echo stderr >&2", shell=True, stderr=subprocess.PIPE) 68 result = runCmd("echo stdout; echo stderr >&2", shell=True, stderr=subprocess.PIPE)
80 self.assertEqual("stdout", result.output) 69 self.assertEqual("stdout", result.output)
81 self.assertEqual("stderr", result.error) 70 self.assertEqual("stderr", result.error)
82 71
83 @OETestID(1920)
84 def test_timeout(self): 72 def test_timeout(self):
85 numthreads = threading.active_count() 73 numthreads = threading.active_count()
86 start = time.time() 74 start = time.time()
@@ -91,7 +79,6 @@ class RunCmdTests(OESelftestTestCase):
91 self.assertLess(end - start, self.TIMEOUT + self.DELTA) 79 self.assertLess(end - start, self.TIMEOUT + self.DELTA)
92 self.assertEqual(numthreads, threading.active_count()) 80 self.assertEqual(numthreads, threading.active_count())
93 81
94 @OETestID(1921)
95 def test_timeout_split(self): 82 def test_timeout_split(self):
96 numthreads = threading.active_count() 83 numthreads = threading.active_count()
97 start = time.time() 84 start = time.time()
@@ -102,14 +89,12 @@ class RunCmdTests(OESelftestTestCase):
102 self.assertLess(end - start, self.TIMEOUT + self.DELTA) 89 self.assertLess(end - start, self.TIMEOUT + self.DELTA)
103 self.assertEqual(numthreads, threading.active_count()) 90 self.assertEqual(numthreads, threading.active_count())
104 91
105 @OETestID(1918)
106 def test_stdin(self): 92 def test_stdin(self):
107 numthreads = threading.active_count() 93 numthreads = threading.active_count()
108 result = runCmd("cat", data=b"hello world", timeout=self.TIMEOUT) 94 result = runCmd("cat", data=b"hello world", timeout=self.TIMEOUT)
109 self.assertEqual("hello world", result.output) 95 self.assertEqual("hello world", result.output)
110 self.assertEqual(numthreads, threading.active_count()) 96 self.assertEqual(numthreads, threading.active_count())
111 97
112 @OETestID(1919)
113 def test_stdin_timeout(self): 98 def test_stdin_timeout(self):
114 numthreads = threading.active_count() 99 numthreads = threading.active_count()
115 start = time.time() 100 start = time.time()
@@ -119,14 +104,12 @@ class RunCmdTests(OESelftestTestCase):
119 self.assertLess(end - start, self.TIMEOUT + self.DELTA) 104 self.assertLess(end - start, self.TIMEOUT + self.DELTA)
120 self.assertEqual(numthreads, threading.active_count()) 105 self.assertEqual(numthreads, threading.active_count())
121 106
122 @OETestID(1908)
123 def test_log(self): 107 def test_log(self):
124 log = MemLogger() 108 log = MemLogger()
125 result = runCmd("echo stdout; echo stderr >&2", shell=True, output_log=log) 109 result = runCmd("echo stdout; echo stderr >&2", shell=True, output_log=log)
126 self.assertEqual(["Running: echo stdout; echo stderr >&2", "stdout", "stderr"], log.info_msgs) 110 self.assertEqual(["Running: echo stdout; echo stderr >&2", "stdout", "stderr"], log.info_msgs)
127 self.assertEqual([], log.error_msgs) 111 self.assertEqual([], log.error_msgs)
128 112
129 @OETestID(1909)
130 def test_log_split(self): 113 def test_log_split(self):
131 log = MemLogger() 114 log = MemLogger()
132 result = runCmd("echo stdout; echo stderr >&2", shell=True, output_log=log, stderr=subprocess.PIPE) 115 result = runCmd("echo stdout; echo stderr >&2", shell=True, output_log=log, stderr=subprocess.PIPE)