File: mouse.sh

package info (click to toggle)
xnee 3.06-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 6,324 kB
  • ctags: 2,429
  • sloc: ansic: 21,992; sh: 12,427; makefile: 563
file content (158 lines) | stat: -rwxr-xr-x 2,659 bytes parent folder | download | duplicates (8)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#/bin/sh
#
#
# Filename:   record/mouse-rec.sh
# Generated:  Sun Mar 16 21:57:36 CET 2003
# 
# Description:
#
#  Test the Xnee functionality
#       record mouse motions
#
#
 
 
 
 
 
# name of myself
MYNAME=record/mouse.sh
 
 
# source useful funs
if [ ! -f etc/base_funs ]; 
then 
    echo "Can't find the file: base_funs"  
    echo "Start me up in the xnee test dir "
    exit
else 
    . etc/base_funs
fi 
 
init_test $MYNAME
parse_me "$*"

#######################################################################


function check_nr_of_loops()
{
    EXPECTED=$1
    LOGFILE=$2

    
    NR=`grep -c -e '^0,6' $LOGFILE | sed 's,[ \t]*,,g'`


    echo "loops in file:   $NR"
    echo "expected         $EXPECTED"
    
    verify_same $EXPECTED $NR $LOGFILE 
}


function check_intervals()
{
    PIX=$1
    DIRECTION=$2
    FILE=$3
    FIELD=$4
    EXP_DIFF=$5

    TMP=0
    LAST=""


    TOTAL_TEST=`expr $TOTAL_TEST + 1`

    for i in `grep -e "^0,6" $FILE | awk -F , -v fi=$FIELD '{ print $fi }' `
    do
      THIS=$i
      if [ "$LAST" != "" ] ;
	  then
	  DIFF=`expr $LAST - $THIS`
	  
	  if [ "$DIFF" != "$EXP_DIFF" ]
	      then
	      MSG=" Comparing intervals in file $FILE $FIELD i=$i: $DIFF"
	      echo " Data differs: $MSG"
	      verbose " Data differs: $MSG"
	      error_log " Data differs: $MSG"
	      ERR_TEST=`expr $ERR_TEST + 1`
	      return 1
	  fi

      fi
      LAST=$THIS
    done
    SUCC_TEST=`expr $SUCC_TEST + 1`
}


function test_mouse()
{
    DIRECTION=$1
    PIX=$2
    FILE=$3
    FIELD=$4
    EXP_DIFF=$5

    TMP=-1
    verbose "starting xnee"
    run_cnee --record --device-event-range 6 --data-to-record 10000 --seconds-to-record 10000 --events-to-record $PIX -o $FILE &

    sleep 2
    while [ "$TMP" != "$PIX" ];
      do
      echo "$DIRECTION" > $MOUSE_DEVICE
      TMP=`expr $TMP + 1 `
      sleep 0
    done
    sleep 2

    echo "check loops"
    check_nr_of_loops $PIX $FILE 
    sleep 1
    echo "check intervals"
    check_intervals   $PIX $DIRECTION $FILE $FIELD $EXP_DIFF
}




# main ..... I guess

verify_device $MOUSE_DEVICE_NAME



rm m*.log

NR_OF_PIX=250


verbose "find a nice start position ..."
#start with the mouse in such a position that in can move around enought
get_in_position

#zero the device counter
zero_device $MOUSE_DEVICE_NAME

verbose  "starting...."
move_mouse      d  $NR_OF_PIX
test_mouse      u  $NR_OF_PIX mu.log 4 1

move_mouse      r  $NR_OF_PIX
test_mouse      l  $NR_OF_PIX ml.log 3 1

move_mouse      l  $NR_OF_PIX
test_mouse      r  $NR_OF_PIX mr.log 3 -1

move_mouse      u  $NR_OF_PIX
test_mouse      d  $NR_OF_PIX md.log 4 -1


#rm m*.log

result_log $MYNAME 
exit