3 #include <mach/mach_host.h>
5 #include <darwintest.h>
8 do_test(int notify_type
, void (^trigger_block
)(void))
11 T_ASSERT_MACH_SUCCESS(mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE
, &port
), NULL
);
13 T_ASSERT_MACH_SUCCESS(host_request_notification(mach_host_self(), notify_type
, port
), NULL
);
18 mach_msg_header_t hdr
;
19 mach_msg_trailer_t trailer
;
20 } message
= { .hdr
= {
22 .msgh_size
= sizeof(mach_msg_header_t
),
23 .msgh_remote_port
= MACH_PORT_NULL
,
24 .msgh_local_port
= port
,
25 .msgh_voucher_port
= MACH_PORT_NULL
,
29 T_ASSERT_EQ(MACH_RCV_TOO_LARGE
, mach_msg_receive(&message
.hdr
), NULL
);
30 mach_msg_destroy(&message
.hdr
);
33 T_DECL(host_notify_calendar_change
, "host_request_notification(HOST_NOTIFY_CALENDAR_CHANGE)", T_META_CHECK_LEAKS(false), T_META_LTEPHASE(LTE_POSTINIT
))
35 do_test(HOST_NOTIFY_CALENDAR_CHANGE
, ^{
37 if (gettimeofday(&tm
, NULL
) != 0 || settimeofday(&tm
, NULL
) != 0) {
38 T_SKIP("Unable to settimeofday()");
43 T_DECL(host_notify_calendar_set
, "host_request_notification(HOST_NOTIFY_CALENDAR_SET)", T_META_CHECK_LEAKS(false), T_META_LTEPHASE(LTE_POSTINIT
))
45 do_test(HOST_NOTIFY_CALENDAR_SET
, ^{
47 if (gettimeofday(&tm
, NULL
) != 0 || settimeofday(&tm
, NULL
) != 0) {
48 T_SKIP("Unable to settimeofday()");