tests: pyunit always exiting with 0
As unittest.TextTestRunner().run(suite) doesn't exit the script, it won't set the exit code, even when some tests are failing. This means testlib is always interpreting those unittests as passing even when there are failures. With this patch we are propagating the error to our CI system (testlib) Change-Id: I63b7622661a19a9b40243d13b7391e510c2007d4 Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48969 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -35,8 +35,9 @@
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
print("ERROR: This file must be run from gem5.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
@@ -47,5 +48,9 @@ if __name__ == "__m5_main__":
|
||||
tests = loader.discover("pyunit", pattern='pyunit*.py')
|
||||
|
||||
runner = unittest.runner.TextTestRunner(verbosity=2)
|
||||
runner.run(tests)
|
||||
result = runner.run(tests)
|
||||
if result.wasSuccessful():
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user