void errorReporterClose(ErrorReporter self) { // Always do this, just in case flushErrorLog(); printf("\n=== Error report complete ===\n"); printf("Created error report at %s\n", self->reportDirPath->data); printf("Please compress and email the report to: %s\n", SUPPORT_EMAIL); printf("Thanks!\n"); }
void errorReporterClose(ErrorReporter self) { #if HAVE_LIBARCHIVE struct archive* outArchive; CharString outputFilename = newCharString(); LinkedList reportContents = newLinkedList(); #endif // Always do this, just in case flushErrorLog(); #if HAVE_LIBARCHIVE // In case any part of the error report causes a segfault, this function will // be called recursively. A mutex would really be a better solution here, but // this will also work just fine. if(!self->completed) { self->completed = true; buildAbsolutePath(self->desktopPath, self->reportName, "tar.gz", outputFilename); listDirectory(self->reportDirPath->data, reportContents); if(self != NULL) { outArchive = archive_write_new(); archive_write_set_compression_gzip(outArchive); archive_write_set_format_pax_restricted(outArchive); archive_write_open_filename(outArchive, outputFilename->data); linkedListForeach(reportContents, _remapFileToErrorReportRelativePath, self); chdir(self->desktopPath->data); linkedListForeach(reportContents, _addFileToArchive, outArchive); archive_write_close(outArchive); archive_write_free(outArchive); } // Remove original error report removeDirectory(self->reportDirPath); } #endif printf("\n=== Error report complete ===\n"); printf("Created error report at %s\n", self->reportDirPath->data); #if HAVE_LIBARCHIVE printf("Please email the report to: %s\n", SUPPORT_EMAIL); #else printf("Please compress and email the report to: %s\n", SUPPORT_EMAIL); #endif printf("Thanks!\n"); }
int main(int iargc, char *argv[]) { /* despite different conventions */ unsigned argc = (unsigned) iargc; /* make argc consistently unsigned */ unsigned int i; signed int j; char *logfilename = NULL; int allTestsPassed = TRUE; int retval; char *mutatee_name = NULL; unsigned int label_count = 0; int print_labels = FALSE; FILE* f; #if defined(os_bgq_test) MPI_Init(&iargc, &argv); #endif gargc = argc; gargv = argv; initOutputDriver(); /* Extract the name of the mutatee binary from argv[0] */ /* Find the last '/' in argv[0]; we want everything after that */ mutatee_name = strrchr(argv[0], '/'); if (!mutatee_name) { /* argv[0] contains just the filename for the executable */ mutatee_name = argv[0]; setExecutableName(argv[0]); } else { mutatee_name += 1; /* Skip past the '/' */ setExecutableName(mutatee_name); } for (j=0; j < max_tests; j++) { runTest[j] = FALSE; } /* Parse command line arguments */ for (i=1; i < argc; i++) { if (!strcmp(argv[i], "-verbose")) { debugPrint = 1; } else if (!strcmp(argv[i], "-log")) { /* Read the log file name so we can set it up later */ if ((i + 1) >= argc) { output->log(STDERR, "Missing log file name\n"); exit(-1); } i += 1; logfilename = argv[i]; } else if (!strcmp(argv[i], "-attach")) { useAttach = TRUE; #if !defined(os_windows_test) if (++i >= argc) { output->log(STDERR, "attach usage\n"); output->log(STDERR, "%s\n", USAGE); exit(-1); } pfd = atoi(argv[i]); #endif } else if (!strcmp(argv[i], "-customattach")) { custom_attach = 1; } else if (!strcmp(argv[i], "-delayedattach")) { delayed_attach = 1; } else if (!strcmp(argv[i], "-run")) { int j; for ( j = i+1; j < argc; j++ ) { if ( argv[j][0] == '-' ) { // end of test list break; } else { setRunTest(argv[j]); } } i = j - 1; } else if (!strcmp(argv[i], "-label")) { if (i + 1 >= argc) { output->log(STDERR, "-label must be followed by a label string\n"); exit(-1); } i += 1; setLabel(argv[i]); label_count += 1; } else if (!strcmp(argv[i], "-print-labels")) { print_labels = TRUE; } else if (!strcmp(argv[i], "-humanlog")) { if (i + 1 >= argc) { output->log(STDERR, "-humanlog must be followed by a file name or '-'\n"); exit(-1); } i += 1; setHumanLog(argv[i]); } else if (!strcmp(argv[i], "-runall")) { for (j = 0; j < max_tests; j++) { runTest[j] = TRUE; } } else if (!strcmp(argv[i], "-dboutput")) { /* Set up database output */ initDatabaseOutputDriver(); } else if (!strcmp(argv[i], "-resumelog")) { i += 1; resumelog_name = argv[i]; } else if (!strcmp(argv[i], "-uniqueid")) { i += 1; unique_id = atoi(argv[i]); } else if (!strcmp(argv[i], "-signal_file")) { i += 1; f = fopen(argv[i], "w"); fclose(f); } else if (!strcmp(argv[i], "-signal_fd")) { signal_fd = atoi(argv[++i]); if (!signal_fd) { fprintf(stderr, "Invalid signal_fd value %s\n", argv[i]); exit(-1); } } else { /* Let's just ignore unrecognized parameters. They might be * important to a specific test. */ } } //fprintf(stderr, "parsed command line args\n"); if ((logfilename != NULL) && (strcmp(logfilename, "-") != 0)) { /* Set up the log file */ redirectStream(LOGINFO, logfilename); redirectStream(LOGERR, logfilename); outlog = fopen(logfilename, "a"); if (NULL == outlog) { output->log(STDERR, "Error opening log file %s\n", logfilename); exit(-1); } errlog = outlog; } else { outlog = stdout; errlog = stderr; } if ((argc==1) || debugPrint) logstatus("Mutatee %s [%s]:\"%s\"\n", argv[0], mutateeCplusplus ? "C++" : "C", Builder_id); if (argc==1) { fprintf(stderr, "no tests specified, exiting\n"); exit(0); } /* see if we should wait for the attach */ if (useAttach && !custom_attach) { if (!delayed_attach) handleAttach(); } else { setUseAttach(FALSE); } /* * Run the tests and keep track of return values in case of test failure */ for (i = 0; i < (unsigned) max_tests; i++) { if (runTest[i]) { log_testrun(mutatee_funcs[i].testname); if (print_labels && (mutatee_funcs[i].testlabel != NULL)) { logstatus("%s\n", mutatee_funcs[i].testlabel); } output->setTestName(mutatee_funcs[i].testname); mutatee_funcs[i].func(); log_testresult(passedTest[i]); if (!passedTest[i]) { allTestsPassed = FALSE; } } flushOutputLog(); flushErrorLog(); } if (allTestsPassed) { logstatus("All tests passed.\n"); retval = 0; } else { #if 0 unsigned int i; for (i = 0; i < max_tests; ++i) { if (runTest[i]) logstatus("%s[%d]: %s: %s \n", __FILE__, __LINE__, mutatee_funcs[i].testlabel == NULL ? "bad_label" : mutatee_funcs[i].testlabel, passedTest[i] ? "PASSED" : "FAILED"); } logstatus("\n"); #endif retval = -1; } /* Clean up after ourselves */ if ((outlog != NULL) && (outlog != stdout)) { fclose(outlog); } //logstatus("Mutatee exiting\n"); exit( retval); }