aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2020-04-10 02:00:58 -0400
committerGitHub <noreply@github.com>2020-04-10 02:00:58 -0400
commitc4ef8c76154afa2d0528f1cd18e650062f9a87cd (patch)
tree53128cf378fbb0d4687791648267f6cb1b278c5b /tests
parent2b0a5e96ae76e6e2a2ef29e234af2770f8ef0e7a (diff)
parente6eb62c343e368b343e115fab829b26ad23f4d89 (diff)
downloadspmc-c4ef8c76154afa2d0528f1cd18e650062f9a87cd.tar.gz
Merge pull request #20 from jhunkeler/test-spm_mkdtemp
Test spm mkdtemp
Diffstat (limited to 'tests')
-rw-r--r--tests/test_spm_mkdtemp.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_spm_mkdtemp.c b/tests/test_spm_mkdtemp.c
new file mode 100644
index 0000000..619ca42
--- /dev/null
+++ b/tests/test_spm_mkdtemp.c
@@ -0,0 +1,27 @@
+#include "spm.h"
+#include "framework.h"
+
+struct TestCase testCase[] = {
+ {.arg[0].sptr = "testing", .arg[1].sptr = NULL},
+ {.arg[0].sptr = "testing", .arg[1].sptr = "a/sub_directory/here"},
+};
+size_t numCases = sizeof(testCase) / sizeof(struct TestCase);
+
+int main(int argc, char *argv[]) {
+ // SPM initializes a series of global variables when the main program kicks off.
+ // We are not fully initializing SPM...
+
+ TMP_DIR = calloc(PATH_MAX, sizeof(char));
+ TMP_DIR[0] = '.';
+
+ for (size_t i = 0; i < numCases; i++) {
+ char *result = spm_mkdtemp(testCase[i].arg[0].sptr, testCase[i].arg[2].sptr);
+ myassert(result != NULL, "unexpected NULL\n");
+ int present = access(result, F_OK);
+ myassert(present == 0, "%s: %s\n", result, strerror(errno));
+ rmdirs(result);
+ free(result);
+ }
+ free(TMP_DIR);
+ return 0;
+} \ No newline at end of file