Prerequisite:
-
lcov. Install viasudo apt-get install lcov -
Either of
gcov <= 7, orllvm-cov >= 11
gcov <= 7. Install gccsudo apt-get install gcc. For more information around managing multiple gcc/toolchains, please refer to this article.llvm-cov >= 11. You can either install using apt/yum/dnf, or the official LLVM installation script:
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 11
If your platform cannot install either of them, you can use another platform to analyze the generated gcno and gcda files. Ubuntu 18.04 has gcc-7 by default, and can install llvm 11 using the above script.
$ make COV=1
$ cd bin && ./app && cd ..
$ make gen_cov_html
Then open html/index.html, where amazing happens!
sgx_cov supports xargo as well:
$ XARGO_SGX=1 make COV=1
$ cd bin && ./app && cd ..
$ XARGO_SGX=1 make gen_cov_html
- Enable feature
global_exitforsgx_urts - Inject an
on exitfunction usingglobal_dtors_object!macro, and invokesgx_cov::cov_writeout() .gcnowould be generated during compile time atTarget_Dir.gcnawould be generated during run time atTarget_dirmake gen_cov_htmlwould process.gcnoand.gcnaand generate html results.
To be continued ...