Testcase generation tool for combinatorial interaction testing
Revision | 446e4f13d917ec3a3eadf7398ac8076db1f1050a (tree) |
---|---|
Zeit | 2015-05-22 18:55:32 |
Autor | t-tutiya <tatsuhiro@ieee...> |
Commiter | t-tutiya |
Bug fixes related to ref/deref of BDD nodes
@@ -7,14 +7,16 @@ import java.util.ArrayList; | ||
7 | 7 | import java.util.List; |
8 | 8 | |
9 | 9 | class ConstraintHandler { |
10 | + static final int sizeOfNodetable = 1000; | |
11 | + static final int sizeOfCache = 1000; | |
12 | + | |
10 | 13 | List<VariableAndBDD> parameters = null; |
11 | 14 | BDD bdd; |
12 | 15 | int bddConstraint; |
13 | 16 | int numOfBDDvariables; |
14 | 17 | |
15 | 18 | ConstraintHandler(PList parameterList, List<Node> constraintList) { |
16 | - //TODO BDDを設定 -> 1000, ... 文字定数化 | |
17 | - bdd = new BDD(1000,1000); | |
19 | + bdd = new BDD(sizeOfNodetable, sizeOfCache); | |
18 | 20 | bdd = new jdd.bdd.debug.DebugBDD(1000,1000); |
19 | 21 | |
20 | 22 | //parameterのリスト |
@@ -70,28 +72,26 @@ class ConstraintHandler { | ||
70 | 72 | bdd.ref(g); |
71 | 73 | for (int j = var.length - 1; j > i; j--) { |
72 | 74 | if ((p.value_name.size() - 1 & (0x01 << j)) > 0) { |
73 | - g = bdd.ref(bdd.and(g, var[j])); | |
75 | + int tmp = bdd.ref(bdd.and(g, var[j])); bdd.deref(g); g = tmp; | |
74 | 76 | } else { |
75 | - g = bdd.ref(bdd.and(g, bdd.not(var[j]))); | |
77 | + int tmp = bdd.ref(bdd.and(g, bdd.not(var[j]))); bdd.deref(g); g = tmp; | |
76 | 78 | } |
77 | 79 | } |
78 | - g = bdd.ref(bdd.and(g, bdd.not(var[i]))); | |
79 | - f = bdd.ref(bdd.or(f, g)); | |
80 | + int tmp = bdd.ref(bdd.and(g, bdd.not(var[i]))); bdd.deref(g); g = tmp; | |
81 | + tmp = bdd.ref(bdd.or(f, g)); bdd.deref(g); f = tmp; | |
80 | 82 | } |
81 | 83 | } |
82 | - bdd.ref(f); // useless? | |
83 | 84 | |
84 | 85 | // domain - 1自身 |
85 | 86 | int g = bdd.getOne(); |
86 | 87 | bdd.ref(g); |
87 | 88 | for (int i = var.length - 1; i >= 0; i--) { |
88 | 89 | if ((p.value_name.size() - 1 & (0x01 << i)) > 0) { |
89 | - g = bdd.ref(bdd.and(g, var[i])); | |
90 | + int tmp = bdd.ref(bdd.and(g, var[i])); bdd.deref(g); g = tmp; | |
90 | 91 | } else { |
91 | - g = bdd.ref(bdd.and(g, bdd.not(var[i]))); | |
92 | + int tmp = bdd.ref(bdd.and(g, bdd.not(var[i]))); bdd.deref(g); g = tmp; | |
92 | 93 | } |
93 | 94 | } |
94 | - bdd.ref(g); | |
95 | 95 | |
96 | 96 | int d = bdd.or(f, g); |
97 | 97 | bdd.ref(d); |
@@ -105,25 +105,19 @@ class ConstraintHandler { | ||
105 | 105 | } |
106 | 106 | |
107 | 107 | private int setBddConstraint(List<Node> constraintList) { |
108 | - // TODO Auto-generated method stub | |
109 | 108 | int f = bdd.getOne(); |
110 | 109 | bdd.ref(f); |
111 | 110 | |
112 | 111 | // パラメータでつかわない領域をfalseにする |
113 | 112 | for (VariableAndBDD vb : parameters) { |
114 | - f = bdd.and(f, vb.constraint); | |
115 | - bdd.ref(f); | |
113 | + int tmp = bdd.ref(bdd.and(f, vb.constraint)); bdd.deref(f); f = tmp; | |
116 | 114 | } |
117 | 115 | |
118 | 116 | // 制約式の論理積をとる |
119 | 117 | for (Node n: constraintList) { |
120 | 118 | int g = n.evaluate(bdd, parameters); |
121 | - bdd.ref(g); | |
122 | - f = bdd.and(f, g); | |
123 | - bdd.ref(f); | |
124 | - bdd.deref(g); | |
119 | + int tmp = bdd.ref(bdd.and(f, g)); bdd.deref(f); bdd.deref(g); f = tmp; | |
125 | 120 | } |
126 | -// bdd.ref(f); | |
127 | 121 | |
128 | 122 | // *を付加 |
129 | 123 | f = extendBddConstraint(f); |
@@ -135,17 +129,13 @@ class ConstraintHandler { | ||
135 | 129 | int f = constraint; |
136 | 130 | for (VariableAndBDD p : parameters) { |
137 | 131 | int cube = p.var[0]; |
132 | + bdd.ref(cube); | |
138 | 133 | for (int i = 1; i < p.var.length; i++) { |
139 | - cube = bdd.ref(bdd.and(cube, p.var[i])); | |
134 | + int tmp = bdd.ref(bdd.and(cube, p.var[i])); bdd.deref(cube); cube = tmp; | |
140 | 135 | } |
141 | - bdd.ref(cube); | |
142 | 136 | int tmp0 = bdd.ref(bdd.exists(f, cube)); |
143 | - bdd.ref(tmp0); | |
144 | 137 | int tmp = bdd.ref(bdd.and(tmp0, cube)); |
145 | - bdd.ref(tmp); | |
146 | - int newf = | |
147 | - bdd.ref(bdd.or(f, tmp)); | |
148 | - bdd.ref(newf); | |
138 | + int newf = bdd.ref(bdd.or(f, tmp)); | |
149 | 139 | |
150 | 140 | bdd.deref(cube); |
151 | 141 | bdd.deref(tmp0); |
@@ -156,7 +146,7 @@ class ConstraintHandler { | ||
156 | 146 | return f; |
157 | 147 | } |
158 | 148 | |
159 | - //TODO テストケースが制約を満たすか | |
149 | + // テストケースが制約を満たすか | |
160 | 150 | boolean isPossible (Testcase test) { |
161 | 151 | int node = bddConstraint; |
162 | 152 | boolean[] bv = binarize(test); |
@@ -175,18 +175,16 @@ class EqualityOfParameterAndValue extends ComparisonOfParameterAndValue { | ||
175 | 175 | int evaluate(BDD bdd, List<VariableAndBDD> parameters) { |
176 | 176 | int res = bdd.getOne(); |
177 | 177 | bdd.ref(res); |
178 | - // deref 必要? | |
179 | 178 | int[] var = parameters.get(this.p).var; |
180 | 179 | for (int i = var.length - 1; i >= 0; i--) { |
181 | - if ((this.v & (0x01 << i)) > 0) | |
182 | - res = bdd.ref(bdd.and(res, var[i])); | |
183 | - else | |
184 | - res = bdd.ref(bdd.and(res, bdd.not(var[i]))); | |
180 | + if ((this.v & (0x01 << i)) > 0) { | |
181 | + int tmp = bdd.ref(bdd.and(res, var[i])); bdd.deref(res); res = tmp; | |
182 | + } | |
183 | + else { | |
184 | + int tmp = bdd.ref(bdd.and(res, bdd.not(var[i]))); bdd.deref(res); res = tmp; | |
185 | + } | |
185 | 186 | } |
186 | 187 | bdd.ref(res); |
187 | 188 | return res; |
188 | 189 | } |
189 | -} | |
190 | - | |
191 | - | |
192 | - | |
190 | +} | |
\ No newline at end of file |