-
-#ifdef FCE_TEST_MAIN
-
-
-void shortsleep( unsigned int us )
-{
- usleep( us );
-}
-int main( int argc, char*argv[] )
-{
- int c;
-
- char *port = FCE_DEFAULT_PORT_STRING;
- char *host = "localhost";
- int delay_between_events = 1000;
- int event_code = FCE_FILE_MODIFY;
- char pathbuff[1024];
- int duration_in_seconds = 0; // TILL ETERNITY
- char target[256];
- char *path = getcwd( pathbuff, sizeof(pathbuff) );
-
- // FULLSPEED TEST IS "-s 1001" -> delay is 0 -> send packets without pause
-
- while ((c = getopt(argc, argv, "d:e:h:p:P:s:")) != -1) {
- switch(c) {
- case '?':
- fprintf(stdout, "%s: [ -p Port -h Listener1 [ -h Listener2 ...] -P path -s Delay_between_events_in_us -e event_code -d Duration ]\n", argv[0]);
- exit(1);
- break;
- case 'd':
- duration_in_seconds = atoi(optarg);
- break;
- case 'e':
- event_code = atoi(optarg);
- break;
- case 'h':
- host = strdup(optarg);
- break;
- case 'p':
- port = strdup(optarg);
- break;
- case 'P':
- path = strdup(optarg);
- break;
- case 's':
- delay_between_events = atoi(optarg);
- break;
- }
- }
-
- sprintf(target, "%s:%s", host, port);
- if (fce_add_udp_socket(target) != 0)
- return 1;
-
- int ev_cnt = 0;
- time_t start_time = time(NULL);
- time_t end_time = 0;
-
- if (duration_in_seconds)
- end_time = start_time + duration_in_seconds;
-
- while (1)
- {
- time_t now = time(NULL);
- if (now > start_time)
- {
- start_time = now;
- fprintf( stdout, "%d events/s\n", ev_cnt );
- ev_cnt = 0;
- }
- if (end_time && now >= end_time)
- break;
-
- fce_register(event_code, path, NULL, 0);
- ev_cnt++;
-
-
- shortsleep( delay_between_events );
- }
-}
-#endif /* TESTMAIN*/