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.
This commit is contained in:
2015-07-15 09:02:17 +00:00
parent 8d51f43946
commit d27cccaeff
4 changed files with 54 additions and 0 deletions

1
tests/.gitignore vendored
View File

@ -33,6 +33,7 @@ uio
umovestr
umovestr2
unix-pair-send-recv
utime
xattr
*.log
*.log.*

View File

@ -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 \

28
tests/utime.c Normal file
View File

@ -0,0 +1,28 @@
#include <time.h>
#include <utime.h>
#include <errno.h>
#include <stdio.h>
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;
}

23
tests/utime.test Executable file
View File

@ -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