LCOV - code coverage report
Current view: top level - test - test_procmon.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 24 24 100.0 %
Date: 2021-11-24 03:28:48 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* Copyright (c) 2010-2021, The Tor Project, Inc. */
       2             : /* See LICENSE for licensing information */
       3             : 
       4             : #include "orconfig.h"
       5             : #include "core/or/or.h"
       6             : #include "test/test.h"
       7             : 
       8             : #include "lib/evloop/procmon.h"
       9             : 
      10             : #include "test/log_test_helpers.h"
      11             : 
      12             : struct event_base;
      13             : 
      14             : static void
      15           1 : test_procmon_tor_process_monitor_new(void *ignored)
      16             : {
      17           1 :   (void)ignored;
      18           1 :   tor_process_monitor_t *res;
      19           1 :   const char *msg;
      20             : 
      21           1 :   res = tor_process_monitor_new(NULL, "probably invalid", 0, NULL, NULL, &msg);
      22           1 :   tt_assert(!res);
      23           1 :   tt_str_op(msg, OP_EQ, "invalid PID");
      24             : 
      25           1 :   res = tor_process_monitor_new(NULL, "243443535345454", 0, NULL, NULL, &msg);
      26           1 :   tt_assert(!res);
      27           1 :   tt_str_op(msg, OP_EQ, "invalid PID");
      28             : 
      29           1 :   res = tor_process_monitor_new(tor_libevent_get_base(), "43", 0,
      30             :                                 NULL, NULL, &msg);
      31           1 :   tt_assert(res);
      32           1 :   tt_assert(!msg);
      33           1 :   tor_process_monitor_free(res);
      34             : 
      35           1 :   res = tor_process_monitor_new(tor_libevent_get_base(), "44 hello", 0,
      36             :                                 NULL, NULL, &msg);
      37           1 :   tt_assert(res);
      38           1 :   tt_assert(!msg);
      39           1 :   tor_process_monitor_free(res);
      40             : 
      41           1 :   res = tor_process_monitor_new(tor_libevent_get_base(), "45:hello", 0,
      42             :                                 NULL, NULL, &msg);
      43           1 :   tt_assert(res);
      44           1 :   tt_assert(!msg);
      45             : 
      46           1 :  done:
      47           1 :   tor_process_monitor_free(res);
      48           1 : }
      49             : 
      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
      54             : };
      55             : 

Generated by: LCOV version 1.14