From: Isira Seneviratne Subject: [PATCH v4] winetest: Add GUI to display results of individual tests. Message-Id: Date: Wed, 13 Feb 2019 14:27:52 +0530

From 973a3540b2804fa38e6f643bf08b9d5ccd540aa7 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Sun, 16 Dec 2018 14:59:20 +0530 Subject: [PATCH v4] winetest: Add GUI to display results of individual tests. This patch adds a listview control displaying the results of each test, together with the component being tested. Signed-off-by: Isira Seneviratne --- programs/winetest/gui.c | 23 +++++++++++++- programs/winetest/main.c | 60 +++++++++++++++++++++++++++++++++-- programs/winetest/resource.h | 2 ++ programs/winetest/winetest.h | 4 +++ programs/winetest/winetest.rc | 18 +++++++---- 5 files changed, 97 insertions(+), 10 deletions(-) diff --git a/programs/winetest/gui.c b/programs/winetest/gui.c index bda00f3707..656d10a8db 100644 --- a/programs/winetest/gui.c +++ b/programs/winetest/gui.c @@ -2,6 +2,7 @@ * GUI support * * Copyright 2004 Ferenc Wagner + * Copyright 2018-2019 Isira Seneviratne * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -43,6 +44,9 @@ static int progressGroup; static WNDPROC DefEditProc; +/* List view handle */ +HWND res_list_view; + static int MBdefault (int uType) { @@ -130,7 +134,7 @@ guiStep (va_list ap) { const int pgID = IDC_ST0 + progressGroup * 2; char *str = vstrmake (NULL, ap); - + progressCurr++; SetDlgItemTextA (dialog, pgID, str); SendDlgItemMessageA(dialog, pgID+1, PBM_SETPOS, @@ -421,6 +425,8 @@ AboutProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) static INT_PTR CALLBACK DlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { + LVCOLUMNA lvCol; + switch (msg) { case WM_INITDIALOG: SendMessageA(hwnd, WM_SETICON, ICON_SMALL, @@ -430,6 +436,21 @@ DlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) SendMessageA(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIconA( GetModuleHandleA(NULL), MAKEINTRESOURCEA(IDI_WINE))); dialog = hwnd; + + /* Initializes the list view control that the main dialog window contains */ + res_list_view = GetDlgItem(dialog, IDD_RES_LIST); + + lvCol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + lvCol.cx = 130; + lvCol.fmt = LVCFMT_LEFT; + + lvCol.pszText = (char *) "Component"; + ListView_InsertColumnA(res_list_view, 0, &lvCol); + + lvCol.pszText = (char *) "No. of failures"; + lvCol.cx = 100; + ListView_InsertColumnA(res_list_view, 1, &lvCol); + if (!SetEvent (initEvent)) { report (R_STATUS, "Can't signal main thread: %d", GetLastError ()); diff --git a/programs/winetest/main.c b/programs/winetest/main.c index 3d6cc660ec..46f461ff1e 100644 --- a/programs/winetest/main.c +++ b/programs/winetest/main.c @@ -4,6 +4,7 @@ * Copyright 2003, 2004 Jakob Eriksson (for Solid Form Sweden AB) * Copyright 2003 Dimitrie O. Paun * Copyright 2003 Ferenc Wagner + * Copyright 2018-2019 Isira Seneviratne * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,10 +31,12 @@ #define COBJMACROS #include +#include #include #include #include #include +#include #include "winetest.h" #include "resource.h" @@ -85,6 +88,9 @@ static void (WINAPI *pReleaseActCtx)(HANDLE); /* To store the current PATH setting (related to .NET only provided dlls) */ static char *curpath; +/* To display the test results in a listview control */ +static int cur_row = 0; + /* check if test is being filtered out */ static BOOL test_filtered_out( LPCSTR module, LPCSTR testname ) { @@ -533,7 +539,7 @@ static void* extract_rcdata (LPCSTR name, LPCSTR type, DWORD* size) HRSRC rsrc; HGLOBAL hdl; LPVOID addr; - + if (!(rsrc = FindResourceA(NULL, name, type)) || !(*size = SizeofResource (0, rsrc)) || !(hdl = LoadResource (0, rsrc)) || @@ -788,12 +794,62 @@ run_test (struct wine_test* test, const char* subtest, HANDLE out_file, const ch } else { - int status; + int status, test_fail_count, test_count, test_todo_count, test_skipped_count; + int match_count; + char test_fail_count_str[10]; + char buffer[1000]; + char subtest_name[20]; + char test_subtest_name[50]; + char *cur_line = buffer, *next_line; DWORD pid, start = GetTickCount(); + DWORD read_count; + LVITEMA lv_item; char *cmd = strmake (NULL, "%s %s", test->exename, subtest); + report (R_STEP, "Running: %s:%s", test->name, subtest); xprintf ("%s:%s start %s -\n", test->name, subtest, file); status = run_ex (cmd, out_file, tempdir, 120000, &pid); + + lv_item.mask = LVIF_TEXT; + lv_item.state = 0; + lv_item.stateMask = 0; + + SetFilePointer (out_file, -sizeof(buffer), NULL, FILE_CURRENT); + ReadFile (out_file, buffer, sizeof(buffer), &read_count, NULL); + + /* + * Traverses the buffer line by line, reading the lines of the test output + * where the test results are saved. + */ + while (1) + { + match_count = sscanf (cur_line, + "%*x:%s %d tests executed (%d marked as todo, %d failures), %d skipped.", + subtest_name, &test_count, &test_todo_count, &test_fail_count, &test_skipped_count); + + if (match_count == 5) + { + sprintf (test_subtest_name, "%s:%s", test->name, subtest); + sprintf (test_fail_count_str, "%d", test_fail_count); + + /* Adds a single row to the list view control (component name and no. of failed tests). */ + lv_item.iSubItem = 0; + lv_item.iItem = cur_row; + lv_item.pszText = test_subtest_name; + ListView_InsertItemA (res_list_view, &lv_item); + + lv_item.iSubItem = 1; + lv_item.pszText = test_fail_count_str; + ListView_SetItemA (res_list_view, &lv_item); + + cur_row++; + } + next_line = strchr (cur_line, '\n'); + if (!next_line) + break; + cur_line = next_line+1; + } + heap_free (cmd); xprintf ("%s:%s:%04x done (%d) in %ds\n", test->name, subtest, pid, status, (GetTickCount()-start)/1000); if (status) failures++; diff --git a/programs/winetest/resource.h b/programs/winetest/resource.h index be71274f58..90c684e130 100644 --- a/programs/winetest/resource.h +++ b/programs/winetest/resource.h @@ -2,6 +2,7 @@ * Resource definitions * * Copyright 2004 Ferenc Wagner + * Copyright 2018-2019 Isira Seneviratne * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -24,6 +25,7 @@ #define IDD_ABOUT 101 #define IDD_TAG 102 #define IDD_EMAIL 103 +#define IDD_RES_LIST 105 #define IDC_STATIC -1 diff --git a/programs/winetest/winetest.h b/programs/winetest/winetest.h index 0446ad5bdc..342e25b506 100644 --- a/programs/winetest/winetest.h +++ b/programs/winetest/winetest.h @@ -3,6 +3,7 @@ * * Copyright 2003 Dimitrie O. Paun * Copyright 2003 Ferenc Wagner + * Copyright 2018-2019 Isira Seneviratne * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -74,4 +75,7 @@ int guiAskTag (void); int guiAskEmail (void); int report (enum report_type t, ...); +/* Listview handle */ +extern HWND res_list_view; + #endif /* __WINETESTS_H */ diff --git a/programs/winetest/winetest.rc b/programs/winetest/winetest.rc index a3898b6ce0..662b793ae6 100644 --- a/programs/winetest/winetest.rc +++ b/programs/winetest/winetest.rc @@ -2,6 +2,7 @@ * Winetest resources * * Copyright 2004 Ferenc Wagner + * Copyright 2018-2019 Isira Seneviratne * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -48,7 +49,7 @@ BEGIN PUSHBUTTON "Abort", IDABORT, 85, 45, 40, 14 END -IDD_STATUS DIALOG 0, 0, 160, 150 +IDD_STATUS DIALOG 0, 0, 160, 275 STYLE WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX CAPTION "Wine Test Shell" FONT 8, "MS Shell Dlg" @@ -61,19 +62,22 @@ BEGIN CONTROL "PB2", IDC_PB2, PROGRESS_CLASSA, 0, 5, 65, 150, 10 LTEXT "Tag:", IDC_STATIC, 5, 89, 100, 10 - EDITTEXT IDC_TAG, 25, 88, 125, 10, + EDITTEXT IDC_TAG, 25, 88, 130, 10, ES_READONLY LTEXT "Working directory:", IDC_STATIC, 5, 100, 100, 10 - EDITTEXT IDC_DIR, 71, 99, 79, 10, + EDITTEXT IDC_DIR, 71, 99, 84, 10, ES_READONLY | ES_AUTOHSCROLL LTEXT "Output file:", IDC_STATIC, 5, 111, 100, 10 - EDITTEXT IDC_OUT, 46, 110, 104, 10, + EDITTEXT IDC_OUT, 46, 110, 109, 10, ES_READONLY | ES_AUTOHSCROLL - DEFPUSHBUTTON "About", IDHELP, 20, 123, 30, 14 - PUSHBUTTON "Edit", IDCANCEL, 65, 123, 30, 14, + CONTROL "", IDD_RES_LIST, "SysListView32", WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT, + 5, 130, 150, 100 + + DEFPUSHBUTTON "About", IDHELP, 20, 243, 30, 14 + PUSHBUTTON "Edit", IDCANCEL, 65, 243, 30, 14, WS_DISABLED - PUSHBUTTON "Stop", IDABORT, 110, 123, 30, 14 + PUSHBUTTON "Stop", IDABORT, 110, 243, 30, 14 CONTROL "Created", IDC_SB, STATUSCLASSNAMEA, 0, 0,0,0,0 END -- 2.20.1