diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-07-29 12:33:19 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-08-02 15:09:32 +1000 |
commit | b4d3cd4fe605f3c8c41721bc7344e67d80bf0008 (patch) | |
tree | e78ed0786a8e0374e4dcdd42fbdaa56540aecf02 | |
parent | 91f6d649ae6151fd410511dc4c2117be87705dc3 (diff) |
XST: Add Test for basic xorg.conf driver.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | ILTest/XST/XOrgConfDriver.pm | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/ILTest/XST/XOrgConfDriver.pm b/ILTest/XST/XOrgConfDriver.pm new file mode 100644 index 0000000..1906b0f --- /dev/null +++ b/ILTest/XST/XOrgConfDriver.pm @@ -0,0 +1,143 @@ +#!/usr/bin/perl + +# Copyright © 2011 by Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# Authors: Peter Hutterer <peter.hutterer@redhat.com> + + +=head1 NAME + +ILtest::XST::xorgconf-driver - ILTest for xorg.conf devices + +=head1 DESCRIPTION + +This ILTest::TestCase configures the X Server to use a specific driver input +device and then checks for this device's presence in the server. + +=head2 Paramaters + +=over + +=item B<driver> + +The driver to be used. Required parameter. + +=item B<identifier> + +The identifier for this device. If unset, the identifier is "$driver +identifier". + +=back + +=cut + +package ILTest::XST::XOrgConfDriver; + +use ILTest::TestCase; +use ILTest::Error; + +use XOrg::xorgconf; +use XOrg::xorglog; + +use warnings; +use strict; + +our @ISA = qw(ILTest::TestCase); + +sub pre { + my $self = shift; + + my $driver = $self->parameters->{driver}; + my $identifier = $self->parameters->{identifier}; + my %opts; + + if (not defined $driver) { + return ILTest::Error->new(msg => "Driver required but not defined\n"); + } + + $identifier = "$driver identifier" if not defined $identifier; + + $self->iltest->file_backup("/etc/X11/xorg.conf"); + + for (keys %{$self->{parameters}}) { + next if $_ eq "driver"; + next if $_ eq "identifier"; + $opts{$_} = $self->{parameters}->{$_}; + } + + my $conf = XOrg::xorgconf->new(); + $conf->add_serverlayout("driver testing layout", {"AutoAddDevices" => "off"}); + $conf->add_input_device($identifier, $driver, \%opts); + + $self->{identifier} = $identifier; + $self->{driver} = $driver; + + $self->iltest->print(7, $conf->print); + if (not $conf->save) { + return ILTest::Error->new(msg => "Failed to write config\n"); + } + + return undef; +} + +sub run { + my $self = shift; + my $log = XOrg::xorglog->new(file=> "/var/log/Xorg.0.log"); + + my $server = $log->server; + my $driver = $self->{driver}; + my $identifier = $self->{identifier}; + + + if (not defined $server->modules->{$driver}) { + return ILTest::Error->new(msg => "Unable to find module $driver.\n"); + } + + if ($server->auto_add_devices) { + return ILTest::Error->new(msg => "AAD is on but should be off.\n"); + } + + my @devices = @{$server->devices}; + + my $found = 0; + for (@devices) { + $self->iltest->println(8, "Found device '".$_->name."' present: ". $_->present); + next if $_->name ne $identifier; + next if not $_->present; + + $found = 1; + last; + } + + + if (not $found) { + return ILTest::Error->new(msg => "Could not find device '$identifier' in log\n"); + } + + return undef; +} + +sub post { + my $self = shift; + + $self->iltest->file_restore("/etc/X11/xorg.conf"); + + return undef; +} + +1; +# vim: set noexpandtab shiftwidth=8 tabstop=8: |