fallbackdir: Update list generated on August 30, 2023
[tor.git] / src / test / test_procmon.c
blob3e459edeccc18f2fa62086aab2afeb60756aef9b
1 /* Copyright (c) 2010-2021, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
4 #include "orconfig.h"
5 #include "core/or/or.h"
6 #include "test/test.h"
8 #include "lib/evloop/procmon.h"
10 #include "test/log_test_helpers.h"
12 struct event_base;
14 static void
15 test_procmon_tor_process_monitor_new(void *ignored)
17 (void)ignored;
18 tor_process_monitor_t *res;
19 const char *msg;
21 res = tor_process_monitor_new(NULL, "probably invalid", 0, NULL, NULL, &msg);
22 tt_assert(!res);
23 tt_str_op(msg, OP_EQ, "invalid PID");
25 res = tor_process_monitor_new(NULL, "243443535345454", 0, NULL, NULL, &msg);
26 tt_assert(!res);
27 tt_str_op(msg, OP_EQ, "invalid PID");
29 res = tor_process_monitor_new(tor_libevent_get_base(), "43", 0,
30 NULL, NULL, &msg);
31 tt_assert(res);
32 tt_assert(!msg);
33 tor_process_monitor_free(res);
35 res = tor_process_monitor_new(tor_libevent_get_base(), "44 hello", 0,
36 NULL, NULL, &msg);
37 tt_assert(res);
38 tt_assert(!msg);
39 tor_process_monitor_free(res);
41 res = tor_process_monitor_new(tor_libevent_get_base(), "45:hello", 0,
42 NULL, NULL, &msg);
43 tt_assert(res);
44 tt_assert(!msg);
46 done:
47 tor_process_monitor_free(res);
50 struct testcase_t procmon_tests[] = {
51 { "tor_process_monitor_new", test_procmon_tor_process_monitor_new,
52 TT_FORK, NULL, NULL },
53 END_OF_TESTCASES