GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Unverified Commit e8453eb5 authored by boklm's avatar boklm

Run the tests inside an X Virtual FrameBuffer

parent 3993ab5f
......@@ -36,6 +36,9 @@ a virtualenv:
If you want to reinstall the virtualenv used, remove the 'virtualenv'
directory and run 'setup' again.
Unless you are using the '--no-xvfb' option, all tests will be run in
a virtual framebuffer with xvfb, so you need to have xvfb installed.
Usage
-----
......@@ -93,3 +96,10 @@ Available options
The default is the 'virtualenv' directory created by the 'setup'
script.
--no-xvfb
Don't run the tests using a virtual frame buffer X server.
--resolution=<resolution>
When using xvfb, this sets the default resolution. The default
is 1024x768.
......@@ -37,6 +37,8 @@ my %default_options = (
'tor-control-port' => '9551',
'tor-socks-port' => '9550',
virtualenv => "$FindBin::Bin/virtualenv",
resolution => '1024x768',
xvfb => 1,
);
my $options = get_options(@ARGV);
sub exit_error {
......@@ -48,7 +50,7 @@ sub exit_error {
sub get_options {
my @options = qw(mozmill! selenium! starttor! tor-control-port=i
tor-socks-port=i reports-dir=s gpgcheck! keyring=s
virtualenv=s);
virtualenv=s xvfb!);
my %res = %default_options;
Getopt::Long::GetOptionsFromArray(\@_, \%res, @options) || exit 1;
$res{files} = \@_;
......@@ -196,6 +198,14 @@ sub screenshot_thumbnail {
$image->Write("$dir/t-$name");
}
sub xvfb_run {
my ($test) = @_;
return () unless $options->{xvfb};
my $resolution = $test->{resolution} ? $test->{resolution}
: $options->{resolution};
return ('xvfb-run', '-s', "-screen 0 ${resolution}x24");
}
sub mozmill_run {
my ($test) = @_;
return unless $options->{mozmill};
......@@ -203,7 +213,7 @@ sub mozmill_run {
my $screenshots_tmp = File::Temp::newdir;
$ENV{'MOZMILL_SCREENSHOTS'} = $screenshots_tmp;
my $results_file = "$options->{tbbinfos}{'results-dir'}/$test->{name}.json";
system("$options->{virtualenv}/bin/mozmill", '-b',
system(xvfb_run($test), "$options->{virtualenv}/bin/mozmill", '-b',
"$options->{tbbdir}/Browser/firefox", '-p',
"$options->{tbbdir}/Data/Browser/profile.default", '-t',
"$FindBin::Bin/mozmill-tests/tbb-tests/$test->{name}.js",
......@@ -224,7 +234,7 @@ sub selenium_run {
return unless $options->{selenium};
my $result_file = $ENV{SELENIUM_TEST_RESULT_FILE} =
"$options->{tbbinfos}{'results-dir'}/$test->{name}.json";
system("$options->{virtualenv}/bin/python",
system(xvfb_run($test), "$options->{virtualenv}/bin/python",
"$FindBin::Bin/selenium-tests/run_test", $test->{name});
$test->{results} = decode_json(read_file($result_file));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment