Microsoft Word - 【第5分科会】ConcolicTestingグループ_付録_修正_ doc

Similar documents
kiso2-03.key

Microsoft Word - no12.doc

新・明解C言語 実践編

Microsoft Word - Training10_プリプロセッサ.docx

C言語によるアルゴリズムとデータ構造

PowerPoint Presentation

PowerPoint プレゼンテーション

プログラミング基礎

kiso2-09.key

Microsoft PowerPoint - 10.ppt [互換モード]

C プログラミング演習 1( 再 ) 2 講義では C プログラミングの基本を学び 演習では やや実践的なプログラミングを通して学ぶ

[1] #include<stdio.h> main() { printf("hello, world."); return 0; } (G1) int long int float ± ±

PowerPoint プレゼンテーション

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裶²ó ¨¡ À©¸æ¹½Â¤¡§·«¤êÊÖ¤· ¨¡

/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v

memo

画像ファイルを扱う これまでに学んだ条件分岐, 繰り返し, 配列, ファイル入出力を使って, 画像を扱うプログラムにチャレンジしてみよう

8 / 0 1 i++ i 1 i-- i C !!! C 2

C C UNIX C ( ) 4 1 HTML 1

プログラミング実習I

プログラミング及び演習 第1回 講義概容・実行制御

ポインタ変数

プログラミング基礎

1 4 2 EP) (EP) (EP)

Microsoft PowerPoint - 計算機言語 第7回.ppt

slide5.pptx

メソッドのまとめ

Microsoft Word - no15.docx

Taro-再帰関数Ⅲ(公開版).jtd

Informatics 2015

Taro-再帰関数Ⅱ(公開版).jtd

Taro-リストⅠ(公開版).jtd

Informatics 2014

Taro-ファイル処理(公開版).jtd

memo

Prog1_15th

ポインタ変数

Prog1_6th

ex01.dvi

次に示す数値の並びを昇順にソートするものとする このソートでは配列の末尾側から操作を行っていく まず 末尾の数値 9 と 8 に着目する 昇順にソートするので この値を交換すると以下の数値の並びになる 次に末尾側から 2 番目と 3 番目の 1

関数 C 言語は関数の言語 関数とは 関数の定義 : f(x) = x * x ; 使うときは : y = f(x) 戻り値 引数

Undestand の解析 Understand の C 言語で抽出できない依存関係について サンプルコードを用いて説明します 確認バージョン Understand 3.0 (Build 640) Understand 3.1 (Build 700) Understand 4.0 (Build 78

debug ( ) 1) ( ) 2) ( ) assert, printf ( ) Japan Advanced Institute of Science and Technology

file:///D|/C言語の擬似クラス.txt

第3回 配列とリスト

02: 変数と標準入出力

