OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [ecostest/] [common/] [TestResource.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####                                        
2
// -------------------------------------------                              
3
// This file is part of the eCos host tools.                                
4
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.            
5
//
6
// This program is free software; you can redistribute it and/or modify     
7
// it under the terms of the GNU General Public License as published by     
8
// the Free Software Foundation; either version 2 or (at your option) any   
9
// later version.                                                           
10
//
11
// This program is distributed in the hope that it will be useful, but      
12
// WITHOUT ANY WARRANTY; without even the implied warranty of               
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        
14
// General Public License for more details.                                 
15
//
16
// You should have received a copy of the GNU General Public License        
17
// along with this program; if not, write to the                            
18
// Free Software Foundation, Inc., 51 Franklin Street,                      
19
// Fifth Floor, Boston, MA  02110-1301, USA.                                
20
// -------------------------------------------                              
21
// ####ECOSHOSTGPLCOPYRIGHTEND####                                          
22
//=================================================================
23
//
24
//        TestResource.h
25
//
26
//        Test resource class
27
//
28
//=================================================================
29
//=================================================================
30
//#####DESCRIPTIONBEGIN####
31
//
32
// Author(s):     sdf
33
// Contributors:  sdf
34
// Date:          1999-04-01
35
// Description:   This class abstracts test resources for use in the testing infrastructure
36
// Usage:
37
//
38
//####DESCRIPTIONEND####
39
 
40
#ifndef _TESTRESOURCE_H
41
#define _TESTRESOURCE_H
42
 
43
#include "Collections.h"
44
#include "eCosStd.h"
45
#include "eCosTest.h"
46
#include "eCosSerial.h"
47
#include "Properties.h"
48
#include "ResetAttributes.h"
49
 
50
// This class is used to manipulate test resources.  A test resource is the means to execute
51
// a test (usually an eCosTestServer running on a tcp/ip port)
52
class CTestResource {
53
public:
54
 
55
  // ctors/dtors
56
  CTestResource(
57
    LPCTSTR pszHostPort,  // Where the resource "lives" - i.e. the host and TCP/IP port for the server
58
    LPCTSTR target,
59
    // Physical port characteristics.  If pszPort is null, simulator run is meant (in which case nBaud is ignored)
60
    LPCTSTR pszPort=0, int nBaud=0,
61
    // Associated reset characteristics: pszPort may be a remote server (host:port) or a local port
62
    LPCTSTR pszResetString=_T("")
63
    );
64
  // Not chained or fully initialized
65
  CTestResource():m_nBaud(0),m_bLocked(false),m_pNextInstance(0),m_pPrevInstance(0){}
66
  virtual ~CTestResource();
67
 
68
  bool Use(); // Mark this resource as "in use"
69
 
70
  // This causes the reset to be performed (via rsh, on the machine
71
  CResetAttributes::ResetResult RemoteReset(LogFunc *pfnLog, void *pfnLogparam=0);
72
  const String Image() const;
73
 
74
  // Receive details from the socket
75
  static bool Load(Duration dTimeout=10*1000) { return LoadSocket(strResourceHostPort,dTimeout); }
76
  static bool Save(Duration dTimeout=10*1000) { return SaveSocket(strResourceHostPort,dTimeout); }
77
 
78
  CeCosTest::ServerStatus Query();
79
 
80
  // [Resource] locking:
81
  bool Unlock();
82
  bool Lock ();
83
  bool IsLocked() const { return m_bLocked; }
84
 
85
  static CTestResource *First() { return pFirstInstance; }
86
  CTestResource *Next() const { return m_pNextInstance; }
87
  static CTestResource * Lookup(LPCTSTR  pszHostPort);
88
  static unsigned int ResourceCount() { return nCount; }
89
  static void DeleteAllInstances();
90
  static bool LoadFromDirectory (LPCTSTR psz); // Load information from a set of files in given directory
91
  static bool SaveToDirectory   (LPCTSTR psz); // Save information, likewise
92
 
93
#ifdef _WIN32
94
  static bool SaveToRegistry(HKEY key,LPCTSTR pszKey);  // Save information to the registry
95
  static bool LoadFromRegistry(HKEY key,LPCTSTR pszKey);// Load information from the registry
96
#endif
97
 
98
  void SetInfo (LPCTSTR pszInfo) { m_strInfo=pszInfo; }
99
  LPCTSTR  Info() const { return m_strInfo; }
100
 
101
  // Host and TCP/IP port:
102
  String HostPort() const { return CeCosSocket::HostPort(m_strHost,m_nPort); }
103
  // Same information, but separately:
104
  String Host() const { return m_strHost; }
105
  int TcpIPPort() const { return m_nPort; }
106
 
107
  // Serial (comms) port:
108
  LPCTSTR Serial() const { return m_strPort; }
109
 
110
  LPCTSTR Target() const { return m_Target; }
111
 
112
  // Is there an associated reset string?
113
  bool HasReset() const { return !m_strReset.empty(); }
114
 
115
  // Baud rate:
116
  int Baud() const { return m_nBaud; }
117
 
118
  void SetHostPort(LPCTSTR pszHostPort) { CeCosSocket::ParseHostPort(pszHostPort,m_strHost,m_nPort); }
119
 
120
  void SetTarget        (LPCTSTR target) { m_Target=target; }
121
  void SetDownload(LPCTSTR pszDownloadPort,int nBaud) { m_strPort=pszDownloadPort; m_nBaud=nBaud; }
122
  void SetReset  (LPCTSTR pszReset) { m_strReset=pszReset; }
123
  void SetUser   (LPCTSTR pszUser,LPCTSTR pszEmail) {m_strUser=pszUser; m_strEmail=pszEmail; }
124
  void SetReason (LPCTSTR pszReason) {m_strReason=pszReason; }
125
  void SetBoardID(LPCTSTR pszBoardID){m_strBoardID=pszBoardID; }
126
  void SetDate   (LPCTSTR pszDate)   {m_strDate   =pszDate; }
127
 
128
  LPCTSTR Email  () { return m_strEmail; }
129
  LPCTSTR User   () { return m_strUser; }
130
  LPCTSTR Reason () { return m_strReason; }
131
  LPCTSTR BoardID() { return m_strBoardID; }
132
  LPCTSTR Date   () { return m_strDate; }
133
 
134
  // Scheduling functions
135
  // Get the array of resources capable of executing "e"
136
  // nCount gives the number of entries in ar on input
137
  // result is the number of entries required in ar (may exceed nCount, but this case does no damage)
138
  static unsigned int GetMatchCount (const CeCosTest::ExecutionParameters &e,bool bIgnoreLocking=false);
139
  static bool GetMatches (const CeCosTest::ExecutionParameters &e,StringArray &arstr,bool bIgnoreLocking=false); // as before, but callee allocates.  Deallocate using delete [].
140
 
141
  static bool SetResourceServer (LPCTSTR pszHostPort) { bool b=CeCosSocket::IsLegalHostPort(pszHostPort);if(b)strResourceHostPort=pszHostPort; return b;}
142
  static String GetResourceServer (){ return strResourceHostPort; }
143
  static bool ResourceServerSet() { return CeCosSocket::IsLegalHostPort(GetResourceServer()); }
144
 
145
  static CTestResource *GetResource(const CeCosTest::ExecutionParameters &e);
146
  void Release() {
147
    //VTRACE(_T("Release %s\n"),Serial1());
148
    m_bInUse=false;
149
  }
150
 
151
  bool InUse() const { return m_bInUse; }
152
  static int Count (const CeCosTest::ExecutionParameters &e);
153
 
154
  // Reset the hardware attached to this port.  Output goes to pfnLog
155
  CResetAttributes::ResetResult Reset(LogFunc *pfnLog=0, void *pfnLogparam=0);
156
  CResetAttributes::ResetResult Reset(String &str); // as above, output to string
157
 
158
  static bool Matches(LPCTSTR pszHostPort, const CeCosTest::ExecutionParameters &e);
159
  bool FromStr(LPCTSTR pszImage);
160
  LPCTSTR ResetString() const { return m_strReset; }
161
 
162
  class CTestResourceProperties : public CProperties {
163
  public:
164
    CTestResourceProperties(CTestResource *pResource);
165
    virtual ~CTestResourceProperties(){}
166
  protected:
167
  };
168
 
169
protected:
170
 
171
  friend class CTestResourceProperties;
172
 
173
  String FileName() const;
174
  String m_strReason,m_strUser,m_strEmail,m_strBoardID, m_strDate;
175
 
176
  String m_strReset;
177
 
178
  static void CALLBACK StringLogFunc (void *pParam,LPCTSTR psz);
179
 
180
  static bool LoadSocket (LPCTSTR pszHostPort,Duration dTimeout=10*1000);
181
  static bool SaveSocket (LPCTSTR pszHostPort,Duration dTimeout=10*1000);
182
  static LPCTSTR szFormat;
183
 
184
  void Chain();
185
 
186
  unsigned static int nCount;
187
  static String strResourceHostPort;
188
  static CTestResource *pFirstInstance;
189
 
190
  bool Matches  (const CeCosTest::ExecutionParameters &e,bool bIgnoreLocking=false) const;
191
 
192
 
193
  String m_strInfo;
194
  bool m_bFlag;
195
  bool m_bInUse;
196
  int  m_nBaud;
197
  String m_strPort;
198
 
199
  bool m_bLocked;
200
 
201
  String m_Target;
202
  String m_strHost;
203
  int m_nPort;
204
  CTestResource *m_pNextInstance;
205
  CTestResource *m_pPrevInstance;
206
};
207
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.