int main(void) { if (init_szig()) return 1; /* szig thread count has a skew of 2 that offsets the threads started by Zorp core * before SZIG initialization: this makes testing thread counters and averages * difficult, so we generate two thread stop events here */ z_szig_event(Z_SZIG_THREAD_STOP, NULL); z_szig_event(Z_SZIG_THREAD_STOP, NULL); fprintf(stdout, "checking connection rate statistics\n"); /* generate NUM_CONNS connections right now */ generate_connections(); /* test sliding window */ fprintf(stdout, "fast-forwarding one minute\n"); forward_time(TICKS_PER_1_MIN); sleep(1); if (check_connection_rates(NUM_CONNS / S_1_MIN, NUM_CONNS / S_5_MIN, NUM_CONNS / S_15_MIN)) return 1; fprintf(stdout, "fast-forwarding four minutes\n"); forward_time(TICKS_PER_5_MIN - TICKS_PER_1_MIN); sleep(1); if (check_connection_rates(0, NUM_CONNS / S_5_MIN, NUM_CONNS / S_15_MIN)) return 1; fprintf(stdout, "fast-forwarding ten minutes\n"); forward_time(TICKS_PER_15_MIN - TICKS_PER_5_MIN); sleep(1); if (check_connection_rates(0, 0, NUM_CONNS / S_15_MIN)) return 1; fprintf(stdout, "fast-forwarding one minute\n"); forward_time(TICKS_PER_1_MIN); sleep(1); if (check_connection_rates(0, 0, 0)) return 1; fprintf(stdout, "checking thread rate statistics\n"); /* start and stop NUM_THREADS threads */ generate_threads(); /* test sliding window */ fprintf(stdout, "fast-forwarding one minute\n"); forward_time(TICKS_PER_1_MIN); sleep(1); if (check_thread_rates(NUM_THREADS / S_1_MIN, NUM_THREADS / S_5_MIN, NUM_THREADS / S_15_MIN)) return 1; fprintf(stdout, "checking thread counters\n"); if (check_thread_counters()) return 1; return 0; }
bool work_queue_for_tests::forward_time (const bool wait_for_completion) { const work_queue::time_point_type nearest_time_point = get_nearest_time_point (); return forward_time (is_time_point_empty (nearest_time_point) ? get_current_time_point () : nearest_time_point, wait_for_completion); }