/* Nothing to do here besides verify that the mutator worked */ int test2_13_mutatee() { if (test2_13_passed) { test_passes(testname); return 0; /* No error */ } else { return -1; /* Error */ } }
/* * Start of Test #4 - sequence * Run two expressions and verify correct ordering. */ int test1_4_mutatee() { if (test1_4_func1()) { return -1; } else { test_passes(testname); return 0; } }
int test1_34_mutatee() { /* The only possible failures occur in the mutator, and if it fails, the * mutatee will never be run. So if the mutatee is run, just return success. */ logerror( "Passed test #34 (loop information)\n" ); test_passes(testname); return 0; /* Test passed */ }
int test_write_param_mutatee() { int result; result = test_write_param_func(); if (result != -1) { test_passes(testname); return 0; /* Test passed */ } else { return -1; /* Test failed */ } }
int test1_1_mutatee() { dprintf("Address of func1_1 is %p, calling func1_1\n", &test1_1_func1_1); test1_1_func1_1(); if (11 == globalVariable1_1) { test_passes(testname); return 0; /* Test passed */ } else { return -1; /* Test failed */ } }
int test1_13_mutatee() { int retval; retval = test1_13_func1(131, 132, 133, 134, 135); if (0 == retval && called_func_3) { test_passes(testname); } return retval; }
//Basic test for create/attach and exit. int pc_library_mutatee() { int result; void *handlea, *handleb; syncloc msg; //fprintf(stderr, "Entering pc_library_mutatee\n"); result = initProcControlTest(threadFunc, NULL); //fprintf(stderr, "Done with init, pc_library_mutatee\n"); if (result != 0) { output->log(STDERR, "Initialization failed\n"); return -1; } //fprintf(stderr, "Opening libtestA pc_library_mutatee\n"); handlea = openLib(LIBTESTA); //fprintf(stderr, "Opening libtestB pc_library_mutatee\n"); handleb = openLib(LIBTESTB); //fprintf(stderr, "Closing libtestB\n"); closeLib(LIBTESTB, handleb); //fprintf(stderr, "Closing libtestB\n"); closeLib(LIBTESTA, handlea); msg.code = SYNCLOC_CODE; result = send_message((unsigned char *) &msg, sizeof(syncloc)); if (result == -1) { output->log(STDERR, "Failed to send sync message\n"); return -1; } result = recv_message((unsigned char *) &msg, sizeof(syncloc)); if (result == -1) { output->log(STDERR, "Failed to recv sync message\n"); return -1; } if (msg.code != SYNCLOC_CODE) { output->log(STDERR, "Recieved unexpected sync message\n"); return -1; } result = finiProcControlTest(0); if (result != 0) { output->log(STDERR, "Finalization failed\n"); return -1; } test_passes(testname); return 0; }
int test5_8_mutatee() { test5_8_test8.func_cpp(); if (1 == passed) { // Test passed logstatus("Passed test #8 (declaration)\n"); test_passes(testname); return 0; } else { if (!inst_called) { logerror("**Failed test #8 (declaration)\n"); logerror(" Instrumentation not called\n"); } // Test failed return -1; } }
int test1_12F_mutatee() { globals.passedTest_ = FALSE; if (setupFortranOutput()) { logerror("Error redirecting Fortran component output to log file\n"); } init_globals(); func12_1(); if (cleanupFortranOutput()) { logerror("Error restoring output to stdout\n"); } /* Combine fortran passedTest with C passedTest */ if (globals.passedTest_) { test_passes(testname); return 0; } else { return -1; } }
int test_stack_1_mutatee() { test_stack_1_func1(); /* If the mutatee passed the test, set passedTest[0] to TRUE, and return 0 */ test_passes(testname); return 0; /* Return code for this mutatee is not checked */ }
/* * Test #24 - arrary variables */ int test1_24_mutatee() { int i, j; int retval; #if !defined(rs6000_ibm_aix4_1_test) \ && !defined(i386_unknown_linux2_0_test) \ && !defined(x86_64_unknown_linux2_4_test) /* Blind duplication - Ray */ \ && !defined(i386_unknown_nt4_0_test) \ && !defined(os_freebsd_test) \ && !defined(os_linux_test) /* Use OS #define instead of platform - Greg */ logerror("Skipped test #24 (array variables)\n"); logerror("\t- not implemented on this platform\n"); test_passes(testname); /* Test "passes" */ retval = 0; #else /* passedTest[24] = TRUE; */ for (i=0; i < 100; i++) test1_24_globalVariable1[i] = 2400000; test1_24_globalVariable1[79] = 2400003; test1_24_globalVariable1[83] = 2400004; for (i=0; i < 10; i++) { for (j=0; j < 15; j++) { test1_24_globalVariable8[i][j] = 2400010; } } test1_24_globalVariable8[7][9] = 2400012; /* inst code we put into this function: * At Call: * test1_24_globalVariable1[1] = 2400001 * test1_24_globalVariable1[test1_24_globalVariable2] = 2400002 * test1_24_globalVariable3 = test1_24_globalVariable1[79] * test1_24_globalVariable5 = test1_24_globalVariable1[test1_24_globalVariable4] * localVariable24_1[1] = 2400001 * localVariable24_1[test1_24_globalVariable2] = 2400002 * test1_24_globalVariable8[2][3] = 2400011 * test1_24_globalVariable6 = localVariable24_1[79] * test1_24_globalVariable7 = localVariable24_1[test1_24_globalVariable4] */ test1_24_call1(); for (i=0; i < 100; i++) { if (i == 1) { /* 1st element should be modified by the snippet (constant index) */ verifyValue24("test1_24_globalVariable1", test1_24_globalVariable1, 1, 2400001); } else if (i == 53) { /* 53rd element should be modified by the snippet (variable index) */ verifyValue24("test1_24_globalVariable1", test1_24_globalVariable1, 53, 2400002); } else if (i == 79) { /* 79th element was modified by us */ verifyValue24("test1_24_globalVariable1", test1_24_globalVariable1, 79, 2400003); } else if (i == 83) { /* 83rd element was modified by us */ verifyValue24("test1_24_globalVariable1", test1_24_globalVariable1, 83, 2400004); } else if (test1_24_globalVariable1[i] != 2400000) { /* rest should still be the original value */ verifyValue24("test1_24_globalVariable1", test1_24_globalVariable1, i, 2400000); } } verifyScalarValue24("test1_24_globalVariable3", test1_24_globalVariable3, 2400003); verifyScalarValue24("test1_24_globalVariable5", test1_24_globalVariable5, 2400004); /* now for the two elements read from the local variable */ verifyScalarValue24("test1_24_globalVariable6", test1_24_globalVariable6, 2400007); verifyScalarValue24("test1_24_globalVariable7", test1_24_globalVariable7, 2400008); /* verify 2-d element use */ verifyScalarValue24("test1_24_globalVariable8[2][3]", test1_24_globalVariable8[2][3], 2400011); verifyScalarValue24("test1_24_globalVariable9", test1_24_globalVariable9, 2400012); if (!test_failed) { logerror("Passed test #24 (array variables)\n"); test_passes(testname); retval = 0; /* Test passed */ } else { retval = -1; /* Test failed */ } #endif return retval; }
//Basic test for create/attach and exit. int pc_thread_cont_mutatee() { int result; int error = 0; int i; struct local_data *localData = NULL; handshake can_stop; allow_exit can_exit; num_threads = 0; for (i = 0; i < gargc; i++) { if (strcmp(gargv[i], "-mt") == 0) { num_threads = atoi(gargv[i+1]); break; } } if( num_threads > 0 ) { // Each thread needs its own mutex and access to the barrier localData = (struct local_data *)malloc(sizeof(struct local_data)); initBarrier(&localData->barrier, num_threads+1); localData->myLocks = (testlock_t *)malloc(sizeof(testlock_t)*num_threads); for(i = 0; i < num_threads; ++i) { initLock(&localData->myLocks[i]); testLock(&localData->myLocks[i]); } } result = initProcControlTest(threadFunc, (void *)localData); if (result != 0) { output->log(STDERR, "Initialization failed\n"); if( num_threads > 0 ) freeLocalData(localData); return -1; } if( num_threads > 0 ) { logstatus("initial thread: waiting on barrier\n"); waitTestBarrier(&localData->barrier); // Alert the mutator that all the threads have gotten through the lock // and can safely be stopped now can_stop.code = HANDSHAKE_CODE; send_message((unsigned char *)&can_stop, sizeof(handshake)); // Wait for mutator to indicate that the stop finished memset(&can_stop, 0, sizeof(handshake)); recv_message((unsigned char *)&can_stop, sizeof(handshake)); if (can_stop.code != HANDSHAKE_CODE) { output->log(STDERR, "Received event that wasn't handshake\n"); error = 1; } logstatus("initial thread: received stop handshake, releasing threads\n"); // Release all the locks for(i = 0; i < num_threads; ++i) { testUnlock(&localData->myLocks[i]); } // Alert mutator that all threads can be continued when ready memset(&can_stop, 0, sizeof(handshake)); can_stop.code = HANDSHAKE_CODE; send_message((unsigned char *)&can_stop, sizeof(handshake)); logstatus("initial thread: all threads can be continued\n"); } recv_message((unsigned char *) &can_exit, sizeof(allow_exit)); if (can_exit.code != ALLOWEXIT_CODE) { output->log(STDERR, "Recieved event that wasn't allow_exit\n"); error = 1; } result = finiProcControlTest(0); if (result != 0) { output->log(STDERR, "Finalization failed\n"); if( num_threads > 0 ) freeLocalData(localData); return -1; } if (error) { if( num_threads > 0 ) freeLocalData(localData); return -1; } if( num_threads > 0 ) freeLocalData(localData); test_passes(testname); return 0; }
/* FIXME Remove all this condition compilation crud & replace with correct * specifications */ int test1_40_mutatee(void) { #ifdef __XLC__ /* xlc does not produce dynamic inst points with this example, so we just ignore it. */ logerror("Skipped test #40 (monitor dynamic call sites)\n"); logerror("\t- not implemented for mutatees compiled with xlc \n"); test_passes(testname); return 0; /* Test "passed" */ #elif !defined(os_windows_test) int failed = FALSE; test1_40_call5(test1_40_call1); test1_40_call5(test1_40_call2); test1_40_call5(test1_40_call3); if (test1_40_addr_of_call1 != gv40_call40_1_addr) { logerror( "Failed test #40 (monitor dynamic call site)\n" ); logerror( "%s[%d]: addr %p != addr %p\n", __FILE__, __LINE__, (void *)(long)test1_40_addr_of_call1, (void *)(long)gv40_call40_1_addr); failed = TRUE; } if (test1_40_addr_of_call2 != gv40_call40_2_addr) { logerror( "Failed test #40 (monitor dynamic call site)\n" ); logerror( "%s[%d]: addr %p != addr %p\n", __FILE__, __LINE__, (void *)(long)test1_40_addr_of_call2, (void *)(long)gv40_call40_2_addr); failed = TRUE; } if (test1_40_addr_of_call3 != gv40_call40_3_addr) { logerror( "Failed test #40 (monitor dynamic call site)\n" ); logerror( "%s[%d]: addr %p != addr %p\n", __FILE__, __LINE__, (void *)(long)test1_40_addr_of_call3, (void *)(long)gv40_call40_3_addr); failed = TRUE; } if (test1_40_callsite5_addr != gv40_call40_5_addr1) { logerror( "Failed test #40 (monitor dynamic call site)\n" ); logerror( "%s[%d]: addr %p != addr %p\n", __FILE__, __LINE__, (void *)(long)test1_40_callsite5_addr, (void *)(long)gv40_call40_5_addr1); failed = TRUE; } if (test1_40_callsite5_addr != gv40_call40_5_addr2) { logerror( "Failed test #40 (monitor dynamic call site)\n" ); logerror( "%s[%d]: addr %p != addr %p\n", __FILE__, __LINE__, (void *)(long)test1_40_callsite5_addr, (void *)(long)gv40_call40_5_addr2); failed = TRUE; } if (test1_40_callsite5_addr != gv40_call40_5_addr3) { logerror( "Failed test #40 (monitor dynamic call site)\n" ); logerror( "%s[%d]: addr %p != addr %p\n", __FILE__, __LINE__, (void *)(long)test1_40_callsite5_addr, (void *)(long)gv40_call40_5_addr3); failed = TRUE; } if (FALSE == failed) { logerror( "Passed test #40 (monitor dynamic call site)\n" ); fflush(NULL); test_passes(testname); return 0; /* Test passed */ } else { return -1; /* Test failed */ } #else /* ia64 or Windows */ /* no alpha yet */ logerror("Skipped test #40 (monitor dynamic call sites)\n"); logerror("\t- not implemented on this platform\n"); test_passes(testname); return 0; /* Test "passed" */ #endif }
int test_main(int /*argc*/, char * /*argv */[]){ test_fails(); test_passes(); return EXIT_SUCCESS; }
int test1_22_mutatee() { int retval = 0; #if defined(os_linux_test) \ || defined(os_windows_test) \ || defined(os_freebsd_test) /* libtestA.so should already be loaded (by the mutator), but we need to use the dl interface to get pointers to the functions it defines. */ /* int (*call22_5)(int); */ /* int (*call22_6)(int); */ call_type call22_5; call_type call22_6; /* Why shadowing the top-level declaration? */ void *handleA; char dlopenName[128]; int result; unused = sprintf(dlopenName, "%s", libNameA); handleA = loadDynamicLibrary(dlopenName); if (! handleA) { logerror("**Failed test #22 (replaceFunction)\n"); logerror(" Mutatee couldn't get handle for %s\n", libNameA); retval = -1; /* Test failed */ } /* call22_5 = (int(*)(int)) getFuncFromDLL(handleA, "call22_5"); */ call22_5 = (call_type) getFuncFromDLL(handleA, "call22_5a"); if (! call22_5) { logerror("**Failed test #22 (replaceFunction)\n"); logerror(" Mutatee couldn't get handle for call22_5 in %s\n", libNameA); retval = -1; /* Test failed */ } /* call22_6 = (int(*)(int)) getFuncFromDLL(handleA, "call22_6"); */ call22_6 = (call_type) getFuncFromDLL(handleA, "call22_6"); if (! call22_6) { logerror("**Failed test #22 (replaceFunction)\n"); logerror(" Mutatee couldn't get handle for call22_6 in %s\n", libNameA); retval = -1; /* Test failed */ } /* Call functions that have been replaced by the mutator. The side effects of these calls (replaced, not replaced, or otherwise) are independent of each other. */ result = test1_22_call1(10); /* replaced by test1_22_call2 */ if (result != 10 + MAGIC22_2) { logerror("**Failed test #22 (replace function) (a.out -> a.out)\n"); retval = -1; /* Test failed */ } result = test1_22_call3(20); /* replaced by call22_4 */ if (result != 20 + MAGIC22_4) { logerror("**Failed test #22 (replace function) (a.out -> shlib)\n"); retval = -1; /* Test failed */ } if (call22_5 != NULL) { result = call22_5(30); /* replaced by call22_5 (in libtestB) */ if (result != 30 + MAGIC22_5B) { logerror("**Failed test #22 (replace function) (shlib -> shlib)\n"); retval = -1; /* Test failed */ } } if (call22_6 != NULL) { result = call22_6(40); /* replaced by test1_22_call7 */ if (result != 40 + MAGIC22_7) { logerror("**Failed test #22 (replace function) (shlib -> a.out)\n"); retval = -1; /* Test failed */ } } if (0 == retval) { logerror("Passed test #22 (replace function)\n"); test_passes(testname); } #else logerror("Skipped test #22 (replace function)\n"); logerror("\t- not implemented on this platform\n"); test_passes(testname); #endif return retval; }