]> git.lyx.org Git - features.git/commitdiff
Test of brute-force key typing to test lyx for crashes.
authorPavel Sanda <sanda@lyx.org>
Mon, 15 Jun 2009 20:20:14 +0000 (20:20 +0000)
committerPavel Sanda <sanda@lyx.org>
Mon, 15 Jun 2009 20:20:14 +0000 (20:20 +0000)
Vanilla sources from John McCabe-Dansted.

http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg152155.html

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30121 a592a061-630c-0410-9148-cb99ea01b6c8

development/keystest/README [new file with mode: 0644]
development/keystest/autolyx [new file with mode: 0755]
development/keystest/killtest.sh [new file with mode: 0755]
development/keystest/lyx_make.sh [new file with mode: 0755]
development/keystest/maketar.sh [new file with mode: 0755]
development/keystest/report.sh [new file with mode: 0755]
development/keystest/start_tests.sh [new file with mode: 0755]
development/keystest/stock_text [new file with mode: 0644]
development/keystest/test.py [new file with mode: 0755]

diff --git a/development/keystest/README b/development/keystest/README
new file mode 100644 (file)
index 0000000..8f6cf52
--- /dev/null
@@ -0,0 +1,40 @@
+--- LyXtest ---
+
+This is a program to spam LyX with millions of randomly generated key
+presses, and collect the crash results.
+
+Since the code involves spamming random keypresses, I'd recommend
+running it in a VM, well away from your main X windows session.
+
+In short, to use this, move this directory LT into your LyX source directory
+(e.g. lyx-1.6.x, but not lyx-1.6.x/src). Then run LT/lyx_make.sh
+
+It requires the following packages to run
+  xvkbd wmctrl 
+the following are also useful:
+   lyx libqt4-dbg subversion automake
+
+It is run by running ./autolyx in one xterm, and ./test.py in another.
+I wrote lyx_make.sh as a easy way of updating lyx and running these two
+programs together.
+
+CONTENTS:
+
+README: this readme file
+report.sh: A quick way of generating bug reports and an overview from the logs.
+autolyx: A script to continually restart lyx and collect the bug reports
+lyx_make.sh: should updates, compiles, and everything needed to generated logs.
+maketar.sh: Makes this tar file :)
+test.py: Sends LT100 randomly generated keypresses per second to the LyX window.
+killtest: stop the testing
+stock_text: The stock test to add to each bug report.
+
+OUTPUTS:
+
+autolyx: Outputs out/GDB, a log of all output, including backtraces.
+test.py: Outputs out/KEYCODES, a list of all keycodes sent to LyX
+
+reports.sh: Outputs
+  out/overview: an overview of all the frequency of each error
+  out/overview_sort: as above but sorted
+  out/report_*: A collection of autogenerated bug reports.
diff --git a/development/keystest/autolyx b/development/keystest/autolyx
new file mode 100755 (executable)
index 0000000..20477dc
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+# This script starts LyX, and restarts LyX if it is closed
+# it logs all output, including backtraces to LT/out/GDB
+
+#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 LT/out/GDB)
+done
diff --git a/development/keystest/killtest.sh b/development/keystest/killtest.sh
new file mode 100755 (executable)
index 0000000..8d8d30a
--- /dev/null
@@ -0,0 +1,14 @@
+AUTOLYX=`ps gaux | grep autolyx | grep -v grep | sed 's/[^ ]* //' | sed s/0.0.*//g`
+killall autolyx
+killall test.py
+killall lyx
+killall gdb
+killall xterm
+kill $AUTOLYX
+sleep 0.3
+killall autolyx -9
+killall test.py -9
+killall lyx -9
+killall gdb -9
+killall xterm -9
+kill $AUTOLYX -9
diff --git a/development/keystest/lyx_make.sh b/development/keystest/lyx_make.sh
new file mode 100755 (executable)
index 0000000..e6c92e8
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+#This script updates LyX, runs LyX, starts spamming it with hundreds of 
+#keypresses, and logs all output, including backtraces to LT/out/GDB
+#Use report.sh to generated the more useful bug reports in LT/out/{or}*
+
+#LYXDIR=LT/lyx-1.6.x-test
+cd ~/lyx-1.6.x-test
+mkdir -p LT/out
+if which wmctrl xvkbd bash xterm python
+then 
+ #cd "$LYXDIR" || echo CANNOT FIND LT/lyx-1.6.x-test
+ #cd "$LYXDIR" || exit
+ svn up Makefile.am autogen.sh boost/ config/ configure.ac lib/ lyx.1in m4/ rename.sh src/
+ export CFLAGS="-g"
+ export CXXFLAGS="$CFLAGS"
+ ./autogen.sh && ./configure && nice -18 make && (bash LT/autolyx & sleep 9 ; xterm -e python LT/test.py)
+else
+ echo NEEDS the following packages: 
+ echo wmctrl xvkbd bash xterm python
+fi
diff --git a/development/keystest/maketar.sh b/development/keystest/maketar.sh
new file mode 100755 (executable)
index 0000000..670d300
--- /dev/null
@@ -0,0 +1,2 @@
+tar -c LT/start_tests.sh LT/killt* LT/README LT/stock_text LT/report.sh LT/autolyx LT/lyx_make.sh LT/maketar.sh LT/test.py | gzip -9 > LT/lyxtestc.tar.gz
+#cp lyxtestb.tar.gz LT/share
diff --git a/development/keystest/report.sh b/development/keystest/report.sh
new file mode 100755 (executable)
index 0000000..fd059c7
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/bash
+# echo 'grep "#1 " LT/out/GDB | sed 's/0x[^ )]*[ )]/.*/g'  | sort | uniq' >> report.sh
+
+UNIQUE_LINE=1
+
+while [ ! -e LT/out/GDB ]
+do
+  cd ..
+  if [ `pwd` = '/' ]
+  then
+     exit
+  fi
+done
+
+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
+
+cat LT/out/listuniq | while read l 
+do
+  #name=`echo $l | sed s/in// | sed 's/ //g'`
+  grep "$l" -B $UNIQUE_LINE -A 100 LT/out/GDBs | head -n 100 | grep '#[0-9]' >LT/out/tmp
+  name=`cat LT/out/tmp | ( grep -o ' in lyx::[[:alnum:]:]*' || cat LT/out/tmp | grep -o ' [ai][nt] [[:alnum:]:]*' ) | head -n1 | sed s/in// | sed 's/ //g'`
+  echo NAME: $name
+  echo L: $l
+ #out/list | grep -o ' in [[:alnum:]:]* ' | sort | uniq| tee out/listuniq
+  (
+  cat stock_text
+  uname -r ; cat /etc/lsb-release| grep -i DISTRIB_DESCRIPTION
+  (cd src && svn info | grep Rev:)
+  echo
+  NUM_OCCURANCES=`grep "$l" LT/out/list | wc -l`
+  echo number_of_occurances: $NUM_OCCURANCES/$NUM_REPORTS
+  echo -e $NUM_OCCURANCES "\t" $name >> LT/out/overview
+  #echo grep "$l" LT/out/list 
+  #grep $l LT/out/GDB
+  echo '{{{'
+  grep "$l" -B $UNIQUE_LINE -A 100 LT/out/GDBs | head -n 100 | grep '#[0-9]'
+  echo '}}}'
+  ) | tee LT/out/report_$name
+done   
+
+cat LT/out/overview | sort -rn | tee LT/out/overview_sort
+#cp LT/out/r* LT/share/
+#cp LT/out/o* LT/share/
diff --git a/development/keystest/start_tests.sh b/development/keystest/start_tests.sh
new file mode 100755 (executable)
index 0000000..b2332c8
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/bash
+#This script  runs LyX, starts spamming it with hundreds of 
+#keypresses, and logs all output, including backtraces to LT/out/GDB
+#Use report.sh to generated the more useful bug reports in LT/out/{or}*
+
+(bash LT/autolyx & sleep 9 ; xterm -e python LT/test.py)
diff --git a/development/keystest/stock_text b/development/keystest/stock_text
new file mode 100644 (file)
index 0000000..48068d4
--- /dev/null
@@ -0,0 +1 @@
+[[Add stock text here]]
diff --git a/development/keystest/test.py b/development/keystest/test.py
new file mode 100755 (executable)
index 0000000..e4beca1
--- /dev/null
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+#This script generated hundreds of random keypresses per second,
+#  and sends them to the lyx window
+#It requires xvkbd and wmctrl
+#It generates a log of the KEYCODES it sends as LT/out/KEYCODES
+
+import random
+import os 
+
+#os.system("mv LT/*lyx*_*
+
+#os.system("lyx &")
+#os.system("sleep 20")
+
+
+keycode=["\[Left]",'\[Right]','\[Down]','\[Up]','\[BackSpace]','\[Delete]']
+keycode[:0]=keycode
+keycode[:0]=keycode
+
+keycode[:0]=['\\']
+
+for k in range(97, 123):
+  keycode[:0]=chr(k)
+
+for k in range(97, 123):
+  keycode[:0]=["\A"+chr(k)]
+
+for k in range(97, 123):
+  keycode[:0]=["\A"+chr(k)]
+
+for k in range(97, 123):
+  keycode[:0]=["\C"+chr(k)]
+
+
+print (keycode[1])
+print(keycode)
+print (random.randint(1,len(keycode)))
+for k in range(97, 123):
+  print (keycode[random.randint(1,len(keycode))-1])
+
+while True:
+  keystr=""
+  for k in range(1,80):
+       keystr=keystr+keycode[random.randint(1,len(keycode))-1]
+  os.system("wmctrl -R LyX && xvkbd -xsendevent -text '"+keystr+"';sleep 1")
+  #os.system("echo KEYCODES: '"+keystr+"' >> LT/out/GDB")
+  os.system("echo `date +%s`: '"+keystr+"' >> LT/out/KEYCODES")