Пример #1
0
    def test_simplest_create(self):
        print("-- test_simplest_create")

        ucisdb = "file.ucis"
        db = MemFactory.create()

        testnode = db.createHistoryNode(None, "logicalName", ucisdb,
                                        UCIS_HISTORYNODE_TEST)
        td = TestData(teststatus=UCIS_TESTSTATUS_OK,
                      toolcategory="UCIS:simulator",
                      date="20200202020")
        testnode.setTestData(td)

        file = db.createFileHandle("dummy", os.getcwd())

        srcinfo = SourceInfo(file, 0, 0)
        du = db.createScope(
            "foo.bar",
            srcinfo,
            1,  # weight
            UCIS_OTHER,
            UCIS_DU_MODULE,
            UCIS_ENABLED_STMT | UCIS_ENABLED_BRANCH
            | UCIS_ENABLED_COND | UCIS_ENABLED_EXPR
            | UCIS_ENABLED_FSM | UCIS_ENABLED_TOGGLE
            | UCIS_INST_ONCE | UCIS_SCOPE_UNDER_DU)

        instance = db.createInstance(
            "dummy",
            None,  # sourceinfo
            1,  # weight
            UCIS_OTHER,
            UCIS_INSTANCE,
            du,
            UCIS_INST_ONCE)

        cg = instance.createCovergroup(
            "cg",
            SourceInfo(file, 3, 0),
            1,  # weight
            UCIS_OTHER)

        cp = cg.createCoverpoint(
            "t",
            SourceInfo(file, 4, 0),
            1,  # weight
            UCIS_VLOG)
        cp.setComment("Hello There")

        cp.createBin("auto[a]", SourceInfo(file, 4, 0), 1, 4, "a")

        out = StringIO()
        writer = XmlWriter()
        writer.write(out, db)

        print("XML Output:\n" + out.getvalue())
        input = StringIO(out.getvalue())
        validate_ucis_xml(input)
Пример #2
0
    def disabled_test_lib_dump(self):
        LibFactory.load_ucis_library("libucis.so")
        db = LibFactory.create("file.ucis")

        out = StringIO()
        writer = XmlWriter()
        writer.write(out, db)

        input = StringIO(out.getvalue())
Пример #3
0
    def test_simple_dump(self):
        
        @vsc.covergroup
        class my_covergroup(object):
            
            def __init__(self):
                
                self.with_sample(dict(
                    a=vsc.uint8_t(),
                    b=vsc.uint8_t()
                    ))
                
                self.a_cp = vsc.coverpoint(self.a, bins=dict(
                    a_bins =  vsc.bin_array([], [1,8])
                    ))
                
                self.b_cp = vsc.coverpoint(self.b, bins=dict(
                    b_bins = vsc.bin_array([], [1,8])
                    ))

        cg_1 = my_covergroup()
        
        cg_1.sample(1, 2)
        cg_1.sample(2, 1)
        cg_1.sample(4, 2)
        
        cg_2 = my_covergroup()
        
        cg_2.sample(5, 4)
        cg_2.sample(6, 2)
        cg_2.sample(7, 8)

        db = MemFactory.create()
        v = CoverageSaveVisitor(db)

        td = TestData(
            teststatus=UCIS_TESTSTATUS_OK,
            toolcategory="UCIS:simulator",
            date="20200101132000")        
        v.save(td, CoverageRegistry.inst().covergroup_types())
        db.close()

        out = StringIO()        
        writer = XmlWriter()
        writer.write(out, db)

        print("Output:\n" + out.getvalue())        

        xmlin = StringIO(out.getvalue())        
        XmlReader.validate(xmlin)
Пример #4
0
    def write(db: UCIS, file_or_filename):
        """Writes the specified database in XML format"""
        writer = XmlWriter()

        if type(file_or_filename) == str:
            fp = open(file_or_filename, "w")
        else:
            fp = file_or_filename

        writer.write(fp, db)

        if type(file_or_filename) == str:
            fp.close()

        pass
