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