Differential code coverage for a simple example in ifort

烈酒焚心 提交于 2019-12-24 07:53:10

问题


I am interested in using the differential code coverage functionality in ifort. The documentation appears to address this thoroughly but I have failed to apply it to my reduced example. Heres what I have:

program test
    integer :: userinput
    print *, 'enter 1 or 0'
    read *, userinput

    if (userinput.eq.1) then
        print *, 'You have entered ONE'
    else
        print *, 'You have not entered ONE'
    end if
end program test

A simple program that can take one of two paths. If the user enters 1 then it goes into the if ... then statement, if the user enters 0 then it goes into the else... statement.

The goal of differential code coverage (as stated by intel docs) is as follows:

compare the profiles from two runs of an application: a reference run and a new run identifying the code that is covered by the new run but not covered by the reference run

So if we take a reference run where the user enters 0 and a new run where the user enters 1, the differential code coverage should be able to identify that the new run covers the if statement whereas the reference run does not (reference run goes into the else statement). I followed the docs as closely as possible. The source file is called test.f90. Here are the compile lines i'm using:

ifort test.f90 /Qcov-gen

Which generates PGOPTI.SPI, PGOPTI, test.exe and test.obj. I then run the executable and enter 0, I get the correct message "You have not entered ONE". This causes a .dyn file to be created (due to the Qcov-gen option). I then do the following:

profmerge

Which generates additional files pgopti.dpi, pgopti.dpi.lock. At this point I think I have enough material to generate my reference data. This I attempt using the following:

codecov -prj Project_Name -dpi pgopti.dpi -ref pgopti.dpi

Which generates html files similar to the ones displayed when code coverage is run in Visual Studio for Intel Fortran. I also get 100% code coverage which seems incorrect. The docs then show this command:

codecov -prj Project_Name -spi pgopti.spi -dpi pgopti.dpi 

Which does not appear to provide an opportunity for a new run.

Could someone please explain how to do a simple differential code coverage on this particular example? I'm eventually trying to extrapolate this to a larger project but I'm trying to take baby steps to get there.

来源:https://stackoverflow.com/questions/46418203/differential-code-coverage-for-a-simple-example-in-ifort

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!