~ubuntu-branches/ubuntu/breezy/cmake/breezy

« back to all changes in this revision

Viewing changes to Source/cmCTest.h

  • Committer: Bazaar Package Importer
  • Author(s): A. Maitland Bottoms
  • Date: 2004-08-12 09:21:32 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20040812092132-qus2c27xt84ypfx4
Tags: 2.0.3-1
* New upstream release
* finds QT's moc, gets bug closing syntax right (Closes: #250000)

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
  Program:   CMake - Cross-Platform Makefile Generator
4
4
  Module:    $RCSfile: cmCTest.h,v $
5
5
  Language:  C++
6
 
  Date:      $Date: 2003/11/03 20:38:23 $
7
 
  Version:   $Revision: 1.18 $
 
6
  Date:      $Date: 2004/07/29 18:45:51 $
 
7
  Version:   $Revision: 1.38.2.5 $
8
8
 
9
9
  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
10
10
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
20
20
 
21
21
 
22
22
#include "cmStandardIncludes.h"
 
23
#include "cmListFileCache.h"
 
24
 
 
25
class cmMakefile;
23
26
 
24
27
class cmCTest
25
28
{
26
29
public:
 
30
  typedef std::vector<cmStdString> tm_VectorOfStrings;
 
31
  typedef std::vector<cmListFileArgument> tm_VectorOfListFileArgs;
 
32
 
 
33
  ///! Process Command line arguments
 
34
  int Run(std::vector<std::string>const&, std::string* output = 0);
 
35
  
 
36
  /**
 
37
   * Run a dashboard using a specified confiuration script
 
38
   */
 
39
  int RunConfigurationScript();
 
40
  int RunConfigurationScript(const std::string& script);
 
41
  int RunConfigurationDashboard(cmMakefile *mf, 
 
42
                                const char *srcDir, const char *binDir,
 
43
                                const char *ctestRoot,
 
44
                                bool backup, const char *cvsCheckOut,
 
45
                                const char *ctestCmd);
 
46
  
27
47
  /**
28
48
   * Initialize and finalize testing
29
49
   */
30
 
  void Initialize();
 
50
  int Initialize();
31
51
  void Finalize();
32
52
 
33
53
  /**
50
70
  /**
51
71
   * Try to run tests of the project
52
72
   */
53
 
  int TestDirectory();
 
73
  int TestDirectory(bool memcheck);
54
74
 
55
75
  /**
56
76
   * Try to get coverage of the project
81
101
  /**
82
102
   * Run the test for a directory and any subdirectories
83
103
   */
84
 
  void ProcessDirectory(std::vector<std::string> &passed, 
85
 
                        std::vector<std::string> &failed);
 
104
  void ProcessDirectory(tm_VectorOfStrings &passed, 
 
105
                        tm_VectorOfStrings &failed,
 
106
                        bool memcheck);
86
107
 
87
108
  /**
88
109
   * Find the executable for a test
97
118
  /**
98
119
   * Set the cmake test mode (experimental, nightly, continuous).
99
120
   */
100
 
  void SetTestModel(int mode)
101
 
    {
102
 
    m_TestModel = mode;
103
 
    }
 
121
  void SetTestModel(int mode);
 
122
 
104
123
  std::string GetTestModelString();
 
124
  static int GetTestModelFromString(const char* str);
105
125
 
106
126
  /**
107
127
   * constructor
108
128
   */
109
129
  cmCTest();
110
130
 
 
131
  //! Set the notes files to be created.
 
132
  void SetNotesFiles(const char* notes);
 
133
 
111
134
  bool m_UseIncludeRegExp;
112
135
  std::string m_IncludeRegExp;
113
136
 
120
143
  bool m_DartMode;
121
144
  bool m_ShowOnly;
122
145
 
 
146
  bool m_ForceNewCTestProcess;
 
147
 
 
148
  bool m_RunConfigurationScript;
 
149
  tm_VectorOfStrings m_ConfigurationScripts;
 
150
 
123
151
  enum {
124
152
    EXPERIMENTAL,
125
153
    NIGHTLY,
126
154
    CONTINUOUS
127
155
  };
128
156
 
 
157
  int GenerateNotesFile(const char* files);
 
158
 
 
159
  void RestoreBackupDirectories(bool backup, 
 
160
                                const char *srcDir, const char *binDir,
 
161
                                const char *backupSrc, const char *backupBin);
 
162
 
129
163
private:
 
164
  void SetTestsToRunInformation(const char*);
 
165
  void ExpandTestsToRunInformation(int numPossibleTests);
 
166
  std::string TestsToRunString;
 
167
  
130
168
  enum {
131
169
    FIRST_TEST     = 0,
132
170
    UPDATE_TEST    = 1,
135
173
    BUILD_TEST     = 4,
136
174
    TEST_TEST      = 5,
137
175
    COVERAGE_TEST  = 6,
138
 
    PURIFY_TEST    = 7,
 
176
    MEMCHECK_TEST  = 7,
139
177
    SUBMIT_TEST    = 8,
140
 
    ALL_TEST       = 9,
141
 
    LAST_TEST      = 10
 
178
    NOTES_TEST     = 9,
 
179
    ALL_TEST       = 10,
 
180
    LAST_TEST      = 11
142
181
  };
143
182
  
144
183
  enum { // Program statuses
154
193
    COMPLETED
155
194
  };
156
195
 
 
196
  enum { // Memory checkers
 
197
    UNKNOWN = 0,
 
198
    VALGRIND,
 
199
    PURIFY,
 
200
    BOUNDS_CHECKER
 
201
  };
 
202
 
 
203
  enum { // Memory faults
 
204
    ABR = 0,
 
205
    ABW,
 
206
    ABWL,
 
207
    COR,
 
208
    EXU,
 
209
    FFM,
 
210
    FIM,
 
211
    FMM,
 
212
    FMR,
 
213
    FMW,
 
214
    FUM,
 
215
    IPR,
 
216
    IPW,
 
217
    MAF,
 
218
    MLK,
 
219
    MPK,
 
220
    NPR,
 
221
    ODS,
 
222
    PAR,
 
223
    PLK,
 
224
    UMC,
 
225
    UMR,
 
226
    NO_MEMORY_FAULT
 
227
  };
 
228
 
 
229
 
157
230
  struct cmCTestTestResult
158
231
  {
159
232
    std::string m_Name;
165
238
    std::string m_CompletionStatus;
166
239
    std::string m_Output;
167
240
    std::string m_RegressionImages;
 
241
    int         m_TestCount;
168
242
  };
169
243
 
170
244
  struct cmCTestBuildErrorWarning
179
253
    std::string m_PostContext;
180
254
  };
