Skip to content

Commit 211538b

Browse files
committed
Merge branch 'code-cleanup' into develop
* code-cleanup: Remove HTML and LaTeX output Remove out commented code Remove superfluous documentation comment Remove not needed and undocumented start delay feature
2 parents 33da451 + ff75d82 commit 211538b

File tree

3 files changed

+3
-244
lines changed

3 files changed

+3
-244
lines changed

mpi_test_suite.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -169,31 +169,6 @@ int main (int argc, char * argv[])
169169
MPI_Comm_rank (MPI_COMM_WORLD, &tst_global_rank);
170170
MPI_Comm_size (MPI_COMM_WORLD, &tst_global_size);
171171

172-
{
173-
char * start_delay_str;
174-
/* XXX DOC CN Need to add MPI_TEST_SUITE_START_DELAY environment variable to documentation
175-
*/
176-
start_delay_str = getenv ("MPI_TEST_SUITE_START_DELAY");
177-
if (NULL != start_delay_str)
178-
{
179-
char hostname[256];
180-
int delay;
181-
delay = atoi(start_delay_str);
182-
if (delay < 0) {
183-
printf ("Warning: Delay time should be greater than zero! Using no delay now.\n");
184-
}
185-
else {
186-
gethostname (hostname, 256);
187-
hostname[255] = '\0';
188-
/* XXX LOG CN Should be modified for logfie support.
189-
*/
190-
printf ("(Rank:%d) host:%s pid:%ld Going to sleep for %d seconds\n",
191-
tst_global_rank, hostname, (long int)getpid(), delay);
192-
sleep (delay);
193-
}
194-
}
195-
}
196-
197172
tst_output_init (DEBUG_LOG, TST_OUTPUT_RANK_SELF, TST_REPORT_MAX, TST_OUTPUT_TYPE_LOGFILE, "tst.log");
198173

199174
char *info_str = (char *) calloc(MAX_INFO_STRING_LENGTH, sizeof(char));
@@ -208,10 +183,6 @@ int main (int argc, char * argv[])
208183
#ifndef HAVE_MPI2_THREADS
209184
tst_output_printf(DEBUG_LOG, TST_REPORT_FULL, "Testsuite was compiled without MPI2_THREADS");
210185
#endif
211-
/*
212-
* Output example:
213-
* tst_output_printf (DEBUG_LOG, TST_REPORT_MAX, "Hello from rank %d\n", tst_global_rank);
214-
*/
215186

216187
#if MPI_VERSION < 2
217188
MPI_CHECK (MPI_Attr_get (MPI_COMM_WORLD, MPI_TAG_UB, &val, &flag));
@@ -525,19 +496,6 @@ int main (int argc, char * argv[])
525496
tst_test_print_failed ();
526497
}
527498

528-
/*
529-
* XXX Disable for Thread Checker test, as we free twice???
530-
*/
531-
/*
532-
tst_comm_cleanup ();
533-
tst_type_cleanup ();
534-
tst_test_cleanup ();
535-
tst_profiling_cleanup ();
536-
free (tst_comm_array);
537-
free (tst_type_array);
538-
free (tst_test_array);
539-
*/
540-
541499
time_stop = MPI_Wtime ();
542500
tst_output_printf (DEBUG_LOG, TST_REPORT_FULL, "(Rank:%d) Overall time taken:%lf\n",
543501
tst_global_rank, time_stop - time_start);

tst_output.c

