/*************************************************************************** Regression test report generator **************************************************************************** Copyright Aaron Giles All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name 'MAME' nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ****************************************************************************/ #include #include #include #include #include #include "osdcore.h" #include "png.h" /*************************************************************************** CONSTANTS & DEFINES ***************************************************************************/ #define MAX_COMPARES 16 #define BITMAP_SPACE 4 enum { STATUS_NOT_PRESENT = 0, STATUS_SUCCESS, STATUS_SUCCESS_DIFFERENT, STATUS_MISSING_FILES, STATUS_EXCEPTION, STATUS_FATAL_ERROR, STATUS_FAILED_VALIDITY, STATUS_OTHER, STATUS_COUNT }; enum { BUCKET_UNKNOWN = 0, BUCKET_IMPROVED, BUCKET_REGRESSED, BUCKET_CHANGED, BUCKET_MULTI_ERROR, BUCKET_CONSISTENT_ERROR, BUCKET_GOOD, BUCKET_GOOD_BUT_CHANGED, BUCKET_GOOD_BUT_CHANGED_SCREENSHOTS, BUCKET_COUNT }; /*************************************************************************** TYPE DEFINITIONS ***************************************************************************/ struct summary_file { summary_file * next; char name[20]; char source[100]; UINT8 status[MAX_COMPARES]; UINT8 matchbitmap[MAX_COMPARES]; char * text[MAX_COMPARES]; UINT32 textsize[MAX_COMPARES]; UINT32 textalloc[MAX_COMPARES]; }; struct summary_list { summary_list * next; summary_file * files; char * dir; char version[40]; }; /*************************************************************************** GLOBAL VARIABLES ***************************************************************************/ static summary_file *filehash[128][128]; static summary_list lists[MAX_COMPARES]; static int list_count; static const char *const bucket_name[] = { "Unknown", "Games That Have Improved", "Games That Have Regressed", "Games With Changed Screenshots", "Games With Multiple Errors", "Games With Consistent Errors", "Games That Are Consistently Good", "Games That Regressed But Improved", "Games With Changed Screenshots", }; static const int bucket_output_order[] = { BUCKET_REGRESSED, BUCKET_IMPROVED, BUCKET_CHANGED, BUCKET_GOOD_BUT_CHANGED_SCREENSHOTS, BUCKET_GOOD_BUT_CHANGED, BUCKET_MULTI_ERROR, BUCKET_CONSISTENT_ERROR }; static const char *const status_text[] = { "", "Success", "Changed", "Missing Files", "Exception", "Fatal Error", "Failed Validity Check", "Other Unknown Error" }; static const char *const status_color[] = { "", "background:#00A000", "background:#E0E000", "background:#8000C0", "background:#C00000", "background:#C00000", "background:#C06000", "background:#C00000", "background:#C00000", }; /*************************************************************************** PROTOTYPES ***************************************************************************/ /* summary parsing */ static int read_summary_log(const char *filename, int index); static summary_file *parse_driver_tag(char *linestart, int index); static summary_file *get_file(const char *filename); static int CLIB_DECL compare_file(const void *file0ptr, const void *file1ptr); static summary_file *sort_file_list(void); /* HTML helpers */ static core_file *create_file_and_output_header(astring &filename, astring &templatefile, astring &title); static void output_footer_and_close_file(core_file *file, astring &templatefile, astring &title); /* report generators */ static void output_report(astring &dirname, astring &tempheader, astring &tempfooter, summary_file *filelist); static int compare_screenshots(summary_file *curfile); static int generate_png_diff(const summary_file *curfile, astring &destdir, const char *destname); static void create_linked_file(astring &dirname, const summary_file *curfile, const summary_file *prevfile, const summary_file *nextfile, const char *pngfile, astring &tempheader, astring &tempfooter); static void append_driver_list_table(const char *header, astring &dirname, core_file *indexfile, const summary_file *listhead, astring &tempheader, astring &tempfooter); /*************************************************************************** INLINE FUNCTIONS ***************************************************************************/ /*------------------------------------------------- trim_string - trim leading/trailing spaces from a string -------------------------------------------------*/ INLINE char *trim_string(char *string) { int length; /* trim leading spaces */ while (*string != 0 && isspace((UINT8)*string)) string++; /* trim trailing spaces */ length = strlen(string); while (length > 0 && isspace((UINT8)string[length - 1])) string[--length] = 0; return string; } /*------------------------------------------------- get_unique_index - get the unique bitmap index for a given entry -------------------------------------------------*/ INLINE int get_unique_index(const summary_file *curfile, int index) { int listnum, curindex = 0; /* if we're invalid, just return that */ if (curfile->matchbitmap[index] == 0xff) return -1; /* count unique elements up to us */ for (listnum = 0; listnum < curfile->matchbitmap[index]; listnum++) if (curfile->matchbitmap[listnum] == listnum) curindex++; return curindex; } /*************************************************************************** MAIN ***************************************************************************/ /*------------------------------------------------- main - main entry point -------------------------------------------------*/ int main(int argc, char *argv[]) { UINT32 bufsize; void *buffer; int listnum; int result; /* first argument is the directory */ if (argc < 4) { fprintf(stderr, "Usage:\nregrep