Blame SOURCES/0032-tests-check-decoding-of-successful-evdev-ioctl.patch

4d44fe
From e286b9cbc0bd542bb441c5acb65fef5f58b71aef Mon Sep 17 00:00:00 2001
4d44fe
From: Zhibin Li <08826794brmt@gmail.com>
4d44fe
Date: Wed, 1 Aug 2018 17:54:35 +0800
4d44fe
Subject: [PATCH] tests: check decoding of successful evdev ioctl
4d44fe
4d44fe
* tests/ioctl_evdev-success.c: New file.
4d44fe
* tests/ioctl_evdev-success-v.c: Likewise.
4d44fe
* tests/ioctl_evdev-success.test: New test.
4d44fe
* tests/ioctl_evdev-success-v.test: Likewise.
4d44fe
* tests/.gitignore: Add ioctl_evdev-success and ioctl_evdev-success-v.
4d44fe
* tests/Makefile.am (check_PROGRAMS): Likewise.
4d44fe
(DECODER_TESTS): Add the two tests mentioned above.
4d44fe
4d44fe
Skipped files (not present in the tarball):
4d44fe
	tests/.gitignore
4d44fe
4d44fe
Additional changes:
4d44fe
	tests/Makefile.in (generated from tests/Makefile.am)
4d44fe
	tests-m32/Makefile.am (generated from tests/Makefile.am)
4d44fe
	tests-m32/Makefile.in (generated from tests-m32/Makefile.am)
4d44fe
	tests-m32/ioctl_evdev-success-v.c (copy of tests/ioctl_evdev-success-v.c)
4d44fe
	tests-m32/ioctl_evdev-success-v.test (copy of tests/ioctl_evdev-success-v.test)
4d44fe
	tests-m32/ioctl_evdev-success.c (copy of tests/ioctl_evdev-success.c)
4d44fe
	tests-m32/ioctl_evdev-success.test (copy of tests/ioctl_evdev-success.test)
4d44fe
	tests-mx32/Makefile.am (generated from tests/Makefile.am)
4d44fe
	tests-mx32/Makefile.in (generated from tests-mx32/Makefile.am)
4d44fe
	tests-mx32/ioctl_evdev-success-v.c (copy of tests/ioctl_evdev-success-v.c)
4d44fe
	tests-mx32/ioctl_evdev-success-v.test (copy of tests/ioctl_evdev-success-v.test)
4d44fe
	tests-mx32/ioctl_evdev-success.c (copy of tests/ioctl_evdev-success.c)
4d44fe
	tests-mx32/ioctl_evdev-success.test (copy of tests/ioctl_evdev-success.test)
4d44fe
---
4d44fe
 tests/.gitignore                 |   2 +
4d44fe
 tests/Makefile.am                |   4 +
4d44fe
 tests/ioctl_evdev-success-v.c    |   2 +
4d44fe
 tests/ioctl_evdev-success-v.test |  13 +++
4d44fe
 tests/ioctl_evdev-success.c      | 232 +++++++++++++++++++++++++++++++++++++++
4d44fe
 tests/ioctl_evdev-success.test   |  13 +++
4d44fe
 6 files changed, 266 insertions(+)
4d44fe
 create mode 100644 tests/ioctl_evdev-success-v.c
4d44fe
 create mode 100755 tests/ioctl_evdev-success-v.test
4d44fe
 create mode 100644 tests/ioctl_evdev-success.c
4d44fe
 create mode 100755 tests/ioctl_evdev-success.test
4d44fe
4d44fe
Index: strace-4.24/tests/Makefile.am
4d44fe
===================================================================
4d44fe
--- strace-4.24.orig/tests/Makefile.am	2019-08-01 18:40:47.334658983 +0200
4d44fe
+++ strace-4.24/tests/Makefile.am	2019-08-01 18:40:47.365658583 +0200
4d44fe
@@ -98,6 +98,8 @@
4d44fe
 	int_0x80 \
4d44fe
 	ioctl_dm-v \
4d44fe
 	ioctl_evdev-v \
4d44fe
+	ioctl_evdev-success \
4d44fe
+	ioctl_evdev-success-v \
4d44fe
 	ioctl_loop-nv \
4d44fe
 	ioctl_loop-v \
4d44fe
 	ioctl_nsfs \
4d44fe
@@ -231,6 +233,8 @@
4d44fe
 	futex.test \
4d44fe
 	getuid.test \
4d44fe
 	ioctl.test \
4d44fe
+	ioctl_evdev-success.test \
4d44fe
+	ioctl_evdev-success-v.test \
4d44fe
 	ioctl_perf-success.test \
4d44fe
 	ipc_msgbuf.test \
4d44fe
 	kern_features-fault.test \
4d44fe
Index: strace-4.24/tests-m32/Makefile.am
4d44fe
===================================================================
4d44fe
--- strace-4.24.orig/tests-m32/Makefile.am	2018-08-14 02:44:30.000000000 +0200
4d44fe
+++ strace-4.24/tests-m32/Makefile.am	2019-08-01 18:40:47.365658583 +0200
4d44fe
@@ -118,6 +118,8 @@
4d44fe
 	int_0x80 \
4d44fe
 	ioctl_dm-v \
4d44fe
 	ioctl_evdev-v \
4d44fe
+	ioctl_evdev-success \
4d44fe
+	ioctl_evdev-success-v \
4d44fe
 	ioctl_loop-nv \
4d44fe
 	ioctl_loop-v \
4d44fe
 	ioctl_nsfs \
4d44fe
@@ -247,6 +249,8 @@
4d44fe
 	futex.test \
4d44fe
 	getuid.test \
4d44fe
 	ioctl.test \
4d44fe
+	ioctl_evdev-success.test \
4d44fe
+	ioctl_evdev-success-v.test \
4d44fe
 	ioctl_perf-success.test \
4d44fe
 	ipc_msgbuf.test \
4d44fe
 	kern_features-fault.test \
4d44fe
Index: strace-4.24/tests-mx32/Makefile.am
4d44fe
===================================================================
4d44fe
--- strace-4.24.orig/tests-mx32/Makefile.am	2018-08-14 02:44:30.000000000 +0200
4d44fe
+++ strace-4.24/tests-mx32/Makefile.am	2019-08-01 18:40:47.366658571 +0200
4d44fe
@@ -118,6 +118,8 @@
4d44fe
 	int_0x80 \
4d44fe
 	ioctl_dm-v \
4d44fe
 	ioctl_evdev-v \
4d44fe
+	ioctl_evdev-success \
4d44fe
+	ioctl_evdev-success-v \
4d44fe
 	ioctl_loop-nv \
4d44fe
 	ioctl_loop-v \
4d44fe
 	ioctl_nsfs \
4d44fe
@@ -247,6 +249,8 @@
4d44fe
 	futex.test \
4d44fe
 	getuid.test \
4d44fe
 	ioctl.test \
4d44fe
+	ioctl_evdev-success.test \
4d44fe
+	ioctl_evdev-success-v.test \
4d44fe
 	ioctl_perf-success.test \
4d44fe
 	ipc_msgbuf.test \
4d44fe
 	kern_features-fault.test \
