Exemple #1
0
class SdkUpdateTest(oeSDKExtTest):

    @classmethod
    def setUpClass(self):
        self.publish_dir = os.path.join(self.tc.sdktestdir, 'esdk_publish')
        if os.path.exists(self.publish_dir):
            shutil.rmtree(self.publish_dir)
        os.mkdir(self.publish_dir)

        tcname_new = self.tc.d.expand(
            "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}-new.sh")
        if not os.path.exists(tcname_new):
            tcname_new = self.tc.tcname

        cmd = 'oe-publish-sdk %s %s' % (tcname_new, self.publish_dir)
        subprocess.check_output(cmd, shell=True)

        self.http_service = HTTPService(self.publish_dir)
        self.http_service.start()

        self.http_url = "http://127.0.0.1:%d" % self.http_service.port

    def test_sdk_update_http(self):
        output = self._run("devtool sdk-update \"%s\"" % self.http_url)

    def test_sdk_update_local(self):
        output = self._run("devtool sdk-update \"%s\"" % self.publish_dir)

    @classmethod
    def tearDownClass(self):
        self.http_service.stop()
        shutil.rmtree(self.publish_dir)
Exemple #2
0
class SdkUpdateTest(OESDKExtTestCase):
    @classmethod
    def setUpClass(self):
        self.publish_dir = os.path.join(self.tc.sdk_dir, 'esdk_publish')
        if os.path.exists(self.publish_dir):
            shutil.rmtree(self.publish_dir)
        os.mkdir(self.publish_dir)

        base_tcname = "%s/%s" % (self.td.get("SDK_DEPLOY", ''),
            self.td.get("TOOLCHAINEXT_OUTPUTNAME", ''))
        tcname_new = "%s-new.sh" % base_tcname
        if not os.path.exists(tcname_new):
            tcname_new = "%s.sh" % base_tcname

        cmd = 'oe-publish-sdk %s %s' % (tcname_new, self.publish_dir)
        subprocess.check_output(cmd, shell=True)

        self.http_service = HTTPService(self.publish_dir)
        self.http_service.start()

        self.http_url = "http://127.0.0.1:%d" % self.http_service.port

    def test_sdk_update_http(self):
        output = self._run("devtool sdk-update \"%s\"" % self.http_url)

    @classmethod
    def tearDownClass(self):
        self.http_service.stop()
        shutil.rmtree(self.publish_dir)
