def disable(self): XorgDriverHandler.disable(self) # Set the alternative back to open drivers open_drivers = self._alternatives.get_open_egl_drivers_alternative() logging.debug('pvr-omap4.disable(%s): open_drivers: %s', self.module, open_drivers) if open_drivers: self._alternatives.set_alternative(open_drivers) return False
def test_xorg_invalid_conf(self): '''XorgDriverHandler with invalid xorg.conf''' # append some breakage f = open(OSLib.inst.xorg_conf_path, 'a') print >> f, ''' EndSection Section "Module" EndSection ''' f.close() h = XorgDriverHandler(self.backend, 'vanilla3d', 'mesa-vanilla', 'v3d', 'vanilla', extra_conf_options={'SuperSpeed': 'true'}, add_modules=['glx'], disable_modules=['dri2'], remove_modules=['dri'], name='Vanilla accelerated graphics driver') self.assertEqual(h.name(), 'Vanilla accelerated graphics driver') self.assertEqual(h.description(), OSLib.inst.package_description('mesa-vanilla')[1]) self.assertEqual(h.rationale(), None) self.failIf(h.free()) self.failIf(h.changed()) self.assert_('xorg.conf is invalid' in h.can_change()) self.failIf(h.enabled()) self.assertEqual(h.available(), None) self.failIf(h.enable()) self.failIf(h.changed()) self.failIf(h.enabled()) self.failIf(h.disable()) self.failIf(h.changed()) self.failIf(h.enabled())
def test_xorg_driver_nobackup(self): """XorgDriverHandler with no xorg.conf backup""" h = XorgDriverHandler( self.backend, "vanilla3d", "mesa-vanilla", "v3d", "vanilla", extra_conf_options={"SuperSpeed": "true"}, add_modules=["glx"], disable_modules=["dri2"], remove_modules=["dri"], name="Vanilla accelerated graphics driver", ) self.failIf(h.enable()) conf = open(OSLib.inst.xorg_conf_path).read() self.assert_(re.search('^\s*driver\s*"v3d"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*option\s*"SuperSpeed"\s*"true"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*load\s*"glx"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*disable\s*"dri2"\s*$', conf, re.I | re.M)) self.failIf(re.search('^\s*load\s*"dri"\s*$', conf, re.I | re.M)) # unlink backup file os.unlink(os.path.join(OSLib.inst.backup_dir, "v3d.oldconf")) self.failIf(h.disable()) conf = open(OSLib.inst.xorg_conf_path).read() self.assert_(re.search('^\s*driver\s*"vanilla"\s*$', conf, re.I | re.M)) self.failIf("SuperSpeed" in conf) self.failIf(re.search('^\s*load\s*"glx"\s*$', conf, re.I | re.M)) # modules which were explicitly disabled should be removed self.failIf(re.search('^\s*disable\s*"dri2"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*load\s*"dri"\s*$', conf, re.I | re.M))
def disable(self): XorgDriverHandler.disable(self) # make sure that 'cedarview-drm' is removed too self.backend.remove_package('cedarview-drm') # Set the alternative back to open drivers open_drivers = self._alternatives.get_open_drivers_alternative() logging.debug('cdv.disable(%s): open_drivers: %s', self.module, open_drivers) if open_drivers: self._alternatives.set_alternative(open_drivers) subprocess.call(['update-initramfs', '-u']) subprocess.call(['update-initramfs', '-u', '-k', os.uname()[2]]) return False
def test_xorg_driver_nobackup_nodriver(self): '''XorgDriverHandler with no xorg.conf backup and no explicit "Driver"''' h = XorgDriverHandler(self.backend, 'vanilla3d', 'mesa-vanilla', None, None, extra_conf_options={'SuperSpeed': 'true'}, add_modules=['glx'], disable_modules=['dri2'], remove_modules=['dri'], name='Vanilla accelerated graphics driver') self.failIf(h.enable()) conf = open(OSLib.inst.xorg_conf_path).read() # should keep the "Driver" as it was before self.assert_(re.search('^\s*driver\s*"vanilla"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*option\s*"SuperSpeed"\s*"true"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*load\s*"glx"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*disable\s*"dri2"\s*$', conf, re.I|re.M)) self.failIf(re.search('^\s*load\s*"dri"\s*$', conf, re.I|re.M)) # unlink backup file os.unlink(os.path.join(OSLib.inst.backup_dir, 'mesa-vanilla.oldconf')) self.failIf(h.disable()) conf = open(OSLib.inst.xorg_conf_path).read() self.assert_(re.search('^\s*driver\s*"vanilla"\s*$', conf, re.I|re.M)) self.failIf('SuperSpeed' in conf) self.failIf(re.search('^\s*load\s*"glx"\s*$', conf, re.I|re.M)) # modules which were explicitly disabled should be removed self.failIf(re.search('^\s*disable\s*"dri2"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*load\s*"dri"\s*$', conf, re.I|re.M))
def test_xorg_driver_enable_all_one_serverlayout(self): '''XorgDriverHandler enable the proprietary driver with one ServerLayout in xorg.conf''' os.unlink(OSLib.inst.xorg_conf_path) f = open(OSLib.inst.xorg_conf_path, 'a') print >> f, ''' Section "Device" Identifier "Graphics card 1" Driver "via" EndSection Section "Device" Identifier "Graphics card 2" Driver "via" EndSection Section "Screen" Identifier "Screen 1" Device "Graphics card 1" EndSection Section "Screen" Identifier "Screen 2" Device "Graphics card 2" EndSection Section "ServerLayout" Identifier "Another Layout" Screen "Screen 2" EndSection ''' f.close() h = XorgDriverHandler(self.backend, 'vanilla3d', 'mesa-vanilla', 'v3d', 'vanilla', extra_conf_options={'SuperSpeed': 'true'}, add_modules=['glx'], disable_modules=['dri2'], remove_modules=['dri'], name='Vanilla accelerated graphics driver') # only the 2nd device section should have the driver changed self.failIf(h.enable()) conf = open(OSLib.inst.xorg_conf_path).read() self.assert_(re.search('^\s*driver\s*"v3d"\s*$', conf, re.I|re.M)) self.failIf(re.search('^\s*driver\s*"vanilla"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*driver\s*"via"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*option\s*"SuperSpeed"\s*"true"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*load\s*"glx"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*disable\s*"dri2"\s*$', conf, re.I|re.M)) self.failIf(re.search('^\s*load\s*"dri"\s*$', conf, re.I|re.M)) # backup file should have been created self.assert_(os.path.isfile(os.path.join(OSLib.inst.backup_dir, 'v3d.oldconf'))) # disabling should restore xorg.conf self.failIf(h.disable()) conf = open(OSLib.inst.xorg_conf_path).read() self.failIf(re.search('^\s*driver\s*"v3d"\s*$', conf, re.I|re.M)) self.failIf(re.search('^\s*driver\s*"vanilla"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*driver\s*"via"\s*$', conf, re.I|re.M))
def test_xorg_driver_modules(self): '''XorgDriverHandler with default Modules xorg.conf section''' # append a Module section f = open(OSLib.inst.xorg_conf_path, 'a') print >> f, ''' Section "Module" Load "dri" SubSection "extmod" Option "omit xfree86-dga" EndSubSection Load "foo" EndSection ''' f.close() h = XorgDriverHandler(self.backend, 'vanilla3d', 'mesa-vanilla', 'v3d', 'vanilla', extra_conf_options={'SuperSpeed': 'true'}, add_modules=['glx'], disable_modules=['dri2'], remove_modules=['dri'], name='Vanilla accelerated graphics driver') self.assertEqual(h.name(), 'Vanilla accelerated graphics driver') self.assertEqual(h.description(), OSLib.inst.package_description('mesa-vanilla')[1]) self.assertEqual(h.rationale(), None) self.failIf(h.free()) self.failIf(h.changed()) self.assertEqual(h.can_change(), None) self.failIf(h.enabled()) self.assertEqual(h.available(), None) self.failIf(h.enable()) self.assert_(h.changed()) self.assert_(h.enabled()) self.assert_(OSLib.inst.package_installed('mesa-vanilla')) self.failIf(OSLib.inst.module_blacklisted('vanilla3d')) conf = open(OSLib.inst.xorg_conf_path).read() self.assert_(re.search('^\s*driver\s*"v3d"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*option\s*"SuperSpeed"\s*"true"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*load\s*"glx"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*disable\s*"dri2"\s*$', conf, re.I|re.M)) self.failIf(re.search('^\s*load\s*"dri"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*load\s*"foo"\s*$', conf, re.I|re.M)) # unlink backup file os.unlink(os.path.join(OSLib.inst.backup_dir, 'v3d.oldconf')) # should restore module dri, drop glx and remove dri2 self.failIf(h.disable()) self.assert_(h.changed()) self.failIf(h.enabled()) self.failIf(OSLib.inst.package_installed('mesa-vanilla')) self.assert_(OSLib.inst.module_blacklisted('vanilla3d')) conf = open(OSLib.inst.xorg_conf_path).read() self.failIf(re.search('^\s*load\s*"glx"\s*$', conf, re.I|re.M)) self.failIf(re.search('^\s*disable\s*"dri2"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*load\s*"dri"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*load\s*"foo"\s*$', conf, re.I|re.M))
def test_xorg_driver_nomodules(self): '''XorgDriverHandler with no default Modules xorg.conf section''' h = XorgDriverHandler(self.backend, 'vanilla3d', 'mesa-vanilla', 'v3d', 'vanilla', extra_conf_options={'SuperSpeed': 'true'}, add_modules=['glx'], disable_modules=['dri2'], remove_modules=['dri'], name='Vanilla accelerated graphics driver') orig_xorg_conf = open(OSLib.inst.xorg_conf_path).read() self.assertEqual(h.name(), 'Vanilla accelerated graphics driver') self.assertEqual(h.id(), 'xorg:vanilla3d') self.assertEqual(h.description(), OSLib.inst.package_description('mesa-vanilla')[1]) self.assertEqual(h.rationale(), None) self.failIf(h.free()) self.failIf(h.changed()) self.assertEqual(h.can_change(), None) self.failIf(h.enabled()) self.failIf(h.used()) self.assertEqual(h.available(), None) self.failIf(h.enables_composite()) self.failIf(h.enable()) self.assert_(h.changed()) self.failIf(h.used()) # X.org needs to be restarted for this to work self.assert_(h.enabled()) self.assert_(OSLib.inst.package_installed('mesa-vanilla')) self.failIf(OSLib.inst.module_blacklisted('vanilla3d')) conf = open(OSLib.inst.xorg_conf_path).read() self.assert_(re.search('^\s*driver\s*"v3d"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*option\s*"SuperSpeed"\s*"true"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*load\s*"glx"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*disable\s*"dri2"\s*$', conf, re.I|re.M)) self.failIf(re.search('^\s*load\s*"dri"\s*$', conf, re.I|re.M)) # driver should be used when loading the module (done in enable()) and # starting jockey again h2 = XorgDriverHandler(self.backend, 'vanilla3d', 'mesa-vanilla', 'v3d', 'vanilla', extra_conf_options={'SuperSpeed': 'true'}, add_modules=['glx'], disable_modules=['dri2'], remove_modules=['dri'], name='Vanilla accelerated graphics driver') self.assert_(h2.enabled()) self.assert_(h2.used()) self.failIf(h.disable()) self.assert_(h.changed()) self.failIf(h.enabled()) self.failIf(h.used()) # wasn't used after enabling self.failIf(OSLib.inst.package_installed('mesa-vanilla')) self.assert_(OSLib.inst.module_blacklisted('vanilla3d')) # restores original backup self.assertEqual(open(OSLib.inst.xorg_conf_path).read(), orig_xorg_conf) # vendor h.driver_vendor = 'Foo Bar' self.assertEqual(h.id(), 'xorg:vanilla3d:Foo_Bar')
def disable(self): # make sure that fglrx-kernel-source is removed too XorgDriverHandler.disable(self) #kernel_source = 'fglrx-kernel-source' #self.backend.remove_package(kernel_source) # Set the alternative back to open drivers open_drivers = self._alternatives.get_open_drivers_alternative() logging.debug('fglrx.disable(%s): open_drivers: %s', self.module, open_drivers) if open_drivers: self._alternatives.set_alternative(open_drivers) other_open_drivers = self._other_alternatives.get_open_drivers_alternative() logging.debug('fglrx.disable(%s): other_open_drivers: %s', self.module, other_open_drivers) if other_open_drivers: self._other_alternatives.set_alternative(other_open_drivers) subprocess.call(['update-initramfs', '-u']) subprocess.call(['update-initramfs', '-u', '-k', os.uname()[2]]) return False
def disable(self): XorgDriverHandler.disable(self) if self.package: try: self.backend.remove_package('nvidia-settings') except SystemError: pass # Set the alternative back to open drivers open_drivers = self._alternatives.get_open_drivers_alternative() logging.debug('NVidia.disable(%s): open_drivers: %s', self.module, open_drivers) if open_drivers: self._alternatives.set_alternative(open_drivers) other_open_drivers = self._other_alternatives.get_open_drivers_alternative() logging.debug('NVidia.disable(%s): other_open_drivers: %s', self.module, other_open_drivers) if other_open_drivers: self._other_alternatives.set_alternative(other_open_drivers) subprocess.call(['update-initramfs', '-u']) subprocess.call(['update-initramfs', '-u', '-k', os.uname()[2]]) return False
def test_xorg_driver_enable_all_no_serverlayout(self): """XorgDriverHandler enable the proprietary driver without ServerLayout in xorg.conf""" os.unlink(OSLib.inst.xorg_conf_path) f = open(OSLib.inst.xorg_conf_path, "a") print >> f, """ Section "Device" Identifier "Graphics card 1" Driver "via" EndSection Section "Device" Identifier "Graphics card 2" Driver "via" EndSection """ f.close() h = XorgDriverHandler( self.backend, "vanilla3d", "mesa-vanilla", "v3d", "vanilla", extra_conf_options={"SuperSpeed": "true"}, add_modules=["glx"], disable_modules=["dri2"], remove_modules=["dri"], name="Vanilla accelerated graphics driver", ) # all drivers will be changed self.failIf(h.enable()) conf = open(OSLib.inst.xorg_conf_path).read() self.assert_(re.search('^\s*driver\s*"v3d"\s*$', conf, re.I | re.M)) self.failIf(re.search('^\s*driver\s*"vanilla"\s*$', conf, re.I | re.M)) self.failIf(re.search('^\s*driver\s*"via"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*option\s*"SuperSpeed"\s*"true"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*load\s*"glx"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*disable\s*"dri2"\s*$', conf, re.I | re.M)) self.failIf(re.search('^\s*load\s*"dri"\s*$', conf, re.I | re.M)) # backup file should have been created self.assert_(os.path.isfile(os.path.join(OSLib.inst.backup_dir, "v3d.oldconf"))) # disabling should restore xorg.conf self.failIf(h.disable()) conf = open(OSLib.inst.xorg_conf_path).read() self.failIf(re.search('^\s*driver\s*"v3d"\s*$', conf, re.I | re.M)) self.failIf(re.search('^\s*driver\s*"vanilla"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*driver\s*"via"\s*$', conf, re.I | re.M))
def disable(self): XorgDriverHandler.disable(self) if self.package: try: self.backend.remove_package('nvidia-settings') except SystemError: pass # Set the alternative back to open drivers open_drivers = self._alternatives.get_open_drivers_alternative() logging.debug('NVidia.disable(%s): open_drivers: %s', self.module, open_drivers) if open_drivers: self._alternatives.set_alternative(open_drivers) other_open_drivers = self._other_alternatives.get_open_drivers_alternative( ) logging.debug('NVidia.disable(%s): other_open_drivers: %s', self.module, other_open_drivers) if other_open_drivers: self._other_alternatives.set_alternative(other_open_drivers) subprocess.call(['update-initramfs', '-u']) subprocess.call(['update-initramfs', '-u', '-k', os.uname()[2]]) return False
def test_xorg_driver_no_xorgconf(self): """XorgDriverHandler without a default xorg.conf""" os.unlink(OSLib.inst.xorg_conf_path) h = XorgDriverHandler( self.backend, "vanilla3d", "mesa-vanilla", "v3d", "vanilla", extra_conf_options={"SuperSpeed": "true"}, add_modules=["glx"], disable_modules=["dri2"], remove_modules=["dri"], name="Vanilla accelerated graphics driver", ) self.failIf(h.free()) self.failIf(h.changed()) self.assertEqual(h.can_change(), None) # should create an xorg.conf from scratch self.failIf(h.enabled()) self.assertEqual(h.available(), None) self.failIf(h.enable()) self.assert_(h.changed()) self.assert_(h.enabled()) self.assert_(OSLib.inst.package_installed("mesa-vanilla")) self.failIf(OSLib.inst.module_blacklisted("vanilla3d")) conf = open(OSLib.inst.xorg_conf_path).read() self.assert_(re.search('^\s*driver\s*"v3d"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*option\s*"SuperSpeed"\s*"true"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*load\s*"glx"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*disable\s*"dri2"\s*$', conf, re.I | re.M)) self.failIf(re.search('^\s*load\s*"dri"\s*$', conf, re.I | re.M)) # should remove xorg.conf again self.failIf(h.disable()) self.assert_(h.changed()) self.failIf(h.enabled()) self.failIf(OSLib.inst.package_installed("mesa-vanilla")) self.assert_(OSLib.inst.module_blacklisted("vanilla3d")) self.failIf(os.path.exists(OSLib.inst.xorg_conf_path))
def test_xorg_invalid_conf(self): """XorgDriverHandler with invalid xorg.conf""" # append some breakage f = open(OSLib.inst.xorg_conf_path, "a") print >> f, """ EndSection Section "Module" EndSection """ f.close() h = XorgDriverHandler( self.backend, "vanilla3d", "mesa-vanilla", "v3d", "vanilla", extra_conf_options={"SuperSpeed": "true"}, add_modules=["glx"], disable_modules=["dri2"], remove_modules=["dri"], name="Vanilla accelerated graphics driver", ) self.assertEqual(h.name(), "Vanilla accelerated graphics driver") self.assertEqual(h.description(), OSLib.inst.package_description("mesa-vanilla")[1]) self.assertEqual(h.rationale(), None) self.failIf(h.free()) self.failIf(h.changed()) self.assert_("xorg.conf is invalid" in h.can_change()) self.failIf(h.enabled()) self.assertEqual(h.available(), None) self.failIf(h.enable()) self.failIf(h.changed()) self.failIf(h.enabled()) self.failIf(h.disable()) self.failIf(h.changed()) self.failIf(h.enabled())
def test_xorg_driver_existing_proprietary(self): '''XorgDriverHandler backup with the proprietary driver already in xorg.conf''' f = open(OSLib.inst.xorg_conf_path, 'a') print >> f, ''' Section "Device" Identifier "Graphics card 1" Driver "via" EndSection Section "Device" Identifier "Graphics card 2" Driver "v3d" EndSection ''' f.close() h = XorgDriverHandler(self.backend, 'vanilla3d', 'mesa-vanilla', 'v3d', 'vanilla', extra_conf_options={'SuperSpeed': 'true'}, add_modules=['glx'], disable_modules=['dri2'], remove_modules=['dri'], name='Vanilla accelerated graphics driver') self.failIf(h.enable()) conf = open(OSLib.inst.xorg_conf_path).read() self.assert_(re.search('^\s*driver\s*"v3d"\s*$', conf, re.I|re.M)) self.failIf(re.search('^\s*driver\s*"vanilla"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*driver\s*"via"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*option\s*"SuperSpeed"\s*"true"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*load\s*"glx"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*disable\s*"dri2"\s*$', conf, re.I|re.M)) self.failIf(re.search('^\s*load\s*"dri"\s*$', conf, re.I|re.M)) # no backup file should have been created self.failIf(os.path.isfile(os.path.join(OSLib.inst.backup_dir, 'v3d.oldconf'))) # disabling should restore xorg.conf self.failIf(h.disable()) conf = open(OSLib.inst.xorg_conf_path).read() self.assert_(re.search('^\s*driver\s*"v3d"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*driver\s*"vanilla"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*driver\s*"via"\s*$', conf, re.I|re.M))
def test_xorg_driver_no_xorgconf_nodriver(self): '''XorgDriverHandler without a default xorg.conf and no explicit "Driver"''' os.unlink(OSLib.inst.xorg_conf_path) h = XorgDriverHandler(self.backend, 'vanilla3d', 'mesa-vanilla', None, None, extra_conf_options={'SuperSpeed': 'true'}, add_modules=['glx'], disable_modules=['dri2'], name='Vanilla accelerated graphics driver') self.failIf(h.free()) self.failIf(h.changed()) self.assertEqual(h.can_change(), None) # should create an xorg.conf from scratch self.failIf(h.enabled()) self.assertEqual(h.available(), None) self.failIf(h.enable()) self.assert_(h.changed()) self.assert_(h.enabled()) self.assert_(OSLib.inst.package_installed('mesa-vanilla')) self.failIf(OSLib.inst.module_blacklisted('vanilla3d')) conf = open(OSLib.inst.xorg_conf_path).read() self.failIf(re.search('^\s*driver', conf, re.I|re.M)) self.assert_(re.search('^\s*option\s*"SuperSpeed"\s*"true"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*load\s*"glx"\s*$', conf, re.I|re.M)) self.assert_(re.search('^\s*disable\s*"dri2"\s*$', conf, re.I|re.M)) self.failIf(re.search('^\s*load\s*"dri"\s*$', conf, re.I|re.M)) # should remove xorg.conf again self.failIf(h.disable()) self.assert_(h.changed()) self.failIf(h.enabled()) self.failIf(OSLib.inst.package_installed('mesa-vanilla')) self.assert_(OSLib.inst.module_blacklisted('vanilla3d')) self.failIf(os.path.exists(OSLib.inst.xorg_conf_path))
def test_xorg_driver_enable_all_more_serverlayouts(self): """XorgDriverHandler enable the proprietary driver with more ServerLayouts in xorg.conf""" os.unlink(OSLib.inst.xorg_conf_path) f = open(OSLib.inst.xorg_conf_path, "a") print >> f, """ Section "Device" Identifier "Graphics card 1" Driver "via" EndSection Section "Device" Identifier "Graphics card 2" Driver "via" EndSection Section "Screen" Identifier "Screen 1" Device "Graphics card 1" EndSection Section "Screen" Identifier "Screen 2" Device "Graphics card 2" EndSection Section "ServerLayout" Identifier "Default Layout" Option "Whatever" Screen "Screen 1" 0 0 Screen "Screen 2" RightOf "Screen 1" EndSection Section "ServerLayout" Identifier "Another Layout" Option "Whatever" Screen "Screen 2" 0 0 EndSection Section "ServerFlags" Option "DefaultServerLayout" "Another Layout" EndSection """ f.close() h = XorgDriverHandler( self.backend, "vanilla3d", "mesa-vanilla", "v3d", "vanilla", extra_conf_options={"SuperSpeed": "true"}, add_modules=["glx"], disable_modules=["dri2"], remove_modules=["dri"], name="Vanilla accelerated graphics driver", ) # the 2nd serverlayout is used, therefore only the 2nd device section must be # changed self.failIf(h.enable()) conf = open(OSLib.inst.xorg_conf_path).read() self.assert_(re.search('^\s*driver\s*"v3d"\s*$', conf, re.I | re.M)) self.failIf(re.search('^\s*driver\s*"vanilla"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*driver\s*"via"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*option\s*"SuperSpeed"\s*"true"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*load\s*"glx"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*disable\s*"dri2"\s*$', conf, re.I | re.M)) self.failIf(re.search('^\s*load\s*"dri"\s*$', conf, re.I | re.M)) # backup file should have been created self.assert_(os.path.isfile(os.path.join(OSLib.inst.backup_dir, "v3d.oldconf"))) # disabling should restore xorg.conf self.failIf(h.disable()) conf = open(OSLib.inst.xorg_conf_path).read() self.failIf(re.search('^\s*driver\s*"v3d"\s*$', conf, re.I | re.M)) self.failIf(re.search('^\s*driver\s*"vanilla"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*driver\s*"via"\s*$', conf, re.I | re.M))
def test_xorg_driver_modules(self): """XorgDriverHandler with default Modules xorg.conf section""" # append a Module section f = open(OSLib.inst.xorg_conf_path, "a") print >> f, """ Section "Module" Load "dri" SubSection "extmod" Option "omit xfree86-dga" EndSubSection Load "foo" EndSection """ f.close() h = XorgDriverHandler( self.backend, "vanilla3d", "mesa-vanilla", "v3d", "vanilla", extra_conf_options={"SuperSpeed": "true"}, add_modules=["glx"], disable_modules=["dri2"], remove_modules=["dri"], name="Vanilla accelerated graphics driver", ) self.assertEqual(h.name(), "Vanilla accelerated graphics driver") self.assertEqual(h.description(), OSLib.inst.package_description("mesa-vanilla")[1]) self.assertEqual(h.rationale(), None) self.failIf(h.free()) self.failIf(h.changed()) self.assertEqual(h.can_change(), None) self.failIf(h.enabled()) self.assertEqual(h.available(), None) self.failIf(h.enable()) self.assert_(h.changed()) self.assert_(h.enabled()) self.assert_(OSLib.inst.package_installed("mesa-vanilla")) self.failIf(OSLib.inst.module_blacklisted("vanilla3d")) conf = open(OSLib.inst.xorg_conf_path).read() self.assert_(re.search('^\s*driver\s*"v3d"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*option\s*"SuperSpeed"\s*"true"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*load\s*"glx"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*disable\s*"dri2"\s*$', conf, re.I | re.M)) self.failIf(re.search('^\s*load\s*"dri"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*load\s*"foo"\s*$', conf, re.I | re.M)) # unlink backup file os.unlink(os.path.join(OSLib.inst.backup_dir, "v3d.oldconf")) # should restore module dri, drop glx and remove dri2 self.failIf(h.disable()) self.assert_(h.changed()) self.failIf(h.enabled()) self.failIf(OSLib.inst.package_installed("mesa-vanilla")) self.assert_(OSLib.inst.module_blacklisted("vanilla3d")) conf = open(OSLib.inst.xorg_conf_path).read() self.failIf(re.search('^\s*load\s*"glx"\s*$', conf, re.I | re.M)) self.failIf(re.search('^\s*disable\s*"dri2"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*load\s*"dri"\s*$', conf, re.I | re.M)) self.assert_(re.search('^\s*load\s*"foo"\s*$', conf, re.I | re.M))