標籤:blog http 使用 ar strong 檔案 sp art c
很多IT公司對於軟體開發都有嚴格的分工,這包括設計、測試、服務支援等等。但是,我一直都認為只有開發人員才是真正對軟體品質負責的人。沒有好的軟體設計,軟體品質基本上是無從談起。當然,要做到這一點是需要額外的一些工具來進行保證的。因為這一段時間都是在linux上開發的,所以下面涉及到的工具基本上都是基於linux平台的。假設測試的檔案名稱為test.c。
(1)測試程式碼涵蓋範圍
- gcc -fprofile-arcs -ftest-coverage -o test test.c
- ./test
- gcov test.c
GCOV使用: http://blog.csdn.net/lishenglong666/article/details/8056777
(2)代碼靜態測試
- sudo apt-get install splint
- splint test.c
splint的學習與使用: http://www.cnblogs.com/bangerlee/archive/2011/09/07/2166593.html
(3)記憶體流失測試
- sudo apt-get install valgrind
- ./test
- valgrind --tool=memcheck --leak-check=yes ./test
(4)效能測試
- gcc test.c -pg -o test
- ./test
- gprof test gmon.out -p
(5)單元測試CUnit-2-0-1
- aclocal
- autoconf
- autoheader
- chmod u+x configure
- libtoolize
- automake --add-missing
- ./configure
- make
因為CUnit-2-0-1中有一個test_cunit代碼,所以大家可以直接看看單元測試下是怎麼運行和測試的。
上面的幾個工具都是linux下測試的幾個工具,大家可以根據自己的需要進行靈活的選擇。當然,在實際開發中,我們需要把這些工具整合到makefile中,這樣可以達到最好的測試效果。
參考連結:http://blog.csdn.net/feixiaoxing/article/details/39716601
linux 提高代碼品質的工具