class SmartRepoTest(SmartTest):

    @classmethod
    def setUpClass(self):
        self.repolist = []
        self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR', True), oeRuntimeTest.tc.target.server_ip)
        self.repo_server.start()

    @classmethod
    def tearDownClass(self):
        self.repo_server.stop()
        for i in self.repolist:
            oeRuntimeTest.tc.target.run('smart channel -y --remove '+str(i))

    def test_smart_channel(self):
        self.smart('channel', 1)

    @testcase(719)
    def test_smart_channel_add(self):
        image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE', True)
        deploy_url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, image_pkgtype)
        pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS', True).replace("-","_").split()
        for arch in os.listdir('%s/%s' % (self.repo_server.root_dir, image_pkgtype)):
            if arch in pkgarchs:
                self.smart('channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(a=arch, u=deploy_url))
                self.repolist.append(arch)
        self.smart('update')

    def test_smart_channel_help(self):
        self.smart('channel --help')

    def test_smart_channel_list(self):
        self.smart('channel --list')

    def test_smart_channel_show(self):
        self.smart('channel --show')

    @testcase(717)
    def test_smart_channel_rpmsys(self):
        self.smart('channel --show rpmsys')
        self.smart('channel --disable rpmsys')
        self.smart('channel --enable rpmsys')

    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install(self):
        self.smart('remove -y psplash-default')
        self.smart('install -y psplash-default')

    @testcase(728)
    @skipUnlessPassed('test_smart_install')
    def test_smart_install_dependency(self):
        self.smart('remove -y psplash')
        self.smart('install -y psplash-default')

    @testcase(723)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install_from_disk(self):
        self.smart('remove -y psplash-default')
        self.smart('download psplash-default')
        self.smart('install -y ./psplash-default*')

    @testcase(725)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install_from_http(self):
        output = self.smart('download --urls psplash-default')
        url = re.search('(http://.*/psplash-default.*\.rpm)', output)
        self.assertTrue(url, msg="Couln't find download url in %s" % output)
        self.smart('remove -y psplash-default')
        self.smart('install -y %s' % url.group(0))

    @testcase(729)
    @skipUnlessPassed('test_smart_install')
    def test_smart_reinstall(self):
        self.smart('reinstall -y psplash-default')

    @testcase(727)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_remote_repo(self):
        self.smart('update')
        self.smart('install -y psplash')
        self.smart('remove -y psplash')

    @testcase(726)
    def test_smart_local_dir(self):
        self.target.run('mkdir /tmp/myrpmdir')
        self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
        self.target.run('cd /tmp/myrpmdir')
        self.smart('download psplash')
        output = self.smart('channel --list')
        for i in output.split("\n"):
            if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
                self.smart('channel --disable '+str(i))
        self.target.run('cd /home/root')
        self.smart('install psplash')
        for i in output.split("\n"):
            if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
                self.smart('channel --enable '+str(i))
        self.smart('channel --remove myrpmdir -y')
        self.target.run("rm -rf /tmp/myrpmdir")

    @testcase(718)
    def test_smart_add_rpmdir(self):
        self.target.run('mkdir /tmp/myrpmdir')
        self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
        self.smart('channel --disable myrpmdir -y')
        output = self.smart('channel --show myrpmdir')
        self.assertTrue("disabled = yes" in output, msg="Failed to disable rpm dir")
        self.smart('channel --enable  myrpmdir -y')
        output = self.smart('channel --show myrpmdir')
        self.assertFalse("disabled = yes" in output, msg="Failed to enable rpm dir")
        self.smart('channel --remove myrpmdir -y')
        self.target.run("rm -rf /tmp/myrpmdir")

    @testcase(731)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_remove_package(self):
        self.smart('install -y psplash')
        self.smart('remove -y psplash')
Exemple #4
0
class SmartRepoTest(SmartTest):
    @classmethod
    def create_index(self, arg):
        index_cmd = arg
        try:
            bb.note("Executing '%s' ..." % index_cmd)
            result = subprocess.check_output(index_cmd,
                                             stderr=subprocess.STDOUT,
                                             shell=True).decode("utf-8")
        except subprocess.CalledProcessError as e:
            return (
                "Index creation command '%s' failed with return code %d:\n%s" %
                (e.cmd, e.returncode, e.output.decode("utf-8")))
        if result:
            bb.note(result)
        return None

    @classmethod
    def setUpClass(self):
        self.repolist = []

        # Index RPMs
        rpm_createrepo = bb.utils.which(os.getenv('PATH'), "createrepo")
        index_cmds = []
        rpm_dirs_found = False
        archs = (oeRuntimeTest.tc.d.getVar('ALL_MULTILIB_PACKAGE_ARCHS')
                 or "").replace('-', '_').split()
        for arch in archs:
            rpm_dir = os.path.join(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR_RPM'),
                                   arch)
            idx_path = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR'),
                                    'rpm', arch)
            db_path = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR'),
                                   'rpmdb', arch)
            if not os.path.isdir(rpm_dir):
                continue
            if os.path.exists(db_path):
                bb.utils.remove(dbpath, True)
            lockfilename = oeRuntimeTest.tc.d.getVar(
                'DEPLOY_DIR_RPM') + "/rpm.lock"
            lf = bb.utils.lockfile(lockfilename, False)
            oe.path.copyhardlinktree(rpm_dir, idx_path)
            # Full indexes overload a 256MB image so reduce the number of rpms
            # in the feed. Filter to p* since we use the psplash packages and
            # this leaves some allarch and machine arch packages too.
            bb.utils.remove(idx_path + "*/[a-oq-z]*.rpm")
            bb.utils.unlockfile(lf)
            index_cmds.append("%s --dbpath %s --update -q %s" %
                              (rpm_createrepo, db_path, idx_path))
            rpm_dirs_found = True
        # Create repodata¬
        result = oe.utils.multiprocess_exec(index_cmds, self.create_index)
        if result:
            bb.fatal('%s' % ('\n'.join(result)))
        self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar('WORKDIR'),
                                       oeRuntimeTest.tc.target.server_ip)
        self.repo_server.start()

    @classmethod
    def tearDownClass(self):
        self.repo_server.stop()
        for i in self.repolist:
            oeRuntimeTest.tc.target.run('smart channel -y --remove ' + str(i))

    @testcase(1143)
    def test_smart_channel(self):
        self.smart('channel', 1)

    @testcase(719)
    def test_smart_channel_add(self):
        image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE')
        deploy_url = 'http://%s:%s/%s' % (self.target.server_ip,
                                          self.repo_server.port, image_pkgtype)
        pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS').replace("-", "_").split()
        for arch in os.listdir('%s/%s' %
                               (self.repo_server.root_dir, image_pkgtype)):
            if arch in pkgarchs:
                self.smart(
                    'channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(
                        a=arch, u=deploy_url))
                self.repolist.append(arch)
        self.smart('update')

    @testcase(969)
    def test_smart_channel_help(self):
        self.smart('channel --help')

    @testcase(970)
    def test_smart_channel_list(self):
        self.smart('channel --list')

    @testcase(971)
    def test_smart_channel_show(self):
        self.smart('channel --show')

    @testcase(717)
    def test_smart_channel_rpmsys(self):
        self.smart('channel --show rpmsys')
        self.smart('channel --disable rpmsys')
        self.smart('channel --enable rpmsys')

    @testcase(1144)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install(self):
        self.smart('remove -y psplash-default')
        self.smart('install -y psplash-default')

    @testcase(728)
    @skipUnlessPassed('test_smart_install')
    def test_smart_install_dependency(self):
        self.smart('remove -y psplash')
        self.smart('install -y psplash-default')

    @testcase(723)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install_from_disk(self):
        self.smart('remove -y psplash-default')
        self.smart('download psplash-default')
        self.smart('install -y ./psplash-default*')

    @testcase(725)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install_from_http(self):
        output = self.smart('download --urls psplash-default')
        url = re.search('(http://.*/psplash-default.*\.rpm)', output)
        self.assertTrue(url, msg="Couln't find download url in %s" % output)
        self.smart('remove -y psplash-default')
        self.smart('install -y %s' % url.group(0))

    @testcase(729)
    @skipUnlessPassed('test_smart_install')
    def test_smart_reinstall(self):
        self.smart('reinstall -y psplash-default')

    @testcase(727)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_remote_repo(self):
        self.smart('update')
        self.smart('install -y psplash')
        self.smart('remove -y psplash')

    @testcase(726)
    def test_smart_local_dir(self):
        self.target.run('mkdir /tmp/myrpmdir')
        self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
        self.target.run('cd /tmp/myrpmdir')
        self.smart('download psplash')
        output = self.smart('channel --list')
        for i in output.split("\n"):
            if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
                self.smart('channel --disable ' + str(i))
        self.target.run('cd $HOME')
        self.smart('install psplash')
        for i in output.split("\n"):
            if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
                self.smart('channel --enable ' + str(i))
        self.smart('channel --remove myrpmdir -y')
        self.target.run("rm -rf /tmp/myrpmdir")

    @testcase(718)
    def test_smart_add_rpmdir(self):
        self.target.run('mkdir /tmp/myrpmdir')
        self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
        self.smart('channel --disable myrpmdir -y')
        output = self.smart('channel --show myrpmdir')
        self.assertTrue("disabled = yes" in output,
                        msg="Failed to disable rpm dir")
        self.smart('channel --enable  myrpmdir -y')
        output = self.smart('channel --show myrpmdir')
        self.assertFalse("disabled = yes" in output,
                         msg="Failed to enable rpm dir")
        self.smart('channel --remove myrpmdir -y')
        self.target.run("rm -rf /tmp/myrpmdir")

    @testcase(731)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_remove_package(self):
        self.smart('install -y psplash')
        self.smart('remove -y psplash')
