Check return values for tor_munmap_file() in unit tests

This commit is contained in:
Nick Mathewson 2014-03-31 11:40:00 -04:00
parent 7cdb50e866
commit 8e94d5f22e

View File

@ -1577,14 +1577,14 @@ test_util_mmap(void)
test_eq(mapping->size, strlen("Short file.")); test_eq(mapping->size, strlen("Short file."));
test_streq(mapping->data, "Short file."); test_streq(mapping->data, "Short file.");
#ifdef _WIN32 #ifdef _WIN32
tor_munmap_file(mapping); tt_int_op(0, ==, tor_munmap_file(mapping));
mapping = NULL; mapping = NULL;
test_assert(unlink(fname1) == 0); test_assert(unlink(fname1) == 0);
#else #else
/* make sure we can unlink. */ /* make sure we can unlink. */
test_assert(unlink(fname1) == 0); test_assert(unlink(fname1) == 0);
test_streq(mapping->data, "Short file."); test_streq(mapping->data, "Short file.");
tor_munmap_file(mapping); tt_int_op(0, ==, tor_munmap_file(mapping));
mapping = NULL; mapping = NULL;
#endif #endif
@ -1605,7 +1605,7 @@ test_util_mmap(void)
test_assert(mapping); test_assert(mapping);
test_eq(mapping->size, buflen); test_eq(mapping->size, buflen);
test_memeq(mapping->data, buf, buflen); test_memeq(mapping->data, buf, buflen);
tor_munmap_file(mapping); tt_int_op(0, ==, tor_munmap_file(mapping));
mapping = NULL; mapping = NULL;
/* Now try a big aligned file. */ /* Now try a big aligned file. */
@ -1614,7 +1614,7 @@ test_util_mmap(void)
test_assert(mapping); test_assert(mapping);
test_eq(mapping->size, 16384); test_eq(mapping->size, 16384);
test_memeq(mapping->data, buf, 16384); test_memeq(mapping->data, buf, 16384);
tor_munmap_file(mapping); tt_int_op(0, ==, tor_munmap_file(mapping));
mapping = NULL; mapping = NULL;
done: done:
@ -1627,8 +1627,7 @@ test_util_mmap(void)
tor_free(fname3); tor_free(fname3);
tor_free(buf); tor_free(buf);
if (mapping) tor_munmap_file(mapping);
tor_munmap_file(mapping);
} }
/** Run unit tests for escaping/unescaping data for use by controllers. */ /** Run unit tests for escaping/unescaping data for use by controllers. */