aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_procmon.c
diff options
context:
space:
mode:
authorOla Bini <ola@olabini.se>2015-09-15 17:56:56 +0200
committerOla Bini <ola@olabini.se>2015-09-15 17:56:56 +0200
commitb4950c9334d476049b8b273ad1d8cb15a86f6074 (patch)
tree8297da8a35881f263c945c32e2b5545bfe64f842 /src/test/test_procmon.c
parenta444b11323799536b4cd7902e29f711b0806293a (diff)
downloadtor-b4950c9334d476049b8b273ad1d8cb15a86f6074.tar.gz
tor-b4950c9334d476049b8b273ad1d8cb15a86f6074.zip
Add tests for procmon. These currently fail. Investigation should happen before submitting
Diffstat (limited to 'src/test/test_procmon.c')
-rw-r--r--src/test/test_procmon.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/test/test_procmon.c b/src/test/test_procmon.c
new file mode 100644
index 0000000000..ac70a0f3db
--- /dev/null
+++ b/src/test/test_procmon.c
@@ -0,0 +1,51 @@
+/* Copyright (c) 2010-2015, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#define PROCMON_PRIVATE
+#include "orconfig.h"
+#include "or.h"
+#include "test.h"
+
+#include "procmon.h"
+
+#include "log_test_helpers.h"
+
+#define NS_MODULE procmon
+
+struct event_base;
+
+static void
+test_procmon_tor_process_monitor_new(void *ignored)
+{
+ (void)ignored;
+ tor_process_monitor_t *res;
+ const char *msg;
+
+ res = tor_process_monitor_new(NULL, "probably invalid", 0, NULL, NULL, &msg);
+ tt_assert(!res);
+ tt_str_op(msg, OP_EQ, "invalid PID");
+
+ res = tor_process_monitor_new(NULL, "243443535345454", 0, NULL, NULL, &msg);
+ tt_assert(!res);
+ tt_str_op(msg, OP_EQ, "invalid PID");
+
+ res = tor_process_monitor_new(tor_libevent_get_base(), "43", 0, NULL, NULL, &msg);
+ tt_assert(res);
+ tt_assert(!msg);
+
+ res = tor_process_monitor_new(tor_libevent_get_base(), "44 hello", 0, NULL, NULL, &msg);
+ tt_assert(res);
+ tt_assert(!msg);
+
+ res = tor_process_monitor_new(tor_libevent_get_base(), "45:hello", 0, NULL, NULL, &msg);
+ tt_assert(res);
+ tt_assert(!msg);
+
+ done:
+ (void)0;
+}
+
+struct testcase_t procmon_tests[] = {
+ { "tor_process_monitor_new", test_procmon_tor_process_monitor_new, TT_FORK, NULL, NULL },
+ END_OF_TESTCASES
+};