diff options
| -rw-r--r-- | meta-selftest/recipes-test/logging-test/logging-test.bb | 10 | ||||
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/bblogging.py | 69 |
2 files changed, 78 insertions, 1 deletions
diff --git a/meta-selftest/recipes-test/logging-test/logging-test.bb b/meta-selftest/recipes-test/logging-test/logging-test.bb index a6100123f9..ac3fb46f45 100644 --- a/meta-selftest/recipes-test/logging-test/logging-test.bb +++ b/meta-selftest/recipes-test/logging-test/logging-test.bb | |||
| @@ -11,12 +11,22 @@ do_shelltest() { | |||
| 11 | } | 11 | } |
| 12 | addtask do_shelltest | 12 | addtask do_shelltest |
| 13 | 13 | ||
| 14 | python do_pythontest_exec_func_shell() { | ||
| 15 | bb.build.exec_func('do_shelltest', d) | ||
| 16 | } | ||
| 17 | addtask do_pythontest_exec_func_shell | ||
| 18 | |||
| 14 | python do_pythontest_exit () { | 19 | python do_pythontest_exit () { |
| 15 | print("This is python stdout") | 20 | print("This is python stdout") |
| 16 | sys.exit(1) | 21 | sys.exit(1) |
| 17 | } | 22 | } |
| 18 | addtask do_pythontest_exit | 23 | addtask do_pythontest_exit |
| 19 | 24 | ||
| 25 | python do_pythontest_exec_func_python() { | ||
| 26 | bb.build.exec_func('do_pythontest_exit', d) | ||
| 27 | } | ||
| 28 | addtask do_pythontest_exec_func_python | ||
| 29 | |||
| 20 | python do_pythontest_fatal () { | 30 | python do_pythontest_fatal () { |
| 21 | print("This is python fatal test stdout") | 31 | print("This is python fatal test stdout") |
| 22 | bb.fatal("This is a fatal error") | 32 | bb.fatal("This is a fatal error") |
diff --git a/meta/lib/oeqa/selftest/cases/bblogging.py b/meta/lib/oeqa/selftest/cases/bblogging.py index ea6c3c8c77..6b0bbfe1c1 100644 --- a/meta/lib/oeqa/selftest/cases/bblogging.py +++ b/meta/lib/oeqa/selftest/cases/bblogging.py | |||
| @@ -30,7 +30,7 @@ class BitBakeLogging(OESelftestTestCase): | |||
| 30 | self.write_config('BBINCLUDELOGS = ""') | 30 | self.write_config('BBINCLUDELOGS = ""') |
| 31 | result = bitbake("logging-test -c shelltest -f -v", ignore_status = True) | 31 | result = bitbake("logging-test -c shelltest -f -v", ignore_status = True) |
| 32 | self.assertIn("ERROR: Logfile of failure stored in:", result.output) | 32 | self.assertIn("ERROR: Logfile of failure stored in:", result.output) |
| 33 | # two copies due to set +x | 33 | # two copies due to set +x |
| 34 | self.assertCount(result.output, "This is shell stdout", 2) | 34 | self.assertCount(result.output, "This is shell stdout", 2) |
| 35 | self.assertCount(result.output, "This is shell stderr", 2) | 35 | self.assertCount(result.output, "This is shell stderr", 2) |
| 36 | 36 | ||
| @@ -42,6 +42,41 @@ class BitBakeLogging(OESelftestTestCase): | |||
| 42 | self.assertCount(result.output, "This is shell stdout", 2) | 42 | self.assertCount(result.output, "This is shell stdout", 2) |
| 43 | self.assertCount(result.output, "This is shell stderr", 2) | 43 | self.assertCount(result.output, "This is shell stderr", 2) |
| 44 | 44 | ||
| 45 | def test_python_exec_func_shell_logging(self): | ||
| 46 | # no logs, no verbose | ||
| 47 | self.write_config('BBINCLUDELOGS = ""') | ||
| 48 | result = bitbake("logging-test -c pythontest_exec_func_shell -f", | ||
| 49 | ignore_status = True) | ||
| 50 | self.assertIn("ERROR: Logfile of failure stored in:", result.output) | ||
| 51 | self.assertNotIn("This is shell stdout", result.output) | ||
| 52 | self.assertNotIn("This is shell stderr", result.output) | ||
| 53 | |||
| 54 | # logs, no verbose | ||
| 55 | self.write_config('BBINCLUDELOGS = "yes"') | ||
| 56 | result = bitbake("logging-test -c pythontest_exec_func_shell -f", | ||
| 57 | ignore_status = True) | ||
| 58 | self.assertIn("ERROR: Logfile of failure stored in:", result.output) | ||
| 59 | self.assertCount(result.output, "This is shell stdout", 1) | ||
| 60 | self.assertCount(result.output, "This is shell stderr", 1) | ||
| 61 | |||
| 62 | # no logs, verbose | ||
| 63 | self.write_config('BBINCLUDELOGS = ""') | ||
| 64 | result = bitbake("logging-test -c pythontest_exec_func_shell -f -v", | ||
| 65 | ignore_status = True) | ||
| 66 | self.assertIn("ERROR: Logfile of failure stored in:", result.output) | ||
| 67 | # two copies due to set +x | ||
| 68 | self.assertCount(result.output, "This is shell stdout", 2) | ||
| 69 | self.assertCount(result.output, "This is shell stderr", 2) | ||
| 70 | |||
| 71 | # logs, verbose | ||
| 72 | self.write_config('BBINCLUDELOGS = "yes"') | ||
| 73 | result = bitbake("logging-test -c pythontest_exec_func_shell -f -v", | ||
| 74 | ignore_status = True) | ||
| 75 | self.assertIn("ERROR: Logfile of failure stored in:", result.output) | ||
| 76 | # two copies due to set +x | ||
| 77 | self.assertCount(result.output, "This is shell stdout", 2) | ||
| 78 | self.assertCount(result.output, "This is shell stderr", 2) | ||
| 79 | |||
| 45 | def test_python_exit_logging(self): | 80 | def test_python_exit_logging(self): |
| 46 | # no logs, no verbose | 81 | # no logs, no verbose |
| 47 | self.write_config('BBINCLUDELOGS = ""') | 82 | self.write_config('BBINCLUDELOGS = ""') |
| @@ -70,6 +105,38 @@ class BitBakeLogging(OESelftestTestCase): | |||
| 70 | # python tasks don't log output with -v currently | 105 | # python tasks don't log output with -v currently |
| 71 | #self.assertCount(result.output, "This is python stdout", 1) | 106 | #self.assertCount(result.output, "This is python stdout", 1) |
| 72 | 107 | ||
| 108 | def test_python_exec_func_python_logging(self): | ||
| 109 | # no logs, no verbose | ||
| 110 | self.write_config('BBINCLUDELOGS = ""') | ||
| 111 | result = bitbake("logging-test -c pythontest_exec_func_python -f", | ||
| 112 | ignore_status = True) | ||
| 113 | self.assertIn("ERROR: Logfile of failure stored in:", result.output) | ||
| 114 | self.assertNotIn("This is python stdout", result.output) | ||
| 115 | |||
| 116 | # logs, no verbose | ||
| 117 | self.write_config('BBINCLUDELOGS = "yes"') | ||
| 118 | result = bitbake("logging-test -c pythontest_exec_func_python -f", | ||
| 119 | ignore_status = True) | ||
| 120 | self.assertIn("ERROR: Logfile of failure stored in:", result.output) | ||
| 121 | # A sys.exit() should include the output | ||
| 122 | self.assertCount(result.output, "This is python stdout", 1) | ||
| 123 | |||
| 124 | # no logs, verbose | ||
| 125 | self.write_config('BBINCLUDELOGS = ""') | ||
| 126 | result = bitbake("logging-test -c pythontest_exec_func_python -f -v", | ||
| 127 | ignore_status = True) | ||
| 128 | self.assertIn("ERROR: Logfile of failure stored in:", result.output) | ||
| 129 | # python tasks don't log output with -v currently | ||
| 130 | #self.assertCount(result.output, "This is python stdout", 1) | ||
| 131 | |||
| 132 | # logs, verbose | ||
| 133 | self.write_config('BBINCLUDELOGS = "yes"') | ||
| 134 | result = bitbake("logging-test -c pythontest_exec_func_python -f -v", | ||
| 135 | ignore_status = True) | ||
| 136 | self.assertIn("ERROR: Logfile of failure stored in:", result.output) | ||
| 137 | # python tasks don't log output with -v currently | ||
| 138 | #self.assertCount(result.output, "This is python stdout", 1) | ||
| 139 | |||
| 73 | def test_python_fatal_logging(self): | 140 | def test_python_fatal_logging(self): |
| 74 | # no logs, no verbose | 141 | # no logs, no verbose |
| 75 | self.write_config('BBINCLUDELOGS = ""') | 142 | self.write_config('BBINCLUDELOGS = ""') |
