summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorteor <teor2345@gmail.com>2016-11-02 14:13:34 +1100
committerteor <teor2345@gmail.com>2016-11-02 14:13:34 +1100
commitd7634dc5196801c5a3e6be9eb2167c2c96f48ab4 (patch)
tree27fb2659511c585c438bbd731a93e44eb1f39396 /src
parent2f48693663c3703e1015fd438fc585cd2857ba71 (diff)
downloadtor-d7634dc5196801c5a3e6be9eb2167c2c96f48ab4.tar.gz
tor-d7634dc5196801c5a3e6be9eb2167c2c96f48ab4.zip
Create get_fname_suffix, and refactor get_fname to use it
Diffstat (limited to 'src')
-rw-r--r--src/test/testing_common.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/test/testing_common.c b/src/test/testing_common.c
index fd7c4e7074..e28e3dd457 100644
--- a/src/test/testing_common.c
+++ b/src/test/testing_common.c
@@ -102,18 +102,29 @@ setup_directory(void)
temp_dir_setup_in_pid = getpid();
}
-/** Return a filename relative to our testing temporary directory */
-const char *
-get_fname(const char *name)
+/** Return a filename relative to our testing temporary directory, based on
+ * name and suffix. If name is NULL, return the name of the testing temporary
+ * directory. */
+static const char *
+get_fname_suffix(const char *name, const char *suffix)
{
static char buf[1024];
setup_directory();
if (!name)
return temp_dir;
- tor_snprintf(buf,sizeof(buf),"%s/%s",temp_dir,name);
+ tor_snprintf(buf,sizeof(buf),"%s/%s%s%s",temp_dir,name,suffix ? "_" : "",
+ suffix ? suffix : "");
return buf;
}
+/** Return a filename relative to our testing temporary directory. If name is
+ * NULL, return the name of the testing temporary directory. */
+const char *
+get_fname(const char *name)
+{
+ return get_fname_suffix(name, NULL);
+}
+
/* Remove a directory and all of its subdirectories */
static void
rm_rf(const char *dir)