Nymph  v1.5.2
Flow-Based Data Processing Framework
TestCacheDirectory.cc
Go to the documentation of this file.
1 /*
2  * TestCacheDirectory.cc
3  *
4  * Created on: Dec 3, 2012
5  * Author: nsoblath
6  *
7  * Usage:
8  * > TestCacheDirectory
9  *
10  * Will first test if the current directory can be used as the cache (the default condition if no other directory is specified.
11  * Then tests if ./TestCacheDirectory can be used as the cache. This will pass if the directory exists and is read/writable.
12  */
13 
14 #include "KTCacheDirectory.hh"
15 
16 #include "KTLogger.hh"
17 
18 using namespace Nymph;
19 
20 KTLOGGER(testlog, "TestCacheDirectory");
21 
22 int main()
23 {
24 
25  KTCacheDirectory* cacheDir = KTCacheDirectory::get_instance();
26 
27  KTINFO(testlog, "Testing ./ (should pass if the current directory is read/writeable)");
28  KTINFO(testlog, "Current cache directory is: " << cacheDir->GetPath());
29  KTWARN(testlog, "Is the cache directory OK? " << cacheDir->IsReady());
30 
31  KTINFO(testlog, "Testing ./TestCacheDirectory (should pass if ./TestCacheDirectory exists and is read/writeable)");
32  if (! cacheDir->SetPath("./TestCacheDirectory"))
33  {
34  KTERROR(testlog, "Error setting the path");
35  }
36  KTINFO(testlog, "Current cache directory is: " << cacheDir->GetPath());
37  KTWARN(testlog, "Is the cache directory OK? " << cacheDir->IsReady());
38 
39  KTINFO(testlog, "Testing /usr/local (should fail, assuming you're not running as root)");
40  if (! cacheDir->SetPath("/usr/local"))
41  {
42  KTERROR(testlog, "Error setting the path");
43  }
44  KTINFO(testlog, "Current cache directory is: " << cacheDir->GetPath());
45  KTWARN(testlog, "Is the cache directory OK? " << cacheDir->IsReady());
46 
47  return 0;
48 }
#define KTINFO(...)
Definition: KTLogger.hh:344
bool SetPath(const std::string &strPath)
Definition: KTDirectory.cc:49
KTLOGGER(applog, "KTApplication")
int main()
bool IsReady() const
Check if everything has been correctly configured.
#define KTERROR(...)
Definition: KTLogger.hh:347
#define KTWARN(...)
Definition: KTLogger.hh:346
const std::string & GetPath() const
Definition: KTDirectory.cc:34
Contains the logger class and macros, based on Kasper&#39;s KLogger class.