Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/kernel Use an ATF_TC_CLEANUP() routine to delete the m...
details: https://anonhg.NetBSD.org/src/rev/f5e35f7b09a0
branches: trunk
changeset: 782567:f5e35f7b09a0
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Tue Nov 06 19:35:38 2012 +0000
description:
Use an ATF_TC_CLEANUP() routine to delete the mkdtemp() directory even
if the test case fails/exits sooner.
diffstat:
tests/kernel/t_mqueue.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diffs (54 lines):
diff -r cd8215af0477 -r f5e35f7b09a0 tests/kernel/t_mqueue.c
--- a/tests/kernel/t_mqueue.c Tue Nov 06 19:08:45 2012 +0000
+++ b/tests/kernel/t_mqueue.c Tue Nov 06 19:35:38 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mqueue.c,v 1.2 2012/11/06 13:55:03 apb Exp $ */
+/* $NetBSD: t_mqueue.c,v 1.3 2012/11/06 19:35:38 pgoyette Exp $ */
/*
* Test for POSIX message queue priority handling.
@@ -16,6 +16,8 @@
#include <mqueue.h>
+char *tmpdir;
+
#define MQ_PRIO_BASE 24
static void
@@ -96,7 +98,7 @@
"mq_receive 6 prio/data mismatch");
}
-ATF_TC(mqueue);
+ATF_TC_WITH_CLEANUP(mqueue);
ATF_TC_HEAD(mqueue, tc)
{
@@ -107,7 +109,6 @@
ATF_TC_BODY(mqueue, tc)
{
int status;
- char *tmpdir;
char template[32];
char mq_name[64];
@@ -127,8 +128,16 @@
status = mq_close(mqfd);
ATF_REQUIRE_MSG(status == 0, "mq_close failed: %d", errno);
- status = rmdir(tmpdir);
- ATF_REQUIRE_MSG(status == 0, "rmdir failed: %d", errno);
+}
+
+ATF_TC_CLEANUP(mqueue, tc)
+{
+ int status;
+
+ if (tmpdir != NULL) {
+ status = rmdir(tmpdir);
+ ATF_REQUIRE_MSG(status == 0, "rmdir failed: %d", errno);
+ }
}
ATF_TP_ADD_TCS(tp)
Home |
Main Index |
Thread Index |
Old Index