Exemple #5
0
class PtestRunnerTest(oeRuntimeTest):

    # a ptest log parser
    def parse_ptest(self, logfile):
        parser = Lparser(test_0_pass_regex="^PASS:(.+)", test_0_fail_regex="^FAIL:(.+)", section_0_begin_regex="^BEGIN: .*/(.+)/ptest", section_0_end_regex="^END: .*/(.+)/ptest")
        parser.init()
        result = Result()

        with open(logfile) as f:
            for line in f:
                result_tuple = parser.parse_line(line)
                if not result_tuple:
                    continue
                result_tuple = line_type, category, status, name = parser.parse_line(line)

                if line_type == 'section' and status == 'begin':
                    current_section = name
                    continue

                if line_type == 'section' and status == 'end':
                    current_section = None
                    continue

                if line_type == 'test' and status == 'pass':
                    result.store(current_section, name, status)
                    continue

                if line_type == 'test' and status == 'fail':
                    result.store(current_section, name, status)
                    continue

        result.sort_tests()
        return result

    @classmethod
    def setUpClass(self):
        #note the existing channels that are on the board before creating new ones
#        self.existingchannels = set()
#        (status, result) = oeRuntimeTest.tc.target.run('smart channel --show | grep "\["', 0)
#        for x in result.split("\n"):
#            self.existingchannels.add(x)
        self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR'), oeRuntimeTest.tc.target.server_ip)
        self.repo_server.start()

    @classmethod
    def tearDownClass(self):
        self.repo_server.stop()
        #remove created channels to be able to repeat the tests on same image
