1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright 2018 Joyent, Inc. 14 */ 15 16 #include "../../../mevent.c" 17 #include "testlib.h" 18 19 /* 20 * Returns by reference the number of events on the global and change lists. 21 * 22 * Used by tests that wish to ensure that the event count changes as suggested 23 * by mevent_add() and mevent_delete(). Note that a delete does not immediately 24 * delete an event. Events that are pending delete are included in the change 25 * list until the next pass through the change list to process pending changes. 26 */ 27 void 28 test_mevent_count_lists(int *ret_global, int *ret_change, int *ret_del_pending) 29 { 30 struct mevent *mevp; 31 int global = 0; 32 int change = 0; 33 int del_pending = 0; 34 35 mevent_qlock(); 36 37 LIST_FOREACH(mevp, &global_head, me_list) { 38 global++; 39 VERBOSE(("on global: type %d fd %d state %d", mevp->me_type, 40 mevp->me_fd, mevp->me_state)); 41 } 42 43 LIST_FOREACH(mevp, &change_head, me_list) { 44 change++; 45 if (mevp->me_state == EV_DELETE) { 46 del_pending++; 47 } 48 VERBOSE(("on change: type %d fd %d state %d", mevp->me_type, 49 mevp->me_fd, mevp->me_state)); 50 } 51 52 mevent_qunlock(); 53 54 *ret_global = global; 55 *ret_change = change; 56 *ret_del_pending = del_pending; 57 } 58 59 void 60 set_mevent_file_poll_interval_ms(int ms) 61 { 62 mevent_file_poll_interval_ms = ms; 63 } 64