1 /*
2 * Copyright (c) 2016 Linux Test Project
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <stdlib.h>
19 #include <sys/mount.h>
20 #include <stdint.h>
21
22 #include "tst_test.h"
23
do_test(void)24 static void do_test(void)
25 {
26 int fd;
27 const char *dev;
28 uint64_t ltp_dev_size;
29
30 dev = tst_device->dev;
31 if (!dev)
32 tst_brk(TCONF, "Failed to acquire test device");
33
34 SAFE_MKFS(dev, "ext2", NULL, NULL);
35
36 fd = SAFE_OPEN(dev, O_RDONLY);
37 SAFE_IOCTL(fd, BLKGETSIZE64, <p_dev_size);
38 SAFE_CLOSE(fd);
39
40 if (ltp_dev_size/1024/1024 == 300)
41 tst_res(TPASS, "Got expected device size");
42 else
43 tst_res(TFAIL, "Got unexpected device size");
44 }
45
46 static struct tst_test test = {
47 .needs_tmpdir = 1,
48 .needs_device = 1,
49 .dev_min_size = 300,
50 .test_all = do_test,
51 };
52