-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.h
173 lines (142 loc) · 3.38 KB
/
config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
* Configuration options for the fstest utility
*
* Copyright (C) 2013 Fraunhofer ITWM, Bernd Schubert
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
************************************************************************/
#include "fstest.h"
#ifndef CONFIG_H_
#define CONFIG_H_
#define MAX_USAGE_PERCENT 90 // fill file system up to this level
#define TIMEOUT -1 // timeout before leaving
// file sizes between min and max
#define DEFAULT_MIN_SIZE_BITS 20 // 2^20 = 1MiB
#define DEFAULT_MAX_SIZE_BITS 30 // 2^30 = 1GiB
class Config_fstest {
public:
Config_fstest(void)
{
this->usage_percent = MAX_USAGE_PERCENT;
this->timeout = TIMEOUT;
this->immediate_check = false;
this->testdir = "";
this->min_size_bits = DEFAULT_MIN_SIZE_BITS;
this->max_size_bits = DEFAULT_MAX_SIZE_BITS;
this->error_stop = false;
this->max_files = QL_FSTEST_DEFAULT_NUM_FILES;
this->direct_io = false;
}
private:
size_t usage_percent; // max fill level
ssize_t timeout; // in seconds
bool immediate_check;
string testdir;
size_t min_size_bits;
size_t max_size_bits;
size_t max_files;
bool error_stop; // stop on first error
bool direct_io;
public:
void set_usage(size_t value)
{
this->usage_percent = value;
}
size_t get_usage(void)
{
return this->usage_percent;
}
void set_timeout(ssize_t value)
{
this->timeout = value;
}
ssize_t get_timeout(void)
{
return this->timeout;
}
void set_immediate_check(bool value)
{
this->immediate_check = value;
}
bool get_immediate_check(void)
{
return this->immediate_check;
}
void set_testdir(string testdir)
{
if ((testdir.length() > 0)
&& (testdir.at(testdir.length() - 1) != '/')) {
testdir += '/';
}
// add pid to directory
pid_t pid = getpid();
stringstream str;
str << pid;
testdir += "fstest." + str.str() + "/";
this->testdir = testdir;
}
string get_testdir(void)
{
return this->testdir;
}
void set_min_size_bits(int min)
{
this->min_size_bits = min;
}
int get_min_size_bits(void)
{
return this->min_size_bits;
}
void set_max_size_bits(size_t max)
{
this->max_size_bits = max;
}
size_t get_max_size_bits(void)
{
return this->max_size_bits;
}
void set_max_files(size_t max_files)
{
this->max_files = max_files;
}
size_t get_max_files(void)
{
return this->max_files;
}
ssize_t get_default_max_files(void)
{
return QL_FSTEST_DEFAULT_NUM_FILES;
}
void set_error_immediate_stop(void)
{
this->error_stop = true;
}
bool get_error_immediate_stop()
{
return this->error_stop;
}
void set_direct_io(void)
{
this->direct_io = true;
}
bool get_direct_io(void)
{
return this->direct_io;
}
};
Config_fstest *get_global_cfg(void);
#endif /* CONFIG_H_ */