Update zoneinfo database.
[dragonfly/netmp.git] / contrib / sendmail / libsm / t-event.c
blob607377617c8367237352de1efc31269ce673e26d
1 /*
2 * Copyright (c) 2001-2002 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.11 2002/04/25 01:50:25 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 <sys/time.h>
20 #endif /* SM_CONF_SETITIMER */
22 #include <sm/clock.h>
23 #include <sm/test.h>
25 int check;
27 void
28 evcheck(arg)
29 int arg;
31 SM_TEST(arg == 3);
32 SM_TEST(check == 0);
33 check++;
36 void
37 ev1(arg)
38 int arg;
40 SM_TEST(arg == 1);
43 /* define as x if you want debug output */
44 #define DBG_OUT(x)
46 int
47 main(argc, argv)
48 int argc;
49 char *argv[];
51 SM_EVENT *ev;
53 sm_test_begin(argc, argv, "test event handling");
54 fprintf(stdout, "This test may hang. If there is no output within twelve seconds, abort it\nand recompile with -DSM_CONF_SETITIMER=%d\n",
55 SM_CONF_SETITIMER == 0 ? 1 : 0);
56 sleep(1);
57 SM_TEST(1 == 1);
58 DBG_OUT(fprintf(stdout, "We're back, test 1 seems to work.\n"));
59 ev = sm_seteventm(1000, ev1, 1);
60 sleep(1);
61 SM_TEST(2 == 2);
62 DBG_OUT(fprintf(stdout, "We're back, test 2 seems to work.\n"));
64 /* schedule an event in 9s */
65 ev = sm_seteventm(9000, ev1, 2);
66 sleep(1);
68 /* clear the event before it can fire */
69 sm_clrevent(ev);
70 SM_TEST(3 == 3);
71 DBG_OUT(fprintf(stdout, "We're back, test 3 seems to work.\n"));
73 /* schedule an event in 1s */
74 check = 0;
75 ev = sm_seteventm(1000, evcheck, 3);
76 sleep(2);
78 /* clear the event */
79 sm_clrevent(ev);
80 SM_TEST(4 == 4);
81 SM_TEST(check == 1);
82 DBG_OUT(fprintf(stdout, "We're back, test 4 seems to work.\n"));
84 return sm_test_end();