1#/bin/sh
2#
3#
4# This file is generated from new_script.sh
5# and updated by hand by hesa
6#
7# Filename:   opt_scripts/print-request-name.sh
8# Generated:  Sun Mar 16 21:57:36 CET 2003
9#
10# Description:
11#
12#  Tests the Xnee option
13#       --print-request-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-request-name.sh
26
27# Arguments to test (short and long)
28export LONG_ARG=--print-request-name
29export SHORT_ARG=-prn
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 $MY_NAME
42parse_me "$*"
43
44#######################################################################
45
46
47X11_NAMES=/tmp/xnee_requests.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_requests  /usr/include/X11/Xproto.h $X11_NAMES
59
60LAST_REQ=`grep X_GetModifierMapping /usr/include/X11/Xproto.h | awk '{ print $3}' | sed 's,[ ]*,,g' `
61
62
63
64
65#
66# positive tests of long args
67#
68# compare Xnee number and names with the system
69for i in `cat $X11_NAMES`
70do
71  EV_=`echo $i | sed 's,\([0-9]*\)=.*,\1,g'`
72  NAME_=`echo $i | sed 's,[0-9]*=\([a-zA-Z0-9]*\),\1,g'`
73
74  XNEE_EV=`run_cnee $LONG_ARG $NAME_`
75  STATUS=$?
76  check_retval $STATUS 0 "run_cnee $LONG_ARG $NAME_"
77
78  XNEE_EV_NAME=`run_cnee $LONG_ARG $EV_`
79  STATUS=$?
80  check_retval $STATUS 0 "run_cnee $LONG_ARG $EV_"
81
82  compare_data $EV_ $NAME_  $XNEE_EV $XNEE_EV_NAME "$MYNAME"
83
84done
85
86
87# compare Xnee number and names with the system
88# short args
89for i in `cat $X11_NAMES`
90do
91  EV_=`echo $i | sed 's,\([0-9]*\)=.*,\1,g'`
92  NAME_=`echo $i | sed 's,[0-9]*=\([a-zA-Z0-9]*\),\1,g'`
93
94  XNEE_EV=`run_cnee $SHORT_ARG $NAME_`
95  STATUS=$?
96  check_retval $STATUS 0
97
98  XNEE_EV_NAME=`run_cnee $SHORT_ARG $EV_`
99  STATUS=$?
100  check_retval $STATUS 0
101
102  compare_data $EV_ $NAME_  $XNEE_EV $XNEE_EV_NAME
103done
104
105
106
107# loop through all requests and run them in a Xnee renaming pipe
108# Make sure that 2 == 2
109# after this has been done:  2 --xnee--> 'requestname' --xnee--> 2
110# loop from  to
111
112TMP=1
113while [ "$TMP" != "$LAST_REQ" ];
114do
115  TOTAL_TEST=`expr $TOTAL_TEST + 1`
116  REC=`run_cnee $LONG_ARG  $TMP | xargs run_cnee $SHORT_ARG  `
117  STATUS=$?
118  check_retval $STATUS 0
119  if [ "$REC" != "$TMP" ];
120      then
121      log " unexpected result: using  \"run_cnee $LONG_ARG  $TMP | run_cnee $SHORT_ARG $TMP\""
122      log " got: $REC ..... wanted: $TMP"
123      ERR_TEST=`expr $ERR_TEST + 1`
124  else
125    SUCC_TEST=`expr $SUCC_TEST + 1`
126  fi
127
128
129
130  TOTAL_TEST=`expr $TOTAL_TEST + 1`
131  REC=`run_cnee $SHORT_ARG  $TMP | xargs run_cnee $LONG_ARG  `
132  STATUS=$?
133  check_retval $STATUS 0
134  if [ "$REC" != "$TMP" ];
135      then
136      log " unexpected result: using  \"run_cnee $SHORT_ARG  $TMP | run_cnee $LONG_ARG $TMP\""
137      log " got: $REC ..... wanted: $TMP"
138      ERR_TEST=`expr $ERR_TEST + 1`
139  else
140    SUCC_TEST=`expr $SUCC_TEST + 1`
141  fi
142
143
144
145  TMP=`expr $TMP + 1`
146
147done
148
149
150
151
152#
153# negative tests
154#
155for i in 0=bartok -12=bela  200=shostakovich
156do
157  EV_=`echo $i | sed 's,\([-0-9]*\)=.*,\1,g'`
158  NAME_=`echo $i | sed 's,[-0-9]*=\([a-zA-Z0-9]*\),\1,g'`
159
160
161  XNEE_EV=`run_cnee $LONG_ARG $NAME_`
162  STATUS=$?
163  check_retval_false $STATUS 0
164  if [ "$XNEE_EV" != "" ];
165      then
166      ERR_TEST=`expr $ERR_TEST + 1`
167  else
168      SUCC_TEST=`expr $SUCC_TEST + 1`
169  fi
170  TOTAL_TEST=`expr $TOTAL_TEST + 1`
171
172  XNEE_EV_NAME=`run_cnee $LONG_ARG $EV_`
173  STATUS=$?
174  check_retval_false $STATUS 0
175  if [ "$XNEE_EV_NAME" != "" ];
176      then
177      ERR_TEST=`expr $ERR_TEST + 1`
178  else
179      SUCC_TEST=`expr $SUCC_TEST + 1`
180  fi
181  TOTAL_TEST=`expr $TOTAL_TEST + 1`
182
183# ###
184# Xnee returns no value so we can't compare
185# ###
186#  compare_data_false $EV_ $NAME_  $XNEE_EV $XNEE_EV_NAME
187
188
189  XNEE_EV=`run_cnee $SHORT_ARG $NAME_`
190  STATUS=$?
191  check_retval_false $STATUS 0
192  if [ "$XNEE_EV" != "" ];
193      then
194      ERR_TEST=`expr $ERR_TEST + 1`
195  else
196      SUCC_TEST=`expr $SUCC_TEST + 1`
197  fi
198  TOTAL_TEST=`expr $TOTAL_TEST + 1`
199
200  XNEE_EV_NAME=`run_cnee $SHORT_ARG $EV_`
201  STATUS=$?
202  check_retval_false $STATUS 0
203  if [ "$XNEE_EV_NAME" != "" ];
204      then
205      ERR_TEST=`expr $ERR_TEST + 1`
206  else
207      SUCC_TEST=`expr $SUCC_TEST + 1`
208  fi
209  TOTAL_TEST=`expr $TOTAL_TEST + 1`
210
211done
212
213
214# more neg tests.....
215#for i in    1=allan 67=pettersson 127=dimitri
216for i in    1=allan
217do
218  EV_=`echo $i | sed 's,\([-0-9]*\)=.*,\1,g'`
219  NAME_=`echo $i | sed 's,[-0-9]*=\([a-zA-Z0-9]*\),\1,g'`
220
221
222  XNEE_EV=`run_cnee $LONG_ARG $NAME_`
223  STATUS=$?
224  check_retval_false $STATUS 0
225  if [ "$XNEE_EV" != "" ];
226      then
227      ERR_TEST=`expr $ERR_TEST + 1`
228  else
229      SUCC_TEST=`expr $SUCC_TEST + 1`
230  fi
231  TOTAL_TEST=`expr $TOTAL_TEST + 1`
232
233
234  XNEE_EV_NAME=`run_cnee $LONG_ARG $EV_`
235  STATUS=$?
236  check_retval $STATUS 0
237  if [ "$XNEE_EV_NAME" == "" ];
238      then
239      ERR_TEST=`expr $ERR_TEST + 1`
240  else
241      SUCC_TEST=`expr $SUCC_TEST + 1`
242  fi
243  TOTAL_TEST=`expr $TOTAL_TEST + 1`
244
245# ###
246# Xnee returns no value so we can't compare
247# ###
248#  compare_data_false $EV_ $NAME_  $XNEE_EV $XNEE_EV_NAME
249
250  XNEE_EV=`run_cnee $SHORT_ARG $NAME_`
251  STATUS=$?
252  check_retval_false $STATUS 0
253  if [ "$XNEE_EV" != "" ];
254      then
255      ERR_TEST=`expr $ERR_TEST + 1`
256  else
257      SUCC_TEST=`expr $SUCC_TEST + 1`
258  fi
259  TOTAL_TEST=`expr $TOTAL_TEST + 1`
260
261
262
263  XNEE_EV_NAME=`run_cnee $SHORT_ARG $EV_`
264  STATUS=$?
265  check_retval $STATUS 0
266  if [ "$XNEE_EV_NAME" == "" ];
267      then
268      ERR_TEST=`expr $ERR_TEST + 1`
269  else
270      SUCC_TEST=`expr $SUCC_TEST + 1`
271  fi
272  TOTAL_TEST=`expr $TOTAL_TEST + 1`
273
274# ###
275# Xnee returns no value so we can't compare
276# ###
277#  compare_data_false $EV_ $NAME_  $XNEE_EV $XNEE_EV_NAME
278done
279
280
281\rm -f $X11_NAMES
282result_log $MYNAME
283exit
284