Exemple #1
0
 def generate(self, name, deps=(), mains=()):
     return gprfor(
         prjid=name, mains=mains, langs=['Ada'], deps=deps,
         srcdirs=['../../src-{}'.format(name)],
         objdir='obj-{}'.format(name),
         extra=gprcov_for(units_in=self.units_in,
                          units_out=self.units_out))
Exemple #2
0
    def gpr(self):
        """The GPR Coverage package corresponding to our lists of attribute
           contents, as a multiline string."""

        return gprcov_for(units_in=self.units_in,
                          units_out=self.units_out,
                          ulist_in=self.ulist_in,
                          ulist_out=self.ulist_out)
Exemple #3
0
def run(subdir, extra_args, covlevel=None):
    """
    Build and run the single test program, which volontarily performs stmt and
    decision coverage violations.
    """
    dirname = f"tmp_{subdir}"
    wd = Wdir(dirname)

    gpr = gprfor(mains=[pgm + '.adb'],
                 srcdirs=['../src'],
                 extra=gprcov_for(switches=[
                     Csw('*', ['--level=stmt']),
                     Csw('coverage', ['--annotate=report'])
                 ]))

    xcov_args = build_and_run(
        gprsw=GPRswitches(root_project=gpr),
        covlevel=covlevel,
        mains=[pgm],
        extra_coverage_args=[] if covlevel is None else ['--level', covlevel])
    xcov(xcov_args + extra_args)

    wd.to_homedir()
    return dirname
Exemple #4
0
from e3.fs import mkdir

from SCOV.minicheck import build_and_run
from SUITE.context import thistest
from SUITE.cutils import Wdir, contents_of
from SUITE.gprutils import Csw, GPRswitches, gprcov_for
from SUITE.tutils import gprfor, xcov

pgm = 'test_lt0'
wd = Wdir('wd_', clean=True)

gpr = gprfor(mains=[pgm + '.adb'],
             srcdirs=['../src'],
             extra=gprcov_for(switches=[
                 Csw('*', ['--level=stmt']),
                 Csw('coverage', ['--annotate=report'])
             ]))


def run(extra_args, covlevel=None):
    """
    Build and run the single test program, which volontarily performs stmt and
    decision coverage violations.
    """
    xcov_args = build_and_run(gprsw=GPRswitches(root_project=gpr),
                              covlevel=covlevel,
                              mains=[pgm],
                              extra_coverage_args=[])
    xcov(xcov_args + extra_args)

Exemple #5
0
"""
Check that invalid units passed as project attributes are properly reported.
"""

from SCOV.minicheck import build_run_and_coverage, check_xcov_reports
from SUITE.context import thistest
from SUITE.gprutils import GPRswitches, gprcov_for
from SUITE.cutils import Wdir, contents_of
from SUITE.tutils import gprfor

tmp = Wdir('wd_')

build_run_and_coverage(gprsw=GPRswitches(
    root_project=gprfor('main.adb',
                        srcdirs='..',
                        extra=gprcov_for(units_in=['no_such_unit', 'main']))),
                       covlevel='stmt',
                       mains=['main'],
                       extra_coverage_args=['-axcov'])

log_file = ('coverage.log'
            if thistest.options.trace_mode == 'bin' else 'instrument.log')
thistest.fail_if_not_equal(
    'gnatcov output',
    'warning: no unit no_such_unit in project gen (coverage.units attribute)',
    contents_of(log_file).strip())

check_xcov_reports('obj/*.xcov', {'obj/main.adb.xcov': {'+': {5}}})

thistest.result()
Exemple #6
0
def check_valid_sequence_for(id, gprcov):
    """
    Common checking sequence for a specific gpr coverage package
    with valid options for both run and coverage.
    """
    gpr = gprvariant(id=id, extra=gprcov)
    try_run(id, gpr)
    try_cov(id, gpr)


# Basic check for starters. No "*".
id = 'basic'
check_valid_sequence_for(id=id,
                         gprcov=gprcov_for(switches=[
                             Csw('run', tagopt_for(id)),
                             Csw('coverage',
                                 levopt_for(id) + annopt_for(id))
                         ]))

# Check that "*" applies to all. Pass --level there.
id = 'star_valid'
check_valid_sequence_for(id=id,
                         gprcov=gprcov_for(switches=[
                             Csw('*', levopt_for(id)),
                             Csw('run', tagopt_for(id)),
                             Csw('coverage', annopt_for(id))
                         ]))

# Check that command specific args prevail over "*", with "*" placed
# before in the gpr file.
id = 'star_postover'