#        (status, result) = oeRuntimeTest.tc.target.run('smart channel --show | grep "\["', 0)
#        for x in result.split("\n"):
#            if x not in self.existingchannels:
#                oeRuntimeTest.tc.target.run('smart channel --remove '+x[1:-1]+' -y', 0)

    def add_smart_channel(self):
        image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE')
        deploy_url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, image_pkgtype)
        pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS').replace("-","_").split()
        for arch in os.listdir('%s/%s' % (self.repo_server.root_dir, image_pkgtype)):
            if arch in pkgarchs:
                self.target.run('smart channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(a=arch, u=deploy_url), 0)
        self.target.run('smart update', 0)

    def install_complementary(self, globs=None):
        installed_pkgs_file = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR'),
                                           "installed_pkgs.txt")
        self.pkgs_list = RpmPkgsList(oeRuntimeTest.tc.d, oeRuntimeTest.tc.d.getVar('IMAGE_ROOTFS'), oeRuntimeTest.tc.d.getVar('arch_var'), oeRuntimeTest.tc.d.getVar('os_var'))
        with open(installed_pkgs_file, "w+") as installed_pkgs:
            installed_pkgs.write(self.pkgs_list.list("arch"))

        cmd = [bb.utils.which(os.getenv('PATH'), "oe-pkgdata-util"),
               "-p", oeRuntimeTest.tc.d.getVar('PKGDATA_DIR'), "glob", installed_pkgs_file,
               globs]
        try:
            bb.note("Installing complementary packages ...")
            complementary_pkgs = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as e:
            bb.fatal("Could not compute complementary packages list. Command "
                     "'%s' returned %d:\n%s" %
                     (' '.join(cmd), e.returncode, e.output))

        return complementary_pkgs.split()

    def setUpLocal(self):
        self.ptest_log = os.path.join(oeRuntimeTest.tc.d.getVar("TEST_LOG_DIR",True), "ptest-%s.log" % oeRuntimeTest.tc.d.getVar('DATETIME'))

    @skipUnlessPassed('test_ssh')
    def test_ptestrunner(self):
        self.add_smart_channel()
        (runnerstatus, result) = self.target.run('which ptest-runner', 0)
        cond = oeRuntimeTest.hasPackage("ptest-runner") and oeRuntimeTest.hasFeature("ptest") and oeRuntimeTest.hasPackageMatch("-ptest") and (runnerstatus != 0)
        if cond:
            self.install_packages(self.install_complementary("*-ptest"))
            self.install_packages(['ptest-runner'])

        (runnerstatus, result) = self.target.run('/usr/bin/ptest-runner > /tmp/ptest.log 2>&1', 0)
        #exit code is !=0 even if ptest-runner executes because some ptest tests fail.
        self.assertTrue(runnerstatus != 127, msg="Cannot execute ptest-runner!")
        self.target.copy_from('/tmp/ptest.log', self.ptest_log)
        shutil.copyfile(self.ptest_log, "ptest.log")

        result = self.parse_ptest("ptest.log")
        log_results_to_location = "./results"
        if os.path.exists(log_results_to_location):
            shutil.rmtree(log_results_to_location)
        os.makedirs(log_results_to_location)

        result.log_as_files(log_results_to_location, test_status = ['pass','fail'])
class PtestRunnerTest(oeRuntimeTest):

    # a ptest log parser
    def parse_ptest(self, logfile):
        parser = Lparser(test_0_pass_regex="^PASS:(.+)",
                         test_0_fail_regex="^FAIL:(.+)",
                         section_0_begin_regex="^BEGIN: .*/(.+)/ptest",
                         section_0_end_regex="^END: .*/(.+)/ptest")
        parser.init()
        result = Result()

        with open(logfile) as f:
            for line in f:
                result_tuple = parser.parse_line(line)
                if not result_tuple:
                    continue
                result_tuple = line_type, category, status, name = parser.parse_line(
                    line)

                if line_type == 'section' and status == 'begin':
                    current_section = name
                    continue

                if line_type == 'section' and status == 'end':
                    current_section = None
                    continue

                if line_type == 'test' and status == 'pass':
                    result.store(current_section, name, status)
                    continue

                if line_type == 'test' and status == 'fail':
                    result.store(current_section, name, status)
                    continue

        result.sort_tests()
        return result

    @classmethod
    def setUpClass(self):
        #note the existing channels that are on the board before creating new ones
        #        self.existingchannels = set()
        #        (status, result) = oeRuntimeTest.tc.target.run('smart channel --show | grep "\["', 0)
        #        for x in result.split("\n"):
        #            self.existingchannels.add(x)
        self.repo_server = HTTPService(
            oeRuntimeTest.tc.d.getVar('DEPLOY_DIR', True),
            oeRuntimeTest.tc.target.server_ip)
        self.repo_server.start()

    @classmethod
    def tearDownClass(self):
        self.repo_server.stop()
        #remove created channels to be able to repeat the tests on same image
