From 3f3d37ca095c3751b87028df783154f1460f2ea5 Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Wed, 17 Jun 2009 17:56:56 +0000 Subject: [PATCH] Next patch from John McCabe-Dansted. http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg152211.html git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30148 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/keystest/autolyx | 50 ++++++++++++++++-- development/keystest/killtest.sh | 7 ++- development/keystest/killtestpy.sh | 4 ++ development/keystest/lyx_make.sh | 8 ++- development/keystest/replay.sh | 65 ++++++++++++++++++++++++ development/keystest/report.sh | 2 +- development/keystest/report_html.sh | 78 +++++++++++++++++++++++++++++ development/keystest/start_tests.sh | 2 +- development/keystest/test.py | 18 +++---- 9 files changed, 216 insertions(+), 18 deletions(-) create mode 100644 development/keystest/killtestpy.sh create mode 100644 development/keystest/replay.sh create mode 100644 development/keystest/report_html.sh diff --git a/development/keystest/autolyx b/development/keystest/autolyx index 669042bbfa..cf666a37d9 100755 --- a/development/keystest/autolyx +++ b/development/keystest/autolyx @@ -2,15 +2,59 @@ # This script starts LyX, and restarts LyX if it is closed # it logs all output, including backtraces to development/keystest/out/GDB +#Setting the following may give better screen shots +#gconftool-2 /apps/metacity/general/compositing_manager -s -t bool true + +DIRNAME0=`dirname "$0"` +OUTDIR="$DIRNAME0/out" + #rename other windows to avoid confusion. wmctrl -N __renamed__ -r lyx wmctrl -N __renamed__ -r lyx wmctrl -N __renamed__ -r lyx wmctrl -N __renamed__ -r lyx +( while true do - ( (echo SECONDS: `date +%s` - (echo "run - bt" ; yes q) | gdb src/lyx 2>&1) | strings| tee -a development/keystest/out/GDB) + SEC=`date +%s` + GDB=$OUTDIR/$SEC.GDB + KEYCODE=$OUTDIR/$SEC.KEYCODE + ( sleep 20 && python $DIRNAME0/test.py | tee $KEYCODE) & + CHILD_PID="$!" + ls src/lyx ; sleep 1 + pwd + #sleep 10 + + #You may want to use the following to simulate SIGFPE + #(sleep 90 && killall -8 lyx) & + + (echo " + shell svn info src/ + run + bt + shell kill $CHILD_PID + shell import -window root '$GDB.png' + shell wmctrl -l + shell sleep 1 + shell kill -9 $CHILD_PID + shell wmctrl -r __renamed__ -b add,shaded + shell wmctrl -r term -b add,shaded + shell wmctrl -r term -b add,shaded + shell wmctrl -R lyx + shell import -window root '$GDB..png' + " ; yes q) | gdb src/lyx 2>&1 | strings| tee $GDB + kill $CHILD_PID + #sleep 2 kill -9 $CHILD_PID + grep " signal " $GDB || ( + rm $OUTDIR/*GDB*.bak + rm $OUTDIR/*KEYCODE*.bak + mv $KEYCODE $KEYCODE.bak + mv $GDB $GDB.bak + mv $GDB.png $GDB.png.bak + mv $GDB..png $GDB..png.bak + #rm $OUTDIR/KEYCODE.$SEC + #rm $OUTDIR/GDB.$SEC + ) done +) 2>&1 |tee $OUTDIR/log diff --git a/development/keystest/killtest.sh b/development/keystest/killtest.sh index 8d8d30ada9..9390c9510b 100755 --- a/development/keystest/killtest.sh +++ b/development/keystest/killtest.sh @@ -1,14 +1,17 @@ AUTOLYX=`ps gaux | grep autolyx | grep -v grep | sed 's/[^ ]* //' | sed s/0.0.*//g` +TESTPY=`ps gaux | grep test.py | grep -v grep | sed 's/[^ ]* //' | sed s/0.0.*//g` killall autolyx killall test.py killall lyx killall gdb killall xterm -kill $AUTOLYX +killall replay.sh +kill $AUTOLYX $TESTPY sleep 0.3 killall autolyx -9 killall test.py -9 killall lyx -9 killall gdb -9 killall xterm -9 -kill $AUTOLYX -9 +killall replay.sh -9 +kill $AUTOLYX $TESTPY -9 diff --git a/development/keystest/killtestpy.sh b/development/keystest/killtestpy.sh new file mode 100644 index 0000000000..ecdbeb9191 --- /dev/null +++ b/development/keystest/killtestpy.sh @@ -0,0 +1,4 @@ +TESTPY=`ps gaux | grep test.py | grep -v grep | sed 's/[^ ]* //' | sed s/0.0.*//g` +kill $TESTPY +sleep 0.1 +kill $TESTPY -9 diff --git a/development/keystest/lyx_make.sh b/development/keystest/lyx_make.sh index b9e5d590f2..14637efcee 100755 --- a/development/keystest/lyx_make.sh +++ b/development/keystest/lyx_make.sh @@ -16,12 +16,16 @@ then if [ a"$1" == a--update ]; then svn up - ./autogen.sh && ./configure --enable-debug -- && nice -18 make && (bash $LT/autolyx & sleep 9 ; xterm -e python $LT/test.py) + ./autogen.sh && ./configure --enable-debug -- && nice -18 make && + if [ ! a"$2" == a"0" ] + then + bash $LT/autolyx + fi else DBG=`src/lyx --version 2>&1 | grep C++.Compiler.flags|grep -- -g`; if [ -z "$DBG" ]; then echo Wrong build of LyX binary. ; exit; fi - bash $LT/autolyx & sleep 9 ; xterm -e python $LT/test.py + bash $LT/autolyx fi else diff --git a/development/keystest/replay.sh b/development/keystest/replay.sh new file mode 100644 index 0000000000..f2fa27e6f4 --- /dev/null +++ b/development/keystest/replay.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# This script starts LyX, and restarts LyX if it is closed +# it logs all output, including backtraces to development/keystest/out/GDB + +#rename other windows to avoid confusion. +DIRNAME0=`dirname "$0"` +OUTDIR="$DIRNAME0/out" +WAITSECS=20 +INFILE="$1" +LINES_TO_INCLUDE=8 + +if [ ! -e "$INFILE" ] +then + echo cannot find "$INFILE" + exit +fi + +killall lyx + +wmctrl -N __renamed__ -r lyx +wmctrl -N __renamed__ -r lyx +wmctrl -N __renamed__ -r lyx +wmctrl -N __renamed__ -r lyx + +while ! grep " signal SIG[^T]" "$INFILE.new_gdb" +do + SEC=`date +%s` + echo GDB---------------- >> "$INFILE.new_gdb.bak" + cat "$INFILE.new_gdb" >> "$INFILE.new_gdb.bak" + echo LINES_TO_INCLUDE $LINES_TO_INCLUDE + #cat $NUMLINES + tail -n $LINES_TO_INCLUDE < $INFILE > $INFILE.new_key + NUMLINES=`wc -l "$INFILE.new_key"` + echo NUMLINES $NUMLINES + ( i=0 + echo Waiting $WAITSECS before starting replay + sleep $WAITSECS + echo Starting replay + wmctrl -R LyX && xvkbd -xsendevent -text '\Afn' + cat "$INFILE.new_key" | + while read -r l + do + wmctrl -R LyX && xvkbd -xsendevent -text "$l" + #echo -- "$l" + i=$(($i+1)) + echo $i/$NUMLINES + sleep 0.1 + done + echo FINISHED REPLAY + sleep 4 + killall lyx + sleep 2 + killall lyx -9 + echo FINISHED REPLAY and killed lyx + ) & + CHILD_PID="$!" + echo "Starting Lyx" + (echo "run + bt" ; yes q) | gdb src/lyx 2>&1 | strings| tee "$INFILE.new_gdb" + kill $CHILD_PID + sleep 2 kill -9 $CHILD_PID + LINES_TO_INCLUDE=$(($LINES_TO_INCLUDE*2)) + +done +echo END diff --git a/development/keystest/report.sh b/development/keystest/report.sh index d26384af5a..f6151876c4 100755 --- a/development/keystest/report.sh +++ b/development/keystest/report.sh @@ -14,7 +14,7 @@ do fi done -strings $LT/out/GDB > $LT/out/GDBs +strings $LT/out/*GDB > $LT/out/GDBs grep "#$UNIQUE_LINE " $LT/out/GDBs > $LT/out/list #cat $LT/out/list | grep -o ' in [[:alnum:]:]* ' | sort | uniq| tee $LT/out/listuniq #cat $LT/out/list | grep -o ' in [[:alnum:]:]* ' | sort | uniq| tee $LT/out/listuniq diff --git a/development/keystest/report_html.sh b/development/keystest/report_html.sh new file mode 100644 index 0000000000..62870ed94c --- /dev/null +++ b/development/keystest/report_html.sh @@ -0,0 +1,78 @@ +#!/bin/bash +LT=development/keystest + +# echo 'grep "#1 " $LT/out/GDB | sed 's/0x[^ )]*[ )]/.*/g' | sort | uniq' >> report.sh + +UNIQUE_LINE=1 +SRC= +if [ -e out/log ] +then + LT=. +fi + +while [ ! -e $LT/out/log ] +do + cd .. + if [ `pwd` = '/' ] + then + exit + fi +done + +OUT=$LT/out +rm $OUT/index*.html +#rm $OUT/indexreport.html +ls $OUT/*.html + +strings $LT/out/GDB.* > $LT/out/GDBs +grep "#$UNIQUE_LINE " $LT/out/GDBs > $LT/out/list +#cat $LT/out/list | grep -o ' in [[:alnum:]:]* ' | sort | uniq| tee $LT/out/listuniq +#cat $LT/out/list | grep -o ' in [[:alnum:]:]* ' | sort | uniq| tee $LT/out/listuniq +cat $LT/out/list | sed 's/0x[^ )]*[ )]/.*/g' | sort | uniq | tee $LT/out/listuniq + +NUM_REPORTS=`wc -l < $LT/out/list` +echo NUM_REPORTS $NUM_REPORTS + +echo > $LT/out/overview + +echo '' >> $OUT/indexreport.html + +#cat $LT/out/listuniq | while read l +for f in $LT/out/*GDB +do + echo $f + g=$f.short + if egrep '([Ii][Nn] .*[:[:alnum:]][:][0-9]*[^0-9]|#0 | signal SIG)' -A9999 <$f >$g + then + #egrep '(([Ii][Nn]|at) .*[:[:alnum:]][:][0-9]*[^0-9]|#0 | signal SIG)' -A9999 <$f + SEC=`echo $f | sed s/[^[:digit:]]//g` + #IN_AT=`egrep -o '([Ii][Nn]|at) ([:lower:]* )[:_[:alnum:]]*(::[:_[:alnum:]]*|:[0-9]*)' <$f | head -n 1 ` + IN_AT=`egrep -o '([Ii][Nn]|at) ([:lower:]* )?[:_[:alnum:]]*(::[:_[:alnum:]]*|:[0-9]*)' <$f | head -n 1 ` + SIGNAL=`grep -o ' signal SIG[[:alnum:]_]*[, ]' <$g | sed s/[^[:upper:]]//g | head -n 1` + TITLE="$SIGNAL $IN_AT" + TITLE_=`echo $TITLE|sed s/[^[:alnum:]]/_/g` + INDEX="index_$TITLE_.html" + echo TITLE $TITLE + echo INDEX $INDEX + if [ ! -e $LT/out/$INDEX ] + then + echo NEW $INDEX + echo '' >> $LT/out/$INDEX + echo -n ''"$TITLE" >> $OUT/indexreport.html + echo '['1']
' >> $OUT/indexreport.html + else + echo exists $INDEX + fi + ( echo '' + echo "

$TITLE

" + echo "$TITLE" +# head -n 20 $g | txt2html -pi | sed 's/^//' | sed 's/$//g' + #head -n 20 $g | txt2html -pi | sed 's/^#/#/' +# cat $g | txt2html -pi | sed 's/^#/#/' + cat $g | sed 's/&/&/g' | sed 's//' + ) > $OUT/$SEC.html + echo ''$SEC'
' >> $OUT/$INDEX + echo ''$SEC'
' + fi +done +exit diff --git a/development/keystest/start_tests.sh b/development/keystest/start_tests.sh index d796f79b62..866593bb50 100755 --- a/development/keystest/start_tests.sh +++ b/development/keystest/start_tests.sh @@ -5,4 +5,4 @@ LT=development/keystest -(bash $LT/autolyx & sleep 9 ; xterm -e python $LT/test.py) +bash $LT/autolyx diff --git a/development/keystest/test.py b/development/keystest/test.py index 6a6a09f198..6c695de0a7 100755 --- a/development/keystest/test.py +++ b/development/keystest/test.py @@ -7,13 +7,7 @@ import random import os -#os.system("mv LT/*lyx*_* - -#os.system("lyx &") -#os.system("sleep 20") - - -keycode=["\[Left]",'\[Right]','\[Down]','\[Up]','\[BackSpace]','\[Delete]'] +keycode=["\[Left]",'\[Right]','\[Down]','\[Up]','\[BackSpace]','\[Delete]','\[Escape]'] keycode[:0]=keycode keycode[:0]=keycode @@ -38,10 +32,16 @@ print (random.randint(1,len(keycode))) for k in range(97, 123): print (keycode[random.randint(1,len(keycode))-1]) +#Start a new file. We could also open a random Help file. +#os.system("wmctrl -R LyX && xvkbd -xsendevent -text '\Afn';sleep 1") +keystr="'\Afn'" +os.system("wmctrl -R LyX && xvkbd -xsendevent -text '"+keystr+"';sleep 1") +os.system("echo '"+keystr+"'") + while True: keystr="" for k in range(1,80): keystr=keystr+keycode[random.randint(1,len(keycode))-1] + #output keystr before using, to make sure it is output before we are killed + os.system("echo '"+keystr+"'") os.system("wmctrl -R LyX && xvkbd -xsendevent -text '"+keystr+"';sleep 1") - #os.system("echo KEYCODES: '"+keystr+"' >> development/keystest/out/GDB") - os.system("echo `date +%s`: '"+keystr+"' >> development/keystest/out/KEYCODES") -- 2.39.2