This source file includes following definitions.
- START_PARAMETRIZED_TEST
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #define TEST_SUITE_NAME "/lib/vfs"
27
28 #include "tests/mctest.h"
29
30 #include <sys/stat.h>
31
32
33
34
35
36 static const struct test_vfs_adjust_stat_ds
37 {
38 struct stat etalon_stat;
39 } test_vfs_adjust_stat_ds[] =
40 {
41
42 {
43 .etalon_stat =
44 {
45 .st_size = 0,
46 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
47 .st_blksize = 512,
48 #endif
49 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
50 .st_blocks = 0
51 #endif
52 }
53 },
54
55 {
56 .etalon_stat =
57 {
58 .st_size = 4096,
59 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
60 .st_blksize = 512,
61 #endif
62 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
63 .st_blocks = 8
64 #endif
65 }
66 },
67
68 {
69 .etalon_stat =
70 {
71 .st_size = 4096,
72 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
73 .st_blksize = 1024,
74 #endif
75 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
76 .st_blocks = 8
77 #endif
78 }
79 },
80
81 {
82 .etalon_stat =
83 {
84 .st_size = 4096,
85 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
86 .st_blksize = 2048,
87 #endif
88 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
89 .st_blocks = 8
90 #endif
91 }
92 },
93
94 {
95 .etalon_stat =
96 {
97 .st_size = 4096,
98 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
99 .st_blksize = 4096,
100 #endif
101 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
102 .st_blocks = 8
103 #endif
104 }
105 },
106
107 {
108 .etalon_stat =
109 {
110 .st_size = 5000,
111 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
112 .st_blksize = 512,
113 #endif
114 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
115 .st_blocks = 10
116 #endif
117 }
118 },
119
120 {
121 .etalon_stat =
122 {
123 .st_size = 5000,
124 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
125 .st_blksize = 1024,
126 #endif
127 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
128 .st_blocks = 10
129 #endif
130 }
131 },
132
133 {
134 .etalon_stat =
135 {
136 .st_size = 5000,
137 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
138 .st_blksize = 2048,
139 #endif
140 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
141 .st_blocks = 12
142 #endif
143 }
144 },
145
146 {
147 .etalon_stat =
148 {
149 .st_size = 5000,
150 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
151 .st_blksize = 4096,
152 #endif
153 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
154 .st_blocks = 16
155 #endif
156 }
157 }
158 };
159
160
161
162
163
164
165 START_PARAMETRIZED_TEST (test_vfs_adjust_stat, test_vfs_adjust_stat_ds)
166
167 {
168 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
169
170 struct stat expected_stat;
171
172 expected_stat.st_size = data->etalon_stat.st_size;
173 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
174 expected_stat.st_blksize = data->etalon_stat.st_blksize;
175 #endif
176
177 vfs_adjust_stat (&expected_stat);
178
179
180 ck_assert_int_eq (data->etalon_stat.st_blocks, expected_stat.st_blocks);
181 #else
182 ck_assert_int_eq (0, 0);
183 #endif
184 }
185
186 END_PARAMETRIZED_TEST
187
188
189
190
191 int
192 main (void)
193 {
194 TCase *tc_core;
195
196 tc_core = tcase_create ("Core");
197
198
199 mctest_add_parameterized_test (tc_core, test_vfs_adjust_stat, test_vfs_adjust_stat_ds);
200
201
202 return mctest_run_all (tc_core);
203 }
204
205