ATLAS Offline Software
Loading...
Searching...
No Matches
UnitTestDir.cxx
Go to the documentation of this file.
1// - 2012.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5
6// Please feel free to contact me (krumnack@iastate.edu) for bug
7// reports, feature suggestions, praise and complaints.
8
9
10//
11// includes
12//
13
15
16#include <cstdlib>
17#include <TSystem.h>
18#include <TString.h>
21
22//
23// method implementations
24//
25
26namespace RCU
27{
28 void UnitTestDir ::
29 testInvariant () const
30 {
31 //RCU_INVARIANT (this != 0);
32 }
33
34
35
36 UnitTestDir ::
37 UnitTestDir (const std::string& package, const std::string& name)
38 : m_cleanup (getenv ("ROOTCORE_AUTO_UT") != 0)
39 {
40 TString output = "/tmp";
41 {
42 const char *tmpdir = getenv ("TMPDIR");
43 if (tmpdir)
44 output = tmpdir;
45 };
46 output += ("/ut-" + package + "-" + name + ".$$").c_str();
47 gSystem->ExpandPathName (output);
48 m_path = output.Data ();
49
50 if (gSystem->MakeDirectory (output.Data()) != 0)
51 RCU_THROW_MSG (("could not create output directory " + output).Data());
52 }
53
54
55
56 UnitTestDir ::
57 ~UnitTestDir ()
58 {
60
61 if (m_cleanup)
62 gSystem->Exec (("rm -rf " + m_path).c_str());
63 else
64 RCU_PRINT_MSG ("unit test data located at " + m_path);
65 }
66
67
68
69 const std::string& UnitTestDir ::
70 path () const
71 {
72 RCU_READ_INVARIANT (this);
73 return m_path;
74 }
75
76
77
78 bool UnitTestDir ::
79 cleanup () const
80 {
81 RCU_READ_INVARIANT (this);
82 return m_cleanup;
83 }
84
85
86
87 void UnitTestDir ::
88 cleanup (bool val_cleanup)
89 {
91 m_cleanup = val_cleanup;
92 }
93}
#define RCU_DESTROY_INVARIANT(x)
Definition Assert.h:235
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:231
#define RCU_READ_INVARIANT(x)
Definition Assert.h:229
@ Data
Definition BaseObject.h:11
#define RCU_THROW_MSG(message)
Definition PrintMsg.h:58
#define RCU_PRINT_MSG(message)
Definition PrintMsg.h:49
std::string m_path
description: members directly corresponding to accessors
Definition UnitTestDir.h:78
This module defines a variety of assert style macros.
Definition Assert.cxx:26