From f2e6f3d3c4b227d4185fadaa218572d593ac3da3 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sat, 6 Feb 2016 00:56:55 +0000 Subject: [PATCH] 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. --- tests/utime.c | 16 +++++++++++----- tests/utime.test | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/utime.c b/tests/utime.c index fa1003de..22862172 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 * All rights reserved. * @@ -33,7 +35,7 @@ #include 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 @@ print_tm(struct tm *p) 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 9c5628a2..bb0693fc 100755 --- a/tests/utime.test +++ b/tests/utime.test @@ -9,7 +9,7 @@ $STRACE -e utime -h > /dev/null || 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 || { -- 2.40.0