Merge remote-tracking branch 'twstrike/procmon_tests'

Conflicts:
	src/test/include.am
	src/test/log_test_helpers.c
	src/test/log_test_helpers.h
This commit is contained in:
Nick Mathewson
2015-10-07 09:32:51 -04:00
4 changed files with 60 additions and 3 deletions
+2 -2
View File
@@ -192,7 +192,8 @@ tor_process_monitor_new(struct event_base *base,
tor_procmon_callback_t cb, void *cb_arg,
const char **msg)
{
tor_process_monitor_t *procmon = tor_malloc(sizeof(tor_process_monitor_t));
tor_process_monitor_t *procmon = tor_malloc_zero(
sizeof(tor_process_monitor_t));
struct parsed_process_specifier_t ppspec;
tor_assert(msg != NULL);
@@ -354,4 +355,3 @@ tor_process_monitor_free(tor_process_monitor_t *procmon)
tor_free(procmon);
}
+1
View File
@@ -86,6 +86,7 @@ src_test_test_SOURCES = \
src/test/test_oom.c \
src/test/test_options.c \
src/test/test_policy.c \
src/test/test_procmon.c \
src/test/test_pt.c \
src/test/test_relay.c \
src/test/test_relaycell.c \
+2 -1
View File
@@ -1151,6 +1151,7 @@ extern struct testcase_t nodelist_tests[];
extern struct testcase_t oom_tests[];
extern struct testcase_t options_tests[];
extern struct testcase_t policy_tests[];
extern struct testcase_t procmon_tests[];
extern struct testcase_t pt_tests[];
extern struct testcase_t relay_tests[];
extern struct testcase_t relaycell_tests[];
@@ -1203,6 +1204,7 @@ struct testgroup_t testgroups[] = {
{ "oom/", oom_tests },
{ "options/", options_tests },
{ "policy/" , policy_tests },
{ "procmon/", procmon_tests },
{ "pt/", pt_tests },
{ "relay/" , relay_tests },
{ "relaycell/", relaycell_tests },
@@ -1222,4 +1224,3 @@ struct testgroup_t testgroups[] = {
{ "dns/", dns_tests },
END_OF_GROUPS
};
+55
View File
@@ -0,0 +1,55 @@
/* 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
};