Lines changed: 3 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ tst_output_types tst_output_init(tst_output_stream * output, int rank,
101101
#endif
102102

103103
/* Check if stream type uses a file and get the name of this file */
104-
if (type == TST_OUTPUT_TYPE_LOGFILE || type == TST_OUTPUT_TYPE_HTML ||
105-
type == TST_OUTPUT_TYPE_LATEX) {
104+
if (type == TST_OUTPUT_TYPE_LOGFILE) {
106105
va_start(arglist, type);
107106
fname = va_arg (arglist, char *);
108107
sprintf (output->filename,"R%d_", tst_output_global_rank);
@@ -126,28 +125,6 @@ tst_output_types tst_output_init(tst_output_stream * output, int rank,
126125
return 0;
127126
}
128127
break;
129-
case TST_OUTPUT_TYPE_HTML:
130-
output->streamptr = fopen(output->filename, "w+");
131-
if (output->streamptr == NULL) {
132-
fprintf (stderr, "Error opening stream: Could not open output file.");
133-
return 0;
134-
}
135-
fprintf (output->streamptr, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
136-
"<HTML>\n"
137-
"<TITLE>OpenMPI-Test-Suite - Logfile</TITLE>\n"
138-
"</HEAD>\n"
139-
"<BODY>\n");
140-
break;
141-
case TST_OUTPUT_TYPE_LATEX:
142-
output->streamptr = fopen(output->filename, "w+");
143-
if (output->streamptr == NULL) {
144-
fprintf (stderr, "Error opening stream: Could not open output file.");
145-
return 0;
146-
}
147-
fprintf (output->streamptr, "\\documentclass{article}\n"
148-
"\\title{OpenMPI-Test-Suite - Logfile}\n"
149-
"\\begin{document}\n");
150-
break;
151128
default:
152129
fprintf (stderr, "Error opening stream: Unknown stream type (%i).", type);
153130
return TST_OUTPUT_TYPE_NONE;
@@ -179,16 +156,6 @@ int tst_output_close(tst_output_stream * output) {
179156
strcpy (output->filename,"");
180157
fclose (output->streamptr);
181158
break;
182-
case TST_OUTPUT_TYPE_HTML:
183-
fprintf (output->streamptr, "</BODY>\n</HTML>\n");
184-
strcpy (output->filename,"");
185-
fclose (output->streamptr);
186-
break;
187-
case TST_OUTPUT_TYPE_LATEX:
188-
fprintf (output->streamptr, "\\end{document}\n");
189-
strcpy (output->filename,"");
190-
fclose (output->streamptr);
191-
break;
192159
default:
193160
break;
194161
}
@@ -221,63 +188,8 @@ int tst_output_printf(tst_output_stream * output,
221188

222189
if ((output->isopen == 1) && (output->rank == tst_output_global_rank) && (error_level <= output->level)) {
223190
va_start(arglist, format);
224-
switch (output->type) {
225-
case TST_OUTPUT_TYPE_HTML: {
226-
char * msg;
227-
char * tmpstrptr;
228-
229-
msg = malloc (sizeof(char) * 2048);
230-
count = vsnprintf (msg, 2047, format, arglist);
231-
/* Output was truncated */
232-
if (count >= 2047) {
233-
free(msg);
234-
return -1;
235-
}
236-
tst_output_str_replace ("rank", "<B>rank</B>$", msg, &tmpstrptr);
237-
free (msg);
238-
tst_output_str_replace ("Rank", "<B>Rank</B>", tmpstrptr, &msg);
239-
free (tmpstrptr);
240-
tst_output_str_replace ("ERROR", "<B style=\"color:red;\">ERROR</B>", msg, &tmpstrptr);
241-
free (msg);
242-
tst_output_str_replace ("Error", "<B style=\"color:red;\">Error</B>", tmpstrptr, &msg);
243-
free (tmpstrptr);
244-
count = fprintf (output->streamptr, "<P>\n%s</P>\n", msg);
245-
fflush (output->streamptr);
246-
break;
247-
}
248-
case TST_OUTPUT_TYPE_LATEX: {
249-
char * msg;
250-
char * tmpstrptr;
251-
252-
msg = malloc (sizeof(char) * 2048);
253-
count = vsnprintf (msg, 2047, format, arglist);
254-
/* Output was truncated */
255-
if (count >= 2047) {
256-
free(msg);
257-
return -1;
258-
}
259-
tst_output_latex_special_chars(msg, &tmpstrptr);
260-
tst_output_str_replace ("<", "$<$", tmpstrptr, &msg);
261-
free (tmpstrptr);
262-
tst_output_str_replace (">", "$>$", msg, &tmpstrptr);
263-
free (msg);
264-
tst_output_str_replace ("Rank", "\\textbf{Rank}", tmpstrptr, &msg);
265-
free (tmpstrptr);
266-
tst_output_str_replace ("ERROR", "\\textbf{ERROR}", msg, &tmpstrptr);
267-
free (msg);
268-
tst_output_str_replace ("Error", "\\textbf{Error}", tmpstrptr, &msg);
269-
free (tmpstrptr);
270-
271-
count = fprintf (output->streamptr, "%s", msg);
272-
fprintf (output->streamptr, "\n\n");
273-
fflush (output->streamptr);
274-
break;
275-
}
276-
default:
277-
count = vfprintf (output->streamptr, format, arglist);
278-
fflush (output->streamptr);
279-
break;
280-
}
191+
count = vfprintf (output->streamptr, format, arglist);
192+
fflush (output->streamptr);
281193
va_end(arglist);
282194
}
283195
else {
@@ -287,112 +199,3 @@ int tst_output_printf(tst_output_stream * output,
287199
return count;
288200
}
289201

290-
/****************************************************************************/
291-
/** **/
292-
/** LOCAL FUNCTIONS **/
293-
/** **/
294-
/****************************************************************************/
295-
296-
int tst_output_latex_special_chars(char *string, char **result) {
297-
int count = 0;
298-
int newlength = 0;
299-
char * strptr = NULL;
300-
char * resultptr;
301-
302-
/* calculate number of special chars */
303-
strptr = string;
304-
while (*strptr != '\0'){
305-
switch (*strptr) {
306-
case '\\':
307-
case '&':
308-
case '$':
309-
case '%':
310-
case '#':
311-
case '_':
312-
case '{':
313-
case '}':
314-
count++;
315-
break;
316-
}
317-
strptr++;
318-
}
319-
/* allocate memory for the result */
320-
newlength = strlen (string) + count;
321-
resultptr = malloc(sizeof (char) * (newlength + 1));
322-
memset (resultptr, 0, newlength + 1);
323-
*result = resultptr;
324-
/* do special char masking */
325-
strptr = string;
326-
while (*strptr != '\0'){
327-
switch (*strptr) {
328-
case '\\':
329-
case '&':
330-
case '$':
331-
case '%':
332-
case '#':
333-
case '_':
334-
case '{':
335-
case '}':
336-
*resultptr = '\\';
337-
resultptr++;
338-
*resultptr = *strptr;
339-
resultptr++;
340-
break;
341-
default:
342-
*resultptr = *strptr;
343-
resultptr++;
344-
break;
345-
}
346-
strptr++;
347-
}
348-
*resultptr = '\0';
349-
350-
return count;
351-
}
352-
353-
int tst_output_str_replace(char *search, char *replace, char *string, char **result) {
354-
int count = 0, replace_count = 0;
355-
int oldlength = 0;
356-
int newlength = 0 ;
357-
int searchlength = 0;
358-
int n;
359-
char * strptr = NULL;
360-
char * oldstrptr = NULL;
361-
362-
oldlength = strlen(string);
363-
searchlength = strlen (search);
364-
365-
/* Calculate number of replacements to be preformed */
366-
for (strptr = strstr(string, search); strptr != NULL; strptr = strstr(++strptr, search)) {
367-
count++;
368-
}
369-
/* Calculate length of the resulting string and allocate the necessary memory */
370-
newlength = oldlength + count * (strlen(replace) - strlen(search));
371-
*result = (char *) malloc ( (newlength + 1) * sizeof (char) );
372-
memset (*result, 0, newlength + 1);
373-
374-
/* Perform replacements and store result to new string */
375-
for (strptr = string; ; ) {
376-
oldstrptr = strptr;
377-
strptr = strstr (strptr, search);
378-
/* all replacements done? */
379-
if (strptr == NULL) {
380-
strcat (*result, oldstrptr);
381-
break;
382-
}
383-
/* Append all up to place of discovery */
384-
n = strptr - oldstrptr;
385-
strncat (*result, oldstrptr, n);
386-
/* Append replace string and move forward in the string */
387-
strcat (*result, replace);
388-
strptr += searchlength;
389-
replace_count++;
390-
}
391-
392-
/* Safety check */
393-
if (count != replace_count) {
394-
fprintf (stderr, "Error: count (%d) != replace_count (%d)!\n", count, replace_count);
395-
exit (-1);
396-
}
397-
return count;
398-
}

tst_output.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ typedef enum {
2222
TST_OUTPUT_TYPE_STDERR, /**< Output on stderr */
2323
TST_OUTPUT_TYPE_STDOUT, /**< Output on stdout */
2424
TST_OUTPUT_TYPE_LOGFILE, /**< Output into logfile */
25-
TST_OUTPUT_TYPE_LATEX, /**< Output into latex file */
26-
TST_OUTPUT_TYPE_HTML /**< Output into html file */
2725
} tst_output_types;
2826

2927

0 commit comments

Comments
 (0)