+/*
+ * WL handler which checks the overridden Qos and then handoffs the IPC,
+ * enables the knote and checks for the Qos again that it hasn't dropped the sync ipc override.
+ */
+static void
+workloop_cb_test_sync_send_and_enable_handoff(uint64_t *workloop_id, struct kevent_qos_s **eventslist, int *events)
+{
+ unsigned override_priority;
+ int error;
+
+ T_LOG("Workloop handler workloop_cb_test_sync_send_and_enable_handoff called");
+
+ EXPECT_TEST_MSG(*eventslist);
+
+ if (geteuid() != 0) {
+ T_SKIP("kevent_qos test requires root privileges to run.");
+ }
+
+ /* The effective Qos should be the one expected after override */
+ EXPECT_QOS_EQ(g_expected_qos[ENV_QOS_AFTER_OVERRIDE],
+ "dispatch_source event handler QoS should be %s",
+ g_expected_qos_name[ENV_QOS_AFTER_OVERRIDE]);
+
+ /* Snapshot the current override priority */
+ override_priority = get_user_promotion_basepri();
+
+ struct kevent_qos_s *kev = *eventslist;
+ mach_msg_header_t *hdr = (mach_msg_header_t *)kev->ext[0];
+
+ /* handoff the IPC */
+ struct kevent_qos_s handoff_kev = {
+ .filter = EVFILT_WORKLOOP,
+ .ident = hdr->msgh_remote_port,
+ .flags = EV_ADD | EV_DISABLE,
+ .fflags = 0x80000000,
+ };
+
+ error = kevent_id(*workloop_id, &handoff_kev, 1, &handoff_kev, 1, NULL,
+ NULL, KEVENT_FLAG_WORKLOOP | KEVENT_FLAG_ERROR_EVENTS | KEVENT_FLAG_DYNAMIC_KQ_MUST_EXIST);
+ T_QUIET; T_ASSERT_POSIX_SUCCESS(error, "kevent_id");
+ T_ASSERT_EQ(0, error, "Handed off the sync IPC");
+
+ /* Enable the knote */
+ enable_kevent(workloop_id, kev->ident);
+
+ /*
+ * Check if the override has not been dropped.
+ */
+ EXPECT_QOS_EQ(g_expected_qos[ENV_QOS_AFTER_OVERRIDE],
+ "dispatch_source event handler QoS should still be %s",
+ g_expected_qos_name[ENV_QOS_AFTER_OVERRIDE]);
+
+ *events = 0;
+ T_END;
+}
+