aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/test
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-09-27 08:26:50 +0200
committermarha <marha@users.sourceforge.net>2011-09-27 08:26:50 +0200
commit183b7373f9919eeb5eb408f38578e01717b2cc10 (patch)
tree216dcb7e4efb0d67d019a4abe0e58cc6e1fa58b8 /xorg-server/test
parent873965b49f283ad028dd4e0e5b7e93a758c84993 (diff)
downloadvcxsrv-183b7373f9919eeb5eb408f38578e01717b2cc10.tar.gz
vcxsrv-183b7373f9919eeb5eb408f38578e01717b2cc10.tar.bz2
vcxsrv-183b7373f9919eeb5eb408f38578e01717b2cc10.zip
libX11 pixman mesa xserver git update 27 sep 2011
Diffstat (limited to 'xorg-server/test')
-rw-r--r--xorg-server/test/Makefile.am3
-rw-r--r--xorg-server/test/input.c167
-rw-r--r--xorg-server/test/list.c164
-rw-r--r--xorg-server/test/xfree86.c81
4 files changed, 413 insertions, 2 deletions
diff --git a/xorg-server/test/Makefile.am b/xorg-server/test/Makefile.am
index 7ef408c93..689dd7f60 100644
--- a/xorg-server/test/Makefile.am
+++ b/xorg-server/test/Makefile.am
@@ -1,7 +1,7 @@
if ENABLE_UNIT_TESTS
if HAVE_LD_WRAP
SUBDIRS= . xi2
-noinst_PROGRAMS = xkb input xtest list misc fixes
+noinst_PROGRAMS = xkb input xtest list misc fixes xfree86
check_LTLIBRARIES = libxservertest.la
TESTS=$(noinst_PROGRAMS)
@@ -23,6 +23,7 @@ xtest_LDADD=$(TEST_LDADD)
list_LDADD=$(TEST_LDADD)
misc_LDADD=$(TEST_LDADD)
fixes_LDADD=$(TEST_LDADD)
+xfree86_LDADD=$(TEST_LDADD)
nodist_libxservertest_la_SOURCES = $(top_builddir)/hw/xfree86/sdksyms.c
libxservertest_la_LIBADD = \
diff --git a/xorg-server/test/input.c b/xorg-server/test/input.c
index 837ce49dc..b8dad1c60 100644
--- a/xorg-server/test/input.c
+++ b/xorg-server/test/input.c
@@ -1223,7 +1223,7 @@ static void dix_valuator_alloc(void)
assert(v);
assert(v->numAxes == num_axes);
-#ifndef __i386__
+#if !defined(__i386__) && !defined(__sh__)
/* must be double-aligned on 64 bit */
assert(((void*)v->axisVal - (void*)v) % sizeof(double) == 0);
assert(((void*)v->axes - (void*)v) % sizeof(double) == 0);
@@ -1234,6 +1234,169 @@ static void dix_valuator_alloc(void)
free(v);
}
+static void dix_get_master(void)
+{
+ DeviceIntRec vcp, vck;
+ DeviceIntRec ptr, kbd;
+ DeviceIntRec floating;
+ SpriteInfoRec vcp_sprite, vck_sprite;
+ SpriteInfoRec ptr_sprite, kbd_sprite;
+ SpriteInfoRec floating_sprite;
+
+ memset(&vcp, 0, sizeof(DeviceIntRec));
+ memset(&vck, 0, sizeof(DeviceIntRec));
+ memset(&ptr, 0, sizeof(DeviceIntRec));
+ memset(&kbd, 0, sizeof(DeviceIntRec));
+ memset(&floating, 0, sizeof(DeviceIntRec));
+
+ memset(&vcp_sprite, 0, sizeof(DeviceIntRec));
+ memset(&vck_sprite, 0, sizeof(DeviceIntRec));
+ memset(&ptr_sprite, 0, sizeof(DeviceIntRec));
+ memset(&kbd_sprite, 0, sizeof(DeviceIntRec));
+ memset(&floating_sprite, 0, sizeof(DeviceIntRec));
+
+ vcp.type = MASTER_POINTER;
+ vck.type = MASTER_KEYBOARD;
+ ptr.type = SLAVE;
+ kbd.type = SLAVE;
+ floating.type = SLAVE;
+
+ vcp.spriteInfo = &vcp_sprite;
+ vck.spriteInfo = &vck_sprite;
+ ptr.spriteInfo = &ptr_sprite;
+ kbd.spriteInfo = &kbd_sprite;
+ floating.spriteInfo = &floating_sprite;
+
+ vcp_sprite.paired = &vck;
+ vck_sprite.paired = &vcp;
+ ptr_sprite.paired = &vcp;
+ kbd_sprite.paired = &vck;
+ floating_sprite.paired = &floating;
+
+ vcp_sprite.spriteOwner = TRUE;
+ floating_sprite.spriteOwner = TRUE;
+
+ ptr.master = &vcp;
+ kbd.master = &vck;
+
+ assert(GetPairedDevice(&vcp) == &vck);
+ assert(GetPairedDevice(&vck) == &vcp);
+ assert(GetMaster(&ptr, MASTER_POINTER) == &vcp);
+ assert(GetMaster(&ptr, MASTER_KEYBOARD) == &vck);
+ assert(GetMaster(&kbd, MASTER_POINTER) == &vcp);
+ assert(GetMaster(&kbd, MASTER_KEYBOARD) == &vck);
+ assert(GetMaster(&ptr, MASTER_ATTACHED) == &vcp);
+ assert(GetMaster(&kbd, MASTER_ATTACHED) == &vck);
+
+ assert(GetPairedDevice(&floating) == &floating);
+ assert(GetMaster(&floating, MASTER_POINTER) == NULL);
+ assert(GetMaster(&floating, MASTER_KEYBOARD) == NULL);
+ assert(GetMaster(&floating, MASTER_ATTACHED) == NULL);
+
+ assert(GetMaster(&vcp, POINTER_OR_FLOAT) == &vcp);
+ assert(GetMaster(&vck, POINTER_OR_FLOAT) == &vcp);
+ assert(GetMaster(&ptr, POINTER_OR_FLOAT) == &vcp);
+ assert(GetMaster(&kbd, POINTER_OR_FLOAT) == &vcp);
+
+ assert(GetMaster(&vcp, KEYBOARD_OR_FLOAT) == &vck);
+ assert(GetMaster(&vck, KEYBOARD_OR_FLOAT) == &vck);
+ assert(GetMaster(&ptr, KEYBOARD_OR_FLOAT) == &vck);
+ assert(GetMaster(&kbd, KEYBOARD_OR_FLOAT) == &vck);
+
+ assert(GetMaster(&floating, KEYBOARD_OR_FLOAT) == &floating);
+ assert(GetMaster(&floating, POINTER_OR_FLOAT) == &floating);
+}
+
+
+static void input_option_test(void)
+{
+ InputOption *list = NULL;
+ InputOption *opt;
+ const char *val;
+
+ printf("Testing input_option list interface\n");
+
+ list = input_option_new(list, "key", "value");
+ assert(list);
+ opt = input_option_find(list, "key");
+ val = input_option_get_value(opt);
+ assert(strcmp(val, "value") == 0);
+
+ list = input_option_new(list, "2", "v2");
+ opt = input_option_find(list, "key");
+ val = input_option_get_value(opt);
+ assert(strcmp(val, "value") == 0);
+
+ opt = input_option_find(list, "2");
+ val = input_option_get_value(opt);
+ assert(strcmp(val, "v2") == 0);
+
+ list = input_option_new(list, "3", "v3");
+
+ /* search, delete */
+ opt = input_option_find(list, "key");
+ val = input_option_get_value(opt);
+ assert(strcmp(val, "value") == 0);
+ list = input_option_free_element(list, "key");
+ opt = input_option_find(list, "key");
+ assert(opt == NULL);
+
+ opt = input_option_find(list, "2");
+ val = input_option_get_value(opt);
+ assert(strcmp(val, "v2") == 0);
+ list = input_option_free_element(list, "2");
+ opt = input_option_find(list, "2");
+ assert(opt == NULL);
+
+ opt = input_option_find(list, "3");
+ val = input_option_get_value(opt);
+ assert(strcmp(val, "v3") == 0);
+ list = input_option_free_element(list, "3");
+ opt = input_option_find(list, "3");
+ assert(opt == NULL);
+
+ /* list deletion */
+ list = input_option_new(list, "1", "v3");
+ list = input_option_new(list, "2", "v3");
+ list = input_option_new(list, "3", "v3");
+ input_option_free_list(&list);
+
+ assert(list == NULL);
+
+ list = input_option_new(list, "1", "v1");
+ list = input_option_new(list, "2", "v2");
+ list = input_option_new(list, "3", "v3");
+
+ /* value replacement */
+ opt = input_option_find(list, "2");
+ val = input_option_get_value(opt);
+ assert(strcmp(val, "v2") == 0);
+ input_option_set_value(opt, "foo");
+ val = input_option_get_value(opt);
+ assert(strcmp(val, "foo") == 0);
+ opt = input_option_find(list, "2");
+ val = input_option_get_value(opt);
+ assert(strcmp(val, "foo") == 0);
+
+ /* key replacement */
+ input_option_set_key(opt, "bar");
+ val = input_option_get_key(opt);
+ assert(strcmp(val, "bar") == 0);
+ opt = input_option_find(list, "bar");
+ val = input_option_get_value(opt);
+ assert(strcmp(val, "foo") == 0);
+
+ /* value replacement in input_option_new */
+ list = input_option_new(list, "bar", "foobar");
+ opt = input_option_find(list, "bar");
+ val = input_option_get_value(opt);
+ assert(strcmp(val, "foobar") == 0);
+
+ input_option_free_list(&list);
+ assert(list == NULL);
+}
+
+
int main(int argc, char** argv)
{
dix_input_valuator_masks();
@@ -1249,6 +1412,8 @@ int main(int argc, char** argv)
include_bit_test_macros();
xi_unregister_handlers();
dix_valuator_alloc();
+ dix_get_master();
+ input_option_test();
return 0;
}
diff --git a/xorg-server/test/list.c b/xorg-server/test/list.c
index b101c7619..f7d7bffce 100644
--- a/xorg-server/test/list.c
+++ b/xorg-server/test/list.c
@@ -29,6 +29,7 @@
#include <list.h>
#include <string.h>
#include <assert.h>
+#include <stdlib.h>
struct parent {
int a;
@@ -161,6 +162,164 @@ test_list_for_each(void)
}
}
+struct foo {
+ char a;
+ struct foo *next;
+ char b;
+};
+
+static void
+test_nt_list_init(void)
+{
+ struct foo foo;
+
+ foo.a = 10;
+ foo.b = 20;
+ nt_list_init(&foo, next);
+
+ assert(foo.a == 10);
+ assert(foo.b == 20);
+ assert(foo.next == NULL);
+ assert(nt_list_next(&foo, next) == NULL);
+}
+
+static void
+test_nt_list_append(void)
+{
+ int i;
+ struct foo *foo = calloc(10, sizeof(struct foo));
+ struct foo *item;
+
+ for (item = foo, i = 1; i <= 10; i++, item++)
+ {
+ item->a = i;
+ item->b = i * 2;
+ nt_list_init(item, next);
+
+ if (item != foo)
+ nt_list_append(item, foo, struct foo, next);
+ }
+
+ /* Test using nt_list_next */
+ for (item = foo, i = 1; i <= 10; i++, item = nt_list_next(item, next))
+ {
+ assert(item->a = i);
+ assert(item->b = i * 2);
+ }
+
+ /* Test using nt_list_for_each_entry */
+ i = 1;
+ nt_list_for_each_entry(item, foo, next) {
+ assert(item->a = i);
+ assert(item->b = i * 2);
+ i++;
+ }
+ assert(i == 11);
+}
+
+static void
+test_nt_list_insert(void)
+{
+ int i;
+ struct foo *foo = calloc(10, sizeof(struct foo));
+ struct foo *item;
+
+ foo->a = 10;
+ foo->b = 20;
+ nt_list_init(foo, next);
+
+ for (item = &foo[1], i = 9; i > 0; i--, item++)
+ {
+ item->a = i;
+ item->b = i * 2;
+ nt_list_init(item, next);
+ nt_list_insert(item, foo, struct foo, next);
+ }
+
+ /* Test using nt_list_next */
+ for (item = foo, i = 10; i > 0; i--, item = nt_list_next(item, next))
+ {
+ assert(item->a = i);
+ assert(item->b = i * 2);
+ }
+
+ /* Test using nt_list_for_each_entry */
+ i = 1;
+ nt_list_for_each_entry(item, foo, next) {
+ assert(item->a = i);
+ assert(item->b = i * 2);
+ i++;
+ }
+ assert(i == 11);
+}
+
+static void
+test_nt_list_delete(void)
+{
+ int i = 1;
+ struct foo *list = calloc(10, sizeof(struct foo));
+ struct foo *foo = list;
+ struct foo *item, *tmp;
+ struct foo *empty_list = foo;
+
+ nt_list_init(empty_list, next);
+ nt_list_del(empty_list, empty_list, struct foo, next);
+ assert(!empty_list);
+
+ for (item = foo, i = 1; i <= 10; i++, item++)
+ {
+ item->a = i;
+ item->b = i * 2;
+ nt_list_init(item, next);
+
+ if (item != foo)
+ nt_list_append(item, foo, struct foo, next);
+ }
+
+ i = 0;
+ nt_list_for_each_entry(item, foo, next) {
+ i++;
+ }
+ assert(i == 10);
+
+ /* delete last item */
+ nt_list_del(&foo[9], foo, struct foo, next);
+ i = 0;
+ nt_list_for_each_entry(item, foo, next) {
+ assert(item->a != 10); /* element 10 is gone now */
+ i++;
+ }
+ assert(i == 9); /* 9 elements left */
+
+ /* delete second item */
+ nt_list_del(foo->next, foo, struct foo, next);
+ assert(foo->next->a == 3);
+
+ i = 0;
+ nt_list_for_each_entry(item, foo, next) {
+ assert(item->a != 10); /* element 10 is gone now */
+ assert(item->a != 2); /* element 2 is gone now */
+ i++;
+ }
+ assert(i == 8); /* 9 elements left */
+
+ item = foo;
+ /* delete first item */
+ nt_list_del(foo, foo, struct foo, next);
+ assert(item != foo);
+ assert(item->next == NULL);
+ assert(foo->a == 3);
+ assert(foo->next->a == 4);
+
+ nt_list_for_each_entry_safe(item, tmp, foo, next) {
+ nt_list_del(item, foo, struct foo, next);
+ }
+
+ assert(!foo);
+ assert(!item);
+
+ free(list);
+}
int main(int argc, char** argv)
{
@@ -169,5 +328,10 @@ int main(int argc, char** argv)
test_list_del();
test_list_for_each();
+ test_nt_list_init();
+ test_nt_list_append();
+ test_nt_list_insert();
+ test_nt_list_delete();
+
return 0;
}
diff --git a/xorg-server/test/xfree86.c b/xorg-server/test/xfree86.c
new file mode 100644
index 000000000..7012e90c3
--- /dev/null
+++ b/xorg-server/test/xfree86.c
@@ -0,0 +1,81 @@
+/**
+ * Copyright © 2011 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <assert.h>
+
+
+#include "xf86.h"
+
+static void
+xfree86_option_list_duplicate(void)
+{
+ XF86OptionPtr options;
+ XF86OptionPtr duplicate;
+ const char *o1 = "foo",
+ *o2 = "bar",
+ *v1 = "one",
+ *v2 = "two";
+ const char *o_null= "NULL";
+ char *val1, *val2;
+ XF86OptionPtr a, b;
+
+ duplicate = xf86OptionListDuplicate(NULL);
+ assert(!duplicate);
+
+ options = xf86AddNewOption(NULL, o1, v1);
+ assert(options);
+ options = xf86AddNewOption(options, o2, v2);
+ assert(options);
+ options = xf86AddNewOption(options, o_null, NULL);
+ assert(options);
+
+ duplicate = xf86OptionListDuplicate(options);
+ assert(duplicate);
+
+ val1 = xf86CheckStrOption(options, o1, "1");
+ val2 = xf86CheckStrOption(duplicate, o1, "2");
+
+ assert(strcmp(val1, v1) == 0);
+ assert(strcmp(val1, val2) == 0);
+
+ val1 = xf86CheckStrOption(options, o2, "1");
+ val2 = xf86CheckStrOption(duplicate, o2, "2");
+
+ assert(strcmp(val1, v2) == 0);
+ assert(strcmp(val1, val2) == 0);
+
+ a = xf86FindOption(options, o_null);
+ b = xf86FindOption(duplicate, o_null);
+ assert(a && b);
+}
+
+int main(int argc, char** argv)
+{
+ xfree86_option_list_duplicate();
+
+ return 0;
+}