4d44fe
Index: strace-4.24/tests/ioctl_evdev-success-v.c
4d44fe
===================================================================
4d44fe
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
4d44fe
+++ strace-4.24/tests/ioctl_evdev-success-v.c	2019-08-01 18:40:47.366658571 +0200
4d44fe
@@ -0,0 +1,2 @@
4d44fe
+#define VERBOSE 1
4d44fe
+#include "ioctl_evdev-success.c"
4d44fe
Index: strace-4.24/tests-m32/ioctl_evdev-success-v.c
4d44fe
===================================================================
4d44fe
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
4d44fe
+++ strace-4.24/tests-m32/ioctl_evdev-success-v.c	2019-08-01 18:40:47.366658571 +0200
4d44fe
@@ -0,0 +1,2 @@
4d44fe
+#define VERBOSE 1
4d44fe
+#include "ioctl_evdev-success.c"
4d44fe
Index: strace-4.24/tests-mx32/ioctl_evdev-success-v.c
4d44fe
===================================================================
4d44fe
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
4d44fe
+++ strace-4.24/tests-mx32/ioctl_evdev-success-v.c	2019-08-01 18:40:47.366658571 +0200
4d44fe
@@ -0,0 +1,2 @@
4d44fe
+#define VERBOSE 1
4d44fe
+#include "ioctl_evdev-success.c"
4d44fe
Index: strace-4.24/tests/ioctl_evdev-success-v.test
4d44fe
===================================================================
4d44fe
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
4d44fe
+++ strace-4.24/tests/ioctl_evdev-success-v.test	2019-08-01 18:40:58.009521546 +0200
4d44fe
@@ -0,0 +1,13 @@
4d44fe
+#!/bin/sh -efu
4d44fe
+
4d44fe
+. "${srcdir=.}/scno_tampering.sh"
4d44fe
+
4d44fe
+: ${IOCTL_INJECT_START=256}
4d44fe
+: ${IOCTL_INJECT_RETVAL=8}
4d44fe
+
4d44fe
+run_prog
4d44fe
+run_strace -a16 -v -e trace=ioctl \
4d44fe
+	-e inject=ioctl:retval="${IOCTL_INJECT_RETVAL}":when="${IOCTL_INJECT_START}+" \
4d44fe
+	../ioctl_evdev-success-v "${IOCTL_INJECT_START}" "${IOCTL_INJECT_RETVAL}"> "$EXP"
4d44fe
+grep -v '^ioctl([012][,<]' < "$LOG" > "$OUT"
4d44fe
+match_diff "$OUT" "$EXP"
4d44fe
Index: strace-4.24/tests-m32/ioctl_evdev-success-v.test
4d44fe
===================================================================
4d44fe
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
4d44fe
+++ strace-4.24/tests-m32/ioctl_evdev-success-v.test	2019-08-01 18:40:58.009521546 +0200
4d44fe
@@ -0,0 +1,13 @@
4d44fe
+#!/bin/sh -efu
4d44fe
+
4d44fe
+. "${srcdir=.}/scno_tampering.sh"
4d44fe
+
4d44fe
+: ${IOCTL_INJECT_START=256}
4d44fe
+: ${IOCTL_INJECT_RETVAL=8}
4d44fe
+
4d44fe
+run_prog
4d44fe
+run_strace -a16 -v -e trace=ioctl \
4d44fe
+	-e inject=ioctl:retval="${IOCTL_INJECT_RETVAL}":when="${IOCTL_INJECT_START}+" \
4d44fe
+	../ioctl_evdev-success-v "${IOCTL_INJECT_START}" "${IOCTL_INJECT_RETVAL}"> "$EXP"
4d44fe
+grep -v '^ioctl([012][,<]' < "$LOG" > "$OUT"
4d44fe
+match_diff "$OUT" "$EXP"
4d44fe
Index: strace-4.24/tests-mx32/ioctl_evdev-success-v.test
4d44fe
===================================================================
4d44fe
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
4d44fe
+++ strace-4.24/tests-mx32/ioctl_evdev-success-v.test	2019-08-01 18:40:58.009521546 +0200
4d44fe
@@ -0,0 +1,13 @@
4d44fe
+#!/bin/sh -efu
4d44fe
+
4d44fe
+. "${srcdir=.}/scno_tampering.sh"
4d44fe
+
4d44fe
+: ${IOCTL_INJECT_START=256}
4d44fe
+: ${IOCTL_INJECT_RETVAL=8}
4d44fe
+
4d44fe
+run_prog
4d44fe
+run_strace -a16 -v -e trace=ioctl \
4d44fe
+	-e inject=ioctl:retval="${IOCTL_INJECT_RETVAL}":when="${IOCTL_INJECT_START}+" \
4d44fe
+	../ioctl_evdev-success-v "${IOCTL_INJECT_START}" "${IOCTL_INJECT_RETVAL}"> "$EXP"
4d44fe
+grep -v '^ioctl([012][,<]' < "$LOG" > "$OUT"
4d44fe
+match_diff "$OUT" "$EXP"
4d44fe
Index: strace-4.24/tests/ioctl_evdev-success.c
4d44fe
===================================================================
4d44fe
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
4d44fe
+++ strace-4.24/tests/ioctl_evdev-success.c	2019-08-01 18:40:58.009521546 +0200
4d44fe
@@ -0,0 +1,232 @@
4d44fe
+#include "tests.h"
4d44fe
+
4d44fe
+#ifdef HAVE_LINUX_INPUT_H
4d44fe
+
4d44fe
+# include <inttypes.h>
4d44fe
+# include <stdio.h>
4d44fe
+# include <stdlib.h>
4d44fe
+# include <sys/ioctl.h>
4d44fe
+# include <linux/input.h>
4d44fe
+# include "print_fields.h"
4d44fe
+
4d44fe
+static const char *errstr;
4d44fe
+
4d44fe
+struct evdev_check {
4d44fe
+	unsigned long cmd;
4d44fe
+	const char *cmd_str;
4d44fe
+	void *arg_ptr;
4d44fe
+	void (*print_arg)(long rc, void *ptr, void *arg);
4d44fe
+};
4d44fe
+
4d44fe
+static long
4d44fe
+invoke_test_syscall(unsigned long cmd, void *p)
4d44fe
+{
4d44fe
+	long rc = ioctl(-1, cmd, p);
4d44fe
+	errstr = sprintrc(rc);
4d44fe
+	static char inj_errstr[4096];
4d44fe
+
4d44fe
+	snprintf(inj_errstr, sizeof(inj_errstr), "%s (INJECTED)", errstr);
4d44fe
+	errstr = inj_errstr;
4d44fe
+	return rc;
4d44fe
+}
4d44fe
+
4d44fe
+static void
4d44fe
+test_evdev(struct evdev_check *check, void *arg)
4d44fe
+{
4d44fe
+	long rc = invoke_test_syscall(check->cmd, check->arg_ptr);
4d44fe
+	printf("ioctl(-1, %s, ", check->cmd_str);
4d44fe
+	if (check->print_arg)
4d44fe
+		check->print_arg(rc, check->arg_ptr, arg);
4d44fe
+	else
4d44fe
+		printf("%p", check->arg_ptr);
4d44fe
+	printf(") = %s\n", errstr);
4d44fe
+}
4d44fe
+
4d44fe
+static void
4d44fe
+print_input_absinfo(long rc, void *ptr, void *arg)
4d44fe
+{
4d44fe
+	struct input_absinfo *absinfo = ptr;
4d44fe
+
4d44fe
+	if (rc < 0) {
4d44fe
+		printf("%p", absinfo);
4d44fe
+		return;
4d44fe
+	}
4d44fe
+	PRINT_FIELD_U("{", *absinfo, value);
4d44fe
+	PRINT_FIELD_U(", ", *absinfo, minimum);
4d44fe
+# if VERBOSE
4d44fe
+	PRINT_FIELD_U(", ", *absinfo, maximum);
4d44fe
+	PRINT_FIELD_U(", ", *absinfo, fuzz);
4d44fe
+	PRINT_FIELD_U(", ", *absinfo, flat);
4d44fe
+#  ifdef HAVE_STRUCT_INPUT_ABSINFO_RESOLUTION
4d44fe
+	PRINT_FIELD_U(", ", *absinfo, resolution);
4d44fe
+#  endif
4d44fe
+# else
4d44fe
+	printf(", ...");
4d44fe
+# endif
4d44fe
+	printf("}");
4d44fe
+}
4d44fe
+
4d44fe
+static void
4d44fe
+print_input_id(long rc, void *ptr, void *arg)
4d44fe
+{
4d44fe
+	struct input_id *id = ptr;
4d44fe
+
4d44fe
+	if (rc < 0) {
4d44fe
+		printf("%p", id);
4d44fe
+		return;
4d44fe
+	}
4d44fe
+	printf("{ID_BUS=%" PRIu16
4d44fe
+	       ", ID_VENDOR=%" PRIu16
4d44fe
+	       ", ID_PRODUCT=%" PRIu16
4d44fe
+	       ", ID_VERSION=%" PRIu16 "}",
4d44fe
+	       id->bustype, id->vendor, id->product, id->version);
4d44fe
+}
4d44fe
+
4d44fe
+# ifdef EVIOCGMTSLOTS
4d44fe
+static void
4d44fe
+print_mtslots(long rc, void *ptr, void *arg)
4d44fe
+{
4d44fe
+	int *buffer = ptr;
4d44fe
+	const char **str = arg;
4d44fe
+	int num = atoi(*(str + 1));
4d44fe
+
4d44fe
+	if (rc < 0) {
4d44fe
+		printf("%p", buffer);
4d44fe
+		return;
4d44fe
+	}
4d44fe
+
4d44fe
+	printf("{code=%s", *str);
4d44fe
+	printf(", values=[");
4d44fe
+	for (unsigned int i = 1; i <= (unsigned) num; i++)
4d44fe
+		printf("%s%s", i > 1 ? ", " : "", *(str + i + 1));
4d44fe
+	printf("]}");
4d44fe
+}
4d44fe
+# endif
4d44fe
+
4d44fe
+static void
4d44fe
+print_getbit(long rc, void *ptr, void *arg)
4d44fe
+{
4d44fe
+	const char **str = arg;
4d44fe
+	int num = atoi(*str);
4d44fe
+
4d44fe
+	if (rc < 0) {
4d44fe
+		printf("%p", ptr);
4d44fe
+		return;
4d44fe
+	}
4d44fe
+
4d44fe
+	printf("[");
4d44fe
+	printf("%s", *(str + 1));
4d44fe
+	for (unsigned int i = 2; i <= (unsigned) num; i++) {
4d44fe
+# if ! VERBOSE
4d44fe
+		if (i > 4) {
4d44fe
+			printf(", ...");
4d44fe
+			break;
4d44fe
+		}
4d44fe
+# endif
4d44fe
+		printf(", ");
4d44fe
+		printf("%s", *(str + i));
4d44fe
+	}
4d44fe
+	printf("]");
4d44fe
+}
4d44fe
+
4d44fe
+int
4d44fe
+main(int argc, char **argv)
4d44fe
+{
4d44fe
+	unsigned long num_skip;
4d44fe
+	long inject_retval;
4d44fe
+	bool locked = false;
4d44fe
+
4d44fe
+	if (argc == 1)
4d44fe
+		return 0;
4d44fe
+
4d44fe
+	if (argc < 3)
4d44fe
+		error_msg_and_fail("Usage: %s NUM_SKIP INJECT_RETVAL", argv[0]);
4d44fe
+
4d44fe
+	num_skip = strtoul(argv[1], NULL, 0);
4d44fe
+	inject_retval = strtol(argv[2], NULL, 0);
4d44fe
+
4d44fe
+	if (inject_retval < 0)
4d44fe
+		error_msg_and_fail("Expected non-negative INJECT_RETVAL, "
4d44fe
+				   "but got %ld", inject_retval);
4d44fe
+
4d44fe
+	for (unsigned int i = 0; i < num_skip; i++) {
4d44fe
+		long rc = ioctl(-1, EVIOCGID, NULL);
4d44fe
+		printf("ioctl(-1, EVIOCGID, NULL) = %s%s\n",
4d44fe
+		       sprintrc(rc),
4d44fe
+		       rc == inject_retval ? " (INJECTED)" : "");
4d44fe
+
4d44fe
+		if (rc != inject_retval)
4d44fe
+			continue;
4d44fe
+
4d44fe
+		locked = true;
4d44fe
+		break;
4d44fe
+	}
4d44fe
+
4d44fe
+	if (!locked)
4d44fe
+		error_msg_and_fail("Hasn't locked on ioctl(-1"
4d44fe
+				   ", EVIOCGID, NULL) returning %lu",
4d44fe
+				   inject_retval);
4d44fe
+
4d44fe
+	TAIL_ALLOC_OBJECT_CONST_PTR(struct input_id, id);
4d44fe
+	TAIL_ALLOC_OBJECT_CONST_PTR(struct input_absinfo, absinfo);
4d44fe
+	TAIL_ALLOC_OBJECT_CONST_PTR(int, bad_addr_slot);
4d44fe
+# ifdef EVIOCGMTSLOTS
4d44fe
+	int mtslots[] = { ABS_MT_SLOT, 1, 3 };
4d44fe
+	/* we use the second element to indicate the number of values */
4d44fe
+	/* mtslots_str[1] is "2" so the number of values is 2 */
4d44fe
+	const char *mtslots_str[] = { "ABS_MT_SLOT", "2", "1", "3" };
4d44fe
+
4d44fe
+	/* invalid flag */
4d44fe
+	int invalid_mtslot[] = { -1, 1 };
4d44fe
+	char invalid_str[4096];
4d44fe
+	snprintf(invalid_str, sizeof(invalid_str), "%#x /* ABS_MT_??? */", invalid_mtslot[0]);
4d44fe
+	const char *invalid_mtslot_str[] = { invalid_str, "1", "1" };
4d44fe
+# endif
4d44fe
+
4d44fe
+	/* set more than 4 bits */
4d44fe
+	unsigned long ev_more[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED | 1 << EV_SND | 1 << EV_PWR };
4d44fe
+	/* we use the first element to indicate the number of set bits */
4d44fe
+	/* ev_more_str[0] is "5" so the number of set bits is 5 */
4d44fe
+	const char *ev_more_str[] = { "5", "EV_ABS", "EV_MSC", "EV_LED", "EV_SND", "EV_PWR" };
4d44fe
+
4d44fe
+	/* set less than 4 bits */
4d44fe
+	unsigned long ev_less[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED };
4d44fe
+	const char *ev_less_str[] = { "3", "EV_ABS", "EV_MSC", "EV_LED" };
4d44fe
+
4d44fe
+	/* set zero bit */
4d44fe
+	unsigned long ev_zero[] = { 0x0 };
4d44fe
+	const char *ev_zero_str[] = { "0", " 0 " };
4d44fe
+
4d44fe
+	/* KEY_MAX is 0x2ff which is greater than retval * 8 */
4d44fe
+	unsigned long key[] = { 1 << KEY_1 | 1 << KEY_2, 0 };
4d44fe
+	const char *key_str[] = { "2", "KEY_1", "KEY_2" };
4d44fe
+
4d44fe
+	struct {
4d44fe
+		struct evdev_check check;
4d44fe
+		void *ptr;
4d44fe
+	} a[] = {
4d44fe
+		{ { ARG_STR(EVIOCGID), id, print_input_id }, NULL },
4d44fe
+		{ { ARG_STR(EVIOCGABS(ABS_X)), absinfo, print_input_absinfo }, NULL },
4d44fe
+		{ { ARG_STR(EVIOCGABS(ABS_Y)), absinfo, print_input_absinfo }, NULL },
4d44fe
+		{ { ARG_STR(EVIOCGABS(ABS_Y)), absinfo, print_input_absinfo }, NULL },
4d44fe
+		{ { ARG_STR(EVIOCGBIT(0, 0)), ev_more, print_getbit }, &ev_more_str },
4d44fe
+		{ { ARG_STR(EVIOCGBIT(0, 0)), ev_less, print_getbit }, &ev_less_str },
4d44fe
+		{ { ARG_STR(EVIOCGBIT(0, 0)), ev_zero, print_getbit }, &ev_zero_str },
4d44fe
+		{ { ARG_STR(EVIOCGBIT(EV_KEY, 0)), key, print_getbit }, &key_str},
4d44fe
+# ifdef EVIOCGMTSLOTS
4d44fe
+		{ { ARG_STR(EVIOCGMTSLOTS(12)), mtslots, print_mtslots }, &mtslots_str },
4d44fe
+		{ { ARG_STR(EVIOCGMTSLOTS(8)), invalid_mtslot, print_mtslots }, &invalid_mtslot_str }
4d44fe
+# endif
4d44fe
+	};
4d44fe
+	for (unsigned int i = 0; i < ARRAY_SIZE(a); i++) {
4d44fe
+		test_evdev(&a[i].check, a[i].ptr);
4d44fe
+	}
4d44fe
+
4d44fe
+	puts("+++ exited with 0 +++");
4d44fe
+	return 0;
4d44fe
+}
4d44fe
+#else
4d44fe
+
4d44fe
+SKIP_MAIN_UNDEFINED("HAVE_LINUX_INPUT_H")
4d44fe
+
4d44fe
+#endif
4d44fe
Index: strace-4.24/tests-m32/ioctl_evdev-success.c
4d44fe
===================================================================
4d44fe
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
4d44fe
+++ strace-4.24/tests-m32/ioctl_evdev-success.c	2019-08-01 18:40:47.367658558 +0200
4d44fe
@@ -0,0 +1,232 @@
4d44fe
+#include "tests.h"
4d44fe
+
4d44fe
+#ifdef HAVE_LINUX_INPUT_H
4d44fe
+
4d44fe
+# include <inttypes.h>
4d44fe
+# include <stdio.h>
4d44fe
+# include <stdlib.h>
4d44fe
+# include <sys/ioctl.h>
4d44fe
+# include <linux/input.h>
4d44fe
+# include "print_fields.h"
4d44fe
+
4d44fe
+static const char *errstr;
4d44fe
+
4d44fe
+struct evdev_check {
4d44fe
+	unsigned long cmd;
4d44fe
+	const char *cmd_str;
4d44fe
+	void *arg_ptr;
4d44fe
+	void (*print_arg)(long rc, void *ptr, void *arg);
4d44fe
+};
4d44fe
+
4d44fe
+static long
4d44fe
+invoke_test_syscall(unsigned long cmd, void *p)
4d44fe
+{
4d44fe
+	long rc = ioctl(-1, cmd, p);
4d44fe
+	errstr = sprintrc(rc);
4d44fe
+	static char inj_errstr[4096];
4d44fe
+
4d44fe
+	snprintf(inj_errstr, sizeof(inj_errstr), "%s (INJECTED)", errstr);
4d44fe
+	errstr = inj_errstr;
4d44fe
+	return rc;
4d44fe
+}
4d44fe
+
4d44fe
+static void
4d44fe
+test_evdev(struct evdev_check *check, void *arg)
4d44fe
+{
4d44fe
+	long rc = invoke_test_syscall(check->cmd, check->arg_ptr);
4d44fe
+	printf("ioctl(-1, %s, ", check->cmd_str);
4d44fe
+	if (check->print_arg)
4d44fe
+		check->print_arg(rc, check->arg_ptr, arg);
4d44fe
+	else
4d44fe
+		printf("%p", check->arg_ptr);
4d44fe
+	printf(") = %s\n", errstr);
4d44fe
+}
4d44fe
+
4d44fe
+static void
4d44fe
+print_input_absinfo(long rc, void *ptr, void *arg)
4d44fe
+{
4d44fe
+	struct input_absinfo *absinfo = ptr;
4d44fe
+
4d44fe
+	if (rc < 0) {
4d44fe
+		printf("%p", absinfo);
4d44fe
+		return;
4d44fe
+	}
4d44fe
+	PRINT_FIELD_U("{", *absinfo, value);
4d44fe
+	PRINT_FIELD_U(", ", *absinfo, minimum);
4d44fe
+# if VERBOSE
4d44fe
+	PRINT_FIELD_U(", ", *absinfo, maximum);
4d44fe
+	PRINT_FIELD_U(", ", *absinfo, fuzz);
4d44fe
+	PRINT_FIELD_U(", ", *absinfo, flat);
4d44fe
+#  ifdef HAVE_STRUCT_INPUT_ABSINFO_RESOLUTION
4d44fe
+	PRINT_FIELD_U(", ", *absinfo, resolution);
4d44fe
+#  endif
4d44fe
+# else
4d44fe
+	printf(", ...");
4d44fe
+# endif
4d44fe
+	printf("}");
4d44fe
+}
4d44fe
+
4d44fe
+static void
4d44fe
+print_input_id(long rc, void *ptr, void *arg)
4d44fe
+{
4d44fe
+	struct input_id *id = ptr;
4d44fe
+
4d44fe
+	if (rc < 0) {
4d44fe
+		printf("%p", id);
4d44fe
+		return;
4d44fe
+	}
4d44fe
+	printf("{ID_BUS=%" PRIu16
4d44fe
+	       ", ID_VENDOR=%" PRIu16
4d44fe
+	       ", ID_PRODUCT=%" PRIu16
4d44fe
+	       ", ID_VERSION=%" PRIu16 "}",
4d44fe
+	       id->bustype, id->vendor, id->product, id->version);
4d44fe
+}
4d44fe
+
4d44fe
+# ifdef EVIOCGMTSLOTS
4d44fe
+static void
4d44fe
+print_mtslots(long rc, void *ptr, void *arg)
4d44fe
+{
4d44fe
+	int *buffer = ptr;
4d44fe
+	const char **str = arg;
4d44fe
+	int num = atoi(*(str + 1));
4d44fe
+
4d44fe
+	if (rc < 0) {
4d44fe
+		printf("%p", buffer);
4d44fe
+		return;
4d44fe
+	}
4d44fe
+
4d44fe
+	printf("{code=%s", *str);
4d44fe
+	printf(", values=[");
4d44fe
+	for (unsigned int i = 1; i <= (unsigned) num; i++)
4d44fe
+		printf("%s%s", i > 1 ? ", " : "", *(str + i + 1));
4d44fe
+	printf("]}");
4d44fe
+}
4d44fe
+# endif
4d44fe
+
4d44fe
+static void
4d44fe
+print_getbit(long rc, void *ptr, void *arg)
4d44fe
+{
4d44fe
+	const char **str = arg;
4d44fe
+	int num = atoi(*str);
4d44fe
+
4d44fe
+	if (rc < 0) {
4d44fe
+		printf("%p", ptr);
4d44fe
+		return;
4d44fe
+	}
4d44fe
+
4d44fe
+	printf("[");
4d44fe
+	printf("%s", *(str + 1));
4d44fe
+	for (unsigned int i = 2; i <= (unsigned) num; i++) {
4d44fe
+# if ! VERBOSE
4d44fe
+		if (i > 4) {
4d44fe
+			printf(", ...");
4d44fe
+			break;
4d44fe
+		}
4d44fe
+# endif
4d44fe
+		printf(", ");
4d44fe
+		printf("%s", *(str + i));
4d44fe
+	}
4d44fe
+	printf("]");
4d44fe
+}
4d44fe
+
4d44fe
+int
4d44fe
+main(int argc, char **argv)
4d44fe
+{
4d44fe
+	unsigned long num_skip;
4d44fe
+	long inject_retval;
4d44fe
+	bool locked = false;
4d44fe
+
4d44fe
+	if (argc == 1)
4d44fe
+		return 0;
4d44fe
+
4d44fe
+	if (argc < 3)
4d44fe
+		error_msg_and_fail("Usage: %s NUM_SKIP INJECT_RETVAL", argv[0]);
4d44fe
+
4d44fe
+	num_skip = strtoul(argv[1], NULL, 0);
4d44fe
+	inject_retval = strtol(argv[2], NULL, 0);
4d44fe
+
4d44fe
+	if (inject_retval < 0)
4d44fe
+		error_msg_and_fail("Expected non-negative INJECT_RETVAL, "
4d44fe
+				   "but got %ld", inject_retval);
4d44fe
+
4d44fe
+	for (unsigned int i = 0; i < num_skip; i++) {
4d44fe
+		long rc = ioctl(-1, EVIOCGID, NULL);
4d44fe
+		printf("ioctl(-1, EVIOCGID, NULL) = %s%s\n",
4d44fe
+		       sprintrc(rc),
4d44fe
+		       rc == inject_retval ? " (INJECTED)" : "");
4d44fe
+
4d44fe
+		if (rc != inject_retval)
4d44fe
+			continue;
4d44fe
+
4d44fe
+		locked = true;
4d44fe
+		break;
4d44fe
+	}
4d44fe
+
4d44fe
+	if (!locked)
4d44fe
+		error_msg_and_fail("Hasn't locked on ioctl(-1"
4d44fe
+				   ", EVIOCGID, NULL) returning %lu",
4d44fe
+				   inject_retval);
4d44fe
+
4d44fe
+	TAIL_ALLOC_OBJECT_CONST_PTR(struct input_id, id);
4d44fe
+	TAIL_ALLOC_OBJECT_CONST_PTR(struct input_absinfo, absinfo);
4d44fe
+	TAIL_ALLOC_OBJECT_CONST_PTR(int, bad_addr_slot);
4d44fe
+# ifdef EVIOCGMTSLOTS
4d44fe
+	int mtslots[] = { ABS_MT_SLOT, 1, 3 };
4d44fe
+	/* we use the second element to indicate the number of values */
4d44fe
+	/* mtslots_str[1] is "2" so the number of values is 2 */
4d44fe
+	const char *mtslots_str[] = { "ABS_MT_SLOT", "2", "1", "3" };
4d44fe
+
4d44fe
+	/* invalid flag */
4d44fe
+	int invalid_mtslot[] = { -1, 1 };
4d44fe
+	char invalid_str[4096];
4d44fe
+	snprintf(invalid_str, sizeof(invalid_str), "%#x /* ABS_MT_??? */", invalid_mtslot[0]);
4d44fe
+	const char *invalid_mtslot_str[] = { invalid_str, "1", "1" };
4d44fe
+# endif
4d44fe
+
4d44fe
+	/* set more than 4 bits */
4d44fe
+	unsigned long ev_more[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED | 1 << EV_SND | 1 << EV_PWR };
4d44fe
+	/* we use the first element to indicate the number of set bits */
4d44fe
+	/* ev_more_str[0] is "5" so the number of set bits is 5 */
4d44fe
+	const char *ev_more_str[] = { "5", "EV_ABS", "EV_MSC", "EV_LED", "EV_SND", "EV_PWR" };
4d44fe
+
4d44fe
+	/* set less than 4 bits */
4d44fe
+	unsigned long ev_less[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED };
4d44fe
+	const char *ev_less_str[] = { "3", "EV_ABS", "EV_MSC", "EV_LED" };
4d44fe
+
4d44fe
+	/* set zero bit */
4d44fe
+	unsigned long ev_zero[] = { 0x0 };
4d44fe
+	const char *ev_zero_str[] = { "0", " 0 " };
4d44fe
+
4d44fe
+	/* KEY_MAX is 0x2ff which is greater than retval * 8 */
4d44fe
+	unsigned long key[] = { 1 << KEY_1 | 1 << KEY_2, 0 };
4d44fe
+	const char *key_str[] = { "2", "KEY_1", "KEY_2" };
4d44fe
+
4d44fe
+	struct {
4d44fe
+		struct evdev_check check;
4d44fe
+		void *ptr;
4d44fe
+	} a[] = {
4d44fe
+		{ { ARG_STR(EVIOCGID), id, print_input_id }, NULL },
4d44fe
+		{ { ARG_STR(EVIOCGABS(ABS_X)), absinfo, print_input_absinfo }, NULL },
4d44fe
+		{ { ARG_STR(EVIOCGABS(ABS_Y)), absinfo, print_input_absinfo }, NULL },
4d44fe
+		{ { ARG_STR(EVIOCGABS(ABS_Y)), absinfo, print_input_absinfo }, NULL },
4d44fe
+		{ { ARG_STR(EVIOCGBIT(0, 0)), ev_more, print_getbit }, &ev_more_str },
4d44fe
+		{ { ARG_STR(EVIOCGBIT(0, 0)), ev_less, print_getbit }, &ev_less_str },
4d44fe
+		{ { ARG_STR(EVIOCGBIT(0, 0)), ev_zero, print_getbit }, &ev_zero_str },
4d44fe
+		{ { ARG_STR(EVIOCGBIT(EV_KEY, 0)), key, print_getbit }, &key_str},
4d44fe
+# ifdef EVIOCGMTSLOTS
4d44fe
+		{ { ARG_STR(EVIOCGMTSLOTS(12)), mtslots, print_mtslots }, &mtslots_str },
4d44fe
+		{ { ARG_STR(EVIOCGMTSLOTS(8)), invalid_mtslot, print_mtslots }, &invalid_mtslot_str }
4d44fe
+# endif
4d44fe
+	};
4d44fe
+	for (unsigned int i = 0; i < ARRAY_SIZE(a); i++) {
4d44fe
+		test_evdev(&a[i].check, a[i].ptr);
4d44fe
+	}
4d44fe
+
4d44fe
+	puts("+++ exited with 0 +++");
4d44fe
+	return 0;
4d44fe
+}
4d44fe
+#else
4d44fe
+
4d44fe
+SKIP_MAIN_UNDEFINED("HAVE_LINUX_INPUT_H")
4d44fe
+
4d44fe
+#endif
4d44fe
Index: strace-4.24/tests-mx32/ioctl_evdev-success.c
4d44fe
===================================================================
4d44fe
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
4d44fe
+++ strace-4.24/tests-mx32/ioctl_evdev-success.c	2019-08-01 18:40:47.367658558 +0200
4d44fe
@@ -0,0 +1,232 @@
4d44fe
+#include "tests.h"
4d44fe
+
4d44fe
+#ifdef HAVE_LINUX_INPUT_H
4d44fe
+
4d44fe
+# include <inttypes.h>
4d44fe
+# include <stdio.h>
4d44fe
+# include <stdlib.h>
4d44fe
+# include <sys/ioctl.h>
4d44fe
+# include <linux/input.h>
4d44fe
+# include "print_fields.h"
4d44fe
+
4d44fe
+static const char *errstr;
4d44fe
+
4d44fe
+struct evdev_check {
4d44fe
+	unsigned long cmd;
4d44fe
+	const char *cmd_str;
4d44fe
+	void *arg_ptr;
4d44fe
+	void (*print_arg)(long rc, void *ptr, void *arg);
4d44fe
+};
4d44fe
+
4d44fe
+static long
4d44fe
+invoke_test_syscall(unsigned long cmd, void *p)
4d44fe
+{
4d44fe
+	long rc = ioctl(-1, cmd, p);
4d44fe
+	errstr = sprintrc(rc);
4d44fe
+	static char inj_errstr[4096];
4d44fe
+
4d44fe
+	snprintf(inj_errstr, sizeof(inj_errstr), "%s (INJECTED)", errstr);
4d44fe
+	errstr = inj_errstr;
4d44fe
+	return rc;
4d44fe
+}
4d44fe
+
4d44fe
+static void
4d44fe
+test_evdev(struct evdev_check *check, void *arg)
4d44fe
+{
4d44fe
+	long rc = invoke_test_syscall(check->cmd, check->arg_ptr);
4d44fe
+	printf("ioctl(-1, %s, ", check->cmd_str);
4d44fe
+	if (check->print_arg)
4d44fe
+		check->print_arg(rc, check->arg_ptr, arg);
4d44fe
+	else
4d44fe
+		printf("%p", check->arg_ptr);
4d44fe
+	printf(") = %s\n", errstr);
4d44fe
+}
4d44fe
+
4d44fe
+static void
4d44fe
+print_input_absinfo(long rc, void *ptr, void *arg)
4d44fe
+{
4d44fe
+	struct input_absinfo *absinfo = ptr;
4d44fe
+
4d44fe
+	if (rc < 0) {
4d44fe
+		printf("%p", absinfo);
4d44fe
+		return;
4d44fe
+	}
4d44fe
+	PRINT_FIELD_U("{", *absinfo, value);
4d44fe
+	PRINT_FIELD_U(", ", *absinfo, minimum);
4d44fe
+# if VERBOSE
4d44fe
+	PRINT_FIELD_U(", ", *absinfo, maximum);
4d44fe
+	PRINT_FIELD_U(", ", *absinfo, fuzz);
4d44fe
+	PRINT_FIELD_U(", ", *absinfo, flat);
4d44fe
+#  ifdef HAVE_STRUCT_INPUT_ABSINFO_RESOLUTION
4d44fe
+	PRINT_FIELD_U(", ", *absinfo, resolution);
4d44fe
+#  endif
4d44fe
+# else
4d44fe
+	printf(", ...");
4d44fe
+# endif
4d44fe
+	printf("}");
4d44fe
+}
4d44fe
+
4d44fe
+static void
4d44fe
+print_input_id(long rc, void *ptr, void *arg)
4d44fe
+{
4d44fe
+	struct input_id *id = ptr;
4d44fe
+
4d44fe
+	if (rc < 0) {
4d44fe
+		printf("%p", id);
4d44fe
+		return;
4d44fe
+	}
4d44fe
+	printf("{ID_BUS=%" PRIu16
4d44fe
+	       ", ID_VENDOR=%" PRIu16
4d44fe
+	       ", ID_PRODUCT=%" PRIu16
4d44fe
+	       ", ID_VERSION=%" PRIu16 "}",
4d44fe
+	       id->bustype, id->vendor, id->product, id->version);
4d44fe
+}
4d44fe
+
4d44fe
+# ifdef EVIOCGMTSLOTS
4d44fe
+static void
4d44fe
+print_mtslots(long rc, void *ptr, void *arg)
4d44fe
+{
4d44fe
+	int *buffer = ptr;
4d44fe
+	const char **str = arg;
4d44fe
+	int num = atoi(*(str + 1));
4d44fe
+
4d44fe
+	if (rc < 0) {
4d44fe
+		printf("%p", buffer);
4d44fe
+		return;
4d44fe
+	}
4d44fe
+
4d44fe
+	printf("{code=%s", *str);
4d44fe
+	printf(", values=[");
4d44fe
+	for (unsigned int i = 1; i <= (unsigned) num; i++)
4d44fe
+		printf("%s%s", i > 1 ? ", " : "", *(str + i + 1));
4d44fe
+	printf("]}");
4d44fe
+}
4d44fe
+# endif
4d44fe
+
4d44fe
+static void
4d44fe
+print_getbit(long rc, void *ptr, void *arg)
4d44fe
+{
4d44fe
+	const char **str = arg;
4d44fe
+	int num = atoi(*str);
4d44fe
+
4d44fe
+	if (rc < 0) {
4d44fe
+		printf("%p", ptr);
4d44fe
+		return;
4d44fe
+	}
4d44fe
+
4d44fe
+	printf("[");
4d44fe
+	printf("%s", *(str + 1));
4d44fe
+	for (unsigned int i = 2; i <= (unsigned) num; i++) {
4d44fe
+# if ! VERBOSE
4d44fe
+		if (i > 4) {
4d44fe
+			printf(", ...");
4d44fe
+			break;
4d44fe
+		}
4d44fe
+# endif
4d44fe
+		printf(", ");
4d44fe
+		printf("%s", *(str + i));
4d44fe
+	}
4d44fe
+	printf("]");
4d44fe
+}
4d44fe
+
4d44fe
+int
4d44fe
+main(int argc, char **argv)
4d44fe
+{
4d44fe
+	unsigned long num_skip;
4d44fe
+	long inject_retval;
4d44fe
+	bool locked = false;
4d44fe
+
4d44fe
+	if (argc == 1)
4d44fe
+		return 0;
4d44fe
+
4d44fe
+	if (argc < 3)
4d44fe
+		error_msg_and_fail("Usage: %s NUM_SKIP INJECT_RETVAL", argv[0]);
4d44fe
+
4d44fe
+	num_skip = strtoul(argv[1], NULL, 0);
4d44fe
+	inject_retval = strtol(argv[2], NULL, 0);
4d44fe
+
4d44fe
+	if (inject_retval < 0)
4d44fe
+		error_msg_and_fail("Expected non-negative INJECT_RETVAL, "
4d44fe
+				   "but got %ld", inject_retval);
4d44fe
+
4d44fe
+	for (unsigned int i = 0; i < num_skip; i++) {
4d44fe
+		long rc = ioctl(-1, EVIOCGID, NULL);
4d44fe
+		printf("ioctl(-1, EVIOCGID, NULL) = %s%s\n",
4d44fe
+		       sprintrc(rc),
4d44fe
+		       rc == inject_retval ? " (INJECTED)" : "");
4d44fe
+
4d44fe
+		if (rc != inject_retval)
4d44fe
+			continue;
4d44fe
+
4d44fe
+		locked = true;
4d44fe
+		break;
4d44fe
+	}
4d44fe
+
4d44fe
+	if (!locked)
4d44fe
+		error_msg_and_fail("Hasn't locked on ioctl(-1"
4d44fe
+				   ", EVIOCGID, NULL) returning %lu",
4d44fe
+				   inject_retval);
4d44fe
+
4d44fe
+	TAIL_ALLOC_OBJECT_CONST_PTR(struct input_id, id);
4d44fe
+	TAIL_ALLOC_OBJECT_CONST_PTR(struct input_absinfo, absinfo);
4d44fe
+	TAIL_ALLOC_OBJECT_CONST_PTR(int, bad_addr_slot);
4d44fe
+# ifdef EVIOCGMTSLOTS
4d44fe
+	int mtslots[] = { ABS_MT_SLOT, 1, 3 };
4d44fe
+	/* we use the second element to indicate the number of values */
4d44fe
+	/* mtslots_str[1] is "2" so the number of values is 2 */
4d44fe
+	const char *mtslots_str[] = { "ABS_MT_SLOT", "2", "1", "3" };
4d44fe
+
4d44fe
+	/* invalid flag */
4d44fe
+	int invalid_mtslot[] = { -1, 1 };
4d44fe
+	char invalid_str[4096];
4d44fe
+	snprintf(invalid_str, sizeof(invalid_str), "%#x /* ABS_MT_??? */", invalid_mtslot[0]);
4d44fe
+	const char *invalid_mtslot_str[] = { invalid_str, "1", "1" };
4d44fe
+# endif
4d44fe
+
4d44fe
+	/* set more than 4 bits */
4d44fe
+	unsigned long ev_more[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED | 1 << EV_SND | 1 << EV_PWR };
4d44fe
+	/* we use the first element to indicate the number of set bits */
4d44fe
+	/* ev_more_str[0] is "5" so the number of set bits is 5 */
4d44fe
+	const char *ev_more_str[] = { "5", "EV_ABS", "EV_MSC", "EV_LED", "EV_SND", "EV_PWR" };
4d44fe
+
4d44fe
+	/* set less than 4 bits */
4d44fe
+	unsigned long ev_less[] = { 1 << EV_ABS | 1 << EV_MSC | 1 << EV_LED };
4d44fe
+	const char *ev_less_str[] = { "3", "EV_ABS", "EV_MSC", "EV_LED" };
4d44fe
+
4d44fe
+	/* set zero bit */
4d44fe
+	unsigned long ev_zero[] = { 0x0 };
4d44fe
+	const char *ev_zero_str[] = { "0", " 0 " };
4d44fe
+
4d44fe
+	/* KEY_MAX is 0x2ff which is greater than retval * 8 */
4d44fe
+	unsigned long key[] = { 1 << KEY_1 | 1 << KEY_2, 0 };
4d44fe
+	const char *key_str[] = { "2", "KEY_1", "KEY_2" };
4d44fe
+
4d44fe
+	struct {
4d44fe
+		struct evdev_check check;
4d44fe
+		void *ptr;
4d44fe
+	} a[] = {
4d44fe
+		{ { ARG_STR(EVIOCGID), id, print_input_id }, NULL },
4d44fe
+		{ { ARG_STR(EVIOCGABS(ABS_X)), absinfo, print_input_absinfo }, NULL },
4d44fe
+		{ { ARG_STR(EVIOCGABS(ABS_Y)), absinfo, print_input_absinfo }, NULL },
4d44fe
+		{ { ARG_STR(EVIOCGABS(ABS_Y)), absinfo, print_input_absinfo }, NULL },
4d44fe
+		{ { ARG_STR(EVIOCGBIT(0, 0)), ev_more, print_getbit }, &ev_more_str },
4d44fe
+		{ { ARG_STR(EVIOCGBIT(0, 0)), ev_less, print_getbit }, &ev_less_str },
4d44fe
+		{ { ARG_STR(EVIOCGBIT(0, 0)), ev_zero, print_getbit }, &ev_zero_str },
4d44fe
+		{ { ARG_STR(EVIOCGBIT(EV_KEY, 0)), key, print_getbit }, &key_str},
4d44fe
+# ifdef EVIOCGMTSLOTS
4d44fe
+		{ { ARG_STR(EVIOCGMTSLOTS(12)), mtslots, print_mtslots }, &mtslots_str },
4d44fe
+		{ { ARG_STR(EVIOCGMTSLOTS(8)), invalid_mtslot, print_mtslots }, &invalid_mtslot_str }
4d44fe
+# endif
4d44fe
+	};
4d44fe
+	for (unsigned int i = 0; i < ARRAY_SIZE(a); i++) {
4d44fe
+		test_evdev(&a[i].check, a[i].ptr);
4d44fe
+	}
4d44fe
+
4d44fe
+	puts("+++ exited with 0 +++");
4d44fe
+	return 0;
4d44fe
+}
4d44fe
+#else
4d44fe
+
4d44fe
+SKIP_MAIN_UNDEFINED("HAVE_LINUX_INPUT_H")
4d44fe
+
4d44fe
+#endif
4d44fe
Index: strace-4.24/tests/ioctl_evdev-success.test
4d44fe
===================================================================
4d44fe
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
4d44fe
+++ strace-4.24/tests/ioctl_evdev-success.test	2019-08-01 18:40:58.009521546 +0200
4d44fe
@@ -0,0 +1,13 @@
4d44fe
+#!/bin/sh -efu
4d44fe
+
4d44fe
+. "${srcdir=.}/scno_tampering.sh"
4d44fe
+
4d44fe
+: ${IOCTL_INJECT_START=256}
4d44fe
+: ${IOCTL_INJECT_RETVAL=8}
4d44fe
+
4d44fe
+run_prog
4d44fe
+run_strace -a16 -e trace=ioctl \
4d44fe
+	-e inject=ioctl:retval="${IOCTL_INJECT_RETVAL}":when="${IOCTL_INJECT_START}+" \
4d44fe
+	../ioctl_evdev-success "${IOCTL_INJECT_START}" "${IOCTL_INJECT_RETVAL}"> "$EXP"
4d44fe
+grep -v '^ioctl([012][,<]' < "$LOG" > "$OUT"
4d44fe
+match_diff "$OUT" "$EXP"
4d44fe
Index: strace-4.24/tests-m32/ioctl_evdev-success.test
4d44fe
===================================================================
4d44fe
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
4d44fe
+++ strace-4.24/tests-m32/ioctl_evdev-success.test	2019-08-01 18:40:58.009521546 +0200
4d44fe
@@ -0,0 +1,13 @@
4d44fe
+#!/bin/sh -efu
4d44fe
+
4d44fe
+. "${srcdir=.}/scno_tampering.sh"
4d44fe
+
4d44fe
+: ${IOCTL_INJECT_START=256}
4d44fe
+: ${IOCTL_INJECT_RETVAL=8}
4d44fe
+
4d44fe
+run_prog
4d44fe
+run_strace -a16 -e trace=ioctl \
4d44fe
+	-e inject=ioctl:retval="${IOCTL_INJECT_RETVAL}":when="${IOCTL_INJECT_START}+" \
4d44fe
+	../ioctl_evdev-success "${IOCTL_INJECT_START}" "${IOCTL_INJECT_RETVAL}"> "$EXP"
4d44fe
+grep -v '^ioctl([012][,<]' < "$LOG" > "$OUT"
4d44fe
+match_diff "$OUT" "$EXP"
4d44fe
Index: strace-4.24/tests-mx32/ioctl_evdev-success.test
4d44fe
===================================================================
4d44fe
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
4d44fe
+++ strace-4.24/tests-mx32/ioctl_evdev-success.test	2019-08-01 18:40:58.009521546 +0200
4d44fe
@@ -0,0 +1,13 @@
4d44fe
+#!/bin/sh -efu
4d44fe
+
4d44fe
+. "${srcdir=.}/scno_tampering.sh"
4d44fe
+
4d44fe
+: ${IOCTL_INJECT_START=256}
4d44fe
+: ${IOCTL_INJECT_RETVAL=8}
4d44fe
+
4d44fe
+run_prog
4d44fe
+run_strace -a16 -e trace=ioctl \
4d44fe
+	-e inject=ioctl:retval="${IOCTL_INJECT_RETVAL}":when="${IOCTL_INJECT_START}+" \
4d44fe
+	../ioctl_evdev-success "${IOCTL_INJECT_START}" "${IOCTL_INJECT_RETVAL}"> "$EXP"
4d44fe
+grep -v '^ioctl([012][,<]' < "$LOG" > "$OUT"
4d44fe
+match_diff "$OUT" "$EXP"
4d44fe
Index: strace-4.24/tests/Makefile.in
4d44fe
===================================================================
4d44fe
--- strace-4.24.orig/tests/Makefile.in	2019-08-01 18:40:47.308659317 +0200
4d44fe
+++ strace-4.24/tests/Makefile.in	2019-08-01 19:16:24.800947844 +0200
4d44fe
@@ -150,7 +150,8 @@
4d44fe
 	filter-unavailable$(EXEEXT) fork-f$(EXEEXT) fsync-y$(EXEEXT) \
