Bump copyright date to 2019
[tor.git] / src / test / test_procmon.c
blobe23578f4fdbc89b2d4b8fe0c0a0398a6ec031e54
1 /* Copyright (c) 2010-2019, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
4 #define PROCMON_PRIVATE
5 #include "orconfig.h"
6 #include "core/or/or.h"
7 #include "test/test.h"
9 #include "lib/evloop/procmon.h"
11 #include "test/log_test_helpers.h"
13 #define NS_MODULE procmon
15 struct event_base;
17 static void
18 test_procmon_tor_process_monitor_new(void *ignored)
20 (void)ignored;
21 tor_process_monitor_t *res;
22 const char *msg;
24 res = tor_process_monitor_new(NULL, "probably invalid", 0, NULL, NULL, &msg);
25 tt_assert(!res);
26 tt_str_op(msg, OP_EQ, "invalid PID");
28 res = tor_process_monitor_new(NULL, "243443535345454", 0, NULL, NULL, &msg);
29 tt_assert(!res);
30 tt_str_op(msg, OP_EQ, "invalid PID");
32 res = tor_process_monitor_new(tor_libevent_get_base(), "43", 0,
33 NULL, NULL, &msg);
34 tt_assert(res);
35 tt_assert(!msg);
36 tor_process_monitor_free(res);
38 res = tor_process_monitor_new(tor_libevent_get_base(), "44 hello", 0,
39 NULL, NULL, &msg);
40 tt_assert(res);
41 tt_assert(!msg);
42 tor_process_monitor_free(res);
44 res = tor_process_monitor_new(tor_libevent_get_base(), "45:hello", 0,
45 NULL, NULL, &msg);
46 tt_assert(res);
47 tt_assert(!msg);
49 done:
50 tor_process_monitor_free(res);
53 struct testcase_t procmon_tests[] = {
54 { "tor_process_monitor_new", test_procmon_tor_process_monitor_new,
55 TT_FORK, NULL, NULL },
56 END_OF_TESTCASES