perfmonger 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +6 -0
- data/.tachikoma.yml +1 -0
- data/.travis.yml +18 -6
- data/Gemfile +1 -3
- data/Guardfile +26 -0
- data/NEWS +21 -0
- data/README.md +8 -9
- data/Rakefile +33 -1
- data/core/Makefile +23 -0
- data/core/build.sh +48 -0
- data/core/perfmonger-player.go +165 -0
- data/core/perfmonger-recorder.go +296 -0
- data/core/perfmonger-summarizer.go +207 -0
- data/core/subsystem/Makefile +3 -0
- data/core/subsystem/perfmonger.go +60 -0
- data/core/subsystem/perfmonger_darwin.go +22 -0
- data/core/subsystem/perfmonger_linux.go +292 -0
- data/core/subsystem/perfmonger_linux_test.go +73 -0
- data/core/subsystem/stat.go +214 -0
- data/core/subsystem/stat_test.go +281 -0
- data/core/subsystem/usage.go +410 -0
- data/core/subsystem/usage_test.go +496 -0
- data/lib/exec/operationBinding.rb.svn-base +59 -0
- data/lib/exec/perfmonger-player_darwin_amd64 +0 -0
- data/lib/exec/perfmonger-player_linux_386 +0 -0
- data/lib/exec/perfmonger-player_linux_amd64 +0 -0
- data/lib/exec/perfmonger-recorder_darwin_amd64 +0 -0
- data/lib/exec/perfmonger-recorder_linux_386 +0 -0
- data/lib/exec/perfmonger-recorder_linux_amd64 +0 -0
- data/lib/exec/perfmonger-summarizer_darwin_amd64 +0 -0
- data/lib/exec/perfmonger-summarizer_linux_386 +0 -0
- data/lib/exec/perfmonger-summarizer_linux_amd64 +0 -0
- data/lib/exec/perfmonger-summary_linux_386 +0 -0
- data/lib/exec/perfmonger-summary_linux_amd64 +0 -0
- data/lib/perfmonger/cli.rb +8 -3
- data/lib/perfmonger/command/core.rb +62 -0
- data/lib/perfmonger/command/live.rb +39 -0
- data/lib/perfmonger/command/play.rb +56 -0
- data/lib/perfmonger/command/plot.rb +30 -22
- data/lib/perfmonger/command/record.rb +3 -2
- data/lib/perfmonger/command/record_option.rb +40 -59
- data/lib/perfmonger/command/server.rb +7 -2
- data/lib/perfmonger/command/stat.rb +2 -2
- data/lib/perfmonger/command/stat_option.rb +1 -1
- data/lib/perfmonger/command/summary.rb +11 -326
- data/lib/perfmonger/version.rb +1 -3
- data/lib/perfmonger.rb +3 -0
- data/misc/_perfmonger +128 -0
- data/misc/perfmonger-completion.bash +49 -0
- data/perfmonger.gemspec +6 -5
- data/spec/data/busy100.pgr +0 -0
- data/spec/fingerprint_spec.rb +35 -0
- data/spec/live_spec.rb +25 -0
- data/spec/perfmonger_spec.rb +37 -0
- data/spec/play_spec.rb +21 -0
- data/spec/plot_spec.rb +42 -0
- data/spec/record_spec.rb +15 -0
- data/spec/spec_helper.rb +33 -0
- data/spec/stat_spec.rb +15 -0
- data/spec/summary_spec.rb +51 -0
- data/spec/support/aruba.rb +11 -0
- data/wercker.yml +59 -0
- metadata +117 -45
- data/ext/perfmonger/extconf.rb +0 -19
- data/ext/perfmonger/perfmonger.h +0 -58
- data/ext/perfmonger/perfmonger_record.c +0 -754
- data/ext/perfmonger/sysstat/common.c +0 -627
- data/ext/perfmonger/sysstat/common.h +0 -207
- data/ext/perfmonger/sysstat/ioconf.c +0 -515
- data/ext/perfmonger/sysstat/ioconf.h +0 -84
- data/ext/perfmonger/sysstat/iostat.c +0 -1100
- data/ext/perfmonger/sysstat/iostat.h +0 -121
- data/ext/perfmonger/sysstat/libsysstat.h +0 -19
- data/ext/perfmonger/sysstat/mpstat.c +0 -953
- data/ext/perfmonger/sysstat/mpstat.h +0 -79
- data/ext/perfmonger/sysstat/rd_stats.c +0 -2388
- data/ext/perfmonger/sysstat/rd_stats.h +0 -651
- data/ext/perfmonger/sysstat/sysconfig.h +0 -13
- data/test/run-test.sh +0 -39
- data/test/spec/bin_spec.rb +0 -37
- data/test/spec/data/2devices.expected +0 -42
- data/test/spec/data/2devices.output +0 -42
- data/test/spec/spec_helper.rb +0 -20
- data/test/spec/summary_spec.rb +0 -193
- data/test/test-perfmonger.c +0 -145
- data/test/test.h +0 -9
data/test/spec/bin_spec.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe "PerfmongerCommand" do
|
5
|
-
before(:each) do
|
6
|
-
@perfmonger_command = File.expand_path('../../src/perfmonger', __FILE__)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should be an executable" do
|
10
|
-
File.executable?(@perfmonger_command).should be_true
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should print version number if --version specified' do
|
14
|
-
`#{@perfmonger_command} --version`.should include(PerfMonger::VERSION)
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'stat subcommand' do
|
18
|
-
it 'should print "Execution time: XXX.XXX"' do
|
19
|
-
if File.exists?("/proc/diskstats")
|
20
|
-
`#{@perfmonger_command} stat -- sleep 1`.should match(/^Execution time: (\d+)\.(\d+)$/)
|
21
|
-
else
|
22
|
-
# do nothing
|
23
|
-
true.should be_true
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe 'summary subcommand' do
|
29
|
-
it 'should print expected output with 2devices.log' do
|
30
|
-
File.open(data_file('2devices.output'), "w") do |f|
|
31
|
-
f.print(`#{@perfmonger_command} summary #{data_file('2devices.log')}`)
|
32
|
-
end
|
33
|
-
|
34
|
-
system("diff -u #{data_file('2devices.expected')} #{data_file('2devices.output')}").should be_true
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
|
2
|
-
== Performance summary of 'spec/data/2devices.log' ==
|
3
|
-
|
4
|
-
record duration: 1.00 sec
|
5
|
-
|
6
|
-
* Average CPU usage (MAX: 200 %)
|
7
|
-
* Non idle portion: 200.00
|
8
|
-
%usr: 0.00
|
9
|
-
%sys: 200.00
|
10
|
-
%irq: 0.00
|
11
|
-
%soft: 0.00
|
12
|
-
%other: 0.00
|
13
|
-
* Idle portion: 0.00
|
14
|
-
%iowait: 0.00
|
15
|
-
%idle: 0.00
|
16
|
-
|
17
|
-
* Average DEVICE usage: sda
|
18
|
-
read IOPS: 1.00
|
19
|
-
write IOPS: 0.00
|
20
|
-
read throughput: 0.00 MB/s
|
21
|
-
write throughput: 0.00 MB/s
|
22
|
-
read latency: 53.00 msec
|
23
|
-
write latency: 0.0 usec
|
24
|
-
read amount: 512.00 bytes
|
25
|
-
write amount: 0.00 bytes
|
26
|
-
|
27
|
-
* Average DEVICE usage: sdb
|
28
|
-
read IOPS: 0.00
|
29
|
-
write IOPS: 0.00
|
30
|
-
read throughput: 0.00 MB/s
|
31
|
-
write throughput: 0.00 MB/s
|
32
|
-
read latency: 0.0 usec
|
33
|
-
write latency: 0.0 usec
|
34
|
-
read amount: 0.00 bytes
|
35
|
-
write amount: 0.00 bytes
|
36
|
-
|
37
|
-
* TOTAL DEVICE usage: sda, sdb
|
38
|
-
read IOPS: 1.00
|
39
|
-
write IOPS: 0.00
|
40
|
-
read throughput: 0.00 MB/s
|
41
|
-
write throughput: 0.00 MB/s
|
42
|
-
|
@@ -1,42 +0,0 @@
|
|
1
|
-
|
2
|
-
== Performance summary of 'spec/data/2devices.log' ==
|
3
|
-
|
4
|
-
record duration: 1.00 sec
|
5
|
-
|
6
|
-
* Average CPU usage (MAX: 200 %)
|
7
|
-
* Non idle portion: 200.00
|
8
|
-
%usr: 0.00
|
9
|
-
%sys: 200.00
|
10
|
-
%irq: 0.00
|
11
|
-
%soft: 0.00
|
12
|
-
%other: 0.00
|
13
|
-
* Idle portion: 0.00
|
14
|
-
%iowait: 0.00
|
15
|
-
%idle: 0.00
|
16
|
-
|
17
|
-
* Average DEVICE usage: sda
|
18
|
-
read IOPS: 1.00
|
19
|
-
write IOPS: 0.00
|
20
|
-
read throughput: 0.00 MB/s
|
21
|
-
write throughput: 0.00 MB/s
|
22
|
-
read latency: 53.00 msec
|
23
|
-
write latency: 0.0 usec
|
24
|
-
read amount: 512.00 bytes
|
25
|
-
write amount: 0.00 bytes
|
26
|
-
|
27
|
-
* Average DEVICE usage: sdb
|
28
|
-
read IOPS: 0.00
|
29
|
-
write IOPS: 0.00
|
30
|
-
read throughput: 0.00 MB/s
|
31
|
-
write throughput: 0.00 MB/s
|
32
|
-
read latency: 0.0 usec
|
33
|
-
write latency: 0.0 usec
|
34
|
-
read amount: 0.00 bytes
|
35
|
-
write amount: 0.00 bytes
|
36
|
-
|
37
|
-
* TOTAL DEVICE usage: sda, sdb
|
38
|
-
read IOPS: 1.00
|
39
|
-
write IOPS: 0.00
|
40
|
-
read throughput: 0.00 MB/s
|
41
|
-
write throughput: 0.00 MB/s
|
42
|
-
|
data/test/spec/spec_helper.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
$LOAD_PATH << File.expand_path('../../src/ruby', __FILE__)
|
4
|
-
|
5
|
-
TEST_DATA_DIR = File.expand_path('../data', __FILE__)
|
6
|
-
|
7
|
-
require 'perfmonger'
|
8
|
-
require 'tempfile'
|
9
|
-
require 'pathname'
|
10
|
-
|
11
|
-
def data_file(rel_path)
|
12
|
-
from = Pathname.new(Dir.pwd)
|
13
|
-
path = Pathname.new(File.expand_path(rel_path, TEST_DATA_DIR))
|
14
|
-
|
15
|
-
path.relative_path_from(from).to_s
|
16
|
-
end
|
17
|
-
|
18
|
-
RSpec.configure do |config|
|
19
|
-
# RSpec config here
|
20
|
-
end
|
data/test/spec/summary_spec.rb
DELETED
@@ -1,193 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe PerfMonger::Command::SummaryCommand do
|
5
|
-
before(:each) do
|
6
|
-
@summary = PerfMonger::Command::SummaryCommand.new
|
7
|
-
@logfile = data_file('test.log')
|
8
|
-
@logfile_2devices = data_file('2devices.log')
|
9
|
-
end
|
10
|
-
|
11
|
-
describe 'read_logfile method' do
|
12
|
-
it 'should return 3 valid records' do
|
13
|
-
records = @summary.read_logfile(@logfile)
|
14
|
-
records.size.should == 3
|
15
|
-
records.each do |record|
|
16
|
-
record.should be_a Hash
|
17
|
-
record.should include "time"
|
18
|
-
|
19
|
-
record.should include "ioinfo"
|
20
|
-
record["ioinfo"].should include "devices"
|
21
|
-
record["ioinfo"]["devices"].should be_a Array
|
22
|
-
record["ioinfo"]["devices"].should include "sda"
|
23
|
-
record["ioinfo"].should include "sda"
|
24
|
-
record["ioinfo"]["sda"].should be_a Hash
|
25
|
-
record["ioinfo"]["sda"].should include "riops"
|
26
|
-
record["ioinfo"]["sda"].should include "wiops"
|
27
|
-
record["ioinfo"]["sda"].should include "rsecps"
|
28
|
-
record["ioinfo"]["sda"].should include "wsecps"
|
29
|
-
record["ioinfo"]["sda"].should include "r_await"
|
30
|
-
record["ioinfo"]["sda"].should include "w_await"
|
31
|
-
|
32
|
-
record.should include "cpuinfo"
|
33
|
-
record["cpuinfo"].should be_a Hash
|
34
|
-
record["cpuinfo"].should include "nr_cpu"
|
35
|
-
record["cpuinfo"].should include "cpus"
|
36
|
-
record["cpuinfo"].should include "all"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe 'make_summary method' do
|
42
|
-
before(:each) do
|
43
|
-
@records = @summary.read_logfile(@logfile)
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should return nil for empty records' do
|
47
|
-
@summary.make_summary([]).should be_nil
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'should return valid format result' do
|
51
|
-
summary = @summary.make_summary(@records)
|
52
|
-
|
53
|
-
summary.should be_a Hash
|
54
|
-
summary.should include "time"
|
55
|
-
|
56
|
-
summary.should include "ioinfo"
|
57
|
-
summary["ioinfo"].should include "devices"
|
58
|
-
summary["ioinfo"]["devices"].should be_a Array
|
59
|
-
summary["ioinfo"]["devices"].should include "sda"
|
60
|
-
summary["ioinfo"].should include "sda"
|
61
|
-
summary["ioinfo"]["sda"].should be_a Hash
|
62
|
-
summary["ioinfo"]["sda"].should include "riops"
|
63
|
-
summary["ioinfo"]["sda"].should include "wiops"
|
64
|
-
summary["ioinfo"]["sda"].should include "rsecps"
|
65
|
-
summary["ioinfo"]["sda"].should include "wsecps"
|
66
|
-
summary["ioinfo"]["sda"].should include "r_await"
|
67
|
-
summary["ioinfo"]["sda"].should include "w_await"
|
68
|
-
|
69
|
-
summary.should include "cpuinfo"
|
70
|
-
summary["cpuinfo"].should include "nr_cpu"
|
71
|
-
summary["cpuinfo"].should include "cpus"
|
72
|
-
summary["cpuinfo"].should include "all"
|
73
|
-
cpu_entries = [summary["cpuinfo"]["all"], *summary["cpuinfo"]["cpus"]]
|
74
|
-
cpu_entries.each do |entry|
|
75
|
-
entry.should be_a Hash
|
76
|
-
entry.should include "usr"
|
77
|
-
entry.should include "nice"
|
78
|
-
entry.should include "sys"
|
79
|
-
entry.should include "iowait"
|
80
|
-
entry.should include "irq"
|
81
|
-
entry.should include "soft"
|
82
|
-
entry.should include "steal"
|
83
|
-
entry.should include "guest"
|
84
|
-
entry.should include "idle"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'should calculate avg. IOPS correctly against non-equal intervals' do
|
89
|
-
@records[0]["time"] = 0.0
|
90
|
-
@records[1]["time"] = 1.0
|
91
|
-
@records[2]["time"] = 3.0
|
92
|
-
|
93
|
-
@records[0]["ioinfo"]["sda"]["riops"] = 0.0 # no effect for result
|
94
|
-
@records[1]["ioinfo"]["sda"]["riops"] = 3.0
|
95
|
-
@records[2]["ioinfo"]["sda"]["riops"] = 6.0
|
96
|
-
|
97
|
-
# avg. riops should be ((3.0 * 1.0 + 6.0 * 3.0) / 3.0) == 5.0
|
98
|
-
summary = @summary.make_summary(@records)
|
99
|
-
|
100
|
-
summary["ioinfo"]["sda"]["riops"].should be_within(5.0e-6).of(5.0)
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'should return 0.0 for r_await if all values are zero' do
|
104
|
-
@records[0]["ioinfo"]["sda"]["r_await"] = 0.0
|
105
|
-
@records[1]["ioinfo"]["sda"]["r_await"] = 0.0
|
106
|
-
@records[2]["ioinfo"]["sda"]["r_await"] = 0.0
|
107
|
-
|
108
|
-
summary = @summary.make_summary(@records)
|
109
|
-
|
110
|
-
summary["ioinfo"]["sda"]["r_await"].should == 0.0
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'should calculate avg. r_await/w_await correctly' do
|
114
|
-
@records[0]["ioinfo"]["sda"]["riops"] = 0.0
|
115
|
-
@records[0]["ioinfo"]["sda"]["r_await"] = 0.0
|
116
|
-
@records[1]["ioinfo"]["sda"]["riops"] = 100.0
|
117
|
-
@records[1]["ioinfo"]["sda"]["r_await"] = 1.0
|
118
|
-
@records[2]["ioinfo"]["sda"]["riops"] = 200.0
|
119
|
-
@records[2]["ioinfo"]["sda"]["r_await"] = 4.0
|
120
|
-
|
121
|
-
summary = @summary.make_summary(@records)
|
122
|
-
|
123
|
-
summary["ioinfo"]["sda"]["r_await"].should be_within(3.0e-6).of(3.0)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe 'make_summary method with 2 devices' do
|
128
|
-
before(:each) do
|
129
|
-
@records = @summary.read_logfile(@logfile_2devices)
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'should calculate avg. riops in total' do
|
133
|
-
@records[0]["time"] = 0.0
|
134
|
-
@records[1]["time"] = 0.5
|
135
|
-
|
136
|
-
@records[0]["ioinfo"]["total"]["riops"] = 0.0
|
137
|
-
@records[1]["ioinfo"]["total"]["riops"] = 10.0
|
138
|
-
|
139
|
-
summary = @summary.make_summary(@records)
|
140
|
-
|
141
|
-
summary["ioinfo"]["total"]["riops"].should be_within(10.0e-6).of(10.0)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
it "should respond to make_accumulation" do
|
146
|
-
@summary.should respond_to(:make_accumulation)
|
147
|
-
end
|
148
|
-
|
149
|
-
describe "make_accumulation" do
|
150
|
-
before(:each) do
|
151
|
-
@records = @summary.read_logfile(@logfile)
|
152
|
-
end
|
153
|
-
|
154
|
-
it "should return valid format" do
|
155
|
-
accum = @summary.make_accumulation(@records)
|
156
|
-
accum.should be_a Hash
|
157
|
-
accum.keys.should include "ioinfo"
|
158
|
-
# accum.keys.should include "cpuinfo"
|
159
|
-
end
|
160
|
-
|
161
|
-
it "should return nil if no ioinfo" do
|
162
|
-
@records.each do |record|
|
163
|
-
record.delete("ioinfo")
|
164
|
-
end
|
165
|
-
|
166
|
-
@summary.make_accumulation(@records).should be_nil
|
167
|
-
end
|
168
|
-
|
169
|
-
it "should return nil if only 1 record given" do
|
170
|
-
@summary.make_accumulation([@records.first]).should be_nil
|
171
|
-
end
|
172
|
-
|
173
|
-
it "should return valid IO data volume accumulation" do
|
174
|
-
@records[0]["time"] = 0.0
|
175
|
-
@records[0]["ioinfo"]["sda"]["riops"] = 0.0
|
176
|
-
@records[0]["ioinfo"]["sda"]["rsecps"] = 0.0
|
177
|
-
@records[0]["ioinfo"]["sda"]["avgrq-sz"] = 16.0
|
178
|
-
@records[1]["time"] = 2.0
|
179
|
-
@records[1]["ioinfo"]["sda"]["riops"] = 2.0
|
180
|
-
@records[1]["ioinfo"]["sda"]["rsecps"] = 2.0
|
181
|
-
@records[1]["ioinfo"]["sda"]["avgrq-sz"] = 16.0
|
182
|
-
@records[2]["time"] = 4.0
|
183
|
-
@records[2]["ioinfo"]["sda"]["riops"] = 1.0
|
184
|
-
@records[2]["ioinfo"]["sda"]["rsecps"] = 4.0
|
185
|
-
@records[2]["ioinfo"]["sda"]["avgrq-sz"] = 16.0
|
186
|
-
|
187
|
-
accum = @summary.make_accumulation(@records)
|
188
|
-
|
189
|
-
accum["ioinfo"]["sda"]["read_requests"].should be_within(6.0e-6).of(6.0)
|
190
|
-
accum["ioinfo"]["sda"]["read_bytes"].should be_within(1e-6).of(6144.0)
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
data/test/test-perfmonger.c
DELETED
@@ -1,145 +0,0 @@
|
|
1
|
-
|
2
|
-
#include "test.h"
|
3
|
-
#include <perfmonger.h>
|
4
|
-
|
5
|
-
|
6
|
-
/* global variables */
|
7
|
-
|
8
|
-
int argc;
|
9
|
-
char **argv;
|
10
|
-
|
11
|
-
/* utility function proto */
|
12
|
-
|
13
|
-
void setup_arguments(const char *arg, ...);
|
14
|
-
|
15
|
-
/* test function proto */
|
16
|
-
void test_parse_args (void);
|
17
|
-
void test_parse_args_switches(void);
|
18
|
-
|
19
|
-
/* cutter setup/teardown */
|
20
|
-
|
21
|
-
void
|
22
|
-
cut_setup(void)
|
23
|
-
{
|
24
|
-
argc = 0;
|
25
|
-
argv = NULL;
|
26
|
-
}
|
27
|
-
|
28
|
-
void
|
29
|
-
cut_teardown(void)
|
30
|
-
{
|
31
|
-
|
32
|
-
}
|
33
|
-
|
34
|
-
/* utility function bodies */
|
35
|
-
|
36
|
-
void
|
37
|
-
setup_arguments(const char *arg, ...)
|
38
|
-
{
|
39
|
-
va_list ap;
|
40
|
-
|
41
|
-
argc = 1;
|
42
|
-
argv = malloc(sizeof(char *));
|
43
|
-
argv[0] = (char *) arg;
|
44
|
-
|
45
|
-
va_start(ap, arg);
|
46
|
-
while((arg = va_arg(ap, char *)) != NULL) {
|
47
|
-
argv = realloc(argv, sizeof(char *) * (argc + 1));
|
48
|
-
argv[argc ++] = (char *) arg;
|
49
|
-
}
|
50
|
-
va_end(ap);
|
51
|
-
|
52
|
-
cut_take_memory(argv);
|
53
|
-
}
|
54
|
-
|
55
|
-
/* test function bodies */
|
56
|
-
|
57
|
-
void
|
58
|
-
test_parse_args(void)
|
59
|
-
{
|
60
|
-
option_t option;
|
61
|
-
|
62
|
-
setup_arguments("collector", NULL);
|
63
|
-
cut_assert_equal_int(0, parse_args(argc, argv, &option));
|
64
|
-
|
65
|
-
/* show help and exit */
|
66
|
-
setup_arguments("collector", "-h", NULL);
|
67
|
-
cut_assert_equal_int(-1, parse_args(argc, argv, &option));
|
68
|
-
|
69
|
-
/* check -d option and default values */
|
70
|
-
setup_arguments("collector", "-d", "/path/to/dev", NULL);
|
71
|
-
cut_assert_equal_int(0, parse_args(argc, argv, &option));
|
72
|
-
cut_assert_equal_int(1, option.nr_dev);
|
73
|
-
cut_assert_equal_string("/path/to/dev", option.dev_list[0]);
|
74
|
-
cut_assert_equal_double(1.0, 0.0001, option.interval);
|
75
|
-
cut_assert_false(option.report_cpu);
|
76
|
-
cut_assert_true(option.report_io);
|
77
|
-
cut_assert_false(option.verbose);
|
78
|
-
|
79
|
-
/* with multiple devices */
|
80
|
-
setup_arguments("collector", "-d", "/path/to/dev0", "-d", "/path/to/dev1", NULL);
|
81
|
-
cut_assert_equal_int(0, parse_args(argc, argv, &option));
|
82
|
-
cut_assert_equal_int(2, option.nr_dev);
|
83
|
-
cut_assert_equal_string("/path/to/dev0", option.dev_list[0]);
|
84
|
-
cut_assert_equal_string("/path/to/dev1", option.dev_list[1]);
|
85
|
-
cut_assert_true(option.report_io);
|
86
|
-
|
87
|
-
/* with interval in integer */
|
88
|
-
setup_arguments("collector", "-d", "/path/to/dev", "-i", "10", NULL);
|
89
|
-
cut_assert_equal_int(0, parse_args(argc, argv, &option));
|
90
|
-
cut_assert_equal_double(10.0, 0.0001, option.interval);
|
91
|
-
cut_assert_true(option.report_io);
|
92
|
-
|
93
|
-
/* with interval in floating point */
|
94
|
-
setup_arguments("collector", "-d", "/path/to/dev", "-i", "0.5", NULL);
|
95
|
-
cut_assert_equal_int(0, parse_args(argc, argv, &option));
|
96
|
-
cut_assert_equal_double(0.5, 0.0001, option.interval);
|
97
|
-
cut_assert_true(option.report_io);
|
98
|
-
|
99
|
-
/* with verbose */
|
100
|
-
setup_arguments("collector", "-d", "/path/to/dev", "-v", NULL);
|
101
|
-
cut_assert_equal_int(0, parse_args(argc, argv, &option));
|
102
|
-
cut_assert_true(option.verbose);
|
103
|
-
cut_assert_true(option.report_io);
|
104
|
-
}
|
105
|
-
|
106
|
-
void
|
107
|
-
test_parse_args_switches(void)
|
108
|
-
{
|
109
|
-
option_t option;
|
110
|
-
|
111
|
-
/* with cpu (default if no device is specified) */
|
112
|
-
setup_arguments("collector", NULL);
|
113
|
-
cut_assert_equal_int(0, parse_args(argc, argv, &option));
|
114
|
-
cut_assert_true (option.report_cpu);
|
115
|
-
cut_assert_false(option.report_io);
|
116
|
-
cut_assert_false(option.report_ctxsw);
|
117
|
-
|
118
|
-
/* without cpu if some devices are specified */
|
119
|
-
setup_arguments("collector", "-d", "/path/to/dev", NULL);
|
120
|
-
cut_assert_equal_int(0, parse_args(argc, argv, &option));
|
121
|
-
cut_assert_false(option.report_cpu);
|
122
|
-
cut_assert_true (option.report_io);
|
123
|
-
cut_assert_false(option.report_ctxsw);
|
124
|
-
|
125
|
-
/* with cpu if explicitly specified by -C */
|
126
|
-
setup_arguments("collector", "-C", "-d", "/path/to/dev", NULL);
|
127
|
-
cut_assert_equal_int(0, parse_args(argc, argv, &option));
|
128
|
-
cut_assert_true (option.report_cpu);
|
129
|
-
cut_assert_true (option.report_io);
|
130
|
-
cut_assert_false(option.report_ctxsw);
|
131
|
-
|
132
|
-
/* without cpu if context switch option is specified */
|
133
|
-
setup_arguments("collector", "-S", NULL);
|
134
|
-
cut_assert_equal_int(0, parse_args(argc, argv, &option));
|
135
|
-
cut_assert_false(option.report_cpu);
|
136
|
-
cut_assert_false(option.report_io);
|
137
|
-
cut_assert_true (option.report_ctxsw);
|
138
|
-
|
139
|
-
/* with cpu if explicitly specified by -C */
|
140
|
-
setup_arguments("collector", "-C", "-S", NULL);
|
141
|
-
cut_assert_equal_int(0, parse_args(argc, argv, &option));
|
142
|
-
cut_assert_true (option.report_cpu);
|
143
|
-
cut_assert_false(option.report_io);
|
144
|
-
cut_assert_true (option.report_ctxsw);
|
145
|
-
}
|