def testArchiveGeneration(self): """Verifies BuildStandaloneImageArchive produces correct archives""" image_dir = os.path.join(self.tempdir, 'inputs') archive_dir = os.path.join(self.tempdir, 'outputs') files = ('a.bin', 'aa', 'b b b', 'c', 'dalsdkjfasdlkf',) osutils.SafeMakedirs(image_dir) osutils.SafeMakedirs(archive_dir) for f in files: osutils.Touch(os.path.join(image_dir, f)) # Check specifying tar functionality. artifact = {'paths': ['a.bin'], 'output': 'a.tar.gz', 'archive': 'tar', 'compress':'gz'} path = commands.BuildStandaloneArchive(archive_dir, image_dir, artifact) self.assertEquals(path, ['a.tar.gz']) cros_test_lib.VerifyTarball(os.path.join(archive_dir, path[0]), ['a.bin']) # Check multiple input files. artifact = {'paths': ['a.bin', 'aa'], 'output': 'aa.tar.gz', 'archive': 'tar', 'compress': 'gz'} path = commands.BuildStandaloneArchive(archive_dir, image_dir, artifact) self.assertEquals(path, ['aa.tar.gz']) cros_test_lib.VerifyTarball(os.path.join(archive_dir, path[0]), ['a.bin', 'aa']) # Check zip functionality. artifact = {'paths': ['a.bin'], 'archive': 'zip'} path = commands.BuildStandaloneArchive(archive_dir, image_dir, artifact) self.assertEquals(path, ['a.zip']) self.assertExists(os.path.join(archive_dir, path[0]))
def testBuildFirmwareArchive(self): """Verifies that firmware archiver includes proper files""" # Assorted set of file names, some of which are supposed to be included in # the archive. fw_files = ( 'dts/emeraldlake2.dts', 'image-link.rw.bin', 'nv_image-link.bin', 'pci8086,0166.rom', 'seabios.cbfs', 'u-boot.elf', 'u-boot_netboot.bin', 'updater-link.rw.sh', 'x86-memtest') # Files which should be included in the archive. fw_archived_files = ( 'dts/emeraldlake2.dts', 'image-link.rw.bin', 'nv_image-link.bin', 'updater-link.rw.sh') board = 'link' fw_test_root = os.path.join(self.tempdir, os.path.basename(__file__)) fw_files_root = os.path.join(fw_test_root, 'chroot/build/%s/firmware' % board) # Generate a representative set of files produced by a typical build. cros_test_lib.CreateOnDiskHierarchy(fw_files_root, fw_files) # Create an archive from the simulated firmware directory tarball = os.path.join( fw_test_root, commands.BuildFirmwareArchive(fw_test_root, board, fw_test_root)) # Verify the tarball contents. cros_test_lib.VerifyTarball(tarball, fw_archived_files)
def testArchiveTestResults(self): """Test if we can archive a test results dir.""" test_results_dir = 'tmp/taco' abs_results_dir = os.path.join(self.tempdir, 'chroot', test_results_dir) os.makedirs(abs_results_dir) osutils.Touch(os.path.join(abs_results_dir, 'foo.txt')) res = commands.ArchiveTestResults(self.tempdir, test_results_dir, '') cros_test_lib.VerifyTarball(res, ['./', 'foo.txt'])
def testSingleChromeVersion(self): """Test a successful single-version run.""" self._CreateChromeDir(self.chrome_v1_dir) created = artifacts.ArchiveChromeEbuildEnv(self.sysroot, self.output_dir) self.assertStartsWith(created, self.output_dir) cros_test_lib.VerifyTarball(created, self.expected_archive_contents)
def testMultipleChromeVersions(self): """Test a successful multiple version run.""" # Create both directories, but don't populate the v1 dir so it'll hit an # error if the wrong one is used. self._CreateChromeDir(self.chrome_v1_dir, populate=False) self._CreateChromeDir(self.chrome_v2_dir) created = artifacts.ArchiveChromeEbuildEnv(self.sysroot, self.output_dir) self.assertStartsWith(created, self.output_dir) cros_test_lib.VerifyTarball(created, self.expected_archive_contents)
def testChromeEnvironment(self): """Test that the Chrome environment is built.""" # Create the chrome environment compressed file. stage = self.ConstructStage() chrome_env_dir = os.path.join(stage._pkg_dir, constants.CHROME_CP + '-25.3643.0_rc1') env_file = os.path.join(chrome_env_dir, 'environment') osutils.Touch(env_file, makedirs=True) cros_build_lib.run(['bzip2', env_file]) # Run the code. stage._ArchiveChromeEbuildEnv() env_tar_base = stage._upload_queue.get()[0] env_tar = os.path.join(stage.archive_path, env_tar_base) self.assertExists(env_tar) cros_test_lib.VerifyTarball(env_tar, ['./', 'environment'])
def testGceTarballGeneration(self): """Verifies BuildGceTarball produces correct archives""" image_dir = os.path.join(self.tempdir, 'inputs') archive_dir = os.path.join(self.tempdir, 'outputs') image = constants.TEST_IMAGE_BIN output = constants.TEST_IMAGE_GCE_TAR osutils.SafeMakedirs(image_dir) osutils.SafeMakedirs(archive_dir) osutils.Touch(os.path.join(image_dir, image)) output_tar = commands.BuildGceTarball(archive_dir, image_dir, image) self.assertEquals(output, output_tar) output_path = os.path.join(archive_dir, output_tar) self.assertExists(output_path) # GCE expects the tarball to be in a particular format. cros_test_lib.VerifyTarball(output_path, ['disk.raw'])
def testBundleEBuildLogsTarball(self): """Verifies that the correct EBuild tar files are bundled.""" board = 'samus' # Create chroot object and sysroot object chroot_path = os.path.join(self.tempdir, 'chroot') chroot = chroot_lib.Chroot(path=chroot_path) sysroot_path = os.path.join('build', board) sysroot = sysroot_lib.Sysroot(sysroot_path) # Create parent dir for logs log_parent_dir = os.path.join(chroot.path, 'build') # Names of log files typically found in a build directory. log_files = ( '', 'x11-libs:libdrm-2.4.81-r24:20170816-175008.log', 'x11-libs:libpciaccess-0.12.902-r2:20170816-174849.log', 'x11-libs:libva-1.7.1-r2:20170816-175019.log', 'x11-libs:libva-intel-driver-1.7.1-r4:20170816-175029.log', 'x11-libs:libxkbcommon-0.4.3-r2:20170816-174908.log', 'x11-libs:pango-1.32.5-r1:20170816-174954.log', 'x11-libs:pixman-0.32.4:20170816-174832.log', 'x11-misc:xkeyboard-config-2.15-r3:20170816-174908.log', 'x11-proto:kbproto-1.0.5:20170816-174849.log', 'x11-proto:xproto-7.0.31:20170816-174849.log', ) tarred_files = [os.path.join('logs', x) for x in log_files] log_files_root = os.path.join(log_parent_dir, '%s/tmp/portage/logs' % board) # Generate a representative set of log files produced by a typical build. cros_test_lib.CreateOnDiskHierarchy(log_files_root, log_files) archive_dir = self.tempdir tarball = artifacts.BundleEBuildLogsTarball(chroot, sysroot, archive_dir) self.assertEqual('ebuild_logs.tar.xz', tarball) # Verify the tarball contents. tarball_fullpath = os.path.join(self.tempdir, tarball) cros_test_lib.VerifyTarball(tarball_fullpath, tarred_files)
def testBundleFpmcuUnittests(self): """Verifies that the resulting tarball includes proper files""" unittest_files = ( 'bloonchipper/test_rsa.bin', 'dartmonkey/test_utils.bin', ) board = 'hatch' unittest_files_root = os.path.join( self.tempdir, 'chroot/build/%s/firmware/chromeos-fpmcu-unittests' % board) cros_test_lib.CreateOnDiskHierarchy(unittest_files_root, unittest_files) chroot_path = os.path.join(self.tempdir, 'chroot') chroot = chroot_lib.Chroot(path=chroot_path) sysroot = sysroot_lib.Sysroot('/build/%s' % board) tarball = os.path.join( self.tempdir, artifacts.BundleFpmcuUnittests(chroot, sysroot, self.tempdir)) cros_test_lib.VerifyTarball( tarball, unittest_files + ('bloonchipper/', 'dartmonkey/'))
def testNormPath(self): """Test path normalization.""" tar_contents = ['./', './foo/', './foo/./a', './foo/./b'] dir_struct = [Dir('.', []), Dir('foo', ['a', 'b'])] self._MockTarList(tar_contents) cros_test_lib.VerifyTarball(self.TARBALL, dir_struct)
def VerifyTarball(self, tarball): dir_struct = [ Dir('.', []), self.TOOLCHAIN, self.KERNEL_HEADERS, self.BUILD_DEPS ] cros_test_lib.VerifyTarball(tarball, dir_struct)