diff --git a/configure.ac b/configure.ac
index 87b52175f9a2db41d6d86d60020fee83b0946052..3fc7f9ce0479eef0ca35a12a65042e522f7fa19d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -138,7 +138,7 @@ fi
 
 # --enable-unit-tests
 XORG_ENABLE_UNIT_TESTS
-XORG_WITH_GLIB([2.16])
+XORG_WITH_GLIB([2.40])
 XORG_MEMORY_CHECK_FLAGS
 
 # Replaces XFileSearchPathDefault from Imake configs
diff --git a/test/Alloc.c b/test/Alloc.c
index 88eca686ae245758554e2fc8641500a390595e7e..591a003da0d3e6700afe8deb4c5a855e799739cf 100644
--- a/test/Alloc.c
+++ b/test/Alloc.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2022, Oracle and/or its affiliates.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -75,10 +75,10 @@ static void test_XtAsprintf_short(void)
     snlen = snprintf(snbuf, sizeof(snbuf), "%s: %d\n", program_name, r);
     aslen = XtAsprintf(&asbuf, "%s: %d\n", program_name, r);
 
-    g_assert(asbuf != NULL);
-    g_assert(snlen == aslen);
-    g_assert(strcmp(snbuf, asbuf) == 0);
-    g_assert(asbuf[aslen] == '\0');
+    g_assert_nonnull(asbuf);
+    g_assert_cmpint(snlen, ==, aslen);
+    g_assert_cmpstr(snbuf, ==, asbuf);
+    g_assert_cmpint(asbuf[aslen], ==, '\0');
 }
 
 /* Test a string long enough to be past the 256 character limit that
@@ -92,10 +92,10 @@ static void test_XtAsprintf_long(void)
 
     aslen = XtAsprintf(&asbuf, "%.*s", r2, test_chars + r1);
 
-    g_assert(asbuf != NULL);
-    g_assert(aslen == r2);
-    g_assert(strncmp(asbuf, test_chars + r1, r2) == 0);
-    g_assert(asbuf[aslen] == '\0');
+    g_assert_nonnull(asbuf);
+    g_assert_cmpint(aslen, ==, r2);
+    g_assert_cmpint(strncmp(asbuf, test_chars + r1, r2), ==, 0);
+    g_assert_cmpint(asbuf[aslen], ==, '\0');
 }
 
 int main(int argc, char** argv)
diff --git a/test/Converters.c b/test/Converters.c
index ef3c37c9e8a87d7f8006c83f23b3c8a3aa3bbdef..72024290f37455e561d03ce51f31a686dde9c243 100644
--- a/test/Converters.c
+++ b/test/Converters.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2022, Oracle and/or its affiliates.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -54,7 +54,8 @@ static void test_XtCvtIntToPixmap(void)
     status = XtCvtIntToPixmap(display, &args[0], &num_args,
 			      &fromVal, &toVal, closure_ret);
 
-    g_assert(res == num[0]);
+    g_assert_cmpint(status, ==, True);
+    g_assert_cmpint(res, ==, num[0]);
 
 
     num[0] = -1;
@@ -69,7 +70,8 @@ static void test_XtCvtIntToPixmap(void)
     status = XtCvtIntToPixmap(display, &args[0], &num_args,
 			      &fromVal, &toVal, closure_ret);
 
-    g_assert(res == num[1]);
+    g_assert_cmpint(status, ==, True);
+    g_assert_cmpint(res, ==, num[1]);
 }
 
 int main(int argc, char** argv)
diff --git a/test/Event.c b/test/Event.c
index a2f99f953d4de09f784877be05a57b5b68353b6c..2eba8d16376203367f304419cd7d08e39df96642 100644
--- a/test/Event.c
+++ b/test/Event.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2022, Oracle and/or its affiliates.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -75,11 +75,12 @@ static void test_XtAppMainLoop_34715(void)
 	alarm(10);
 
 	XtAppMainLoop(app);
+	alarm(0); /* cancel alarm */
     } else {
-	g_assert(XtAppGetExitFlag(app) == TRUE);
-	g_assert(0 /* timed out */);
+	g_assertion_message(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC,
+			    "test timed out");
     }
-    g_assert(XtAppGetExitFlag(app) == TRUE);
+    g_assert_cmpint(XtAppGetExitFlag(app), ==, TRUE);
     XtDestroyApplicationContext(app);
 }