Пример #5
0
    def test_smoke(self):
        print("-- test_simplest_create")

        ucisdb = "file.ucis"
        db = MemFactory.create()

        testnode = db.createHistoryNode(None, "logicalName", ucisdb,
                                        UCIS_HISTORYNODE_TEST)
        td = TestData(teststatus=UCIS_TESTSTATUS_OK,
                      toolcategory="UCIS:simulator",
                      date="20200202020")
        testnode.setTestData(td)

        file = db.createFileHandle("dummy", os.getcwd())

        srcinfo = SourceInfo(file, 0, 0)
        du = db.createScope(
            "foo.bar",
            srcinfo,
            1,  # weight
            UCIS_OTHER,
            UCIS_DU_MODULE,
            UCIS_ENABLED_STMT | UCIS_ENABLED_BRANCH
            | UCIS_ENABLED_COND | UCIS_ENABLED_EXPR
            | UCIS_ENABLED_FSM | UCIS_ENABLED_TOGGLE
            | UCIS_INST_ONCE | UCIS_SCOPE_UNDER_DU)

        instance = db.createInstance(
            "my_inst_scope",
            None,  # sourceinfo
            1,  # weight
            UCIS_OTHER,
            UCIS_INSTANCE,
            du,
            UCIS_INST_ONCE)

        cg = instance.createCovergroup(
            "cg",
            SourceInfo(file, 3, 0),
            1,  # weight
            UCIS_OTHER)

        cp1 = cg.createCoverpoint(
            "cp1",
            SourceInfo(file, 4, 0),
            1,  # weight
            UCIS_VLOG)

        cp1.createBin("v[1]", SourceInfo(file, 4, 0), 1, 4, "v")
        cp1.createBin("v[2]", SourceInfo(file, 4, 0), 1, 4, "v")

        cp2 = cg.createCoverpoint(
            "cp2",
            SourceInfo(file, 4, 0),
            1,  # weight
            UCIS_VLOG)

        cp2.createBin("v2[1]", SourceInfo(file, 4, 0), 1, 4, "v2")
        cp2.createBin("v2[2]", SourceInfo(file, 4, 0), 1, 4, "v2")

        cr = cg.createCross("cr", SourceInfo(file, 4, 0), 1, UCIS_VLOG,
                            [cp1, cp2])

        cr.createBin("<v1[1],v2[1]>", SourceInfo(file, 4, 0), 1, 4, "v1,v2")

        cr.createBin("<v1[2],v2[1]>", SourceInfo(file, 4, 0), 1, 4, "v1,v2")

        cr.createBin("<v1[1],v2[2]>", SourceInfo(file, 4, 0), 1, 4, "v1,v2")

        cr.createBin("<v1[2],v2[2]>", SourceInfo(file, 4, 0), 1, 4, "v1,v2")

        out = StringIO()
        writer = XmlWriter()
        writer.write(out, db)

        print("XML Output:\n" + out.getvalue())
        input = StringIO(out.getvalue())
        validate_ucis_xml(input)

        input = StringIO(out.getvalue())
        reader = XmlReader()
        db2 = reader.read(input)

        out2 = StringIO()
        writer = XmlWriter()
        writer.write(out2, db2)
        print("XML Output2:\n" + out2.getvalue())
        input = StringIO(out2.getvalue())
        validate_ucis_xml(input)
Пример #6
0
    def test_simplest_create_2inst(self):

        ucisdb = "file_2inst.ucis"
        db = MemFactory.create()

        testnode = db.createHistoryNode(None, "logicalName", ucisdb,
                                        UCIS_HISTORYNODE_TEST)
        td = TestData(teststatus=UCIS_TESTSTATUS_OK,
                      toolcategory="UCIS:simulator",
                      date="20200202020")
        testnode.setTestData(td)

        file = db.createFileHandle("dummy", os.getcwd())

        srcinfo = SourceInfo(file, 0, 0)
        du1 = db.createScope(
            "foo.bar1",
            srcinfo,
            1,  # weight
            UCIS_OTHER,
            UCIS_DU_MODULE,
            UCIS_ENABLED_STMT | UCIS_ENABLED_BRANCH
            | UCIS_ENABLED_COND | UCIS_ENABLED_EXPR
            | UCIS_ENABLED_FSM | UCIS_ENABLED_TOGGLE
            | UCIS_INST_ONCE | UCIS_SCOPE_UNDER_DU)

        du2 = db.createScope(
            "foo.bar2",
            srcinfo,
            1,  # weight
            UCIS_OTHER,
            UCIS_DU_MODULE,
            UCIS_ENABLED_STMT | UCIS_ENABLED_BRANCH
            | UCIS_ENABLED_COND | UCIS_ENABLED_EXPR
            | UCIS_ENABLED_FSM | UCIS_ENABLED_TOGGLE
            | UCIS_INST_ONCE | UCIS_SCOPE_UNDER_DU)

        instance1 = db.createInstance(
            "dummy",
            None,  # sourceinfo
            1,  # weight
            UCIS_OTHER,
            UCIS_INSTANCE,
            du1,
            UCIS_INST_ONCE)

        cg1 = instance1.createCovergroup(
            "cg",
            SourceInfo(file, 3, 0),
            1,  # weight
            UCIS_OTHER)

        cp1 = cg1.createCoverpoint(
            "t",
            SourceInfo(file, 4, 0),
            1,  # weight
            UCIS_VLOG)

        cp1.createBin("auto[a]", SourceInfo(file, 4, 0), 1, 4, "a")

        du2 = db.createScope(
            "foo.bar2",
            srcinfo,
            1,  # weight
            UCIS_OTHER,
            UCIS_DU_MODULE,
            UCIS_ENABLED_STMT | UCIS_ENABLED_BRANCH
            | UCIS_ENABLED_COND | UCIS_ENABLED_EXPR
            | UCIS_ENABLED_FSM | UCIS_ENABLED_TOGGLE
            | UCIS_INST_ONCE | UCIS_SCOPE_UNDER_DU)

        instance2 = db.createInstance(
            "dummy",
            None,  # sourceinfo
            1,  # weight
            UCIS_OTHER,
            UCIS_INSTANCE,
            du2,
            UCIS_INST_ONCE)

        cg2 = instance2.createCovergroup(
            "cg",
            SourceInfo(file, 3, 0),
            1,  # weight
            UCIS_OTHER)

        cp2 = cg2.createCoverpoint(
            "t",
            SourceInfo(file, 4, 0),
            1,  # weight
            UCIS_VLOG)

        cp2.createBin("auto[a]", SourceInfo(file, 4, 0), 1, 4, "a")

        db.close()

        xmlout = StringIO()
        writer = XmlWriter()
        writer.write(xmlout, db)
        xmlin = StringIO(xmlout.getvalue())
        XmlReader.validate(xmlin)