#        (status, result) = oeRuntimeTest.tc.target.run('smart channel --show | grep "\["', 0)
#        for x in result.split("\n"):
#            if x not in self.existingchannels:
#                oeRuntimeTest.tc.target.run('smart channel --remove '+x[1:-1]+' -y', 0)

    def add_smart_channel(self):
        image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE', True)
        deploy_url = 'http://%s:%s/%s' % (self.target.server_ip,
                                          self.repo_server.port, image_pkgtype)
        pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS',
                                    True).replace("-", "_").split()
        for arch in os.listdir('%s/%s' %
                               (self.repo_server.root_dir, image_pkgtype)):
            if arch in pkgarchs:
                self.target.run(
                    'smart channel -y --add {a} type=rpm-md baseurl={u}/{a}'.
                    format(a=arch, u=deploy_url), 0)
        self.target.run('smart update', 0)

    def install_complementary(self, globs=None):
        installed_pkgs_file = os.path.join(
            oeRuntimeTest.tc.d.getVar('WORKDIR', True), "installed_pkgs.txt")
        self.pkgs_list = RpmPkgsList(
            oeRuntimeTest.tc.d,
            oeRuntimeTest.tc.d.getVar('IMAGE_ROOTFS', True),
            oeRuntimeTest.tc.d.getVar('arch_var', True),
            oeRuntimeTest.tc.d.getVar('os_var', True))
        with open(installed_pkgs_file, "w+") as installed_pkgs:
            installed_pkgs.write(self.pkgs_list.list("arch"))

        cmd = [
            bb.utils.which(os.getenv('PATH'), "oe-pkgdata-util"), "-p",
            oeRuntimeTest.tc.d.getVar('PKGDATA_DIR', True), "glob",
            installed_pkgs_file, globs
        ]
        try:
            bb.note("Installing complementary packages ...")
            complementary_pkgs = subprocess.check_output(
                cmd, stderr=subprocess.STDOUT)
        except subprocess.CalledProcessError as e:
            bb.fatal("Could not compute complementary packages list. Command "
                     "'%s' returned %d:\n%s" %
                     (' '.join(cmd), e.returncode, e.output))

        return complementary_pkgs.split()

    def setUpLocal(self):
        self.ptest_log = os.path.join(
            oeRuntimeTest.tc.d.getVar("TEST_LOG_DIR", True),
            "ptest-%s.log" % oeRuntimeTest.tc.d.getVar('DATETIME', True))

    @skipUnlessPassed('test_ssh')
    def test_ptestrunner(self):
        self.add_smart_channel()
        (runnerstatus, result) = self.target.run('which ptest-runner', 0)
        cond = oeRuntimeTest.hasPackage(
            "ptest-runner") and oeRuntimeTest.hasFeature(
                "ptest") and oeRuntimeTest.hasPackage("-ptest") and (
                    runnerstatus != 0)
        if cond:
            self.install_packages(self.install_complementary("*-ptest"))
            self.install_packages(['ptest-runner'])

        (runnerstatus, result) = self.target.run(
            '/usr/bin/ptest-runner > /tmp/ptest.log 2>&1', 0)
        #exit code is !=0 even if ptest-runner executes because some ptest tests fail.
        self.assertTrue(runnerstatus != 127,
                        msg="Cannot execute ptest-runner!")
        self.target.copy_from('/tmp/ptest.log', self.ptest_log)
        shutil.copyfile(self.ptest_log, "ptest.log")

        result = self.parse_ptest("ptest.log")
        log_results_to_location = "./results"
        if os.path.exists(log_results_to_location):
            shutil.rmtree(log_results_to_location)
        os.makedirs(log_results_to_location)

        result.log_as_files(log_results_to_location,
                            test_status=['pass', 'fail'])
