Example #1
0
    def test_cleanup_workdir(self):
        path = os.path.dirname(get_bb_var('WORKDIR', 'gzip'))
        old_version_recipe = os.path.join(get_bb_var('COREBASE'), 'meta/recipes-extended/gzip/gzip_1.3.12.bb')
        old_version = '1.3.12'
        bitbake("-ccleansstate gzip")
        bitbake("-ccleansstate -b %s" % old_version_recipe)
        if os.path.exists(get_bb_var('WORKDIR', "-b %s" % old_version_recipe)):
            shutil.rmtree(get_bb_var('WORKDIR', "-b %s" % old_version_recipe))
        if os.path.exists(get_bb_var('WORKDIR', 'gzip')):
            shutil.rmtree(get_bb_var('WORKDIR', 'gzip'))

        if os.path.exists(path):
            initial_contents = os.listdir(path)
        else:
            initial_contents = []

        bitbake('gzip')
        intermediary_contents = os.listdir(path)
        bitbake("-b %s" % old_version_recipe)
        runCmd('cleanup-workdir')
        remaining_contents = os.listdir(path)

        expected_contents = [x for x in intermediary_contents if x not in initial_contents]
        remaining_not_expected = [x for x in remaining_contents if x not in expected_contents]
        self.assertFalse(remaining_not_expected, msg="Not all necessary content has been deleted from %s: %s" % (path, ', '.join(map(str, remaining_not_expected))))
        expected_not_remaining = [x for x in expected_contents if x not in remaining_contents]
        self.assertFalse(expected_not_remaining, msg="The script removed extra contents from %s: %s" % (path, ', '.join(map(str, expected_not_remaining))))
