tests: extend coverage of utime syscall
* tests/utime.c (main): Check decoding of NULL struct utimbuf pointer.
Check decoding of struct utimbuf located at the end of page boundary.
* tests/utime.test: Update.
diff --git a/tests/utime.c b/tests/utime.c
index fa1003d..2286217 100644
--- a/tests/utime.c
+++ b/tests/utime.c
@@ -1,4 +1,6 @@
/*
+ * This file is part of utime strace test.
+ *
* Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
@@ -33,7 +35,7 @@
#include <stdio.h>
static void
-print_tm(struct tm *p)
+print_tm(const struct tm * const p)
{
printf("%02d/%02d/%02d-%02d:%02d:%02d",
p->tm_year + 1900, p->tm_mon + 1, p->tm_mday,
@@ -43,16 +45,20 @@
int
main(void)
{
- time_t t = time(NULL);
- struct utimbuf u = { .actime = t, .modtime = t };
- struct tm *p = localtime(&t);
+ utime("", NULL);
+ printf("utime(\"\", NULL) = -1 ENOENT (%m)\n");
+
+ const time_t t = time(NULL);
+ const struct tm * const p = localtime(&t);
+ const struct utimbuf u = { .actime = t, .modtime = t };
+ const struct utimbuf const *tail_u = tail_memdup(&u, sizeof(u));
printf("utime(\"utime\\nfilename\", [");
print_tm(p);
printf(", ");
print_tm(p);
printf("]) = -1 ENOENT ");
- assert(utime("utime\nfilename", &u) == -1);
+ assert(utime("utime\nfilename", tail_u) == -1);
if (ENOENT != errno)
perror_msg_and_skip("utime");
printf("(%m)\n");
diff --git a/tests/utime.test b/tests/utime.test
index 9c5628a..bb0693f 100755
--- a/tests/utime.test
+++ b/tests/utime.test
@@ -9,7 +9,7 @@
OUT="$LOG.out"
run_prog > /dev/null
-run_strace -e utime $args > "$OUT"
+run_strace -a 16 -e utime $args > "$OUT"
check_prog grep
LC_ALL=C grep -x "utime(.*" "$LOG" > /dev/null || {