1#/bin/sh
2#
3#
4# This file is generated from new_script.sh
5# and updated by hand by hesa
6#
7# Filename:   options/print-event-name.sh
8# Generated:  Sun Mar 16 21:57:36 CET 2003
9#
10# Description:
11#
12#  Test the Xnee option
13#       --print-event-name
14#  By reading up X11 events (name and number) from
15#  the header file X.h. These values are compared
16#  with the output from Xnee
17#
18#
19
20
21
22
23
24# name of myself
25MYNAME=print-event-name.sh
26
27# Arguments to test (short and long)
28export LONG_ARG=--print-event-name
29export SHORT_ARG=-pen
30
31# source useful funs
32if [ ! -f etc/base_funs ];
33then
34    echo "Can't find the file: base_funs"
35    echo "Start me up in the xnee test dir "
36    exit
37else
38    . etc/base_funs
39fi
40
41init_test
42parse_me "$*"
43
44#######################################################################
45
46
47X11_NAMES=/tmp/xnee_events.tmp
48
49
50
51
52
53#
54# main .... sort of
55#
56
57# get the event numbers and names from the devel header file
58find_events  /usr/include/X11/X.h $X11_NAMES
59LAST_EVENT=`grep LASTEvent /usr/include/X11/X.h | awk '{ print $3}' | sed 's,[ ]*,,g' `
60
61
62
63
64
65
66
67#
68# positive tests
69#
70# compare Xnee number and names with the system
71for i in `cat $X11_NAMES`
72do
73  EV_=`echo $i | sed 's,\([0-9]*\)=.*,\1,g'`
74  NAME_=`echo $i | sed 's,[0-9]*=\([a-zA-Z0-9]*\),\1,g'`
75
76  XNEE_EV=`run_cnee $LONG_ARG $NAME_`
77  STATUS=$?
78  check_retval $STATUS 0
79
80  XNEE_EV_NAME=`run_cnee $LONG_ARG $EV_`
81  STATUS=$?
82  check_retval $STATUS 0
83  compare_data $EV_ $NAME_  $XNEE_EV $XNEE_EV_NAME
84done
85
86
87
88
89
90
91
92# compare Xnee number and names with the system
93for i in `cat $X11_NAMES`
94do
95  EV_=`echo $i | sed 's,\([0-9]*\)=.*,\1,g'`
96  NAME_=`echo $i | sed 's,[0-9]*=\([a-zA-Z0-9]*\),\1,g'`
97
98  XNEE_EV=`run_cnee $SHORT_ARG $NAME_`
99  STATUS=$?
100  check_retval $STATUS 0
101
102  XNEE_EV_NAME=`run_cnee $SHORT_ARG $EV_`
103  STATUS=$?
104  check_retval $STATUS 0
105
106  compare_data $EV_ $NAME_  $XNEE_EV $XNEE_EV_NAME
107done
108
109
110
111# loop through all events and run them in a Xnee renaming pipe
112# Make sure that 2 == 2
113# after this has been done:  2 --xnee--> KeyPress --xnee--> 2
114# loop from 2 to LASTEvent
115
116TMP=2
117while [ "$TMP" != "$LAST_EVENT" ];
118do
119  TOTAL_TEST=`expr $TOTAL_TEST + 1`
120  REC=`run_cnee $LONG_ARG  $TMP | xargs run_cnee $SHORT_ARG  `
121  STATUS=$?
122  check_retval $STATUS 0
123  if [ "$REC" != "$TMP" ];
124      then
125      log " unexpected result: using  \"run_cnee $LONG_ARG  $TMP | run_cnee $SHORT_ARG $TMP\""
126      log " got: $REC ..... wanted: $TMP"
127      ERR_TEST=`expr $ERR_TEST + 1`
128  else
129    SUCC_TEST=`expr $SUCC_TEST + 1`
130  fi
131
132
133  TOTAL_TEST=`expr $TOTAL_TEST + 1`
134  REC=`run_cnee $SHORT_ARG  $TMP | xargs run_cnee $LONG_ARG  `
135  STATUS=$?
136  check_retval $STATUS 0
137  if [ "$REC" != "$TMP" ];
138      then
139      log " unexpected result: using  \"run_cnee $SHORT_ARG  $TMP | run_cnee $LONG_ARG $TMP\""
140      log " got: $REC ..... wanted: $TMP"
141      ERR_TEST=`expr $ERR_TEST + 1`
142  else
143    SUCC_TEST=`expr $SUCC_TEST + 1`
144  fi
145
146
147
148  TMP=`expr $TMP + 1`
149done
150
151#
152# negative tests
153#
154for i in 0=bartok    -12=bela      1=allan 67=pettersson 127=dimitri 200=shostakovich
155do
156  EV_=`echo $i | sed 's,\([-0-9]*\)=.*,\1,g'`
157  NAME_=`echo $i | sed 's,[-0-9]*=\([a-zA-Z0-9]*\),\1,g'`
158
159  XNEE_EV=`run_cnee $LONG_ARG $NAME_`
160  STATUS=$?
161  check_retval_false $STATUS 0
162  if [ "$XNEE_EV" != "" ];
163      then
164      ERR_TEST=`expr $ERR_TEST + 1`
165  else
166      SUCC_TEST=`expr $SUCC_TEST + 1`
167  fi
168  TOTAL_TEST=`expr $TOTAL_TEST + 1`
169
170  XNEE_EV_NAME=`run_cnee $LONG_ARG $EV_`
171  STATUS=$?
172  check_retval_false $STATUS 0
173  if [ "$XNEE_EV_NAME" != "" ];
174      then
175      ERR_TEST=`expr $ERR_TEST + 1`
176  else
177      SUCC_TEST=`expr $SUCC_TEST + 1`
178  fi
179  TOTAL_TEST=`expr $TOTAL_TEST + 1`
180
181
182  # ###
183  # Xnee returns no value so we can't compare
184  # ###
185  #  compare_data_false $EV_ $NAME_  $XNEE_EV $XNEE_EV_NAME
186
187
188  XNEE_EV=`run_cnee $SHORT_ARG $NAME_`
189  STATUS=$?
190  check_retval_false $STATUS 0
191  if [ "$XNEE_EV" != "" ];
192      then
193      ERR_TEST=`expr $ERR_TEST + 1`
194  else
195      SUCC_TEST=`expr $SUCC_TEST + 1`
196  fi
197  TOTAL_TEST=`expr $TOTAL_TEST + 1`
198
199
200
201  XNEE_EV_NAME=`run_cnee $SHORT_ARG $EV_`
202  STATUS=$?
203  check_retval_false $STATUS 0
204  if [ "$XNEE_EV_NAME" != "" ];
205      then
206      ERR_TEST=`expr $ERR_TEST + 1`
207  else
208      SUCC_TEST=`expr $SUCC_TEST + 1`
209  fi
210  TOTAL_TEST=`expr $TOTAL_TEST + 1`
211
212
213
214# ###
215# Xnee returns no value so we can't compare
216# ###
217#  compare_data_false $EV_ $NAME_  $XNEE_EV $XNEE_EV_NAME
218done
219
220
221
222\rm -f $X11_NAMES
223
224result_log $MYNAME
225exit
226