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

tests/adjtimex.c
tests/adjtimex.test

index 50f77b681fdc94e1e13a9584426442d0983dc6ed..aafb4b64d6ee9d5c22985d5cecaeb61cee100db5 100644 (file)
@@ -1,4 +1,6 @@
 /*
+ * This file is part of adjtimex strace test.
+ *
  * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
  * All rights reserved.
  *
 #include "tests.h"
 #include <stdio.h>
 #include <stdint.h>
+#include <string.h>
 #include <sys/timex.h>
 
 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);
 
index 10653aa01436cc4c7601a57472cb98a9e3b76d3e..a2466e64a65f34a0ee63e8e24b93753cded300a8 100755 (executable)
@@ -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"