|
|
0fd959 |
From 2bc68568ee6d8b75da07d98818142af081f0b132 Mon Sep 17 00:00:00 2001
|
|
|
0fd959 |
From: Alan Coopersmith <alan.coopersmith@oracle.com>
|
|
|
0fd959 |
Date: Sun, 9 Feb 2014 21:27:27 -0800
|
|
|
0fd959 |
Subject: [PATCH 17/33] Add request length checking test cases for some Xinput
|
|
|
0fd959 |
1.x requests
|
|
|
0fd959 |
|
|
|
0fd959 |
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
|
|
|
0fd959 |
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
|
|
|
0fd959 |
Signed-off-by: Fedora X Ninjas <x@fedoraproject.org>
|
|
|
0fd959 |
---
|
|
|
0fd959 |
configure.ac | 1 +
|
|
|
0fd959 |
test/Makefile.am | 2 +-
|
|
|
0fd959 |
test/xi1/Makefile.am | 34 +++++++++
|
|
|
0fd959 |
test/xi1/protocol-xchangedevicecontrol.c | 122 +++++++++++++++++++++++++++++++
|
|
|
0fd959 |
4 files changed, 158 insertions(+), 1 deletion(-)
|
|
|
0fd959 |
create mode 100644 test/xi1/Makefile.am
|
|
|
0fd959 |
create mode 100644 test/xi1/protocol-xchangedevicecontrol.c
|
|
|
0fd959 |
|
|
|
0fd959 |
diff --git a/configure.ac b/configure.ac
|
|
|
0fd959 |
index 2202a56..e1f0fe4 100644
|
|
|
0fd959 |
--- a/configure.ac
|
|
|
0fd959 |
+++ b/configure.ac
|
|
|
0fd959 |
@@ -2538,6 +2538,7 @@ hw/kdrive/fbdev/Makefile
|
|
|
0fd959 |
hw/kdrive/linux/Makefile
|
|
|
0fd959 |
hw/kdrive/src/Makefile
|
|
|
0fd959 |
test/Makefile
|
|
|
0fd959 |
+test/xi1/Makefile
|
|
|
0fd959 |
test/xi2/Makefile
|
|
|
0fd959 |
xserver.ent
|
|
|
0fd959 |
xorg-server.pc
|
|
|
0fd959 |
diff --git a/test/Makefile.am b/test/Makefile.am
|
|
|
0fd959 |
index 2852bb3..cd739e2 100644
|
|
|
0fd959 |
--- a/test/Makefile.am
|
|
|
0fd959 |
+++ b/test/Makefile.am
|
|
|
0fd959 |
@@ -4,7 +4,7 @@ noinst_PROGRAMS = list string
|
|
|
0fd959 |
if XORG
|
|
|
0fd959 |
# Tests that require at least some DDX functions in order to fully link
|
|
|
0fd959 |
# For now, requires xf86 ddx, could be adjusted to use another
|
|
|
0fd959 |
-SUBDIRS += xi2
|
|
|
0fd959 |
+SUBDIRS += xi1 xi2
|
|
|
0fd959 |
noinst_PROGRAMS += xkb input xtest misc fixes xfree86 hashtabletest os signal-logging touch
|
|
|
0fd959 |
endif
|
|
|
0fd959 |
check_LTLIBRARIES = libxservertest.la
|
|
|
0fd959 |
diff --git a/test/xi1/Makefile.am b/test/xi1/Makefile.am
|
|
|
0fd959 |
new file mode 100644
|
|
|
0fd959 |
index 0000000..907fa7a
|
|
|
0fd959 |
--- /dev/null
|
|
|
0fd959 |
+++ b/test/xi1/Makefile.am
|
|
|
0fd959 |
@@ -0,0 +1,34 @@
|
|
|
0fd959 |
+if ENABLE_UNIT_TESTS
|
|
|
0fd959 |
+if HAVE_LD_WRAP
|
|
|
0fd959 |
+noinst_PROGRAMS = \
|
|
|
0fd959 |
+ protocol-xchangedevicecontrol
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+TESTS=$(noinst_PROGRAMS)
|
|
|
0fd959 |
+TESTS_ENVIRONMENT = $(XORG_MALLOC_DEBUG_ENV)
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
|
|
|
0fd959 |
+AM_CPPFLAGS = @XORG_INCS@ -I$(srcdir)/../xi2
|
|
|
0fd959 |
+TEST_LDADD=../libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLX_SYS_LIBS)
|
|
|
0fd959 |
+COMMON_SOURCES=$(srcdir)/../xi2/protocol-common.c
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+if SPECIAL_DTRACE_OBJECTS
|
|
|
0fd959 |
+TEST_LDADD += $(OS_LIB) $(DIX_LIB)
|
|
|
0fd959 |
+endif
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+protocol_xchangedevicecontrol_LDADD=$(TEST_LDADD)
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+protocol_xchangedevicecontrol_LDFLAGS=$(AM_LDFLAGS) -Wl,-wrap,WriteToClient
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+protocol_xchangedevicecontrol_SOURCES=$(COMMON_SOURCES) protocol-xchangedevicecontrol.c
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+else
|
|
|
0fd959 |
+# Print that xi1-tests were skipped (exit code 77 for automake test harness)
|
|
|
0fd959 |
+TESTS = xi1-tests
|
|
|
0fd959 |
+CLEANFILES = $(TESTS)
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+xi1-tests:
|
|
|
0fd959 |
+ @echo 'echo "ld -wrap support required for xi1 unit tests, skipping"' > $@
|
|
|
0fd959 |
+ @echo 'exit 77' >> $@
|
|
|
0fd959 |
+ $(AM_V_GEN)chmod +x $@
|
|
|
0fd959 |
+endif
|
|
|
0fd959 |
+endif
|
|
|
0fd959 |
diff --git a/test/xi1/protocol-xchangedevicecontrol.c b/test/xi1/protocol-xchangedevicecontrol.c
|
|
|
0fd959 |
new file mode 100644
|
|
|
0fd959 |
index 0000000..8e638b2
|
|
|
0fd959 |
--- /dev/null
|
|
|
0fd959 |
+++ b/test/xi1/protocol-xchangedevicecontrol.c
|
|
|
0fd959 |
@@ -0,0 +1,122 @@
|
|
|
0fd959 |
+/**
|
|
|
0fd959 |
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
|
|
0fd959 |
+ *
|
|
|
0fd959 |
+ * Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
0fd959 |
+ * copy of this software and associated documentation files (the "Software"),
|
|
|
0fd959 |
+ * to deal in the Software without restriction, including without limitation
|
|
|
0fd959 |
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
0fd959 |
+ * and/or sell copies of the Software, and to permit persons to whom the
|
|
|
0fd959 |
+ * Software is furnished to do so, subject to the following conditions:
|
|
|
0fd959 |
+ *
|
|
|
0fd959 |
+ * The above copyright notice and this permission notice (including the next
|
|
|
0fd959 |
+ * paragraph) shall be included in all copies or substantial portions of the
|
|
|
0fd959 |
+ * Software.
|
|
|
0fd959 |
+ *
|
|
|
0fd959 |
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
0fd959 |
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
0fd959 |
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
0fd959 |
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
0fd959 |
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
0fd959 |
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
0fd959 |
+ * DEALINGS IN THE SOFTWARE.
|
|
|
0fd959 |
+ */
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+#ifdef HAVE_DIX_CONFIG_H
|
|
|
0fd959 |
+#include <dix-config.h>
|
|
|
0fd959 |
+#endif
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+/*
|
|
|
0fd959 |
+ * Protocol testing for ChangeDeviceControl request.
|
|
|
0fd959 |
+ */
|
|
|
0fd959 |
+#include <stdint.h>
|
|
|
0fd959 |
+#include <X11/X.h>
|
|
|
0fd959 |
+#include <X11/Xproto.h>
|
|
|
0fd959 |
+#include <X11/extensions/XIproto.h>
|
|
|
0fd959 |
+#include "inputstr.h"
|
|
|
0fd959 |
+#include "chgdctl.h"
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+#include "protocol-common.h"
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+static ClientRec client_request;
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+static void
|
|
|
0fd959 |
+reply_ChangeDeviceControl(ClientPtr client, int len, char *data, void *userdata)
|
|
|
0fd959 |
+{
|
|
|
0fd959 |
+ xChangeDeviceControlReply *rep = (xChangeDeviceControlReply *) data;
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+ if (client->swapped) {
|
|
|
0fd959 |
+ swapl(&rep->length);
|
|
|
0fd959 |
+ swaps(&rep->sequenceNumber);
|
|
|
0fd959 |
+ }
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+ reply_check_defaults(rep, len, ChangeDeviceControl);
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+ /* XXX: check status code in reply */
|
|
|
0fd959 |
+}
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+static void
|
|
|
0fd959 |
+request_ChangeDeviceControl(ClientPtr client, xChangeDeviceControlReq * req,
|
|
|
0fd959 |
+ xDeviceCtl *ctl, int error)
|
|
|
0fd959 |
+{
|
|
|
0fd959 |
+ int rc;
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+ client_request.req_len = req->length;
|
|
|
0fd959 |
+ rc = ProcXChangeDeviceControl(&client_request);
|
|
|
0fd959 |
+ assert(rc == error);
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+ /* XXX: ChangeDeviceControl doesn't seem to fill in errorValue to check */
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+ client_request.swapped = TRUE;
|
|
|
0fd959 |
+ swaps(&req->length);
|
|
|
0fd959 |
+ swaps(&req->control);
|
|
|
0fd959 |
+ swaps(&ctl->length);
|
|
|
0fd959 |
+ swaps(&ctl->control);
|
|
|
0fd959 |
+ /* XXX: swap other contents of ctl, depending on type */
|
|
|
0fd959 |
+ rc = SProcXChangeDeviceControl(&client_request);
|
|
|
0fd959 |
+ assert(rc == error);
|
|
|
0fd959 |
+}
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+static unsigned char *data[4096]; /* the request buffer */
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+static void
|
|
|
0fd959 |
+test_ChangeDeviceControl(void)
|
|
|
0fd959 |
+{
|
|
|
0fd959 |
+ xChangeDeviceControlReq *request = (xChangeDeviceControlReq *) data;
|
|
|
0fd959 |
+ xDeviceCtl *control = (xDeviceCtl *) (&request[1]);
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+ request_init(request, ChangeDeviceControl);
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+ reply_handler = reply_ChangeDeviceControl;
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+ client_request = init_client(request->length, request);
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+ printf("Testing invalid lengths:\n");
|
|
|
0fd959 |
+ printf(" -- no control struct\n");
|
|
|
0fd959 |
+ request_ChangeDeviceControl(&client_request, request, control, BadLength);
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+ printf(" -- xDeviceResolutionCtl\n");
|
|
|
0fd959 |
+ request_init(request, ChangeDeviceControl);
|
|
|
0fd959 |
+ request->control = DEVICE_RESOLUTION;
|
|
|
0fd959 |
+ control->length = (sizeof(xDeviceResolutionCtl) >> 2);
|
|
|
0fd959 |
+ request->length += control->length - 2;
|
|
|
0fd959 |
+ request_ChangeDeviceControl(&client_request, request, control, BadLength);
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+ printf(" -- xDeviceEnableCtl\n");
|
|
|
0fd959 |
+ request_init(request, ChangeDeviceControl);
|
|
|
0fd959 |
+ request->control = DEVICE_ENABLE;
|
|
|
0fd959 |
+ control->length = (sizeof(xDeviceEnableCtl) >> 2);
|
|
|
0fd959 |
+ request->length += control->length - 2;
|
|
|
0fd959 |
+ request_ChangeDeviceControl(&client_request, request, control, BadLength);
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+ /* XXX: Test functionality! */
|
|
|
0fd959 |
+}
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+int
|
|
|
0fd959 |
+main(int argc, char **argv)
|
|
|
0fd959 |
+{
|
|
|
0fd959 |
+ init_simple();
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+ test_ChangeDeviceControl();
|
|
|
0fd959 |
+
|
|
|
0fd959 |
+ return 0;
|
|
|
0fd959 |
+}
|
|
|
0fd959 |
--
|
|
|
0fd959 |
1.9.3
|
|
|
0fd959 |
|