# copy my solution to the desktop; for some reason, lcov doesn't # like to operate on sshfs-mounted directories cp -r ../../assignments/hw1/hw1_soln ~/Desktop/ cd ~/Desktop/hw1_soln # let's try to do code coverage for my LinkedList.c and AVLTree.c # files; we'll compile LinkedList.o and AVLTreeree.o, telling gcc to # instrument the object files with gcov coverage: gcc -o LinkedList.o -Wall -fprofile-arcs -ftest-coverage -c LinkedList.c gcc -o AVLTree.o -Wall -fprofile-arcs -ftest-coverage -c AVLTree.c # compile the test drivers and link them to the gcov-instrumented # object files g++ -o test_linkedlist.o -c test_linkedlist.cc g++ -o test_avltree.o -c test_avltree.cc g++ -Wall -o test_suite -fprofile-arcs -ftest-coverage *.o -L./gtest -lgtest -lphtread # run the linked list test driver, produce a coverage report for it ./test_suite # we can view a text version of the coverage report gcov LinkedList.c less LinkedList.c.gcov # we can also produce a nice, HTML version of the coverage report cd .. mkdir html cd html lcov --directory ../hw1_soln --capture --output-file hw1.info genhtml hw1.info firefox index.html # let's run the AVLTree test driver. This will produce coverage # data for AVLTree.c. Any new data this creates for LinkedList.c # is aggregated with the existing data we already collected. cd ../hw1_soln gcov AVLTree.c gprof AVLTree.c.info | less cd ../html lcov --directory ../hw1_soln --capture --output-file hw1.info genhtml hw1.info firefox index.html # if we wanted to reset the coverage data we've accumulated so # far, we can cd back into hw1_soln and delete the coverage # data files. cd ../hw1_soln rm *.gcda