Fix more C++ transition issues
[charm.git] / coverage / ck-convcore-summary.C
blob65981cf01c7e72b9309c4b22877b690f0c6b4867
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
5 int main(int argc, char **argv) {
6     if(argc != 2) {
7         fprintf(stderr, "Usage:\n\tck-convcore [lcov trace file]\n");
8         exit(1);
9     }
11     FILE *tracefile = fopen(argv[1], "r");
12     if(tracefile == NULL) {
13         fprintf(stderr, "Error: couldn't open tracefile %s\n", argv[1]);
14         exit(1);
15     }
17     int inCK = 0, inCONV = 0, finishedCK = 0, finishedCONV = 0;
18     int FNFck = 0, FNHck = 0, LHck = 0, LFck = 0;
19     int FNFconv = 0, FNHconv = 0, LHconv = 0, LFconv = 0;
20     char *lineptr = NULL;
21     size_t n = 0;
22     while(getline(&lineptr, &n, tracefile) != -1) {
23         if(inCK) {
24             if(lineptr[0] == 'F' && lineptr[1] == 'N' && lineptr[2] == 'F')
25                 FNFck = atoi(lineptr + 4);
26             else if(lineptr[0] == 'F' && lineptr[1] == 'N' && lineptr[2] == 'H')
27                 FNHck = atoi(lineptr + 4);
28             else if(lineptr[0] == 'L' && lineptr[1] == 'F')
29                 LFck = atoi(lineptr + 3);
30             else if(lineptr[0] == 'L' && lineptr[1] == 'H') {
31                 LHck = atoi(lineptr + 3);
32                 inCK = 0;
33                 finishedCK = 1;
34                 if(finishedCK && finishedCONV)
35                     break;
36             }
37         } else if(inCONV) {
38             if(lineptr[0] == 'F' && lineptr[1] == 'N' && lineptr[2] == 'F')
39                 FNFconv = atoi(lineptr + 4);
40             else if(lineptr[0] == 'F' && lineptr[1] == 'N' && lineptr[2] == 'H')
41                 FNHconv = atoi(lineptr + 4);
42             else if(lineptr[0] == 'L' && lineptr[1] == 'F')
43                 LFconv = atoi(lineptr + 3);
44             else if(lineptr[0] == 'L' && lineptr[1] == 'H') {
45                 LHconv = atoi(lineptr + 3);
46                 inCONV = 0;
47                 finishedCONV = 1;
48                 if(finishedCK && finishedCONV)
49                     break;
50             }
51         } else if(lineptr[0] == 'S' && lineptr[1] == 'F') {
52             if(strstr(lineptr, "tmp/ck.C") != NULL)
53                 inCK = 1;
54             else if(strstr(lineptr, "tmp/convcore.c") != NULL)
55                 inCONV = 1;
56             else if(strstr(lineptr, "tmp/convcore.C") != NULL)
57                 inCONV = 1;
59         }
61         free(lineptr);
62         lineptr = NULL;
63         n = 0;
64     }
66     free(lineptr);
67     lineptr = NULL;
68     n = 0;
70     printf("Summary ck.C in %s:\n", argv[1]);
71     printf("\tlines......: %.1f%% (%d of %d lines)\n", ((double)(100 * LHck) / LFck), LHck, LFck);
72     printf("\tfunctions..: %.1f%% (%d of %d functions)\n", ((double)(100 * FNHck) / FNFck), FNHck, FNFck);
74     printf("Summary convcore.C in %s:\n", argv[1]);
75     printf("\tlines......: %.1f%% (%d of %d lines)\n", ((double)(100 * LHconv) / LFconv), LHconv, LFconv);
76     printf("\tfunctions..: %.1f%% (%d of %d functions)\n", ((double)(100 * FNHconv) / FNFconv), FNHconv, FNFconv);