From: Eugene Syromyatnikov Date: Sun, 1 Jan 2017 19:43:09 +0000 (+0300) Subject: tests: check non-verbose decoding of LOOP_* ioctls X-Git-Tag: v4.16~95 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=23287f11fe9e41ed47de2bdaa404ef6f20479d02;p=strace tests: check non-verbose decoding of LOOP_* ioctls * tests/ioctl_loop-nv.c: New file. * tests/ioctl_loop-nv.test: New test. * tests/ioctl_loop.c [!ABBREV] (ABBREV): Define to 0. (print_loop_info, print_loop_info64): Handle [ABBREV != 0] case. * tests/.gitignore: Add ioctl_loop-nv. * tests/Makefile.am (check_PROGRAMS): Likewise. --- diff --git a/tests/.gitignore b/tests/.gitignore index e4be0001..cec446e8 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -119,6 +119,7 @@ ioctl_dm-v ioctl_evdev ioctl_evdev-v ioctl_loop +ioctl_loop-nv ioctl_loop-v ioctl_mtd ioctl_rtc diff --git a/tests/Makefile.am b/tests/Makefile.am index 205b9b68..8c7cdd0f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -180,6 +180,7 @@ check_PROGRAMS = \ ioctl_evdev \ ioctl_evdev-v \ ioctl_loop \ + ioctl_loop-nv \ ioctl_loop-v \ ioctl_mtd \ ioctl_rtc \ @@ -577,6 +578,7 @@ DECODER_TESTS = \ ioctl_dm-v.test \ ioctl_evdev.test \ ioctl_evdev-v.test \ + ioctl_loop-nv.test \ ioctl_loop-v.test \ ioctl_loop.test \ ioctl_mtd.test \ diff --git a/tests/ioctl_loop-nv.c b/tests/ioctl_loop-nv.c new file mode 100644 index 00000000..dc6b916d --- /dev/null +++ b/tests/ioctl_loop-nv.c @@ -0,0 +1,2 @@ +#define ABBREV 1 +#include "ioctl_loop.c" diff --git a/tests/ioctl_loop-nv.test b/tests/ioctl_loop-nv.test new file mode 100755 index 00000000..dcc27e1d --- /dev/null +++ b/tests/ioctl_loop-nv.test @@ -0,0 +1,12 @@ +#!/bin/sh + +# Check non-verbose decoding of LOOP_* ioctls. + +. "${srcdir=.}/init.sh" + +run_prog > /dev/null +run_strace -a22 -eioctl -e verbose=none $args > "$EXP" +check_prog grep +grep -v '^ioctl([012],' < "$LOG" > "$OUT" +match_diff "$OUT" "$EXP" +rm -f "$EXP" "$OUT" diff --git a/tests/ioctl_loop.c b/tests/ioctl_loop.c index 3341e689..6946a2f4 100644 --- a/tests/ioctl_loop.c +++ b/tests/ioctl_loop.c @@ -40,11 +40,18 @@ #include #include "xlat/loop_cmds.h" +#ifndef ABBREV +# define ABBREV 0 +#endif + static void print_loop_info(struct loop_info * const info, bool print_encrypt, const char *encrypt_type, const char *encrypt_key, const char *flags) { +#if ABBREV + printf("%p", info); +#else printf("{lo_number=%d", info->lo_number); # if VERBOSE printf(", lo_device=makedev(%u, %u), lo_inode=%lu, " @@ -92,6 +99,7 @@ print_loop_info(struct loop_info * const info, bool print_encrypt, # else /* !VERBOSE */ printf(", ...}"); # endif /* VERBOSE */ +#endif /* !ABBREV */ } static void @@ -99,6 +107,9 @@ print_loop_info64(struct loop_info64 * const info64, bool print_encrypt, const char *encrypt_type, const char *encrypt_key, const char *flags) { +#if ABBREV + printf("%p", info64); +#else # if VERBOSE printf("{lo_device=makedev(%u, %u), lo_inode=%" PRIu64 ", lo_rdevice=makedev(%u, %u), lo_offset=%#" PRIx64 @@ -151,6 +162,7 @@ print_loop_info64(struct loop_info64 * const info64, bool print_encrypt, # else /* !VERBOSE */ printf(", ...}"); # endif /* VERBOSE */ +#endif /* !ABBREV */ } int