⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ecostest.h

📁 ecos为实时嵌入式操作系统
💻 H
📖 第 1 页 / 共 2 页
字号:
#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 "stdafx.h"#include "eCosTestUtils.h"#include "eCosTestSocket.h"class CPort;#ifdef _WIN32    #define CALLBACK    __stdcall               // Calling conventions for a callback    #define THREAD_ID void *                    // Type of a thread_id    #define THREADFUNC unsigned long __stdcall  // Result type of the thread function    #define WOULDBLOCK WSAEWOULDBLOCK           // "Would blocking" error#else    #include <pthread.h>    #define THREAD_ID pthread_t    #define THREADFUNC void *    #define WOULDBLOCK EWOULDBLOCK    #define CALLBACK#endif#ifndef min    #define min(a,b) (a<b?a:b)#endifclass CeCosTest{public:    ///////////////////////////////////////////////////////////////////////////    // 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, const char * const pszExecutable, const char * 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,CeCosTestUtils::Duration nTimeout=NOTIMEOUT);    // Tap them on the shoulder (does not wait)    static void CancelAllInstances ();    ///////////////////////////////////////////////////////////////////////////    ///////////////////////////////////////////////////////////////////////////    // Representation of target:    enum TargetType {        TX39_jmr3904,        TX39_minsim,        TX39_jmr3904_sim,        PowerPC_cogent,        PowerPC_sim,        SPARClite_sim,        SPARClite_sleb,        ARM_PID,        ARM_AEB,        MN10300_stdeval1,        MN10300_minsim,        MN10300_stdeval1_sim,        I386_Linux,        TargetTypeMax };	static const char * const Image(TargetType t) { return arTargetInfo[min(t,TargetTypeMax)].pszImage; }    // Translate a string to a target type (returns null if no luck)    static TargetType TargetTypeValue (const char * const pszStr);	static TargetType FromStr (const char * const pszStr) { return TargetTypeValue(pszStr); }    ///////////////////////////////////////////////////////////////////////////    ///////////////////////////////////////////////////////////////////////////    // Class used to represent execution parameters (to be passed with request to execute a test)    // This needs to be serializable (capabable of being [un]marshalled for socket communication)    // and so we are careful to use an int[] internally to hold the data.    class ExecutionParameters {        enum { SERIALIZE_LENGTH=5*sizeof(int) };    public:		enum RequestType { RUN, QUERY, LOCK, UNLOCK, STOP, RequestTypeMax};        static const char * Image (RequestType r) { return arRequestImage[r]; }        typedef int Data[SERIALIZE_LENGTH/sizeof(int)];        ExecutionParameters (const Data buf) { memcpy(m_arE,buf,SERIALIZE_LENGTH); }        const Data * const Marshall() const { return &m_arE;}        CeCosTestUtils::Duration    ActiveTimeout() const { return (CeCosTestUtils::Duration)m_arE[0]; }        CeCosTestUtils::Duration    ElapsedTimeout() const { return (CeCosTestUtils::Duration)m_arE[1]; }        TargetType  Target() const { return (TargetType)m_arE[3]; }        bool        IsValid() const { return (unsigned)Target()<(unsigned)TargetTypeMax; }        RequestType Request() const { return (RequestType)m_arE[4];}        //  nTimeout       : timeout in milliseconds        //  bSim           : whether execution is to be on a simulator        void SetActiveTimeout  (CeCosTestUtils::Duration t){m_arE[0]=t;}        void SetElapsedTimeout (CeCosTestUtils::Duration t){m_arE[1]=t;}		void SetRequest        (RequestType r){m_arE[4]=r;}        ExecutionParameters (            TargetType  Target,            CeCosTestUtils::Duration    nActiveTimeout=NOTIMEOUT,            CeCosTestUtils::Duration    nElapsedTimeout=NOTIMEOUT)        {            m_arE[0]=(int)nActiveTimeout;            m_arE[1]=(int)nElapsedTimeout;            m_arE[2]=0; // unused            m_arE[3]=(int)Target;			m_arE[4]=RUN;        }        virtual ~ExecutionParameters()        {}    protected:	    static const char * arRequestImage [1+RequestTypeMax];	    //static const char * arExecutableTypeImage [1+ExecutableTypeMax];        Data m_arE;    };    ///////////////////////////////////////////////////////////////////////////        ///////////////////////////////////////////////////////////////////////////    // Result status stuff.    // Order is important - SetStatus can only change status in left-to-right direction    enum StatusType {NotStarted, NoResult, Inapplicable, Pass, DownloadTimeOut, TimeOut, Cancelled, Fail, StatusTypeMax};    static StatusType StatusTypeValue (const char * const pszStr);	static const char * const Image(StatusType s) { return arResultImage[min(s,StatusTypeMax)]; }    ///////////////////////////////////////////////////////////////////////////    ///////////////////////////////////////////////////////////////////////////    // Attributes    const char * const  Executable()                const { return m_strExecutable;}            // Executable name    const               TargetType Target()         const { return m_ep.Target();}              // Target    static bool         Sim(TargetType t)                 { return arTargetInfo[t].bSim; }    bool                Sim()                       const { return Sim(Target()); }    const char * const  Title()                     const;                                      // Title        CeCosTestUtils::Duration            ActiveTimeout()             const { return m_ep.ActiveTimeout(); }      // Active timeout    CeCosTestUtils::Duration            ElapsedTimeout()            const { return m_ep.ElapsedTimeout(); }     // Total timeout    StatusType          Status()                    const { return m_Status; }                  // Test status        CeCosTestUtils::Duration            Download()                  const { return m_nDownloadTime; }           // Download time    CeCosTestUtils::Duration            Total()                     const { return m_nTotalTime; }              // Total    CeCosTestUtils::Duration            MaxInactive()               const { return m_nMaxInactiveTime; }        // Max. inactive        const char * const  Output()                    const { return m_strOutput; }               // Output generated by a test run [for report purposes]    const CPort * const Port()                      const { return m_pPort; }                   // Port used for a test run [for report purposes]     const char * const  ResultString ()             const;    ///////////////////////////////////////////////////////////////////////////    ///////////////////////////////////////////////////////////////////////////    // Define the characteristics of a callback procedure:    // A callback procedure.  The result from the procedure determines whether the    // caller (the thread executing the test) should delete the class instance.  If    // true is returned, this will happen and the class object must therefore be allocated    // on the heap.    typedef void (CALLBACK CallbackProc)(CeCosTest*,void *);    // Struct to define a callback    struct Callback {        CallbackProc *m_pProc;  // Call this function        void *        m_pParam; // With this parameter        void Call();        Callback (CallbackProc *pProc=0,void *pParam=0):            m_pProc(pProc),            m_pParam(pParam)        {        }        bool IsNull() { return 0==m_pProc && 0==m_pParam; }    };    static const Callback NoCallback;    void InvokeCallback (const Callback &cb);    ///////////////////////////////////////////////////////////////////////////    // Running a test:    // If pCallback is non-null, behavior will be non-blocking with notification    // via the callback procedure - otherwise behavior is blocking.    // On completion of the test the results are logged.        // The result of the function represents the ability to find a host on which to    // run the test, not the result of the test.        // Run a test locally:    bool RunLocal (const Callback &cb=NoCallback);    // 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 (const char * const pszRemoteHostPort,const Callback &cb=NoCallback);    void Cancel (); // Stop the run    ///////////////////////////////////////////////////////////////////////////        ///////////////////////////////////////////////////////////////////////////    // Resource functions    static void SetLogFile (const char * const pszFile);   // Define the log file        // Run as a server on given TCP/IP port    static bool RunAgent(int nTcpPort); 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -