def xcov_run(self, main): """run MAIN through "xcov run" to produce an execution trace.""" # Feed xcov run with full path (absolute dir) of the program so we # can directly get to the binary from the trace when reading it from # a different directory, such as in consolidation tests. ofile = "xcov_run_%s.out" % main # Some execution engines (e.g. valgrind) do not let us distinguish # executed program errors from engine errors. Because of them, we # ignore here any kind of execution error for tests expected to trigger # failures (such as harness tests), assuming that they will perform # further checks that are bound to fail if the execution doesn't # proceed as expected somehow (e.g. not producing a trace). xrun([ self.abdir_for(main) + exename_for(main), "--level=%s" % self.xcovlevel ] + self.scoptions, out=ofile, register_failure=not self.testcase.expect_failures) thistest.fail_if( match( "(!!! EXCEPTION RAISED !!!" "|raised [A-Z_]+ : [-._a-zA-Z]+:[0-9]+ \w+)", ofile), "exception raised while running '%s'." % main)
def run(self): tmp = Wdir('tmp_') # Compile all the sources. This method will not work if there are # sources that are not in the "." directory, but since executabes are # processed next, there will be an error if not all sources are # compiled. project = gprfor(self.sources, srcdirs=[".."], main_cargs=self.options) gprbuild(project, gargs=["-bargs", "-z"]) # If requested, check at least one non statement SCO in alis if self.ensure_dcscos: for ali in self.alis: thistest.fail_if(not match('^C[^S ]', ali, re.MULTILINE), "couldn't find non-statement SCO in %s" % ali) # Run xcov map-routines and check absence of errors mapoutput = do( maybe_valgrind([ XCOV, 'map-routines', '-v', '--scos=@{}'.format(list_to_file(self.alis)), ] + self.execs)) maperrors = [ str(m) for m in re.findall(r"(\*\*\*|\!\!\!)(.*)", mapoutput) ] thistest.log('\n'.join(maperrors)) thistest.fail_if( maperrors, "expect no map-routines error for %s" % ", ".join(self.sources)) tmp.to_homedir()
def run_test(self, main): """Execute the MAIN program to produce an execution trace, and trigger a failure if it raises an unhandled exception.""" out_file = self.mode_execute(main=main) thistest.fail_if( match( "(!!! EXCEPTION RAISED !!!" "|raised [A-Z_]+ : [-._a-zA-Z]+:[0-9]+ \w+)", out_file), "exception raised while running '%s'." % main)
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) thistest.fail_if( not match(': Please specify an executable to run', dump), 'missing expected error diag on main-less invocation of gnatcov run') thistest.result()