From a6238e079b4e8e62d3e23f019e0895c626133c83 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Thu, 25 Jun 2015 03:35:16 +0000 Subject: Bug 1144485: Adapt upstream Selenium test suite to BMO --- qa/t/selenium_server_start.t | 83 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 qa/t/selenium_server_start.t (limited to 'qa/t/selenium_server_start.t') diff --git a/qa/t/selenium_server_start.t b/qa/t/selenium_server_start.t new file mode 100644 index 000000000..c08db293c --- /dev/null +++ b/qa/t/selenium_server_start.t @@ -0,0 +1,83 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +use strict; +use warnings; + +use constant DISPLAY => 99; +#use constant DISPLAY => 0; + +use Test::More tests => 12; +#use Test::More tests => 4; + +my $pid; + +# Start the Xvfb server first +$pid = xserver_start(); +ok($pid, "X Server started with PID $pid on display " . DISPLAY); +ok(open(XPID, ">testing.x.pid"), "Opening testing.x.pid"); +ok((print XPID $pid), "Writing testing.x.pid"); +ok(close(XPID), "Closing testing.x.pid"); + +# Start the VNC service second +ok($pid = vnc_start(), "VNC desktop started with PID $pid"); +ok(open(VNCPID, ">testing.vnc.pid"), "Opening testing.vnc.pid"); +ok((print VNCPID $pid), "Writing testing.vnc.pid"); +ok(close(VNCPID), "Closing testing.vnc.pid"); + +# Start the selenium server third +ok($pid = selenium_start(), "Selenium RC server started with PID $pid"); +ok(open(SPID, ">testing.selenium.pid"), "Opening testing.selenium.pid"); +ok((print SPID $pid), "Writing testing.selenium.pid"); +ok(close(SPID), "Closing testing.selenium.pid"); + +sleep(10); + +# Subroutines + +sub xserver_start { + my $pid; + my @x_cmd = qw(Xvfb -ac -screen 0 1600x1200x24 -fbdir /tmp); + push(@x_cmd, ":" . DISPLAY); + $pid = fork(); + if (!$pid) { + open(STDOUT, ">/dev/null"); + open(STDERR, ">/dev/null"); + exec(@x_cmd) || die "unable to execute: $!"; + } + else { + return $pid; + } + return 0; +} + +sub vnc_start { + my @vnc_cmd = qw(x11vnc -viewonly -forever -nopw -quiet -display); + push(@vnc_cmd, ":" . DISPLAY); + my $pid = fork(); + if (!$pid) { + open(STDOUT, ">/dev/null"); + open(STDERR, ">/dev/null"); + exec(@vnc_cmd) || die "unabled to execute: $!"; + } + return $pid; +} + +sub selenium_start { + my @selenium_cmd = qw(java -jar ../config/selenium-server-standalone.jar + -firefoxProfileTemplate ../config/firefox + -log ../config/selenium.log + -singlewindow); + unshift(@selenium_cmd, "env", "DISPLAY=:" . DISPLAY); + my $pid = fork(); + if (!$pid) { + open(STDOUT, ">/dev/null"); + open(STDERR, ">/dev/null"); + exec(@selenium_cmd) || die "unable to execute: $!"; + } + return $pid; +} -- cgit v1.2.3-24-g4f1b