diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-05-07 15:29:56 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-05-07 15:29:56 -0400 |
commit | e086db795238da9187aa9824fda3d708cff10bf6 (patch) | |
tree | 13dc823d24ea89a6fbf47c92994b8fa997887a53 /src/test/test_util.c | |
parent | a2a6a19db165dd08b2dd6e7e493f21d2336a85d0 (diff) | |
parent | 79e85313aa611b599f19fea61c38ff3928e1fd59 (diff) | |
download | tor-e086db795238da9187aa9824fda3d708cff10bf6.tar.gz tor-e086db795238da9187aa9824fda3d708cff10bf6.zip |
Merge branch 'writing_tests'
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 6a4c3ec072..30dc59844a 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -4302,6 +4302,35 @@ test_util_ipv4_validation(void *arg) return; } +static void +test_util_writepid(void *arg) +{ + (void) arg; + + char *contents = NULL; + const char *fname = get_fname("tmp_pid"); + unsigned long pid; + char c; + + write_pidfile(fname); + + contents = read_file_to_str(fname, 0, NULL); + tt_assert(contents); + + int n = sscanf(contents, "%lu\n%c", &pid, &c); + tt_int_op(n, OP_EQ, 1); + tt_uint_op(pid, OP_EQ, +#ifdef _WIN32 + _getpid() +#else + getpid() +#endif + ); + + done: + tor_free(contents); +} + struct testcase_t util_tests[] = { UTIL_LEGACY(time), UTIL_TEST(parse_http_time, 0), @@ -4368,6 +4397,7 @@ struct testcase_t util_tests[] = { UTIL_TEST(max_mem, 0), UTIL_TEST(hostname_validation, 0), UTIL_TEST(ipv4_validation, 0), + UTIL_TEST(writepid, 0), END_OF_TESTCASES }; |