|
| 1 | +""" |
| 2 | +Check that the instrumentation of Ada sources with preprocessing enabled works |
| 3 | +as expected on an example project. |
| 4 | +""" |
| 5 | + |
| 6 | +import os |
| 7 | +import os.path |
| 8 | + |
| 9 | +from SCOV.minicheck import build_run_and_coverage, check_xcov_reports |
| 10 | +from SUITE.context import thistest |
| 11 | +from SUITE.cutils import Wdir |
| 12 | +from SUITE.tutils import gprfor |
| 13 | +from SUITE.gprutils import GPRswitches |
| 14 | + |
| 15 | + |
| 16 | +tmp = Wdir("tmp_") |
| 17 | + |
| 18 | +# Avoid "creating output path" info messages |
| 19 | +os.mkdir("obj") |
| 20 | + |
| 21 | +# Test the working case. The "log" preprocessing symbol is set to "false" in |
| 22 | +# "prep.txt", so all logging lines are supposed to be disabled and thus not |
| 23 | +# create coverage obligations. Yet the line numbers for the code remaining are |
| 24 | +# supposed to be preserved. |
| 25 | +thistest.log("== Up to the coverage report ==") |
| 26 | +build_run_and_coverage( |
| 27 | + gprsw=GPRswitches( |
| 28 | + root_project=gprfor( |
| 29 | + mains=["test_eval.adb"], |
| 30 | + srcdirs=[".."], |
| 31 | + compiler_extra=( |
| 32 | + 'for Default_Switches ("Ada")' |
| 33 | + ' use ("-gnatep=" & Project\'Project_Dir & "/../prep.txt");' |
| 34 | + ), |
| 35 | + ) |
| 36 | + ), |
| 37 | + covlevel="stmt+decision", |
| 38 | + mains=["test_eval"], |
| 39 | + extra_coverage_args=["-axcov", "--output-dir=xcov"], |
| 40 | + trace_mode="src", |
| 41 | +) |
| 42 | +check_xcov_reports( |
| 43 | + "*.xcov", |
| 44 | + { |
| 45 | + "test_eval.adb.xcov": {"+": {4}, "!": {12}, "-": {13}}, |
| 46 | + "vm.ads.xcov": {"+": {3, 4, 6, 7, 16, 17}}, |
| 47 | + "vm.adb.xcov": { |
| 48 | + "+": { |
| 49 | + # Eval header |
| 50 | + 13, |
| 51 | + |
| 52 | + # Pop |
| 53 | + 27, 31, |
| 54 | + |
| 55 | + # Push |
| 56 | + 43, 44, |
| 57 | + |
| 58 | + # Eval loop |
| 59 | + 61, 62, 70, 72, 87, 89, 90, 96, |
| 60 | + |
| 61 | + # Eval wrapper |
| 62 | + 117, 118, 121, 122, 123, 125, 126, 127, |
| 63 | + }, |
| 64 | + "!": { |
| 65 | + # Branch condition evaluation |
| 66 | + 78 |
| 67 | + }, |
| 68 | + "-": { |
| 69 | + # Jump |
| 70 | + 75, |
| 71 | + |
| 72 | + # Branch jump |
| 73 | + 79, |
| 74 | + |
| 75 | + # Push_Lit, Add |
| 76 | + 83, 94, |
| 77 | + }, |
| 78 | + }, |
| 79 | + }, |
| 80 | + cwd="xcov", |
| 81 | +) |
| 82 | + |
| 83 | +thistest.result() |
0 commit comments