]> granicus.if.org Git - strace/commitdiff
tests: check non-verbose decoding of LOOP_* ioctls
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sun, 1 Jan 2017 19:43:09 +0000 (22:43 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 4 Jan 2017 22:00:38 +0000 (22:00 +0000)
* 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.

tests/.gitignore
tests/Makefile.am
tests/ioctl_loop-nv.c [new file with mode: 0644]
tests/ioctl_loop-nv.test [new file with mode: 0755]
tests/ioctl_loop.c

index e4be00015169f84c6fde7bedd055c825c020d320..cec446e8a7dcb76ca0ea78a8745d4275d2f0eba5 100644 (file)
@@ -119,6 +119,7 @@ ioctl_dm-v
 ioctl_evdev
 ioctl_evdev-v
 ioctl_loop
+ioctl_loop-nv
 ioctl_loop-v
 ioctl_mtd
 ioctl_rtc
index 205b9b68515282ca5b8e64692172ee175f2bb494..8c7cdd0fe047440ca5cff293b1d847ae09e005c3 100644 (file)
@@ -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 (file)
index 0000000..dc6b916
--- /dev/null
@@ -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 (executable)
index 0000000..dcc27e1
--- /dev/null
@@ -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"
index 3341e689f7cb823b734ead08aa7ad013eaf51cf3..6946a2f4d8c72fca6900aa1a454d3653da9e6772 100644 (file)
 #include <linux/loop.h>
 #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