2 * Copyright (c) 2016 Proofpoint, Inc. and its suppliers.
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.
14 #if _FFR_DMTRIGGER || _FFR_NOTIFY
19 # include <sm/string.h>
21 # include <sm/notify.h>
25 ** NOTIFY_WR -- test of notify feature
28 ** pid -- pid of process
42 #define TSTSTR "qf0001"
44 r = sm_notify_start(false, 0);
47 perror("sm_notify_start failed");
51 len = sm_snprintf(buf, sizeof(buf), "%s-%ld", TSTSTR, (long) pid);
52 r = sm_notify_snd(buf, len);
58 ** NOTIFY_RD -- test of notify feature
73 #define TSTSTR "qf0001"
75 r = sm_notify_start(true, 0);
78 perror("sm_notify_start failed");
82 for (i = 0; i < nproc; i++)
84 r = sm_notify_rcv(buf, sizeof(buf), 5 * SM_MICROS);
88 fprintf(stderr, "rcv=%d\n", r);
91 if (r > 0 && r < sizeof(buf))
93 buf[sizeof(buf) - 1] = '\0';
94 SM_TEST(strncmp(buf, TSTSTR, sizeof(TSTSTR) - 1) == 0);
95 SM_TEST(r > sizeof(TSTSTR));
96 fprintf(stderr, "buf=\"%s\"\n", buf);
111 # define OPTIONS "p:"
112 while ((i = getopt(argc, argv, OPTIONS)) != -1)
117 nproc = atoi(optarg);
121 perror("-p: must be >0\n");
130 sm_test_begin(argc, argv, "test notify");
131 r = sm_notify_init(0);
135 perror("sm_notify_init failed\n");
140 for (i = 0; i < nproc; i++)
142 if ((pid = fork()) < 0)
144 perror("fork failed\n");
150 /* give the parent the chance to set up data */
152 r = notify_wr(getpid());
157 r = notify_rd(nproc);
159 return sm_test_end();
161 #else /* _FFR_DMTRIGGER */
167 printf("SKIPPED: no _FFR_DMTRIGGER\n");
170 #endif /* _FFR_DMTRIGGER */