first commit of dyninst library. Also includes:
[dyninst.git] / dyninstAPI / tests / src / test1.C
1
2 //
3 // libdyninst validation suite test #1
4 //    Author: Jeff Hollingsworth (1/7/97)
5 //        derived from a previous test by Bryan Buck
6 //
7
8 //  This program tests the basic features of the dyninst API.  
9 //      The mutatee that goes with this file is test1.mutatee.c
10 //      
11 //  Naming conventions:
12 //      All functions, variables, etc are name funcXX_YY, exprXX_YY, etc.
13 //          XX is the test number
14 //          YY is the instance withing the test
15 //          func1_2 is the second function used in test case #1.
16 //
17
18 /*
19  * $Log: test1.C,v $
20  * Revision 1.1  1997/03/18 19:45:21  buck
21  * first commit of dyninst library.  Also includes:
22  *      moving templates from paradynd to dyninstAPI
23  *      converting showError into a function (in showerror.C)
24  *      many ifdefs for BPATCH_LIBRARY in dyinstAPI/src.
25  *
26  *
27  */
28
29 #include <stdio.h>
30 #include <signal.h>
31
32 #include "BPatch_Vector.h"
33 #include "BPatch_thread.h"
34 #include "BPatch_snippet.h"
35
36 int debugPrint = 0;
37
38 // control debug printf statements
39 #define dprintf if (debugPrint) printf
40
41 //
42 // Start Test Case #6 - mutator side (arithmetic operators)
43 //
44 void mutatorTest6(BPatch_thread *appThread, BPatch_image *appImage)
45 {
46     // Find the entry point to the procedure "func6_1"
47     BPatch_Vector<BPatch_point *> *point6_1 =
48         appImage->findProcedurePoint("func6_1", BPatch_entry);
49     BPatch_variableExpr *expr6_1 = appImage->findVariable("globalVariable6_1");
50     BPatch_variableExpr *expr6_2 = appImage->findVariable("globalVariable6_2");
51     BPatch_variableExpr *expr6_3 = appImage->findVariable("globalVariable6_3");
52     BPatch_variableExpr *expr6_4 = appImage->findVariable("globalVariable6_4");
53     BPatch_variableExpr *expr6_5 = appImage->findVariable("globalVariable6_5");
54     BPatch_variableExpr *expr6_6 = appImage->findVariable("globalVariable6_6");
55     if (!expr6_1 || !expr6_2 || !expr6_3 || !expr6_4 || 
56         !expr6_5 || !expr6_6) {
57         fprintf(stderr, "**Failed** test #6 (arithmetic operators)\n");
58         fprintf(stderr, "    Unable to locate one of globalVariable6_?\n");
59         exit(1);
60     }
61
62     BPatch_Vector<BPatch_snippet*> vect6_1;
63
64     // globalVariable6_1 = 60 + 2
65     BPatch_arithExpr arith6_1 (BPatch_assign, *expr6_1, 
66       BPatch_arithExpr(BPatch_plus,BPatch_constExpr(60), BPatch_constExpr(2)));
67     vect6_1.push_back(&arith6_1);
68
69     // globalVariable6_2 = 64 - 1
70     BPatch_arithExpr arith6_2 (BPatch_assign, *expr6_2, 
71       BPatch_arithExpr(BPatch_minus,BPatch_constExpr(64),BPatch_constExpr(1)));
72     vect6_1.push_back(&arith6_2);
73
74     // globalVariable6_3 = 66 / 3
75     BPatch_arithExpr arith6_3 (BPatch_assign, *expr6_3, BPatch_arithExpr(
76       BPatch_divide,BPatch_constExpr(66),BPatch_constExpr(3)));
77     vect6_1.push_back(&arith6_3);
78
79     // globalVariable6_4 = 67 / 3
80     BPatch_arithExpr arith6_4 (BPatch_assign, *expr6_4, BPatch_arithExpr(
81       BPatch_divide,BPatch_constExpr(67),BPatch_constExpr(3)));
82     vect6_1.push_back(&arith6_4);
83
84     // globalVariable6_5 = 6 * 5
85     BPatch_arithExpr arith6_5 (BPatch_assign, *expr6_5, BPatch_arithExpr(
86       BPatch_times,BPatch_constExpr(6),BPatch_constExpr(5)));
87     vect6_1.push_back(&arith6_5);
88
89     // globalVariable6_6 = 10,3
90     BPatch_arithExpr arith6_6 (BPatch_assign, *expr6_6, 
91         BPatch_arithExpr(BPatch_seq,BPatch_constExpr(10),BPatch_constExpr(3)));
92     vect6_1.push_back(&arith6_6);
93
94     appThread->insertSnippet( BPatch_sequence(vect6_1), *point6_1);
95 }
96
97 void genRelTest(BPatch_image *appImage,BPatch_Vector<BPatch_snippet*> &vect7_1, 
98                 BPatch_relOp op, int r1, int r2, char *var1)
99 {
100     BPatch_variableExpr *varExpr1 = appImage->findVariable(var1);
101     if (!varExpr1) {
102         fprintf(stderr, "**Failed** test #7 (relational operators)\n");
103         fprintf(stderr, "    Unable to locate variable %s\n", var1);
104         exit(1);
105     }
106     BPatch_ifExpr *tempExpr1 = new BPatch_ifExpr(
107         BPatch_boolExpr(op, BPatch_constExpr(r1), BPatch_constExpr(r2)), 
108         BPatch_arithExpr(BPatch_assign, *varExpr1, BPatch_constExpr(72)));
109     vect7_1.push_back(tempExpr1);
110
111 }
112
113 //
114 // Start Test Case #7 - mutator side (relational operators)
115 //
116 void mutatorTest7(BPatch_thread *appThread, BPatch_image *appImage)
117 {
118     // Find the entry point to the procedure "func7_1"
119     BPatch_Vector<BPatch_point *> *point7_1 =
120         appImage->findProcedurePoint("func7_1", BPatch_entry);
121     BPatch_Vector<BPatch_snippet*> vect7_1;
122
123     genRelTest(appImage, vect7_1, BPatch_lt, 0, 1, "globalVariable7_1");
124     genRelTest(appImage, vect7_1, BPatch_lt, 1, 0, "globalVariable7_2");
125     genRelTest(appImage, vect7_1, BPatch_eq, 2, 2, "globalVariable7_3");
126     genRelTest(appImage, vect7_1, BPatch_eq, 2, 3, "globalVariable7_4");
127     genRelTest(appImage, vect7_1, BPatch_gt, 4, 3, "globalVariable7_5");
128     genRelTest(appImage, vect7_1, BPatch_gt, 3, 4, "globalVariable7_6");
129     genRelTest(appImage, vect7_1, BPatch_le, 3, 4, "globalVariable7_7");
130     genRelTest(appImage, vect7_1, BPatch_le, 4, 3, "globalVariable7_8");
131     genRelTest(appImage, vect7_1, BPatch_ne, 5, 6, "globalVariable7_9");
132     genRelTest(appImage, vect7_1, BPatch_ne, 5, 5, "globalVariable7_10");
133     genRelTest(appImage, vect7_1, BPatch_ge, 9, 7, "globalVariable7_11");
134     genRelTest(appImage, vect7_1, BPatch_ge, 7, 9, "globalVariable7_12");
135     genRelTest(appImage, vect7_1, BPatch_and, 1, 1, "globalVariable7_13");
136     genRelTest(appImage, vect7_1, BPatch_and, 1, 0, "globalVariable7_14");
137     genRelTest(appImage, vect7_1, BPatch_or, 1, 0, "globalVariable7_15");
138     genRelTest(appImage, vect7_1, BPatch_or, 0, 0, "globalVariable7_16");
139
140     dprintf("relops test vector length is %d\n", vect7_1.size());
141
142     appThread->insertSnippet( BPatch_sequence(vect7_1), *point7_1);
143 }
144
145 //
146 // Start Test Case #8 - mutator side (preserve registers - expr)
147 //
148 void mutatorTest8(BPatch_thread *appThread, BPatch_image *appImage)
149 {
150     // Find the entry point to the procedure "func8_1"
151     BPatch_Vector<BPatch_point *> *point8_1 =
152         appImage->findProcedurePoint("func8_1", BPatch_entry);
153     BPatch_Vector<BPatch_snippet*> vect8_1;
154
155     BPatch_variableExpr *expr8_1 = appImage->findVariable("globalVariable8_1");
156     if (!expr8_1) {
157         fprintf(stderr, "**Failed** test #3 (passing variables)\n");
158         fprintf(stderr, "    Unable to locate variable globalVariable8_1\n");
159         exit(1);
160     }
161
162     BPatch_arithExpr arith8_1 (BPatch_assign, *expr8_1, 
163       BPatch_arithExpr(BPatch_plus, 
164             BPatch_arithExpr(BPatch_plus, 
165                 BPatch_arithExpr(BPatch_plus, BPatch_constExpr(81), 
166                                               BPatch_constExpr(82)),
167                 BPatch_arithExpr(BPatch_plus, BPatch_constExpr(83), 
168                                               BPatch_constExpr(84))),
169             BPatch_arithExpr(BPatch_plus, 
170                 BPatch_arithExpr(BPatch_plus, BPatch_constExpr(85), 
171                                               BPatch_constExpr(86)),
172                 BPatch_arithExpr(BPatch_plus, BPatch_constExpr(87), 
173                                               BPatch_constExpr(88)))));
174     vect8_1.push_back(&arith8_1);
175
176     appThread->insertSnippet( BPatch_sequence(vect8_1), *point8_1);
177 }
178
179 //
180 // Start Test Case #9 - mutator side (preserve registers - funcCall)
181 //
182 void mutatorTest9(BPatch_thread *appThread, BPatch_image *appImage)
183 {
184     // Find the entry point to the procedure "func9_1"
185     BPatch_Vector<BPatch_point *> *point9_1 =
186         appImage->findProcedurePoint("func9_1", BPatch_entry);
187
188     BPatch_function *call9_func = appImage->findFunction("call9_1");
189     if (call9_func == NULL) {
190         fprintf(stderr, "Unable to find function \"call9_1.\"\n");
191         exit(1);
192     }
193
194     BPatch_Vector<BPatch_snippet *> call9_args;
195
196     BPatch_constExpr constExpr91(91);
197     call9_args.push_back(&constExpr91);
198
199     BPatch_constExpr constExpr92(92);
200     call9_args.push_back(&constExpr92);
201
202     BPatch_constExpr constExpr93(93);
203     call9_args.push_back(&constExpr93);
204
205     BPatch_constExpr constExpr94(94);
206     call9_args.push_back(&constExpr94);
207
208     BPatch_constExpr constExpr95(95);
209     call9_args.push_back(&constExpr95);
210
211     BPatch_funcCallExpr call9Expr(*call9_func, call9_args);
212
213     appThread->insertSnippet( call9Expr, *point9_1);
214 }
215
216
217 //
218 // Start Test Case #10 - mutator side (insert snippet order)
219 //
220 void mutatorTest10(BPatch_thread *appThread, BPatch_image *appImage)
221 {
222     // Find the entry point to the procedure "func10_1"
223     BPatch_Vector<BPatch_point *> *point10_1 =
224         appImage->findProcedurePoint("func10_1", BPatch_entry);
225
226     BPatch_function *call10_1_func = appImage->findFunction("call10_1");
227     if (call10_1_func == NULL) {
228         fprintf(stderr, "Unable to find function \"call10_1.\"\n");
229         exit(1);
230     }
231
232     BPatch_function *call10_2_func = appImage->findFunction("call10_2");
233     if (call10_2_func == NULL) {
234         fprintf(stderr, "Unable to find function \"call10_2.\"\n");
235         exit(1);
236     }
237
238     BPatch_function *call10_3_func = appImage->findFunction("call10_3");
239     if (call10_3_func == NULL) {
240         fprintf(stderr, "Unable to find function \"call10_3.\"\n");
241         exit(1);
242     }
243
244     BPatch_Vector<BPatch_snippet *> nullArgs;
245     BPatch_funcCallExpr call10_1Expr(*call10_1_func, nullArgs);
246     BPatch_funcCallExpr call10_2Expr(*call10_2_func, nullArgs);
247     BPatch_funcCallExpr call10_3Expr(*call10_3_func, nullArgs);
248
249     appThread->insertSnippet( call10_2Expr, *point10_1);
250     appThread->insertSnippet( call10_1Expr, *point10_1, BPatch_callBefore, 
251                                                         BPatch_firstSnippet);
252     appThread->insertSnippet( call10_3Expr, *point10_1, BPatch_callBefore, 
253                                                         BPatch_lastSnippet);
254 }
255
256
257 //
258 // Start Test Case #11 - mutator side (snippets at entry,exit,call)
259 //
260 void mutatorTest11(BPatch_thread *appThread, BPatch_image *appImage)
261 {
262     // Find the entry point to the procedure "func11_1"
263     BPatch_Vector<BPatch_point *> *point11_1 =
264         appImage->findProcedurePoint("func11_1", BPatch_entry);
265     if (!point11_1) {
266         fprintf(stderr, "Unable to find point func11_1 - entry.\n");
267         exit(-1);
268     }
269
270     // Find the subroutine points for the procedure "func11_1"
271     BPatch_Vector<BPatch_point *> *point11_2 =
272         appImage->findProcedurePoint("func11_1", BPatch_subroutine);
273     if (!point11_2) {
274         fprintf(stderr, "Unable to find point func11_1 - calls.\n");
275         exit(-1);
276     }
277
278     // Find the exit point to the procedure "func11_1"
279     BPatch_Vector<BPatch_point *> *point11_3 =
280         appImage->findProcedurePoint("func11_1", BPatch_exit);
281     if (!point11_3) {
282         fprintf(stderr, "Unable to find point func11_1 - exit.\n");
283         exit(-1);
284     }
285
286     BPatch_function *call11_1_func = appImage->findFunction("call11_1");
287     if (call11_1_func == NULL) {
288         fprintf(stderr, "Unable to find function \"call11_1.\"\n");
289         exit(1);
290     }
291
292     BPatch_function *call11_2_func = appImage->findFunction("call11_2");
293     if (call11_2_func == NULL) {
294         fprintf(stderr, "Unable to find function \"call11_2.\"\n");
295         exit(1);
296     }
297
298     BPatch_function *call11_3_func = appImage->findFunction("call11_3");
299     if (call11_3_func == NULL) {
300         fprintf(stderr, "Unable to find function \"call11_3.\"\n");
301         exit(1);
302     }
303
304     BPatch_function *call11_4_func = appImage->findFunction("call11_4");
305     if (call11_4_func == NULL) {
306         fprintf(stderr, "Unable to find function \"call11_4.\"\n");
307         exit(1);
308     }
309
310     BPatch_Vector<BPatch_snippet *> nullArgs;
311     BPatch_funcCallExpr call11_1Expr(*call11_1_func, nullArgs);
312     BPatch_funcCallExpr call11_2Expr(*call11_2_func, nullArgs);
313     BPatch_funcCallExpr call11_3Expr(*call11_3_func, nullArgs);
314     BPatch_funcCallExpr call11_4Expr(*call11_4_func, nullArgs);
315
316     appThread->insertSnippet(call11_1Expr, *point11_1);
317     appThread->insertSnippet(call11_2Expr, *point11_2, BPatch_callBefore);
318     appThread->insertSnippet(call11_3Expr, *point11_2, BPatch_callAfter);
319     appThread->insertSnippet(call11_4Expr, *point11_3);
320
321 }
322
323 BPatch_variableExpr *varExpr12_1;
324
325 //
326 // Start Test Case #12 - mutator side (insert/remove and malloc/free)
327 //
328 void mutatorTest12a(BPatch_thread *appThread, BPatch_image *appImage)
329 {
330     // Find the entry point to the procedure "func12_2"
331     BPatch_Vector<BPatch_point *> *point12_2 =
332         appImage->findProcedurePoint("func12_2", BPatch_entry);
333     if (!point12_2) {
334         fprintf(stderr, "Unable to find point func12_2 - entry.\n");
335         exit(-1);
336     }
337
338     varExpr12_1 = appThread->malloc(100);
339     if (!varExpr12_1) {
340         fprintf(stderr, "Unable to allocate 100 bytes in mutatee\n");
341         exit(-1);
342     }
343
344     BPatch_function *call12_1_func = appImage->findFunction("call12_1");
345     if (call12_1_func == NULL) {
346         fprintf(stderr, "Unable to find function \"call12_1.\"\n");
347         exit(1);
348     }
349
350     BPatch_Vector<BPatch_snippet *> nullArgs;
351     BPatch_funcCallExpr call12_1Expr(*call12_1_func, nullArgs);
352     appThread->insertSnippet(call12_1Expr, *point12_2);
353 }
354
355 void mutatorTest12b(BPatch_thread *appThread, BPatch_image *appImage)
356 {
357     while (!appThread->isStopped() && !appThread->isTerminated()) ;
358     if (appThread->stopSignal() == SIGSTOP) {
359         // remove instrumentation and free memory
360         appThread->free(*varExpr12_1);
361
362         // continue process
363         appThread->continueExecution();
364     } else if (appThread->isStopped()) {
365         printf("**Failed test #12 (insert/remove and malloc/free)\n");
366         printf("    process stopped on signal %d, not SIGSTOP\n", 
367                 appThread->stopSignal());
368         exit(-1);
369     } else {
370         printf("**Failed test #12 (insert/remove and malloc/free)\n");
371         printf("    process did not signal mutator via SIGSTOP\n");
372         exit(-1);
373     }
374 }
375
376
377 //
378 // Start Test Case #13 - mutator side (paramExpr,nullExpr)
379 //
380 void mutatorTest13(BPatch_thread *appThread, BPatch_image *appImage)
381 {
382     // Find the entry point to the procedure "func13_1"
383     BPatch_Vector<BPatch_point *> *point13_1 =
384         appImage->findProcedurePoint("func13_1", BPatch_entry);
385     if (!point13_1) {
386         fprintf(stderr, "Unable to find point func13_1 - entry.\n");
387         exit(-1);
388     }
389
390     BPatch_function *call13_1_func = appImage->findFunction("call13_1");
391     if (call13_1_func == NULL) {
392         fprintf(stderr, "Unable to find function \"call13_1.\"\n");
393         exit(1);
394     }
395
396     BPatch_Vector<BPatch_snippet *> funcArgs;
397     funcArgs.push_back(new BPatch_paramExpr(0));
398     funcArgs.push_back(new BPatch_paramExpr(1));
399     funcArgs.push_back(new BPatch_paramExpr(2));
400     funcArgs.push_back(new BPatch_paramExpr(3));
401     funcArgs.push_back(new BPatch_paramExpr(4));
402     BPatch_funcCallExpr call13_1Expr(*call13_1_func, funcArgs);
403     BPatch_nullExpr call13_2Expr;
404
405     appThread->insertSnippet(call13_1Expr, *point13_1);
406     // This causes a crash right now jkh 3/7/97
407     // appThread->insertSnippet(call13_2Expr, *point13_1);
408 }
409
410 void mutatorMAIN(char *pathname)
411 {
412     printf("Starting \"%s\"\n", pathname);
413
414     char *child_argv[] = { pathname, "-verbose", NULL };
415     if (!debugPrint) {
416         // null out the verbose mode if not enabled.
417         child_argv[1] = NULL;
418     }
419     BPatch_thread *appThread =
420         new BPatch_thread(pathname, child_argv, NULL);
421
422     if (appThread->isTerminated()) {
423         fprintf(stderr, "Unable to run test program.\n");
424         exit(1);
425     }
426
427     // Read the program's image and get an associated image object
428     BPatch_image *appImage = appThread->getImage();
429
430     BPatch_Vector<BPatch_function *> *p = appImage->getProcedures();
431     for (int i=0; i < p->size(); i++) {
432         // dprintf("func %s\n", (*p)[i]->name());
433     }
434
435     // Start Test Case #1 - mutator side (call a zero argument function)
436
437     // Find the entry point to the procedure "func1_1"
438     BPatch_Vector<BPatch_point *> *point1_1 =
439         appImage->findProcedurePoint("func1_1", BPatch_entry);
440
441     if ((*point1_1).size() == 0) {
442         fprintf(stderr, "**Failed** test #1 (zero arg function call)\n");
443         fprintf(stderr, "    Unable to find entry point to \"func1_1.\"\n");
444         exit(1);
445     }
446
447     BPatch_function *call1_func = appImage->findFunction("call1_1");
448     if (call1_func == NULL) {
449         fprintf(stderr, "**Failed** test #1 (zero arg function call)\n");
450         fprintf(stderr, "Unable to find function \"call1_1\"\n");
451         exit(1);
452     }
453
454     BPatch_Vector<BPatch_snippet *> call1_args;
455     BPatch_funcCallExpr call1Expr(*call1_func, call1_args);
456
457     dprintf("Inserted snippet2\n");
458     appThread->insertSnippet(call1Expr, *point1_1);
459
460
461     //
462     // Start Test Case #2 - mutator side (call a three argument function)
463     //
464
465     // Find the entry point to the procedure "func2_1"
466     BPatch_Vector<BPatch_point *> *point2_1 =
467         appImage->findProcedurePoint("func2_1", BPatch_entry);
468
469     if (!point2_1 || ((*point2_1).size() == 0)) {
470         fprintf(stderr, "**Failed** test #2 (three parameter function)\n");
471         fprintf(stderr, "    Unable to find entry point to \"func2_1.\"\n");
472         exit(1);
473     }
474
475     BPatch_function *call2_func = appImage->findFunction("call2_1");
476     if (call2_func == NULL) {
477         fprintf(stderr, "**Failed** test #2 (three parameter function)\n");
478         fprintf(stderr, "    Unable to find function \"call2_1.\"\n");
479         exit(1);
480     }
481
482     BPatch_Vector<BPatch_snippet *> call2_args;
483     BPatch_constExpr expr2_1(1);
484     BPatch_constExpr expr2_2(2);
485     BPatch_constExpr expr2_3("testString2_1");
486     call2_args.push_back(&expr2_1);
487     call2_args.push_back(&expr2_2);
488     call2_args.push_back(&expr2_3);
489
490     BPatch_funcCallExpr call2Expr(*call2_func, call2_args);
491
492     dprintf("Inserted snippet2\n");
493     appThread->insertSnippet(call2Expr, *point2_1);
494
495     //
496     // Start Test Case #3 - mutator side (passing variables to function)
497     //
498
499     // Find the entry point to the procedure "func3_1"
500     BPatch_Vector<BPatch_point *> *point3_1 =
501         appImage->findProcedurePoint("func3_1", BPatch_entry);
502
503     if (!point3_1 || ((*point3_1).size() == 0)) {
504         fprintf(stderr, "Unable to find entry point to \"func3_1.\"\n");
505         exit(1);
506     }
507
508     BPatch_function *call3_func = appImage->findFunction("call3_1");
509     if (call3_func == NULL) {
510         fprintf(stderr, "Unable to find function \"call3_1.\"\n");
511         exit(1);
512     }
513
514     BPatch_Vector<BPatch_snippet *> call3_args;
515
516     BPatch_variableExpr *expr3_1 = appImage->findVariable("globalVariable3_1");
517     if (!expr3_1) {
518         fprintf(stderr, "**Failed** test #3 (passing variables)\n");
519         fprintf(stderr, "    Unable to locate variable globalVariable3_1\n");
520         exit(1);
521     }
522
523     BPatch_variableExpr *expr3_2 = appThread->malloc(*appImage->findType("int"));
524     if (!expr3_2) {
525         fprintf(stderr, "**Failed** test #3 (passing variables)\n");
526         fprintf(stderr, "    Unable to create new int variable\n");
527         exit(1);
528     }
529
530     call3_args.push_back(expr3_1);
531     call3_args.push_back(expr3_2);
532
533     BPatch_funcCallExpr call3Expr(*call3_func, call3_args);
534     appThread->insertSnippet(call3Expr, *point3_1);
535
536     BPatch_arithExpr expr3_3(BPatch_assign, *expr3_2, BPatch_constExpr(32));
537     appThread->insertSnippet(expr3_3, *point3_1);
538
539     dprintf("Inserted snippet3\n");
540
541     //
542     // Start Test Case #4 - mutator side (sequence)
543     //
544
545     // Find the entry point to the procedure "func4_1"
546     BPatch_Vector<BPatch_point *> *point4_1 =
547         appImage->findProcedurePoint("func4_1", BPatch_entry);
548
549
550     BPatch_variableExpr *expr4_1 = appImage->findVariable("globalVariable4_1");
551     if (!expr4_1) {
552         fprintf(stderr, "**Failed** test #4 (sequence)\n");
553         fprintf(stderr, "    Unable to locate variable globalVariable4_1\n");
554         exit(1);
555     }
556
557     BPatch_arithExpr expr4_2(BPatch_assign, *expr4_1, BPatch_constExpr(42));
558     BPatch_arithExpr expr4_3(BPatch_assign, *expr4_1, BPatch_constExpr(43));
559
560     BPatch_Vector<BPatch_snippet*> vect4_1;
561     vect4_1.push_back(&expr4_2);
562     vect4_1.push_back(&expr4_3);
563
564     BPatch_sequence expr4_4(vect4_1);
565     appThread->insertSnippet(expr4_4, *point4_1);
566
567     //
568     // Start Test Case #5 - mutator side (if w.o. else)
569     //
570
571     // Find the entry point to the procedure "func5_1"
572     BPatch_Vector<BPatch_point *> *point5_1 =
573         appImage->findProcedurePoint("func5_1", BPatch_entry);
574     BPatch_variableExpr *expr5_1 = appImage->findVariable("globalVariable5_1");
575     BPatch_variableExpr *expr5_2 = appImage->findVariable("globalVariable5_2");
576     if (!expr5_1 || !expr5_2) {
577         fprintf(stderr, "**Failed** test #5 (f w.o. else)\n");
578         fprintf(stderr, "    Unable to locate variable globalVariable5_1 or ");
579         fprintf(stderr, "    variable globalVariable5_2\n");
580         exit(1);
581     }
582
583     BPatch_Vector<BPatch_snippet*> vect5_1;
584
585     // if (0 == 1) globalVariable5_1 = 52;
586     BPatch_ifExpr expr5_3(
587         BPatch_boolExpr(BPatch_eq, BPatch_constExpr(0), BPatch_constExpr(1)), 
588         BPatch_arithExpr(BPatch_assign, *expr5_1, BPatch_constExpr(52)));
589
590     // if (1 == 1) globalVariable5_2 = 53;
591     BPatch_ifExpr expr5_4(
592         BPatch_boolExpr(BPatch_eq, BPatch_constExpr(1), BPatch_constExpr(1)), 
593         BPatch_arithExpr(BPatch_assign, *expr5_2, BPatch_constExpr(53)));
594
595     vect5_1.push_back(&expr5_3);
596     vect5_1.push_back(&expr5_4);
597
598     BPatch_sequence expr5_5(vect5_1);
599     appThread->insertSnippet(expr5_5, *point5_1);
600
601     mutatorTest6(appThread, appImage);
602
603     mutatorTest7(appThread, appImage);
604
605     mutatorTest8(appThread, appImage);
606
607     mutatorTest9(appThread, appImage);
608
609     mutatorTest10(appThread, appImage);
610
611     mutatorTest11(appThread, appImage);
612
613     mutatorTest12a(appThread, appImage);
614
615     mutatorTest13(appThread, appImage);
616
617     // Start of code to continue the process.
618     dprintf("starting program execution.\n");
619     appThread->continueExecution();
620
621     mutatorTest12b(appThread, appImage);
622
623     while (!appThread->isTerminated()) ;
624     dprintf("Done.\n");
625 }
626
627 //
628 // main - decide our role and call the correct "main"
629 //
630 main(int argc, char *argv[])
631 {
632     if (argc == 1) {
633         // become the mutator
634         mutatorMAIN("./test1.mutatee");
635     } else if (argc == 2 && !strcmp(argv[1], "-verbose")) {
636         debugPrint = 1;
637         mutatorMAIN("./test1.mutatee");
638     } else {
639         fprintf(stderr, "Usage: test1 [-verbose]\n");
640         exit(-1);
641     }
642 }