| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: t_stat.c,v 1.4 2011/06/07 19:06:39 jruoho Exp $ */ | | 1 | /* $NetBSD: t_stat.c,v 1.5 2011/06/08 05:28:03 jruoho Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2011 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2011 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jukka Ruohonen. | | 8 | * by Jukka Ruohonen. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -19,39 +19,41 @@ | | | @@ -19,39 +19,41 @@ |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | #include <sys/cdefs.h> | | 31 | #include <sys/cdefs.h> |
32 | __RCSID("$NetBSD: t_stat.c,v 1.4 2011/06/07 19:06:39 jruoho Exp $"); | | 32 | __RCSID("$NetBSD: t_stat.c,v 1.5 2011/06/08 05:28:03 jruoho Exp $"); |
33 | | | 33 | |
34 | #include <sys/stat.h> | | 34 | #include <sys/stat.h> |
35 | #include <sys/types.h> | | 35 | #include <sys/types.h> |
36 | | | 36 | |
37 | #include <atf-c.h> | | 37 | #include <atf-c.h> |
38 | #include <errno.h> | | 38 | #include <errno.h> |
39 | #include <fcntl.h> | | 39 | #include <fcntl.h> |
40 | #include <fts.h> | | 40 | #include <fts.h> |
41 | #include <limits.h> | | 41 | #include <limits.h> |
42 | #include <string.h> | | 42 | #include <string.h> |
43 | #include <unistd.h> | | 43 | #include <unistd.h> |
44 | | | 44 | |
| | | 45 | #include <stdio.h> |
| | | 46 | |
45 | static const char *path = "stat"; | | 47 | static const char *path = "stat"; |
46 | | | 48 | |
47 | ATF_TC_WITH_CLEANUP(stat_chflags); | | 49 | ATF_TC_WITH_CLEANUP(stat_chflags); |
48 | ATF_TC_HEAD(stat_chflags, tc) | | 50 | ATF_TC_HEAD(stat_chflags, tc) |
49 | { | | 51 | { |
50 | atf_tc_set_md_var(tc, "descr", "Test chflags(2) with stat(2)"); | | 52 | atf_tc_set_md_var(tc, "descr", "Test chflags(2) with stat(2)"); |
51 | } | | 53 | } |
52 | | | 54 | |
53 | ATF_TC_BODY(stat_chflags, tc) | | 55 | ATF_TC_BODY(stat_chflags, tc) |
54 | { | | 56 | { |
55 | struct stat sa, sb; | | 57 | struct stat sa, sb; |
56 | int fd; | | 58 | int fd; |
57 | | | 59 | |
| @@ -75,37 +77,38 @@ ATF_TC_BODY(stat_chflags, tc) | | | @@ -75,37 +77,38 @@ ATF_TC_BODY(stat_chflags, tc) |
75 | ATF_TC_CLEANUP(stat_chflags, tc) | | 77 | ATF_TC_CLEANUP(stat_chflags, tc) |
76 | { | | 78 | { |
77 | (void)unlink(path); | | 79 | (void)unlink(path); |
78 | } | | 80 | } |
79 | | | 81 | |
80 | ATF_TC(stat_dir); | | 82 | ATF_TC(stat_dir); |
81 | ATF_TC_HEAD(stat_dir, tc) | | 83 | ATF_TC_HEAD(stat_dir, tc) |
82 | { | | 84 | { |
83 | atf_tc_set_md_var(tc, "descr", "Test stat(2) with directories"); | | 85 | atf_tc_set_md_var(tc, "descr", "Test stat(2) with directories"); |
84 | } | | 86 | } |
85 | | | 87 | |
86 | ATF_TC_BODY(stat_dir, tc) | | 88 | ATF_TC_BODY(stat_dir, tc) |
87 | { | | 89 | { |
88 | /* | | | |
89 | * XXX: This panics qemu/i386 guest. | | | |
90 | */ | | | |
91 | #if 0 | | | |
92 | const short depth = 3; | | 90 | const short depth = 3; |
93 | struct stat sa, sb; | | 91 | struct stat sa, sb; |
94 | char *argv[2]; | | 92 | char *argv[2]; |
95 | FTSENT *ftse; | | 93 | FTSENT *ftse; |
96 | FTS *fts; | | 94 | FTS *fts; |
97 | int ops; | | 95 | int ops; |
98 | | | 96 | |
| | | 97 | /* |
| | | 98 | * XXX: This is verified to panic at least a qemu/i386 guest. |
| | | 99 | */ |
| | | 100 | atf_tc_skip("the test may cause a panic"); |
| | | 101 | |
99 | argv[1] = NULL; | | 102 | argv[1] = NULL; |
100 | argv[0] = __UNCONST("/"); | | 103 | argv[0] = __UNCONST("/"); |
101 | | | 104 | |
102 | ops = FTS_NOCHDIR; | | 105 | ops = FTS_NOCHDIR; |
103 | ops |= FTS_PHYSICAL; | | 106 | ops |= FTS_PHYSICAL; |
104 | | | 107 | |
105 | fts = fts_open(argv, ops, NULL); | | 108 | fts = fts_open(argv, ops, NULL); |
106 | ATF_REQUIRE(fts != NULL); | | 109 | ATF_REQUIRE(fts != NULL); |
107 | | | 110 | |
108 | while ((ftse = fts_read(fts)) != NULL) { | | 111 | while ((ftse = fts_read(fts)) != NULL) { |
109 | | | 112 | |
110 | if (ftse->fts_level < 1) | | 113 | if (ftse->fts_level < 1) |
111 | continue; | | 114 | continue; |
| @@ -138,27 +141,26 @@ ATF_TC_BODY(stat_dir, tc) | | | @@ -138,27 +141,26 @@ ATF_TC_BODY(stat_dir, tc) |
138 | * call equals the manual one. | | 141 | * call equals the manual one. |
139 | */ | | 142 | */ |
140 | if (sb.st_ino != ftse->fts_statp->st_ino) | | 143 | if (sb.st_ino != ftse->fts_statp->st_ino) |
141 | atf_tc_fail("stat(2) and fts(3) differ"); | | 144 | atf_tc_fail("stat(2) and fts(3) differ"); |
142 | | | 145 | |
143 | break; | | 146 | break; |
144 | | | 147 | |
145 | default: | | 148 | default: |
146 | break; | | 149 | break; |
147 | } | | 150 | } |
148 | } | | 151 | } |
149 | | | 152 | |
150 | (void)fts_close(fts); | | 153 | (void)fts_close(fts); |
151 | #endif | | | |
152 | } | | 154 | } |
153 | | | 155 | |
154 | ATF_TC(stat_err); | | 156 | ATF_TC(stat_err); |
155 | ATF_TC_HEAD(stat_err, tc) | | 157 | ATF_TC_HEAD(stat_err, tc) |
156 | { | | 158 | { |
157 | atf_tc_set_md_var(tc, "descr", "Test errors from the stat(2) family"); | | 159 | atf_tc_set_md_var(tc, "descr", "Test errors from the stat(2) family"); |
158 | } | | 160 | } |
159 | | | 161 | |
160 | ATF_TC_BODY(stat_err, tc) | | 162 | ATF_TC_BODY(stat_err, tc) |
161 | { | | 163 | { |
162 | char buf[NAME_MAX + 1]; | | 164 | char buf[NAME_MAX + 1]; |
163 | struct stat st; | | 165 | struct stat st; |
164 | | | 166 | |