Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--Makefile.commands8
-rw-r--r--Makefile.helpers15
-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
-rwxr-xr-xcommands/helpers/test50
-rwxr-xr-xcommands/helpers/xephyr-window.c58
-rw-r--r--commands/helpers/xinitrc54
-rwxr-xr-xcommands/run52
-rwxr-xr-xcommands/run-command9
-rwxr-xr-xcommands/test49
-rw-r--r--config/modules/sugar.json4
-rw-r--r--devbot/config.py23
-rw-r--r--devbot/environ.py4
-rw-r--r--devbot/run.py22
17 files changed, 114 insertions, 311 deletions
diff --git a/Makefile b/Makefile
index 6cf2901..91c3519 100644
--- a/Makefile
+++ b/Makefile
@@ -8,5 +8,4 @@ all: check-system pull build
include Makefile.config
include Makefile.commands
-include Makefile.helpers
include Makefile.buildbot
diff --git a/Makefile.commands b/Makefile.commands
index 04f228c..238a19a 100644
--- a/Makefile.commands
+++ b/Makefile.commands
@@ -12,19 +12,19 @@ pull:
build:
@$(COMMANDS_DIR)/build
-run: helpers-build
+run:
@$(COMMANDS_DIR)/run
-test: helpers-build
+test:
@$(COMMANDS_DIR)/test
-shell: helpers-build
+shell:
@$(COMMANDS_DIR)/shell
bug-report:
@$(COMMANDS_DIR)/bug-report
-clean: helpers-clean
+clean:
@$(COMMANDS_DIR)/clean
build-%:
diff --git a/Makefile.helpers b/Makefile.helpers
deleted file mode 100644
index 79f30eb..0000000
--- a/Makefile.helpers
+++ /dev/null
@@ -1,15 +0,0 @@
-.PHONY: helpers-build helpers-clean
-
-HELPERS_LIBS = $(shell pkg-config --libs xrandr x11)
-
-$(HELPERS)/%: $(HELPERS)/%.c
- gcc -o $@ $< $(HELPERS_LIBS)
-
-bin_HELPERS = $(HELPERS_DIR)/list-outputs \
- $(HELPERS_DIR)/find-free-display \
- $(HELPERS_DIR)/xephyr-window
-
-helpers-build: $(bin_HELPERS)
-
-helpers-clean:
- rm -f $(bin_HELPERS)
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 <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
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 <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
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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-
-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=`</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 $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=`</dev/urandom tr -cd A-Za-z0-9 | head -c10`
- echo "PROFILE=$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")])
diff --git a/config/modules/sugar.json b/config/modules/sugar.json
index 511455a..496dba7 100644
--- a/config/modules/sugar.json
+++ b/config/modules/sugar.json
@@ -42,5 +42,9 @@
"name": "gst-plugins-espeak",
"out-of-source": false,
"repo": "git://git.sugarlabs.org/gst-plugins-espeak/mainline.git"
+ },
+ {
+ "name": "sugar-runner",
+ "repo": "git://git.sugarlabs.org/sugar-runner/sugar-runner.git"
}
]
diff --git a/devbot/config.py b/devbot/config.py
index d5e1a74..7b9978c 100644
--- a/devbot/config.py
+++ b/devbot/config.py
@@ -171,20 +171,37 @@ def set_prefs_path(path):
global prefs_path
prefs_path = path
-def get_pref(name):
- prefs = {}
+def _read_prefs():
+ global prefs_path
if not os.path.exists(prefs_path):
- return None
+ return {}
+ prefs = {}
with open(prefs_path) as f:
for line in f.readlines():
splitted = line.strip().split("=")
if len(splitted) == 2:
prefs[splitted[0]] = splitted[1]
+ return prefs
+
+def _save_prefs(prefs):
+ global prefs_path
+
+ with open(prefs_path, "w") as f:
+ for pref in prefs.items():
+ f.write("%s\n" % "=".join(pref))
+
+def get_pref(name):
+ prefs = _read_prefs()
return prefs.get(name, None)
+def set_pref(name, value):
+ prefs = _read_prefs()
+ prefs[name] = value
+ _save_prefs(prefs)
+
def load_plugins():
for loader, name, ispkg in pkgutil.iter_modules(plugins.__path__):
f, filename, desc = imp.find_module(name, plugins.__path__)
diff --git a/devbot/environ.py b/devbot/environ.py
index 5879995..2107792 100644
--- a/devbot/environ.py
+++ b/devbot/environ.py
@@ -58,6 +58,10 @@ def _setup_variables():
os.environ["GTK_DATA_PREFIX"] = config.prefix_dir
os.environ["GTK_PATH"] = os.path.join(config.lib_dir, "gtk-2.0")
+ profile = config.get_pref("PROFILE")
+ if profile is not None:
+ os.environ["SUGAR_PROFILE"] = profile
+
def _setup_gconf():
gconf_dir = os.path.join(config.etc_dir, "gconf")
gconf_pathdir = os.path.join(gconf_dir, "2")
diff --git a/devbot/run.py b/devbot/run.py
index 1bbe695..451da96 100644
--- a/devbot/run.py
+++ b/devbot/run.py
@@ -1,9 +1,29 @@
#!/usr/bin/python -u
import os
+import string
+import random
from devbot import environ
+from devbot import config
-def run_command(args):
+def run(args):
environ.setup()
os.execlp(args[0], *args)
+
+def run_sugar():
+ profile_env = os.environ.get("SUGAR_PROFILE", None)
+ profile_pref = config.get_pref("PROFILE")
+
+ if profile_env is not None:
+ if profile_pref is None:
+ config.set_pref("PROFILE", _get_random_id())
+ elif profile_pref == profile_env:
+ print "Cannot run two instances with the same profile."
+ return
+
+ run(["sugar-runner"])
+
+def _get_random_id():
+ return ''.join(random.choice(string.letters) for i in xrange(8))
+