tests: allow to expect protocol errors from unknown objects
wl_display_get_protocol_error() takes a pointer to interface as parameter and may set it to NULL when the error comes from an unknown interface. That can happen when the client destroys the wl_proxy before calling this function. So when the wl_display.error event comes, it will refer to an object id that has already been marked as deleted in the client's object map. So the protocol error interface will be set to NULL and its id to 0. In our test suite, expect_protocol_error() ignores such case, and asserts that a interface != NULL is set. This commit fixes that, and now callers are able to call expect_protocol_error() when they expect errors from unknown objects. In the next commit we add the color-management protocol implementation tests, and that requires such case to work. Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This commit is contained in:
parent
39ada71cb3
commit
67c6d39634
|
@ -913,6 +913,23 @@ static const struct wl_registry_listener registry_listener = {
|
||||||
handle_global_remove,
|
handle_global_remove,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expect protocol error
|
||||||
|
*
|
||||||
|
* @param client A client instance, as created by create_client().
|
||||||
|
* @param intf The interface where the error should occur. NULL is also valid,
|
||||||
|
* when the error should come from an unknown object.
|
||||||
|
* @param code The error code that is expected.
|
||||||
|
*
|
||||||
|
* To exercise our protocol implementations, tests can use this function when
|
||||||
|
* they do something on purpose expecting a protocol error.
|
||||||
|
*
|
||||||
|
* When tests know that their wl_proxy would get destroyed before they have a
|
||||||
|
* chance to call this, they should pass a NULL intf to expect the error from an
|
||||||
|
* unknown object. When wl_display.error event comes, it will refer to an object
|
||||||
|
* id that has already been marked as deleted in the client's object map, so
|
||||||
|
* the protocol error interface will be set to NULL and the object id to 0.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
expect_protocol_error(struct client *client,
|
expect_protocol_error(struct client *client,
|
||||||
const struct wl_interface *intf,
|
const struct wl_interface *intf,
|
||||||
|
@ -940,10 +957,15 @@ expect_protocol_error(struct client *client,
|
||||||
failed = 1;
|
failed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this should be definitely set */
|
if (intf && !interface) {
|
||||||
assert(interface);
|
testlog("Should get interface '%s' but got error from unknown object\n",
|
||||||
|
intf->name);
|
||||||
if (strcmp(intf->name, interface->name) != 0) {
|
failed = 1;
|
||||||
|
} else if (!intf && interface) {
|
||||||
|
testlog("Should get error from unknown object but got it from interface '%s'\n",
|
||||||
|
interface->name);
|
||||||
|
failed = 1;
|
||||||
|
} else if (intf && interface && strcmp(intf->name, interface->name) != 0) {
|
||||||
testlog("Should get interface '%s' but got '%s'\n",
|
testlog("Should get interface '%s' but got '%s'\n",
|
||||||
intf->name, interface->name);
|
intf->name, interface->name);
|
||||||
failed = 1;
|
failed = 1;
|
||||||
|
@ -955,8 +977,12 @@ expect_protocol_error(struct client *client,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* all OK */
|
/* all OK */
|
||||||
testlog("Got expected protocol error on '%s' (object id: %d) "
|
if (intf)
|
||||||
"with code %d\n", interface->name, id, errcode);
|
testlog("Got expected protocol error on '%s' (object id: %d) " \
|
||||||
|
"with code %d\n", intf->name, id, errcode);
|
||||||
|
else
|
||||||
|
testlog("Got expected protocol error on unknown object " \
|
||||||
|
"with code %d\n", errcode);
|
||||||
|
|
||||||
client->errored_ok = true;
|
client->errored_ok = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue