def test_basic(self): """grab_driver_files: copy drivers into place, return module list""" # create a bunch of fake extracted files outdir = self.tmpdir + '/extract-outdir' moddir = outdir + "/lib/modules/%s/kernel/" % os.uname()[2] fwdir = outdir + "/lib/firmware/" modules = makefiles(moddir+"net/funk.ko", moddir+"fs/lolfs.ko.xz") firmware = makefiles(fwdir+"funk.fw") makefiles(outdir+"/usr/bin/monkey", outdir+"/other/dir/blah.ko") mod_upd_dir = self.tmpdir+'/module-updates' fw_upd_dir = self.tmpdir+'/fw-updates' # use our updates dirs instead of the default updates dirs with mock.patch.multiple("driver_updates", MODULE_UPDATES_DIR=mod_upd_dir, FIRMWARE_UPDATES_DIR=fw_upd_dir): modnames = grab_driver_files(outdir) self.assertEqual(set(modnames), set(["funk", "lolfs"])) modfiles = set(['funk.ko', 'lolfs.ko.xz']) fwfiles = set(['funk.fw']) # modules/firmware are *not* in their old locations self.assertEqual([f for f in modules+firmware if os.path.exists(f)], []) # modules are in the system's updates dir self.assertEqual(set(os.listdir(mod_upd_dir)), modfiles) # modules are also in outdir's updates dir self.assertEqual(set(os.listdir(outdir+'/'+mod_upd_dir)), modfiles) # repeat for firmware self.assertEqual(set(os.listdir(fw_upd_dir)), fwfiles) self.assertEqual(set(os.listdir(outdir+'/'+fw_upd_dir)), fwfiles)
def test_basic(self): """grab_driver_files: copy drivers into place, return module+alias dict""" # create a bunch of fake extracted files outdir = self.tmpdir + '/extract-outdir' moddir = outdir + "/lib/modules/%s/kernel/" % os.uname()[2] fwdir = outdir + "/lib/firmware/" modules = makefiles(moddir + "net/funk.ko", moddir + "fs/lolfs.ko.xz") firmware = makefiles(fwdir + "funk.fw", fwdir + "fs/lolfs.fw") makefiles(outdir + "/usr/bin/monkey", outdir + "/other/dir/blah.ko") mod_upd_dir = self.tmpdir + '/module-updates' fw_upd_dir = self.tmpdir + '/fw-updates' # use our updates dirs instead of the default updates dirs with mock.patch.multiple("driver_updates", MODULE_UPDATES_DIR=mod_upd_dir, FIRMWARE_UPDATES_DIR=fw_upd_dir, list_aliases=lambda _x: []): moddict = grab_driver_files(outdir) self.assertEqual(moddict, {"funk": [], "lolfs": []}) modfiles = set(['net/funk.ko', 'fs/lolfs.ko.xz']) fwfiles = set(['funk.fw', 'fs/lolfs.fw']) # modules/firmware are *not* in their old locations self.assertEqual([f for f in modules + firmware if os.path.exists(f)], []) # modules are in the system's updates dir self.assertEqual(set(listfiles(mod_upd_dir)), modfiles) # modules are also in outdir's updates dir self.assertEqual(set(listfiles(outdir + '/' + mod_upd_dir)), modfiles) # repeat for firmware self.assertEqual(set(listfiles(fw_upd_dir)), fwfiles) self.assertEqual(set(listfiles(outdir + '/' + fw_upd_dir)), fwfiles)