24 struct submodule
**submods
;
28 struct module
**modules
= 0;
30 struct module
*get_module(char *name
)
33 for (i
= 0; i
< modulecount
; i
++)
35 if (!strcmp(modules
[i
]->name
, name
))
42 struct submodule
*get_submodule(struct module
*mod
, char *name
)
45 for (i
= 0; i
< mod
->submodcount
; i
++)
47 if (!strcmp(mod
->submods
[i
]->name
, name
))
49 return mod
->submods
[i
];
55 void add_test(char *module
, char *submodule
, char *status
, char *file
, char *line
, char *msg
)
58 struct module
*mod
= get_module(module
);
62 modules
= realloc(modules
, (modulecount
+ 1) * sizeof(struct module
*));
63 modules
[modulecount
] = malloc(sizeof(struct module
));
64 memset(modules
[modulecount
], 0, sizeof(struct module
));
65 modules
[modulecount
]->name
= strdup(module
);
66 mod
= modules
[modulecount
];
70 struct submodule
*submod
= get_submodule(mod
, submodule
);
74 mod
->submods
= realloc(mod
->submods
, (mod
->submodcount
+ 1) * sizeof(struct submodule
*));
75 mod
->submods
[mod
->submodcount
] = malloc(sizeof(struct submodule
));
76 memset(mod
->submods
[mod
->submodcount
], 0, sizeof(struct submodule
));
77 mod
->submods
[mod
->submodcount
]->name
= strdup(submodule
);
78 submod
= mod
->submods
[mod
->submodcount
];
82 struct test
*test
= malloc(sizeof(struct test
));
83 test
->msg
= strdup(msg
);
84 if (strcmp(status
, "PASSED"))
87 submod
->failedcount
++;
92 submod
->tests
= realloc(submod
->tests
, (submod
->testcount
+ 1) * sizeof(struct test
*));
93 submod
->tests
[submod
->testcount
] = test
;
97 void create_html_file(void)
99 printf("<html><head><title>Test results</title></head><body>\n");
100 printf("<h1>Test results</h1>\n");
102 for (i
= 0; i
< modulecount
; i
++)
104 struct module
*module
= modules
[i
];
105 printf("<h3>%s</h3>\n", module
->name
);
106 printf("<table border=\"1\">\n");
107 printf("<colgroup><col width=\"100\"><col width=\"100\"></colgroup>\n");
109 for (j
= 0; j
< module
->submodcount
; j
++)
112 float ratio
= (float)module
->submods
[j
]->failedcount
/ (float)module
->submods
[j
]->testcount
;
113 unsigned char red
= ratio
* 255;
114 unsigned char green
= (1.0 - ratio
) * 255;
115 printf("<td>%s</td><td bgcolor=\"#%02X%02X00\">%d/%d</td>", module
->submods
[j
]->name
,
116 red
, green
, module
->submods
[j
]->testcount
- module
->submods
[j
]->failedcount
,
117 module
->submods
[j
]->testcount
);
120 printf("</table>\n");
122 printf("</body></html>\n");
125 int main(int argc
, char **argv
)
131 fgets(buffer
, 1024, stdin
);
132 if (!strncmp("[tests] ", buffer
, 6))
134 buffer
= strchr(buffer
, ']');
135 if (!buffer
) continue;
137 char *module
= buffer
;
138 buffer
= strchr(buffer
, '/');
139 if (!buffer
) continue;
142 char *submodule
= buffer
;
143 buffer
= strchr(buffer
, ':');
144 if (!buffer
) continue;
147 char *status
= buffer
;
148 buffer
= strchr(buffer
, ':');
149 if (!buffer
) continue;
153 buffer
= strchr(buffer
, ':');
154 if (!buffer
) continue;
158 buffer
= strchr(buffer
, ':');
159 if (!buffer
) continue;
163 add_test(module
, submodule
, status
, file
, line
, msg
);