glx: add GLXdispatchIndex sort check
authorEric Engestrom <eric.engestrom@imgtec.com>
Tue, 21 Feb 2017 16:49:25 +0000 (16:49 +0000)
committerEric Engestrom <eric.engestrom@imgtec.com>
Fri, 24 Feb 2017 14:44:58 +0000 (14:44 +0000)
Signed-off-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
src/glx/tests/Makefile.am
src/glx/tests/dispatch-index-check [new file with mode: 0755]

index bdc78c0d5aff6dfd81e382d44ef2a61b3403c344..8874c20b010d52a34a218b0d6e1816b36f163676 100644 (file)
@@ -12,7 +12,7 @@ AM_CPPFLAGS = \
        $(LIBDRM_CFLAGS) \
        $(X11_INCLUDES)
 
-TESTS = glx-test
+TESTS = glx-test dispatch-index-check
 check_PROGRAMS = glx-test
 
 glx_test_SOURCES =                     \
diff --git a/src/glx/tests/dispatch-index-check b/src/glx/tests/dispatch-index-check
new file mode 100755 (executable)
index 0000000..78464b8
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# extract enum definition
+dispatch_list=$(sed '/__GLXdispatchIndex/,/__GLXdispatchIndex/!d' \
+  "$srcdir"/../g_glxglvnddispatchindices.h)
+
+# extract values inside of enum
+dispatch_list=$(sed '1d;$d' <<< "$dispatch_list")
+
+# remove indentation
+dispatch_list=$(sed 's/^\s\+//' <<< "$dispatch_list")
+
+# extract function names
+dispatch_list=$(sed 's/DI_//;s/,//' <<< "$dispatch_list")
+
+# same for commented functions, we want to keep them sorted too
+dispatch_list=$(sed 's#// ##;s/ implemented by [a-z]\+//' <<< "$dispatch_list")
+
+# remove LAST_INDEX, as it will not be in alphabetical order
+dispatch_list=$(sed '/LAST_INDEX/d' <<< "$dispatch_list")
+
+sorted=$(LC_ALL=C sort <<< "$dispatch_list")
+
+test "$dispatch_list" = "$sorted"