From ae516ac1821822a4034b77cad82805ab8d7a0f9e Mon Sep 17 00:00:00 2001 From: bryan Date: Tue, 7 Feb 2017 08:06:59 -0800 Subject: Add fail trap and success functions JIRA: COPPER-4 Remove redundant set +x. Change-Id: I20707d9b1b4076e668fab7d195b5849064becabe Signed-off-by: bryan --- tests/dmz-clean.sh | 20 ++++++++++++++++++-- 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 -- cgit 1.2.3-korg