[PATCH xserver 5.5/7] test: Extend sync tests to cover alarm delta and waitvalue changes.
Eric Anholt
eric at anholt.net
Wed Aug 23 17:06:14 UTC 2017
This would be squashed into the other tests.
Signed-off-by: Eric Anholt <eric at anholt.net>
---
test/sync/sync.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 69 insertions(+), 2 deletions(-)
diff --git a/test/sync/sync.c b/test/sync/sync.c
index c39774246841..f25d3fa3774a 100644
--- a/test/sync/sync.c
+++ b/test/sync/sync.c
@@ -38,13 +38,18 @@ static const int64_t some_values[] = {
};
static int64_t
+pack_sync_value(xcb_sync_int64_t val)
+{
+ return ((int64_t)val.hi << 32) | val.lo;
+}
+
+static int64_t
counter_value(struct xcb_connection_t *c,
xcb_sync_query_counter_cookie_t cookie)
{
xcb_sync_query_counter_reply_t *reply =
xcb_sync_query_counter_reply(c, cookie, NULL);
- int64_t value = (((int64_t)reply->counter_value.hi << 32) |
- reply->counter_value.lo);
+ int64_t value = pack_sync_value(reply->counter_value);
free(reply);
return value;
@@ -216,6 +221,66 @@ test_change_counter_overflow(xcb_connection_t *c)
}
}
+static void
+test_change_alarm_value(xcb_connection_t *c)
+{
+ xcb_sync_alarm_t alarm = xcb_generate_id(c);
+ xcb_sync_query_alarm_cookie_t queries[ARRAY_SIZE(some_values)];
+
+ xcb_sync_create_alarm(c, alarm, 0, NULL);
+
+ for (int i = 0; i < ARRAY_SIZE(some_values); i++) {
+ uint32_t values[] = { some_values[i] >> 32, some_values[i] };
+
+ xcb_sync_change_alarm(c, alarm, XCB_SYNC_CA_VALUE, values);
+ queries[i] = xcb_sync_query_alarm_unchecked(c, alarm);
+ }
+
+ for (int i = 0; i < ARRAY_SIZE(some_values); i++) {
+ xcb_sync_query_alarm_reply_t *reply =
+ xcb_sync_query_alarm_reply(c, queries[i], NULL);
+ int64_t value = pack_sync_value(reply->trigger.wait_value);
+
+ if (value != some_values[i]) {
+ fprintf(stderr, "Setting alarm value to %lld returned %lld\n",
+ (long long)some_values[i],
+ (long long)value);
+ exit(1);
+ }
+ free(reply);
+ }
+}
+
+static void
+test_change_alarm_delta(xcb_connection_t *c)
+{
+ xcb_sync_alarm_t alarm = xcb_generate_id(c);
+ xcb_sync_query_alarm_cookie_t queries[ARRAY_SIZE(some_values)];
+
+ xcb_sync_create_alarm(c, alarm, 0, NULL);
+
+ for (int i = 0; i < ARRAY_SIZE(some_values); i++) {
+ uint32_t values[] = { some_values[i] >> 32, some_values[i] };
+
+ xcb_sync_change_alarm(c, alarm, XCB_SYNC_CA_DELTA, values);
+ queries[i] = xcb_sync_query_alarm_unchecked(c, alarm);
+ }
+
+ for (int i = 0; i < ARRAY_SIZE(some_values); i++) {
+ xcb_sync_query_alarm_reply_t *reply =
+ xcb_sync_query_alarm_reply(c, queries[i], NULL);
+ int64_t value = pack_sync_value(reply->delta);
+
+ if (value != some_values[i]) {
+ fprintf(stderr, "Setting alarm delta to %lld returned %lld\n",
+ (long long)some_values[i],
+ (long long)value);
+ exit(1);
+ }
+ free(reply);
+ }
+}
+
int main(int argc, char **argv)
{
int screen;
@@ -231,6 +296,8 @@ int main(int argc, char **argv)
test_set_counter(c);
test_change_counter_basic(c);
test_change_counter_overflow(c);
+ test_change_alarm_value(c);
+ test_change_alarm_delta(c);
xcb_disconnect(c);
exit(0);
--
2.13.3
More information about the xorg-devel
mailing list