How to use mkinitrd method in autotest

Best Python code snippet using autotest_python

make_ramboot_initrd_test.py

Source:make_ramboot_initrd_test.py Github

copy

Full Screen

1#!/usr/bin/python2#3# Copyright (C) 2011 Google Inc.4#5# This program is free software; you can redistribute it and/or modify6# it under the terms of the GNU General Public License as published by7# the Free Software Foundation; either version 2 of the License, or8# (at your option) any later version.9#10# This program is distributed in the hope that it will be useful, but11# WITHOUT ANY WARRANTY; without even the implied warranty of12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13# General Public License for more details.14#15# You should have received a copy of the GNU General Public License16# along with this program; if not, write to the Free Software17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA18# 02110-1301, USA.19"""Tests for make_ramboot_initrd."""20import os21import platform22import shutil23import tempfile24import unittest25import mox26import make_ramboot_initrd as mkinitrd27class MakeRambootInitrdTest(unittest.TestCase):28 SRCDIR = os.environ.get("SRCDIR", ".")29 MOVETORAM = os.path.join(SRCDIR, "test", "testdata", "movetoram")30 def setUp(self):31 self.mox = mox.Mox()32 self.conf_dir = tempfile.mkdtemp()33 self.install_dir = tempfile.mkdtemp()34 self.test_filename = "test"35 self.test_file_contents = "test"36 self.test_filepath = os.path.join(self.conf_dir, self.test_filename)37 self.dirs_to_remove = [self.conf_dir, self.install_dir]38 os.makedirs(os.path.join(self.conf_dir, "scripts", "local-bottom"))39 test_file = open(self.test_filepath, "w")40 test_file.write(self.test_file_contents)41 test_file.close()42 os.chmod(self.conf_dir, 0755)43 os.chmod(self.test_filepath, 0644)44 self.temp_dir, self.new_conf_dir = mkinitrd.CreateTempDir(self.conf_dir)45 self.dirs_to_remove.append(self.temp_dir)46 def tearDown(self):47 self.mox.UnsetStubs()48 self.mox.ResetAll()49 for d in self.dirs_to_remove:50 if d and os.path.isdir(d):51 shutil.rmtree(d)52 def testCreateTempDirCopiesFiles(self):53 self.assertTrue(os.path.isdir(self.temp_dir))54 self.assertTrue(os.path.isdir(self.new_conf_dir))55 filename = os.path.join(self.new_conf_dir, self.test_filename)56 self.assertTrue(os.path.isfile(filename))57 f = open(filename, "r")58 contents = f.read(5)59 self.assertEqual(self.test_file_contents, contents)60 f.close()61 def testCreateTempDirPermissions(self):62 # Ensure that only the user running the script can see into the directory63 # from which the initrd is being built64 # No one but the user should see into the temp dir65 tdmode = os.stat(self.temp_dir).st_mode & 077766 self.assertEqual(0700, tdmode)67 # The user must be able to access the subdirectory, but it doesn't matter68 # if others can as they can't get into the parent directory69 ncdmode = os.stat(self.new_conf_dir).st_mode & 070070 self.assertEqual(0700, ncdmode)71 filename = os.path.join(self.new_conf_dir, self.test_filename)72 filemode = os.stat(filename).st_mode & 077773 self.assertEqual(0644, filemode)74 def testCreateTempDirHandlesPermissionDenied(self):75 self.mox.StubOutWithMock(mkinitrd.tempfile, "mkdtemp")76 self.mox.StubOutWithMock(mkinitrd.shutil, "copytree")77 tempdirname = "/tmp/12345"78 confdirname = os.path.join(tempdirname, "initramfs-tools")79 mkinitrd.tempfile.mkdtemp().AndReturn(tempdirname)80 mkinitrd.shutil.copytree(self.conf_dir,81 confdirname).AndRaise(OSError("Permission denied"))82 self.mox.ReplayAll()83 # Make sure we fail if user can't read conf_dir84 self.assertRaises(mkinitrd.Error, mkinitrd.CreateTempDir, self.conf_dir)85 self.mox.VerifyAll()86 def testInstallInitrdHandlesPermissionDenied(self):87 self.mox.StubOutWithMock(mkinitrd.shutil, "copy")88 mkinitrd.shutil.copy(self.test_filepath,89 self.install_dir).AndRaise(OSError("Denied"))90 self.mox.ReplayAll()91 # Make sure we fail if user can't write boot_dir92 try:93 self.assertRaises(mkinitrd.Error, mkinitrd.InstallInitrd,94 self.test_filepath, # file to copy95 self.install_dir, # where to put it96 self.test_filename) # name of file97 except (OSError, IOError):98 self.fail()99 self.mox.VerifyAll()100 def testInstallInitrdHandlesExistingFile(self):101 # Make sure that we ask for confirmation if boot_dir/file_name exists102 dest_filename = os.path.join(self.install_dir, self.test_filename)103 open(dest_filename, "a").close() # Create file104 self.assertRaises(mkinitrd.Error, mkinitrd.InstallInitrd,105 self.test_filepath, # file to copy (would be the initrd)106 self.install_dir, # where to put it107 self.test_filename) # name of file108 def testInstallInitrdInstallsFile(self):109 mkinitrd.InstallInitrd(self.test_filepath, # file to copy110 self.install_dir, # where to put it111 self.test_filename) # name of file112 dest_filename = os.path.join(self.install_dir, self.test_filename)113 self.assertTrue(os.path.isfile(dest_filename))114 filemode = os.stat(dest_filename).st_mode & 0777115 self.assertEqual(0644, filemode)116 def testCleanUpRemovesFiles(self):117 mkinitrd.CleanUp(self.temp_dir)118 self.assertFalse(os.path.exists(self.temp_dir))119 def testCleanUpHandlesMissingDir(self):120 mkinitrd.CleanUp(self.temp_dir)121 try:122 mkinitrd.CleanUp(self.temp_dir) # should be no error even doing it twice123 except (OSError, IOError):124 self.fail()125 def testCleanUpQuitsCleanlyOnError(self):126 self.mox.StubOutWithMock(mkinitrd.shutil, "rmtree")127 mkinitrd.shutil.rmtree(self.temp_dir).AndRaise(OSError("Permission denied"))128 self.mox.ReplayAll()129 self.assertRaises(SystemExit, mkinitrd.CleanUp, self.temp_dir)130 self.mox.VerifyAll()131 def testAddScriptCreatesCorrectScript(self):132 dest_filename = os.path.join(self.new_conf_dir, "scripts",133 "local-bottom", "movetoram")134 try:135 mkinitrd.AddScript(self.new_conf_dir)136 except mkinitrd.Error:137 self.fail() # should not produce error on normal conf dir138 self.assertTrue(os.path.isfile(dest_filename))139 src_file = open(self.MOVETORAM, "r")140 dst_file = open(dest_filename, "r")141 src_contents = src_file.read(500)142 dst_contents = dst_file.read(500)143 self.assertEqual(src_contents, dst_contents)144 def testAddScriptDetectsImproperConfigDir(self):145 os.rmdir(os.path.join(self.new_conf_dir, "scripts", "local-bottom"))146 self.assertRaises(mkinitrd.Error, mkinitrd.AddScript, self.new_conf_dir)147 def testBuildInitrdRunsCommand(self):148 self.mox.StubOutWithMock(mkinitrd.subprocess, "call")149 self.mox.StubOutWithMock(os.path, "exists")150 test_name = "testinitrd"151 test_tmp = os.path.join("/tmp", "test_makeinitrd")152 test_out = os.path.join(test_tmp, test_name)153 test_conf = os.path.join(test_tmp, "conf")154 test_version = "2.6-test"155 mkinitrd.subprocess.call(["mkinitramfs", "-d", test_conf,156 "-o", test_out, test_version]).AndReturn(0)157 self.mox.ReplayAll()158 try:159 mkinitrd.BuildInitrd(test_tmp, test_conf, test_name, test_version, False)160 except mkinitrd.Error:161 self.fail()162 self.mox.VerifyAll()163 def testBuildInitrdRaisesErrorOnFailure(self):164 self.mox.StubOutWithMock(mkinitrd.subprocess, "call")165 self.mox.StubOutWithMock(os.path, "exists")166 test_name = "testinitrd"167 test_tmp = os.path.join("/tmp", "test_makeinitrd")168 test_out = os.path.join(test_tmp, test_name)169 test_conf = os.path.join(test_tmp, "conf")170 test_version = "2.6-test"171 mkinitrd.subprocess.call(["mkinitramfs", "-d", test_conf,172 "-o", test_out, test_version]).AndReturn(1)173 os.path.exists(os.path.join("/lib/modules", test_version)).AndReturn(False)174 self.mox.ReplayAll()175 self.assertRaises(mkinitrd.Error, mkinitrd.BuildInitrd, test_tmp,176 test_conf, test_name, test_version, False)177 self.mox.VerifyAll()178 def testParseArgsHandlesArgsCorrectly(self):179 old_conf_dir = "/etc/new-initramfs-tools"180 boot_dir = "/boot/subdir"181 file_name = "testinitrd.img"182 version = "2.6-test"183 argv = ["make_ramboot_initrd_test.py", "-d", old_conf_dir, "-v",184 "-n", file_name, "-b", boot_dir, "-V", version]185 options = mkinitrd.ParseOptions(argv)186 self.assertEqual(file_name, options.file_name)187 self.assertEqual(boot_dir, options.boot_dir)188 self.assertTrue(options.verbose)189 self.assertEqual(old_conf_dir, options.conf_dir)190 self.assertFalse(options.keep_temp)191 self.assertFalse(options.overwrite)192 self.assertEqual(version, options.version)193 def testParseArgsHandlesNoArgsCorrectly(self):194 argv = ["make_ramboot_initrd_test.py"]195 options = mkinitrd.ParseOptions(argv)196 expected_version = platform.release()197 self.assertEqual(expected_version, options.version)198 self.assertEqual("initrd.img-%s-ramboot" % expected_version,199 options.file_name)200 self.assertEqual("/boot", options.boot_dir)201 self.assertFalse(options.verbose)202 self.assertEqual("/etc/initramfs-tools", options.conf_dir)203 self.assertFalse(options.keep_temp)204 self.assertFalse(options.overwrite)205 def testParseArgsHandlesWeirdScriptName(self):206 # make sure it doesn't get thrown off by being called with a strange name207 argv = ["-v"] # called with -v as script name208 options = mkinitrd.ParseOptions(argv)209 self.assertFalse(options.verbose)210 def testMainHandlesOptions(self):211 old_conf_dir = "/etc/new-initramfs-tools"212 temp_dir = "/tmp/abcde"213 new_conf_dir = os.path.join(temp_dir, "confdir")214 temp_out = os.path.join(temp_dir, "initrd")215 boot_dir = self.install_dir216 file_name = "testinitrd.img"217 version = "2.6-test"218 self.mox.StubOutWithMock(mkinitrd, "CreateTempDir")219 self.mox.StubOutWithMock(mkinitrd, "AddScript")220 self.mox.StubOutWithMock(mkinitrd, "BuildInitrd")221 self.mox.StubOutWithMock(mkinitrd, "InstallInitrd")222 self.mox.StubOutWithMock(mkinitrd, "CleanUp")223 mkinitrd.CreateTempDir(old_conf_dir).AndReturn((temp_dir, new_conf_dir))224 mkinitrd.AddScript(new_conf_dir)225 mkinitrd.BuildInitrd(temp_dir, new_conf_dir, file_name,226 version, False).AndReturn(temp_out)227 mkinitrd.InstallInitrd(temp_out, boot_dir, file_name, False)228 mkinitrd.CleanUp(temp_dir)229 self.mox.ReplayAll()230 argv = ["make_ramboot_initrd_test.py", "-d", old_conf_dir, "-v",231 "-n", file_name, "-b", boot_dir, "-V", version]232 mkinitrd.main(argv)233 self.mox.VerifyAll()234 def testMainHandlesNoOptions(self):235 old_conf_dir = "/etc/initramfs-tools"236 temp_dir = "/tmp/abcde"237 new_conf_dir = os.path.join(temp_dir, "confdir")238 temp_out = os.path.join(temp_dir, "initrd")239 boot_dir = self.install_dir # specify this because it must be writable240 version = platform.release()241 file_name = "initrd.img-%s-ramboot" % version242 self.mox.StubOutWithMock(mkinitrd, "CreateTempDir")243 self.mox.StubOutWithMock(mkinitrd, "AddScript")244 self.mox.StubOutWithMock(mkinitrd, "BuildInitrd")245 self.mox.StubOutWithMock(mkinitrd, "InstallInitrd")246 self.mox.StubOutWithMock(mkinitrd, "CleanUp")247 mkinitrd.CreateTempDir(old_conf_dir).AndReturn((temp_dir, new_conf_dir))248 mkinitrd.AddScript(new_conf_dir)249 mkinitrd.BuildInitrd(temp_dir, new_conf_dir, file_name,250 version, False).AndReturn(temp_out)251 mkinitrd.InstallInitrd(temp_out, boot_dir, file_name, False)252 mkinitrd.CleanUp(temp_dir)253 self.mox.ReplayAll()254 argv = ["make_ramboot_initrd_test.py", "-b", boot_dir]255 mkinitrd.main(argv)256 self.mox.VerifyAll()257 def testMainHandlesError(self):258 old_conf_dir = "/etc/initramfs-tools"259 temp_dir = "/tmp/abcde"260 new_conf_dir = os.path.join(temp_dir, "confdir")261 boot_dir = self.install_dir262 version = platform.release()263 file_name = "initrd.img-%s-ramboot" % version264 self.mox.StubOutWithMock(mkinitrd, "CreateTempDir")265 self.mox.StubOutWithMock(mkinitrd, "AddScript")266 self.mox.StubOutWithMock(mkinitrd, "BuildInitrd")267 self.mox.StubOutWithMock(mkinitrd, "InstallInitrd")268 self.mox.StubOutWithMock(mkinitrd, "CleanUp")269 mkinitrd.CreateTempDir(old_conf_dir).AndReturn((temp_dir, new_conf_dir))270 mkinitrd.AddScript(new_conf_dir)271 mkinitrd.BuildInitrd(temp_dir, new_conf_dir, file_name,272 version, False).AndRaise(mkinitrd.Error("test!"))273 mkinitrd.CleanUp(temp_dir)274 self.mox.ReplayAll()275 argv = ["make_ramboot_initrd_test.py", "-b", boot_dir]276 self.assertRaises(SystemExit, mkinitrd.main, argv)277 self.mox.VerifyAll()278 def testMainExitsEarlyIfInstallDirUnwritable(self):279 # none of these should be called, because there's no point in doing280 # the work if you're going to discard it later281 self.mox.StubOutWithMock(mkinitrd, "CreateTempDir")282 self.mox.StubOutWithMock(mkinitrd, "AddScript")283 self.mox.StubOutWithMock(mkinitrd, "BuildInitrd")284 self.mox.StubOutWithMock(mkinitrd, "InstallInitrd")285 self.mox.StubOutWithMock(mkinitrd, "CleanUp")286 self.mox.StubOutWithMock(mkinitrd.os, "access")287 mkinitrd.os.access(self.install_dir, mkinitrd.os.W_OK).AndReturn(False)288 mkinitrd.CleanUp(None)289 self.mox.ReplayAll()290 argv = ["make_ramboot_initrd_test.py", "-b", self.install_dir]291 self.assertRaises(SystemExit, mkinitrd.main, argv)292 self.mox.VerifyAll()293 def testMainExitsEarlyIfFileExists(self):294 # none of these should be called, because there's no point in doing295 # the work if you're going to discard it later296 self.mox.StubOutWithMock(mkinitrd, "CreateTempDir")297 self.mox.StubOutWithMock(mkinitrd, "AddScript")298 self.mox.StubOutWithMock(mkinitrd, "BuildInitrd")299 self.mox.StubOutWithMock(mkinitrd, "InstallInitrd")300 self.mox.StubOutWithMock(mkinitrd, "CleanUp")301 mkinitrd.CleanUp(None)302 self.mox.ReplayAll()303 dest_filename = os.path.join(self.install_dir, self.test_filename)304 open(dest_filename, "a").close() # Create file305 argv = ["make_ramboot_initrd_test.py", "-b", self.install_dir,306 "-n", self.test_filename]307 self.assertRaises(SystemExit, mkinitrd.main, argv)308 self.mox.VerifyAll()309if __name__ == "__main__":...

Full Screen

Full Screen

SConstruct

Source:SConstruct Github

copy

Full Screen

1import os2import sys3import datetime4SetOption('num_jobs', 4)5build = "debug"6# Use host machine compiler to build special tools7# like mkinitrd8build_host = True9# Travis CI does not support host c++11 compiler10if "CI" in os.environ:11 build_host = False12config = {13 "project_name": "runtimejs",14 "build_host": build_host,15 "binary_output_file": "disk/boot/runtime",16 "toolchain_bin_path": "",17 "fasm_pathname": "fasm",18 "link_script": "etc/kernel.ld",19 "name_gxx": "g++",20 "name_gcc": "gcc",21 "name_as": "as",22 "name_ld": "gcc",23 "name_ar": "ar",24 "name_ranlib": "ranlib",25 "name_objcopy": "objcopy",26 "flags_common": {27 "shared": set([28 '-m64',29 '-fpermissive',30 '-ffreestanding',31 '-nostdlib',32 '-mno-red-zone',33 '-mno-mmx',34 '-mno-sse3',35 '-mno-3dnow',36 '-nodefaultlibs',37 '-nostartfiles',38 '-Wall',39 '-Wextra',40 '-Wno-unused',41 '-fno-exceptions',42 '-Wno-unused-parameter',43 '-D__runtime_js__',44 '-DRUNTIMEJS_PLATFORM_X64',45 ]),46 "release": set([47 ]),48 "debug": set([49 '-g',50 '-ggdb',51 ]),52 },53 "flags_gxx": {54 "shared": set([55 '-nostdinc++',56 '-std=c++11',57 '-O3',58 '-fno-tree-vectorize', # misaligned movdqa %xmm1,(%rsp) generated without this option and O359 '-fno-rtti',60 '-U__STRICT_ANSI__',61 '-DENABLE_DEBUGGER_SUPPORT',62 '-DENABLE_DISASSEMBLER',63 '-DV8_HOST_ARCH_X64',64 '-DV8_TARGET_ARCH_X64',65 # '-DVERIFY_HEAP',66 # '-DDEBUG',67 # '-DOBJECT_PRINT',68 # '-DENABLE_EXTRA_CHECKS',69 # '-DENABLE_HANDLE_ZAPPING',70 ]),71 "release": set([72 ]),73 "debug": set([74 ]),75 },76 "flags_gcc": {77 "shared": set([78 '-O2',79 '-c',80 '-std=c99',81 '-D_XOPEN_SOURCE=700',82 ]),83 "release": set([84 ]),85 "debug": set([86 ]),87 },88 "flags_link": set([89 '-nostdlib',90 '-nodefaultlibs',91 # '-Map etc/map.txt',92 ]),93 "locations": {94 "cc": [95 'src',96 'src/arch',97 'src/kernel',98 'src/kernel/x64',99 'src/kernel/profiler',100 'src/common',101 'test/cc',102 ],103 "asm": [104 'src',105 'src/kernel/x64',106 ],107 "js": [108 'src/kernel/Js',109 ],110 },111 "includes": [112 'deps/musl/src/internal',113 'deps/musl/include',114 'deps/musl/arch/x86_64',115 'deps/musl/arch/x86_64/bits',116 'deps/libcxx/include',117 'deps/v8/include',118 'deps/v8',119 'deps/concurrentqueue',120 'deps/acpica/source/include',121 'deps/printf',122 'src',123 'test',124 ],125 "libs": [126 'v8',127 'cxx',128 'acpica',129 'printf',130 'musl',131 'gcc',132 'gcc_s',133 ],134}135def CreateToolchainPath(binpath, name):136 return os.path.join(binpath, name);137def CombineFlagsBuild(name, build):138 return config[name]["shared"] | config[name][build]139def EnvironmentCreate(build):140 gxx = CreateToolchainPath(config["toolchain_bin_path"], config["name_gxx"])141 gcc = CreateToolchainPath(config["toolchain_bin_path"], config["name_gcc"])142 ar = CreateToolchainPath(config["toolchain_bin_path"], config["name_ar"])143 ranlib = CreateToolchainPath(config["toolchain_bin_path"], config["name_ranlib"])144 _as = CreateToolchainPath(config["toolchain_bin_path"], config["name_as"])145 ld = CreateToolchainPath(config["toolchain_bin_path"], config["name_ld"])146 fasm = config["fasm_pathname"]147 flags_shared = CombineFlagsBuild("flags_common", build)148 flags_gxx = flags_shared | CombineFlagsBuild("flags_gxx", build)149 flags_gcc = flags_shared | CombineFlagsBuild("flags_gcc", build)150 proj_name = config["project_name"]151 asm_builder = Builder(152 action = fasm + ' $SOURCE $TARGET >/dev/null',153 single_source = 1,154 suffix = '.asm_o',155 src_suffix = '.asm'156 )157 js_builder = Builder(158 action = 'xxd -i < $SOURCE > $TARGET; echo ",0x00" >> $TARGET',159 single_source = 1,160 suffix = '.js.h',161 src_suffix = '.js'162 )163 env = Environment(164 CXX = gxx,165 CC = gcc,166 AR = ar,167 AS = _as,168 RANLIB = ranlib,169 CXXFLAGS = " ".join(flags_gxx),170 CFLAGS = " ".join(flags_gcc),171 LINK = ld,172 LINKFLAGS = '-T ' + config["link_script"] + ' ' + ' '.join(config["flags_link"]) + ' -o ' + proj_name,173 CXXCOMSTR = '[cross] Build $TARGET',174 LINKCOMSTR = '[cross] Link $TARGET',175 RANLIBCOMSTR = '[cross] Index $TARGET',176 ARCOMSTR = '[cross] Archive $TARGET',177 ENV = {'PATH': os.environ['PATH']},178 )179 env.Append(180 BUILDERS = {181 'asm': asm_builder,182 'js': js_builder,183 }184 )185 return env186def EnvironmentCreateHost():187 hostenv = Environment(188 CXXFLAGS = '-std=c++11 -O3',189 CPPPATH = ['src', 'deps/printf'],190 OBJSUFFIX = '.host',191 CXXCOMSTR = '[host] Build $TARGET',192 LINKCOMSTR = '[host] Link $TARGET',193 RANLIBCOMSTR = '[host] Index $TARGET',194 ARCOMSTR = '[host] Archive $TARGET',195 ENV = {'PATH': os.environ['PATH']},196 )197 return hostenv198def BuildMkinitrd(hostenv):199 return hostenv.Program('mkinitrd', ['src/mkinitrd/mkinitrd.cc', 'src/common/package.cc', 'src/common/crc64.cc'])200def BuildTestsHost(hostenv):201 hostenv.Program('test-host', ['test/hostcc/test-host.cc', 'deps/printf/printf.cc'])202 return203def BuildProject(env_base, mkinitrd):204 env = env_base.Clone();205 sources = {}206 for ext, dirs in config["locations"].items():207 if ext not in sources:208 sources[ext] = []209 for d in dirs:210 path = os.path.join(d, "*."+ext)211 sources[ext].append(Glob(path))212 obj_asm = [env.asm(i) for i in sources["asm"]]213 env.Depends(obj_asm, Glob('src/*.inc'))214 obj_js = [env.js(i) for i in sources["js"]]215 env.Replace(CPPPATH = config["includes"])216 env.Replace(LIBS = config["libs"])217 env.Replace(LIBPATH = ['deps'])218 proj_name = config["project_name"]219 env.Depends(proj_name, obj_js);220 env.Depends(proj_name, config["link_script"])221 output_elf = env.Program(proj_name, sources["cc"] + obj_asm)222 binary_output = config["binary_output_file"]223 objcopy = CreateToolchainPath(config["toolchain_bin_path"], config["name_objcopy"])224 output_bin = env.Command(binary_output, '',225 objcopy + ' -O binary --strip-all --set-section-flags \'.bss\'=alloc,load,contents,data ' +226 proj_name + ' ' + binary_output)227 env.Depends(output_bin, output_elf);228 if mkinitrd is not None:229 initrd = env.Command('disk/boot/initrd', '', './makeinitrd.sh')230 env.Depends(initrd, Glob('initrd/*.*'))231 env.Depends(initrd, Glob('initrd/*/*.*'))232 env.Depends(initrd, Glob('initrd/*/*/*.*'))233 env.Depends(initrd, Glob('initrd/*/*/*/*.*'))234 env.Depends(initrd, mkinitrd)235 env.Depends(output_bin, initrd);236 return237mkinitrd = None238# Build mkinitrd tool239if config["build_host"]:240 env_host = EnvironmentCreateHost()241 mkinitrd = BuildMkinitrd(env_host)242 BuildTestsHost(env_host)243# Build kernel244env_base = EnvironmentCreate(build)245SConscript('deps/SConscript', exports = 'env_base')...

Full Screen

Full Screen

initrd.py

Source:initrd.py Github

copy

Full Screen

1import argparse2import os.path3import pbs4import shutil5import subprocess6description = 'build initial ramdisk'7usage = 'initrd [options]'8summary = ''9def exec(project, *args):10 parser = argparse.ArgumentParser()11 parser.add_argument('--output', '-o')12 args = parser.parse_args(args[1:])13 sysroot = os.path.join(pbs.objtree, 'sysroot')14 initrd = os.path.join(pbs.objtree, 'initrd')15 mkinitrd = os.path.join(sysroot, 'usr/bin/mkinitrd')16 if not os.path.exists(mkinitrd):17 pbs.log.error('%s not found' % mkinitrd)18 return19 if os.path.exists(initrd):20 pbs.log.begin('removing %s...' % initrd)21 shutil.rmtree(initrd)22 pbs.log.end('done')23 if args.output:24 output = args.output25 else:26 output = 'initrd.gz'27 command = [ mkinitrd, '--output', output, sysroot, initrd ]28 pbs.log.info('creating initial ramdisk:', ' '.join(command))29 with subprocess.Popen(command, stdout=subprocess.PIPE,30 stderr=subprocess.STDOUT) as proc:31 while True:32 line = proc.stdout.readline()33 if not line:34 break35 line = line.decode()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful