2016-02-27 18:48:19 +01:00
|
|
|
/* Copyright (c) 2010-2016, The Tor Project, Inc. */
|
2015-09-15 17:56:56 +02:00
|
|
|
/* 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");
|
|
|
|
|
2015-10-05 20:42:43 +02:00
|
|
|
res = tor_process_monitor_new(tor_libevent_get_base(), "43", 0,
|
|
|
|
NULL, NULL, &msg);
|
2015-09-15 17:56:56 +02:00
|
|
|
tt_assert(res);
|
|
|
|
tt_assert(!msg);
|
2015-10-21 17:17:59 +02:00
|
|
|
tor_process_monitor_free(res);
|
2015-09-15 17:56:56 +02:00
|
|
|
|
2015-10-05 20:42:43 +02:00
|
|
|
res = tor_process_monitor_new(tor_libevent_get_base(), "44 hello", 0,
|
|
|
|
NULL, NULL, &msg);
|
2015-09-15 17:56:56 +02:00
|
|
|
tt_assert(res);
|
|
|
|
tt_assert(!msg);
|
2015-10-21 17:17:59 +02:00
|
|
|
tor_process_monitor_free(res);
|
2015-09-15 17:56:56 +02:00
|
|
|
|
2015-10-05 20:42:43 +02:00
|
|
|
res = tor_process_monitor_new(tor_libevent_get_base(), "45:hello", 0,
|
|
|
|
NULL, NULL, &msg);
|
2015-09-15 17:56:56 +02:00
|
|
|
tt_assert(res);
|
|
|
|
tt_assert(!msg);
|
|
|
|
|
|
|
|
done:
|
2015-10-21 17:17:59 +02:00
|
|
|
tor_process_monitor_free(res);
|
2015-09-15 17:56:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
struct testcase_t procmon_tests[] = {
|
2015-10-05 20:42:43 +02:00
|
|
|
{ "tor_process_monitor_new", test_procmon_tor_process_monitor_new,
|
|
|
|
TT_FORK, NULL, NULL },
|
2015-09-15 17:56:56 +02:00
|
|
|
END_OF_TESTCASES
|
|
|
|
};
|
2015-10-07 15:34:02 +02:00
|
|
|
|