7 #include "test-utils.h"
8 #include "../core/hfs_fsctl.h"
9 #include "disk-image.h"
13 int run_disklevel(__unused test_ctx_t
*ctx
)
15 disk_image_t
*di
= disk_image_get();
16 const char *test_hfs_volume
= di
->mount_point
;
17 uint32_t very_low_disk
= 0, low_disk
= 0, near_low_disk
= 0, desired_disk
= 0;
19 // Make sure initial values are sane.
20 assert_no_err(fsctl(test_hfs_volume
, HFSIOC_GET_VERY_LOW_DISK
, &very_low_disk
, 0));
21 assert_no_err(fsctl(test_hfs_volume
, HFSIOC_GET_LOW_DISK
, &low_disk
, 0));
22 assert_no_err(fsctl(test_hfs_volume
, APFSIOC_GET_NEAR_LOW_DISK
, &near_low_disk
, 0));
23 assert_no_err(fsctl(test_hfs_volume
, HFSIOC_GET_DESIRED_DISK
, &desired_disk
, 0));
24 assert(very_low_disk
> 0);
25 assert(very_low_disk
< low_disk
);
26 assert(low_disk
< near_low_disk
);
27 assert(near_low_disk
< desired_disk
);
33 // Re-assign the values to new legal values and make sure they are preserved.
34 assert_no_err(fsctl(test_hfs_volume
, HFSIOC_SET_VERY_LOW_DISK
, &very_low_disk
, 0));
35 assert_no_err(fsctl(test_hfs_volume
, HFSIOC_SET_LOW_DISK
, &low_disk
, 0));
36 assert_no_err(fsctl(test_hfs_volume
, APFSIOC_SET_NEAR_LOW_DISK
, &near_low_disk
, 0));
37 assert_no_err(fsctl(test_hfs_volume
, HFSIOC_SET_DESIRED_DISK
, &desired_disk
, 0));
39 assert_no_err(fsctl(test_hfs_volume
, HFSIOC_GET_VERY_LOW_DISK
, &very_low_disk
, 0));
40 assert_no_err(fsctl(test_hfs_volume
, HFSIOC_GET_LOW_DISK
, &low_disk
, 0));
41 assert_no_err(fsctl(test_hfs_volume
, APFSIOC_GET_NEAR_LOW_DISK
, &near_low_disk
, 0));
42 assert_no_err(fsctl(test_hfs_volume
, HFSIOC_GET_DESIRED_DISK
, &desired_disk
, 0));
43 assert_equal(very_low_disk
, 1, "%d");
44 assert_equal(low_disk
, 2, "%d");
45 assert_equal(near_low_disk
, 3, "%d");
46 assert_equal(desired_disk
, 4, "%d");
48 // Now, attempt to reassign the levels to illegal values and make sure they don't lose their previous value.
53 assert(fsctl(test_hfs_volume
, HFSIOC_SET_VERY_LOW_DISK
, &very_low_disk
, 0) < 0);
54 assert(fsctl(test_hfs_volume
, HFSIOC_SET_LOW_DISK
, &low_disk
, 0) < 0);
55 assert(fsctl(test_hfs_volume
, APFSIOC_SET_NEAR_LOW_DISK
, &near_low_disk
, 0) < 0);
56 assert(fsctl(test_hfs_volume
, HFSIOC_SET_DESIRED_DISK
, &desired_disk
, 0) < 0);
58 assert_no_err(fsctl(test_hfs_volume
, HFSIOC_GET_VERY_LOW_DISK
, &very_low_disk
, 0));
59 assert_no_err(fsctl(test_hfs_volume
, HFSIOC_GET_LOW_DISK
, &low_disk
, 0));
60 assert_no_err(fsctl(test_hfs_volume
, APFSIOC_GET_NEAR_LOW_DISK
, &near_low_disk
, 0));
61 assert_no_err(fsctl(test_hfs_volume
, HFSIOC_GET_DESIRED_DISK
, &desired_disk
, 0));
62 assert_equal(very_low_disk
, 1, "%d");
63 assert_equal(low_disk
, 2, "%d");
64 assert_equal(near_low_disk
, 3, "%d");
65 assert_equal(desired_disk
, 4, "%d");