unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
To: libc-alpha@sourceware.org
Subject: [PATCH v2 3/7] support: Add 'touch' command
Date: Wed,  5 Aug 2020 15:59:11 -0300	[thread overview]
Message-ID: <20200805185915.2025314-3-adhemerval.zanella@linaro.org> (raw)
In-Reply-To: <20200805185915.2025314-1-adhemerval.zanella@linaro.org>

It allow creates empty files with an specific mode.
---
 support/test-container.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/support/test-container.c b/support/test-container.c
index e9109f9e3d..b6101b9b94 100644
--- a/support/test-container.c
+++ b/support/test-container.c
@@ -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]);
-- 
2.25.1


  parent reply	other threads:[~2020-08-05 18:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-05 18:59 [PATCH v2 1/7] login: Move gnu utmpx to default implementation Adhemerval Zanella via Libc-alpha
2020-08-05 18:59 ` [PATCH v2 2/7] Consolidate and simplify internal utmp definitions Adhemerval Zanella via Libc-alpha
2020-08-05 18:59 ` Adhemerval Zanella via Libc-alpha [this message]
2020-08-05 19:08   ` [PATCH v2 3/7] support: Add 'touch' command DJ Delorie via Libc-alpha
2020-08-05 18:59 ` [PATCH v2 4/7] login: Add 64-bit time support to utmp/utmpx Adhemerval Zanella via Libc-alpha
2020-08-05 19:28   ` Joseph Myers
2020-08-05 20:35     ` Adhemerval Zanella via Libc-alpha
2020-08-05 20:43       ` Joseph Myers
2020-08-05 20:54         ` Adhemerval Zanella via Libc-alpha
2020-08-05 18:59 ` [PATCH v2 5/7] linux: Add pwrite64_nocancel Adhemerval Zanella via Libc-alpha
2020-08-05 18:59 ` [PATCH v2 6/7] login: Use 64-bit time on struct lastlog Adhemerval Zanella via Libc-alpha
2020-08-05 19:56   ` Florian Weimer
2020-08-05 20:36     ` Adhemerval Zanella via Libc-alpha
2020-08-05 18:59 ` [PATCH v2 7/7] Remove __WORDSIZE_TIME64_COMPAT32 Adhemerval Zanella via Libc-alpha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200805185915.2025314-3-adhemerval.zanella@linaro.org \
    --to=libc-alpha@sourceware.org \
    --cc=adhemerval.zanella@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).