# 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 ll.c and hashtable.c files;
# we'll compile ll.o and hashtable.o, telling gcc to instrument
# the object files with gcov coverage
gcc -o ll.o -Wall -fprofile-arcs -ftest-coverage -c ll.c
gcc -o hashtable.o -Wall -fprofile-arcs -ftest-coverage -c hashtable.

# compile the test drivers and link them to the gcov-instrumented
# object files
gcc -o test_driver_ll.o -c test_driver_ll.c 
gcc -o test_driver_ht.o -c test_driver_ht.c
gcc -Wall -o test_driver_ll -fprofile-arcs -ftest-coverage ll.o test_driver_ll.o -LCUnit -lcunit
gcc -Wall -o test_driver_ht -fprofile-arcs -ftest-coverage hashtable.o test_driver_ht.o ll.o -LCUnit -lcunit

# run the linked list test driver, produce a coverage report for it
./test_driver_ll

# we can view a text version of the coverage report
gcov ll.c
less ll.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 hashtable test driver.  This will produce coverage
# data for hashtable.c, and since the hashtable exercises the linked
# list, we'll collect more coverage data for ll.c; the new data for
# ll.c is aggregated with the existing data we already collected.
cd ../hw1_soln
./test_driver_ht
gcov hashtable.c
gprof hashtable.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