diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-02-08 17:11:40 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-02-08 17:11:40 +0100 |
commit | 3d4af18fb0cb257d1466fac417c9f13f080ecd04 (patch) | |
tree | d0c5e67b480a64d5042316bd00965138cfd89263 /bin | |
parent | 6aea18a15f96c733505fc7587ac35e263c165549 (diff) | |
download | vyos-1x-3d4af18fb0cb257d1466fac417c9f13f080ecd04.tar.gz vyos-1x-3d4af18fb0cb257d1466fac417c9f13f080ecd04.zip |
Evaluate exit code when running tests
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/vyos-smoketest | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/bin/vyos-smoketest b/bin/vyos-smoketest index 6d3442622..cb039db42 100755 --- a/bin/vyos-smoketest +++ b/bin/vyos-smoketest @@ -15,9 +15,10 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import os -import sys -from stat import * +from sys import exit +from stat import S_IXOTH +from subprocess import Popen, PIPE success = True for root, dirs, files in os.walk('/usr/libexec/vyos/tests/smoke'): @@ -26,14 +27,16 @@ for root, dirs, files in os.walk('/usr/libexec/vyos/tests/smoke'): mode = os.stat(test_file).st_mode if mode & S_IXOTH: - try: - print('Running Testcase: ' + test_file) - os.system(test_file) - except Exception as e: - print('Testcase "{}" raised an exception'.format(test_file)) + print('Running Testcase: ' + test_file) + process = Popen([test_file], stdout=PIPE) + (output, err) = process.communicate() + exit_code = process.wait() + # We do not want an instant fail - other tests should be run, too + if exit_code != 0: success = False if success: - sys.exit(0) + exit(0) -sys.exit(1) +print("ERROR: One or more tests failed!") +exit(1) |