]>
Commit | Line | Data |
---|---|---|
39037602 A |
1 | #include <sys/time.h> |
2 | #include <mach/mach.h> | |
3 | #include <mach/mach_host.h> | |
4 | ||
5 | #include <darwintest.h> | |
6 | ||
7 | static void do_test(int notify_type, void (^trigger_block)(void)){ | |
8 | mach_port_t port; | |
9 | T_ASSERT_MACH_SUCCESS(mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &port), NULL); | |
10 | ||
11 | T_ASSERT_MACH_SUCCESS(host_request_notification(mach_host_self(), notify_type, port), NULL); | |
12 | ||
13 | trigger_block(); | |
14 | ||
15 | struct { | |
16 | mach_msg_header_t hdr; | |
17 | mach_msg_trailer_t trailer; | |
18 | } message = { .hdr = { | |
19 | .msgh_bits = 0, | |
20 | .msgh_size = sizeof(mach_msg_header_t), | |
21 | .msgh_remote_port = MACH_PORT_NULL, | |
22 | .msgh_local_port = port, | |
23 | .msgh_voucher_port = MACH_PORT_NULL, | |
24 | .msgh_id = 0, | |
25 | }}; | |
26 | ||
27 | T_ASSERT_EQ(MACH_RCV_TOO_LARGE, mach_msg_receive(&message.hdr), NULL); | |
28 | mach_msg_destroy(&message.hdr); | |
29 | } | |
30 | ||
813fb2f6 | 31 | T_DECL(host_notify_calendar_change, "host_request_notification(HOST_NOTIFY_CALENDAR_CHANGE)", T_META_CHECK_LEAKS(false), T_META_LTEPHASE(LTE_POSTINIT)) |
39037602 A |
32 | { |
33 | do_test(HOST_NOTIFY_CALENDAR_CHANGE, ^{ | |
34 | struct timeval tm; | |
35 | if (gettimeofday(&tm, NULL) != 0 || settimeofday(&tm, NULL) != 0){ | |
36 | T_SKIP("Unable to settimeofday()"); | |
37 | } | |
38 | }); | |
39 | } | |
40 | ||
813fb2f6 | 41 | T_DECL(host_notify_calendar_set, "host_request_notification(HOST_NOTIFY_CALENDAR_SET)", T_META_CHECK_LEAKS(false), T_META_LTEPHASE(LTE_POSTINIT)) |
39037602 A |
42 | { |
43 | do_test(HOST_NOTIFY_CALENDAR_SET, ^{ | |
44 | struct timeval tm; | |
45 | if (gettimeofday(&tm, NULL) != 0 || settimeofday(&tm, NULL) != 0){ | |
46 | T_SKIP("Unable to settimeofday()"); | |
47 | } | |
48 | }); | |
49 | } |