sys-filesystem 1.4.3 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +14 -0
- data/README.md +1 -1
- data/Rakefile +13 -0
- data/lib/sys/filesystem.rb +17 -16
- data/lib/sys/unix/sys/filesystem/constants.rb +4 -0
- data/lib/sys/unix/sys/filesystem/functions.rb +19 -23
- data/lib/sys/unix/sys/filesystem/structs.rb +138 -91
- data/lib/sys/unix/sys/filesystem.rb +67 -52
- data/lib/sys/windows/sys/filesystem/functions.rb +1 -0
- data/lib/sys/windows/sys/filesystem/helper.rb +3 -0
- data/lib/sys/windows/sys/filesystem.rb +13 -11
- data/lib/sys-filesystem.rb +2 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/sys_filesystem_shared.rb +14 -0
- data/spec/sys_filesystem_unix_spec.rb +266 -135
- data/spec/sys_filesystem_windows_spec.rb +263 -151
- data/sys-filesystem.gemspec +15 -7
- data.tar.gz.sig +0 -0
- metadata +34 -3
- metadata.gz.sig +2 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
####################################################################
|
|
2
4
|
# sys_filesystem_unix_spec.rb
|
|
3
5
|
#
|
|
@@ -9,388 +11,517 @@ require 'sys-filesystem'
|
|
|
9
11
|
require 'pathname'
|
|
10
12
|
|
|
11
13
|
RSpec.describe Sys::Filesystem, :unix => true do
|
|
12
|
-
let(:solaris) { RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i }
|
|
13
14
|
let(:linux) { RbConfig::CONFIG['host_os'] =~ /linux/i }
|
|
14
|
-
let(:bsd) { RbConfig::CONFIG['host_os'] =~ /bsd/i }
|
|
15
|
+
let(:bsd) { RbConfig::CONFIG['host_os'] =~ /bsd|dragonfly/i }
|
|
15
16
|
let(:darwin) { RbConfig::CONFIG['host_os'] =~ /mac|darwin/i }
|
|
16
17
|
let(:root) { '/' }
|
|
17
18
|
|
|
18
19
|
before do
|
|
19
|
-
@stat =
|
|
20
|
+
@stat = described_class.stat(root)
|
|
20
21
|
@size = 58720256
|
|
21
22
|
end
|
|
22
23
|
|
|
23
|
-
example
|
|
24
|
-
expect(Sys::Filesystem::VERSION).to eq('1.4.3')
|
|
25
|
-
expect(Sys::Filesystem::VERSION).to be_frozen
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
example "you cannot instantiate an instance" do
|
|
29
|
-
expect{ described_class.new }.to raise_error(NoMethodError)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
example "stat path works as expected" do
|
|
24
|
+
example 'stat path works as expected' do
|
|
33
25
|
expect(@stat).to respond_to(:path)
|
|
34
26
|
expect(@stat.path).to eq(root)
|
|
35
27
|
end
|
|
36
28
|
|
|
37
|
-
example
|
|
29
|
+
example 'stat block_size works as expected' do
|
|
38
30
|
expect(@stat).to respond_to(:block_size)
|
|
39
|
-
expect(@stat.block_size).to
|
|
31
|
+
expect(@stat.block_size).to be_a(Numeric)
|
|
40
32
|
end
|
|
41
33
|
|
|
42
|
-
example
|
|
34
|
+
example 'stat fragment_size works as expected' do
|
|
43
35
|
expect(@stat).to respond_to(:fragment_size)
|
|
44
|
-
expect(@stat.fragment_size).to
|
|
36
|
+
expect(@stat.fragment_size).to be_a(Numeric)
|
|
45
37
|
end
|
|
46
38
|
|
|
47
|
-
example
|
|
39
|
+
example 'stat fragment_size is a plausible value' do
|
|
48
40
|
expect(@stat.fragment_size).to be >= 512
|
|
49
|
-
expect(@stat.fragment_size).to be <=
|
|
41
|
+
expect(@stat.fragment_size).to be <= 2**16
|
|
42
|
+
expect(@stat.fragment_size).to be <= @stat.block_size
|
|
50
43
|
end
|
|
51
44
|
|
|
52
|
-
example
|
|
45
|
+
example 'stat blocks works as expected' do
|
|
53
46
|
expect(@stat).to respond_to(:blocks)
|
|
54
|
-
expect(@stat.blocks).to
|
|
47
|
+
expect(@stat.blocks).to be_a(Numeric)
|
|
55
48
|
end
|
|
56
49
|
|
|
57
|
-
example
|
|
50
|
+
example 'stat blocks_free works as expected' do
|
|
58
51
|
expect(@stat).to respond_to(:blocks_free)
|
|
59
|
-
expect(@stat.blocks_free).to
|
|
52
|
+
expect(@stat.blocks_free).to be_a(Numeric)
|
|
60
53
|
end
|
|
61
54
|
|
|
62
|
-
example
|
|
55
|
+
example 'stat blocks_available works as expected' do
|
|
63
56
|
expect(@stat).to respond_to(:blocks_available)
|
|
64
|
-
expect(@stat.blocks_available).to
|
|
57
|
+
expect(@stat.blocks_available).to be_a(Numeric)
|
|
65
58
|
end
|
|
66
59
|
|
|
67
|
-
example
|
|
60
|
+
example 'stat files works as expected' do
|
|
68
61
|
expect(@stat).to respond_to(:files)
|
|
69
|
-
expect(@stat.files).to
|
|
62
|
+
expect(@stat.files).to be_a(Numeric)
|
|
70
63
|
end
|
|
71
64
|
|
|
72
|
-
example
|
|
65
|
+
example 'stat inodes is an alias for files' do
|
|
73
66
|
expect(@stat).to respond_to(:inodes)
|
|
74
67
|
expect(@stat.method(:inodes)).to eq(@stat.method(:files))
|
|
75
68
|
end
|
|
76
69
|
|
|
77
|
-
example
|
|
70
|
+
example 'stat files tree works as expected' do
|
|
78
71
|
expect(@stat).to respond_to(:files_free)
|
|
79
|
-
expect(@stat.files_free).to
|
|
72
|
+
expect(@stat.files_free).to be_a(Numeric)
|
|
80
73
|
end
|
|
81
74
|
|
|
82
|
-
example
|
|
75
|
+
example 'stat inodes_free is an alias for files_free' do
|
|
83
76
|
expect(@stat).to respond_to(:inodes_free)
|
|
84
77
|
expect(@stat.method(:inodes_free)).to eq(@stat.method(:files_free))
|
|
85
78
|
end
|
|
86
79
|
|
|
87
|
-
example
|
|
80
|
+
example 'stat files_available works as expected' do
|
|
88
81
|
expect(@stat).to respond_to(:files_available)
|
|
89
|
-
expect(@stat.files_available).to
|
|
82
|
+
expect(@stat.files_available).to be_a(Numeric)
|
|
90
83
|
end
|
|
91
84
|
|
|
92
|
-
example
|
|
85
|
+
example 'stat inodes_available is an alias for files_available' do
|
|
93
86
|
expect(@stat).to respond_to(:inodes_available)
|
|
94
87
|
expect(@stat.method(:inodes_available)).to eq(@stat.method(:files_available))
|
|
95
88
|
end
|
|
96
89
|
|
|
97
|
-
example
|
|
90
|
+
example 'stat filesystem_id works as expected' do
|
|
98
91
|
expect(@stat).to respond_to(:filesystem_id)
|
|
99
|
-
expect(@stat.filesystem_id).to
|
|
92
|
+
expect(@stat.filesystem_id).to be_a(Integer)
|
|
100
93
|
end
|
|
101
94
|
|
|
102
|
-
example
|
|
95
|
+
example 'stat flags works as expected' do
|
|
103
96
|
expect(@stat).to respond_to(:flags)
|
|
104
|
-
expect(@stat.flags).to
|
|
97
|
+
expect(@stat.flags).to be_a(Numeric)
|
|
105
98
|
end
|
|
106
99
|
|
|
107
|
-
example
|
|
100
|
+
example 'stat name_max works as expected' do
|
|
108
101
|
expect(@stat).to respond_to(:name_max)
|
|
109
|
-
expect(@stat.name_max).to
|
|
102
|
+
expect(@stat.name_max).to be_a(Numeric)
|
|
110
103
|
end
|
|
111
104
|
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
context 'dragonfly', :dragonfly do
|
|
106
|
+
example 'owner works as expected' do
|
|
107
|
+
expect(@stat).to respond_to(:owner)
|
|
108
|
+
expect(@stat.owner).to be_a(Numeric)
|
|
109
|
+
end
|
|
114
110
|
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
example 'filesystem_type works as expected' do
|
|
112
|
+
expect(@stat).to respond_to(:filesystem_type)
|
|
113
|
+
expect(@stat.filesystem_type).to be_a(Numeric)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
example 'sync_reads works as expected' do
|
|
117
|
+
expect(@stat).to respond_to(:sync_reads)
|
|
118
|
+
expect(@stat.sync_reads).to be_a(Numeric)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
example 'async_reads works as expected' do
|
|
122
|
+
expect(@stat).to respond_to(:async_reads)
|
|
123
|
+
expect(@stat.async_reads).to be_a(Numeric)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
example 'sync_writes works as expected' do
|
|
127
|
+
expect(@stat).to respond_to(:sync_writes)
|
|
128
|
+
expect(@stat.sync_writes).to be_a(Numeric)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
example 'async_writes works as expected' do
|
|
132
|
+
expect(@stat).to respond_to(:async_writes)
|
|
133
|
+
expect(@stat.async_writes).to be_a(Numeric)
|
|
134
|
+
end
|
|
117
135
|
end
|
|
118
136
|
|
|
119
|
-
example
|
|
137
|
+
example 'stat constants are defined' do
|
|
120
138
|
expect(Sys::Filesystem::Stat::RDONLY).not_to be_nil
|
|
121
139
|
expect(Sys::Filesystem::Stat::NOSUID).not_to be_nil
|
|
122
140
|
end
|
|
123
141
|
|
|
124
|
-
example
|
|
125
|
-
skip "NOTRUNC test skipped except on Solaris" unless solaris
|
|
126
|
-
expect(Sys::Filesystem::Stat::NOTRUNC).not_to be_nil
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
example "stat bytes_total works as expected" do
|
|
142
|
+
example 'stat bytes_total works as expected' do
|
|
130
143
|
expect(@stat).to respond_to(:bytes_total)
|
|
131
|
-
expect(@stat.bytes_total).to
|
|
144
|
+
expect(@stat.bytes_total).to be_a(Numeric)
|
|
132
145
|
end
|
|
133
146
|
|
|
134
|
-
example
|
|
147
|
+
example 'stat bytes_free works as expected' do
|
|
135
148
|
expect(@stat).to respond_to(:bytes_free)
|
|
136
|
-
expect(@stat.bytes_free).to
|
|
149
|
+
expect(@stat.bytes_free).to be_a(Numeric)
|
|
137
150
|
expect(@stat.blocks_free * @stat.fragment_size).to eq(@stat.bytes_free)
|
|
138
151
|
end
|
|
139
152
|
|
|
140
|
-
example
|
|
153
|
+
example 'stat bytes_available works as expected' do
|
|
141
154
|
expect(@stat).to respond_to(:bytes_available)
|
|
142
|
-
expect(@stat.bytes_available).to
|
|
155
|
+
expect(@stat.bytes_available).to be_a(Numeric)
|
|
143
156
|
expect(@stat.blocks_available * @stat.fragment_size).to eq(@stat.bytes_available)
|
|
144
157
|
end
|
|
145
158
|
|
|
146
|
-
example
|
|
159
|
+
example 'stat bytes works as expected' do
|
|
147
160
|
expect(@stat).to respond_to(:bytes_used)
|
|
148
|
-
expect(@stat.bytes_used).to
|
|
161
|
+
expect(@stat.bytes_used).to be_a(Numeric)
|
|
149
162
|
end
|
|
150
163
|
|
|
151
|
-
example
|
|
164
|
+
example 'stat percent_used works as expected' do
|
|
152
165
|
expect(@stat).to respond_to(:percent_used)
|
|
153
|
-
expect(@stat.percent_used).to
|
|
166
|
+
expect(@stat.percent_used).to be_a(Float)
|
|
154
167
|
end
|
|
155
168
|
|
|
156
|
-
example
|
|
157
|
-
expect{
|
|
169
|
+
example 'stat singleton method requires an argument' do
|
|
170
|
+
expect{ described_class.stat }.to raise_error(ArgumentError)
|
|
158
171
|
end
|
|
159
172
|
|
|
160
|
-
example
|
|
173
|
+
example 'stat case_insensitive method works as expected' do
|
|
161
174
|
expected = darwin ? true : false
|
|
162
175
|
expect(@stat.case_insensitive?).to eq(expected)
|
|
163
|
-
expect(
|
|
176
|
+
expect(described_class.stat(Dir.home).case_insensitive?).to eq(expected)
|
|
164
177
|
end
|
|
165
178
|
|
|
166
|
-
example
|
|
179
|
+
example 'stat case_sensitive method works as expected' do
|
|
167
180
|
expected = darwin ? false : true
|
|
168
181
|
expect(@stat.case_sensitive?).to eq(expected)
|
|
169
|
-
expect(
|
|
182
|
+
expect(described_class.stat(Dir.home).case_sensitive?).to eq(expected)
|
|
170
183
|
end
|
|
171
184
|
|
|
172
|
-
example
|
|
185
|
+
example 'numeric helper methods are defined' do
|
|
173
186
|
expect(@size).to respond_to(:to_kb)
|
|
174
187
|
expect(@size).to respond_to(:to_mb)
|
|
175
188
|
expect(@size).to respond_to(:to_gb)
|
|
176
189
|
expect(@size).to respond_to(:to_tb)
|
|
177
190
|
end
|
|
178
191
|
|
|
179
|
-
example
|
|
192
|
+
example 'to_kb works as expected' do
|
|
180
193
|
expect(@size.to_kb).to eq(57344)
|
|
181
194
|
end
|
|
182
195
|
|
|
183
|
-
example
|
|
196
|
+
example 'to_mb works as expected' do
|
|
184
197
|
expect(@size.to_mb).to eq(56)
|
|
185
198
|
end
|
|
186
199
|
|
|
187
|
-
example
|
|
200
|
+
example 'to_gb works as expected' do
|
|
188
201
|
expect(@size.to_gb).to eq(0)
|
|
189
202
|
end
|
|
190
203
|
|
|
191
|
-
context
|
|
204
|
+
context 'Filesystem.stat(Pathname)' do
|
|
192
205
|
before do
|
|
193
|
-
@stat_pathname =
|
|
206
|
+
@stat_pathname = described_class.stat(Pathname.new(root))
|
|
194
207
|
end
|
|
195
208
|
|
|
196
|
-
example
|
|
209
|
+
example 'class returns expected value with pathname argument' do
|
|
197
210
|
expect(@stat_pathname.class).to eq(@stat.class)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
example 'path returns expected value with pathname argument' do
|
|
198
214
|
expect(@stat_pathname.path).to eq(@stat.path)
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
example 'block_size returns expected value with pathname argument' do
|
|
199
218
|
expect(@stat_pathname.block_size).to eq(@stat.block_size)
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
example 'fragment_size returns expected value with pathname argument' do
|
|
200
222
|
expect(@stat_pathname.fragment_size).to eq(@stat.fragment_size)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
example 'blocks returns expected value with pathname argument' do
|
|
201
226
|
expect(@stat_pathname.blocks).to eq(@stat.blocks)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
example 'blocks_free returns expected value with pathname argument' do
|
|
202
230
|
expect(@stat_pathname.blocks_free).to eq(@stat.blocks_free)
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
example 'blocks_available returns expected value with pathname argument' do
|
|
203
234
|
expect(@stat_pathname.blocks_available).to eq(@stat.blocks_available)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
example 'files returns expected value with pathname argument' do
|
|
204
238
|
expect(@stat_pathname.files).to eq(@stat.files)
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
example 'files_free returns expected value with pathname argument' do
|
|
205
242
|
expect(@stat_pathname.files_free).to eq(@stat.files_free)
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
example 'files_available returns expected value with pathname argument' do
|
|
206
246
|
expect(@stat_pathname.files_available).to eq(@stat.files_available)
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
example 'filesystem_id returns expected value with pathname argument' do
|
|
207
250
|
expect(@stat_pathname.filesystem_id).to eq(@stat.filesystem_id)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
example 'flags returns expected value with pathname argument' do
|
|
208
254
|
expect(@stat_pathname.flags).to eq(@stat.flags)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
example 'name_max returns expected value with pathname argument' do
|
|
209
258
|
expect(@stat_pathname.name_max).to eq(@stat.name_max)
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
example 'base_type returns expected value with pathname argument' do
|
|
210
262
|
expect(@stat_pathname.base_type).to eq(@stat.base_type)
|
|
211
263
|
end
|
|
212
264
|
end
|
|
213
265
|
|
|
214
|
-
context
|
|
266
|
+
context 'Filesystem.stat(File)' do
|
|
215
267
|
before do
|
|
216
|
-
@stat_file = File.open(root){ |file|
|
|
268
|
+
@stat_file = File.open(root){ |file| described_class.stat(file) }
|
|
217
269
|
end
|
|
218
270
|
|
|
219
|
-
example
|
|
271
|
+
example 'class returns expected value with file argument' do
|
|
220
272
|
expect(@stat_file.class).to eq(@stat.class)
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
example 'path returns expected value with file argument' do
|
|
221
276
|
expect(@stat_file.path).to eq(@stat.path)
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
example 'block_size returns expected value with file argument' do
|
|
222
280
|
expect(@stat_file.block_size).to eq(@stat.block_size)
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
example 'fragment_size returns expected value with file argument' do
|
|
223
284
|
expect(@stat_file.fragment_size).to eq(@stat.fragment_size)
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
example 'blocks returns expected value with file argument' do
|
|
224
288
|
expect(@stat_file.blocks).to eq(@stat.blocks)
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
example 'blocks_free returns expected value with file argument' do
|
|
225
292
|
expect(@stat_file.blocks_free).to eq(@stat.blocks_free)
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
example 'blocks_available returns expected value with file argument' do
|
|
226
296
|
expect(@stat_file.blocks_available).to eq(@stat.blocks_available)
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
example 'files returns expected value with file argument' do
|
|
227
300
|
expect(@stat_file.files).to eq(@stat.files)
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
example 'files_free returns expected value with file argument' do
|
|
228
304
|
expect(@stat_file.files_free).to eq(@stat.files_free)
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
example 'files_available returns expected value with file argument' do
|
|
229
308
|
expect(@stat_file.files_available).to eq(@stat.files_available)
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
example 'filesystem_id returns expected value with file argument' do
|
|
230
312
|
expect(@stat_file.filesystem_id).to eq(@stat.filesystem_id)
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
example 'flags returns expected value with file argument' do
|
|
231
316
|
expect(@stat_file.flags).to eq(@stat.flags)
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
example 'name_max returns expected value with file argument' do
|
|
232
320
|
expect(@stat_file.name_max).to eq(@stat.name_max)
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
example 'base_type returns expected value with file argument' do
|
|
233
324
|
expect(@stat_file.base_type).to eq(@stat.base_type)
|
|
234
325
|
end
|
|
235
326
|
end
|
|
236
327
|
|
|
237
|
-
context
|
|
328
|
+
context 'Filesystem.stat(Dir)' do
|
|
238
329
|
before do
|
|
239
|
-
@stat_dir = Dir.open(root){ |dir|
|
|
330
|
+
@stat_dir = Dir.open(root){ |dir| described_class.stat(dir) }
|
|
240
331
|
end
|
|
241
332
|
|
|
242
|
-
example
|
|
333
|
+
example 'class returns expected value with Dir argument' do
|
|
243
334
|
expect(@stat_dir.class).to eq(@stat.class)
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
example 'path returns expected value with Dir argument' do
|
|
244
338
|
expect(@stat_dir.path).to eq(@stat.path)
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
example 'block_size returns expected value with Dir argument' do
|
|
245
342
|
expect(@stat_dir.block_size).to eq(@stat.block_size)
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
example 'fragment_size returns expected value with Dir argument' do
|
|
246
346
|
expect(@stat_dir.fragment_size).to eq(@stat.fragment_size)
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
example 'blocks returns expected value with Dir argument' do
|
|
247
350
|
expect(@stat_dir.blocks).to eq(@stat.blocks)
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
example 'blocks_free returns expected value with Dir argument' do
|
|
248
354
|
expect(@stat_dir.blocks_free).to eq(@stat.blocks_free)
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
example 'blocks_available returns expected value with Dir argument' do
|
|
249
358
|
expect(@stat_dir.blocks_available).to eq(@stat.blocks_available)
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
example 'files returns expected value with Dir argument' do
|
|
250
362
|
expect(@stat_dir.files).to eq(@stat.files)
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
example 'files_free returns expected value with Dir argument' do
|
|
251
366
|
expect(@stat_dir.files_free).to eq(@stat.files_free)
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
example 'files_available returns expected value with Dir argument' do
|
|
252
370
|
expect(@stat_dir.files_available).to eq(@stat.files_available)
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
example 'filesystem_id returns expected value with Dir argument' do
|
|
253
374
|
expect(@stat_dir.filesystem_id).to eq(@stat.filesystem_id)
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
example 'flags returns expected value with Dir argument' do
|
|
254
378
|
expect(@stat_dir.flags).to eq(@stat.flags)
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
example 'name_max returns expected value with Dir argument' do
|
|
255
382
|
expect(@stat_dir.name_max).to eq(@stat.name_max)
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
example 'base_type returns expected value with Dir argument' do
|
|
256
386
|
expect(@stat_dir.base_type).to eq(@stat.base_type)
|
|
257
387
|
end
|
|
258
388
|
end
|
|
259
389
|
|
|
260
|
-
context
|
|
261
|
-
let(:mount){
|
|
390
|
+
context 'Filesystem::Mount' do
|
|
391
|
+
let(:mount){ described_class.mounts[0] }
|
|
262
392
|
|
|
263
393
|
before do
|
|
264
394
|
@array = []
|
|
265
395
|
end
|
|
266
396
|
|
|
267
|
-
example
|
|
268
|
-
expect{ @array =
|
|
269
|
-
expect(@array[0]).to
|
|
397
|
+
example 'mounts singleton method works as expected without a block' do
|
|
398
|
+
expect{ @array = described_class.mounts }.not_to raise_error
|
|
399
|
+
expect(@array[0]).to be_a(Sys::Filesystem::Mount)
|
|
270
400
|
end
|
|
271
401
|
|
|
272
|
-
example
|
|
273
|
-
expect{
|
|
274
|
-
expect(@array[0]).to
|
|
402
|
+
example 'mounts singleton method works as expected with a block' do
|
|
403
|
+
expect{ described_class.mounts{ |m| @array << m } }.not_to raise_error
|
|
404
|
+
expect(@array[0]).to be_a(Sys::Filesystem::Mount)
|
|
275
405
|
end
|
|
276
406
|
|
|
277
|
-
example
|
|
278
|
-
expect{ 1000.times{ @array =
|
|
407
|
+
example 'calling the mounts singleton method a large number of times does not cause issues' do
|
|
408
|
+
expect{ 1000.times{ @array = described_class.mounts } }.not_to raise_error
|
|
279
409
|
end
|
|
280
410
|
|
|
281
|
-
example
|
|
411
|
+
example 'mount name method works as expected' do
|
|
282
412
|
expect(mount).to respond_to(:name)
|
|
283
|
-
expect(mount.name).to
|
|
413
|
+
expect(mount.name).to be_a(String)
|
|
284
414
|
end
|
|
285
415
|
|
|
286
|
-
example
|
|
416
|
+
example 'mount fsname is an alias for name' do
|
|
287
417
|
expect(mount).to respond_to(:fsname)
|
|
288
418
|
expect(mount.method(:fsname)).to eq(mount.method(:name))
|
|
289
419
|
end
|
|
290
420
|
|
|
291
|
-
example
|
|
421
|
+
example 'mount point method works as expected' do
|
|
292
422
|
expect(mount).to respond_to(:mount_point)
|
|
293
|
-
expect(mount.mount_point).to
|
|
423
|
+
expect(mount.mount_point).to be_a(String)
|
|
294
424
|
end
|
|
295
425
|
|
|
296
|
-
example
|
|
426
|
+
example 'mount dir is an alias for mount_point' do
|
|
297
427
|
expect(mount).to respond_to(:dir)
|
|
298
428
|
expect(mount.method(:dir)).to eq(mount.method(:mount_point))
|
|
299
429
|
end
|
|
300
430
|
|
|
301
|
-
example
|
|
431
|
+
example 'mount mount_type works as expected' do
|
|
302
432
|
expect(mount).to respond_to(:mount_type)
|
|
303
|
-
expect(mount.mount_type).to
|
|
433
|
+
expect(mount.mount_type).to be_a(String)
|
|
304
434
|
end
|
|
305
435
|
|
|
306
|
-
example
|
|
436
|
+
example 'mount options works as expected' do
|
|
307
437
|
expect(mount).to respond_to(:options)
|
|
308
|
-
expect(mount.options).to
|
|
438
|
+
expect(mount.options).to be_a(String)
|
|
309
439
|
end
|
|
310
440
|
|
|
311
|
-
example
|
|
441
|
+
example 'mount opts is an alias for options' do
|
|
312
442
|
expect(mount).to respond_to(:opts)
|
|
313
443
|
expect(mount.method(:opts)).to eq(mount.method(:options))
|
|
314
444
|
end
|
|
315
445
|
|
|
316
|
-
|
|
446
|
+
# This method may be removed
|
|
447
|
+
example 'mount time works as expected' do
|
|
317
448
|
expect(mount).to respond_to(:mount_time)
|
|
318
|
-
|
|
319
|
-
if solaris
|
|
320
|
-
expect(mount.mount_time).to be_kind_of(Time)
|
|
321
|
-
else
|
|
322
|
-
expect(mount.mount_time).to be_nil
|
|
323
|
-
end
|
|
449
|
+
expect(mount.mount_time).to be_nil
|
|
324
450
|
end
|
|
325
451
|
|
|
326
|
-
example
|
|
452
|
+
example 'mount dump_frequency works as expected' do
|
|
327
453
|
msg = 'dump_frequency test skipped on this platform'
|
|
328
|
-
skip msg if
|
|
454
|
+
skip msg if bsd || darwin
|
|
329
455
|
expect(mount).to respond_to(:dump_frequency)
|
|
330
|
-
expect(mount.dump_frequency).to
|
|
456
|
+
expect(mount.dump_frequency).to be_a(Numeric)
|
|
331
457
|
end
|
|
332
458
|
|
|
333
|
-
example
|
|
459
|
+
example 'mount freq is an alias for dump_frequency' do
|
|
334
460
|
expect(mount).to respond_to(:freq)
|
|
335
461
|
expect(mount.method(:freq)).to eq(mount.method(:dump_frequency))
|
|
336
462
|
end
|
|
337
463
|
|
|
338
|
-
example
|
|
464
|
+
example 'mount pass_number works as expected' do
|
|
339
465
|
msg = 'pass_number test skipped on this platform'
|
|
340
|
-
skip msg if
|
|
466
|
+
skip msg if bsd || darwin
|
|
341
467
|
expect(mount).to respond_to(:pass_number)
|
|
342
|
-
expect(mount.pass_number).to
|
|
468
|
+
expect(mount.pass_number).to be_a(Numeric)
|
|
343
469
|
end
|
|
344
470
|
|
|
345
|
-
example
|
|
471
|
+
example 'mount passno is an alias for pass_number' do
|
|
346
472
|
expect(mount).to respond_to(:passno)
|
|
347
473
|
expect(mount.method(:passno)).to eq(mount.method(:pass_number))
|
|
348
474
|
end
|
|
349
475
|
|
|
350
|
-
example
|
|
351
|
-
expect(
|
|
352
|
-
expect{
|
|
353
|
-
expect(
|
|
476
|
+
example 'mount_point singleton method works as expected' do
|
|
477
|
+
expect(described_class).to respond_to(:mount_point)
|
|
478
|
+
expect{ described_class.mount_point(Dir.pwd) }.not_to raise_error
|
|
479
|
+
expect(described_class.mount_point(Dir.pwd)).to be_a(String)
|
|
354
480
|
end
|
|
355
481
|
|
|
356
|
-
example
|
|
357
|
-
expect(
|
|
482
|
+
example 'mount singleton method is defined' do
|
|
483
|
+
expect(described_class).to respond_to(:mount)
|
|
358
484
|
end
|
|
359
485
|
|
|
360
|
-
example
|
|
361
|
-
expect(
|
|
486
|
+
example 'umount singleton method is defined' do
|
|
487
|
+
expect(described_class).to respond_to(:umount)
|
|
362
488
|
end
|
|
363
489
|
end
|
|
364
490
|
|
|
365
|
-
context
|
|
491
|
+
context 'FFI' do
|
|
366
492
|
before(:context) do
|
|
367
493
|
require 'mkmf-lite'
|
|
368
494
|
end
|
|
369
495
|
|
|
370
496
|
let(:dummy) { Class.new { extend Mkmf::Lite } }
|
|
371
497
|
|
|
372
|
-
example
|
|
373
|
-
expect(
|
|
374
|
-
expect(
|
|
498
|
+
example 'ffi functions are private' do
|
|
499
|
+
expect(described_class.methods.include?('statvfs')).to be false
|
|
500
|
+
expect(described_class.methods.include?('strerror')).to be false
|
|
375
501
|
end
|
|
376
502
|
|
|
377
|
-
example
|
|
503
|
+
example 'statfs struct is expected size' do
|
|
378
504
|
header = bsd || darwin ? 'sys/mount.h' : 'sys/statfs.h'
|
|
379
505
|
expect(Sys::Filesystem::Structs::Statfs.size).to eq(dummy.check_sizeof('struct statfs', header))
|
|
380
506
|
end
|
|
381
507
|
|
|
382
|
-
example
|
|
508
|
+
example 'statvfs struct is expected size' do
|
|
383
509
|
expect(Sys::Filesystem::Structs::Statvfs.size).to eq(dummy.check_sizeof('struct statvfs', 'sys/statvfs.h'))
|
|
384
510
|
end
|
|
385
511
|
|
|
386
|
-
example
|
|
387
|
-
skip
|
|
388
|
-
expect(Sys::Filesystem::Structs::
|
|
512
|
+
example 'mntent struct is expected size' do
|
|
513
|
+
skip 'mnttab test skipped except on Linux' unless linux
|
|
514
|
+
expect(Sys::Filesystem::Structs::Mntent.size).to eq(dummy.check_sizeof('struct mntent', 'mntent.h'))
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
example 'a failed statvfs call behaves as expected' do
|
|
518
|
+
msg = 'statvfs() function failed: No such file or directory'
|
|
519
|
+
expect{ described_class.stat('/whatever') }.to raise_error(Sys::Filesystem::Error, msg)
|
|
389
520
|
end
|
|
390
521
|
|
|
391
|
-
example
|
|
392
|
-
|
|
393
|
-
expect(Sys::Filesystem::
|
|
522
|
+
example 'statvfs alias is used for statvfs64' do
|
|
523
|
+
expect(Sys::Filesystem::Functions.attached_functions[:statvfs]).to be_a(FFI::Function)
|
|
524
|
+
expect(Sys::Filesystem::Functions.attached_functions[:statvfs64]).to be_nil
|
|
394
525
|
end
|
|
395
526
|
end
|
|
396
527
|
end
|