diff options
author | bryan <bryan.sullivan@att.com> | 2017-02-07 08:06:59 -0800 |
---|---|---|
committer | bryan <bryan.sullivan@att.com> | 2017-02-07 08:09:35 -0800 |
commit | ae516ac1821822a4034b77cad82805ab8d7a0f9e (patch) | |
tree | e2b6d6e2f51d5bd3382d4c04e91eb6bf06602bd9 | |
parent | c04ffff59b770ae32c4691bdc3d3b4363604db78 (diff) |
Add fail trap and success functions
JIRA: COPPER-4
Remove redundant set +x.
Change-Id: I20707d9b1b4076e668fab7d195b5849064becabe
Signed-off-by: bryan <bryan.sullivan@att.com>
-rw-r--r-- | tests/dmz-clean.sh | 20 | ||||
-rw-r--r-- | tests/dmz.sh | 2 |
2 files changed, 18 insertions, 4 deletions
diff --git a/tests/dmz-clean.sh b/tests/dmz-clean.sh index b13ef7e..9161d69 100644 --- a/tests/dmz-clean.sh +++ b/tests/dmz-clean.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2015-2016 AT&T Intellectual Property, Inc +# Copyright 2015-2017 AT&T Intellectual Property, Inc # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -28,6 +28,22 @@ # # After test, cleanup # $ bash dmz-clean.sh +trap 'fail' ERR + +pass() { + echo "Hooray!" + set +x #echo off + exit 0 +} + +# Use this to trigger fail() at the right places +# if [ "$RESULT" == "Test Failed!" ]; then fail; fi +fail() { + echo "Test Failed!" + set +x + exit 1 +} + if [ $# -eq 1 ]; then if [ $1 == "debug" ]; then set -x #echo on @@ -101,5 +117,5 @@ neutron subnet-delete test_internal echo "Delete internal network" neutron net-delete test_internal -set +x #echo off +pass diff --git a/tests/dmz.sh b/tests/dmz.sh index e95a7ea..ab16ef6 100644 --- a/tests/dmz.sh +++ b/tests/dmz.sh @@ -209,6 +209,4 @@ done echo "Verify cirros1 is paused:" $RESULT if [ "$RESULT" == "Test Failed!" ]; then fail; fi -set +x #echo off - pass |