Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libc/gen PR/51808: Ngie Cooper: fix leaks, sort in...
details: https://anonhg.NetBSD.org/src/rev/08bc245253df
branches: trunk
changeset: 350333:08bc245253df
user: christos <christos%NetBSD.org@localhost>
date: Tue Jan 10 15:19:00 2017 +0000
description:
PR/51808: Ngie Cooper: fix leaks, sort includes, check returns
diffstat:
tests/lib/libc/gen/t_dir.c | 29 +++++++++++++++++++++--------
1 files changed, 21 insertions(+), 8 deletions(-)
diffs (73 lines):
diff -r 214f829e9626 -r 08bc245253df tests/lib/libc/gen/t_dir.c
--- a/tests/lib/libc/gen/t_dir.c Tue Jan 10 15:17:57 2017 +0000
+++ b/tests/lib/libc/gen/t_dir.c Tue Jan 10 15:19:00 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_dir.c,v 1.6 2013/10/19 17:45:00 christos Exp $ */
+/* $NetBSD: t_dir.c,v 1.7 2017/01/10 15:19:00 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -26,18 +26,19 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/stat.h>
+#include <assert.h>
#include <atf-c.h>
-
-#include <assert.h>
#include <dirent.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <sys/stat.h>
+
ATF_TC(seekdir_basic);
ATF_TC_HEAD(seekdir_basic, tc)
@@ -54,10 +55,19 @@
struct dirent *entry;
long here;
- mkdir("t", 0755);
- creat("t/a", 0600);
- creat("t/b", 0600);
- creat("t/c", 0600);
+#define CREAT(x, m) do { \
+ int _creat_fd; \
+ ATF_REQUIRE_MSG((_creat_fd = creat((x), (m))), \
+ "creat(%s, %x) failed: %s", (x), (m), \
+ strerror(errno)); \
+ (void)close(_creat_fd); \
+ } while(0);
+
+ ATF_REQUIRE_MSG(mkdir("t", 0755) == 0,
+ "mkdir failed: %s", strerror(errno));
+ CREAT("t/a", 0600);
+ CREAT("t/b", 0600);
+ CREAT("t/c", 0600);
dp = opendir("t");
if ( dp == NULL)
@@ -70,6 +80,8 @@
/* get first entry */
entry = readdir(dp);
here = telldir(dp);
+ ATF_REQUIRE_MSG(here != -1,
+ "telldir failed: %s", strerror(errno));
/* get second entry */
entry = readdir(dp);
@@ -109,6 +121,7 @@
atf_tc_fail("3rd seekdir found wrong name");
closedir(dp);
+ free(wasname);
}
ATF_TC(telldir_leak);
Home |
Main Index |
Thread Index |
Old Index