From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:36250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlpGg-00042x-QL for qemu-devel@nongnu.org; Fri, 13 Jan 2012 17:06:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlpGY-0007y1-Mg for qemu-devel@nongnu.org; Fri, 13 Jan 2012 17:06:38 -0500 Received: from e34.co.us.ibm.com ([32.97.110.152]:52860) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlpGY-0007xt-G8 for qemu-devel@nongnu.org; Fri, 13 Jan 2012 17:06:30 -0500 Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 13 Jan 2012 15:06:29 -0700 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q0DM6G0k092538 for ; Fri, 13 Jan 2012 15:06:17 -0700 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q0DM6Cg8030230 for ; Fri, 13 Jan 2012 15:06:12 -0700 From: Ryan Harper Date: Fri, 13 Jan 2012 16:05:19 -0600 Message-Id: <1326492321-13540-3-git-send-email-ryanh@us.ibm.com> In-Reply-To: <1326492321-13540-1-git-send-email-ryanh@us.ibm.com> References: <1326492321-13540-1-git-send-email-ryanh@us.ibm.com> Subject: [Qemu-devel] [PATCH 2/4] Add cleanup function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Ryan Harper 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 --- 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