6aa3dd6c77c4e47fb2a88650827c286779700fc4
[platform/upstream/libxkbcommon.git] / test / xkey.sh
1 #!/bin/sh
2
3 srcdir=${srcdir-.}
4 builddir=${builddir-.}
5
6 log="$builddir/xkey.log"
7
8 check_error()
9 {
10     if [ "$2" != "$3" ]; then
11         echo "error checking $1" >&2
12         echo "  expected: $2" >&2
13         echo "  received: $3" >&2
14         return 1
15     fi
16 }
17
18 check_string()
19 {
20     echo "${builddir}/xkey -s '$1'" >>"$log"
21     val=`${builddir}/xkey -s "$1"` &&
22         echo "$val" >>"$log" &&
23         check_error "$1" "$2" "$val" >>"$log" 2>&1 ||
24         exit $?
25 }
26
27 check_key()
28 {
29     echo "${builddir}/xkey -k '$1'" >>"$log"
30     val=`${builddir}/xkey -k "$1"` && \
31         echo "$val" >>"$log" &&
32         check_error "$1" "$2" "$val" >>"$log" 2>&1 || \
33         exit $?
34 }
35
36 rm -f "$log"
37
38 check_string Undo 0xFF65
39 check_key 0x1008FF56 XF86Close
40 check_string ThisKeyShouldNotExist NoSymbol
41 check_key 0x0 NULL
42 check_string XF86_Switch_VT_5 0x1008FE05
43 check_key 0x1008FE20 XF86_Ungrab