Esempio n. 1
0
    def runTests(self):
        # Setup some globals to pass to the TestCase
        global SOFT_PKG
        global IMPL_ID
        SOFT_PKG = self.spd_file
        spd = SPDParser.parse(self.spd_file)

        if self.testRunner is None:
            try:
                import xmlrunner
                self.testRunner = xmlrunner.XMLTestRunner(
                    verbosity=self.verbosity)
            except ImportError:
                self.testRunner = unittest.TextTestRunner(
                    verbosity=self.verbosity)

        for implementation in spd.get_implementation():
            IMPL_ID = implementation.get_id()
            if IMPL_ID == self.impl or self.impl is None:
                result = self.testRunner.run(self.test)
                self.results.append(result)
Esempio n. 2
0
    def _get_impls_from_spd(self, dep_file):
        # try and get dependency spd file
        sdr_root = '/var/sca/sdr'
        if 'SCAROOT' in os.environ:
            sdr_root = os.path.abspath(os.environ['SCAROOT'])
        else:
            print "Warning: SCAROOT undefined, defaulting to ", sdr_root

        fname = os.path.join(sdr_root, 'dom', dep_file)
        if dep_file.startswith('/'):
            fname = os.path.join(sdr_root, 'dom', dep_file[1:])

        impls = {}
        try:
            parser = spd.parse(fname)
        except:
            print "Warning: Unable to open dependency file: ", fname
            return None
        for x in parser.get_implementation():
            impls[x.get_id()] = x
        return impls
Esempio n. 3
0
    def __init__(
            self,
            name,
            implementation,
            outputDir=".",
            generator="cpp.component.pull",
            spdTemplateFile = SCAHOME+DEFAULT_SPD_TEMPLATE,
            scdTemplateFile = SCAHOME+DEFAULT_SCD_TEMPLATE,
            prfTemplateFile = SCAHOME+DEFAULT_PRF_TEMPLATE,
            loggingConfigUri = None):
        '''
        Create a resource with no ports/properties.  Use helper methods to add
        additional elements.

        Note, "implementation" argument must be "cpp", "java", or "python"

        '''

        SoftPackage.__init__(self, name, implementation, outputDir)

        self.spd = spd.parse(spdTemplateFile)
        self.scd = scd.parse(scdTemplateFile)
        self.prf = prf.parse(prfTemplateFile)

        self._setImplementation()
        self._setNameInSpd()
        self._setPropertyFileInSpd()
        self._setDescriptorInSpd()

        self._createWavedevContent(generator=generator)

        if loggingConfigUri:
            self.addSimpleProperty(
                id="LOGGING_CONFIG_URI",
                value=loggingConfigUri,
                type="string",
                complex=False,
                kindtypes=["configure", "execparam"])
Esempio n. 4
0
    def setUp(self):
        """
        Starts the component whose id matches the one stored in the IMPL_ID
        """

        signal.signal(signal.SIGINT, self.tearDown)
        signal.signal(signal.SIGTERM, self.tearDown)
        signal.signal(signal.SIGQUIT, self.tearDown)

        global SOFT_PKG
        global IMPL_ID
        self.comp_obj = None
        self.comp = None
        # Use the globals by default
        self.impl = IMPL_ID
        self.spd_file = SOFT_PKG
        self.spd = SPDParser.parse(SOFT_PKG)

        try:
            self.prf_file = self.spd.get_propertyfile().get_localfile(
            ).get_name()
            if (self.prf_file[0] != '/'):
                self.prf_file = os.path.join(os.path.dirname(self.spd_file),
                                             self.prf_file)
            self.prf = PRFParser.parse(self.prf_file)
        except:
            self.prf_file = None
            self.prf = None

        self.scd_file = self.spd.get_descriptor().get_localfile().get_name()
        if (self.scd_file[0] != '/'):
            self.scd_file = os.path.join(os.path.dirname(self.spd_file),
                                         self.scd_file)
        self.scd = SCDParser.parse(self.scd_file)

        # create a map between prop ids and names
        if self.prf:
            self._props = prop_helpers.getPropNameDict(self.prf)
    def __init__(self,
                 name,
                 implementation,
                 libraryLocation,
                 outputDir=".",
                 sharedLibraries=[],
                 spdTemplateFile=SCAHOME + DEFAULT_RESOURCE_TEMPLATE,
                 variant=""):

        SoftPackage.__init__(self, name, implementation, outputDir)

        # intantiate the class object representing the spd file
        self.spd = spd.parse(spdTemplateFile)

        self._setNameInSpd()
        self._setImplementation()

        self._createWavedevContent(
            generator="project.softPackageDependency.directory")

        # Create the output directory strucutre.  A share directory will be
        # created in the implemetation directory.  The share directory is
        # a symbolic link to the target directory.
        fullOutputDir = outputDir + "/" + name + "/"
        if not os.path.exists(fullOutputDir + implementation):
            os.makedirs(fullOutputDir + implementation)
        if not os.path.exists(fullOutputDir + implementation + "/share"):
            if not os.path.isabs(libraryLocation):
                libraryLocation = os.path.join(os.getcwd(), libraryLocation)
            shutil.copytree(libraryLocation,
                            fullOutputDir + implementation + "/share")

        # Add soft package dependencies to the package being created (in the
        # case that the soft package dependency being created has its own
        # soft package dependencies).
        for sharedLibrary in sharedLibraries:
            self.addSoftPackageDependency(sharedLibrary)