def test_coverpoint_array_bin(self): cg = CovergroupModel("cg") a = 0 a_cp = CoverpointModel(ExprRefModel(lambda: a, 32, False), "a_cp", CoverageOptionsModel()) cg.add_coverpoint(a_cp) bins = a_cp.add_bin_model(CoverpointBinArrayModel("a", 0, 15)) cg.finalize() for i in range(8): a = i cg.sample() for i in range(16): if (i < 8): self.assertEqual(a_cp.get_bin_hits(i), 1) else: self.assertEqual(a_cp.get_bin_hits(i), 0) self.assertEqual(a_cp.get_coverage(), 50.0) self.assertEqual(cg.get_coverage(), 50.0)
def visit_coverpoint(self, cp : CoverpointModel): from ucis.source_info import SourceInfo active_s = self.active_scope_s[-1] cp_name = cp.name decl_location = None if cp.srcinfo_decl is not None: decl_location = SourceInfo( self.get_file_handle(cp.srcinfo_decl.filename), cp.srcinfo_decl.lineno, 0) # Obtain weight from coverpoint # TODO: obtain from .options vs .type_options? weight = cp.options.weight # TODO: obtain at_least from coverpoint and set on cp_scope at_least = cp.options.at_least # TODO: obtain goal from coverpoint and set on cp_scope # TODO: obtain comment from coverpoint and set on cp_scope cp_scope = active_s.createCoverpoint( cp_name, decl_location, weight, # weight UCIS_OTHER) # Source type self.coverpoint_m[cp.name] = cp_scope # TODO: setAtLeast() # cp_scope.set for bi in range(cp.get_n_bins()): decl_location = None bn_name = cp.get_bin_name(bi) cp_bin = cp_scope.createBin( bn_name, decl_location, at_least, # at_least cp.get_bin_hits(bi), bn_name, UCIS_CVGBIN) for bi in range(cp.get_n_ignore_bins()): decl_location = None bn_name = cp.get_ignore_bin_name(bi) cp_bin = cp_scope.createBin( bn_name, decl_location, at_least, # at_least cp.get_ignore_bin_hits(bi), bn_name, UCIS_IGNOREBIN) for bi in range(cp.get_n_illegal_bins()): decl_location = None bn_name = cp.get_illegal_bin_name(bi) cp_bin = cp_scope.createBin( bn_name, decl_location, at_least, # at_least cp.get_illegal_bin_hits(bi), bn_name, UCIS_ILLEGALBIN)