aboutsummaryrefslogtreecommitdiffstats
path: root/src/glx/tests/dispatch-index-check
blob: d1d0731347beefda2f3a0e2e9d6220479882915a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
set -e

if [ -z "$srcdir" ]
then
  srcdir=$(dirname "$0")
fi

# 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"