I. Backus-Naur BNF : N N 0 N N N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) (2) (3) (4) II. 0(0 101)* (

4 分岐処理と繰返し処理 ( 教科書 P.32) プログラムの基本的処理は三つある. (1) 順次処理 : 上から下に順番に処理する ぶんきそろ (2) 分岐処理 : 条件が揃えば, 処理する はんぷく (3) 反復処理 : 条件が揃うまで処理を繰り返す 全てのプログラムは (1) から (3) の

PGRelief C/C++ 強化ポイント説明書

PowerPoint プレゼンテーション

C 言語第 3 回 2 a と b? 関係演算子 a と b の関係 関係演算子 等しい a==b 等しくない a!=b より大きい a>b 以上 a>=b より小さい a<b 以下 a<=b 状態 真偽 値 条件が満たされた場合 TRUE( 真 ) 1(0 以外 ) 条件が満たされなかった場合 F

Microsoft Word - no11.docx

Microsoft PowerPoint - kougi11.ppt

I 2 tutimura/ I 2 p.1/??

kiso2-06.key

Cプログラミング1(再) 第2回

double float

Report#2.docx

情報処理演習 B8クラス

Microsoft PowerPoint - 説明2_演算と型(C_guide2)【2015新教材対応確認済み】.pptx

計算機プログラミング

Maple 12 Windows版シングルユーザ/ネットワークライセンス

Microsoft PowerPoint - C_Programming(3).pptx

C¥×¥í¥°¥é¥ß¥ó¥° ÆþÌç

第2回講義:まとめ

1 return main() { main main C 1 戻り値の型 関数名 引数 関数ブロックをあらわす中括弧 main() 関数の定義 int main(void){ printf("hello World!!\n"); return 0; 戻り値 1: main() 2.2 C main

ServerView RAID Manager VMware vSphere ESXi 6 インストールガイド

ゲームエンジンの構成要素

はじめてのコンコリックテスト

PowerPoint Presentation

appli_HPhi_install

新・明解C言語で学ぶアルゴリズムとデータ構造

コンピュータ工学講義プリント (7 月 17 日 ) 今回の講義では フローチャートについて学ぶ フローチャートとはフローチャートは コンピュータプログラムの処理の流れを視覚的に表し 処理の全体像を把握しやすくするために書く図である 日本語では流れ図という 図 1 は ユーザーに 0 以上の整数 n

Microsoft PowerPoint - 説明3_if文switch文(C_guide3)【2015新教材対応確認済み】.pptx

Microsoft Word - Cプログラミング演習(12)

I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) + x * x + x x (4) * *

プログラミング基礎

Prog1_10th

Microsoft PowerPoint - lec4.ppt

memo

/*Source.cpp*/ #include<stdio.h> //printf はここでインクルードして初めて使えるようになる // ここで関数 average を定義 3 つの整数の平均値を返す double 型の関数です double average(int a,int b,int c){

DVIOUT

情報工学実験 C コンパイラ第 2 回説明資料 (2017 年度 ) 担当 : 笹倉 佐藤

memo

ServerView RAID Manager VMware vSphere ESXi 5 インストールガイド

<4D F736F F D20438CBE8CEA8D758DC F0939A82C282AB2E646F63>

Microsoft Word - Cプログラミング演習(1)_2012

演習課題No12

Microsoft Word - no206.docx

Microsoft Word - Cプログラミング演習(3)

Microsoft PowerPoint - C言語の復習(配布用).ppt [互換モード]

void hash1_init(int *array) int i; for (i = 0; i < HASHSIZE; i++) array[i] = EMPTY; /* i EMPTY */ void hash1_insert(int *array, int n) if (n < 0 n >=

Microsoft Word - report#8.docx

A/B (2010/10/08) Ver kurino/2010/soft/soft.html A/B

kantan_C_1_iro3.indd

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU

Microsoft Word - C言語研修 C++編 3.doc

Solaris 10 10/08 OSにおける統合インストーラの注意事項

1. 関数 scanf() 関数 printf() は変数の値を画面に表示しますが それに対し関数 scanf() はキーボードで入力した値を変数に代入します この関数を活用することで対話式 ( ユーザーの操作に応じて処理を行う ) プログラムを作ることができるようになります 整数の和

P05.ppt

Transcription:

付録 1 研究スケジュール 本研究は以下のスケジュールで行った. 項目内容期間論文調査 CREST に関する論文の調査 2014 年 5 月 CREST のインストール VMWare による Linux 環境の構築と,CREST 及び必要プログラムのインストール CREST の試用サンプルコードにて CREST を実行して, 出力結果を確認 SIG の準備 実施ソフトウェア品質シンポジウム SIG: Let s Concolic Testing の準備と実施 バグの抽出方法をマスターする新旧プログラムの結果比較方法をマスターする実施手順の整理 バグの種類と CREST での摘出可能性についての調査デグレード防止のための比較方法についての調査バグの抽出方法及び新旧プログラムの比較についてのまとめ 2014 年 5 月 ~ 2014 年 6 月 2014 年 7 月 ~ 2014 年 8 月 2014 年 8 月 ~ 2014 年 9 月 2014 年 8 月 ~ 2014 年 11 月 2014 年 11 月 ~ 2014 年 12 月 2014 年 12 年 ~ 2015 年 1 月 付録 2 CREST 検証環境 CREST 検証環境を以下に記す. ホスト OS VM ゲスト OS Concolic-testing ツール Crest 走行に必要なツール Windows7(32bit),Windous8(32bit) VMware-6.0.2 Ubuntu-14.0.4 CREST-0.1.1 Yices CIL OCAML CREST は Linux または Mac OS X 上で動作する. 本研究では,Windows 上の仮想環境 (VMware) で Linux を動作させることにした.

付録 3 三角形形状判定プログラムのソースコード : オリジナル 3.2 で示した三角形形状判定プログラムの仕様に基づき作成したプログラム. /* Concolic-Testing 例題 : 三角形の形状判断 */ #include <stdio.h> #include <assert.h> int triangle(int iside1, int iside2, int iside3); int main(void){ /* main は関数を呼び出して結果をプリント */ int a,b,c,m; printf("input 3 sides value =>"); scanf("%d %d %d",&a,&b,&c); m = triangle(a,b,c); printf("shape of Triangle = %d\n", m); return 0; /* 形状を判定する */ int triangle(int iside1, int iside2, int iside3){ int msg; /* 入力データ誤りのチェック */ if(iside1 <= 0 iside2 <= 0 iside3 <= 0) { printf("\n"); /* 三角形であることのチェック */ if ((iside1 + iside2)<= iside3 (iside2 + iside3)<= iside1 (iside1 + iside3)<= iside2) { printf("\n"); /* 三角形の形状判定 */ else{ msg = 20; /* 不等辺三角形 */ if( iside1 == iside2 iside2 == iside3 iside1 == iside3){ msg = 30; /* 二等辺三角形 */ if (iside1 == iside2 && iside1 == iside3){ msg =40; /* 正三角形 */

付録 4 CREST 対応した三角形形状判定プログラムの解析とテスト実行結果 (1) ソースコードソースコード名 :triangle.c 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 /* Concolic-Testing 三角形の形状判断 */ #include <crest.h> #include <stdio.h> #include <assert.h> #define DEBUGMD int triangle(int iside1, int iside2, int iside3); int main(void){ /* main は関数を呼び出して結果をプリント */ int a,b,c,m; #ifndef DEBUGMD /* CREST 実行時はスキップ */ printf("input 3 sides value =>"); scanf("%d %d %d",&a,&b,&c); #endif m = triangle(a,b,c); printf("shape of Triangle = %d\n", m); return 0; CREST 実行用に Symbolic 変数を宣言 CRSET 実行時に入力しなくて良いようにした /* 形状を判定する */ int triangle(int iside1, int iside2, int iside3){ int msg; CREST_int(iSide1); CREST_int(iSide2); CREST_int(iSide3); /* 入力データ誤りのチェック */ if(iside1 <= 0 iside2 <= 0 iside3 <= 0) { printf("\n"); /* 三角形であることのチェック */ if ((iside1 + iside2)<= iside3 (iside2 + iside3)<= iside1 (iside1 + iside3)<= iside2) { printf("\n"); /* 三角形の形状判定 */ else{ msg = 20; /* 不等辺三角形 */ if( iside1 == iside2 iside2 == iside3 iside1 == iside3){ msg = 30; /* 二等辺三角形 */ if (iside1 == iside2 && iside1 == iside3){ msg =40; /* 正三角形 */

(2) run_crest で (4) の CREST 生成値を出力する方法 1CREST のプログラムにパッチを充てる * 本研究ではこちらを採用 Crest の src/run_crest/concolic_search.cc にパッチを入れる. Search::RunProgram() のところ. LaunchProgram() 処理の直前に次を入れる. //Save the given inputs. Char fname[32]; Snprintf(fname, 32 "input.%d", num_iters_); WriteInputToFileOrDie(fname,inputs); crest を make する. 出力先 :input ファイル 2 印刷 (printf) 文を挿入する CREST 変数宣言の後ろに printf("%d,%d,%d\n",iside1,iside2,iside3); を挿入する. CREST_int(iSide1); CREST_int(iSide2); CREST_int(iSide3); 出力先 :(4)run_crest コマンドによるテスト実行 (3)CRESTC コマンドによるコード解析実行 mptqa@mptqa-virtual-machine:~/crest/test/triangle$ /home/mptqa/crest/crest-0.1.1/bin/crestc triangle.c gcc -D_GNUCC -E -I/home/mptqa/CREST/crest-0.1.1/bin/../include -DCIL=1 triangle.c -o./triangle.i CRESTC のコマンド. C プログラムを配置したディレクトリか /home/mptqa/crest/crest-0.1.1/cil/obj/x86_linux/cilly.asm.exe --out./triangle.cil.c ら,crestc を実行する. --docrestinstrument./triangle.i gcc -D_GNUCC -E -I/home/mptqa/CREST/crest-0.1.1/bin/../include./triangle.cil.c -o./triangle.cil.i gcc -D_GNUCC -c -I/home/mptqa/CREST/crest-0.1.1/bin/../include -o./triangle.o./triangle.cil.i triangle.c:11:1: warning: crest_skip attribute directive ignored [-Wattributes] /* main は関数を呼び出して結果をプリント */ このようにコメントなど CRSETC の解析では無視される warning がいくつか出るが, ここでは以降割愛する. gcc -D_GNUCC -o triangle -I/home/mptqa/CREST/crest-0.1.1/bin/../include./triangle.o /home/mptqa/crest/crest-0.1.1/bin/../lib/libcrest.a -L/home/mptqa/CREST/crest-0.1.1/bin/../lib -lstdc++ Read 22 branches. ブランチ数, ノード数, Read 46 nodes. エッジ数が出力される. Wrote 22 branch edges.

(4)run_crest コマンドによるテスト実行 mptqa@mptqa-virtual-machine:~/crest/test/triangle$ /home/mptqa/crest/crest-0.1.1/bin/run_cr est./triangle 20 -dfs Iteration 0 (0s): covered 0 branches [0 reach funs, 0 reach branches]. run_crest のコマンド. [20] は実行される Iteration 数以上 Iteration 1 (0s): covered 1 branches [1 reach funs, 22 reach branches]. Iteration 2 (0s): covered 3 branches [1 reach funs, 22 reach branches]. Iteration 3 (0s): covered 5 branches [1 reach funs, 22 reach branches]. Shape of Triangle = 40 Iteration 4 (0s): covered 12 branches [1 reach funs, 22 reach branches]. Iteration 5 (0s): covered 13 branches [1 reach funs, 22 reach branches]. を入力する必要がある.( このプログラムの場合,11 以上 ) [-dfs] で深さ優先探索を指定. 各 Iterationはパスと入力値を組合せたテストの繰り返す数である. : 三角形の形状を出力. CREST で生成される辺長は通常表示されないの で, 別ファイルに出力されるようにした Iteration 6 (0s): covered 14 branches [1 reach funs, 22 reach branches]. Iteration 7 (0s): covered 15 branches [1 reach funs, 22 reach branches]. Iteration 8 (0s): covered 19 branches [1 reach funs, 22 reach branches]. Iteration 9 (0s): covered 20 branches [1 reach funs, 22 reach branches]. Shape of Triangle = 20 CRESTC で算出された 22 個のブランチを 11 個の Iteration でカバーしている. Iteration 10 (0s): covered 21 branches [1 reach funs, 22 reach branches]. Iteration 11 (0s): covered 22 branches [1 reach funs, 22 reach branches]. (5)run_crest コマンド実行時の CREST で生成された入力値 input1,,input11 と別ファイルで出力されたものを整理する. Iteration1 と input1,,iteration11 と input11 が対応している. input1 input2 input3 input4 input5 input6 input7 input8 input9 input10 input11 iside1 0 1 1 1 1 2 1 2 3 4 2 iside2 0 0 1 1 1 1 2 1 2 3 2 iside3 0 0 0 1 2 1 1 2 2 2 1 (6) 表 2. 三角形形状判定プログラム :CREST 実行結果の DT との対応 run_crest コマンドによるテスト実行結果と run_crest コマンド実行時の CREST で生成された入力値を組み合わせる. テストケース 1 11 原因 結果 辺長 A 0 2 B 0 2 C 0 1 Invalid(10) X 三角形非形成 (10) 正三角形 (40) 二等辺三角形 (30) X 不等辺三角形 (20)

(7)CRESTC コマンドで解析した中間言語展開後の制御パス CREST の出力する Configuration(CFG) 情報を使って作成する. 1 22 iside2+iside3<=iside1? 2 23 Print 3 24 4 25 45 5 iside1< 0? 26 iside1+iside3<=iside2? 6 Print 27 Print 7 28 8 45 29 45 9 iside2< 0? 30 10 Print 31 iside1=iside2? 11 32 12 45 iside2=iside3? 33 13 iside3< 0? 34 14 Print iside1=iside3? 35 15 36 16 45 37 iside1=iside2? 17 iside1+iside2<=iside3? 38 iside1=iside3? 18 22 39 19 Print 41 40 20 42 21 45 43 44 6 45

付録 5 三角形形状判定プログラム ( バグ有 ) の解析とテスト実行結果 1 (1) ソースコードソースコード名 :triangle_bug.c 1 2 3 4 5 6 /* Concolic-Testing 三角形の形状判断 */ #include <crest.h> #include <stdio.h> #include <assert.h> #define DEBUGMD 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 /* 三角形であることのチェック */ if ((iside1 + iside2)< iside3 (iside2 + iside3)< iside1 (iside1 + iside3)< iside2) { printf("\n"); /* 三角形の形状判定 */ else{ if ((iside1 + iside2)<= iside3 (iside2 + iside3)<= iside1 (iside1 + iside3)<= iside2) を if ((iside1 + iside2)< iside3 (iside2 + iside3)< iside1 (iside1 + iside3)< iside2) とバグ有の状態にする. msg = 20; /* 不等辺三角形 */ if( iside1 == iside2 iside2 == iside3 iside1 == iside3){ msg = 30; /* 二等辺三角形 */ if (iside1 == iside2 && iside1 == iside3){ msg =40; /* 正三角形 */ (2)CRESTC コマンドによるコード解析結果 mptqa@mptqa-virtual-machine:~/crest/test/triangle_bug$ /home/mptqa/crest/crest-0.1.1/bin/cr estc triangle_bug.c gcc -D_GNUCC -E -I/home/mptqa/CREST/crest-0.1.1/bin/../include -DCIL=1 triangle_bug.c -o./triangle_bug.i /home/mptqa/crest/crest-0.1.1/cil/obj/x86_linux/cilly.asm.exe --out./triangle_bug.cil.c --docrestinstrument./triangle_bug.i gcc -D_GNUCC -E -I/home/mptqa/CREST/crest-0.1.1/bin/../include./triangle_bug.cil.c -o./triangle_bug.cil.i gcc -D_GNUCC -c -I/home/mptqa/CREST/crest-0.1.1/bin/../include -o./triangle_bug.o./triangle_bug.cil.i Warning は割愛 gcc -D_GNUCC -o triangle_bug -I/home/mptqa/CREST/crest-0.1.1/bin/../include./triangle_bug.o /home/mptqa/crest/crest-0.1.1/bin/../lib/libcrest.a -L/home/mptqa/CREST/crest-0.1.1/bin/../lib -lstdc++ Read 22 branches. Read 46 nodes. Wrote 22 branch edges. 7

(3)run_crest コマンドによるテスト実行結果 mptqa@mptqa-virtual-machine:~/crest/test/triangle_bug$ /home/mptqa/crest/crest-0.1.1/bin/run_ crest./triangle_bug 20 -dfs Iteration 0 (0s): covered 0 branches [0 reach funs, 0 reach branches]. Iteration 1 (0s): covered 1 branches [1 reach funs, 22 reach branches]. Iteration 2 (0s): covered 3 branches [1 reach funs, 22 reach branches]. Iteration 3 (0s): covered 5 branches [1 reach funs, 22 reach branches]. Shape of Triangle = 40 Iteration 4 (1s): covered 12 branches [1 reach funs, 22 reach branches]. Iteration 5 (1s): covered 13 branches [1 reach funs, 22 reach branches]. Iteration 6 (1s): covered 14 branches [1 reach funs, 22 reach branches]. Iteration 7 (1s): covered 15 branches [1 reach funs, 22 reach branches]. Iteration 8 (1s): covered 18 branches [1 reach funs, 22 reach branches]. Shape of Triangle = 20 Iteration 9 (1s): covered 20 branches [1 reach funs, 22 reach branches]. Iteration 10 (1s): covered 21 branches [1 reach funs, 22 reach branches]. Iteration 11 (1s): covered 22 branches [1 reach funs, 22 reach branches]. (4)run_crest 実行時の各 Iteration の入力値 input1 input2 input3 input4 input5 input6 input7 input8 input9 input10 input11 iside1 0 1 1 1 1 3 1 2 3 1 2 iside2 0 0 1 1 1 1 3 1 2 2 2 iside3 0 0 0 1 3 1 1 1 1 1 1 8

付録 6 三角形形状判定プログラム ( バグ有 ) の解析とテスト実行結果 2 (1) ソースコードソースコード名 :triangle_bug_add_assert.c 1 34 /* Concolic-Testing 三角形の形状判断 */ /* 三角形であることのチェック */ #ifdef DEBUGMD assert( (iside1 + iside3)<= iside2); #endif assert 挿入. ここでは単純にバグに対する条件文としたが, バグの種類により assert を工夫する必要がある. 35 36 37 38 39 40 if ((iside1 + iside2)<= iside3 (iside2 + iside3)<= iside1 (iside1 + iside3)< iside2) { printf("\n"); (iside1 + iside3)<= iside2) を (iside1 + iside3)< iside2) とバグ有の状態にする. (2)CRESTC コマンドによるコード解析結果 mptqa@mptqa-virtual-machine:~/crest/test/triangle_add+bug _assert$ /home/mptqa/crest/crest-0.1.1/bin/crestc triangle_add_bug_assert.c gcc -D_GNUCC -E -I/home/mptqa/CREST/crest-0.1.1/bin/../include -DCIL=1 triangle_add_bug_assert.c -o./triangle_add_bug_assert.i /home/mptqa/crest/crest-0.1.1/cil/obj/x86_linux/cilly.asm.exe --out./triangle_add_bug_assert.cil.c --docrestinstrument./triangle_add_bug_assert.i gcc -D_GNUCC -E -I/home/mptqa/CREST/crest-0.1.1/bin/../include./triangle_add_bug_assert.cil.c -o./triangle_add_bug_assert.cil.i gcc -D_GNUCC -c -I/home/mptqa/CREST/crest-0.1.1/bin/../include -o./triangle_add_bug_assert.o./triangle_add_bug_assert.cil.i Warning は割愛 gcc -D_GNUCC -o triangle_add_bug_assert -I/home/mptqa/CREST/crest-0.1.1/bin/../include./triangle_add_bug_assert.o /home/mptqa/crest/crest-0.1.1/bin/../lib/libcrest.a -L/home/mptqa/CREST/crest-0.1.1/bin/../lib -lstdc++ Read 34 branches. Read 66 nodes. Wrote 38 branch edges. 9

(3)run_crest コマンドによるテスト実行結果 mptqa@mptqa-virtual-machine:~/crest/test/triangle_add+bug _assert$ /home/mptqa/crest/crest-0.1.1/bin/run_crest./triangle_add_bug_assert 20 -dfs Iteration 0 (0s): covered 0 branches [0 reach funs, 0 reach branches]. Iteration 1 (0s): covered 1 branches [1 reach funs, 30 reach branches]. Iteration 2 (0s): covered 3 branches [1 reach funs, 30 reach branches]. Iteration 3 (0s): covered 5 branches [1 reach funs, 30 reach branches]. Shape of Triangle = 40 Iteration 4 (0s): covered 16 branches [1 reach funs, 30 reach branches]. Iteration 5 (0s): covered 17 branches [1 reach funs, 30 reach branches]. Iteration 6 (0s): covered 18 branches [1 reach funs, 30 reach branches]. Iteration 7 (0s): covered 19 branches [1 reach funs, 30 reach branches]. triangle_add_bug_assert: triangle_add_bug_assert.c:46: triangle: Assertion `(iside1 + iside3) >= iside2' failed. Aborted (core dumped) Iteration 8 (0s): covered 19 branches [1 reach funs, 30 reach branches]. Prediction failed! assert によりバグ検知 Iteration 9 (0s): covered 20 branches [1 reach funs, 30 reach branches]. Iteration 10 (0s): covered 21 branches [1 reach funs, 30 reach branches]. Iteration 11 (0s): covered 25 branches [1 reach funs, 30 reach branches]. Iteration 12 (0s): covered 26 branches [1 reach funs, 30 reach branches]. Shape of Triangle = 20 Iteration 13 (0s): covered 27 branches [1 reach funs, 30 reach branches]. Iteration 14 (0s): covered 28 branches [1 reach funs, 30 reach branches]. (4)run_crest 実行時の各 Iteration の入力値 バグ有 input1 input2 input3 input4 input5 input6 input7 input8 input9 input10 input11 Input12 Input13 Input14 iside1 0 1 1 1 11 1 1 1 1 2 2 3 4 2 iside2 0 0 1 1 1 11 1 3 1 1 1 2 3 2 iside3 0 0 0 1 1 1 11 1 2 1 2 2 2 1 10

付録 7 割り算プログラムの解析とテスト実行結果 2 (1) ソースコードソースコード名 :divisin.c 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 /* 割り算プログラム */ #include <crest.h> #include <stdio.h> #include <assert.h> #define DEBUGMD int main(void){ int a, b; CREST_int(a); CREST_int(b); #ifndef DEBUGMD printf("input a b =>"); scanf("%d %d", &a, &b); #endif printf("input %d,%d\n",a,b); if(a > 0){ if(a < b){ printf("input a > b.\n"); return 0; return 0; else{ #ifdef DEBUGMD assert(b!= 0); #endif printf("quotient = %d\n", a / b); printf("remainder = %d\n", a % b); 0 割検知用の assert CREST の入力変数値自動生成により, 0 となる条件が成立可能かを検証することが可能となる. 11

(2)CRESTC コマンドによるコード解析結果 mptqa@mptqa-virtual-machine:~/crest/test/division$ /home/mptqa/crest/crest-0.1.1/bin/cr estc division.c gcc -D_GNUCC -E -I/home/mptqa/CREST/crest-0.1.1/bin/../include -DCIL=1 division.c -o./division.i /home/mptqa/crest/crest-0.1.1/cil/obj/x86_linux/cilly.asm.exe --out./division.cil.c --docrestinstrument./division.i gcc -D_GNUCC -E -I/home/mptqa/CREST/crest-0.1.1/bin/../include./division.cil.c -o./division.cil.i gcc -D_GNUCC -c -I/home/mptqa/CREST/crest-0.1.1/bin/../include -o./division.o./division.cil.i Warning は割愛 gcc -D_GNUCC -o division -I/home/mptqa/CREST/crest-0.1.1/bin/../include./division.o /home/mptqa/crest/crest-0.1.1/bin/../lib/libcrest.a -L/home/mptqa/CREST/crest-0.1.1/bin/../lib -lstdc++ Read 6 branches. Read 14 nodes. Wrote 4 branch edges. (3)run_crest コマンドによるテスト実行結果 mptqa@mptqa-virtual-machine:~/crest/test/division$ /home/mptqa/crest/crest-0.1.1/bin/run_cres t./division 20 -dfs Iteration 0 (0s): covered 0 branches [0 reach funs, 0 reach branches]. input 0,0 Iteration 1 (0s): covered 1 branches [1 reach funs, 6 reach branches]. input 1,0 assert によりバグ検知 division: division.c:25: main: Assertion `b!= 0' failed. Aborted (core dumped) Iteration 2 (0s): covered 1 branches [1 reach funs, 6 reach branches]. Prediction failed! 12

付録 8 仕様追加した三角形形状判定プログラムの解析とテスト実行結果 (1) ソースコードソースコード名 :triangle_add.c 1 /* Concolic-Testing 三角形の形状判断 */ 26 27 28 29 30 31 /* 入力データ誤りのチェック */ if(iside1 <= 0 iside2 <= 0 iside3 <= 0) 付録 4-26-31 { 行目の入力データ誤りチェックの printf("\n"); 後ろに iside1,2,3 が 10 より大きい時に 5 を出力する判定文を追加 /* 上限チェック */ if(iside1 > 10 iside2 > 10 iside3 > 10) { printf("\n"); msg = 5; CRSET 実行時に入力しなくて良いようにした 34 35 36 37 38 39 40 /* 三角形であることのチェック */ if ((iside1 + iside2)<= iside3 (iside2 + iside3)<= iside1 (iside1 + iside3)<= iside2) { printf("\n"); (2)CRESTC コマンドによるコード解析実行 mptqa@mptqa-virtual-machine:~/crest/test/triangle_add$ /home/mptqa/crest/crest-0.1.1/bin/c restc triangle_add.c gcc -D_GNUCC -E -I/home/mptqa/CREST/crest-0.1.1/bin/../include -DCIL=1 triangle_add.c -o./triangle_add.i /home/mptqa/crest/crest-0.1.1/cil/obj/x86_linux/cilly.asm.exe --out./triangle_add.cil.c --docrestinstrument./triangle_add.i gcc -D_GNUCC -E -I/home/mptqa/CREST/crest-0.1.1/bin/../include./triangle_add.cil.c -o./triangle_add.cil.i gcc -D_GNUCC -c -I/home/mptqa/CREST/crest-0.1.1/bin/../include -o./triangle_add.o./triangle_add.cil.i Warning は割愛 gcc -D_GNUCC -o triangle_add -I/home/mptqa/CREST/crest-0.1.1/bin/../include./triangle_add.o /home/mptqa/crest/crest-0.1.1/bin/../lib/libcrest.a -L/home/mptqa/CREST/crest-0.1.1/bin/../lib -lstdc++ Read 28 branches. 仕様追加前の結果 ( 付録 4) Read 59 nodes. Read 22 branches. Wrote 28 branch edges. Read 46 nodes. 仕様追加により, ブランチ数, ノード数, エッジ数が増加している. Wrote 22 branch edges. 13

(3)run_crest コマンドによるテスト実行 mptqa@mptqa-virtual-machine:~/crest/test/triangle_add$ /home/mptqa/crest/crest-0.1.1/bin/r un_crest./triangle_add 20 -dfs Iteration 0 (0s): covered 0 branches [0 reach funs, 0 reach branches]. Iteration 1 (0s): covered 1 branches [1 reach funs, 28 reach branches]. Iteration 2 (0s): covered 3 branches [1 reach funs, 28 reach branches]. Iteration 3 (0s): covered 5 branches [1 reach funs, 28 reach branches]. Shape of Triangle = 40 Iteration 4 (0s): covered 15 branches [1 reach funs, 28 reach branches]. Iteration 5 (0s): covered 16 branches [1 reach funs, 28 reach branches]. Iteration 6 (0s): covered 17 branches [1 reach funs, 28 reach branches]. Iteration 7 (0s): covered 18 branches [1 reach funs, 28 reach branches]. Iteration 8 (0s): covered 19 branches [1 reach funs, 28 reach branches]. Iteration 9 (0s): covered 20 branches [1 reach funs, 28 reach branches]. Iteration 10 (0s): covered 21 branches [1 reach funs, 28 reach branches]. Iteration 11 (0s): covered 25 branches [1 reach funs, 28 reach branches]. Iteration 12 (0s): covered 26 branches [1 reach funs, 28 reach Iteration branches]. が 11 から 14 に増加. Shape of Triangle = 20 Iteration 13 (0s): covered 27 branches [1 reach funs, 28 reach branches]. Iteration 14 (0s): covered 28 branches [1 reach funs, 28 reach branches]. (4)run_crest コマンド出力結果実行時の CREST で生成された入力値 input1 input2 input3 input4 input5 input6 input7 input8 input9 input10 input11 Input12 Input13 Input14 iside1 0 1 1 1 11 1 1 1 2 1 2 3 4 2 iside2 0 0 1 1 1 11 1 1 1 2 1 2 3 2 iside3 0 0 0 1 1 1 11 2 1 1 2 2 2 1 14

付録 9 仕様追加した三角形形状判定プログラム ( バグ有 ) の解析とテスト実行結果 (1) ソースコードソースコード名 :triangle_add_bug.c 1 /* Concolic-Testing 三角形の形状判断 */ 26 27 28 29 30 31 /* 入力データ誤りのチェック */ if(iside1 <= 0 iside2 <= 0 iside3 <= 0) { printf("\n"); /* 上限チェック */ if(iside1 > 10 iside2 > 10 iside3 > 10) { printf("\n"); msg = 5; 34 35 36 37 38 39 40 /* 三角形であることのチェック */ if ((iside1 + iside2)<= iside3 (iside2 + iside3)<= iside1 (iside1 + iside3)< iside2) { printf("\n"); (iside1 + iside3)<= iside2) を (iside1 + iside3)< iside2) とバグ有の状態にする. (2)CRESTC コマンドによるコード解析結果 mptqa@mptqa-virtual-machine:~/crest/test/triangle_add+bug$ /home/mptqa/crest/crest-0.1.1/bin /crestc triangle_add_bug.c gcc -D_GNUCC -E -I/home/mptqa/CREST/crest-0.1.1/bin/../include -DCIL=1 triangle_add_bug.c -o./triangle_add_bug.i /home/mptqa/crest/crest-0.1.1/cil/obj/x86_linux/cilly.asm.exe --out./triangle_add_bug.cil.c --docrestinstrument./triangle_add_bug.i gcc -D_GNUCC -E -I/home/mptqa/CREST/crest-0.1.1/bin/../include./triangle_add_bug.cil.c -o./triangle_add_bug.cil.i gcc -D_GNUCC -c -I/home/mptqa/CREST/crest-0.1.1/bin/../include -o./triangle_add_bug.o./triangle_add_bug.cil.i Warning は割愛 gcc -D_GNUCC -o triangle_add_bug -I/home/mptqa/CREST/crest-0.1.1/bin/../include./triangle_add_bug.o /home/mptqa/crest/crest-0.1.1/bin/../lib/libcrest.a -L/home/mptqa/CREST/crest-0.1.1/bin/../lib -lstdc++ Read 28 branches. Read 59 nodes. Wrote 28 branch edges. 15

(3)run_crest コマンドによるテスト実行結果 mptqa@mptqa-virtual-machine:~/crest/test/triangle_add+bug$ /home/mptqa/crest/crest-0.1.1/bin /run_crest./triangle_add_bug 20 -dfs Iteration 0 (0s): covered 0 branches [0 reach funs, 0 reach branches]. Iteration 1 (0s): covered 1 branches [1 reach funs, 28 reach branches]. Iteration 2 (0s): covered 3 branches [1 reach funs, 28 reach branches]. Iteration 3 (0s): covered 5 branches [1 reach funs, 28 reach branches]. Shape of Triangle = 40 Iteration 4 (0s): covered 15 branches [1 reach funs, 28 reach branches]. Iteration 5 (0s): covered 16 branches [1 reach funs, 28 reach branches]. Iteration 6 (0s): covered 17 branches [1 reach funs, 28 reach branches]. Iteration 7 (0s): covered 18 branches [1 reach funs, 28 reach branches]. Iteration 8 (0s): covered 19 branches [1 reach funs, 28 reach branches]. Iteration 9 (0s): covered 20 branches [1 reach funs, 28 reach branches]. Iteration 10 (0s): covered 21 branches [1 reach funs, 28 reach branches]. Iteration 11 (0s): covered 25 branches [1 reach funs, 28 reach branches]. Iteration 12 (0s): covered 26 branches [1 reach funs, 28 reach branches]. Shape of Triangle = 20 Iteration 13 (0s): covered 27 branches [1 reach funs, 28 reach branches]. Iteration 14 (0s): covered 28 branches [1 reach funs, 28 reach branches]. 付録 8 と同様 (4)run_crest 実行時の各 Iteration の入力値 input1 input2 input3 input4 input5 input6 input7 input8 input9 input10 input11 Input12 Input13 Input14 iside1 0 1 1 1 11 1 1 1 2 1 2 3 4 2 iside2 0 0 1 1 1 11 1 1 1 3 1 2 3 2 iside3 0 0 0 1 1 1 11 2 1 1 2 2 2 1 入力値が仕様変更前の付 録 4(5)input7 と違う. 16