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.
This commit is contained in:
Дмитрий Левин 2016-02-06 00:56:55 +00:00
parent b5a7011d71
commit f2e6f3d3c4
2 changed files with 12 additions and 6 deletions

View 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");

View File

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