rambrain
configTest.cpp
Go to the documentation of this file.
1 /* rambrain - a dynamical physical memory extender
2  * Copyright (C) 2015 M. Imgrund, A. Arth
3  * mimgrund (at) mpifr-bonn.mpg.de
4  * arth (at) usm.uni-muenchen.de
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 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU 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, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include <iostream>
21 #include "managedPtr.h"
22 #include "cyclicManagedMemory.h"
23 #include "managedDummySwap.h"
24 #include "rambrainconfig.h"
25 
26 using namespace std;
27 using namespace rambrain;
28 
29 namespace rambrain
30 {
32 {
33  return man->swap;
34 }
35 }
36 
40 int main ( int argc, char **argv )
41 {
42  int ret = 0;
43  cout << "Starting check if binary specific config is read and used properly" << endl;
44 
45  rambrainglobals::config.setCustomConfigPath ( "../tests/testConfig.conf" );
47 
49  managedMemory *man = managedMemory::defaultManager;
50  managedSwap *swap = configTestGetSwap ( man );
51 
52  if ( config.memoryManager.value != "cyclicManagedMemory" || reinterpret_cast<cyclicManagedMemory *> ( man ) == NULL ) {
53  cerr << "Manager is wrong!" << endl;
54  ++ ret;
55  }
56 
57  if ( config.swap.value != "managedDummySwap" || reinterpret_cast<managedDummySwap *> ( swap ) == NULL ) {
58  cerr << "Swap is wrong!" << endl;
59  ++ ret;
60  }
61 
62  if ( config.memory.value != 100 || man->getMemoryLimit() != 100ul ) {
63  cerr << "Memory limit is wrong! " << config.memory.value << " != " << man->getMemoryLimit() << " != 100" << endl;
64  ++ ret;
65  }
66 
67  if ( config.swapMemory.value != 1000000000uLL || swap->getSwapSize() != 1000000000uLL ) {
68  cerr << "Swap limit is wrong! " << config.swapMemory.value << " != 1000000000" << endl;
69  ++ ret;
70  }
71 
72  if ( config.swapfiles.value != "rambrainswapconfigtest-%d-%d" ) {
73  cerr << "Swap files are named incorrectly! " << config.swapfiles.value << " != rambrainswapconfigtest-%d-%d" << endl;
74  ++ ret;
75  }
76 
77  managedPtr<double> data1 ( 10, 2.0 );
78  managedPtr<double> data2 ( 10, 4.0 );
79 
80  {
81  ADHERETOLOC ( double, data1, d );
82  for ( int i = 0; i < 10; ++i ) {
83  if ( d[i] != 2.0 ) {
84  cerr << "Swapped in data is wrong at index " << i << endl;
85  ++ ret;
86  }
87  }
88  }
89 
90  cout << endl << "Done, " << ret << " errors occured" << endl;
91 
92  return ret;
93 }
94 
const configuration & getConfig()
Simple getter.
Class that serves as a backend to managedMemory to actual write/read managedMemoryChunks to/from hard...
Definition: managedSwap.h:35
Main class to allocate memory that is managed by the rambrain memory defaultManager.
Definition: managedMemory.h:54
virtual global_bytesize getSwapSize() const
Simple getter.
Definition: managedSwap.h:82
managedSwap * configTestGetSwap(managedMemory *man)
Definition: configTest.cpp:31
configLine< string > swapfiles
Definition: configreader.h:138
Main struct to save configuration variables.
Definition: configreader.h:131
int main(int argc, char **argv)
A test to check if binary specific custom config files are properly read in and used.
Definition: configTest.cpp:40
void setCustomConfigPath(const string &path)
Simple setter.
rambrainConfig config
You will find the object in managedMemory.cpp as we have to define it in some 'used' file in the link...
void reinit(bool reread=true)
Reinitialises the system.
configLine< global_bytesize > memory
Definition: configreader.h:139
configLine< string > swap
Definition: configreader.h:138
STL namespace.
global_bytesize getMemoryLimit() const
returns current memory limit
Definition: managedMemory.h:93
configLine< string > memoryManager
Definition: configreader.h:138
configLine< global_bytesize > swapMemory
Definition: configreader.h:139
Backend class to handle raw memory and interaction/storage with managedSwap.
Definition: managedMemory.h:68