summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/helpers.c14
-rw-r--r--test/helpers.h6
2 files changed, 18 insertions, 2 deletions
diff --git a/test/helpers.c b/test/helpers.c
index 975e7cb..491822e 100644
--- a/test/helpers.c
+++ b/test/helpers.c
@@ -49,14 +49,14 @@ void *t_calloc(size_t nmemb, size_t size)
/*
* Helper for creating file and write @size byte buf with 0xaa value in the file.
*/
-void t_create_file(const char *file, size_t size)
+static void __t_create_file(const char *file, size_t size, char pattern)
{
ssize_t ret;
char *buf;
int fd;
buf = t_malloc(size);
- memset(buf, 0xaa, size);
+ memset(buf, pattern, size);
fd = open(file, O_WRONLY | O_CREAT, 0644);
assert(fd >= 0);
@@ -68,6 +68,16 @@ void t_create_file(const char *file, size_t size)
assert(ret == size);
}
+void t_create_file(const char *file, size_t size)
+{
+ __t_create_file(file, size, 0xaa);
+}
+
+void t_create_file_pattern(const char *file, size_t size, char pattern)
+{
+ __t_create_file(file, size, pattern);
+}
+
/*
* Helper for creating @buf_num number of iovec
* with @buf_size bytes buffer of each iovec.
diff --git a/test/helpers.h b/test/helpers.h
index 7526d46..d0beb93 100644
--- a/test/helpers.h
+++ b/test/helpers.h
@@ -41,6 +41,12 @@ void *t_calloc(size_t nmemb, size_t size);
void t_create_file(const char *file, size_t size);
/*
+ * Helper for creating file and write @size byte buf with @pattern value in
+ * the file.
+ */
+void t_create_file_pattern(const char *file, size_t size, char pattern);
+
+/*
* Helper for creating @buf_num number of iovec
* with @buf_size bytes buffer of each iovec.
*/