Exemple #7
0
class SmartRepoTest(SmartTest):

    @classmethod
    def create_index(self, arg):
        index_cmd = arg
        try:
            bb.note("Executing '%s' ..." % index_cmd)
            result = subprocess.check_output(index_cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
        except subprocess.CalledProcessError as e:
            return("Index creation command '%s' failed with return code %d:\n%s" %
                    (e.cmd, e.returncode, e.output.decode("utf-8")))
        if result:
            bb.note(result)
        return None

    @classmethod
    def setUpClass(self):
        self.repolist = []

        # Index RPMs
        rpm_createrepo = bb.utils.which(os.getenv('PATH'), "createrepo")
        index_cmds = []
        rpm_dirs_found = False
        archs = (oeRuntimeTest.tc.d.getVar('ALL_MULTILIB_PACKAGE_ARCHS', True) or "").replace('-', '_').split()
        for arch in archs:
            rpm_dir = os.path.join(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR_RPM', True), arch)
            idx_path = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR', True), 'rpm', arch)
            db_path = os.path.join(oeRuntimeTest.tc.d.getVar('WORKDIR', True), 'rpmdb', arch)
            if not os.path.isdir(rpm_dir):
                continue
            if os.path.exists(db_path):
                bb.utils.remove(dbpath, True)
            lockfilename = oeRuntimeTest.tc.d.getVar('DEPLOY_DIR_RPM', True) + "/rpm.lock"
            lf = bb.utils.lockfile(lockfilename, False)
            oe.path.copyhardlinktree(rpm_dir, idx_path)
            bb.utils.unlockfile(lf)
            index_cmds.append("%s --dbpath %s --update -q %s" % (rpm_createrepo, db_path, idx_path))
            rpm_dirs_found = True
         # Create repodata¬
        result = oe.utils.multiprocess_exec(index_cmds, self.create_index)
        if result:
            bb.fatal('%s' % ('\n'.join(result)))
        self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar('WORKDIR', True), oeRuntimeTest.tc.target.server_ip)
        self.repo_server.start()

    @classmethod
    def tearDownClass(self):
        self.repo_server.stop()
        for i in self.repolist:
            oeRuntimeTest.tc.target.run('smart channel -y --remove '+str(i))

    @testcase(1143)
    def test_smart_channel(self):
        self.smart('channel', 1)

    @testcase(719)
    def test_smart_channel_add(self):
        image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE', True)
        deploy_url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, image_pkgtype)
        pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS', True).replace("-","_").split()
        for arch in os.listdir('%s/%s' % (self.repo_server.root_dir, image_pkgtype)):
            if arch in pkgarchs:
                self.smart('channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(a=arch, u=deploy_url))
                self.repolist.append(arch)
        self.smart('update')

    @testcase(969)
    def test_smart_channel_help(self):
        self.smart('channel --help')

    @testcase(970)
    def test_smart_channel_list(self):
        self.smart('channel --list')

    @testcase(971)
    def test_smart_channel_show(self):
        self.smart('channel --show')

    @testcase(717)
    def test_smart_channel_rpmsys(self):
        self.smart('channel --show rpmsys')
        self.smart('channel --disable rpmsys')
        self.smart('channel --enable rpmsys')

    @testcase(1144)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install(self):
        self.smart('remove -y psplash-default')
        self.smart('install -y psplash-default')

    @testcase(728)
    @skipUnlessPassed('test_smart_install')
    def test_smart_install_dependency(self):
        self.smart('remove -y psplash')
        self.smart('install -y psplash-default')

    @testcase(723)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install_from_disk(self):
        self.smart('remove -y psplash-default')
        self.smart('download psplash-default')
        self.smart('install -y ./psplash-default*')

    @testcase(725)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install_from_http(self):
        output = self.smart('download --urls psplash-default')
        url = re.search('(http://.*/psplash-default.*\.rpm)', output)
        self.assertTrue(url, msg="Couln't find download url in %s" % output)
        self.smart('remove -y psplash-default')
        self.smart('install -y %s' % url.group(0))

    @testcase(729)
    @skipUnlessPassed('test_smart_install')
    def test_smart_reinstall(self):
        self.smart('reinstall -y psplash-default')

    @testcase(727)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_remote_repo(self):
        self.smart('update')
        self.smart('install -y psplash')
        self.smart('remove -y psplash')

    @testcase(726)
    def test_smart_local_dir(self):
        self.target.run('mkdir /tmp/myrpmdir')
        self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
        self.target.run('cd /tmp/myrpmdir')
        self.smart('download psplash')
        output = self.smart('channel --list')
        for i in output.split("\n"):
            if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
                self.smart('channel --disable '+str(i))
        self.target.run('cd $HOME')
        self.smart('install psplash')
        for i in output.split("\n"):
            if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
                self.smart('channel --enable '+str(i))
        self.smart('channel --remove myrpmdir -y')
        self.target.run("rm -rf /tmp/myrpmdir")

    @testcase(718)
    def test_smart_add_rpmdir(self):
        self.target.run('mkdir /tmp/myrpmdir')
        self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
        self.smart('channel --disable myrpmdir -y')
        output = self.smart('channel --show myrpmdir')
        self.assertTrue("disabled = yes" in output, msg="Failed to disable rpm dir")
        self.smart('channel --enable  myrpmdir -y')
        output = self.smart('channel --show myrpmdir')
        self.assertFalse("disabled = yes" in output, msg="Failed to enable rpm dir")
        self.smart('channel --remove myrpmdir -y')
        self.target.run("rm -rf /tmp/myrpmdir")

    @testcase(731)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_remove_package(self):
        self.smart('install -y psplash')
        self.smart('remove -y psplash')
Exemple #8
0
class SmartRepoTest(SmartTest):

    @classmethod
    def setUpClass(self):
        self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar('DEPLOY_DIR', True), oeRuntimeTest.tc.target.server_ip)
        self.repo_server.start()

    @classmethod
    def tearDownClass(self):
        self.repo_server.stop()

    def test_smart_channel(self):
        self.smart('channel', 1)

    def test_smart_channel_add(self):
        image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE', True)
        deploy_url = 'http://%s:%s/%s' %(self.target.server_ip, self.repo_server.port, image_pkgtype)
        pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS', True)
        for arch in os.listdir('%s/%s' % (self.repo_server.root_dir, image_pkgtype)):
            if arch in pkgarchs:
                self.smart('channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(a=arch, u=deploy_url))
        self.smart('update')

    def test_smart_channel_help(self):
        self.smart('channel --help')

    def test_smart_channel_list(self):
        self.smart('channel --list')

    def test_smart_channel_show(self):
        self.smart('channel --show')

    def test_smart_channel_rpmsys(self):
        self.smart('channel --show rpmsys')
        self.smart('channel --disable rpmsys')
        self.smart('channel --enable rpmsys')

    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install(self):
        self.smart('remove -y psplash-default')
        self.smart('install -y psplash-default')

    @skipUnlessPassed('test_smart_install')
    def test_smart_install_dependency(self):
        self.smart('remove -y psplash')
        self.smart('install -y psplash-default')

    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install_from_disk(self):
        self.smart('remove -y psplash-default')
        self.smart('download psplash-default')
        self.smart('install -y ./psplash-default*')

    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install_from_http(self):
        output = self.smart('download --urls psplash-default')
        url = re.search('(http://.*/psplash-default.*\.rpm)', output)
        self.assertTrue(url, msg="Couln't find download url in %s" % output)
        self.smart('remove -y psplash-default')
        self.smart('install -y %s' % url.group(0))

    @skipUnlessPassed('test_smart_install')
    def test_smart_reinstall(self):
        self.smart('reinstall -y psplash-default')
Exemple #9
0
class SmartRepoTest(SmartTest):
    @classmethod
    def setUpClass(self):
        self.repolist = []
        self.repo_server = HTTPService(
            oeRuntimeTest.tc.d.getVar('DEPLOY_DIR', True),
            oeRuntimeTest.tc.target.server_ip)
        self.repo_server.start()

    @classmethod
    def tearDownClass(self):
        self.repo_server.stop()
        for i in self.repolist:
            oeRuntimeTest.tc.target.run('smart channel -y --remove ' + str(i))

    def test_smart_channel(self):
        self.smart('channel', 1)

    @testcase(719)
    def test_smart_channel_add(self):
        image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE', True)
        deploy_url = 'http://%s:%s/%s' % (self.target.server_ip,
                                          self.repo_server.port, image_pkgtype)
        pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS',
                                    True).replace("-", "_").split()
        for arch in os.listdir('%s/%s' %
                               (self.repo_server.root_dir, image_pkgtype)):
            if arch in pkgarchs:
                self.smart(
                    'channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(
                        a=arch, u=deploy_url))
                self.repolist.append(arch)
        self.smart('update')

    @testcase(969)
    def test_smart_channel_help(self):
        self.smart('channel --help')

    @testcase(970)
    def test_smart_channel_list(self):
        self.smart('channel --list')

    @testcase(971)
    def test_smart_channel_show(self):
        self.smart('channel --show')

    @testcase(717)
    def test_smart_channel_rpmsys(self):
        self.smart('channel --show rpmsys')
        self.smart('channel --disable rpmsys')
        self.smart('channel --enable rpmsys')

    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install(self):
        self.smart('remove -y psplash-default')
        self.smart('install -y psplash-default')

    @testcase(728)
    @skipUnlessPassed('test_smart_install')
    def test_smart_install_dependency(self):
        self.smart('remove -y psplash')
        self.smart('install -y psplash-default')

    @testcase(723)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install_from_disk(self):
        self.smart('remove -y psplash-default')
        self.smart('download psplash-default')
        self.smart('install -y ./psplash-default*')

    @testcase(725)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install_from_http(self):
        output = self.smart('download --urls psplash-default')
        url = re.search('(http://.*/psplash-default.*\.rpm)', output)
        self.assertTrue(url, msg="Couln't find download url in %s" % output)
        self.smart('remove -y psplash-default')
        self.smart('install -y %s' % url.group(0))

    @testcase(729)
    @skipUnlessPassed('test_smart_install')
    def test_smart_reinstall(self):
        self.smart('reinstall -y psplash-default')

    @testcase(727)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_remote_repo(self):
        self.smart('update')
        self.smart('install -y psplash')
        self.smart('remove -y psplash')

    @testcase(726)
    def test_smart_local_dir(self):
        self.target.run('mkdir /tmp/myrpmdir')
        self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
        self.target.run('cd /tmp/myrpmdir')
        self.smart('download psplash')
        output = self.smart('channel --list')
        for i in output.split("\n"):
            if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
                self.smart('channel --disable ' + str(i))
        self.target.run('cd /home/root')
        self.smart('install psplash')
        for i in output.split("\n"):
            if ("rpmsys" != str(i)) and ("myrpmdir" != str(i)):
                self.smart('channel --enable ' + str(i))
        self.smart('channel --remove myrpmdir -y')
        self.target.run("rm -rf /tmp/myrpmdir")

    @testcase(718)
    def test_smart_add_rpmdir(self):
        self.target.run('mkdir /tmp/myrpmdir')
        self.smart('channel --add myrpmdir type=rpm-dir path=/tmp/myrpmdir -y')
        self.smart('channel --disable myrpmdir -y')
        output = self.smart('channel --show myrpmdir')
        self.assertTrue("disabled = yes" in output,
                        msg="Failed to disable rpm dir")
        self.smart('channel --enable  myrpmdir -y')
        output = self.smart('channel --show myrpmdir')
        self.assertFalse("disabled = yes" in output,
                         msg="Failed to enable rpm dir")
        self.smart('channel --remove myrpmdir -y')
        self.target.run("rm -rf /tmp/myrpmdir")

    @testcase(731)
    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_remove_package(self):
        self.smart('install -y psplash')
        self.smart('remove -y psplash')