4d44fe
 	getpid$(EXEEXT) getppid$(EXEEXT) gettid$(EXEEXT) \
4d44fe
 	inject-nf$(EXEEXT) int_0x80$(EXEEXT) ioctl_dm-v$(EXEEXT) \
4d44fe
-	ioctl_evdev-v$(EXEEXT) ioctl_loop-nv$(EXEEXT) \
4d44fe
+	ioctl_evdev-v$(EXEEXT) ioctl_evdev-success$(EXEEXT) \
4d44fe
+	ioctl_evdev-success-v$(EXEEXT) ioctl_loop-nv$(EXEEXT) \
4d44fe
 	ioctl_loop-v$(EXEEXT) ioctl_nsfs$(EXEEXT) \
4d44fe
 	ioctl_perf-success$(EXEEXT) ioctl_rtc-v$(EXEEXT) \
4d44fe
 	is_linux_mips_n64$(EXEEXT) kill_child$(EXEEXT) \
4d44fe
@@ -974,6 +975,14 @@
4d44fe
 ioctl_evdev_OBJECTS = ioctl_evdev.$(OBJEXT)
4d44fe
 ioctl_evdev_LDADD = $(LDADD)
4d44fe
 ioctl_evdev_DEPENDENCIES = libtests.a
4d44fe
+ioctl_evdev_success_SOURCES = ioctl_evdev-success.c
4d44fe
+ioctl_evdev_success_OBJECTS = ioctl_evdev-success.$(OBJEXT)
4d44fe
+ioctl_evdev_success_LDADD = $(LDADD)
4d44fe
+ioctl_evdev_success_DEPENDENCIES = libtests.a
4d44fe
+ioctl_evdev_success_v_SOURCES = ioctl_evdev-success-v.c
4d44fe
+ioctl_evdev_success_v_OBJECTS = ioctl_evdev-success-v.$(OBJEXT)
4d44fe
+ioctl_evdev_success_v_LDADD = $(LDADD)
4d44fe
+ioctl_evdev_success_v_DEPENDENCIES = libtests.a
4d44fe
 ioctl_evdev_v_SOURCES = ioctl_evdev-v.c
