From 9d77b562d3c3d8f376efec1b6e0bd70d348934c8 Mon Sep 17 00:00:00 2001 From: Elvira Khabirova Date: Fri, 21 Aug 2015 00:09:32 +0300 Subject: [PATCH] tests: add times-fail.test * tests/times-fail.c: New file. * tests/times-fail.test: New test. * tests/Makefile.am (check_PROGRAMS): Add times-fail. (TESTS): Add times-fail.test. * tests/.gitignore: Add times-fail. --- tests/.gitignore | 1 + tests/Makefile.am | 2 ++ tests/times-fail.c | 18 ++++++++++++++++++ tests/times-fail.test | 13 +++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 tests/times-fail.c create mode 100755 tests/times-fail.test diff --git a/tests/.gitignore b/tests/.gitignore index d9a0a757..624aaae6 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -48,6 +48,7 @@ statfs sysinfo time times +times-fail uid uid16 uid32 diff --git a/tests/Makefile.am b/tests/Makefile.am index 24e255eb..5ae29e48 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -61,6 +61,7 @@ check_PROGRAMS = \ sysinfo \ time \ times \ + times-fail \ uid \ uid16 \ uid32 \ @@ -141,6 +142,7 @@ TESTS = \ sun_path.test \ time.test \ times.test \ + times-fail.test \ umovestr.test \ umovestr2.test \ unix-yy.test \ diff --git a/tests/times-fail.c b/tests/times-fail.c new file mode 100644 index 00000000..f3202b1f --- /dev/null +++ b/tests/times-fail.c @@ -0,0 +1,18 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include + +int +main (void) +{ + if (syscall(__NR_times, 0x42) != -1) + return 77; + puts("times(0x42) = -1 EFAULT (Bad address)"); + puts("+++ exited with 0 +++"); + + return 0; +} diff --git a/tests/times-fail.test b/tests/times-fail.test new file mode 100755 index 00000000..6e596fab --- /dev/null +++ b/tests/times-fail.test @@ -0,0 +1,13 @@ +#!/bin/sh + +# Check decoding of failing times syscall + +. "${srcdir=.}/init.sh" + +run_prog > /dev/null +OUT="$LOG.out" +run_strace -a12 -etimes $args > "$OUT" +match_diff "$OUT" "$LOG" +rm -f "$OUT" + +exit 0 -- 2.40.0