kerneltest/e32test/usbho/t_usbdi/inc/testdebug.h
changeset 0 a41df078684a
child 43 c1f20ce4abcf
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 #ifndef __TEST_DEBUG_H
       
     2 #define __TEST_DEBUG_H
       
     3 
       
     4 /*
       
     5 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     6 * All rights reserved.
       
     7 * This component and the accompanying materials are made available
       
     8 * under the terms of the License "Eclipse Public License v1.0"
       
     9 * which accompanies this distribution, and is available
       
    10 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    11 *
       
    12 * Initial Contributors:
       
    13 * Nokia Corporation - initial contribution.
       
    14 *
       
    15 * Contributors:
       
    16 *
       
    17 * Description:
       
    18 * @file testdebug.h
       
    19 * @internalComponent
       
    20 * 
       
    21 *
       
    22 */
       
    23 
       
    24 
       
    25 
       
    26 #include <e32debug.h>
       
    27 #include <d32usbdescriptors.h>
       
    28 #include <d32usbdi.h>
       
    29 #include <f32file.h>
       
    30 
       
    31 /**
       
    32 Debug macro for serial port logging of function names and signatures
       
    33 */
       
    34 #define LOG_CFUNC TFunctionLog funcLog(__PRETTY_FUNCTION__, NULL);
       
    35 #define LOG_FUNC TFunctionLog funcLog(__PRETTY_FUNCTION__,this);
       
    36 
       
    37 #define LOG_POINT(x) RDebug::Printf(">> Debug point: " #x);
       
    38 
       
    39 //#define LOG_INFO(x) RDebug::Print x;
       
    40 
       
    41 #define LOG_INFO(x) 
       
    42 
       
    43 
       
    44 /**
       
    45 Debug function to print out (log) the data for the descriptor
       
    46 @param aDescriptor the host-side view of the descriptor
       
    47 */
       
    48 inline void PrintDescriptorBlob(TUsbGenericDescriptor& aDescriptor);
       
    49 
       
    50 /**
       
    51 */
       
    52 class TFunctionLog
       
    53 	{
       
    54 public:
       
    55 	/**
       
    56 	Constructor
       
    57 	*/
       
    58 	TFunctionLog(const char* aFunctionName,void* aThisPointer)
       
    59 	:	iFunctionName(aFunctionName),
       
    60 		iThisPointer(aThisPointer)
       
    61 		{
       
    62 		RDebug::Printf("\nIN  [%08x]    %s",iThisPointer,iFunctionName);
       
    63 		}
       
    64 
       
    65 	/**
       
    66 	Destructor
       
    67 	*/
       
    68 	~TFunctionLog()
       
    69 		{
       
    70 		RDebug::Printf("OUT [%08x]    %s\n",iThisPointer,iFunctionName);
       
    71 		}
       
    72 
       
    73 private:
       
    74 	const char* iFunctionName;
       
    75 	void* iThisPointer;
       
    76 	};
       
    77 
       
    78 /**
       
    79 This class describes a logger for test case actions
       
    80 Pattern: Singleton
       
    81 */
       
    82 class RLog
       
    83 	{
       
    84 public:
       
    85 	/**
       
    86 	*/
       
    87 	static TInt Print(const TDesC8& aLogAction)
       
    88 		{
       
    89 		return Instance().iLogFile.Write(aLogAction);
       
    90 		}
       
    91 	
       
    92 private:
       
    93 	/**
       
    94 	Get the singleton instance
       
    95 	*/
       
    96 	static RLog& Instance()
       
    97 		{
       
    98 		static RLog singleton;
       
    99 		return singleton;
       
   100 		}
       
   101 	
       
   102 	/**
       
   103 	Constructor
       
   104 	*/
       
   105 	RLog()
       
   106 		{
       
   107 		TInt err(iFileServer.Connect());
       
   108 		if(err != KErrNone)
       
   109 			{
       
   110 			User::Panic(_L("RTEST 84"),err);
       
   111 			}
       
   112 		err = iLogFile.Replace(iFileServer,_L("usbdi_testlog.txt"),EFileWrite);
       
   113 		if(err != KErrNone)
       
   114 			{
       
   115 			
       
   116 			}
       
   117 		else
       
   118 			{
       
   119 			
       
   120 			}
       
   121 		}
       
   122 	
       
   123 	/**
       
   124 	Destructor
       
   125 	*/
       
   126 	~RLog()
       
   127 		{
       
   128 		iLogFile.Close();
       
   129 		iFileServer.Close();
       
   130 		}
       
   131 	
       
   132 private:
       
   133 	/**
       
   134 	The session with the file server
       
   135 	*/
       
   136 	RFs iFileServer;
       
   137 
       
   138 	/**
       
   139 	*/
       
   140 	RFile iLogFile;
       
   141 	
       
   142 	};
       
   143 	
       
   144 	
       
   145 // Implementation
       
   146 void PrintDescriptorBlob(TUsbGenericDescriptor& aDescriptor)
       
   147 	{
       
   148 	for(int i=0; i<aDescriptor.iBlob.Length(); i++)
       
   149 		{
       
   150 		RDebug::Printf("<Type %d><Blob 0x%02x>",aDescriptor.ibDescriptorType,aDescriptor.iBlob[i]);
       
   151 		}
       
   152 	}
       
   153 
       
   154 
       
   155 #endif
       
   156