4d44fe
 ioctl_evdev_v_OBJECTS = ioctl_evdev-v.$(OBJEXT)
4d44fe
 ioctl_evdev_v_LDADD = $(LDADD)
4d44fe
@@ -2740,11 +2749,12 @@
4d44fe
 	getuid.c getuid32.c getxxid.c group_req.c inet-cmsg.c \
4d44fe
 	init_module.c inject-nf.c inotify.c inotify_init1.c int_0x80.c \
4d44fe
 	ioctl.c ioctl_block.c ioctl_dm.c ioctl_dm-v.c ioctl_evdev.c \
4d44fe
-	ioctl_evdev-v.c ioctl_inotify.c ioctl_kvm_run.c \
4d44fe
-	ioctl_kvm_run-v.c ioctl_kvm_run_auxstr_vcpu.c ioctl_loop.c \
4d44fe
-	ioctl_loop-nv.c ioctl_loop-v.c ioctl_mtd.c ioctl_nsfs.c \
4d44fe
-	ioctl_perf.c ioctl_perf-success.c ioctl_ptp.c ioctl_rtc.c \
4d44fe
-	ioctl_rtc-v.c ioctl_scsi.c ioctl_sg_io_v3.c ioctl_sg_io_v4.c \
4d44fe
+	ioctl_evdev-success.c ioctl_evdev-success-v.c ioctl_evdev-v.c \
4d44fe
+	ioctl_inotify.c ioctl_kvm_run.c ioctl_kvm_run-v.c \
4d44fe
+	ioctl_kvm_run_auxstr_vcpu.c ioctl_loop.c ioctl_loop-nv.c \
4d44fe
+	ioctl_loop-v.c ioctl_mtd.c ioctl_nsfs.c ioctl_perf.c \
4d44fe
+	ioctl_perf-success.c ioctl_ptp.c ioctl_rtc.c ioctl_rtc-v.c \
4d44fe
+	ioctl_scsi.c ioctl_sg_io_v3.c ioctl_sg_io_v4.c \
4d44fe
 	ioctl_sock_gifconf.c ioctl_uffdio.c ioctl_v4l2.c ioperm.c \
