[v2,3/7] support: Add 'touch' command
Commit Message
It allow creates empty files with an specific mode.
---
support/test-container.c | 11 +++++++++++
1 file changed, 11 insertions(+)
@@ -102,6 +102,7 @@ int verbose = 0;
cwd PATH
exec FILE
mkdirp MODE DIR
+ touch MODE FILE
variables:
$B/ build dir, equivalent to $(common-objpfx)
@@ -127,6 +128,7 @@ int verbose = 0;
- 'cwd': set test working directory
- 'exec': change test binary location (may end in /)
- 'mkdirp': A minimal "mkdir -p FILE" command.
+ - 'touch': A minimal 'touch' command to create empty files.
* mytest.root/postclean.req causes fresh rsync (with delete) after
test if present
@@ -999,6 +1001,15 @@ main (int argc, char **argv)
TEST_COMPARE (errno, 0);
xmkdirp (the_words[2], m);
}
+ else if (nt == 3 && strcmp (the_words[0], "touch") == 0)
+ {
+ long int m;
+ errno = 0;
+ m = strtol (the_words[1], NULL, 0);
+ TEST_COMPARE (errno, 0);
+
+ xopen (the_words[2], O_WRONLY | O_TRUNC | O_CREAT, m);
+ }
else if (nt > 0 && the_words[0][0] != '#')
{
fprintf (stderr, "\033[31minvalid [%s]\033[0m\n", the_words[0]);