aboutsummaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorAndrea Shepard <andrea@torproject.org>2016-06-25 06:26:44 +0000
committerAndrea Shepard <andrea@torproject.org>2016-06-30 07:03:24 +0000
commit17ed2fed68ed18480976748e3f407bf6952ab72c (patch)
tree5951d5584830189ae725612a5dc65d634aa10737 /src/common/util.c
parent726dc9acf599567bf2ed1786fc2af785f15cac25 (diff)
downloadtor-17ed2fed68ed18480976748e3f407bf6952ab72c.tar.gz
tor-17ed2fed68ed18480976748e3f407bf6952ab72c.zip
Expose dump_desc() to the test suite and make things it calls mockable
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 4b6df81b7d..d4553c3942 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -2013,6 +2013,16 @@ clean_name_for_stat(char *name)
#endif
}
+/** Wrapper for unlink() to make it mockable for the test suite; returns 0
+ * if unlinking the file succeeded, -1 and sets errno if unlinking fails.
+ */
+
+MOCK_IMPL(int,
+tor_unlink,(const char *pathname))
+{
+ return unlink(pathname);
+}
+
/** Return:
* FN_ERROR if filename can't be read, is NULL, or is zero-length,
* FN_NOENT if it doesn't exist,
@@ -2306,8 +2316,8 @@ check_private_dir(const char *dirname, cpd_check_t check,
* function, and all other functions in util.c that create files, create them
* with mode 0600.
*/
-int
-write_str_to_file(const char *fname, const char *str, int bin)
+MOCK_IMPL(int,
+write_str_to_file,(const char *fname, const char *str, int bin))
{
#ifdef _WIN32
if (!bin && strchr(str, '\r')) {