Example #2
0
 def test_devtool_add(self):
     # Check preconditions
     workspacedir = os.path.join(self.builddir, 'workspace')
     self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory')
     # Fetch source
     tempdir = tempfile.mkdtemp(prefix='devtoolqa')
     self.track_for_cleanup(tempdir)
     url = 'http://www.ivarch.com/programs/sources/pv-1.5.3.tar.bz2'
     result = runCmd('wget %s' % url, cwd=tempdir)
     result = runCmd('tar xfv pv-1.5.3.tar.bz2', cwd=tempdir)
     srcdir = os.path.join(tempdir, 'pv-1.5.3')
     self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure')), 'Unable to find configure script in source directory')
     # Test devtool add
     self.track_for_cleanup(workspacedir)
     self.add_command_to_tearDown('bitbake -c cleansstate pv')
     self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
     result = runCmd('devtool add pv %s' % srcdir)
     self.assertTrue(os.path.exists(os.path.join(workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created')
     # Test devtool status
     result = runCmd('devtool status')
     self.assertIn('pv', result.output)
     self.assertIn(srcdir, result.output)
     # Clean up anything in the workdir/sysroot/sstate cache (have to do this *after* devtool add since the recipe only exists then)
     bitbake('pv -c cleansstate')
     # Test devtool build
     result = runCmd('devtool build pv')
     installdir = get_bb_var('D', 'pv')
     self.assertTrue(installdir, 'Could not query installdir variable')
     bindir = get_bb_var('bindir', 'pv')
     self.assertTrue(bindir, 'Could not query bindir variable')
     if bindir[0] == '/':
         bindir = bindir[1:]
     self.assertTrue(os.path.isfile(os.path.join(installdir, bindir, 'pv')), 'pv binary not found in D')
Example #3
0
    def setUpClass(cls):
        # Start to serve sstate dir
        sstate_dir = os.path.join(os.environ['BUILDDIR'], 'sstate-cache')
        cls.http_service = HTTPService(sstate_dir)
        cls.http_service.start()

        http_url = "127.0.0.1:%d" % cls.http_service.port
 
        image = 'core-image-minimal'

        cls.tmpdir_eSDKQA = tempfile.mkdtemp(prefix='eSDKQA')
        oeSDKExtSelfTest.generate_eSDK(image)

        # Install eSDK
        ext_sdk_path = oeSDKExtSelfTest.get_eSDK_toolchain(image)
        runCmd("%s -y -d \"%s\"" % (ext_sdk_path, cls.tmpdir_eSDKQA))

        cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA)

        # Configure eSDK to use sstate mirror from poky
        sstate_config="""
SDK_LOCAL_CONF_WHITELIST = "SSTATE_MIRRORS"
SSTATE_MIRRORS =  "file://.* http://%s/PATH"
        """ % http_url
        with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
            f.write(sstate_config)
Example #4
0
    def test_efi_gummiboot_images_can_be_built(self):
        """
        Summary:     Check if efi/gummiboot images can be built
        Expected:    1. File gummibootx64.efi should be available in build/tmp/deploy/images/genericx86-64
                     2. Efi/gummiboot images can be built
        Product:     oe-core
        Author:      Ionut Chisanovici <*****@*****.**>
        AutomatedBy: Daniel Istrate <*****@*****.**>
        """

        # We'd use DEPLOY_DIR_IMAGE here, except that we need its value for
        # MACHINE="genericx86-64 which is probably not the one configured
        gummibootfile = os.path.join(get_bb_var('DEPLOY_DIR'), 'images', 'genericx86-64', 'gummibootx64.efi')

        self._common_setup()

        # Ensure we're actually testing that this gets built and not that
        # it was around from an earlier build
        bitbake('-c cleansstate gummiboot')
        runCmd('rm -f %s' % gummibootfile)

        self._common_build()

        found = os.path.isfile(gummibootfile)
        self.assertTrue(found, 'Gummiboot file %s not found' % gummibootfile)
Example #5
0
 def test_devtool_modify_git(self):
     # Check preconditions
     workspacedir = os.path.join(self.builddir, 'workspace')
     self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory')
     testrecipe = 'mkelfimage'
     src_uri = get_bb_var('SRC_URI', testrecipe)
     self.assertIn('git://', src_uri, 'This test expects the %s recipe to be a git recipe' % testrecipe)
     # Clean up anything in the workdir/sysroot/sstate cache
     bitbake('%s -c cleansstate' % testrecipe)
     # Try modifying a recipe
     tempdir = tempfile.mkdtemp(prefix='devtoolqa')
     self.track_for_cleanup(tempdir)
     self.track_for_cleanup(workspacedir)
     self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
     self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe)
     result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir))
     self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile')), 'Extracted source could not be found')
     self.assertTrue(os.path.isdir(os.path.join(tempdir, '.git')), 'git repository for external source tree not found')
     self.assertTrue(os.path.exists(os.path.join(workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created')
     matches = glob.glob(os.path.join(workspacedir, 'appends', 'mkelfimage_*.bbappend'))
     self.assertTrue(matches, 'bbappend not created')
     # Test devtool status
     result = runCmd('devtool status')
     self.assertIn(testrecipe, result.output)
     self.assertIn(tempdir, result.output)
     # Check git repo
     result = runCmd('git status --porcelain', cwd=tempdir)
     self.assertEqual(result.output.strip(), "", 'Created git repo is not clean')
     result = runCmd('git symbolic-ref HEAD', cwd=tempdir)
     self.assertEqual(result.output.strip(), "refs/heads/devtool", 'Wrong branch in git repo')
     # Try building
     bitbake(testrecipe)
Example #6
0
 def test_devtool_modify_localfiles(self):
     # Check preconditions
     workspacedir = os.path.join(self.builddir, 'workspace')
     self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory')
     testrecipe = 'lighttpd'
     src_uri = (get_bb_var('SRC_URI', testrecipe) or '').split()
     foundlocal = False
     for item in src_uri:
         if item.startswith('file://') and '.patch' not in item:
             foundlocal = True
             break
     self.assertTrue(foundlocal, 'This test expects the %s recipe to fetch local files and it seems that it no longer does' % testrecipe)
     # Clean up anything in the workdir/sysroot/sstate cache
     bitbake('%s -c cleansstate' % testrecipe)
     # Try modifying a recipe
     tempdir = tempfile.mkdtemp(prefix='devtoolqa')
     self.track_for_cleanup(tempdir)
     self.track_for_cleanup(workspacedir)
     self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
     self.add_command_to_tearDown('bitbake -c clean %s' % testrecipe)
     result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir))
     self.assertTrue(os.path.exists(os.path.join(tempdir, 'configure.ac')), 'Extracted source could not be found')
     self.assertTrue(os.path.exists(os.path.join(workspacedir, 'conf', 'layer.conf')), 'Workspace directory not created')
     matches = glob.glob(os.path.join(workspacedir, 'appends', '%s_*.bbappend' % testrecipe))
     self.assertTrue(matches, 'bbappend not created')
     # Test devtool status
     result = runCmd('devtool status')
     self.assertIn(testrecipe, result.output)
     self.assertIn(tempdir, result.output)
     # Try building
     bitbake(testrecipe)
Example #7
0
    def test_testimage_dnf(self):
        """
        Summary: Check package feeds functionality for dnf
        Expected: 1. Check that remote package feeds can be accessed
        Product: oe-core
        Author: Alexander Kanavin <*****@*****.**>
        """
        if get_bb_var('DISTRO') == 'poky-tiny':
            self.skipTest('core-image-full-cmdline not buildable for poky-tiny')

        features = 'INHERIT += "testimage"\n'
        features += 'TEST_SUITES = "ping ssh dnf_runtime dnf.DnfBasicTest.test_dnf_help"\n'
        # We don't yet know what the server ip and port will be - they will be patched
        # in at the start of the on-image test
        features += 'PACKAGE_FEED_URIS = "http://bogus_ip:bogus_port"\n'
        features += 'EXTRA_IMAGE_FEATURES += "package-management"\n'
        features += 'PACKAGE_CLASSES = "package_rpm"\n'

        # Enable package feed signing
        self.gpg_home = tempfile.mkdtemp(prefix="oeqa-feed-sign-")
        signing_key_dir = os.path.join(self.testlayer_path, 'files', 'signing')
        runCmd('gpg --batch --homedir %s --import %s' % (self.gpg_home, os.path.join(signing_key_dir, 'key.secret')))
        features += 'INHERIT += "sign_package_feed"\n'
        features += 'PACKAGE_FEED_GPG_NAME = "testuser"\n'
        features += 'PACKAGE_FEED_GPG_PASSPHRASE_FILE = "%s"\n' % os.path.join(signing_key_dir, 'key.passphrase')
        features += 'GPG_PATH = "%s"\n' % self.gpg_home
        self.write_config(features)

        # Build core-image-sato and testimage
        bitbake('core-image-full-cmdline socat')
        bitbake('-c testimage core-image-full-cmdline')

        # remove the oeqa-feed-sign temporal directory
        shutil.rmtree(self.gpg_home, ignore_errors=True)
Example #8
0
    def test_stopping_prservice_message(self):
        port = get_free_port()

        runCmd('bitbake-prserv --host localhost --port %s --loglevel=DEBUG --start' % port)
        ret = runCmd('bitbake-prserv --host localhost --port %s --loglevel=DEBUG --stop' % port)

        self.assertEqual(ret.status, 0)
Example #9
0
    def test_wic_cp_ext(self):
        """Test copy files and directories to the ext partition."""
        self.assertEqual(0, runCmd("wic create wictestdisk "
                                   "--image-name=core-image-minimal "
                                   "-D -o %s" % self.resultdir).status)
        images = glob(self.resultdir + "wictestdisk-*.direct")
        self.assertEqual(1, len(images))

        sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools')

        # list directory content of the ext4 partition
        result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot))
        self.assertEqual(0, result.status)
        dirs = set(line.split()[-1] for line in result.output.split('\n') if line)
        self.assertTrue(set(['bin', 'home', 'proc', 'usr', 'var', 'dev', 'lib', 'sbin']).issubset(dirs))

        with NamedTemporaryFile("w", suffix=".wic-cp") as testfile:
            testfile.write("test")

            # copy file to the partition
            result = runCmd("wic cp %s %s:2/ -n %s" % (testfile.name, images[0], sysroot))
            self.assertEqual(0, result.status)

            # check if file is there
            result = runCmd("wic ls %s:2/ -n %s" % (images[0], sysroot))
            self.assertEqual(0, result.status)
            newdirs = set(line.split()[-1] for line in result.output.split('\n') if line)
            self.assertEqual(newdirs.difference(dirs), set([os.path.basename(testfile.name)]))
Example #10
0
    def run_test_sstate_cache_management_script(
        self, target, global_config=[""], target_config=[""], ignore_patterns=[]
    ):
        self.assertTrue(global_config)
        self.assertTrue(target_config)
        self.assertTrue(
            len(global_config) == len(target_config),
            msg="Lists global_config and target_config should have the same number of elements",
        )
        self.config_sstate(temp_sstate_location=True, add_local_mirrors=[self.sstate_path])

        # If buildhistory is enabled, we need to disable version-going-backwards QA checks for this test. It may report errors otherwise.
        if ("buildhistory" in get_bb_var("USER_CLASSES")) or ("buildhistory" in get_bb_var("INHERIT")):
            remove_errors_config = 'ERROR_QA_remove = "version-going-backwards"'
            self.append_config(remove_errors_config)

        # For not this only checks if random sstate tasks are handled correctly as a group.
        # In the future we should add control over what tasks we check for.

        sstate_archs_list = []
        expected_remaining_sstate = []
        for idx in range(len(target_config)):
            self.append_config(global_config[idx])
            self.append_recipeinc(target, target_config[idx])
            sstate_arch = get_bb_var("SSTATE_PKGARCH", target)
            if not sstate_arch in sstate_archs_list:
                sstate_archs_list.append(sstate_arch)
            if target_config[idx] == target_config[-1]:
                target_sstate_before_build = self.search_sstate(target + ".*?\.tgz$")
            bitbake("-cclean %s" % target)
            result = bitbake(target, ignore_status=True)
            if target_config[idx] == target_config[-1]:
                target_sstate_after_build = self.search_sstate(target + ".*?\.tgz$")
                expected_remaining_sstate += [
                    x
                    for x in target_sstate_after_build
                    if x not in target_sstate_before_build
                    if not any(pattern in x for pattern in ignore_patterns)
                ]
            self.remove_config(global_config[idx])
            self.remove_recipeinc(target, target_config[idx])
            self.assertEqual(result.status, 0)

        runCmd(
            "sstate-cache-management.sh -y --cache-dir=%s --remove-duplicated --extra-archs=%s"
            % (self.sstate_path, ",".join(map(str, sstate_archs_list)))
        )
        actual_remaining_sstate = [
            x for x in self.search_sstate(target + ".*?\.tgz$") if not any(pattern in x for pattern in ignore_patterns)
        ]

        actual_not_expected = [x for x in actual_remaining_sstate if x not in expected_remaining_sstate]
        self.assertFalse(
            actual_not_expected,
            msg="Files should have been removed but ware not: %s" % ", ".join(map(str, actual_not_expected)),
        )
        expected_not_actual = [x for x in expected_remaining_sstate if x not in actual_remaining_sstate]
        self.assertFalse(
            expected_not_actual, msg="Extra files ware removed: %s" ", ".join(map(str, expected_not_actual))
        )
Example #11
0
    def test_devtool_modify_invalid(self):
        # Check preconditions
        workspacedir = os.path.join(self.builddir, 'workspace')
        self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory')
        # Try modifying some recipes
        tempdir = tempfile.mkdtemp(prefix='devtoolqa')
        self.track_for_cleanup(tempdir)
        self.track_for_cleanup(workspacedir)
        self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')

        testrecipes = 'perf kernel-devsrc package-index core-image-minimal meta-toolchain packagegroup-core-sdk meta-ide-support'.split()
        # Find actual name of gcc-source since it now includes the version - crude, but good enough for this purpose
        result = runCmd('bitbake-layers show-recipes gcc-source*')
        reading = False
        for line in result.output.splitlines():
            if line.startswith('=='):
                reading = True
            elif reading and not line.startswith(' '):
                testrecipes.append(line.split(':')[0])
        for testrecipe in testrecipes:
            # Check it's a valid recipe
            bitbake('%s -e' % testrecipe)
            # devtool extract should fail
            result = runCmd('devtool extract %s %s' % (testrecipe, os.path.join(tempdir, testrecipe)), ignore_status=True)
            self.assertNotEqual(result.status, 0, 'devtool extract on %s should have failed' % testrecipe)
            self.assertNotIn('Fetching ', result.output, 'devtool extract on %s should have errored out before trying to fetch' % testrecipe)
            self.assertIn('ERROR: ', result.output, 'devtool extract on %s should have given an ERROR' % testrecipe)
            # devtool modify should fail
            result = runCmd('devtool modify %s -x %s' % (testrecipe, os.path.join(tempdir, testrecipe)), ignore_status=True)
            self.assertNotEqual(result.status, 0, 'devtool modify on %s should have failed' % testrecipe)
            self.assertIn('ERROR: ', result.output, 'devtool modify on %s should have given an ERROR' % testrecipe)
Example #12
0
    def test_wic_rm(self):
        """Test removing files and directories from the the wic image."""
        self.assertEqual(0, runCmd("wic create mkefidisk "
                                   "--image-name=core-image-minimal "
                                   "-D -o %s" % self.resultdir).status)
        images = glob(self.resultdir + "mkefidisk-*.direct")
        self.assertEqual(1, len(images))

        sysroot = get_bb_var('RECIPE_SYSROOT_NATIVE', 'wic-tools')

        # list directory content of the first partition
        result = runCmd("wic ls %s:1 -n %s" % (images[0], sysroot))
        self.assertEqual(0, result.status)
        self.assertIn('\nBZIMAGE        ', result.output)
        self.assertIn('\nEFI          <DIR>     ', result.output)

        # remove file
        result = runCmd("wic rm %s:1/bzimage -n %s" % (images[0], sysroot))
        self.assertEqual(0, result.status)

        # remove directory
        result = runCmd("wic rm %s:1/efi -n %s" % (images[0], sysroot))
        self.assertEqual(0, result.status)

        # check if they're removed
        result = runCmd("wic ls %s:1 -n %s" % (images[0], sysroot))
        self.assertEqual(0, result.status)
        self.assertNotIn('\nBZIMAGE        ', result.output)
        self.assertNotIn('\nEFI          <DIR>     ', result.output)
Example #13
0
 def test_build_rootfs_long(self):
     """Test --build-rootfs option"""
     runCmd("wic create wictestdisk "
                                "--image-name=core-image-minimal "
                                "--build-rootfs "
                                "--outdir %s" % self.resultdir)
     self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
Example #14
0
 def test_sdimage_bootpart(self):
     """Test creation of sdimage-bootpart image"""
     cmd = "wic create sdimage-bootpart -e core-image-minimal -o %s" % self.resultdir
     kimgtype = get_bb_var('KERNEL_IMAGETYPE', 'core-image-minimal')
     self.write_config('IMAGE_BOOT_FILES = "%s"\n' % kimgtype)
     runCmd(cmd)
     self.assertEqual(1, len(glob(self.resultdir + "sdimage-bootpart-*direct")))
Example #15
0
    def test_fixed_size(self):
        """
        Test creation of a simple image with partition size controlled through
        --fixed-size flag
        """
        wkspath, wksname = Wic2._make_fixed_size_wks(200)

        runCmd("wic create %s -e core-image-minimal -o %s" \
                                   % (wkspath, self.resultdir))
        os.remove(wkspath)
        wicout = glob(self.resultdir + "%s-*direct" % wksname)
        self.assertEqual(1, len(wicout))

        wicimg = wicout[0]

        # verify partition size with wic
        res = runCmd("parted -m %s unit mib p 2>/dev/null" % wicimg,
                     native_sysroot=self.native_sysroot)

        # parse parted output which looks like this:
        # BYT;\n
        # /var/tmp/wic/build/tmpfwvjjkf_-201611101222-hda.direct:200MiB:file:512:512:msdos::;\n
        # 1:0.00MiB:200MiB:200MiB:ext4::;\n
        partlns = res.output.splitlines()[2:]

        self.assertEqual(1, len(partlns))
        self.assertEqual("1:0.00MiB:200MiB:200MiB:ext4::;", partlns[0])
Example #16
0
    def test_recipetool_load_plugin(self):
        """Test that recipetool loads only the first found plugin in BBPATH."""

        recipetool = runCmd("which recipetool")
        fromname = runCmd("recipetool --quiet pluginfile")
        srcfile = fromname.output
        searchpath = self.bbpath.split(':') + [os.path.dirname(recipetool.output)]
        plugincontent = []
        with open(srcfile) as fh:
            plugincontent = fh.readlines()
        try:
            self.assertIn('meta-selftest', srcfile, 'wrong bbpath plugin found')
            for path in searchpath:
                self._copy_file_with_cleanup(srcfile, path, 'lib', 'recipetool')
            result = runCmd("recipetool --quiet count")
            self.assertEqual(result.output, '1')
            result = runCmd("recipetool --quiet multiloaded")
            self.assertEqual(result.output, "no")
            for path in searchpath:
                result = runCmd("recipetool --quiet bbdir")
                self.assertEqual(result.output, path)
                os.unlink(os.path.join(result.output, 'lib', 'recipetool', 'bbpath.py'))
        finally:
            with open(srcfile, 'w') as fh:
                fh.writelines(plugincontent)
Example #17
0
    def test_efi_systemdboot_images_can_be_built(self):
        """
        Summary:     Check if systemd-boot images can be built correctly
        Expected:    1. File systemd-boot.efi should be available in $poky/build/tmp/deploy/images/genericx86-64
                     2. 'systemd-boot" can be built correctly
        Product:     oe-core
        Author:      Jose Perez Carranza <*****@*****.**>
        AutomatedBy: Jose Perez Carranza <*****@*****.**>
        """

        # We'd use DEPLOY_DIR_IMAGE here, except that we need its value for
        # MACHINE="genericx86-64 which is probably not the one configured
        systemdbootfile = os.path.join(get_bb_var('DEPLOY_DIR'), 'images', 'genericx86-64', 'systemd-bootx64.efi')

        self._common_setup()

        # Ensure we're actually testing that this gets built and not that
        # it was around from an earlier build
        bitbake('-c clean systemd-boot')
        runCmd('rm -f %s' % systemdbootfile)

        self._common_build()

        found = os.path.isfile(systemdbootfile)
        self.assertTrue(found, 'Systemd-Boot file %s not found' % systemdbootfile)
Example #18
0
 def power_ctl(self, msg):
     if self.powercontrol_cmd:
         cmd = "%s %s" % (self.powercontrol_cmd, msg)
         try:
             commands.runCmd(cmd, assert_error=False, preexec_fn=os.setsid, env=self.origenv)
         except CommandError as e:
             bb.fatal(str(e))
Example #19
0
    def test_copy_tree_xattr(self):
        """
        Summary:    oe.path.copytree() should preserve xattr on copied files
        Expected:   testxattr file in destination should have user.oetest
                    extended attribute
        Product:    OE-Core
        Author:     Joshua Lock <*****@*****.**>
        """
        testloc = oe.path.join(self.tmp_dir, 'liboetests')
        src = oe.path.join(testloc, 'src')
        dst = oe.path.join(testloc, 'dst')
        bb.utils.mkdirhier(testloc)
        bb.utils.mkdirhier(src)
        testfilename = 'testxattr'

        # ensure we have setfattr available
        bitbake("attr-native")

        bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'bindir'], 'attr-native')
        destdir = bb_vars['SYSROOT_DESTDIR']
        bindir = bb_vars['bindir']
        bindir = destdir + bindir

        # create a file with xattr and copy it
        open(oe.path.join(src, testfilename), 'w+b').close()
        runCmd('%s/setfattr -n user.oetest -v "testing liboe" %s' % (bindir, oe.path.join(src, testfilename)))
        oe.path.copytree(src, dst)

        # ensure file in dest has user.oetest xattr
        result = runCmd('%s/getfattr -n user.oetest %s' % (bindir, oe.path.join(dst, testfilename)))
        self.assertIn('user.oetest="testing liboe"', result.output, 'Extended attribute not sert in dst')

        oe.path.remove(testloc)
Example #20
0
    def test_signing_packages(self):
        """
        Summary:     Test that packages can be signed in the package feed
        Expected:    Package should be signed with the correct key
        Expected:    Images can be created from signed packages
        Product:     oe-core
        Author:      Daniel Istrate <*****@*****.**>
        Author:      Alexander Kanavin <*****@*****.**>
        AutomatedBy: Daniel Istrate <*****@*****.**>
        """
        import oe.packagedata

        package_classes = get_bb_var('PACKAGE_CLASSES')
        if 'package_rpm' not in package_classes:
            self.skipTest('This test requires RPM Packaging.')

        test_recipe = 'ed'

        feature = 'INHERIT += "sign_rpm"\n'
        feature += 'RPM_GPG_PASSPHRASE = "test123"\n'
        feature += 'RPM_GPG_NAME = "testuser"\n'
        feature += 'GPG_PATH = "%s"\n' % self.gpg_dir

        self.write_config(feature)

        bitbake('-c clean %s' % test_recipe)
        bitbake('-f -c package_write_rpm %s' % test_recipe)

        self.add_command_to_tearDown('bitbake -c clean %s' % test_recipe)

        needed_vars = ['PKGDATA_DIR', 'DEPLOY_DIR_RPM', 'PACKAGE_ARCH', 'STAGING_BINDIR_NATIVE']
        bb_vars = get_bb_vars(needed_vars, test_recipe)
        pkgdatadir = bb_vars['PKGDATA_DIR']
        pkgdata = oe.packagedata.read_pkgdatafile(pkgdatadir + "/runtime/ed")
        if 'PKGE' in pkgdata:
            pf = pkgdata['PN'] + "-" + pkgdata['PKGE'] + pkgdata['PKGV'] + '-' + pkgdata['PKGR']
        else:
            pf = pkgdata['PN'] + "-" + pkgdata['PKGV'] + '-' + pkgdata['PKGR']
        deploy_dir_rpm = bb_vars['DEPLOY_DIR_RPM']
        package_arch = bb_vars['PACKAGE_ARCH'].replace('-', '_')
        staging_bindir_native = bb_vars['STAGING_BINDIR_NATIVE']

        pkg_deploy = os.path.join(deploy_dir_rpm, package_arch, '.'.join((pf, package_arch, 'rpm')))

        # Use a temporary rpmdb
        rpmdb = tempfile.mkdtemp(prefix='oeqa-rpmdb')

        runCmd('%s/rpmkeys --define "_dbpath %s" --import %s' %
               (staging_bindir_native, rpmdb, self.pub_key_path))

        ret = runCmd('%s/rpmkeys --define "_dbpath %s" --checksig %s' %
                     (staging_bindir_native, rpmdb, pkg_deploy))
        # tmp/deploy/rpm/i586/ed-1.9-r0.i586.rpm: rsa sha1 md5 OK
        self.assertIn('rsa sha1 (md5) pgp md5 OK', ret.output, 'Package signed incorrectly.')
        shutil.rmtree(rpmdb)

        #Check that an image can be built from signed packages
        self.add_command_to_tearDown('bitbake -c clean core-image-minimal')
        bitbake('-c clean core-image-minimal')
        bitbake('core-image-minimal')
Example #21
0
File: pkgdata.py Project: kacf/poky
 def test_lookup_recipe(self):
     result = runCmd('oe-pkgdata-util lookup-recipe "libc6-staticdev busybox"')
     self.assertEqual(result.output, 'glibc\nbusybox')
     result = runCmd('oe-pkgdata-util lookup-recipe libz-dbg')
     self.assertEqual(result.output, 'zlib')
     result = runCmd('oe-pkgdata-util lookup-recipe nonexistentpkg', ignore_status=True)
     self.assertEqual(result.status, 1, "Status different than 1. output: %s" % result.output)
     self.assertEqual(result.output, 'ERROR: The following packages could not be found: nonexistentpkg')
