From: Dmitry V. Levin Date: Sat, 6 Feb 2016 00:56:15 +0000 (+0000) Subject: tests: extend coverage of adjtimex syscall X-Git-Tag: v4.12~585 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7fce7c0332a15a261f39db287ef0a6ecd8ca4acf;p=strace tests: extend coverage of adjtimex syscall * tests/adjtimex.c (main): Check decoding of NULL struct timex pointer. Check decoding of struct timex located at the end of page boundary. * tests/adjtimex.test: Update. --- diff --git a/tests/adjtimex.c b/tests/adjtimex.c index 50f77b68..aafb4b64 100644 --- a/tests/adjtimex.c +++ b/tests/adjtimex.c @@ -1,4 +1,6 @@ /* + * This file is part of adjtimex strace test. + * * Copyright (c) 2015-2016 Dmitry V. Levin * All rights reserved. * @@ -28,14 +30,19 @@ #include "tests.h" #include #include +#include #include int main(void) { - struct timex tx = {}; - int state = adjtimex(&tx); + adjtimex(NULL); + printf("adjtimex\\(NULL\\) = -1 EFAULT \\(%m\\)\n"); + + struct timex * const tx = tail_alloc(sizeof(*tx)); + memset(tx, 0, sizeof(*tx)); + int state = adjtimex(tx); if (state < 0) perror_msg_and_skip("adjtimex"); @@ -48,27 +55,27 @@ main(void) ", tai=%d" #endif "\\}\\) = %d \\(TIME_[A-Z]+\\)\n", - (intmax_t) tx.offset, - (intmax_t) tx.freq, - (intmax_t) tx.maxerror, - (intmax_t) tx.esterror, - tx.status ? "STA_[A-Z]+(\\|STA_[A-Z]+)*" : "0", - (intmax_t) tx.constant, - (intmax_t) tx.precision, - (intmax_t) tx.tolerance, - (intmax_t) tx.time.tv_sec, - (intmax_t) tx.time.tv_usec, - (intmax_t) tx.tick, - (intmax_t) tx.ppsfreq, - (intmax_t) tx.jitter, - tx.shift, - (intmax_t) tx.stabil, - (intmax_t) tx.jitcnt, - (intmax_t) tx.calcnt, - (intmax_t) tx.errcnt, - (intmax_t) tx.stbcnt, + (intmax_t) tx->offset, + (intmax_t) tx->freq, + (intmax_t) tx->maxerror, + (intmax_t) tx->esterror, + tx->status ? "STA_[A-Z]+(\\|STA_[A-Z]+)*" : "0", + (intmax_t) tx->constant, + (intmax_t) tx->precision, + (intmax_t) tx->tolerance, + (intmax_t) tx->time.tv_sec, + (intmax_t) tx->time.tv_usec, + (intmax_t) tx->tick, + (intmax_t) tx->ppsfreq, + (intmax_t) tx->jitter, + tx->shift, + (intmax_t) tx->stabil, + (intmax_t) tx->jitcnt, + (intmax_t) tx->calcnt, + (intmax_t) tx->errcnt, + (intmax_t) tx->stbcnt, #ifdef HAVE_STRUCT_TIMEX_TAI - tx.tai, + tx->tai, #endif state); diff --git a/tests/adjtimex.test b/tests/adjtimex.test index 10653aa0..a2466e64 100755 --- a/tests/adjtimex.test +++ b/tests/adjtimex.test @@ -6,7 +6,7 @@ run_prog > /dev/null OUT="$LOG.out" -run_strace -e adjtimex $args > "$OUT" +run_strace -a 15 -e adjtimex $args > "$OUT" match_grep "$LOG" "$OUT" rm -f "$OUT"