summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-02-26 13:24:52 +1030
committerAndrew Jeffery <andrew@aj.id.au>2018-03-19 10:55:33 +1030
commitc3144042b9f050c3d880f4ae5464a2a21617fe7d (patch)
tree6567b6c7fee4aaebb5cfc939601daf43477ddad5
parentbaea36d912053f0945ba529e5503a6c5471e802b (diff)
downloadphosphor-mboxd-c3144042b9f050c3d880f4ae5464a2a21617fe7d.tar.gz
phosphor-mboxd-c3144042b9f050c3d880f4ae5464a2a21617fe7d.zip
test: Update tmpf to store data in /tmp, reformat names
Cleans up residuals from failed tests in the source tree by moving them to /tmp. Some were annoying to remove with prefixes like 'mbox', so change the pattern as well to include '-store'. Change-Id: I674664a372e7e15ec4c3cd93d33318c4135f33ba Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
-rw-r--r--test/copy_flash.c2
-rw-r--r--test/erase_flash.c2
-rw-r--r--test/mbox.c6
-rw-r--r--test/tmpf.c5
-rw-r--r--test/tmpf.h12
-rw-r--r--test/write_flash.c2
6 files changed, 22 insertions, 7 deletions
diff --git a/test/copy_flash.c b/test/copy_flash.c
index 5c40b53..d39ef93 100644
--- a/test/copy_flash.c
+++ b/test/copy_flash.c
@@ -66,7 +66,7 @@ int main(void)
goto free;
}
- rc = tmpf_init(&tmp, "flashXXXXXX");
+ rc = tmpf_init(&tmp, "flash-store.XXXXXX");
if (rc < 0)
goto free;
diff --git a/test/erase_flash.c b/test/erase_flash.c
index 71e87b5..fa8c92c 100644
--- a/test/erase_flash.c
+++ b/test/erase_flash.c
@@ -42,7 +42,7 @@ char *get_dev_mtd(void)
{
int rc;
- rc = tmpf_init(&mtd, "flashXXXXXX");
+ rc = tmpf_init(&mtd, "flash-store.XXXXXX");
if (rc < 0)
return NULL;
diff --git a/test/mbox.c b/test/mbox.c
index dc049ce..6fe7277 100644
--- a/test/mbox.c
+++ b/test/mbox.c
@@ -216,13 +216,13 @@ struct mbox_context *mbox_create_test_context(int n_windows, size_t len)
atexit(cleanup);
- rc = tmpf_init(&test.mbox, "mboxXXXXXX");
+ rc = tmpf_init(&test.mbox, "mbox-store.XXXXXX");
assert(rc == 0);
- rc = tmpf_init(&test.flash, "flashXXXXXX");
+ rc = tmpf_init(&test.flash, "flash-store.XXXXXX");
assert(rc == 0);
- rc = tmpf_init(&test.lpc, "lpcXXXXXX");
+ rc = tmpf_init(&test.lpc, "lpc-store.XXXXXX");
assert(rc == 0);
test.context.windows.num = n_windows;
diff --git a/test/tmpf.c b/test/tmpf.c
index 285f5d5..e9cc558 100644
--- a/test/tmpf.c
+++ b/test/tmpf.c
@@ -25,9 +25,12 @@
#include "test/tmpf.h"
+static const char *tmpf_dir = "/tmp/";
+
int tmpf_init(struct tmpf *tmpf, const char *template)
{
- strncpy(tmpf->path, template, sizeof(tmpf->path) - 1);
+ strcpy(tmpf->path, tmpf_dir);
+ strncat(tmpf->path, template, sizeof(tmpf->path) - sizeof(tmpf_dir));
tmpf->fd = mkstemp(tmpf->path);
if (tmpf->fd < 0) {
diff --git a/test/tmpf.h b/test/tmpf.h
index ce47191..cb1bda4 100644
--- a/test/tmpf.h
+++ b/test/tmpf.h
@@ -27,8 +27,20 @@ struct tmpf {
char path[PATH_MAX];
};
+/**
+ * Initialise a tmpf instance for use, creating a temporary file.
+ *
+ * @tmpf: A context to initialise with the provided template
+ * @template_str: A file basename in mkstemp(3) template form
+ *
+ * Returns 0 on success, or -1 on error with errno set appropriately
+ */
int tmpf_init(struct tmpf *tmpf, const char *template_str);
+/**
+ * Destroy a tmpf instance, closing the file descriptor and removing the
+ * temporary file.
+ */
void tmpf_destroy(struct tmpf *tmpf);
#endif /* MBOX_TEST_UTILS_H */
diff --git a/test/write_flash.c b/test/write_flash.c
index ebd0fb7..6a92d4b 100644
--- a/test/write_flash.c
+++ b/test/write_flash.c
@@ -40,7 +40,7 @@ char *get_dev_mtd(void)
{
int rc;
- rc = tmpf_init(tmp, "flashXXXXXX");
+ rc = tmpf_init(tmp, "flash-store.XXXXXX");
if (rc < 0)
return NULL;
OpenPOWER on IntegriCloud