]>
git.proxmox.com Git - mirror_spl.git/blob - src/splat/splat-time.c
1 #include <sys/zfs_context.h>
2 #include <sys/splat-ctl.h>
4 #define KZT_SUBSYSTEM_TIME 0x0800
5 #define KZT_TIME_NAME "time"
6 #define KZT_TIME_DESC "Kernel Time Tests"
8 #define KZT_TIME_TEST1_ID 0x0801
9 #define KZT_TIME_TEST1_NAME "time1"
10 #define KZT_TIME_TEST1_DESC "HZ Test"
12 #define KZT_TIME_TEST2_ID 0x0802
13 #define KZT_TIME_TEST2_NAME "time2"
14 #define KZT_TIME_TEST2_DESC "Monotonic Test"
17 kzt_time_test1(struct file
*file
, void *arg
)
20 kzt_vprint(file
, KZT_TIME_TEST1_NAME
, "hz is %d\n", myhz
);
25 kzt_time_test2(struct file
*file
, void *arg
)
31 kzt_vprint(file
, KZT_TIME_TEST2_NAME
, "time is %lld\n", tm1
);
33 for(i
= 0; i
< 100; i
++) {
35 kzt_vprint(file
, KZT_TIME_TEST2_NAME
, "time is %lld\n", tm2
);
38 kzt_print(file
, "%s: gethrtime() is not giving monotonically increasing values\n", KZT_TIME_TEST2_NAME
);
43 set_current_state(TASK_INTERRUPTIBLE
);
55 sub
= kmalloc(sizeof(*sub
), GFP_KERNEL
);
59 memset(sub
, 0, sizeof(*sub
));
60 strncpy(sub
->desc
.name
, KZT_TIME_NAME
, KZT_NAME_SIZE
);
61 strncpy(sub
->desc
.desc
, KZT_TIME_DESC
, KZT_DESC_SIZE
);
62 INIT_LIST_HEAD(&sub
->subsystem_list
);
63 INIT_LIST_HEAD(&sub
->test_list
);
64 spin_lock_init(&sub
->test_lock
);
65 sub
->desc
.id
= KZT_SUBSYSTEM_TIME
;
67 KZT_TEST_INIT(sub
, KZT_TIME_TEST1_NAME
, KZT_TIME_TEST1_DESC
,
68 KZT_TIME_TEST1_ID
, kzt_time_test1
);
69 KZT_TEST_INIT(sub
, KZT_TIME_TEST2_NAME
, KZT_TIME_TEST2_DESC
,
70 KZT_TIME_TEST2_ID
, kzt_time_test2
);
76 kzt_time_fini(kzt_subsystem_t
*sub
)
80 KZT_TEST_FINI(sub
, KZT_TIME_TEST2_ID
);
81 KZT_TEST_FINI(sub
, KZT_TIME_TEST1_ID
);
89 return KZT_SUBSYSTEM_TIME
;