summaryrefslogtreecommitdiff
path: root/tests-clar/clar_helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests-clar/clar_helpers.c')
-rw-r--r--tests-clar/clar_helpers.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests-clar/clar_helpers.c b/tests-clar/clar_helpers.c
new file mode 100644
index 000000000..eea8bc87d
--- /dev/null
+++ b/tests-clar/clar_helpers.c
@@ -0,0 +1,29 @@
+#include "clar_libgit2.h"
+#include "posix.h"
+
+void clar_on_init(void)
+{
+ git_threads_init();
+}
+
+void clar_on_shutdown(void)
+{
+ git_threads_shutdown();
+}
+
+void cl_git_mkfile(const char *filename, const char *content)
+{
+ int fd;
+
+ fd = p_creat(filename, 0666);
+ cl_assert(fd != 0);
+
+ if (content) {
+ cl_must_pass(p_write(fd, content, strlen(content)));
+ } else {
+ cl_must_pass(p_write(fd, filename, strlen(filename)));
+ cl_must_pass(p_write(fd, "\n", 1));
+ }
+
+ cl_must_pass(p_close(fd));
+}