From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/sandbox:master commit in: tests/
Date: Mon, 28 Sep 2015 20:17:04 +0000 (UTC) [thread overview]
Message-ID: <1443470417.6b0db7d9abfded8bdf8c7d061b261f053eec886d.vapier@gentoo> (raw)
commit: 6b0db7d9abfded8bdf8c7d061b261f053eec886d
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Sep 28 20:00:17 2015 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Sep 28 20:00:17 2015 +0000
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=6b0db7d9
tests: add basic parsing of timespec fields
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
tests/test-skel-0.c | 23 ++++++++++++++++++++++-
tests/tests.h | 3 +++
tests/utimensat-0.c | 2 +-
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/tests/test-skel-0.c b/tests/test-skel-0.c
index dbe60db..96e42ae 100644
--- a/tests/test-skel-0.c
+++ b/tests/test-skel-0.c
@@ -9,7 +9,6 @@ const char *color_red = "\033[31;01m";
# define CONFIG 1
#endif
-#define V_TIMESPEC "NULL"
#define V_STRMODE "<r|w|a>[+bcemx] (see `man 3 fopen`)"
static bool _strtoul(const char *sul, unsigned long *ul)
@@ -132,6 +131,28 @@ int at_get_fd(const char *str_dirfd)
return open(str_path, f_get_flags(str_flags), sscanf_mode_t(str_mode));
}
+#define V_TIMESPEC "NULL | NOW | #[,#]"
+struct timespec *parse_timespec(const char *s)
+{
+ struct timespec *times;
+
+ if (!strcmp(s, "NULL"))
+ return NULL;
+
+ times = xzalloc(sizeof(*times));
+
+ if (!strcmp(s, "NOW")) {
+ times->tv_sec = time(0);
+ } else {
+ long sec = 0, nsec = 0;
+ sscanf(s, "%li,%li", &sec, &nsec);
+ times->tv_sec = sec;
+ times->tv_nsec = nsec;
+ }
+
+ return times;
+}
+
#define V_ACCESS_MODE "r | w | x | f"
int access_mode(const char *s)
{
diff --git a/tests/tests.h b/tests/tests.h
index 51dc68a..22733ca 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -10,6 +10,9 @@
#define err(fmt, args...) ({ _stderr_msg(fmt, ##args); exit(1); })
#define errp(fmt, args...) ({ _stderr_pmsg(fmt, ##args); exit(1); })
+#define xmalloc(size) ({ void *ret = malloc(size); assert(ret); ret; })
+#define xzalloc(size) ({ void *ret = xmalloc(size); memset(ret, 0, size); ret; })
+
typedef struct {
const char *name;
int val;
diff --git a/tests/utimensat-0.c b/tests/utimensat-0.c
index 431d179..99c3fa4 100644
--- a/tests/utimensat-0.c
+++ b/tests/utimensat-0.c
@@ -14,7 +14,7 @@
const char *file = f_get_file(s); \
\
s = argv[i++]; \
- const struct timespec *times = NULL; \
+ const struct timespec *times = parse_timespec(s); \
\
s = argv[i++]; \
int flags = at_get_flags(s);
next reply other threads:[~2015-09-28 20:17 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-28 20:17 Mike Frysinger [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-01-14 18:43 [gentoo-commits] proj/sandbox:master commit in: tests/ Mike Gilbert
2025-01-14 4:38 Mike Gilbert
2025-01-08 4:09 [gentoo-commits] proj/sandbox:stable-2.x " Mike Gilbert
2025-01-14 4:38 ` [gentoo-commits] proj/sandbox:master " Mike Gilbert
2025-01-08 3:29 [gentoo-commits] proj/sandbox:stable-2.x " Mike Gilbert
2025-01-14 4:38 ` [gentoo-commits] proj/sandbox:master " Mike Gilbert
2025-01-08 3:04 [gentoo-commits] proj/sandbox:stable-2.x " Mike Gilbert
2025-01-14 4:38 ` [gentoo-commits] proj/sandbox:master " Mike Gilbert
2024-11-11 22:47 Sam James
2023-07-01 23:52 Mike Gilbert
2023-06-22 13:54 Mike Gilbert
2023-06-22 13:54 Mike Gilbert
2021-11-03 19:13 Mike Frysinger
2021-10-24 0:54 Mike Frysinger
2021-10-23 22:19 Mike Frysinger
2021-10-22 7:21 Michał Górny
2021-10-22 4:54 Mike Frysinger
2021-10-22 4:15 Mike Frysinger
2021-10-21 2:48 Mike Frysinger
2021-10-18 5:21 Mike Frysinger
2020-05-31 10:52 Michał Górny
2019-06-27 21:41 Sergei Trofimovich
2018-02-19 5:50 Michał Górny
2016-03-29 12:24 Mike Frysinger
2016-03-29 12:24 Mike Frysinger
2015-12-20 21:33 Mike Frysinger
2015-09-27 6:13 Mike Frysinger
2015-09-11 7:53 Mike Frysinger
2015-09-11 7:53 Mike Frysinger
2012-12-24 23:58 Mike Frysinger
2012-11-26 10:10 Mike Frysinger
2012-06-24 6:14 Mike Frysinger
2012-06-23 21:27 Mike Frysinger
2012-03-06 19:00 Mike Frysinger
2012-03-05 7:01 Mike Frysinger
2012-03-05 7:01 Mike Frysinger
2011-07-08 19:53 Mike Frysinger
2011-07-04 23:06 Mike Frysinger
2011-07-04 23:06 Mike Frysinger
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443470417.6b0db7d9abfded8bdf8c7d061b261f053eec886d.vapier@gentoo \
--to=vapier@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.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