Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-11-16 09:53:35 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-11-16 09:53:35 (GMT)
commit61765e0aaae479b94a3fddd01e4e12eae76bb8da (patch)
tree4c00c5555c77d70db6bd8cae2768d365d12c6702 /commands
parent76d6fad87094008bc25e3b4e090fb79631414fec (diff)
Move the remaining scripts to commands
Diffstat (limited to 'commands')
-rwxr-xr-xcommands/bug-report4
-rw-r--r--commands/helpers/find-free-display.c25
-rwxr-xr-xcommands/helpers/get-screen-dpi6
-rw-r--r--commands/helpers/list-outputs.c33
-rwxr-xr-xcommands/helpers/run-with-keyring12
-rw-r--r--commands/helpers/xinitrc58
-rwxr-xr-xcommands/run43
-rwxr-xr-xcommands/run-command9
-rwxr-xr-xcommands/test47
9 files changed, 229 insertions, 8 deletions
diff --git a/commands/bug-report b/commands/bug-report
index 05f02ec..cb60b14 100755
--- a/commands/bug-report
+++ b/commands/bug-report
@@ -1,7 +1,7 @@
#!/bin/sh
-scriptsdir=`dirname "$0"`
-rootdir=`dirname "$scriptsdir"`
+commandsdir=`dirname "$0"`
+rootdir=`dirname "$commandsdir"`
buildlogsdir=$rootdir/logs
sugarlogsdir=~/.sugar/default/logs
tarfile=$buildlogsdir/all-logs.tar.bz2
diff --git a/commands/helpers/find-free-display.c b/commands/helpers/find-free-display.c
new file mode 100644
index 0000000..4a07131
--- /dev/null
+++ b/commands/helpers/find-free-display.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <X11/extensions/Xrandr.h>
+
+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
new file mode 100755
index 0000000..8165920
--- /dev/null
+++ b/commands/helpers/get-screen-dpi
@@ -0,0 +1,6 @@
+#!/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
new file mode 100644
index 0000000..183258c
--- /dev/null
+++ b/commands/helpers/list-outputs.c
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <X11/extensions/Xrandr.h>
+
+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
new file mode 100755
index 0000000..2925d2f
--- /dev/null
+++ b/commands/helpers/run-with-keyring
@@ -0,0 +1,12 @@
+#!/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/xinitrc b/commands/helpers/xinitrc
new file mode 100644
index 0000000..9cb52c8
--- /dev/null
+++ b/commands/helpers/xinitrc
@@ -0,0 +1,58 @@
+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=`</dev/urandom tr -cd A-Za-z0-9 | head -c10`
+ echo "PROFILE=$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 $RESOLUTION ]; then
+ xrandr -s $RESOLUTION
+fi
+
+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 b1f76aa..0b485b5 100755
--- a/commands/run
+++ b/commands/run
@@ -1,9 +1,40 @@
-#!/usr/bin/python
+#!/bin/bash
-import common
-import sys
+commandsdir=`dirname "$0"`
+helpersdir=$commandsdir/helpers
+rootdir=`dirname "$commandsdir"`
+display=`$helpersdir/find-free-display`
-from devbot import run
+if [ -f $rootdir/config ]; then
+ source $rootdir/config
+fi
-common.setup()
-run.run(sys.argv[1:])
+if [ -n $SUGAR_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/config
+ if [ $? -eq 1 ]; then
+ randomstring=`</dev/urandom tr -cd A-Za-z0-9 | head -c10`
+ echo "PROFILE=$randomstring" >> $ROOT_DIR/config
+ 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"
+
+ if [ -z $RUN_IN_WINDOW ]; then
+ xephyr_options="$xephyr_options -fullscreen"
+ fi
+
+ xinit $helpersdir/xinitrc -- /usr/bin/Xephyr $display $xephyr_options
+fi
diff --git a/commands/run-command b/commands/run-command
new file mode 100755
index 0000000..b1f76aa
--- /dev/null
+++ b/commands/run-command
@@ -0,0 +1,9 @@
+#!/usr/bin/python
+
+import common
+import sys
+
+from devbot import run
+
+common.setup()
+run.run(sys.argv[1:])
diff --git a/commands/test b/commands/test
new file mode 100755
index 0000000..3378691
--- /dev/null
+++ b/commands/test
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+commandsdir=`dirname "$0"`
+helpersdir=$commandsdir/helpers
+rootdir=`dirname "$helpersdir"`
+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_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