1. 程式人生 > >C變異測試 mutation testing 工具 Milu

C變異測試 mutation testing 工具 Milu

最近在做mutation testing實驗時,發現支援傳統C語言的工具很少,不像JAVA, 有很多很強大的比如PIT,很早之前出過一個Proteum/IM 2.0, 這個算是老古董了基於LI中間語言的,很多如今的程式是支援不來了

下面推薦一個新的基於clang的工具Milu,中文麋鹿,是一箇中國人開發的

Compilation in Ubuntu

  • sudo apt-get install build-essential libglib2.0-dev llvm libclang-dev
  • cd Milu
  • make

Usage

  • ./bin/milu -f func.txt src.c NB: src.c need to be processed by gcc -E, func.txt contains a list of names of the functions under test

  • ./bin/milu -? (to show options)


func.txt 可以寫函式比如main

還可以自定義mutation operator

-m mop.txt 來實現, 比如指定OAAA

這個工具是軟工大牛mark的學生實現的,如果感興趣細節可以參考下面的論文

Yue Jia and Mark Harman. Milu: A Customizable, Runtime-Optimized Higher Order Mutation Testing Tool for the Full C Language TAIC PART'08, Windsor, UK, 29th-31st August 2008.


簡單的說分為下面幾部

1 確定需要的mutation operator,

2, 構建AST,遍歷每一個node,判斷是否符合哪些mutation operator的pattern, 可以看成一種分類

3,  根據分類結果,採取每一種operator 對應的變異行為來變異,修改AST node

4. 通過新的AST 構建新的原始檔