📄 fileperftest.cpp
字号:
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//------------------------------------------------------------------------------
//
// Copyright (C) 2004-2006, Freescale Semiconductor, Inc. All Rights Reserved.
// THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
// AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//------------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
//
// File Read/Write Performance TUX DLL
//
// Module: FilePerfTest.cpp
// Contains the shell processing function.
//
////////////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <Devload.h>
#include <ceddk.h>
#include "main.h"
#include "globals.h"
#include "csp.h"
//-----------------------------------------------------------------------------
// External Functions
extern void SetParameters(int nSize,TCHAR* pDirectory);
//-----------------------------------------------------------------------------
// External Variables
//-----------------------------------------------------------------------------
// Defines
#define FILEPERF_ZONE_ERROR 1
//-----------------------------------------------------------------------------
// Types
//-----------------------------------------------------------------------------
// Global Variables
static int g_nSize = 4*1024*1024; // default is 4M Bytes
static TCHAR g_szDirectory[MAX_PATH] = _T("\\Temp"); //default folder
//-----------------------------------------------------------------------------
// Local Variables
//-----------------------------------------------------------------------------
// Local Functions
static BOOL InitializeTests(void);
static VOID FinishTests(void);
////////////////////////////////////////////////////////////////////////////////
// DllMain
// Main entry point of the DLL. Called when the DLL is loaded or unloaded.
//
// Parameters:
// hInstance Module instance of the DLL.
// dwReason Reason for the function call.
// lpReserved Reserved for future use.
//
// Return value:
// TRUE if successful, FALSE to indicate an error condition.
BOOL WINAPI DllMain(HANDLE hInstance, ULONG dwReason, LPVOID lpReserved)
{
// Any initialization code goes here.
return TRUE;
}
////////////////////////////////////////////////////////////////////////////////
// Debug
// Printf-like wrapping around OutputDebugString.
//
// Parameters:
// szFormat Formatting string (as in printf).
// ... Additional arguments.
//
// Return value:
// None.
void Debug(LPCTSTR szFormat, ...)
{
static TCHAR szHeader[] = TEXT("FilePerf: ");
TCHAR szBuffer[1024];
va_list pArgs;
va_start(pArgs, szFormat);
lstrcpy(szBuffer, szHeader);
wvsprintf(
szBuffer + countof(szHeader) - 1,
szFormat,
pArgs);
va_end(pArgs);
_tcscat(szBuffer, TEXT("\r\n"));
OutputDebugString(szBuffer);
}
static void Usage(void)
{
g_pKato->Log(LOG_FAIL, TEXT( "Usage: s tux -o -d FilePerfTest tux_parameters -c \"dll_parameters\"" ));
g_pKato->Log(LOG_FAIL, TEXT( "Tux parameters: please refer to: s tux -?" ));
g_pKato->Log(LOG_FAIL, TEXT( "DLL parameters: [# size_parameter] [dir_parameter] [?]" ));
g_pKato->Log(LOG_FAIL, TEXT( "\tsize_parameter\ttest file size, default is 4M bytes"));
g_pKato->Log(LOG_FAIL, TEXT( "\tdir_parameter\tdirectory, should exist, default is \\Temp. If there is a SPACE in directory, you must use <> to include the whole string."));
g_pKato->Log(LOG_FAIL, TEXT( "\t?\tThis help message" ));
g_pKato->Log(LOG_FAIL, TEXT( "Examples:\n" ));
g_pKato->Log(LOG_FAIL, TEXT( "\t s tux -o -d FilePerfTest -c \"\\TEMP #2000000\"\n" ));
g_pKato->Log(LOG_FAIL, TEXT( "\t s tux -o -d FilePerfTest -c \"# 1048576 <\\Hard Disk>\"\n" ));
g_pKato->Log(LOG_FAIL, TEXT( "\t s tux -o -d FilePerfTest -c \"?\"\n" ));
}
//******************************************************************************
BOOL ProcessCommandLine(LPCTSTR szDLLCmdLine)
{
TCHAR* pCmdLine = (TCHAR*)szDLLCmdLine;
TCHAR* pCurrent;
TCHAR tchFlag;
BOOL bRet = TRUE;
int nSize = wcslen(szDLLCmdLine);
for ( ; nSize; )
{
for (pCurrent = pCmdLine; nSize && TCHAR(' ') == *pCurrent; pCurrent++, nSize--)
{
//Debug( TEXT("Parm=\"%s\", size=%d" ), pCurrent, nSize);
}
if (0 == nSize)
break;
tchFlag = *pCurrent;
//Debug( TEXT("CmdLine=\"%s\", size=%d, tchFlag=%c" ), pCmdLine, nSize, tchFlag);
if(TCHAR('?') == tchFlag)
{
Usage();
return FALSE;
}
else if (TCHAR('#') == tchFlag)
{
pCurrent++; nSize--;
g_nSize = _ttoi(pCurrent);
//Debug( TEXT( "got Size %d"),g_nSize);
for ( ; nSize && *pCurrent >= '0' && *pCurrent <= TCHAR('9'); pCurrent++, nSize--)
{
//Debug( TEXT("Parm=\"%s\", size=%d" ), pCurrent, nSize);
}
pCmdLine = pCurrent;
}
else
{ // directory
int nDirSize = 0;
if (TCHAR('<') == tchFlag)
{
pCurrent++; nSize--;
pCmdLine = pCurrent;
for ( ; nSize && TCHAR('>') != *pCurrent; pCurrent++, nSize--, nDirSize++)
{
//Debug( TEXT("Parm=\"%s\", size=%d" ), pCurrent, nSize);
}
if (0 == nSize || TCHAR('>') != *pCurrent)
{
g_pKato->Log(LOG_FAIL, TEXT( "'<' missed\n" ));
return FALSE;
}
//Debug( TEXT( "nSize=%d,nDirSize=%d,pCmdLine:'%s',pCurrent:'%s'"),
//nSize,nDirSize,pCmdLine,pCurrent);
_tcsncpy(g_szDirectory, pCmdLine, nDirSize);
g_szDirectory[nDirSize] = 0;
//Debug( TEXT( "Specified Directory:'%s'"),g_szDirectory);
pCmdLine = pCurrent+1;
nSize--;
}
else
{
pCmdLine = pCurrent;
for ( ; nSize && TCHAR(' ') != *pCurrent; pCurrent++, nSize--, nDirSize++)
{
//Debug( TEXT("finding4=\"%s\", size=%d" ), pCurrent, nSize);
}
//Debug( TEXT( "nSize=%d,nDirSize=%d,pCmdLine:%s!,pCurrent:%s!"),
//nSize,nDirSize,pCmdLine,pCurrent);
_tcsncpy(g_szDirectory, pCmdLine, nDirSize);
g_szDirectory[nDirSize] = 0;
//Debug( TEXT( "Specified Directory:'%s'"),g_szDirectory);
pCmdLine = pCurrent;
if(nSize>0) // SPACE
pCmdLine, nSize--;
}
}
}
return TRUE;
} // szTokenrocessCommandLine
////////////////////////////////////////////////////////////////////////////////
// ShellProc
// Processes messages from the TUX shell.
//
// Parameters:
// uMsg Message code.
// spParam Additional message-dependent data.
//
// Return value:
// Depends on the message.
SHELLPROCAPI ShellProc(UINT uMsg, SPPARAM spParam)
{
LPSPS_BEGIN_TEST pBT;
LPSPS_END_TEST pET;
LPTSTR lpszCmdLine = NULL;
BOOL fRtn = TRUE;
switch (uMsg)
{
case SPM_LOAD_DLL:
// Sent once to the DLL immediately after it is loaded. The spParam
// parameter will contain a pointer to a SPS_LOAD_DLL structure. The
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -