📄 ecostest.h
字号:
LPCTSTR const Output() const { return m_strOutput; } // Output generated by a test run [for report purposes] const CTestResource * const Port() const { return m_pPort; } // Port used for a test run [for report purposes] LPCTSTR const ResultString (bool bIncludeOutput=true) const; /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // Running a test: // Run a test locally: bool RunLocal (); // Run a test remotely: // If pszRemoteHostPort is given, it sends the test for execution on the given host:post. // Otherwise, a suitable host:port is determined from the test resource information. bool RunRemote (LPCTSTR const pszRemoteHostPort); void Cancel (); // Stop the run /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // Resource functions static bool SetLogFile (LPCTSTR pszFile); // Define the log file // Run as a server on given TCP/IP port static bool RunAgent(int nTcpPort); unsigned int RunCount() const { return m_nRunCount; } static bool IsValid (LPCTSTR pszTarget) { return Target(pszTarget).IsValid(); } static int InitTargetInfo(LPCTSTR pszFilename); static bool SaveTargetInfo(LPCTSTR pszFilename); bool InteractiveGdb(const String &strHost,int nPort,TCHAR **argv); void SetTimeouts (Duration dActive,Duration dElapsed); void SetExecutable (LPCTSTR pszExecutable); static bool Value ( LPCTSTR pszStr, struct tm &t, StatusType &status, String &target, String &strExecutionHostPort, String &strExecutableTail, String &strTitle, int &nFileSize, Duration &nTotalTime, Duration &nMaxInactiveTime, Duration &nDownloadTime, Duration &nDownloadTimeout, Duration &nActiveTimeout, int &nDownloadedSize); Time GdbCpuTime();#ifndef _WIN32 int ReadPipe (String &str,bool bBlock=false); // Read from gdb process#endif enum ServerStatus {SERVER_BUSY, SERVER_READY, SERVER_CANT_RUN, CONNECTION_FAILED, SERVER_LOCKED, ServerStatusMax}; static LPCTSTR const Image(ServerStatus s) { return arServerStatusImage[MIN(s,ServerStatusMax)]; } static ServerStatus ServerStatusValue(LPCTSTR psz); static ServerStatus CeCosTest::Connect (String strHost,int port, CeCosTestSocket *&pSock, const ExecutionParameters &e,String &strInfo,Duration dTimeout=10*1000); // Delay for given count of milliseconds // Record test result in log file: void LogResult(); // Connect to m_strExecutionHostPort void ConnectForExecution (); // Log some output. The accumulated output can be retrieved using Output() void Log (LPCTSTR const pszFormat,...); void LogString (LPCTSTR psz); static bool GetSizes(LPCTSTR pszExecutable, LPCTSTR target,unsigned int &nFileSize, unsigned int &nStrippedSize); protected: static String GetGreatestSubkey (LPCTSTR pszKey); bool GetTargetReady(String &strHostPort); unsigned int m_nRunCount; void Interactive(LPCTSTR pszFormat, ...); bool m_bStopConnectSocketToSerial; static String CygPath (LPCTSTR pszPath); CResetAttributes::ResetResult Reset(bool bSendStatus); void LogTimeStampedOutput(LPCTSTR psz);#ifndef _WIN32 bool Suck(LPCTSTR pszPrompt,Duration d=1000);#endif bool AtPrompt(LPCTSTR pszPrompt); bool BreakpointsOperational() const { return TargetInfo::HARDWARE_NO_BP!=Target(Target()).Type(); } void * m_wPipeHandle; void * m_rPipeHandle; // For Unix to limit calls to ps: Time m_tGdbCpuTime; Time m_tPrevSample; unsigned int m_nStrippedSize; void SendKeepAlives(bool &b); void WaitForRemoteCompletion(); Time GdbTime(); String m_strPath; void GetPath(String &strPath); void SetPath(const String &strPath); unsigned int m_nFileSize; // Size of executable String m_strExecutionHostPort; /////////////////////////////////////////////////////////////////////////// // Stuff to manage running gdb as child subprocess bool CheckForTimeout(); // Check for a timeout - set status and return false if it happens bool m_bDownloading; // Are we currently downloading executable? bool GdbProcessAlive (); // Is gdb still alive and kicking? Time m_tBase; // Base used for measurement of timeouts Time m_tBase0; // Base used for measurement of timeouts Time m_tWallClock0; // When the test was actually started void * m_pGdbProcesshandle; // Handle associated with gdb process#ifndef _WIN32 bool WritePipe (const String &str); // Write to gdb process void DriveGdb(LPCTSTR pszPrompt,const StringArray &arstrGdbCmds); // Run gdb#endif /////////////////////////////////////////////////////////////////////////// // Close the socket used by the current class instance void CloseSocket (); bool send(const void * const pData,unsigned int nLength,LPCTSTR const pszMsg=_T(""),Duration dTimeout=10*1000); bool recv(const void *pData,unsigned int nLength,LPCTSTR const pszMsg=_T(""),Duration dTimeout=10*1000); bool sendResult(Duration dTimeout=10*1000); bool recvResult(Duration dTimeout=10*1000); /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// CeCosTestSocket *m_pSock; mutable String m_strResultString; LPCTSTR ExecutableTail() const { return CeCosTestUtils::Tail(m_strExecutable); } ExecutionParameters m_ep; // Chaining to allow *AllInstances functions to work: static CeCosTest * pFirstInstance; CeCosTest * m_pPrevInstance; CeCosTest * m_pNextInstance; void RunGdb (LPCTSTR pszCmdline,LPCTSTR pszPrompt,const StringArray &arstrGdbCmds); bool OutputContains(LPCTSTR psz) const { return 0!=_tcsstr(m_strOutput,psz); } static void CALLBACK SAcceptThreadFunc (void *pParam) {((CeCosTest *)pParam)->AcceptThreadFunc(); } void AcceptThreadFunc(); static void CALLBACK SConnectSocketToSerialThreadFunc(void *pParam) { ((CeCosTest *)pParam)->ConnectSocketToSerialThreadFunc(); } void ConnectSocketToSerialThreadFunc(); // Stuff. // Thread function used by RunLocal to execute a non-blocking test locally void LocalThreadFunc (); // Thread function used by RunRemote to execute a non-blocking test remotely void RemoteThreadFunc (); String m_strExecutable; String m_strTitle; void SetStatus (StatusType status); StatusType m_Status; Duration m_nDownloadTime; Duration m_nTotalTime; Duration m_nMaxInactiveTime; CTestResource * m_pPort; String m_strOutput; static std::vector<TargetInfo> arTargetInfo; static const TargetInfo tDefault; static LPCTSTR const arResultImage[1+StatusTypeMax]; static LPCTSTR const arServerStatusImage[1+ServerStatusMax]; bool m_bConnectSocketToSerialThreadDone; static void CALLBACK ResetLogFunc(void *pParam, LPCTSTR psz);}; // class CeCosTest#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -