<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 26, 2019 at 9:53 AM Zebediah Figura <<a href="mailto:z.figura12@gmail.com">z.figura12@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
On 2/18/19 6:49 AM, Isira Seneviratne wrote:<br>
> From 462243a2e8860ebbac2bedb90fa6cb97050a6080 Mon Sep 17 00:00:00 2001<br>
> From: Isira Seneviratne <<a href="mailto:isirasen96@gmail.com" target="_blank">isirasen96@gmail.com</a>><br>
> Date: Sun, 16 Dec 2018 14:59:20 +0530<br>
> Subject: [PATCH v5] winetest: Add GUI to display results of individual tests.<br>
> <br>
> This patch adds a listview control displaying the results of each<br>
> test, together with the component being tested.<br>
> <br>
> Advancing the file pointer of the log file by 1 eliminates most of the<br>
> duplicate test entries displayed with the previous revision, except for<br>
> advapi32:security tests, which has two entries due to those tests using<br>
> two threads.<br>
<br>
What you want to do about this is to loop until you find the last line <br>
matching<br>
that process, and then add it to the listview. That's what the <br>
<a href="http://test.winehq.org" rel="noreferrer" target="_blank">test.winehq.org</a><br>
dissect script does.<br></blockquote><div> </div><div>Is there a way for me to see how this script works?</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> <br>
> Signed-off-by: Isira Seneviratne <<a href="mailto:isirasen96@gmail.com" target="_blank">isirasen96@gmail.com</a>><br>
> ---<br>
> programs/winetest/gui.c | 25 +++++++++++++--<br>
> programs/winetest/main.c | 60 +++++++++++++++++++++++++++++++++--<br>
> programs/winetest/resource.h | 2 ++<br>
> programs/winetest/winetest.h | 4 +++<br>
> programs/winetest/winetest.rc | 20 +++++++-----<br>
> 5 files changed, 99 insertions(+), 12 deletions(-)<br>
> <br>
> diff --git a/programs/winetest/gui.c b/programs/winetest/gui.c<br>
> index bda00f3707..607918bb08 100644<br>
> --- a/programs/winetest/gui.c<br>
> +++ b/programs/winetest/gui.c<br>
> @@ -2,6 +2,7 @@<br>
> * GUI support<br>
> *<br>
> * Copyright 2004 Ferenc Wagner<br>
> + * Copyright 2018-2019 Isira Seneviratne<br>
> *<br>
> * This library is free software; you can redistribute it and/or<br>
> * modify it under the terms of the GNU Lesser General Public<br>
> @@ -43,6 +44,9 @@ static int progressGroup;<br>
> <br>
> static WNDPROC DefEditProc;<br>
> <br>
> +/* List view handle */<br>
> +HWND res_list_view;<br>
> +<br>
> static int<br>
> MBdefault (int uType)<br>
> {<br>
> @@ -130,7 +134,7 @@ guiStep (va_list ap)<br>
> {<br>
> const int pgID = IDC_ST0 + progressGroup * 2;<br>
> char *str = vstrmake (NULL, ap);<br>
> - <br>
> +<br>
> progressCurr++;<br>
> SetDlgItemTextA (dialog, pgID, str);<br>
> SendDlgItemMessageA(dialog, pgID+1, PBM_SETPOS,<br>
> @@ -421,6 +425,8 @@ AboutProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)<br>
> static INT_PTR CALLBACK<br>
> DlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)<br>
> {<br>
> + LVCOLUMNA lvCol;<br>
> +<br>
> switch (msg) {<br>
> case WM_INITDIALOG:<br>
> SendMessageA(hwnd, WM_SETICON, ICON_SMALL,<br>
> @@ -430,6 +436,21 @@ DlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)<br>
> SendMessageA(hwnd, WM_SETICON, ICON_BIG,<br>
> (LPARAM)LoadIconA( GetModuleHandleA(NULL), MAKEINTRESOURCEA(IDI_WINE)));<br>
> dialog = hwnd;<br>
> +<br>
> + /* Initializes the list view control that the main dialog window contains */<br>
> + res_list_view = GetDlgItem(dialog, IDD_RES_LIST);<br>
> +<br>
> + lvCol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;<br>
> + lvCol.cx = 130;<br>
> + lvCol.fmt = LVCFMT_LEFT;<br>
> +<br>
> + lvCol.pszText = (char *) "Component";<br>
> + ListView_InsertColumnA(res_list_view, 0, &lvCol);<br>
> +<br>
> + lvCol.pszText = (char *) "No. of failures";<br>
> + lvCol.cx = 90;<br>
> + ListView_InsertColumnA(res_list_view, 1, &lvCol);<br>
> +<br>
> if (!SetEvent (initEvent)) {<br>
> report (R_STATUS, "Can't signal main thread: %d",<br>
> GetLastError ());<br>
> @@ -545,7 +566,7 @@ report (enum report_type t, ...)<br>
> }<br>
> }<br>
> }<br>
> - <br>
> +<br>
> va_start (ap, t);<br>
> if (t < ARRAY_SIZE(text_funcs)) ret = funcs[t](ap);<br>
> else report (R_WARNING, "unimplemented report type: %d", t);<br>
> diff --git a/programs/winetest/main.c b/programs/winetest/main.c<br>
> index 3d6cc660ec..8c841ab08e 100644<br>
> --- a/programs/winetest/main.c<br>
> +++ b/programs/winetest/main.c<br>
> @@ -4,6 +4,7 @@<br>
> * Copyright 2003, 2004 Jakob Eriksson (for Solid Form Sweden AB)<br>
> * Copyright 2003 Dimitrie O. Paun<br>
> * Copyright 2003 Ferenc Wagner<br>
> + * Copyright 2018-2019 Isira Seneviratne<br>
> *<br>
> * This library is free software; you can redistribute it and/or<br>
> * modify it under the terms of the GNU Lesser General Public<br>
> @@ -30,10 +31,12 @@<br>
> <br>
> #define COBJMACROS<br>
> #include <stdio.h><br>
> +#include <string.h><br>
> #include <assert.h><br>
> #include <windows.h><br>
> #include <winternl.h><br>
> #include <mshtml.h><br>
> +#include <commctrl.h><br>
> <br>
> #include "winetest.h"<br>
> #include "resource.h"<br>
> @@ -85,6 +88,9 @@ static void (WINAPI *pReleaseActCtx)(HANDLE);<br>
> /* To store the current PATH setting (related to .NET only provided dlls) */<br>
> static char *curpath;<br>
> <br>
> +/* To display the test results in a listview control */<br>
> +static int cur_row = 0;<br>
> +<br>
> /* check if test is being filtered out */<br>
> static BOOL test_filtered_out( LPCSTR module, LPCSTR testname )<br>
> {<br>
> @@ -533,7 +539,7 @@ static void* extract_rcdata (LPCSTR name, LPCSTR type, DWORD* size)<br>
> HRSRC rsrc;<br>
> HGLOBAL hdl;<br>
> LPVOID addr;<br>
> - <br>
> +<br>
> if (!(rsrc = FindResourceA(NULL, name, type)) ||<br>
> !(*size = SizeofResource (0, rsrc)) ||<br>
> !(hdl = LoadResource (0, rsrc)) ||<br>
> @@ -788,12 +794,62 @@ run_test (struct wine_test* test, const char* subtest, HANDLE out_file, const ch<br>
> }<br>
> else<br>
> {<br>
> - int status;<br>
> + int status, test_fail_count, test_count, test_todo_count, test_skipped_count;<br>
> + int match_count;<br>
> + char test_fail_count_str[10];<br>
> + char buffer[1000];<br>
> + char subtest_name[20];<br>
> + char test_subtest_name[50];<br>
> + char *cur_line = buffer, *next_line;<br>
> DWORD pid, start = GetTickCount();<br>
> + DWORD read_count;<br>
> + LVITEMA lv_item;<br>
> char *cmd = strmake (NULL, "%s %s", test->exename, subtest);<br>
> +<br>
> report (R_STEP, "Running: %s:%s", test->name, subtest);<br>
> xprintf ("%s:%s start %s -\n", test->name, subtest, file);<br>
> status = run_ex (cmd, out_file, tempdir, 120000, &pid);<br>
> +<br>
> + lv_item.mask = LVIF_TEXT;<br>
> + lv_item.state = 0;<br>
> + lv_item.stateMask = 0;<br>
> +<br>
> + SetFilePointer (out_file, -sizeof(buffer), NULL, FILE_CURRENT);<br>
> + ReadFile (out_file, buffer, sizeof(buffer), &read_count, NULL);<br>
> + SetFilePointer (out_file, 1, NULL, FILE_CURRENT);<br>
<br>
This doesn't work. You're extending the file pointer 1 past the file's <br>
actual<br>
length, so a '\0' byte will be written. The reason this only prints out one<br>
line of output is because the strchr() call below will break out of the <br>
loop<br>
after [at most] the first output report in the buffer. But that won't<br>
necessarily be the right one. For example, if I add an artificial <br>
failure into<br>
advapi32:lsa, that doesn't show up in the failures column.<br>
<br>
I think what you want to do instead is essentially the same thing as I<br>
recommend to take care of tests that print subprocess reports: just loop <br>
over<br>
all report lines in the log, discarding any but the last. While you're <br>
at it,<br>
you should probably validate the test name from the output report <br>
against the<br>
name of the test you're running, in case the test crashes or hangs.<br>
<br>
> +<br>
> + /*<br>
> + * Traverses the buffer line by line, reading the lines of the test output<br>
> + * where the test results are saved.<br>
> + */<br>
> + while (1)<br>
> + {<br>
> + match_count = sscanf (cur_line, "%*x:%s %d tests executed (%d marked as todo, %d failures), %d skipped.",<br>
> + subtest_name, &test_count, &test_todo_count, &test_fail_count, &test_skipped_count);<br>
> +<br>
> + if (match_count == 5)<br>
> + {<br>
> + sprintf (test_subtest_name, "%s:%s", test->name, subtest);<br>
> + sprintf (test_fail_count_str, "%d", test_fail_count);<br>
> +<br>
> + /* Adds a single row to the list view control (component name and no. of failed tests). */<br>
> + lv_item.iSubItem = 0;<br>
> + lv_item.iItem = cur_row;<br>
> + lv_item.pszText = test_subtest_name;<br>
> + ListView_InsertItemA (res_list_view, &lv_item);<br>
> +<br>
> + lv_item.iSubItem = 1;<br>
> + lv_item.pszText = test_fail_count_str;<br>
> + ListView_SetItemA (res_list_view, &lv_item);<br>
> +<br>
> + cur_row++;<br>
> + }<br>
> + next_line = strchr (cur_line, '\n');<br>
> + if (!next_line)<br>
> + break;<br>
> + cur_line = next_line+1;<br>
> + }<br>
> +<br>
> heap_free (cmd);<br>
> xprintf ("%s:%s:%04x done (%d) in %ds\n", test->name, subtest, pid, status, (GetTickCount()-start)/1000);<br>
> if (status) failures++;<br>
> diff --git a/programs/winetest/resource.h b/programs/winetest/resource.h<br>
> index be71274f58..90c684e130 100644<br>
> --- a/programs/winetest/resource.h<br>
> +++ b/programs/winetest/resource.h<br>
> @@ -2,6 +2,7 @@<br>
> * Resource definitions<br>
> *<br>
> * Copyright 2004 Ferenc Wagner<br>
> + * Copyright 2018-2019 Isira Seneviratne<br>
> *<br>
> * This library is free software; you can redistribute it and/or<br>
> * modify it under the terms of the GNU Lesser General Public<br>
> @@ -24,6 +25,7 @@<br>
> #define IDD_ABOUT 101<br>
> #define IDD_TAG 102<br>
> #define IDD_EMAIL 103<br>
> +#define IDD_RES_LIST 105<br>
> <br>
> #define IDC_STATIC -1<br>
> <br>
> diff --git a/programs/winetest/winetest.h b/programs/winetest/winetest.h<br>
> index 0446ad5bdc..342e25b506 100644<br>
> --- a/programs/winetest/winetest.h<br>
> +++ b/programs/winetest/winetest.h<br>
> @@ -3,6 +3,7 @@<br>
> *<br>
> * Copyright 2003 Dimitrie O. Paun<br>
> * Copyright 2003 Ferenc Wagner<br>
> + * Copyright 2018-2019 Isira Seneviratne<br>
> *<br>
> * This library is free software; you can redistribute it and/or<br>
> * modify it under the terms of the GNU Lesser General Public<br>
> @@ -74,4 +75,7 @@ int guiAskTag (void);<br>
> int guiAskEmail (void);<br>
> int report (enum report_type t, ...);<br>
> <br>
> +/* Listview handle */<br>
> +extern HWND res_list_view;<br>
> +<br>
> #endif /* __WINETESTS_H */<br>
> diff --git a/programs/winetest/winetest.rc b/programs/winetest/winetest.rc<br>
> index a3898b6ce0..25d10505c6 100644<br>
> --- a/programs/winetest/winetest.rc<br>
> +++ b/programs/winetest/winetest.rc<br>
> @@ -2,6 +2,7 @@<br>
> * Winetest resources<br>
> *<br>
> * Copyright 2004 Ferenc Wagner<br>
> + * Copyright 2018-2019 Isira Seneviratne<br>
> *<br>
> * This library is free software; you can redistribute it and/or<br>
> * modify it under the terms of the GNU Lesser General Public<br>
> @@ -48,7 +49,7 @@ BEGIN<br>
> PUSHBUTTON "Abort", IDABORT, 85, 45, 40, 14<br>
> END<br>
> <br>
> -IDD_STATUS DIALOG 0, 0, 160, 150<br>
> +IDD_STATUS DIALOG 0, 0, 160, 275<br>
> STYLE WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX<br>
> CAPTION "Wine Test Shell"<br>
> FONT 8, "MS Shell Dlg"<br>
> @@ -59,21 +60,24 @@ BEGIN<br>
> CONTROL "PB1", IDC_PB1, PROGRESS_CLASSA, 0, 5, 40, 150, 10<br>
> LTEXT "Network transfer:", IDC_ST2, 5, 55, 140, 10<br>
> CONTROL "PB2", IDC_PB2, PROGRESS_CLASSA, 0, 5, 65, 150, 10<br>
> - <br>
> +<br>
> LTEXT "Tag:", IDC_STATIC, 5, 89, 100, 10<br>
> - EDITTEXT IDC_TAG, 25, 88, 125, 10,<br>
> + EDITTEXT IDC_TAG, 25, 88, 130, 10,<br>
> ES_READONLY<br>
> LTEXT "Working directory:", IDC_STATIC, 5, 100, 100, 10<br>
> - EDITTEXT IDC_DIR, 71, 99, 79, 10,<br>
> + EDITTEXT IDC_DIR, 71, 99, 84, 10,<br>
> ES_READONLY | ES_AUTOHSCROLL<br>
> LTEXT "Output file:", IDC_STATIC, 5, 111, 100, 10<br>
> - EDITTEXT IDC_OUT, 46, 110, 104, 10,<br>
> + EDITTEXT IDC_OUT, 46, 110, 109, 10,<br>
> ES_READONLY | ES_AUTOHSCROLL<br>
> <br>
> - DEFPUSHBUTTON "About", IDHELP, 20, 123, 30, 14<br>
> - PUSHBUTTON "Edit", IDCANCEL, 65, 123, 30, 14,<br>
> + CONTROL "", IDD_RES_LIST, "SysListView32", WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT,<br>
> + 5, 130, 150, 100<br>
> +<br>
> + DEFPUSHBUTTON "About", IDHELP, 20, 243, 30, 14<br>
> + PUSHBUTTON "Edit", IDCANCEL, 65, 243, 30, 14,<br>
> WS_DISABLED<br>
> - PUSHBUTTON "Stop", IDABORT, 110, 123, 30, 14<br>
> + PUSHBUTTON "Stop", IDABORT, 110, 243, 30, 14<br>
> <br>
> CONTROL "Created", IDC_SB, STATUSCLASSNAMEA, 0, 0,0,0,0<br>
> END<br>
> -- <br>
> 2.20.1<br>
<br>
<br>
</blockquote></div></div>