Correct math and limerick.
[dragonfly.git] / contrib / sendmail-8.14 / libsm / t-event.c
blob1096b36a70ecabe8176ce35b3fcd8aa8ca3b58be
1 /*
2 * Copyright (c) 2001-2002, 2004 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
8 */
10 #include <sm/gen.h>
11 SM_RCSID("@(#)$Id: t-event.c,v 1.13 2005/06/14 23:07:20 ca Exp $")
13 #include <stdio.h>
15 #include <stdlib.h>
16 #include <unistd.h>
17 # include <sys/wait.h>
18 #if SM_CONF_SETITIMER
19 # include <sm/time.h>
20 #endif /* SM_CONF_SETITIMER */
22 #include <sm/clock.h>
23 #include <sm/test.h>
25 static void evcheck __P((int));
26 static void ev1 __P((int));
28 static int check;
30 static void
31 evcheck(arg)
32 int arg;
34 SM_TEST(arg == 3);
35 SM_TEST(check == 0);
36 check++;
39 static void
40 ev1(arg)
41 int arg;
43 SM_TEST(arg == 1);
46 /* define as x if you want debug output */
47 #define DBG_OUT(x)
49 int
50 main(argc, argv)
51 int argc;
52 char *argv[];
54 SM_EVENT *ev;
56 sm_test_begin(argc, argv, "test event handling");
57 fprintf(stdout, "This test may hang. If there is no output within twelve seconds, abort it\nand recompile with -DSM_CONF_SETITIMER=%d\n",
58 SM_CONF_SETITIMER == 0 ? 1 : 0);
59 sleep(1);
60 SM_TEST(1 == 1);
61 DBG_OUT(fprintf(stdout, "We're back, test 1 seems to work.\n"));
62 ev = sm_seteventm(1000, ev1, 1);
63 sleep(1);
64 SM_TEST(2 == 2);
65 DBG_OUT(fprintf(stdout, "We're back, test 2 seems to work.\n"));
67 /* schedule an event in 9s */
68 ev = sm_seteventm(9000, ev1, 2);
69 sleep(1);
71 /* clear the event before it can fire */
72 sm_clrevent(ev);
73 SM_TEST(3 == 3);
74 DBG_OUT(fprintf(stdout, "We're back, test 3 seems to work.\n"));
76 /* schedule an event in 1s */
77 check = 0;
78 ev = sm_seteventm(1000, evcheck, 3);
79 sleep(2);
81 /* clear the event */
82 sm_clrevent(ev);
83 SM_TEST(4 == 4);
84 SM_TEST(check == 1);
85 DBG_OUT(fprintf(stdout, "We're back, test 4 seems to work.\n"));
87 return sm_test_end();