r2625 - in people/bmsleight: . autotesting

bmsleight-guest at alioth.debian.org bmsleight-guest at alioth.debian.org
Sun Jul 29 00:04:10 UTC 2007


Author: bmsleight-guest
Date: 2007-07-29 00:04:10 +0000 (Sun, 29 Jul 2007)
New Revision: 2625

Added:
   people/bmsleight/autotesting/
   people/bmsleight/autotesting/video-qemu-booting-iso.sh
Log:
Work in progress

Added: people/bmsleight/autotesting/video-qemu-booting-iso.sh
===================================================================
--- people/bmsleight/autotesting/video-qemu-booting-iso.sh	                        (rev 0)
+++ people/bmsleight/autotesting/video-qemu-booting-iso.sh	2007-07-29 00:04:10 UTC (rev 2625)
@@ -0,0 +1,217 @@
+#!/bin/bash
+get_global_variables ()
+{
+PASSWD="$RANDOM.$RANDOM.$RANDOM.$RANDOM.$RANDOM"
+HOSTNAME=$(hostname)
+OLD_DISPLAY="$DISPLAY"
+TMP_DIR=/tmp/vqbi.$$.tmp
+IPADDRESS=$(sudo ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}')
+VNCREC_MOVIE_FRAMERATE=1
+}
+
+get_options_and_defaults ()
+{
+if [ "$SENDKEYS" = "" ]; then
+ SENDKEYS="spc,l,i,v,e,spc,kp_enter"
+fi
+if [ "$QEMU_MONITOR_PORT" = "" ]; then
+ QEMU_MONITOR_PORT=4444
+fi
+if [ "$GEOMETRY" = "" ]; then
+ GEOMETRY="1280x960"
+fi
+if [ "$CONVERT_DIM" = "" ]; then
+ CONVERT_DIM="800x600"
+fi
+if [ "$MCODER_DIM" = "" ]; then
+ MCODER_DIM="w=800:h=600"
+fi
+MCODER_DIM_SCALE=$(echo "$MCODER_DIM" | sed s/x/,/g)
+if [ "$TIME_Q" = "" ]; then
+ TIME_Q="60"
+fi
+if [ "$LOGO" = "" ]; then
+ LOGO="/home/morph/webconverger/openlogo-75.png"
+fi
+if [ "$QEMU_BIN" = "" ]; then
+ QEMU_BIN="qemu"
+ #qemu_0.8.4-etch1
+fi
+}
+
+
+set_up_workspace ()
+{
+mkdir $TMP_DIR 2>/dev/null
+rm ~/.vnc/passwd
+
+cat<<EOF > ~/.vnc/xstartup
+#!/bin/sh
+xsetroot -solid grey
+EOF
+chmod 755 ~/.vnc/xstartup
+
+cat<<EOF > $TMP_DIR/vnc.exp
+spawn vncpasswd
+expect "Password:" { send "$PASSWD\r" }
+expect "Verify:" { send "$PASSWD\r" }
+interact
+puts "\nVNC Password changed\n"
+EOF
+
+expect $TMP_DIR/vnc.exp >/dev/null 2>/dev/null
+echo "VNC Password changed"
+}
+
+start_vnc_sessions ()
+{
+vncserver -nocursor -geometry $GEOMETRY  >$TMP_DIR/vncserver.txt 2>&1
+VNSERVER_QEMU=$(cat $TMP_DIR/vncserver.txt | grep 'New' | awk '{ print $5}' )
+VNCSERVER_QMEU_NUMBER=$(cat $TMP_DIR/vncserver.txt | grep 'New' | cut -d: -f2)
+echo "Launched vncserver $VNSERVER_QEMU"
+vncserver -nocursor -geometry 1600x1200  >$TMP_DIR/vncserver.txt 2>&1
+VNSERVER_VNCREC=$(cat $TMP_DIR/vncserver.txt | grep 'New' | awk '{ print $5}' )
+VNCSERVER_VNCREC_NUMBER=$(cat $TMP_DIR/vncserver.txt | grep 'New' | cut -d: -f2)
+echo "Launched vncserver $VNSERVER_VNCREC"
+}
+
+start_vnc_record ()
+{
+export DISPLAY="$VNSERVER_VNCREC"	
+#export DISPLAY="$OLD_DISPLAY"
+rm /tmp/qemu.1.vnc
+export VNCREC_MOVIE_FRAMERATE
+echo "Starting vncrec, recording :$VNCSERVER_QMEU_NUMBER. Local display :$VNCSERVER_VNCREC_NUMBER"
+vncrec -display :$VNCSERVER_VNCREC_NUMBER -passwd ~/.vnc/passwd -shared -viewonly -encoding raw -record $TMP_DIR/qemu.1.vnc :$VNCSERVER_QMEU_NUMBER &
+}
+
+start_qemu ()
+{
+export DISPLAY=$VNSERVER_QEMU
+echo "Starting qemu, within Dispaly $VNSERVER_QEMU"
+$QEMU_BIN -no-kqemu -full-screen  -cdrom $ISO -monitor telnet:$IPADDRESS:$QEMU_MONITOR_PORT,server,nowait &
+sleep 3
+i=1
+REACHED_LAST_KB=""
+while [ -z $REACHED_LAST_KB ]
+do
+ KEY=$(echo $SENDKEYS | cut -d, -f$i)
+ if [ "$KEY" != "" ]
+ then
+  echo "sendkey $KEY" | socat - TCP4:$IPADDRESS:$QEMU_MONITOR_PORT
+ else
+  REACHED_LAST_KB="Y"
+ fi
+ let i=i+1
+done
+sleep 1
+}
+
+let_qemu_run ()
+{
+echo "Sleeping for $TIME_Q seconds whilst qemu runs"  
+sleep $TIME_Q
+}
+
+stop_qemu ()
+{
+echo "Stopping vncrec and qemu"  
+killall vncrec
+killall $QEMU_BIN
+}
+
+stop_vncservers ()
+{
+echo "Stopping vncservers"  
+vncserver -kill :$VNCSERVER_QMEU_NUMBER
+vncserver -kill :$VNCSERVER_VNCREC_NUMBER
+}
+
+
+export_frames ()
+{
+convert $LOGO -resize 200x200 -negate  -gravity South -background Black -font Helvetica-Bold -fill white -splice 0x36 -pointsize 25 -draw "text 0,0 'AutoTesting'" -transparent black $TMP_DIR/minilogo.png
+convert $TMP_DIR/minilogo.png  -fill grey50 -colorize 40 $TMP_DIR/minilogo.png
+VNCREC_MOVIE_CMD='convert xpm:-  '$TMP_DIR'/image-%05d.jpg'
+export VNCREC_MOVIE_CMD
+vncrec  -movie $TMP_DIR/qemu.1.vnc
+for i in $TMP_DIR/image-*.jpg
+do
+ convert $i -resize $CONVERT_DIM $i 
+ echo "Resized $i"
+ composite -dissolve 15 -gravity northeast $TMP_DIR/minilogo.png $i $i
+done
+echo "Finished making Frames"
+}
+
+
+make_video ()
+{
+##Following is ideal - does not work
+#mkfifo -m 660 $TMP_DIR/stream.yuv
+#mplayer -vo yuv4mpeg:file=$TMP_DIR/stream.yuv -ao null -nosound -quiet "mf://$TMP_DIR/*.jpg"  -mf fps=4:type=jpg &
+#ffmpeg2theora -v 8 $TMP_DIR/stream.yuv -o $VIDEO 
+#sleep 5
+
+mencoder mf://"$TMP_DIR/*.jpg" -mf w=800:h=600:fps=4:type=jpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o $TMP_DIR/tmp.avi
+ffmpeg2theora -o $VIDEO $TMP_DIR/tmp.avi
+}
+
+clean_up ()
+{
+DISPLAY="$OLD_DISPLAY"
+export DISPLAY="$OLD_DISPLAY"
+#rm $TMP_DIR -r
+}
+
+
+while getopts s:p:g:d:t:l:q: opt
+do
+    case "$opt" in
+      s)  SENDKEYS="$OPTARG";;
+      p)  QEMU_MONITOR_PORT="$OPTARG";;
+      g)  GEOMETRY="$OPTARG";;
+      d)  CONVERT_DIM="$OPTARG";;
+      t)  TIME_Q="$OPTARG";;
+      l)  LOGO="$OPTARG";;
+      q)  QEMU_BIN="$OPTARG";;
+
+      
+      \?)		# unknown flag
+      	  echo >&2 \
+		"usage: $0 [-s \"keys,to,send,to,qemu\"] [-p port_number for qemu-monitor] [-g geometry of vncsession] [-d dimensions of video] [-t time to run qemu] [-l logo] [-q alternative qemu binary name] IsoToTest.iso Video.ogg " 
+	  exit 1;;
+    esac
+done
+shift `expr $OPTIND - 1`
+
+if [ -z "$1" -a -z "$2" ]; then
+    echo "usage: $0 [-s \"keys,to,send,to,qemu\"] [-p port_number for qemu-monitor] [-g geometry of vncsession] [-d dimensions of video] [-t time to run qemu] [-l logo] IsoToTest.iso Video.ogg " 
+    echo
+    echo " This script boots a livecd using qemu and records a video of the process. "
+    echo 
+    echo " It is worth noting that this script takes a long time to run and heavy usage of CPU."
+    echo " There is heavy usage of the qemu, imagemagik tools. "
+    echo " For every second of running qemu the script it can take up to 12s to compile the video."
+    echo " For example using -t 300 will about one hour."
+    echo
+    echo " Launches a couple of vncserver session, kills other vncrec and qemu session running."
+    echo " Requires sudo ifconfig"
+    exit
+fi
+
+ISO=$1
+VIDEO=$2
+
+get_options_and_defaults
+get_global_variables
+set_up_workspace
+start_vnc_sessions
+start_vnc_record
+start_qemu
+let_qemu_run
+stop_qemu
+export_frames
+make_video
+stop_vncservers
+clean_up


Property changes on: people/bmsleight/autotesting/video-qemu-booting-iso.sh
___________________________________________________________________
Name: svn:executable
   + *




More information about the debian-live-changes mailing list