181
255
 
 
256
  struct cmCTestTestProperties
 
257
    {
 
258
    cmStdString m_Name;
 
259
    cmStdString m_Directory;
 
260
    tm_VectorOfListFileArgs m_Args;
 
261
    };
 
262
 
 
263
  typedef std::vector<cmCTestTestProperties> tm_ListOfTests;
 
264
 
182
265
  // Some structures needed for cvs update
183
266
  struct StringPair : 
184
267
    public std::pair<std::string, std::string>{};
208
291
  };
209
292
 
210
293
  typedef std::vector<cmCTestTestResult> tm_TestResultsVector;
 
294
  //! Map of configuration properties
211
295
  typedef std::map<std::string, std::string> tm_DartConfigurationMap;
212
296
  typedef std::map<std::string, cmCTestCoverage> tm_CoverageMap;
213
297
 
217
301
  int                     m_Tests[LAST_TEST];
218
302
  
219
303
  std::string             m_CurrentTag;
 
304
  bool                    m_TomorrowTag;
220
305
 
221
306
  std::string             m_StartBuild;
222
307
  std::string             m_EndBuild;
223
308
  std::string             m_StartTest;
224
309
  std::string             m_EndTest;
 
310
  double                  m_ElapsedTestingTime;
225
311
 
226
312
  int                     m_TestModel;
227
313
 
228
 
  int                     m_TimeOut;
 
314
  double                  m_TimeOut;
 
315
 
 
316
  std::string             m_MemoryTester;
 
317
  std::string             m_MemoryTesterOptions;
 
318
  int                     m_MemoryTesterStyle;
 
319
  std::string             m_MemoryTesterOutputFile;
 
320
  tm_VectorOfStrings      m_MemoryTesterOptionsParsed;
 
321
  int                     m_MemoryTesterGlobalResults[NO_MEMORY_FAULT];
 
322
 
 
323
  int                     m_CompatibilityMode;
 
324
 
 
325
  // information for the --build-and-test options
 
326
  std::string              m_ExecutableDirectory;
 
327
  std::string              m_CMakeSelf;
 
328
  std::string              m_CTestSelf;
 
329
  std::string              m_SourceDir;
 
330
  std::string              m_BinaryDir;
 
331
  std::string              m_BuildRunDir;
 
332
  std::string              m_BuildGenerator;
 
333
  std::string              m_BuildMakeProgram;
 
334
  std::string              m_BuildProject;
 
335
  std::string              m_BuildTarget;
 
336
  std::vector<std::string> m_BuildOptions;
 
337
  std::string              m_TestCommand;
 
338
  std::vector<std::string> m_TestCommandArgs;
 
339
  bool                     m_BuildTwoConfig;
 
340
  bool                     m_BuildNoClean;
 
341
  bool                     m_BuildNoCMake;
 
342
  std::string              m_NotesFiles;
 
343
  std::vector<int>         m_TestsToRun;
 
344
  
 
345
 
 
346
  int ReadCustomConfigurationFileTree(const char* dir);
 
347
  void PopulateCustomVector(cmMakefile* mf, const char* definition, tm_VectorOfStrings& vec);
 
348
 
 
349
  tm_VectorOfStrings       m_CustomErrorMatches;
 
350
  tm_VectorOfStrings       m_CustomErrorExceptions;
 
351
  tm_VectorOfStrings       m_CustomWarningMatches;
 
352
  tm_VectorOfStrings       m_CustomWarningExceptions;
 
353
 
 
354
  tm_VectorOfStrings       m_CustomTestsIgnore;
 
355
  tm_VectorOfStrings       m_CustomMemCheckIgnore;
 
356
 
 
357
  tm_VectorOfStrings       m_CustomPreTest;
 
358
  tm_VectorOfStrings       m_CustomPostTest;
 
359
  tm_VectorOfStrings       m_CustomPreMemCheck;
 
360
  tm_VectorOfStrings       m_CustomPostMemCheck;
 
361
  bool                     m_InteractiveDebugMode;
 
362
  
 
363
  void BlockTestErrorDiagnostics();
 
364
 
 
365
  int ExecuteCommands(tm_VectorOfStrings& vec);
 
366
 
 
367
  /**
 
368
   * Get the list of tests in directory and subdirectories.
 
369
   */
 
370
  void GetListOfTests(tm_ListOfTests* testlist, bool memcheck);
 
371
 
 
372
  //! Reread the configuration file
 
373
  void UpdateCTestConfiguration();
229
374
 
230
375
  /**
231
376
   * Generate the Dart compatible output
232
377
   */
233
378
  void GenerateDartTestOutput(std::ostream& os);
 
379
  void GenerateDartMemCheckOutput(std::ostream& os);
234
380
  void GenerateDartBuildOutput(std::ostream& os, 
235
 
                               std::vector<cmCTestBuildErrorWarning>);
 
381
                               std::vector<cmCTestBuildErrorWarning>,
 
382
                               double elapsed_time);
236
383
 
237
384
  bool OpenOutputFile(const std::string& path, 
238
385
                      const std::string& name, std::ofstream& stream);  
247
394
 
248
395
  //! Run command specialized for tests. Returns process status and retVal is
249
396
  // return value or exception.
250
 
  int RunTest(std::vector<const char*> args, std::string* output, int *retVal);
 
397
  int RunTest(std::vector<const char*> args, std::string* output, int *retVal, 
 
398
    std::ostream* logfile);
251
399
 
252
400
  std::string GenerateRegressionImages(const std::string& xml);
253
401
  const char* GetTestStatus(int status);
 
402
 
 
403
  //! Start CTest XML output file
 
404
  void StartXML(std::ostream& ostr);
 
405
 
 
406
  //! End CTest XML output file
 
407
  void EndXML(std::ostream& ostr);
 
408
 
 
409
  //! Create not from files.
 
410
  int GenerateDartNotesOutput(std::ostream& os, const tm_VectorOfStrings& files);
 
411
 
 
412
  //! Parse Valgrind/Purify/Bounds Checker result out of the output string. After running,
 
413
  // log holds the output and results hold the different memmory errors.
 
414
  bool ProcessMemCheckOutput(const std::string& str, std::string& log, int* results);
 
415
  bool ProcessMemCheckValgrindOutput(const std::string& str, std::string& log, int* results);
 
416
  bool ProcessMemCheckPurifyOutput(const std::string& str, std::string& log, int* results);
 
417
 
 
418
  ///! Run CMake and build a test and then run it as a single test.
 
419
  int RunCMakeAndTest(std::string* output);
 
420
  ///! Initialize memory checking subsystem.
 
421
  bool InitializeMemoryChecking();
 
422
  ///! Find the running cmake
 
423
  void FindRunningCMake(const char* arg0);
 
424
 
 
425
  ///! Get the current time as string
 
426
  std::string CurrentTime();
254
427
};
255
428
 
256
429
#endif