From e571d1d525359f562074d6922ac06e35ac49b48c Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Wed, 28 Nov 2012 01:04:15 +0000 Subject: Refactor to use sugar-runner --- (limited to 'commands') diff --git a/commands/helpers/find-free-display.c b/commands/helpers/find-free-display.c deleted file mode 100644 index 4a07131..0000000 --- a/commands/helpers/find-free-display.c +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include - -int main(int argc, char **argv) -{ - int port; - - for (port = 99; port < 1000; port++) { - char display_name[255]; - - sprintf(display_name, ":%d", port); - Display *dpy = XOpenDisplay(display_name); - - if (!dpy) { - printf(display_name); - return 0; - } else { - XCloseDisplay(dpy); - } - } - - printf("No free display found"); - - return 0; -} diff --git a/commands/helpers/get-screen-dpi b/commands/helpers/get-screen-dpi deleted file mode 100755 index 8165920..0000000 --- a/commands/helpers/get-screen-dpi +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/python - -from gi.repository import Gtk - -settings = Gtk.Settings.get_default() -print settings.get_property('gtk-xft-dpi') / 1024 diff --git a/commands/helpers/list-outputs.c b/commands/helpers/list-outputs.c deleted file mode 100644 index 183258c..0000000 --- a/commands/helpers/list-outputs.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -int main(int argc, char **argv) -{ - Display *dpy = XOpenDisplay(NULL); - XRRScreenResources *rr; - XRROutputInfo *output; - int i; - - XSynchronize(dpy, 1); - - rr = XRRGetScreenResources(dpy, DefaultRootWindow(dpy)); - - if (rr != NULL) { - for (i = 0; i < rr->noutput; i++) { - output = XRRGetOutputInfo(dpy, rr, rr->outputs[i]); - - if (output->connection == RR_Connected) { - printf("%s\n", output->name); - } - - XRRFreeOutputInfo(output); - } - } - - XRRFreeScreenResources(rr); - - XSync(dpy, 1); - XCloseDisplay(dpy); - - return 0; -} diff --git a/commands/helpers/run-with-keyring b/commands/helpers/run-with-keyring deleted file mode 100755 index 2925d2f..0000000 --- a/commands/helpers/run-with-keyring +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -eval `gnome-keyring-daemon --start --components=secrets,pkcs11,ssh,gpg` - -export SSH_AUTH_SOCK -export GNOME_KEYRING_CONTROL -export GPG_AGENT_INFO -export GNOME_KEYRING_PID - -exec $1 - -kill $GNOME_KEYRING_PID diff --git a/commands/helpers/test b/commands/helpers/test new file mode 100755 index 0000000..077abca --- /dev/null +++ b/commands/helpers/test @@ -0,0 +1,50 @@ +#!/bin/sh + +helpersdir=`dirname "$0"` +commandsdir=`dirname "$helpersdir"` +rootdir=`dirname "$commandsdir"` +runnerhelpersdir=$rootdir/install/libexec/sugar-runner +testsdir=$rootdir/tests +logsdir=$rootdir/logs +display=`$helpersdir/find-free-display` +resolution=1024x768x16 + +xvfb=`which Xvfb` +xserver="$xvfb $display -ac -noreset -shmem -screen 0 $resolution" + +if [ -z "$SUGAR_BUILDBOT" ]; then + xserver=$display +fi + +export SUGAR_LOGGER_LEVEL=debug +export GTK_MODULES=gail:atk-bridge +export SUGAR_PROFILE=uitests + +xinit $runnerhelpersdir/xinitrc -- $xserver & +xinitpid=$! + +sleep 5 + +DISPLAY=$display python -u $testsdir/shell.py +result=$? + +kill $xinitpid + +if [ -z "$SUGAR_BUILDBOT" ]; then + LOGFILE=$logsdir/test-`date +%Y%m%d-%H%M%S`.log +else + LOGFILE=$logsdir/test.log +fi + +cd ~/.sugar/uitests/logs + +for logfile in *.log +do + echo -e "===== $logfile =====\n" >> $LOGFILE + cat $logfile >> $LOGFILE + echo >> $LOGFILE +done + +#rm -rf ~/.sugar/uitests + +exit $result diff --git a/commands/helpers/xephyr-window.c b/commands/helpers/xephyr-window.c deleted file mode 100755 index b711f99..0000000 --- a/commands/helpers/xephyr-window.c +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include -#include -#include -#include - -int main(int argc, char **argv) -{ - Display *display = XOpenDisplay(NULL); - Window window, root_window; - Atom atom; - int width = 100, height = 100; - - if (argc > 1) { - char *geometry = strdup(argv[1]); - char *delimiter = strchr(geometry, 'x'); - - if (delimiter == NULL) { - fprintf(stderr, "Cannot parse geometry\n"); - free(geometry); - exit(1); - } - - *delimiter = '\0'; - width = atoi(geometry); - height = atoi(delimiter + 1); - - free(geometry); - } - - root_window = RootWindow(display, 0); - - window = XCreateSimpleWindow(display, root_window, 0, 0, - width, height, 0, 0, 0); - - printf("%d\n", window); - fflush(stdout); - - if (argc < 2) { - atom = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", True); - XChangeProperty(display, window, - XInternAtom(display, "_NET_WM_STATE", True), - XA_ATOM, 32, PropModeReplace, - (unsigned char *)&atom, 1); - } - - XMapWindow(display, window); - - XFlush(display); - - while(1) { - sleep(60); - } - - XCloseDisplay(display); - - return(0); -} diff --git a/commands/helpers/xinitrc b/commands/helpers/xinitrc deleted file mode 100644 index 320b346..0000000 --- a/commands/helpers/xinitrc +++ /dev/null @@ -1,54 +0,0 @@ -unset GPG_AGENT_INFO -unset SSH_AUTH_SOCK -unset GNOME_KEYRING_CONTROL -unset GNOME_KEYRING_PID -unset SESSION_MANAGER - -HELPERS_DIR=`dirname "$0"` -COMMANDS_DIR=`dirname "$HELPERS_DIR"` -ROOT_DIR=`dirname "$COMMANDS_DIR"` - -if [ ! -z $SUGAR_PROFILE ]; then - grep -q PROFILE $ROOT_DIR/prefs - if [ $? -ne 0 ]; then - randomstring=`> $ROOT_DIR/prefs - fi -fi - -if [ -f $ROOT_DIR/prefs ]; then - source $ROOT_DIR/prefs -fi - -# Sugar doesn't handle multiple outputs properly. To avoid issues we keep the -# first output in the list returned by xrandr and turn off everything else. - -OUTPUTS=`$HELPERS_DIR/list-outputs` - -for output in $OUTPUTS -do - # Default to the first output in the list - if [ -z $OUTPUT ]; then - OUTPUT=$output - fi - - if [ $OUTPUT != $output ]; then - xrandr --output $output --off - fi -done - -if [ ! -z $SUGAR_UI_TESTS ]; then - rm -rf ~/.sugar/ui-tests - export SUGAR_PROFILE=ui-tests -elif [ ! -z $PROFILE ]; then - export SUGAR_PROFILE=$PROFILE -fi - -if [ ! -z $SUGAR_XKBCONFIG ]; then - cat $SUGAR_XKBCONFIG | xkbcomp - $DISPLAY 2> /dev/null - rm $SUGAR_XKBCONFIG -fi - -RUN_COMMAND="dbus-launch --exit-with-session $HELPERS_DIR/run-with-keyring sugar" - -$COMMANDS_DIR/run-command $RUN_COMMAND diff --git a/commands/run b/commands/run index 1f043d0..bef41f2 100755 --- a/commands/run +++ b/commands/run @@ -1,50 +1,8 @@ -#!/bin/bash +#!/usr/bin/python -commandsdir=$(dirname $(readlink -f $0)) -helpersdir=$commandsdir/helpers -rootdir=`dirname "$commandsdir"` -display=`$helpersdir/find-free-display` +import common -$commandsdir/check-system --skip-if-unchanged +from devbot import run -if [ -f $rootdir/prefs ]; then - source $rootdir/prefs -fi - -if [ ! -z $DISPLAY ]; then - SUGAR_XKBCONFIG=`mktemp -t sugar-xkbconfig-XXXXXX` - setxkbmap -print > $SUGAR_XKBCONFIG - export SUGAR_XKBCONFIG -fi - -if [ ! -z $SUGAR_PROFILE ]; then - grep -q PROFILE $rootdir/prefs - if [ $? -eq 1 ]; then - randomstring=`> $ROOT_DIR/prefs - fi -fi - -if [ -z $DISPLAY ]; then - tty_num=`tty | grep -oE '[0-9]+$'` - x_options="vt$tty_num" - - xinit $helpersdir/xinitrc -- $display $x_options -else - screen_dpi=`$helpersdir/get-screen-dpi` - xephyr_options="-dpi $screen_dpi" - - xidfile=`mktemp -t sugar-xephyr-xid-XXXXXX` - $helpersdir/xephyr-window $RESOLUTION > $xidfile & - xephyrwindowpid=$! - - while [ ! -s $xidfile ] - do - sleep 1 - done - - xephyr_options="$xephyr_options -parent `cat $xidfile`" - xinit $helpersdir/xinitrc -- /usr/bin/Xephyr $display $xephyr_options - - kill $xephyrwindowpid -fi +common.setup() +run.run_sugar() diff --git a/commands/run-command b/commands/run-command deleted file mode 100755 index 941873e..0000000 --- a/commands/run-command +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/python - -import common -import sys - -from devbot import run - -common.setup() -run.run_command(sys.argv[1:]) diff --git a/commands/test b/commands/test index 18adf3d..6a18454 100755 --- a/commands/test +++ b/commands/test @@ -1,47 +1,10 @@ -#!/bin/sh +#!/usr/bin/python -commandsdir=`dirname "$0"` -helpersdir=$commandsdir/helpers -rootdir=`dirname "$commandsdir"` -testsdir=$rootdir/tests -logsdir=$rootdir/logs -display=`$helpersdir/find-free-display` -resolution=1024x768x16 +import os -xvfb=`which Xvfb` -xserver="$xvfb $display -ac -noreset -shmem -screen 0 $resolution" +import common -if [ -z "$SUGAR_BUILDBOT" ]; then - xserver=$display -fi +from devbot import run -export SUGAR_LOGGER_LEVEL=debug -export GTK_MODULES=gail:atk-bridge -export SUGAR_UI_TESTS=yes - -xinit $helpersdir/xinitrc -- $xserver & -xinitpid=$! - -sleep 5 - -DISPLAY=$display python -u $testsdir/shell.py -result=$? - -kill $xinitpid - -if [ -z "$SUGAR_BUILDBOT" ]; then - LOGFILE=$logsdir/test-`date +%Y%m%d-%H%M%S`.log -else - LOGFILE=$logsdir/test.log -fi - -cd ~/.sugar/ui-tests/logs - -for logfile in *.log -do - echo -e "===== $logfile =====\n" >> $LOGFILE - cat $logfile >> $LOGFILE - echo >> $LOGFILE -done - -exit $result +common.setup() +run.run([os.path.join(common.helpers_dir, "test")]) -- cgit v0.9.1