]> granicus.if.org Git - strace/commitdiff
tests: extend coverage of utime syscall
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 6 Feb 2016 00:56:55 +0000 (00:56 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 8 Feb 2016 18:18:05 +0000 (18:18 +0000)
* 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
tests/utime.test

index fa1003deeec0e853e80e28bbbea62eb6bd83a630..228621726419ac855b98a3d6ec060a02a7ef837a 100644 (file)
@@ -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 @@ 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");
index 9c5628a26a8fed688daee7905841a80909920385..bb0693fc2b446a401f20e7a0ecdd5569099fa8ca 100755 (executable)
@@ -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 || {