diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2023-06-29 09:22:49 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2023-07-06 09:11:50 +1000 |
commit | 34509105db85dc3e0fca22076fded8607485529b (patch) | |
tree | 46104b401bce6cc01de55a791d960b86c2cdb206 /tests/verify-group-names.sh | |
parent | 6cf6c953f3054f986ec903ecd64eda8030d22296 (diff) |
tests: rename genLists4Comparison to verify-group-names.sh
Because that way it's easier to guess what it does.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tests/verify-group-names.sh')
-rwxr-xr-x | tests/verify-group-names.sh | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/verify-group-names.sh b/tests/verify-group-names.sh new file mode 100755 index 00000000..4969adb4 --- /dev/null +++ b/tests/verify-group-names.sh @@ -0,0 +1,86 @@ +#!/bin/sh + +# This script compares the group names that are mentioned in base*.xml with the ones +# that actually exist in the symbol files. Some differences are okay -- like extra +# quotes or an extra escaping character -- but apart from that they should match. + +set -e + +pwd="$PWD" +tmpdir=$(mktemp -d xkeyboard-config.XXXX) +scriptdir=$(dirname "$0") +ROOT=$(realpath "$scriptdir/..") + +cd "$tmpdir" || exit 1 + +# temporary files +registry_names=reg_names.lst +group_names=grp_names.lst +registry_names_base=${registry_names}.base +registry_names_extras=${registry_names}.extras + +xsltproc "$ROOT"/tests/reg2ll.xsl "$ROOT"/rules/base.xml > $registry_names_base +xsltproc "$ROOT"/tests/reg2ll.xsl "$ROOT"/rules/base.extras.xml | grep -v sun_type > $registry_names_extras + +cat $registry_names_base $registry_names_extras | \ + sort | \ + uniq | \ + grep -v -e '^$' \ + -e '^custom:' > $registry_names + +for sym in "$ROOT"/symbols/*; do + if [ -f "$sym" ]; then + id="$(basename "$sym")" + export id + gawk 'BEGIN{ + FS = "\""; + id = ENVIRON["id"]; + isDefault = 0; + isHwSpecificDefault = 0; + isUnregistered = 0; +} +/#HW-SPECIFIC/{ + isHwSpecificDefault = 1; +} +/#UNREGISTERED/{ + isUnregistered = 1; +} +/^[[:space:]]*\/\//{ + next +} +/.*default.*/{ + isDefault = 1; +} +/xkb_symbols/{ + variant = $2; +}/^[[:space:]]*name\[[Gg]roup1\][[:space:]]*=/{ + if (isUnregistered == 1) { + isUnregistered = 0; + } else if (isDefault == 1) + { + printf "%s:\"%s\"\n",id,$2; + isDefault=0; + } else + { + name=$2; + if (isHwSpecificDefault == 1) { + isHwSpecificDefault = 0; + printf "%s:\"%s\"\n", id, name; + } else { + printf "%s(%s):\"%s\"\n", id, variant, name; + } + } +}' "$sym" + fi +done | sort | uniq > $group_names + +diff -u $registry_names $group_names +rc=$? + +if [ $rc != 0 ] ; then + echo "Legend: '-' is for rules/base*.xml, '+' is for symbols/*" +fi + +cd "$pwd" || exit 1 + +exit $rc |