Exemple #10
0
class SmartRepoTest(SmartTest):
    @classmethod
    def setUpClass(self):
        self.repo_server = HTTPService(
            oeRuntimeTest.tc.d.getVar('DEPLOY_DIR', True),
            oeRuntimeTest.tc.target.server_ip)
        self.repo_server.start()

    @classmethod
    def tearDownClass(self):
        self.repo_server.stop()

    def test_smart_channel(self):
        self.smart('channel', 1)

    def test_smart_channel_add(self):
        image_pkgtype = self.tc.d.getVar('IMAGE_PKGTYPE', True)
        deploy_url = 'http://%s:%s/%s' % (self.target.server_ip,
                                          self.repo_server.port, image_pkgtype)
        pkgarchs = self.tc.d.getVar('PACKAGE_ARCHS', True)
        for arch in os.listdir('%s/%s' %
                               (self.repo_server.root_dir, image_pkgtype)):
            if arch in pkgarchs:
                self.smart(
                    'channel -y --add {a} type=rpm-md baseurl={u}/{a}'.format(
                        a=arch, u=deploy_url))
        self.smart('update')

    def test_smart_channel_help(self):
        self.smart('channel --help')

    def test_smart_channel_list(self):
        self.smart('channel --list')

    def test_smart_channel_show(self):
        self.smart('channel --show')

    def test_smart_channel_rpmsys(self):
        self.smart('channel --show rpmsys')
        self.smart('channel --disable rpmsys')
        self.smart('channel --enable rpmsys')

    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install(self):
        self.smart('remove -y psplash-default')
        self.smart('install -y psplash-default')

    @skipUnlessPassed('test_smart_install')
    def test_smart_install_dependency(self):
        self.smart('remove -y psplash')
        self.smart('install -y psplash-default')

    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install_from_disk(self):
        self.smart('remove -y psplash-default')
        self.smart('download psplash-default')
        self.smart('install -y ./psplash-default*')

    @skipUnlessPassed('test_smart_channel_add')
    def test_smart_install_from_http(self):
        output = self.smart('download --urls psplash-default')
        url = re.search('(http://.*/psplash-default.*\.rpm)', output)
        self.assertTrue(url, msg="Couln't find download url in %s" % output)
        self.smart('remove -y psplash-default')
        self.smart('install -y %s' % url.group(0))

    @skipUnlessPassed('test_smart_install')
    def test_smart_reinstall(self):
        self.smart('reinstall -y psplash-default')
Exemple #11
0
class SmartRepoTest(SmartTest):
    @classmethod
    def setUpClass(self):
        self.repo_server = HTTPService(oeRuntimeTest.tc.d.getVar("DEPLOY_DIR", True), oeRuntimeTest.tc.qemu.host_ip)
        self.repo_server.start()

    @classmethod
    def tearDownClass(self):
        self.repo_server.stop()

    def test_smart_channel(self):
        self.smart("channel", 1)

    def test_smart_channel_add(self):
        image_pkgtype = self.tc.d.getVar("IMAGE_PKGTYPE", True)
        deploy_url = "http://%s:%s/%s" % (self.tc.qemu.host_ip, self.repo_server.port, image_pkgtype)
        pkgarchs = self.tc.d.getVar("PACKAGE_ARCHS", True)
        for arch in os.listdir("%s/%s" % (self.repo_server.root_dir, image_pkgtype)):
            if arch in pkgarchs:
                self.smart("channel -y --add {a} type=rpm-md baseurl={u}/{a}".format(a=arch, u=deploy_url))
        self.smart("update")

    def test_smart_channel_help(self):
        self.smart("channel --help")

    def test_smart_channel_list(self):
        self.smart("channel --list")

    def test_smart_channel_show(self):
        self.smart("channel --show")

    def test_smart_channel_rpmsys(self):
        self.smart("channel --show rpmsys")
        self.smart("channel --disable rpmsys")
        self.smart("channel --enable rpmsys")

    @skipUnlessPassed("test_smart_channel_add")
    def test_smart_install(self):
        self.smart("remove -y psplash-default")
        self.smart("install -y psplash-default")

    @skipUnlessPassed("test_smart_install")
    def test_smart_install_dependency(self):
        self.smart("remove -y psplash")
        self.smart("install -y psplash-default")

    @skipUnlessPassed("test_smart_channel_add")
    def test_smart_install_from_disk(self):
        self.smart("remove -y psplash-default")
        self.smart("download psplash-default")
        self.smart("install -y ./psplash-default*")

    @skipUnlessPassed("test_smart_channel_add")
    def test_smart_install_from_http(self):
        output = self.smart("download --urls psplash-default")
        url = re.search("(http://.*/psplash-default.*\.rpm)", output)
        self.assertTrue(url, msg="Couln't find download url in %s" % output)
        self.smart("remove -y psplash-default")
        self.smart("install -y %s" % url.group(0))

    @skipUnlessPassed("test_smart_install")
    def test_smart_reinstall(self):
        self.smart("reinstall -y psplash-default")