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_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 enabled(self): # See if fglrx is the current alternative target_alternative = self._alternatives.get_alternative_by_name( 'fglrx') current_alternative = self._alternatives.get_current_alternative() other_target_alternative = self._other_alternatives.get_alternative_by_name( 'fglrx') other_current_alternative = self._other_alternatives.get_current_alternative( ) logging.debug( 'fglrx.enabled(%s): target_alt %s current_alt %s other target alt %s other current alt %s', self.module, target_alternative, current_alternative, other_target_alternative, other_current_alternative) if current_alternative is None: logging.debug('current alternative of %s is None, not enabled', self.module) return False if current_alternative != target_alternative or \ other_current_alternative != other_target_alternative: logging.debug('%s is not the alternative in use', self.module) return False return XorgDriverHandler.enabled(self)
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_check_composite_noavail(self): '''calling with --check-composite and no available driver''' sys.argv = ['ui-test', '--check-composite'] ui = sandbox.TestUI() h = XorgDriverHandler(ui, 'vanilla3d', 'mesa-vanilla', 'v3d', 'vanilla') self.failIf(h.enabled()) ui.backend().handlers[h.id()] = h self.assertEqual(ui.run(), 1) self.stop_capture() self.assert_('no available' in self.stderr)
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_check_composite_noavail(self): '''calling with --check-composite and no available driver''' sys.argv = ['ui-test', '--check-composite'] ui = sandbox.TestUI() h = XorgDriverHandler(ui, 'vanilla3d', 'mesa-vanilla', 'v3d', 'vanilla') self.failIf(h.enabled()) ui.backend().handlers[h.id()] = h self.assertEqual(ui.run(), 1) self.stop_capture() self.assert_('no available' in self.stderr)
def enabled(self): # See if cdv is the current alternative target_alternative = \ self._alternatives.get_alternative_by_name(self.alternative_name) current_alternative = self._alternatives.get_current_alternative() logging.debug('cdv.enabled(%s): target_alt %s current_alt %s', self.module, target_alternative, current_alternative) if current_alternative is None: logging.debug('current alternative of %s is None, not enabled', self.module) return False if current_alternative != target_alternative: logging.debug('%s is not the alternative in use', self.module) return False return XorgDriverHandler.enabled(self)
def enabled(self): # See if pvr-omap4 is the current alternative target_alternative = \ self._alternatives.get_alternative_by_name(self.pkg_alternative) current_alternative = self._alternatives.get_current_alternative() logging.debug('pvr-omap4.enabled(%s): target_alt %s current_alt %s', self.module, target_alternative, current_alternative) if current_alternative is None: logging.debug('current alternative of %s is None, not enabled', self.pkg_alternative) return False if current_alternative != target_alternative: logging.debug('%s is not the alternative in use', self.pkg_alternative) return False return XorgDriverHandler.enabled(self)
def enabled(self): # See if fglrx is the current alternative target_alternative = self._alternatives.get_alternative_by_name(self.package) current_alternative = self._alternatives.get_current_alternative() other_target_alternative = self._other_alternatives.get_alternative_by_name(self.package) other_current_alternative = self._other_alternatives.get_current_alternative() logging.debug('fglrx.enabled(%s): target_alt %s current_alt %s other target alt %s other current alt %s', self.module, target_alternative, current_alternative, other_target_alternative, other_current_alternative) if current_alternative is None: logging.debug('current alternative of %s is None, not enabled', self.module) return False if current_alternative != target_alternative or \ other_current_alternative != other_target_alternative: logging.debug('%s is not the alternative in use', self.module) return False return XorgDriverHandler.enabled(self)
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))