Example #22
0
 def test_rootfs_indirect_recipes(self):
     """Test usage of rootfs plugin with rootfs recipes"""
     runCmd("wic create directdisk-multi-rootfs "
                     "--image-name=core-image-minimal "
                     "--rootfs rootfs1=core-image-minimal "
                     "--rootfs rootfs2=core-image-minimal "
                     "--outdir %s" % self.resultdir)
     self.assertEqual(1, len(glob(self.resultdir + "directdisk-multi-rootfs*.direct")))
Example #23
0
    def test_sdk(self):

        result = runCmd("env -0")
        sdk_path = search_sdk_path(result.output)
        self.assertTrue(sdk_path, msg="Can't find SDK path")

        tar_cmd = os.path.join(sdk_path, "tar")
        result = runCmd("%s --help" % tar_cmd)
Example #24
0
File: pkgdata.py Project: kacf/poky
 def test_find_path(self):
     result = runCmd('oe-pkgdata-util find-path /lib/libc.so.6')
     self.assertEqual(result.output, 'glibc: /lib/libc.so.6')
     result = runCmd('oe-pkgdata-util find-path /bin/bash')
     self.assertEqual(result.output, 'bash: /bin/bash')
     result = runCmd('oe-pkgdata-util find-path /not/exist', ignore_status=True)
     self.assertEqual(result.status, 1, "Status different than 1. output: %s" % result.output)
     self.assertEqual(result.output, 'ERROR: Unable to find any package producing path /not/exist')
Example #25
0
    def test_continue(self):
	self.write_recipeinc('man',"\ndo_fail_task () {\nexit 1 \n}\n\naddtask do_fail_task before do_fetch\n" )
	runCmd('bitbake -c cleanall man xcursor-transparent-theme')
	result = runCmd('bitbake man xcursor-transparent-theme -k', ignore_status=True)
	errorpos = result.output.find('ERROR: Function failed: do_fail_task')
	manver = re.search("NOTE: recipe xcursor-transparent-theme-(.*?): task do_unpack: Started", result.output)
	continuepos = result.output.find('NOTE: recipe xcursor-transparent-theme-%s: task do_unpack: Started' % manver.group(1))
	self.assertLess(errorpos,continuepos)
Example #26
0
File: pkgdata.py Project: kacf/poky
 def test_read_value(self):
     result = runCmd('oe-pkgdata-util read-value PN libz1')
     self.assertEqual(result.output, 'zlib')
     result = runCmd('oe-pkgdata-util read-value PKG libz1')
     self.assertEqual(result.output, 'libz1')
     result = runCmd('oe-pkgdata-util read-value PKGSIZE bash')
     pkgsize = int(result.output.strip())
     self.assertGreater(pkgsize, 1, "Size should be greater than 1. %s" % result.output)
Example #27
0
    def tearDownClass(cls):
        # Delete the files generated by 'gpg --import'

        gpg_files = glob.glob(cls.gpg_dir + '*.gpg*')
        random_seed_file = cls.gpg_dir + 'random_seed'
        gpg_files.append(random_seed_file)

        for gpg_file in gpg_files:
            runCmd('rm -f ' + gpg_file)
Example #28
0
 def test_prefile(self):
     preconf = os.path.join(self.builddir, 'conf/prefile.conf')
     self.track_for_cleanup(preconf)
     ftools.write_file(preconf ,"TEST_PREFILE=\"prefile\"")
     result = runCmd('bitbake -r conf/prefile.conf -e | grep TEST_PREFILE=')
     self.assertTrue('prefile' in result.output, "Preconfigure file \"prefile.conf\"was not taken into consideration. ")
     self.write_config("TEST_PREFILE=\"localconf\"")
     result = runCmd('bitbake -r conf/prefile.conf -e | grep TEST_PREFILE=')
     self.assertTrue('localconf' in result.output, "Preconfigure file \"prefile.conf\"was not taken into consideration.")
Example #29
0
    def _pre_run(self):
        def _check_required_env_variables(vars):
            for var in vars:
                if not os.environ.get(var):
                    self.tc.logger.error("%s is not set. Did you forget to source your build environment setup script?" % var)
                    raise OEQAPreRun

        def _check_presence_meta_selftest():
            builddir = os.environ.get("BUILDDIR")
            if os.getcwd() != builddir:
                self.tc.logger.info("Changing cwd to %s" % builddir)
                os.chdir(builddir)

            if not "meta-selftest" in self.tc.td["BBLAYERS"]:
                self.tc.logger.warn("meta-selftest layer not found in BBLAYERS, adding it")
                meta_selftestdir = os.path.join(
                    self.tc.td["BBLAYERS_FETCH_DIR"], 'meta-selftest')
                if os.path.isdir(meta_selftestdir):
                    runCmd("bitbake-layers add-layer %s" %meta_selftestdir)
                    # reload data is needed because a meta-selftest layer was add
                    self.tc.td = get_bb_vars()
                    self.tc.testlayer_path = get_test_layer()
                else:
                    self.tc.logger.error("could not locate meta-selftest in:\n%s" % meta_selftestdir)
                    raise OEQAPreRun

        def _add_layer_libs():
            bbpath = self.tc.td['BBPATH'].split(':')
            layer_libdirs = [p for p in (os.path.join(l, 'lib') \
                    for l in bbpath) if os.path.exists(p)]
            if layer_libdirs:
                self.tc.logger.info("Adding layer libraries:")
                for l in layer_libdirs:
                    self.tc.logger.info("\t%s" % l)

                sys.path.extend(layer_libdirs)
                imp.reload(oeqa.selftest)

        _check_required_env_variables(["BUILDDIR"])
        _check_presence_meta_selftest()

        if "buildhistory.bbclass" in self.tc.td["BBINCLUDED"]:
            self.tc.logger.error("You have buildhistory enabled already and this isn't recommended for selftest, please disable it first.")
            raise OEQAPreRun

        if "PRSERV_HOST" in self.tc.td:
            self.tc.logger.error("Please unset PRSERV_HOST in order to run oe-selftest")
            raise OEQAPreRun

        if "SANITY_TESTED_DISTROS" in self.tc.td:
            self.tc.logger.error("Please unset SANITY_TESTED_DISTROS in order to run oe-selftest")
            raise OEQAPreRun

        _add_layer_libs()

        self.tc.logger.info("Running bitbake -p")
        runCmd("bitbake -p")
