static int genVRelTest(BPatch_image *appImage, BPatch_Vector<BPatch_snippet*> &vect7_1, BPatch_relOp op, BPatch_variableExpr *r1, BPatch_variableExpr *r2, const char *var1) { const char *funcName = "test1_7_func2"; BPatch_Vector<BPatch_function *> found_funcs; if ((NULL == appImage->findFunction(funcName, found_funcs)) || !found_funcs.size()) { logerror(" Unable to find function %s\n", funcName); return -1; } if (1 < found_funcs.size()) { logerror("%s[%d]: WARNING : found %d functions named %s. Using the first.\n", __FILE__, __LINE__, found_funcs.size(), funcName); } BPatch_Vector<BPatch_point *> *point7_1 = found_funcs[0]->findPoint(BPatch_entry); if (!point7_1 || ((*point7_1).size() == 0)) { logerror("Unable to find entry point to \"%s\".\n", funcName); return -1; } BPatch_variableExpr *expr1_1 = findVariable(appImage, var1, point7_1); if (!expr1_1) { logerror("**Failed** test #7 (relational operators)\n"); logerror(" Unable to locate variable %s\n", var1); return -1; } BPatch_ifExpr *tempExpr1 = new BPatch_ifExpr( BPatch_boolExpr(op, *r1, *r2), BPatch_arithExpr(BPatch_assign, *expr1_1, BPatch_constExpr(74))); vect7_1.push_back(tempExpr1); return 0; }
test_results_t test1_5_Mutator::executeTest() { // Find the entry point to the procedure "func5_2" const char *funcName = "test1_5_func2"; BPatch_Vector<BPatch_function *> found_funcs; if ((NULL == appImage->findFunction(funcName, found_funcs)) || !found_funcs.size()) { logerror(" Unable to find function %s\n", funcName); return FAILED; } if (1 < found_funcs.size()) { logerror("%s[%d]: WARNING : found %d functions named %s. Using the first.\n", __FILE__, __LINE__, found_funcs.size(), funcName); } BPatch_Vector<BPatch_point *> *point5_1 = found_funcs[0]->findPoint(BPatch_entry); if (!point5_1 || ((*point5_1).size() == 0)) { logerror("Unable to find entry point to \"%s\".\n", funcName); return FAILED; } const char *funcName2 = "test1_5_func1"; BPatch_Vector<BPatch_function *> found_funcs2; if ((NULL == appImage->findFunction(funcName2, found_funcs2)) || !found_funcs2.size()) { logerror(" Unable to find function %s\n", funcName2); return FAILED; } if (1 < found_funcs2.size()) { logerror("%s[%d]: WARNING : found %d functions named %s. Using the first.\n", __FILE__, __LINE__, found_funcs2.size(), funcName2); } BPatch_Vector<BPatch_point *> *point5_2 = found_funcs2[0]->findPoint(BPatch_subroutine); if (!point5_2 || ((*point5_2).size() == 0)) { logerror("Unable to find subroutine call points in \"%s\".\n", funcName2); return FAILED; } const char *globalVar1 = "test1_5_globalVariable5_1"; const char *globalVar2 = "test1_5_globalVariable5_2"; BPatch_variableExpr *expr5_1 = findVariable (appImage, globalVar1, point5_1); BPatch_variableExpr *expr5_2 = findVariable (appImage, globalVar2, point5_1); if (!expr5_1 || !expr5_2) { logerror("**Failed** test #5 (1f w.o. else)\n"); logerror(" Unable to locate variable %s or ", globalVar1); logerror(" variable %s\n", globalVar2); return FAILED; } BPatch_Vector<BPatch_snippet*> vect5_1; // if (0 == 1) globalVariable5_1 = 52; BPatch_ifExpr expr5_3(BPatch_boolExpr(BPatch_eq, BPatch_constExpr(0), BPatch_constExpr(1)), BPatch_arithExpr(BPatch_assign, *expr5_1, BPatch_constExpr(52))); // if (1 == 1) globalVariable5_2 = 53; BPatch_ifExpr expr5_4(BPatch_boolExpr(BPatch_eq, BPatch_constExpr(1), BPatch_constExpr(1)), BPatch_arithExpr(BPatch_assign, *expr5_2, BPatch_constExpr(53))); vect5_1.push_back(&expr5_3); vect5_1.push_back(&expr5_4); BPatch_sequence expr5_5(vect5_1); checkCost(expr5_5); appAddrSpace->insertSnippet(expr5_5, *point5_1); return PASSED; }