4d44fe
 	iopl.c ioprio.c ip_mreq.c ipc.c ipc_msg.c ipc_msg-Xabbrev.c \
4d44fe
 	ipc_msg-Xraw.c ipc_msg-Xverbose.c ipc_msgbuf.c \
4d44fe
@@ -2887,11 +2897,12 @@
4d44fe
 	getuid.c getuid32.c getxxid.c group_req.c inet-cmsg.c \
4d44fe
 	init_module.c inject-nf.c inotify.c inotify_init1.c int_0x80.c \
4d44fe
 	ioctl.c ioctl_block.c ioctl_dm.c ioctl_dm-v.c ioctl_evdev.c \
4d44fe
-	ioctl_evdev-v.c ioctl_inotify.c ioctl_kvm_run.c \
4d44fe
-	ioctl_kvm_run-v.c ioctl_kvm_run_auxstr_vcpu.c ioctl_loop.c \
4d44fe
-	ioctl_loop-nv.c ioctl_loop-v.c ioctl_mtd.c ioctl_nsfs.c \
4d44fe
-	ioctl_perf.c ioctl_perf-success.c ioctl_ptp.c ioctl_rtc.c \
4d44fe
-	ioctl_rtc-v.c ioctl_scsi.c ioctl_sg_io_v3.c ioctl_sg_io_v4.c \
4d44fe
+	ioctl_evdev-success.c ioctl_evdev-success-v.c ioctl_evdev-v.c \
4d44fe
+	ioctl_inotify.c ioctl_kvm_run.c ioctl_kvm_run-v.c \
4d44fe
+	ioctl_kvm_run_auxstr_vcpu.c ioctl_loop.c ioctl_loop-nv.c \
4d44fe
+	ioctl_loop-v.c ioctl_mtd.c ioctl_nsfs.c ioctl_perf.c \
4d44fe
+	ioctl_perf-success.c ioctl_ptp.c ioctl_rtc.c ioctl_rtc-v.c \
4d44fe
+	ioctl_scsi.c ioctl_sg_io_v3.c ioctl_sg_io_v4.c \
4d44fe
 	ioctl_sock_gifconf.c ioctl_uffdio.c ioctl_v4l2.c ioperm.c \
