summaryrefslogtreecommitdiff
path: root/src/test/test_helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test_helpers.c')
-rw-r--r--src/test/test_helpers.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/test_helpers.c b/src/test/test_helpers.c
new file mode 100644
index 0000000000..e5a76e0360
--- /dev/null
+++ b/src/test/test_helpers.c
@@ -0,0 +1,26 @@
+/* Copyright (c) 2014, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file test_helpers.c
+ * \brief Some helper functions to avoid code duplication in unit tests.
+ */
+
+#include "orconfig.h"
+#include "or.h"
+
+#include "test_helpers.h"
+
+/* Return a statically allocated string representing yesterday's date
+ * in ISO format. We use it so that state file items are not found to
+ * be outdated. */
+const char *
+get_yesterday_date_str(void)
+{
+ static char buf[ISO_TIME_LEN+1];
+
+ time_t yesterday = time(NULL) - 24*60*60;
+ format_iso_time(buf, yesterday);
+ return buf;
+}
+