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