Example #1
0
def _run_and_cov(pgm, level, sco_args):
    """
    Execute gnatcov run then gnatcov coverage for the provided
    program `pgm`, expected to be the base name of without extension
    of an executable file. Pass `level` as --level to both commands
    and the provided `sco_args` to gnatcov coverage, and gnatcov run
    if we are doing mcdc.
    """

    level_arg = '--level=%s' % level

    # gnatcov run

    run_args = [exepath_to(pgm), level_arg]
    if 'mcdc' in level_arg:
        run_args.extend(sco_args)

    xrun(run_args)

    # gnatcov coverage

    cov_args = [
        '--annotate=xcov',
        '--trace=%s' % tracename_for(os.path.basename(pgm)), level_arg
    ] + sco_args

    xcov(['coverage'] + cov_args)
Example #2
0
 def exepath(main):
     main = os.path.join(
         gpr_exe_dir,
         (os.path.join(gprsw.subdirs, main) if gprsw.subdirs else main))
     return abspath(exepath_to(main))
Example #3
0
# Check correctness of transmission from Switches to commands for a few
# particular commands. Check that Switches ("*") comes before Switches (cmd).

wd = Wdir('wd_')

# We will be exercising combinations of run/coverage operations with option
# variations controlled via Coverage attributes in an otherwise common project
# file for a simple program.


def gprvariant(id, extra):
    return gprfor(prjid=id, srcdirs=['../src'], mains=['p.adb'], extra=extra)


exe = exepath_to('p')

# Build once
gprbuild(gprvariant(id='bld', extra=''))

# ------------------------------------------------
# -- Simple helpers for coverage/run variations --
# ------------------------------------------------
#
# --tag, valid only for gnatcov run.
# --annotate, valid only for gnatcov coverage.


def tag_for(id):
    return 'tag-%s' % id
Example #4
0
wd = Wdir('wd_')

# GPR with multiple mains

gprname = 'gen'
mainbases = ['test_tt', 'test_tf']
mainunits = [base + '.adb' for base in mainbases]

gprbuild(
    gprfor(prjid=gprname,
           srcdirs=['../../../../src', '../../src'],
           mains=mainunits))

# We expect this to work. The multiple mains in the gpr file are just ignored
# when there is an exe on the command line.
exe = exepath_to('test_tt')
trace = 'tt.trace0'
dump = 'tt.dump0'

xrun(['-P', gprname, '-o', trace, exe])
xcov(['dump-trace', trace], out=dump)
thistest.fail_if(
    len(re.findall('t block$', contents_of(dump), flags=re.M)) < 1,
    'with exe, no block execution trace found in %s' % trace)

# Again, _not_ providing the executable. Expected to fail
# from missing command line argument.
trace = 'oops.trace0'
dump = 'oops.dump'
xrun(['-P', gprname, '-o', trace], out=dump, register_failure=False)
Example #5
0
 def exepath(main):
     if gpr_exe_dir:
         main = os.path.join(gpr_exe_dir, m)
     return abspath(exepath_to(main))
Example #6
0
gpr_content = contents_of(gpr_filename)


def instantiate_gpr(target):
    with open(gpr_basename, 'w') as f:
        content = gpr_content.replace('%TARGET%', target)
        content = content.replace(
            '%RUNTIME%', 'for Runtime ("Ada") use "{}";'.format(
                thistest.options.RTS) if thistest.options.RTS else '')
        f.write(content)


for mode in ('no_arg', 'with_arg'):
    wd = Wdir('wd_{}'.format(mode))

    exe = exepath_to(mainbase)
    trace = tracename_for(mainbase)

    # Build with the real target as the Target attribute.
    instantiate_gpr(target)
    gprbuild(os.path.abspath(gpr_basename))

    argv = ['-P{}'.format(gprname), '-o', trace, exe]

    # Run with a bad target as the Target attribute in order to check that the
    # --target argument actually takes precedence.
    with_target_arg = mode == 'with_arg'
    if with_target_arg:
        instantiate_gpr('this_target_does_not_exist')

        # Force the passing of --target in the native case, as xrun() does not
Example #7
0
import re

from SUITE.context import thistest
from SUITE.cutils import Wdir, contents_of
from SUITE.tutils import exepath_to, gprbuild, gprfor, xcov, xrun

wd = Wdir('wd_')

# We have two candidate main drivers. Craft a gpr
# with a Main attribute listing only the first one.

mainbase1 = 'test_tt'
mainunit1 = mainbase1 + '.adb'
exe1 = exepath_to(mainbase1)

mainbase2 = 'test_tf'
mainunit2 = mainbase2 + '.adb'
exe2 = exepath_to(mainbase2)

gprname = gprfor(srcdirs=['../../../../src', '../../src'], mains=[mainunit1])

# Build both executables, passing both main unit
# names on the command line:
gprbuild(project=gprname, gargs=[mainunit1, mainunit2])

# Arrange to gnatcov run providing either exe1, exe2 or
# no executable. In all cases, expect to find a trace with
# at least an entry showing actual execution of something
# for this particular case.