Example #30
0
    def setUpClass(cls):
        # Import the gpg keys

        cls.gpg_dir = os.path.join(cls.testlayer_path, 'files/signing/')

        # key.secret key.pub are located in gpg_dir
        pub_key_location = cls.gpg_dir + cls.pub_key_name
        secret_key_location = cls.gpg_dir + cls.secret_key_name
        runCmd('gpg --homedir %s --import %s %s' % (cls.gpg_dir, pub_key_location, secret_key_location))
Example #31
0
 def test_help_kickstart(self):
     """Test wic help kickstart"""
     runCmd('wic help kickstart')
Example #32
0
 def test_list_images(self):
     """Test wic list images"""
     runCmd('wic list images')
Example #33
0
 def test_list_source_plugins(self):
     """Test wic list source-plugins"""
     runCmd('wic list source-plugins')
Example #34
0
 def test_wrong_compressor(self):
     """Test how wic breaks if wrong compressor is provided"""
     self.assertEqual(2, runCmd("wic create wictestdisk "
                                "--image-name=core-image-minimal "
                                "-c wrong -o %s" % self.resultdir,
                                ignore_status=True).status)
Example #35
0
 def test_createhelp(self):
     """Test wic create --help"""
     runCmd('wic create --help')
Example #36
0
 def test_help_overview(self):
     """Test wic help overview"""
     runCmd('wic help overview')
Example #37
0
 def test_compress_bzip2(self):
     """Test compressing an image with bzip2"""
     runCmd("wic create wictestdisk "
                                "--image-name=core-image-minimal "
                                "-c bzip2 -o %s" % self.resultdir)
     self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.bz2")))
Example #38
0
 def test_mkefidisk(self):
     """Test creation of mkefidisk image"""
     cmd = "wic create mkefidisk -e core-image-minimal -o %s" % self.resultdir
     runCmd(cmd)
     self.assertEqual(1, len(glob(self.resultdir + "mkefidisk-*direct")))
Example #39
0
 def test_qemux86_directdisk(self):
     """Test creation of qemux-86-directdisk image"""
     cmd = "wic create qemux86-directdisk -e core-image-minimal -o %s" % self.resultdir
     runCmd(cmd)
     self.assertEqual(1, len(glob(self.resultdir + "qemux86-directdisk-*direct")))
Example #40
0
 def test_compress_gzip(self):
     """Test compressing an image with gzip"""
     runCmd("wic create wictestdisk "
                                "--image-name core-image-minimal "
                                "-c gzip -o %s" % self.resultdir)
     self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.gz")))
Example #41
0
 def test_bmap_short(self):
     """Test generation of .bmap file -m option"""
     cmd = "wic create wictestdisk -e core-image-minimal -m -o %s" % self.resultdir
     runCmd(cmd)
     self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct")))
     self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*direct.bmap")))
Example #42
0
 def test_help(self):
     """Test wic --help and wic -h"""
     runCmd('wic --help')
     runCmd('wic -h')
Example #43
0
 def test_help_plugins(self):
     """Test wic help plugins"""
     runCmd('wic help plugins')
Example #44
0
 def test_help_create(self):
     """Test wic help create"""
     runCmd('wic help create')
Example #45
0
 def test_gpt_image(self):
     """Test creation of core-image-minimal with gpt table and UUID boot"""
     cmd = "wic create directdisk-gpt --image-name core-image-minimal -o %s" % self.resultdir
     runCmd(cmd)
     self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct")))
Example #46
0
 def test_debug_long(self):
     """Test --debug option"""
     runCmd("wic create wictestdisk "
                                "--image-name=core-image-minimal "
                                "--debug -o %s" % self.resultdir)
     self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
Example #47
0
 def test_help_list(self):
     """Test wic help list"""
     runCmd('wic help list')
Example #48
0
 def test_build_image_name(self):
     """Test wic create wictestdisk --image-name=core-image-minimal"""
     cmd = "wic create wictestdisk --image-name=core-image-minimal -o %s" % self.resultdir
     runCmd(cmd)
     self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
Example #49
0
 def test_listhelp(self):
     """Test wic list --help"""
     runCmd('wic list --help')
Example #50
0
 def test_no_command(self):
     """Test wic without command"""
     self.assertEqual(1, runCmd('wic', ignore_status=True).status)
Example #51
0
 def test_unsupported_subcommand(self):
     """Test unsupported subcommand"""
     self.assertNotEqual(0, runCmd('wic unsupported', ignore_status=True).status)
