sys-filesystem 1.1.1 → 1.5.1
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 +6 -14
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +184 -0
- data/Gemfile +2 -0
- data/LICENSE +177 -0
- data/MANIFEST.md +23 -0
- data/README.md +92 -0
- data/Rakefile +32 -27
- data/certs/djberg96_pub.pem +26 -0
- data/examples/example_mount.rb +73 -0
- data/examples/example_stat.rb +2 -0
- data/lib/sys/filesystem.rb +81 -2
- data/lib/sys/unix/sys/filesystem/constants.rb +74 -0
- data/lib/sys/unix/sys/filesystem/functions.rb +65 -0
- data/lib/sys/unix/sys/filesystem/structs.rb +272 -0
- data/lib/sys/unix/sys/filesystem.rb +462 -0
- data/lib/sys/windows/sys/filesystem/functions.rb +40 -0
- data/lib/sys/windows/sys/filesystem/helper.rb +10 -0
- data/lib/{windows → sys/windows}/sys/filesystem.rb +164 -109
- data/lib/sys-filesystem.rb +3 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/sys_filesystem_shared.rb +14 -0
- data/spec/sys_filesystem_unix_spec.rb +527 -0
- data/spec/sys_filesystem_windows_spec.rb +460 -0
- data/sys-filesystem.gemspec +32 -16
- data.tar.gz.sig +0 -0
- metadata +126 -43
- metadata.gz.sig +0 -0
- data/CHANGES +0 -58
- data/MANIFEST +0 -12
- data/README +0 -81
- data/lib/unix/sys/filesystem.rb +0 -566
- data/lib/windows/sys/filesystem/functions.rb +0 -36
- data/lib/windows/sys/filesystem/helper.rb +0 -7
- data/lib/windows/sys/filesystem/structs.rb +0 -0
- data/test/test_sys_filesystem.rb +0 -7
- data/test/test_sys_filesystem_unix.rb +0 -257
- data/test/test_sys_filesystem_windows.rb +0 -222
- /data/lib/{windows → sys/windows}/sys/filesystem/constants.rb +0 -0
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
####################################################################
|
|
4
|
+
# sys_filesystem_unix_spec.rb
|
|
5
|
+
#
|
|
6
|
+
# Specs for the Sys::Filesystem.stat method and related stuff.
|
|
7
|
+
# This test suite should be run via the 'rake spec' task.
|
|
8
|
+
####################################################################
|
|
9
|
+
require 'spec_helper'
|
|
10
|
+
require 'sys-filesystem'
|
|
11
|
+
require 'pathname'
|
|
12
|
+
|
|
13
|
+
RSpec.describe Sys::Filesystem, :unix do
|
|
14
|
+
let(:linux) { RbConfig::CONFIG['host_os'] =~ /linux/i }
|
|
15
|
+
let(:bsd) { RbConfig::CONFIG['host_os'] =~ /bsd|dragonfly/i }
|
|
16
|
+
let(:darwin) { RbConfig::CONFIG['host_os'] =~ /mac|darwin/i }
|
|
17
|
+
let(:root) { '/' }
|
|
18
|
+
|
|
19
|
+
before do
|
|
20
|
+
@stat = described_class.stat(root)
|
|
21
|
+
@size = 58720256
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
example 'stat path works as expected' do
|
|
25
|
+
expect(@stat).to respond_to(:path)
|
|
26
|
+
expect(@stat.path).to eq(root)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
example 'stat block_size works as expected' do
|
|
30
|
+
expect(@stat).to respond_to(:block_size)
|
|
31
|
+
expect(@stat.block_size).to be_a(Numeric)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
example 'stat fragment_size works as expected' do
|
|
35
|
+
expect(@stat).to respond_to(:fragment_size)
|
|
36
|
+
expect(@stat.fragment_size).to be_a(Numeric)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
example 'stat fragment_size is a plausible value' do
|
|
40
|
+
expect(@stat.fragment_size).to be >= 512
|
|
41
|
+
expect(@stat.fragment_size).to be <= 2**16
|
|
42
|
+
expect(@stat.fragment_size).to be <= @stat.block_size
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
example 'stat blocks works as expected' do
|
|
46
|
+
expect(@stat).to respond_to(:blocks)
|
|
47
|
+
expect(@stat.blocks).to be_a(Numeric)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
example 'stat blocks_free works as expected' do
|
|
51
|
+
expect(@stat).to respond_to(:blocks_free)
|
|
52
|
+
expect(@stat.blocks_free).to be_a(Numeric)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
example 'stat blocks_available works as expected' do
|
|
56
|
+
expect(@stat).to respond_to(:blocks_available)
|
|
57
|
+
expect(@stat.blocks_available).to be_a(Numeric)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
example 'stat files works as expected' do
|
|
61
|
+
expect(@stat).to respond_to(:files)
|
|
62
|
+
expect(@stat.files).to be_a(Numeric)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
example 'stat inodes is an alias for files' do
|
|
66
|
+
expect(@stat).to respond_to(:inodes)
|
|
67
|
+
expect(@stat.method(:inodes)).to eq(@stat.method(:files))
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
example 'stat files tree works as expected' do
|
|
71
|
+
expect(@stat).to respond_to(:files_free)
|
|
72
|
+
expect(@stat.files_free).to be_a(Numeric)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
example 'stat inodes_free is an alias for files_free' do
|
|
76
|
+
expect(@stat).to respond_to(:inodes_free)
|
|
77
|
+
expect(@stat.method(:inodes_free)).to eq(@stat.method(:files_free))
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
example 'stat files_available works as expected' do
|
|
81
|
+
expect(@stat).to respond_to(:files_available)
|
|
82
|
+
expect(@stat.files_available).to be_a(Numeric)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
example 'stat inodes_available is an alias for files_available' do
|
|
86
|
+
expect(@stat).to respond_to(:inodes_available)
|
|
87
|
+
expect(@stat.method(:inodes_available)).to eq(@stat.method(:files_available))
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
example 'stat filesystem_id works as expected' do
|
|
91
|
+
expect(@stat).to respond_to(:filesystem_id)
|
|
92
|
+
expect(@stat.filesystem_id).to be_a(Integer)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
example 'stat flags works as expected' do
|
|
96
|
+
expect(@stat).to respond_to(:flags)
|
|
97
|
+
expect(@stat.flags).to be_a(Numeric)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
example 'stat name_max works as expected' do
|
|
101
|
+
expect(@stat).to respond_to(:name_max)
|
|
102
|
+
expect(@stat.name_max).to be_a(Numeric)
|
|
103
|
+
end
|
|
104
|
+
|
|
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
|
|
110
|
+
|
|
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
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
example 'stat constants are defined' do
|
|
138
|
+
expect(Sys::Filesystem::Stat::RDONLY).not_to be_nil
|
|
139
|
+
expect(Sys::Filesystem::Stat::NOSUID).not_to be_nil
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
example 'stat bytes_total works as expected' do
|
|
143
|
+
expect(@stat).to respond_to(:bytes_total)
|
|
144
|
+
expect(@stat.bytes_total).to be_a(Numeric)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
example 'stat bytes_free works as expected' do
|
|
148
|
+
expect(@stat).to respond_to(:bytes_free)
|
|
149
|
+
expect(@stat.bytes_free).to be_a(Numeric)
|
|
150
|
+
expect(@stat.blocks_free * @stat.fragment_size).to eq(@stat.bytes_free)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
example 'stat bytes_available works as expected' do
|
|
154
|
+
expect(@stat).to respond_to(:bytes_available)
|
|
155
|
+
expect(@stat.bytes_available).to be_a(Numeric)
|
|
156
|
+
expect(@stat.blocks_available * @stat.fragment_size).to eq(@stat.bytes_available)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
example 'stat bytes works as expected' do
|
|
160
|
+
expect(@stat).to respond_to(:bytes_used)
|
|
161
|
+
expect(@stat.bytes_used).to be_a(Numeric)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
example 'stat percent_used works as expected' do
|
|
165
|
+
expect(@stat).to respond_to(:percent_used)
|
|
166
|
+
expect(@stat.percent_used).to be_a(Float)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
example 'stat singleton method requires an argument' do
|
|
170
|
+
expect{ described_class.stat }.to raise_error(ArgumentError)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
example 'stat case_insensitive method works as expected' do
|
|
174
|
+
expected = darwin ? true : false
|
|
175
|
+
expect(@stat.case_insensitive?).to eq(expected)
|
|
176
|
+
expect(described_class.stat(Dir.home).case_insensitive?).to eq(expected)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
example 'stat case_sensitive method works as expected' do
|
|
180
|
+
expected = darwin ? false : true
|
|
181
|
+
expect(@stat.case_sensitive?).to eq(expected)
|
|
182
|
+
expect(described_class.stat(Dir.home).case_sensitive?).to eq(expected)
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
example 'numeric helper methods are defined' do
|
|
186
|
+
expect(@size).to respond_to(:to_kb)
|
|
187
|
+
expect(@size).to respond_to(:to_mb)
|
|
188
|
+
expect(@size).to respond_to(:to_gb)
|
|
189
|
+
expect(@size).to respond_to(:to_tb)
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
example 'to_kb works as expected' do
|
|
193
|
+
expect(@size.to_kb).to eq(57344)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
example 'to_mb works as expected' do
|
|
197
|
+
expect(@size.to_mb).to eq(56)
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
example 'to_gb works as expected' do
|
|
201
|
+
expect(@size.to_gb).to eq(0)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
context 'Filesystem.stat(Pathname)' do
|
|
205
|
+
before do
|
|
206
|
+
@stat_pathname = described_class.stat(Pathname.new(root))
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
example 'class returns expected value with pathname argument' do
|
|
210
|
+
expect(@stat_pathname.class).to eq(@stat.class)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
example 'path returns expected value with pathname argument' do
|
|
214
|
+
expect(@stat_pathname.path).to eq(@stat.path)
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
example 'block_size returns expected value with pathname argument' do
|
|
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
|
|
222
|
+
expect(@stat_pathname.fragment_size).to eq(@stat.fragment_size)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
example 'blocks returns expected value with pathname argument' do
|
|
226
|
+
expect(@stat_pathname.blocks).to eq(@stat.blocks)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
example 'blocks_free returns expected value with pathname argument' do
|
|
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
|
|
234
|
+
expect(@stat_pathname.blocks_available).to eq(@stat.blocks_available)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
example 'files returns expected value with pathname argument' do
|
|
238
|
+
expect(@stat_pathname.files).to eq(@stat.files)
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
example 'files_free returns expected value with pathname argument' do
|
|
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
|
|
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
|
|
250
|
+
expect(@stat_pathname.filesystem_id).to eq(@stat.filesystem_id)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
example 'flags returns expected value with pathname argument' do
|
|
254
|
+
expect(@stat_pathname.flags).to eq(@stat.flags)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
example 'name_max returns expected value with pathname argument' do
|
|
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
|
|
262
|
+
expect(@stat_pathname.base_type).to eq(@stat.base_type)
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
context 'Filesystem.stat(File)' do
|
|
267
|
+
before do
|
|
268
|
+
@stat_file = File.open(root){ |file| described_class.stat(file) }
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
example 'class returns expected value with file argument' do
|
|
272
|
+
expect(@stat_file.class).to eq(@stat.class)
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
example 'path returns expected value with file argument' do
|
|
276
|
+
expect(@stat_file.path).to eq(@stat.path)
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
example 'block_size returns expected value with file argument' do
|
|
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
|
|
284
|
+
expect(@stat_file.fragment_size).to eq(@stat.fragment_size)
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
example 'blocks returns expected value with file argument' do
|
|
288
|
+
expect(@stat_file.blocks).to eq(@stat.blocks)
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
example 'blocks_free returns expected value with file argument' do
|
|
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
|
|
296
|
+
expect(@stat_file.blocks_available).to eq(@stat.blocks_available)
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
example 'files returns expected value with file argument' do
|
|
300
|
+
expect(@stat_file.files).to eq(@stat.files)
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
example 'files_free returns expected value with file argument' do
|
|
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
|
|
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
|
|
312
|
+
expect(@stat_file.filesystem_id).to eq(@stat.filesystem_id)
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
example 'flags returns expected value with file argument' do
|
|
316
|
+
expect(@stat_file.flags).to eq(@stat.flags)
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
example 'name_max returns expected value with file argument' do
|
|
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
|
|
324
|
+
expect(@stat_file.base_type).to eq(@stat.base_type)
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
context 'Filesystem.stat(Dir)' do
|
|
329
|
+
before do
|
|
330
|
+
@stat_dir = Dir.open(root){ |dir| described_class.stat(dir) }
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
example 'class returns expected value with Dir argument' do
|
|
334
|
+
expect(@stat_dir.class).to eq(@stat.class)
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
example 'path returns expected value with Dir argument' do
|
|
338
|
+
expect(@stat_dir.path).to eq(@stat.path)
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
example 'block_size returns expected value with Dir argument' do
|
|
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
|
|
346
|
+
expect(@stat_dir.fragment_size).to eq(@stat.fragment_size)
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
example 'blocks returns expected value with Dir argument' do
|
|
350
|
+
expect(@stat_dir.blocks).to eq(@stat.blocks)
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
example 'blocks_free returns expected value with Dir argument' do
|
|
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
|
|
358
|
+
expect(@stat_dir.blocks_available).to eq(@stat.blocks_available)
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
example 'files returns expected value with Dir argument' do
|
|
362
|
+
expect(@stat_dir.files).to eq(@stat.files)
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
example 'files_free returns expected value with Dir argument' do
|
|
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
|
|
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
|
|
374
|
+
expect(@stat_dir.filesystem_id).to eq(@stat.filesystem_id)
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
example 'flags returns expected value with Dir argument' do
|
|
378
|
+
expect(@stat_dir.flags).to eq(@stat.flags)
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
example 'name_max returns expected value with Dir argument' do
|
|
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
|
|
386
|
+
expect(@stat_dir.base_type).to eq(@stat.base_type)
|
|
387
|
+
end
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
context 'Filesystem::Mount' do
|
|
391
|
+
let(:mount){ described_class.mounts[0] }
|
|
392
|
+
|
|
393
|
+
before do
|
|
394
|
+
@array = []
|
|
395
|
+
end
|
|
396
|
+
|
|
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)
|
|
400
|
+
end
|
|
401
|
+
|
|
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)
|
|
405
|
+
end
|
|
406
|
+
|
|
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
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
example 'mount name method works as expected' do
|
|
412
|
+
expect(mount).to respond_to(:name)
|
|
413
|
+
expect(mount.name).to be_a(String)
|
|
414
|
+
end
|
|
415
|
+
|
|
416
|
+
example 'mount fsname is an alias for name' do
|
|
417
|
+
expect(mount).to respond_to(:fsname)
|
|
418
|
+
expect(mount.method(:fsname)).to eq(mount.method(:name))
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
example 'mount point method works as expected' do
|
|
422
|
+
expect(mount).to respond_to(:mount_point)
|
|
423
|
+
expect(mount.mount_point).to be_a(String)
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
example 'mount dir is an alias for mount_point' do
|
|
427
|
+
expect(mount).to respond_to(:dir)
|
|
428
|
+
expect(mount.method(:dir)).to eq(mount.method(:mount_point))
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
example 'mount mount_type works as expected' do
|
|
432
|
+
expect(mount).to respond_to(:mount_type)
|
|
433
|
+
expect(mount.mount_type).to be_a(String)
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
example 'mount options works as expected' do
|
|
437
|
+
expect(mount).to respond_to(:options)
|
|
438
|
+
expect(mount.options).to be_a(String)
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
example 'mount opts is an alias for options' do
|
|
442
|
+
expect(mount).to respond_to(:opts)
|
|
443
|
+
expect(mount.method(:opts)).to eq(mount.method(:options))
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
# This method may be removed
|
|
447
|
+
example 'mount time works as expected' do
|
|
448
|
+
expect(mount).to respond_to(:mount_time)
|
|
449
|
+
expect(mount.mount_time).to be_nil
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
example 'mount dump_frequency works as expected' do
|
|
453
|
+
msg = 'dump_frequency test skipped on this platform'
|
|
454
|
+
skip msg if bsd || darwin
|
|
455
|
+
expect(mount).to respond_to(:dump_frequency)
|
|
456
|
+
expect(mount.dump_frequency).to be_a(Numeric)
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
example 'mount freq is an alias for dump_frequency' do
|
|
460
|
+
expect(mount).to respond_to(:freq)
|
|
461
|
+
expect(mount.method(:freq)).to eq(mount.method(:dump_frequency))
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
example 'mount pass_number works as expected' do
|
|
465
|
+
msg = 'pass_number test skipped on this platform'
|
|
466
|
+
skip msg if bsd || darwin
|
|
467
|
+
expect(mount).to respond_to(:pass_number)
|
|
468
|
+
expect(mount.pass_number).to be_a(Numeric)
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
example 'mount passno is an alias for pass_number' do
|
|
472
|
+
expect(mount).to respond_to(:passno)
|
|
473
|
+
expect(mount.method(:passno)).to eq(mount.method(:pass_number))
|
|
474
|
+
end
|
|
475
|
+
|
|
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)
|
|
480
|
+
end
|
|
481
|
+
|
|
482
|
+
example 'mount singleton method is defined' do
|
|
483
|
+
expect(described_class).to respond_to(:mount)
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
example 'umount singleton method is defined' do
|
|
487
|
+
expect(described_class).to respond_to(:umount)
|
|
488
|
+
end
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
context 'FFI' do
|
|
492
|
+
before(:context) do
|
|
493
|
+
require 'mkmf-lite'
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
let(:dummy) { Class.new { extend Mkmf::Lite } }
|
|
497
|
+
|
|
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
|
|
501
|
+
end
|
|
502
|
+
|
|
503
|
+
example 'statfs struct is expected size' do
|
|
504
|
+
header = bsd || darwin ? 'sys/mount.h' : 'sys/statfs.h'
|
|
505
|
+
expect(Sys::Filesystem::Structs::Statfs.size).to eq(dummy.check_sizeof('struct statfs', header))
|
|
506
|
+
end
|
|
507
|
+
|
|
508
|
+
example 'statvfs struct is expected size' do
|
|
509
|
+
expect(Sys::Filesystem::Structs::Statvfs.size).to eq(dummy.check_sizeof('struct statvfs', 'sys/statvfs.h'))
|
|
510
|
+
end
|
|
511
|
+
|
|
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)
|
|
520
|
+
end
|
|
521
|
+
|
|
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
|
|
525
|
+
end
|
|
526
|
+
end
|
|
527
|
+
end
|