mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 05:54:08 +00:00
test: switch the unit tests to something resembling a test suite
The tests have inadvertent dependencies on each other so let's avoid those by changing to a system that returns a null-terminated list of test functions and our test runner iterates over those and forks off one process per function.
This commit is contained in:
133
test/xtest.c
133
test/xtest.c
@@ -60,57 +60,12 @@ device_cursor_cleanup(DeviceIntPtr dev, ScreenPtr screen)
|
||||
}
|
||||
|
||||
static void
|
||||
xtest_init_devices(void)
|
||||
xtest_init(void)
|
||||
{
|
||||
assert(xtestpointer);
|
||||
assert(xtestkeyboard);
|
||||
assert(IsXTestDevice(xtestpointer, NULL));
|
||||
assert(IsXTestDevice(xtestkeyboard, NULL));
|
||||
assert(IsXTestDevice(xtestpointer, inputInfo.pointer));
|
||||
|
||||
assert(IsXTestDevice(xtestkeyboard, inputInfo.keyboard));
|
||||
assert(GetXTestDevice(inputInfo.pointer) == xtestpointer);
|
||||
|
||||
assert(GetXTestDevice(inputInfo.keyboard) == xtestkeyboard);
|
||||
}
|
||||
|
||||
/**
|
||||
* Each xtest devices has a property attached marking it. This property
|
||||
* cannot be changed.
|
||||
*/
|
||||
static void
|
||||
xtest_properties(void)
|
||||
{
|
||||
int rc;
|
||||
char value = 1;
|
||||
XIPropertyValuePtr prop;
|
||||
Atom xtest_prop = XIGetKnownProperty(XI_PROP_XTEST_DEVICE);
|
||||
|
||||
rc = XIGetDeviceProperty(xtestpointer, xtest_prop, &prop);
|
||||
assert(rc == Success);
|
||||
assert(prop);
|
||||
|
||||
rc = XIGetDeviceProperty(xtestkeyboard, xtest_prop, &prop);
|
||||
assert(rc == Success);
|
||||
assert(prop != NULL);
|
||||
|
||||
rc = XIChangeDeviceProperty(xtestpointer, xtest_prop,
|
||||
XA_INTEGER, 8, PropModeReplace, 1, &value,
|
||||
FALSE);
|
||||
assert(rc == BadAccess);
|
||||
rc = XIChangeDeviceProperty(xtestkeyboard, xtest_prop,
|
||||
XA_INTEGER, 8, PropModeReplace, 1, &value,
|
||||
FALSE);
|
||||
assert(rc == BadAccess);
|
||||
}
|
||||
|
||||
int
|
||||
xtest_test(void)
|
||||
{
|
||||
ScreenRec screen = {0};
|
||||
ClientRec server_client = {0};
|
||||
WindowRec root = {{0}};
|
||||
WindowOptRec optional = {0};
|
||||
static ScreenRec screen = {0};
|
||||
static ClientRec server_client = {0};
|
||||
static WindowRec root = {{0}};
|
||||
static WindowOptRec optional = {0};
|
||||
|
||||
/* random stuff that needs initialization */
|
||||
root.drawable.id = 0xab;
|
||||
@@ -134,11 +89,75 @@ xtest_test(void)
|
||||
|
||||
/* this also inits the xtest devices */
|
||||
InitCoreDevices();
|
||||
|
||||
xtest_init_devices();
|
||||
xtest_properties();
|
||||
|
||||
CloseDownDevices();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
xtest_cleanup(void)
|
||||
{
|
||||
CloseDownDevices();
|
||||
}
|
||||
|
||||
static void
|
||||
xtest_init_devices(void)
|
||||
{
|
||||
xtest_init();
|
||||
|
||||
assert(xtestpointer);
|
||||
assert(xtestkeyboard);
|
||||
assert(IsXTestDevice(xtestpointer, NULL));
|
||||
assert(IsXTestDevice(xtestkeyboard, NULL));
|
||||
assert(IsXTestDevice(xtestpointer, inputInfo.pointer));
|
||||
|
||||
assert(IsXTestDevice(xtestkeyboard, inputInfo.keyboard));
|
||||
assert(GetXTestDevice(inputInfo.pointer) == xtestpointer);
|
||||
|
||||
assert(GetXTestDevice(inputInfo.keyboard) == xtestkeyboard);
|
||||
|
||||
xtest_cleanup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Each xtest devices has a property attached marking it. This property
|
||||
* cannot be changed.
|
||||
*/
|
||||
static void
|
||||
xtest_properties(void)
|
||||
{
|
||||
int rc;
|
||||
char value = 1;
|
||||
XIPropertyValuePtr prop;
|
||||
Atom xtest_prop;
|
||||
|
||||
xtest_init();
|
||||
|
||||
xtest_prop = XIGetKnownProperty(XI_PROP_XTEST_DEVICE);
|
||||
rc = XIGetDeviceProperty(xtestpointer, xtest_prop, &prop);
|
||||
assert(rc == Success);
|
||||
assert(prop);
|
||||
|
||||
rc = XIGetDeviceProperty(xtestkeyboard, xtest_prop, &prop);
|
||||
assert(rc == Success);
|
||||
assert(prop != NULL);
|
||||
|
||||
rc = XIChangeDeviceProperty(xtestpointer, xtest_prop,
|
||||
XA_INTEGER, 8, PropModeReplace, 1, &value,
|
||||
FALSE);
|
||||
assert(rc == BadAccess);
|
||||
rc = XIChangeDeviceProperty(xtestkeyboard, xtest_prop,
|
||||
XA_INTEGER, 8, PropModeReplace, 1, &value,
|
||||
FALSE);
|
||||
assert(rc == BadAccess);
|
||||
|
||||
xtest_cleanup();
|
||||
}
|
||||
|
||||
const testfunc_t*
|
||||
xtest_test(void)
|
||||
{
|
||||
static const testfunc_t testfuncs[] = {
|
||||
xtest_init_devices,
|
||||
xtest_properties,
|
||||
NULL,
|
||||
};
|
||||
return testfuncs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user