4d44fe
 	iopl.c ioprio.c ip_mreq.c ipc.c ipc_msg.c ipc_msg-Xabbrev.c \
4d44fe
 	ipc_msg-Xraw.c ipc_msg-Xverbose.c ipc_msgbuf.c \
4d44fe
@@ -4173,6 +4184,8 @@
4d44fe
 	futex.test \
4d44fe
 	getuid.test \
4d44fe
 	ioctl.test \
4d44fe
+	ioctl_evdev-success.test \
4d44fe
+	ioctl_evdev-success-v.test \
4d44fe
 	ioctl_perf-success.test \
4d44fe
 	ipc_msgbuf.test \
4d44fe
 	kern_features-fault.test \
4d44fe
@@ -4998,6 +5011,14 @@
4d44fe
 	@rm -f ioctl_evdev$(EXEEXT)
4d44fe
 	$(AM_V_CCLD)$(LINK) $(ioctl_evdev_OBJECTS) $(ioctl_evdev_LDADD) $(LIBS)
4d44fe
 
4d44fe
+ioctl_evdev-success$(EXEEXT): $(ioctl_evdev_success_OBJECTS) $(ioctl_evdev_success_DEPENDENCIES) $(EXTRA_ioctl_evdev_success_DEPENDENCIES) 
4d44fe
+	@rm -f ioctl_evdev-success$(EXEEXT)
4d44fe
+	$(AM_V_CCLD)$(LINK) $(ioctl_evdev_success_OBJECTS) $(ioctl_evdev_success_LDADD) $(LIBS)
4d44fe
+
4d44fe
+ioctl_evdev-success-v$(EXEEXT): $(ioctl_evdev_success_v_OBJECTS) $(ioctl_evdev_success_v_DEPENDENCIES) $(EXTRA_ioctl_evdev_success_v_DEPENDENCIES) 
4d44fe
+	@rm -f ioctl_evdev-success-v$(EXEEXT)
4d44fe
+	$(AM_V_CCLD)$(LINK) $(ioctl_evdev_success_v_OBJECTS) $(ioctl_evdev_success_v_LDADD) $(LIBS)
4d44fe
+
4d44fe
 ioctl_evdev-v$(EXEEXT): $(ioctl_evdev_v_OBJECTS) $(ioctl_evdev_v_DEPENDENCIES) $(EXTRA_ioctl_evdev_v_DEPENDENCIES) 
4d44fe
 	@rm -f ioctl_evdev-v$(EXEEXT)
4d44fe
 	$(AM_V_CCLD)$(LINK) $(ioctl_evdev_v_OBJECTS) $(ioctl_evdev_v_LDADD) $(LIBS)
4d44fe
@@ -6833,6 +6854,8 @@
4d44fe
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioctl_block.Po@am__quote@
4d44fe
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioctl_dm-v.Po@am__quote@
4d44fe
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioctl_dm.Po@am__quote@
4d44fe
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioctl_evdev-success-v.Po@am__quote@
4d44fe
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioctl_evdev-success.Po@am__quote@
4d44fe
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioctl_evdev-v.Po@am__quote@
4d44fe
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioctl_evdev.Po@am__quote@
4d44fe
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioctl_inotify.Po@am__quote@