From d27cccaeff704db6a2741a15bc51c5d89650cad9 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 15 Jul 2015 09:02:17 +0000 Subject: [PATCH] tests: add utime.test * tests/utime.c: New file. * tests/utime.test: New test. * tests/Makefile.am (check_PROGRAMS): Add utime. (TESTS): Add utime.test. * tests/.gitignore: Add utime. --- tests/.gitignore | 1 + tests/Makefile.am | 2 ++ tests/utime.c | 28 ++++++++++++++++++++++++++++ tests/utime.test | 23 +++++++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 tests/utime.c create mode 100755 tests/utime.test diff --git a/tests/.gitignore b/tests/.gitignore index 0cc3964b..df25127f 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -33,6 +33,7 @@ uio umovestr umovestr2 unix-pair-send-recv +utime xattr *.log *.log.* diff --git a/tests/Makefile.am b/tests/Makefile.am index 2e298d6f..545bb992 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -44,6 +44,7 @@ check_PROGRAMS = \ umovestr \ umovestr2 \ unix-pair-send-recv \ + utime \ xattr filter_unavailable_LDFLAGS = -pthread @@ -95,6 +96,7 @@ TESTS = \ uid16.test \ uid32.test \ uio.test \ + utime.test \ xattr.test \ count.test \ detach-sleeping.test \ diff --git a/tests/utime.c b/tests/utime.c new file mode 100644 index 00000000..0298b27f --- /dev/null +++ b/tests/utime.c @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +static void +print_tm(struct tm *p) +{ + printf("%02d/%02d/%02d-%02d:%02d:%02d", + p->tm_year + 1900, p->tm_mon + 1, p->tm_mday, + p->tm_hour, p->tm_min, p->tm_sec); +} + +int +main(void) +{ + time_t t = time(NULL); + struct utimbuf u = { .actime = t, .modtime = t }; + struct tm *p = localtime(&t); + + printf("utime\\(\"utime\\\\nfilename\", \\["); + print_tm(p); + printf(", "); + print_tm(p); + printf("\\]\\) += -1 ENOENT .*\n"); + + return utime("utime\nfilename", &u) == -1 && errno == ENOENT ? 0 : 77; +} diff --git a/tests/utime.test b/tests/utime.test new file mode 100755 index 00000000..2ebd4b93 --- /dev/null +++ b/tests/utime.test @@ -0,0 +1,23 @@ +#!/bin/sh + +# Check decoding of utime syscall. + +. "${srcdir=.}/init.sh" + +$STRACE -e utime -h > /dev/null || + skip_ 'utime syscall is not supported on this architecture' + +OUT="$LOG.out" +run_prog > /dev/null +run_strace -e utime $args > "$OUT" + +check_prog grep +LC_ALL=C grep -x "utime(.*" "$LOG" > /dev/null || { + rm -f "$OUT" + skip_ 'test executable does not use utime syscall' +} +match_grep "$LOG" "$OUT" + +rm -f "$OUT" + +exit 0 -- 2.40.0