[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/4] Add cleanup function
From: |
Ryan Harper |
Subject: |
[Qemu-devel] [PATCH 2/4] Add cleanup function |
Date: |
Fri, 13 Jan 2012 16:05:19 -0600 |
Create a cleanup function and call it from all exits so we don't leave
temp files and directories around since we change the name on each invocation.
Also, no need to delete the files in the tmpdir, so just remove the tmpdir
if it exists.
Signed-off-by: Ryan Harper <address@hidden>
---
qemu-test | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/qemu-test b/qemu-test
index cd102a7..71c1ba1 100755
--- a/qemu-test
+++ b/qemu-test
@@ -1,7 +1,14 @@
#!/bin/sh
+cleanup() {
+ if test -n "$tmpdir"; then
+ rm -rf $tmpdir;
+ fi
+}
+
if test -z "$1" -o -z "$2"; then
echo "Usage: $0 QEMU TEST1 [TEST2 ...]"
+ cleanup
exit 1
fi
@@ -23,6 +30,7 @@ if ! which qmp >/dev/null 2>/dev/null; then
if ! test -x "${qmp}"; then
echo "Please set QEMU_SRC to set to a recent qemu.git tree"
+ cleanup
exit 1
fi
else
@@ -182,7 +190,6 @@ QEMU_TEST=1
. "$1"
rc=$?
-rm -f $tmplog $tmppid $tmpqmp $tmpinitrd
-rm -rf $tmpdir $tmprc
+cleanup
exit $rc
--
1.7.6
[Qemu-devel] [PATCH 4/4] Apply consistent indentation, Ryan Harper, 2012/01/13