test: make litest_copy_file copy normal files too
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 24 May 2018 04:47:30 +0000 (14:47 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 8 Jun 2018 03:47:33 +0000 (13:47 +1000)
Make the tempfile creation dependent on whether the required template is
present. Currently unused, this is just prep work for future patches.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
test/litest.c

index b72ec4449d764090a7c0d758bcfeb0fb97023466..0e050789f6cebac462b8d5d0c0841abce5e05193 100644 (file)
@@ -1104,13 +1104,20 @@ litest_copy_file(const char *dest, const char *src, const char *header)
 {
        int in, out, length;
        struct created_file *file;
-       int suffixlen;
 
        file = zalloc(sizeof(*file));
        file->path = safe_strdup(dest);
 
-       suffixlen = file->path + strlen(file->path)  - rindex(file->path, '.');
-       out = mkstemps(file->path, suffixlen);
+       if (strstr(dest, "XXXXXX")) {
+               int suffixlen;
+
+               suffixlen = file->path +
+                               strlen(file->path) -
+                               rindex(file->path, '.');
+               out = mkstemps(file->path, suffixlen);
+       } else {
+               out = open(file->path, O_CREAT|O_WRONLY);
+       }
        if (out == -1)
                litest_abort_msg("Failed to write to file %s (%s)\n",
                                 file->path,