summaryrefslogtreecommitdiffstats
path: root/tests/snapshot.rc
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@redhat.com>2016-04-10 10:51:11 -0400
committerJeff Darcy <jdarcy@redhat.com>2016-04-12 05:04:24 -0700
commitc6d1b9797dd2850cd0b8be7f17a41db525cbe93d (patch)
tree21a5972bc7f5f6d19e51b27d487a29ae7ef28f42 /tests/snapshot.rc
parent5cbe6baa0258074d5003e6cdfc9997adb006750f (diff)
tests: use trap mechanism to ensure that proper cleanups happen
This actually consists of several parts. * Added a generic cleanup-scheduling mechanism. Instead of calling "trap ... EXIT" directly, just call "push_trapfunc ..." instead and your cleanup function will be called along with any others. * Converted a few tests to use push_trapfunc. * Added "push_trapfunc cleanup_lvm" to snapshot.rc to address the particular problem that's driving this - snapshot tests not calling cleanup_lvm on their own and leaving bad state for the next test. Change-Id: I548a97a26328390992fc71ee1f03c0463703f9d7 Signed-off-by: Jeff Darcy <jdarcy@redhat.com> Reviewed-on: http://review.gluster.org/13933 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Diffstat (limited to 'tests/snapshot.rc')
-rw-r--r--tests/snapshot.rc5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/snapshot.rc b/tests/snapshot.rc
index cca1f4d4988..f6da514f826 100644
--- a/tests/snapshot.rc
+++ b/tests/snapshot.rc
@@ -94,6 +94,11 @@ function cleanup_lvm() {
return 0
}
+# Find out how this file was sourced, source traps.rc the same way, and use
+# push_trapfunc to make sure cleanup_lvm gets called before we exit.
+. $(dirname ${BASH_SOURCE[0]})/traps.rc
+push_trapfunc cleanup_lvm
+
########################################################
# Private Functions
########################################################