[gnome-settings-daemon] tests: Check whether an Xorg instance is already running



commit c9b7bdd0b95743e9245aab57e5b4c0ec39bf462a
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jan 24 14:27:45 2013 +0100

    tests: Check whether an Xorg instance is already running
    
    From an old test for example, otherwise we would silently fail to
    start X.org.

 tests/gsdtestcase.py |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/tests/gsdtestcase.py b/tests/gsdtestcase.py
index de146d0..3dd902e 100644
--- a/tests/gsdtestcase.py
+++ b/tests/gsdtestcase.py
@@ -201,12 +201,18 @@ class GSDTestCase(dbusmock.DBusTestCase):
         xorg = os.path.join(klass.workdir, 'Xorg')
         shutil.copy(out, xorg)
 
+        display_num = 99
+
+        if os.path.isfile('/tmp/.X%d-lock' % display_num):
+            sys.stderr.write('Cannot start X.org, an instance already exists\n')
+            sys.exit(1)
+
         # You can rename the log file to *.log if you want to see it on test
         # case failures
         log = os.path.join(klass.workdir, 'Xorg.out')
-        klass.xorg = subprocess.Popen([xorg, '-config', conf, '-logfile', log, ':99'],
+        klass.xorg = subprocess.Popen([xorg, '-config', conf, '-logfile', log, ':%d' % display_num],
                                       stderr=subprocess.PIPE)
-        os.environ['DISPLAY'] = ':99'
+        os.environ['DISPLAY'] = ':%d' % display_num
 
         # wait until the server is ready
         timeout = 50



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]