3 #include <mach/mach_host.h>
5 #include <darwintest.h>
7 static void do_test(int notify_type
, void (^trigger_block
)(void)){
9 T_ASSERT_MACH_SUCCESS(mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE
, &port
), NULL
);
11 T_ASSERT_MACH_SUCCESS(host_request_notification(mach_host_self(), notify_type
, port
), NULL
);
16 mach_msg_header_t hdr
;
17 mach_msg_trailer_t trailer
;
18 } message
= { .hdr
= {
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
,
27 T_ASSERT_EQ(MACH_RCV_TOO_LARGE
, mach_msg_receive(&message
.hdr
), NULL
);
28 mach_msg_destroy(&message
.hdr
);
31 T_DECL(host_notify_calendar_change
, "host_request_notification(HOST_NOTIFY_CALENDAR_CHANGE)", T_META_CHECK_LEAKS(false), T_META_LTEPHASE(LTE_POSTINIT
))
33 do_test(HOST_NOTIFY_CALENDAR_CHANGE
, ^{
35 if (gettimeofday(&tm
, NULL
) != 0 || settimeofday(&tm
, NULL
) != 0){
36 T_SKIP("Unable to settimeofday()");
41 T_DECL(host_notify_calendar_set
, "host_request_notification(HOST_NOTIFY_CALENDAR_SET)", T_META_CHECK_LEAKS(false), T_META_LTEPHASE(LTE_POSTINIT
))
43 do_test(HOST_NOTIFY_CALENDAR_SET
, ^{
45 if (gettimeofday(&tm
, NULL
) != 0 || settimeofday(&tm
, NULL
) != 0){
46 T_SKIP("Unable to settimeofday()");