From 7c19aac60e12d6f5ea301bdb34d7826a01e0b06f Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 8 Nov 2015 12:56:12 +0100 Subject: Rename *.c -> *.cpp in our source (nw) --- src/tools/regrep.cpp | 1109 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1109 insertions(+) create mode 100644 src/tools/regrep.cpp (limited to 'src/tools/regrep.cpp') diff --git a/src/tools/regrep.cpp b/src/tools/regrep.cpp new file mode 100644 index 00000000000..8c2beddf0ed --- /dev/null +++ b/src/tools/regrep.cpp @@ -0,0 +1,1109 @@ +// license:BSD-3-Clause +// copyright-holders:Aaron Giles +/*************************************************************************** + + Regression test report generator + +****************************************************************************/ + +#include +#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]; + std::string text[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(std::string &filename, std::string &templatefile, std::string &title); +static void output_footer_and_close_file(core_file *file, std::string &templatefile, std::string &title); + +/* report generators */ +static void output_report(std::string &dirname, std::string &tempheader, std::string &tempfooter, summary_file *filelist); +static int compare_screenshots(summary_file *curfile); +static int generate_png_diff(const summary_file *curfile, std::string &destdir, const char *destname); +static void create_linked_file(std::string &dirname, const summary_file *curfile, const summary_file *prevfile, const summary_file *nextfile, const char *pngfile, std::string &tempheader, std::string &tempfooter); +static void append_driver_list_table(const char *header, std::string &dirname, core_file *indexfile, const summary_file *listhead, std::string &tempheader, std::string &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