• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2016 Linux Test Project
4  */
5 
6 #include <stdlib.h>
7 #include <sys/mount.h>
8 #include <stdint.h>
9 
10 #include "tst_test.h"
11 
do_test(void)12 static void do_test(void)
13 {
14 	int fd;
15 	const char *dev;
16 	uint64_t ltp_dev_size;
17 
18 	dev = tst_device->dev;
19 	if (!dev)
20 		tst_brk(TCONF, "Failed to acquire test device");
21 
22 	SAFE_MKFS(dev, "ext2", NULL, NULL);
23 
24 	fd = SAFE_OPEN(dev, O_RDONLY);
25 	SAFE_IOCTL(fd, BLKGETSIZE64, &ltp_dev_size);
26 	SAFE_CLOSE(fd);
27 
28 	if (ltp_dev_size/1024/1024 == 300)
29 		tst_res(TPASS, "Got expected device size");
30 	else
31 		tst_res(TFAIL, "Got unexpected device size");
32 }
33 
34 static struct tst_test test = {
35 	.needs_device = 1,
36 	.dev_min_size = 300,
37 	.test_all = do_test,
38 };
39