sl@0: #ifndef __TEST_DEBUG_H sl@0: #define __TEST_DEBUG_H sl@0: sl@0: /* sl@0: * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * @file testdebug.h sl@0: * @internalComponent sl@0: * sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: Debug macro for serial port logging of function names and signatures sl@0: */ sl@0: #define LOG_CFUNC TFunctionLog funcLog(__PRETTY_FUNCTION__, NULL); sl@0: #define LOG_FUNC TFunctionLog funcLog(__PRETTY_FUNCTION__,this); sl@0: sl@0: #define LOG_POINT(x) RDebug::Printf(">> Debug point: " #x); sl@0: sl@0: //#define LOG_INFO(x) RDebug::Print x; sl@0: sl@0: #define LOG_INFO(x) sl@0: sl@0: sl@0: /** sl@0: Debug function to print out (log) the data for the descriptor sl@0: @param aDescriptor the host-side view of the descriptor sl@0: */ sl@0: inline void PrintDescriptorBlob(TUsbGenericDescriptor& aDescriptor); sl@0: sl@0: /** sl@0: */ sl@0: class TFunctionLog sl@0: { sl@0: public: sl@0: /** sl@0: Constructor sl@0: */ sl@0: TFunctionLog(const char* aFunctionName,void* aThisPointer) sl@0: : iFunctionName(aFunctionName), sl@0: iThisPointer(aThisPointer) sl@0: { sl@0: RDebug::Printf("\nIN [%08x] %s",iThisPointer,iFunctionName); sl@0: } sl@0: sl@0: /** sl@0: Destructor sl@0: */ sl@0: ~TFunctionLog() sl@0: { sl@0: RDebug::Printf("OUT [%08x] %s\n",iThisPointer,iFunctionName); sl@0: } sl@0: sl@0: private: sl@0: const char* iFunctionName; sl@0: void* iThisPointer; sl@0: }; sl@0: sl@0: /** sl@0: This class describes a logger for test case actions sl@0: Pattern: Singleton sl@0: */ sl@0: class RLog sl@0: { sl@0: public: sl@0: /** sl@0: */ sl@0: static TInt Print(const TDesC8& aLogAction) sl@0: { sl@0: return Instance().iLogFile.Write(aLogAction); sl@0: } sl@0: sl@0: private: sl@0: /** sl@0: Get the singleton instance sl@0: */ sl@0: static RLog& Instance() sl@0: { sl@0: static RLog singleton; sl@0: return singleton; sl@0: } sl@0: sl@0: /** sl@0: Constructor sl@0: */ sl@0: RLog() sl@0: { sl@0: TInt err(iFileServer.Connect()); sl@0: if(err != KErrNone) sl@0: { sl@0: User::Panic(_L("RTEST 84"),err); sl@0: } sl@0: err = iLogFile.Replace(iFileServer,_L("usbdi_testlog.txt"),EFileWrite); sl@0: if(err != KErrNone) sl@0: { sl@0: sl@0: } sl@0: else sl@0: { sl@0: sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Destructor sl@0: */ sl@0: ~RLog() sl@0: { sl@0: iLogFile.Close(); sl@0: iFileServer.Close(); sl@0: } sl@0: sl@0: private: sl@0: /** sl@0: The session with the file server sl@0: */ sl@0: RFs iFileServer; sl@0: sl@0: /** sl@0: */ sl@0: RFile iLogFile; sl@0: sl@0: }; sl@0: sl@0: sl@0: // Implementation sl@0: void PrintDescriptorBlob(TUsbGenericDescriptor& aDescriptor) sl@0: { sl@0: for(int i=0; i",aDescriptor.ibDescriptorType,aDescriptor.iBlob[i]); sl@0: } sl@0: } sl@0: sl@0: sl@0: #endif sl@0: