void WriteSumFile(FILE *SumFile,const char* Name,const char* Section, const char* SubSection, const char *Result,double timeTaken) { int MaxSize; size_t nChars; char logBuffer[LINE_BUF_SIZE*2]; char output[256]; char *processedName; time_t ltime; struct tm *stime; char formattedDate[20]; MaxSize = sizeof(logBuffer); sprintf(output,"%d",(int)ceil(timeTaken)); time(<ime); stime = localtime(<ime); strftime(formattedDate,sizeof(formattedDate),"%Y-%m-%d",stime); ConvertBackSlashesToWindowsStyle((char *)SubSection); processedName = (char *)malloc(strlen(Name)+1); removeSpecialCharacters(Name,processedName); AppendDelimitedStringsSum(logBuffer, MaxSize, C_COMMA, C_ESCAPE, processedName,Section,SubSection,PLATFORM,BUILDTYPE,BUILDNUMBER,formattedDate,Result,output,NULL); free(processedName); // to remove the trailing commas at the end of every line in the summary file // logBuffer[MaxSize - 1] = 0; logBuffer[strlen(logBuffer)-1] = 0; RemoveLinefeeds(logBuffer); nChars = fprintf(SumFile, "%s%s", logBuffer,EOLN); if (nChars < strlen(logBuffer)+1) { HarnessError("ERROR: Failed to write to the file to log the " "results. This is a fatal error. errno is %d.\n",errno); } }
//******************************************************************* // all cplexs channels are output to here void CPXPUBLIC CSolver:: channelsfunc(void* handle, const char* message) { CcbData* pMyEvn; char messageBuff[400]; pMyEvn = (CcbData*)handle; CSolver* pSolver; pSolver = (CSolver*) pMyEvn->pThis; strcpy(messageBuff, message); // pSolver->Message("This is the message incoming to ourmsgfunc"); // pSolver->Message( message); RemoveLinefeeds(messageBuff); // pSolver->Message("After filtering line feeds"); // pSolver->Message( message ); if ( pMyEvn->pResultsFunc != NULL) pMyEvn->pResultsFunc(messageBuff, pMyEvn->pSelf); }
/* * Logs the result of a test case to the file in the following form: * <TestDir>,<Section>,<SubSection>,<Name>,<type>,<result>,<Output> */ void LogResult(FILE *ResultsFile, const char *Section, const char *SubSection, const char *Name, TEST_TYPE Type, const char *TestDir, const char *Phase, const char *Result, const char *Output) { int MaxSize; size_t nChars; char logBuffer[LINE_BUF_SIZE * 2]; char *testType; testType = TypeToString(Type); MaxSize = sizeof(logBuffer); if (Output == NULL) { Output = ""; } /* * Silently fail if we run out of buffer space, but throw a null in to be * safe. */ AppendDelimitedStringsVA(logBuffer, MaxSize, C_COMMA, C_ESCAPE, TestDir, Section, SubSection, Name, testType, Phase, Result, Output, NULL); logBuffer[MaxSize - 1] = 0; RemoveLinefeeds(logBuffer); nChars = fprintf(ResultsFile, "%s\n", logBuffer); if (nChars < strlen(logBuffer)+1) { HarnessError("ERROR: Failed to write to the file to log the " "results. This is a fatal error. errno is %d.\n",errno); } }