From patchwork Fri Jul 9 00:35:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 110971 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o690ZpUU028239 for ; Fri, 9 Jul 2010 00:35:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757027Ab0GIAfs (ORCPT ); Thu, 8 Jul 2010 20:35:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61544 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756888Ab0GIAfr (ORCPT ); Thu, 8 Jul 2010 20:35:47 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o690Zj2i008210 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 8 Jul 2010 20:35:46 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o690ZjJO017795; Thu, 8 Jul 2010 20:35:45 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o690Zdrd002117; Thu, 8 Jul 2010 20:35:44 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 2/2] KVM test: rss.cpp: write all user messages to a log file Date: Fri, 9 Jul 2010 03:35:36 +0300 Message-Id: <1278635736-14852-2-git-send-email-mgoldish@redhat.com> In-Reply-To: <1278635736-14852-1-git-send-email-mgoldish@redhat.com> References: <1278635736-14852-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 09 Jul 2010 00:35:51 +0000 (UTC) The log file will be placed in the current directory. For example, when rss.exe is run at startup as administrator under WinXP, the current directory will be C:\Documents and Settings\Administrator. Signed-off-by: Michael Goldish --- client/tests/kvm/deps/rss.cpp | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/client/tests/kvm/deps/rss.cpp b/client/tests/kvm/deps/rss.cpp index 5b30b48..d48bbba 100644 --- a/client/tests/kvm/deps/rss.cpp +++ b/client/tests/kvm/deps/rss.cpp @@ -107,6 +107,8 @@ int text_size = 0; CRITICAL_SECTION critical_section; +FILE *log_file; + struct client_info { SOCKET socket; char addr_str[256]; @@ -157,16 +159,22 @@ void ExitOnError(const char *message, BOOL winsock = FALSE) void FlushTextBuffer() { if (!text_size) return; + // Clear the text box if it contains too much text int len = GetWindowTextLength(hTextBox); while (len > TEXTBOX_LIMIT - sizeof(text_buffer)) { SendMessage(hTextBox, EM_SETSEL, 0, TEXTBOX_LIMIT * 1/4); SendMessage(hTextBox, EM_REPLACESEL, FALSE, (LPARAM)"..."); len = GetWindowTextLength(hTextBox); } + // Append the contents of text_buffer to the text box SendMessage(hTextBox, EM_SETSEL, len, len); SendMessage(hTextBox, EM_REPLACESEL, FALSE, (LPARAM)text_buffer); + // Clear text_buffer text_buffer[0] = 0; text_size = 0; + // Make sure the log file's buffer is flushed as well + if (log_file) + fflush(log_file); } void AppendMessage(const char *message, ...) @@ -181,8 +189,13 @@ void AppendMessage(const char *message, ...) int len = strlen(str); EnterCriticalSection(&critical_section); + // Write message to the log file + if (log_file) + fwrite(str, len, 1, log_file); + // Flush the text buffer if necessary if (text_size + len + 1 > sizeof(text_buffer)) FlushTextBuffer(); + // Append message to the text buffer strcpy(text_buffer + text_size, str); text_size += len; LeaveCriticalSection(&critical_section); @@ -881,6 +894,8 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { RECT rect; WSADATA wsaData; + SYSTEMTIME lt; + char log_filename[256]; switch (msg) { case WM_CREATE: @@ -907,6 +922,12 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) SendMessage(hTextBox, EM_LIMITTEXT, TEXTBOX_LIMIT, 0); // Initialize critical section object for text buffer access InitializeCriticalSection(&critical_section); + // Open log file + GetLocalTime(<); + sprintf(log_filename, "rss_%02d-%02d-%02d_%02d-%02d-%02d.log", + lt.wYear, lt.wMonth, lt.wDay, + lt.wHour, lt.wMinute, lt.wSecond); + log_file = fopen(log_filename, "wb"); // Create text box update thread if (!CreateThread(NULL, 0, UpdateTextBox, NULL, 0, NULL)) ExitOnError("Could not create text box update thread");