This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

eCosTest patch


This patch accommodates UNC paths to eCos tests and empty command
prefixes. Checked-in.

John Dallaway
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/ecostest/ChangeLog,v
retrieving revision 1.19
diff -u -5 -r1.19 ChangeLog
--- ChangeLog	13 Aug 2008 09:37:07 -0000	1.19
+++ ChangeLog	9 Feb 2009 10:58:23 -0000
@@ -1,5 +1,12 @@
+2009-02-09  John Dallaway  <john@dallaway.org.uk>
+
+	* common/eCosTest.cpp (CygPath): Accommodate UNC file paths.
+
+	* common/eCosTest.cpp (GetSizes): Accommodate an empty command prefix
+	string.
+
 2007-10-25  Gary Thomas  <gary@mlbassoc.com>
 
 	* common/eCosTest.h: Remove class qualifier - no longer legal
 	in GCC-4.x
 
Index: common/eCosTest.cpp
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/ecostest/common/eCosTest.cpp,v
retrieving revision 1.8
diff -u -5 -r1.8 eCosTest.cpp
--- common/eCosTest.cpp	29 Jan 2009 17:47:50 -0000	1.8
+++ common/eCosTest.cpp	9 Feb 2009 10:58:24 -0000
@@ -1,9 +1,9 @@
 // ####ECOSHOSTGPLCOPYRIGHTBEGIN####                                        
 // -------------------------------------------                              
 // This file is part of the eCos host tools.                                
-// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.            
+// Copyright (C) 1998, 1999, 2000, 2009 Free Software Foundation, Inc.            
 //
 // This program is free software; you can redistribute it and/or modify     
 // it under the terms of the GNU General Public License as published by     
 // the Free Software Foundation; either version 2 or (at your option) any   
 // later version.                                                           
@@ -28,11 +28,11 @@
 //=================================================================
 //=================================================================
 //#####DESCRIPTIONBEGIN####
 //
 // Author(s):     sdf
-// Contributors:  sdf
+// Contributors:  sdf, jld
 // Date:          1999-04-01
 // Description:   This class abstracts a test for use in the testing infrastructure
 // Usage:
 //
 //####DESCRIPTIONEND####
@@ -48,10 +48,14 @@
 #include "eCosTestSerialFilter.h"
 #include "eCosTestDownloadFilter.h"
 #include "Properties.h"
 #include "Subprocess.h"
 
+#ifdef __CYGWIN__
+#include <sys/cygwin.h> /* for cygwin_conv_to_posix_path() */
+#endif
+
 #define WF(n) (n+50)/1000,((n+50)%1000)/100     // Present n as whole and fractional part.  Round to nearest least significant digit
 #define WFS   _T("%u.%u")                           // The format string to output the above
 
 LPCTSTR  const CeCosTest::arResultImage[1+CeCosTest::StatusTypeMax]=
 {_T("NotStarted"), _T("NoResult"), _T("Inapplicable"), _T("Pass"), _T("DTimeout"), _T("Timeout"), _T("Cancelled"), _T("Fail"), _T("AssertFail"), _T("Unknown")};
@@ -1103,11 +1107,23 @@
 }
 
 // Convert a path to something a cygwin tool will understand.  Used when invoking -size and -gdb
 String CeCosTest::CygPath (LPCTSTR pszPath)
 {
-#ifdef _WIN32
+#ifdef __CYGWIN__
+    char buffer[MAX_PATH + 1];
+    long len = ::GetShortPathName (pszPath, NULL, 0);
+    if (len > 0) {
+        char shortpath [len + 1];
+        ::GetShortPathName (pszPath, shortpath, len + 1);
+        cygwin_conv_to_posix_path (shortpath, buffer);
+    } else {
+        cygwin_conv_to_posix_path (pszPath, buffer);
+    }
+    return buffer;
+#elif defined(_WIN32)
+#warning "native Win32 build does not support UNC file paths"
   String str = "";
   HKEY hKey = 0;
   DWORD type;
   BYTE value[256];
   DWORD sz = sizeof(value);
@@ -1172,19 +1188,18 @@
 bool CeCosTest::GetSizes()
 {
 TRACE(_T("GetSizes %s\n"),(LPCTSTR)Executable());
   bool rc=false;
   m_nStrippedSize=m_nFileSize=0;
-  LPCTSTR pszPrefix=m_ep.Platform()->Prefix();
+  String strPrefix(m_ep.Platform()->Prefix());
+  if (strPrefix.length() > 0) strPrefix += _T("-");
   struct _stat buf;
   if(-1==_tstat(Executable(),&buf)){
     Log(_T("%s does not exist\n"),(LPCTSTR)Executable());
-  } else if (_TCHAR('\0')==*pszPrefix){
-    LogString(_T("No prefix to run a size program\n"));
   } else {
     m_nFileSize=buf.st_size;
-    const String strSizeCmd(String::SFormat(_T("%s-size %s"),pszPrefix,(LPCTSTR)CygPath(Executable())));
+    const String strSizeCmd(String::SFormat(_T("%ssize %s"),(LPCTSTR)strPrefix,(LPCTSTR)CygPath(Executable())));
     String strOut;
     CSubprocess sp;
     if(!sp.Run(strOut,strSizeCmd)){
       Log(_T("Failed to run \"%s\" - %s\n"),(LPCTSTR)strSizeCmd,(LPCTSTR)sp.ErrorString());
     } else {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]