2 lib/vfs - test vfs_adjust_stat() functionality
4 Copyright (C) 2017-2021
5 Free Software Foundation, Inc.
8 Andrew Borodin <aborodin@vmail.ru>, 2017
10 This file is part of the Midnight Commander.
12 The Midnight Commander is free software: you can redistribute it
13 and/or modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation, either version 3 of the License,
15 or (at your option) any later version.
17 The Midnight Commander is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #define TEST_SUITE_NAME "/lib/vfs"
28 #include "tests/mctest.h"
32 /* --------------------------------------------------------------------------------------------- */
34 /* @DataSource("test_test_vfs_adjust_stat_ds") */
36 static const struct test_vfs_adjust_stat_ds
38 struct stat etalon_stat
;
39 } test_vfs_adjust_stat_ds
[] =
46 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
49 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
59 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
62 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
72 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
75 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
85 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
88 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
98 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
101 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
111 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
114 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
124 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
127 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
137 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
140 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
150 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
153 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
161 /* --------------------------------------------------------------------------------------------- */
163 /* @Test(dataSource = "test_vfs_adjust_stat_ds") */
165 START_PARAMETRIZED_TEST (test_vfs_adjust_stat
, test_vfs_adjust_stat_ds
)
168 #ifdef HAVE_STRUCT_STAT_ST_BLOCKS
170 struct stat expected_stat
;
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 /* HAVE_STRUCT_STAT_ST_BLKSIZE */
177 vfs_adjust_stat (&expected_stat
);
180 mctest_assert_int_eq (data
->etalon_stat
.st_blocks
, expected_stat
.st_blocks
);
182 mctest_assert_int_eq (0, 0);
183 #endif /* HAVE_STRUCT_STAT_ST_BLOCKS */
186 END_PARAMETRIZED_TEST
189 /* --------------------------------------------------------------------------------------------- */
196 tc_core
= tcase_create ("Core");
198 /* Add new tests here: *************** */
199 mctest_add_parameterized_test (tc_core
, test_vfs_adjust_stat
, test_vfs_adjust_stat_ds
);
200 /* *********************************** */
202 return mctest_run_all (tc_core
);
205 /* --------------------------------------------------------------------------------------------- */