Example #52
0
 def test_listed_images_help(self):
     """Test wic listed images help"""
     output = runCmd('wic list images').output
     imagelist = [line.split()[0] for line in output.splitlines()]
     for image in imagelist:
         runCmd('wic list %s help' % image)
Example #53
0
File: wic.py Project: chbae/poky
 def test_version(self):
     """Test wic --version"""
     self.assertEqual(0, runCmd('wic --version').status)
Example #54
0
 def test_compress_xz(self):
     """Test compressing an image with xz"""
     runCmd("wic create wictestdisk "
                                "--image-name=core-image-minimal "
                                "--compress-with=xz -o %s" % self.resultdir)
     self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct.xz")))
Example #55
0
File: wic.py Project: chbae/poky
 def test_list_images(self):
     """Test wic list images"""
     self.assertEqual(0, runCmd('wic list images').status)
Example #56
0
 def test_version(self):
     """Test wic --version"""
     runCmd('wic --version')
Example #57
0
    def test_exclude_path(self):
        """Test --exclude-path wks option."""

        oldpath = os.environ['PATH']
        os.environ['PATH'] = get_bb_var("PATH", "wic-tools")

        try:
            wks_file = 'temp.wks'
            with open(wks_file, 'w') as wks:
                rootfs_dir = get_bb_var('IMAGE_ROOTFS', 'core-image-minimal')
                wks.write("""
part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path usr
part /usr --source rootfs --ondisk mmcblk0 --fstype=ext4 --rootfs-dir %s/usr
part /etc --source rootfs --ondisk mmcblk0 --fstype=ext4 --exclude-path bin/ --rootfs-dir %s/usr"""
                          % (rootfs_dir, rootfs_dir))
            runCmd("wic create %s -e core-image-minimal -o %s" \
                                       % (wks_file, self.resultdir))

            os.remove(wks_file)
            wicout = glob(self.resultdir + "%s-*direct" % 'temp')
            self.assertEqual(1, len(wicout))

            wicimg = wicout[0]

            # verify partition size with wic
            res = runCmd("parted -m %s unit b p 2>/dev/null" % wicimg)

            # parse parted output which looks like this:
            # BYT;\n
            # /var/tmp/wic/build/tmpfwvjjkf_-201611101222-hda.direct:200MiB:file:512:512:msdos::;\n
            # 1:0.00MiB:200MiB:200MiB:ext4::;\n
            partlns = res.output.splitlines()[2:]

            self.assertEqual(3, len(partlns))

            for part in [1, 2, 3]:
                part_file = os.path.join(self.resultdir, "selftest_img.part%d" % part)
                partln = partlns[part-1].split(":")
                self.assertEqual(7, len(partln))
                start = int(partln[1].rstrip("B")) / 512
                length = int(partln[3].rstrip("B")) / 512
                runCmd("dd if=%s of=%s skip=%d count=%d" %
                                           (wicimg, part_file, start, length))

            def extract_files(debugfs_output):
                """
                extract file names from the output of debugfs -R 'ls -p',
                which looks like this:

                 /2/040755/0/0/.//\n
                 /2/040755/0/0/..//\n
                 /11/040700/0/0/lost+found^M//\n
                 /12/040755/1002/1002/run//\n
                 /13/040755/1002/1002/sys//\n
                 /14/040755/1002/1002/bin//\n
                 /80/040755/1002/1002/var//\n
                 /92/040755/1002/1002/tmp//\n
                """
                # NOTE the occasional ^M in file names
                return [line.split('/')[5].strip() for line in \
                        debugfs_output.strip().split('/\n')]

            # Test partition 1, should contain the normal root directories, except
            # /usr.
            res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \
                             os.path.join(self.resultdir, "selftest_img.part1"))
            files = extract_files(res.output)
            self.assertIn("etc", files)
            self.assertNotIn("usr", files)

            # Partition 2, should contain common directories for /usr, not root
            # directories.
            res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \
                             os.path.join(self.resultdir, "selftest_img.part2"))
            files = extract_files(res.output)
            self.assertNotIn("etc", files)
            self.assertNotIn("usr", files)
            self.assertIn("share", files)

            # Partition 3, should contain the same as partition 2, including the bin
            # directory, but not the files inside it.
            res = runCmd("debugfs -R 'ls -p' %s 2>/dev/null" % \
                             os.path.join(self.resultdir, "selftest_img.part3"))
            files = extract_files(res.output)
            self.assertNotIn("etc", files)
            self.assertNotIn("usr", files)
            self.assertIn("share", files)
            self.assertIn("bin", files)
            res = runCmd("debugfs -R 'ls -p bin' %s 2>/dev/null" % \
                             os.path.join(self.resultdir, "selftest_img.part3"))
            files = extract_files(res.output)
            self.assertIn(".", files)
            self.assertIn("..", files)
            self.assertEqual(2, len(files))

            for part in [1, 2, 3]:
                part_file = os.path.join(self.resultdir, "selftest_img.part%d" % part)
                os.remove(part_file)

        finally:
            os.environ['PATH'] = oldpath
Example #58
0
File: wic.py Project: chbae/poky
 def test_list_source_plugins(self):
     """Test wic list source-plugins"""
     self.assertEqual(0, runCmd('wic list source-plugins').status)
Example #59
0
 def test_build_rootfs_short(self):
     """Test -f option"""
     runCmd("wic create wictestdisk "
                                "--image-name=core-image-minimal "
                                "-f -o %s" % self.resultdir)
     self.assertEqual(1, len(glob(self.resultdir + "wictestdisk-*.direct")))
Example #60
0
File: wic.py Project: chbae/poky
 def test_help_kickstart(self):
     """Test wic help kickstart"""
     self.assertEqual(0, runCmd('wic help kickstart').status)