]> git.saurik.com Git - apple/hfs.git/blob - tests/cases/test-scan-range-size.c
hfs-366.70.1.tar.gz
[apple/hfs.git] / tests / cases / test-scan-range-size.c
1 /*
2 * Copyright (c) 2015 Apple, Inc. All rights reserved.
3 *
4 * <rdar://problem/20565191> hfs_scan_range_size return 0 iosize unexpectedly.
5 */
6
7 #include <TargetConditionals.h>
8
9 #if !TARGET_OS_EMBEDDED
10
11 #include <sys/ioctl.h>
12 #include <sys/ioccom.h>
13 #include <sys/param.h>
14 #include <sys/mount.h>
15 #include <stdio.h>
16 #include <unistd.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <sys/errno.h>
20 #include <sys/stat.h>
21 #include <fcntl.h>
22 #include <pthread.h>
23 #include <signal.h>
24 #include <spawn.h>
25
26 #include "../../core/hfs_fsctl.h"
27
28 #include "hfs-tests.h"
29 #include "test-utils.h"
30 #include "systemx.h"
31 #include "disk-image.h"
32
33 TEST(scan_range_size, .run_as_root = true)
34
35 static disk_image_t *di;
36
37 static hfs_fsinfo fsinfo;
38
39 static void test_fsinfo_file_extent_size(void)
40 {
41 bzero(&fsinfo, sizeof(fsinfo));
42 fsinfo.header.request_type = HFS_FSINFO_FILE_EXTENT_SIZE;
43 fsinfo.header.version = HFS_FSINFO_VERSION;
44 assert_no_err(fsctl(di->mount_point, HFSIOC_GET_FSINFO, &fsinfo, 0));
45 }
46
47 static void test_fsinfo_free_extents(void)
48 {
49 bzero(&fsinfo, sizeof(fsinfo));
50 fsinfo.header.version = HFS_FSINFO_VERSION;
51 fsinfo.header.request_type = HFS_FSINFO_FREE_EXTENTS;
52 assert_no_err(fsctl(di->mount_point, HFSIOC_GET_FSINFO, &fsinfo, 0));
53 }
54
55
56 int run_scan_range_size(__unused test_ctx_t *ctx) {
57
58 di = disk_image_get();
59
60 test_fsinfo_file_extent_size();
61 test_fsinfo_free_extents();
62
63 return 0;
64 }
65
66 #endif // !TARGET_OS_EMBEDDED