📄 ecostest.h
字号:
//####COPYRIGHTBEGIN####// // ----------------------------------------------------------------------------// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.//// This program is part of the eCos host tools.//// This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the Free // Software Foundation; either version 2 of the License, or (at your option) // any later version.// // This program is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for // more details.// // You should have received a copy of the GNU General Public License along with// this program; if not, write to the Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.//// ----------------------------------------------------------------------------// //####COPYRIGHTEND####//=================================================================//// eCosTest.h//// run test header////=================================================================//=================================================================//#####DESCRIPTIONBEGIN####//// Author(s): sdf// Contributors: sdf// Date: 1999-04-01// Description: Run one or more tests// Usage:////####DESCRIPTIONEND#####ifndef _ECOSTEST_H#define _ECOSTEST_H// eCos testing infrastructure// This class represents a single eCos test [executable].// It includes member functions to run the test and to manage// related system resources.#include "eCosStd.h"#include "eCosTestUtils.h"#include "eCosThreadUtils.h"#include "Properties.h"#include "ResetAttributes.h"#include <vector>class CTestResource;class CeCosTestSocket;class CeCosTest{public: static bool Init(); static void Term(); static bool SaveTargetInfo(); class TargetInfo { public: // Update arHwTypeImage if you add to this enum enum HwType {INVALID=-1, HARDWARE=0, SIM=1, SYNTHETIC=2, HARDWARE_NO_BP=3, REMOTE_SIM=4 }; protected: String pszImage; String pszPrefix; HwType nType; String pszGdbcmd; public: static LPCTSTR arHwTypeImage[]; static HwType FromStr (LPCTSTR psz); bool IsValid() const { return nType!=INVALID; } LPCTSTR Image() const { return pszImage.c_str(); } LPCTSTR Prefix() const { return pszPrefix.c_str(); } LPCTSTR GdbCmd() const { return pszGdbcmd.c_str(); } HwType Type() const { return nType; } TargetInfo(); TargetInfo(LPCTSTR pszIm,LPCTSTR pszPre,LPCTSTR pszHwtype,LPCTSTR pszGdb=0); TargetInfo(LPCTSTR pszIm,LPCTSTR pszPre,int nHwtype,LPCTSTR pszGdb=0); // FIXME: phase this out as soon as we can }; static int AddPlatform (const TargetInfo &t); static int InitTargetInfoReg (LPCTSTR szRegKey); static bool SaveTargetInfoReg (LPCTSTR szRegKey); static LPCTSTR pszFormat; /////////////////////////////////////////////////////////////////////////// // Representation of an elapsed time (units of milliseconds) enum {NOTIMEOUT=0}; // No timeout specified /////////////////////////////////////////////////////////////////////////// // ctors, dtors and their friends class ExecutionParameters; CeCosTest(const ExecutionParameters &e, LPCTSTR const pszExecutable, LPCTSTR const pszTitle=0); virtual ~CeCosTest(); // Count of number of instances of this class: static int InstanceCount; // Delete all heap instances of this class (*must* be allocated on heap) static void DeleteAllInstances (); // Simply wait for instances to die a natural death static bool WaitForAllInstances (int nPoll=1000,Duration nTimeout=NOTIMEOUT); // Tap them on the shoulder (does not wait) static void CancelAllInstances (); /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // Representation of target: static unsigned int TargetTypeMax() { return (unsigned)arTargetInfo.size(); } static LPCTSTR const Image(unsigned int i) { return arTargetInfo[i].Image(); } static const TargetInfo &Target(unsigned int i) { return arTargetInfo[i]; } static const TargetInfo &Target(LPCTSTR t); static void RemoveAllPlatforms(); /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // Class used to represent execution parameters (to be passed with request to execute a test) /////////////////////////////////////////////////////////////////////////// class ExecutionParameters { public: enum RequestType { RUN, QUERY, LOCK, UNLOCK, STOP, RequestTypeMax}; static RequestType RequestTypeValue(LPCTSTR ); static LPCTSTR Image (RequestType r) { return arRequestImage[r]; } Duration ActiveTimeout() const { return m_nActiveTimeout; } Duration DownloadTimeout() const { return m_nDownloadTimeout; } LPCTSTR Target() const { return m_Target.c_str(); } bool IsValid() const { return m_Request!=RUN || CeCosTest::IsValid(m_Target); } RequestType Request() const { return m_Request;} void SetActiveTimeout (Duration t){m_nActiveTimeout=t;} void SetDownloadTimeout (Duration t){m_nDownloadTimeout=t;} ExecutionParameters ( RequestType r=CeCosTest::ExecutionParameters::RUN, LPCTSTR Target=_T(""), Duration nActiveTimeout=NOTIMEOUT, Duration nDownloadTimeout=NOTIMEOUT); bool FromStr(LPCTSTR psz); String Image() const; virtual ~ExecutionParameters(){} bool m_bUseFilter; protected: static LPCTSTR arRequestImage [1+RequestTypeMax]; String m_Target; Duration m_nActiveTimeout,m_nDownloadTimeout; RequestType m_Request; int m_nUnused1; int m_nUnused2; int m_nUnused3; bool m_bUnused2; bool m_bUnused3; }; /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // Result status stuff. // Order is important - SetStatus can only change status in left-to-right direction void AnalyzeOutput(); enum StatusType {NotStarted, NoResult, Inapplicable, Pass, DownloadTimeOut, TimeOut, Cancelled, Fail, AssertFail, StatusTypeMax}; static StatusType StatusTypeValue (LPCTSTR const pszStr); static LPCTSTR const Image(StatusType s) { return arResultImage[MIN(s,StatusTypeMax)]; } /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // Attributes LPCTSTR const Executable() const { return m_strExecutable;} // Executable name const LPCTSTR Target() const { return m_ep.Target();} // Target static bool IsSim(LPCTSTR t) { return TargetInfo::SIM==Target(t).Type() || TargetInfo::REMOTE_SIM==Target(t).Type() || TargetInfo::SYNTHETIC==Target(t).Type(); } static bool ServerSideGdb(LPCTSTR t) { return TargetInfo::SIM==Target(t).Type() || TargetInfo::SYNTHETIC==Target(t).Type(); } bool ServerSideGdb() const { return TargetInfo::SIM==Target(Target()).Type() || TargetInfo::SYNTHETIC==Target(Target()).Type(); } LPCTSTR const Title() const; // Title Duration ActiveTimeout() const { return m_ep.ActiveTimeout(); } // Active timeout Duration DownloadTimeout() const { return m_ep.DownloadTimeout(); } // Total timeout StatusType Status() const { return m_Status; } // Test status Duration Download() const { return m_nDownloadTime; } // Download time Duration Total() const { return m_nTotalTime; } // Total Duration MaxInactive() const { return m_nMaxInactiveTime; } // Max. inactive
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -