sys-filesystem 1.3.3 → 1.4.2
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.tar.gz.sig +0 -0
- data/{CHANGES.rdoc → CHANGES.md} +44 -24
- data/Gemfile +3 -0
- data/LICENSE +177 -0
- data/{MANIFEST.rdoc → MANIFEST.md} +3 -1
- data/README.md +89 -0
- data/Rakefile +14 -24
- data/examples/example_mount.rb +3 -2
- data/lib/sys/filesystem.rb +1 -1
- data/lib/sys/unix/sys/filesystem.rb +53 -33
- data/lib/sys/unix/sys/filesystem/constants.rb +2 -4
- data/lib/sys/unix/sys/filesystem/functions.rb +16 -10
- data/lib/sys/unix/sys/filesystem/structs.rb +47 -14
- data/lib/sys/windows/sys/filesystem.rb +43 -29
- data/lib/sys/windows/sys/filesystem/functions.rb +10 -10
- data/lib/sys/windows/sys/filesystem/helper.rb +1 -1
- data/spec/spec_helper.rb +6 -0
- data/spec/sys_filesystem_unix_spec.rb +392 -0
- data/spec/sys_filesystem_windows_spec.rb +344 -0
- data/sys-filesystem.gemspec +6 -8
- metadata +38 -51
- metadata.gz.sig +0 -0
- data/README.rdoc +0 -77
- data/test/test_sys_filesystem.rb +0 -7
- data/test/test_sys_filesystem_unix.rb +0 -329
- data/test/test_sys_filesystem_windows.rb +0 -303
data/sys-filesystem.gemspec
CHANGED
@@ -2,27 +2,25 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'sys-filesystem'
|
5
|
-
spec.version = '1.
|
5
|
+
spec.version = '1.4.2'
|
6
6
|
spec.author = 'Daniel J. Berger'
|
7
7
|
spec.email = 'djberg96@gmail.com'
|
8
8
|
spec.homepage = 'https://github.com/djberg96/sys-filesystem'
|
9
9
|
spec.summary = 'A Ruby interface for getting file system information.'
|
10
10
|
spec.license = 'Apache-2.0'
|
11
|
-
spec.test_files = Dir['
|
11
|
+
spec.test_files = Dir['spec/*_spec.rb']
|
12
12
|
spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
13
13
|
spec.cert_chain = Dir['certs/*']
|
14
14
|
|
15
|
-
spec.
|
16
|
-
|
17
|
-
spec.add_dependency('ffi')
|
15
|
+
spec.add_dependency('ffi', '~> 1.1')
|
16
|
+
spec.add_development_dependency('mkmf-lite', '~> 0.5') unless Gem.win_platform?
|
18
17
|
spec.add_development_dependency('rake')
|
19
|
-
spec.add_development_dependency('
|
20
|
-
spec.add_development_dependency('mkmf-lite', '~> 0.3')
|
18
|
+
spec.add_development_dependency('rspec', '~> 3.9')
|
21
19
|
|
22
20
|
spec.metadata = {
|
23
21
|
'homepage_uri' => 'https://github.com/djberg96/sys-filesystem',
|
24
22
|
'bug_tracker_uri' => 'https://github.com/djberg96/sys-filesystem/issues',
|
25
|
-
'changelog_uri' => 'https://github.com/djberg96/sys-filesystem/blob/
|
23
|
+
'changelog_uri' => 'https://github.com/djberg96/sys-filesystem/blob/main/CHANGES.md',
|
26
24
|
'documentation_uri' => 'https://github.com/djberg96/sys-filesystem/wiki',
|
27
25
|
'source_code_uri' => 'https://github.com/djberg96/sys-filesystem',
|
28
26
|
'wiki_uri' => 'https://github.com/djberg96/sys-filesystem/wiki'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sys-filesystem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -35,114 +35,102 @@ cert_chain:
|
|
35
35
|
ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
|
36
36
|
WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2021-07-22 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: ffi
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - "
|
44
|
+
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
46
|
+
version: '1.1'
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "
|
51
|
+
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '1.1'
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
|
-
name:
|
55
|
+
name: mkmf-lite
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- - "
|
58
|
+
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '0'
|
60
|
+
version: '0.5'
|
61
61
|
type: :development
|
62
62
|
prerelease: false
|
63
63
|
version_requirements: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - "
|
65
|
+
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '0'
|
67
|
+
version: '0.5'
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
|
-
name:
|
69
|
+
name: rake
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- - "
|
72
|
+
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '0'
|
75
75
|
type: :development
|
76
76
|
prerelease: false
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- - "
|
79
|
+
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
81
|
+
version: '0'
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
|
-
name:
|
83
|
+
name: rspec
|
84
84
|
requirement: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
88
|
+
version: '3.9'
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
91
|
version_requirements: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
95
|
+
version: '3.9'
|
96
96
|
description: |2
|
97
97
|
The sys-filesystem library provides a cross-platform interface for
|
98
98
|
gathering filesystem information, such as disk space and mount point data.
|
99
99
|
email: djberg96@gmail.com
|
100
100
|
executables: []
|
101
101
|
extensions: []
|
102
|
-
extra_rdoc_files:
|
103
|
-
- MANIFEST.rdoc
|
104
|
-
- README.rdoc
|
105
|
-
- CHANGES.rdoc
|
102
|
+
extra_rdoc_files: []
|
106
103
|
files:
|
107
|
-
-
|
108
|
-
-
|
109
|
-
-
|
110
|
-
-
|
111
|
-
-
|
112
|
-
-
|
104
|
+
- CHANGES.md
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE
|
107
|
+
- MANIFEST.md
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- certs/djberg96_pub.pem
|
113
111
|
- examples/example_mount.rb
|
114
|
-
-
|
115
|
-
- lib/sys
|
116
|
-
- lib/sys/
|
117
|
-
- lib/sys/unix/sys
|
112
|
+
- examples/example_stat.rb
|
113
|
+
- lib/sys-filesystem.rb
|
114
|
+
- lib/sys/filesystem.rb
|
118
115
|
- lib/sys/unix/sys/filesystem.rb
|
119
|
-
- lib/sys/unix/sys/filesystem
|
120
116
|
- lib/sys/unix/sys/filesystem/constants.rb
|
121
|
-
- lib/sys/unix/sys/filesystem/structs.rb
|
122
117
|
- lib/sys/unix/sys/filesystem/functions.rb
|
123
|
-
- lib/sys/
|
124
|
-
- lib/sys/windows/sys
|
118
|
+
- lib/sys/unix/sys/filesystem/structs.rb
|
125
119
|
- lib/sys/windows/sys/filesystem.rb
|
126
|
-
- lib/sys/windows/sys/filesystem
|
127
120
|
- lib/sys/windows/sys/filesystem/constants.rb
|
128
121
|
- lib/sys/windows/sys/filesystem/functions.rb
|
129
122
|
- lib/sys/windows/sys/filesystem/helper.rb
|
130
|
-
-
|
131
|
-
-
|
132
|
-
-
|
133
|
-
- certs
|
134
|
-
- certs/djberg96_pub.pem
|
135
|
-
- MANIFEST.rdoc
|
136
|
-
- README.rdoc
|
123
|
+
- spec/spec_helper.rb
|
124
|
+
- spec/sys_filesystem_unix_spec.rb
|
125
|
+
- spec/sys_filesystem_windows_spec.rb
|
137
126
|
- sys-filesystem.gemspec
|
138
|
-
- CHANGES.rdoc
|
139
127
|
homepage: https://github.com/djberg96/sys-filesystem
|
140
128
|
licenses:
|
141
129
|
- Apache-2.0
|
142
130
|
metadata:
|
143
131
|
homepage_uri: https://github.com/djberg96/sys-filesystem
|
144
132
|
bug_tracker_uri: https://github.com/djberg96/sys-filesystem/issues
|
145
|
-
changelog_uri: https://github.com/djberg96/sys-filesystem/blob/
|
133
|
+
changelog_uri: https://github.com/djberg96/sys-filesystem/blob/main/CHANGES.md
|
146
134
|
documentation_uri: https://github.com/djberg96/sys-filesystem/wiki
|
147
135
|
source_code_uri: https://github.com/djberg96/sys-filesystem
|
148
136
|
wiki_uri: https://github.com/djberg96/sys-filesystem/wiki
|
@@ -161,11 +149,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
149
|
- !ruby/object:Gem::Version
|
162
150
|
version: '0'
|
163
151
|
requirements: []
|
164
|
-
rubygems_version: 3.0.
|
152
|
+
rubygems_version: 3.0.3.1
|
165
153
|
signing_key:
|
166
154
|
specification_version: 4
|
167
155
|
summary: A Ruby interface for getting file system information.
|
168
156
|
test_files:
|
169
|
-
-
|
170
|
-
-
|
171
|
-
- test/test_sys_filesystem_unix.rb
|
157
|
+
- spec/sys_filesystem_unix_spec.rb
|
158
|
+
- spec/sys_filesystem_windows_spec.rb
|
metadata.gz.sig
CHANGED
Binary file
|
data/README.rdoc
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
== Description
|
2
|
-
A cross platform Ruby interface for getting file system information.
|
3
|
-
|
4
|
-
== Installation
|
5
|
-
gem install sys-filesystem
|
6
|
-
|
7
|
-
== Synopsis
|
8
|
-
require 'sys/filesystem'
|
9
|
-
include Sys
|
10
|
-
|
11
|
-
# Display information about a particular filesystem.
|
12
|
-
p Filesystem.stat('/')
|
13
|
-
|
14
|
-
# Sample output
|
15
|
-
|
16
|
-
#<Sys::Filesystem::Stat:0x517440
|
17
|
-
@base_type = "ufs",
|
18
|
-
@flags = 4,
|
19
|
-
@files_available = 3817457,
|
20
|
-
@block_size = 8192,
|
21
|
-
@blocks_available = 19957633,
|
22
|
-
@blocks = 34349612,
|
23
|
-
@name_max = 255,
|
24
|
-
@path = "/",
|
25
|
-
@filesystem_id = 35651592,
|
26
|
-
@files = 4135040,
|
27
|
-
@fragment_size = 1024,
|
28
|
-
@files_free = 3817457,
|
29
|
-
@blocks_free = 20301129
|
30
|
-
>
|
31
|
-
|
32
|
-
# Describe all mount points on the system
|
33
|
-
Filesystem.mounts{ |mount| p mount }
|
34
|
-
|
35
|
-
# Find the mount point of any particular file
|
36
|
-
puts Filesystem.mount_point('/home/djberge/some_file.txt') => '/home'
|
37
|
-
|
38
|
-
== Notes
|
39
|
-
This is a pure Ruby implementation that uses FFI. This means it should work
|
40
|
-
with JRuby, too.
|
41
|
-
|
42
|
-
== Sample code
|
43
|
-
Run 'rake example' if you want to see a basic sample run. The actual code
|
44
|
-
is 'example_stat.rb' in the 'examples' directory. Modify it as you see fit.
|
45
|
-
|
46
|
-
== Known Bugs
|
47
|
-
None that I'm aware of. Please report bugs on the project page at:
|
48
|
-
|
49
|
-
https://github.com/djberg96/sys-filesystem
|
50
|
-
|
51
|
-
== Future Plans
|
52
|
-
|
53
|
-
* Add better 64-bit support for Linux and BSD.
|
54
|
-
* Other suggestions welcome.
|
55
|
-
|
56
|
-
== Acknowledgements
|
57
|
-
Mike Hall, for ideas and code that I borrowed from his 'filesystem' library.
|
58
|
-
|
59
|
-
Park Heesob, for implementation and API ideas for the MS Windows version.
|
60
|
-
|
61
|
-
Nobuyoshi Miyokawa, for adding the original FreeBSD and OS X support.
|
62
|
-
|
63
|
-
== License
|
64
|
-
Apache-2.0
|
65
|
-
|
66
|
-
== Copyright
|
67
|
-
(C) 2003-2019 Daniel J. Berger
|
68
|
-
|
69
|
-
All Rights Reserved
|
70
|
-
|
71
|
-
== Warranty
|
72
|
-
This library is provided "as is" and without any express or
|
73
|
-
implied warranties, including, without limitation, the implied
|
74
|
-
warranties of merchantability and fitness for a particular purpose.
|
75
|
-
|
76
|
-
== Author
|
77
|
-
Daniel J. Berger
|
data/test/test_sys_filesystem.rb
DELETED
@@ -1,329 +0,0 @@
|
|
1
|
-
####################################################################
|
2
|
-
# test_sys_filesystem_unix.rb
|
3
|
-
#
|
4
|
-
# Test case for the Sys::Filesystem.stat method and related stuff.
|
5
|
-
# This test suite should be run via the 'rake test' task.
|
6
|
-
####################################################################
|
7
|
-
require 'test-unit'
|
8
|
-
require 'sys-filesystem'
|
9
|
-
require 'mkmf-lite'
|
10
|
-
include Sys
|
11
|
-
include Mkmf::Lite
|
12
|
-
|
13
|
-
class TC_Sys_Filesystem_Unix < Test::Unit::TestCase
|
14
|
-
def self.startup
|
15
|
-
@@solaris = RbConfig::CONFIG['host_os'] =~ /solaris/i
|
16
|
-
@@linux = RbConfig::CONFIG['host_os'] =~ /linux/i
|
17
|
-
@@freebsd = RbConfig::CONFIG['host_os'] =~ /freebsd/i
|
18
|
-
@@darwin = RbConfig::CONFIG['host_os'] =~ /darwin/i
|
19
|
-
end
|
20
|
-
|
21
|
-
def setup
|
22
|
-
@dir = "/"
|
23
|
-
@stat = Filesystem.stat(@dir)
|
24
|
-
@mnt = Filesystem.mounts[0]
|
25
|
-
@size = 58720256
|
26
|
-
@array = []
|
27
|
-
end
|
28
|
-
|
29
|
-
test "version number is set to the expected value" do
|
30
|
-
assert_equal('1.3.3', Filesystem::VERSION)
|
31
|
-
assert_true(Filesystem::VERSION.frozen?)
|
32
|
-
end
|
33
|
-
|
34
|
-
test "stat path works as expected" do
|
35
|
-
assert_respond_to(@stat, :path)
|
36
|
-
assert_equal("/", @stat.path)
|
37
|
-
end
|
38
|
-
|
39
|
-
test "stat block_size works as expected" do
|
40
|
-
assert_respond_to(@stat, :block_size)
|
41
|
-
assert_kind_of(Numeric, @stat.block_size)
|
42
|
-
end
|
43
|
-
|
44
|
-
test "stat fragment_size works as expected" do
|
45
|
-
assert_respond_to(@stat, :fragment_size)
|
46
|
-
assert_kind_of(Numeric, @stat.fragment_size)
|
47
|
-
end
|
48
|
-
|
49
|
-
test "stat fragment_size is a plausible value" do
|
50
|
-
assert_true(@stat.fragment_size >= 512)
|
51
|
-
assert_true(@stat.fragment_size <= 16384)
|
52
|
-
end
|
53
|
-
|
54
|
-
test "stat blocks works as expected" do
|
55
|
-
assert_respond_to(@stat, :blocks)
|
56
|
-
assert_kind_of(Numeric, @stat.blocks)
|
57
|
-
end
|
58
|
-
|
59
|
-
test "stat blocks_free works as expected" do
|
60
|
-
assert_respond_to(@stat, :blocks_free)
|
61
|
-
assert_kind_of(Numeric, @stat.blocks_free)
|
62
|
-
end
|
63
|
-
|
64
|
-
test "stat blocks_available works as expected" do
|
65
|
-
assert_respond_to(@stat, :blocks_available)
|
66
|
-
assert_kind_of(Numeric, @stat.blocks_available)
|
67
|
-
end
|
68
|
-
|
69
|
-
test "stat files works as expected" do
|
70
|
-
assert_respond_to(@stat, :files)
|
71
|
-
assert_kind_of(Numeric, @stat.files)
|
72
|
-
end
|
73
|
-
|
74
|
-
test "stat inodes is an alias for files" do
|
75
|
-
assert_respond_to(@stat, :inodes)
|
76
|
-
assert_true(@stat.method(:inodes) == @stat.method(:files))
|
77
|
-
end
|
78
|
-
|
79
|
-
test "stat files tree works as expected" do
|
80
|
-
assert_respond_to(@stat, :files_free)
|
81
|
-
assert_kind_of(Numeric, @stat.files_free)
|
82
|
-
end
|
83
|
-
|
84
|
-
test "stat inodes_free is an alias for files_free" do
|
85
|
-
assert_respond_to(@stat, :inodes_free)
|
86
|
-
assert_true(@stat.method(:inodes_free) == @stat.method(:files_free))
|
87
|
-
end
|
88
|
-
|
89
|
-
test "stat files_available works as expected" do
|
90
|
-
assert_respond_to(@stat, :files_available)
|
91
|
-
assert_kind_of(Numeric, @stat.files_available)
|
92
|
-
end
|
93
|
-
|
94
|
-
test "stat inodes_available is an alias for files_available" do
|
95
|
-
assert_respond_to(@stat, :inodes_available)
|
96
|
-
assert_true(@stat.method(:inodes_available) == @stat.method(:files_available))
|
97
|
-
end
|
98
|
-
|
99
|
-
test "stat filesystem_id works as expected" do
|
100
|
-
assert_respond_to(@stat, :filesystem_id)
|
101
|
-
assert_kind_of(Integer, @stat.filesystem_id)
|
102
|
-
end
|
103
|
-
|
104
|
-
test "stat flags works as expected" do
|
105
|
-
assert_respond_to(@stat, :flags)
|
106
|
-
assert_kind_of(Numeric, @stat.flags)
|
107
|
-
end
|
108
|
-
|
109
|
-
test "stat name_max works as expected" do
|
110
|
-
assert_respond_to(@stat, :name_max)
|
111
|
-
assert_kind_of(Numeric, @stat.name_max)
|
112
|
-
end
|
113
|
-
|
114
|
-
test "stat base_type works as expected" do
|
115
|
-
omit_unless(@@solaris, "base_type test skipped except on Solaris")
|
116
|
-
|
117
|
-
assert_respond_to(@stat, :base_type)
|
118
|
-
assert_kind_of(String, @stat.base_type)
|
119
|
-
end
|
120
|
-
|
121
|
-
test "stat constants are defined" do
|
122
|
-
assert_not_nil(Filesystem::Stat::RDONLY)
|
123
|
-
assert_not_nil(Filesystem::Stat::NOSUID)
|
124
|
-
|
125
|
-
omit_unless(@@solaris, "NOTRUNC test skipped except on Solaris")
|
126
|
-
|
127
|
-
assert_not_nil(Filesystem::Stat::NOTRUNC)
|
128
|
-
end
|
129
|
-
|
130
|
-
test "stat bytes_total works as expected" do
|
131
|
-
assert_respond_to(@stat, :bytes_total)
|
132
|
-
assert_kind_of(Numeric, @stat.bytes_total)
|
133
|
-
end
|
134
|
-
|
135
|
-
test "stat bytes_free works as expected" do
|
136
|
-
assert_respond_to(@stat, :bytes_free)
|
137
|
-
assert_kind_of(Numeric, @stat.bytes_free)
|
138
|
-
assert_equal(@stat.bytes_free, @stat.blocks_free * @stat.fragment_size)
|
139
|
-
end
|
140
|
-
|
141
|
-
test "stat bytes_available works as expected" do
|
142
|
-
assert_respond_to(@stat, :bytes_available)
|
143
|
-
assert_kind_of(Numeric, @stat.bytes_available)
|
144
|
-
assert_equal(@stat.bytes_available, @stat.blocks_available * @stat.fragment_size)
|
145
|
-
end
|
146
|
-
|
147
|
-
test "stat bytes works as expected" do
|
148
|
-
assert_respond_to(@stat, :bytes_used)
|
149
|
-
assert_kind_of(Numeric, @stat.bytes_used)
|
150
|
-
end
|
151
|
-
|
152
|
-
test "stat percent_used works as expected" do
|
153
|
-
assert_respond_to(@stat, :percent_used)
|
154
|
-
assert_kind_of(Float, @stat.percent_used)
|
155
|
-
end
|
156
|
-
|
157
|
-
test "stat singleton method requires an argument" do
|
158
|
-
assert_raises(ArgumentError){ Filesystem.stat }
|
159
|
-
end
|
160
|
-
|
161
|
-
test "stat case_insensitive method works as expected" do
|
162
|
-
expected = @@darwin ? true : false
|
163
|
-
assert_equal(expected, @stat.case_insensitive?)
|
164
|
-
assert_equal(expected, Filesystem.stat(Dir.home).case_insensitive?)
|
165
|
-
end
|
166
|
-
|
167
|
-
test "stat case_sensitive method works as expected" do
|
168
|
-
expected = @@darwin ? false : true
|
169
|
-
assert_equal(expected, @stat.case_sensitive?)
|
170
|
-
assert_equal(expected, Filesystem.stat(Dir.home).case_sensitive?)
|
171
|
-
end
|
172
|
-
|
173
|
-
test "numeric helper methods are defined" do
|
174
|
-
assert_respond_to(@size, :to_kb)
|
175
|
-
assert_respond_to(@size, :to_mb)
|
176
|
-
assert_respond_to(@size, :to_gb)
|
177
|
-
assert_respond_to(@size, :to_tb)
|
178
|
-
end
|
179
|
-
|
180
|
-
test "to_kb works as expected" do
|
181
|
-
assert_equal(57344, @size.to_kb)
|
182
|
-
end
|
183
|
-
|
184
|
-
test "to_mb works as expected" do
|
185
|
-
assert_equal(56, @size.to_mb)
|
186
|
-
end
|
187
|
-
|
188
|
-
test "to_gb works as expected" do
|
189
|
-
assert_equal(0, @size.to_gb)
|
190
|
-
end
|
191
|
-
|
192
|
-
# Filesystem::Mount tests
|
193
|
-
|
194
|
-
test "mounts singleton method works as expected without a block" do
|
195
|
-
assert_nothing_raised{ @array = Filesystem.mounts }
|
196
|
-
assert_kind_of(Filesystem::Mount, @array[0])
|
197
|
-
end
|
198
|
-
|
199
|
-
test "mounts singleton method works as expected with a block" do
|
200
|
-
assert_nothing_raised{ Filesystem.mounts{ |m| @array << m } }
|
201
|
-
assert_kind_of(Filesystem::Mount, @array[0])
|
202
|
-
end
|
203
|
-
|
204
|
-
test "calling the mounts singleton method a large number of times does not cause issues" do
|
205
|
-
assert_nothing_raised{ 1000.times{ @array = Filesystem.mounts } }
|
206
|
-
end
|
207
|
-
|
208
|
-
test "mount name method works as expected" do
|
209
|
-
assert_respond_to(@mnt, :name)
|
210
|
-
assert_kind_of(String, @mnt.name)
|
211
|
-
end
|
212
|
-
|
213
|
-
test "mount fsname is an alias for name" do
|
214
|
-
assert_respond_to(@mnt, :fsname)
|
215
|
-
assert_true(@mnt.method(:fsname) == @mnt.method(:name))
|
216
|
-
end
|
217
|
-
|
218
|
-
test "mount point method works as expected" do
|
219
|
-
assert_respond_to(@mnt, :mount_point)
|
220
|
-
assert_kind_of(String, @mnt.mount_point)
|
221
|
-
end
|
222
|
-
|
223
|
-
test "mount dir is an alias for mount_point" do
|
224
|
-
assert_respond_to(@mnt, :dir)
|
225
|
-
assert_true(@mnt.method(:dir) == @mnt.method(:mount_point))
|
226
|
-
end
|
227
|
-
|
228
|
-
test "mount mount_type works as expected" do
|
229
|
-
assert_respond_to(@mnt, :mount_type)
|
230
|
-
assert_kind_of(String, @mnt.mount_type)
|
231
|
-
end
|
232
|
-
|
233
|
-
test "mount options works as expected" do
|
234
|
-
assert_respond_to(@mnt, :options)
|
235
|
-
assert_kind_of(String, @mnt.options)
|
236
|
-
end
|
237
|
-
|
238
|
-
test "mount opts is an alias for options" do
|
239
|
-
assert_respond_to(@mnt, :opts)
|
240
|
-
assert_true(@mnt.method(:opts) == @mnt.method(:options))
|
241
|
-
end
|
242
|
-
|
243
|
-
test "mount time works as expected" do
|
244
|
-
assert_respond_to(@mnt, :mount_time)
|
245
|
-
|
246
|
-
if @@solaris
|
247
|
-
assert_kind_of(Time, @mnt.mount_time)
|
248
|
-
else
|
249
|
-
assert_nil(@mnt.mount_time)
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
test "mount dump_frequency works as expected" do
|
254
|
-
msg = 'dump_frequency test skipped on this platform'
|
255
|
-
omit_if(@@solaris || @@freebsd || @@darwin, msg)
|
256
|
-
assert_respond_to(@mnt, :dump_frequency)
|
257
|
-
assert_kind_of(Numeric, @mnt.dump_frequency)
|
258
|
-
end
|
259
|
-
|
260
|
-
test "mount freq is an alias for dump_frequency" do
|
261
|
-
assert_respond_to(@mnt, :freq)
|
262
|
-
assert_true(@mnt.method(:freq) == @mnt.method(:dump_frequency))
|
263
|
-
end
|
264
|
-
|
265
|
-
test "mount pass_number works as expected" do
|
266
|
-
msg = 'pass_number test skipped on this platform'
|
267
|
-
omit_if(@@solaris || @@freebsd || @@darwin, msg)
|
268
|
-
assert_respond_to(@mnt, :pass_number)
|
269
|
-
assert_kind_of(Numeric, @mnt.pass_number)
|
270
|
-
end
|
271
|
-
|
272
|
-
test "mount passno is an alias for pass_number" do
|
273
|
-
assert_respond_to(@mnt, :passno)
|
274
|
-
assert_true(@mnt.method(:passno) == @mnt.method(:pass_number))
|
275
|
-
end
|
276
|
-
|
277
|
-
test "mount_point singleton method works as expected" do
|
278
|
-
assert_respond_to(Filesystem, :mount_point)
|
279
|
-
assert_nothing_raised{ Filesystem.mount_point(Dir.pwd) }
|
280
|
-
assert_kind_of(String, Filesystem.mount_point(Dir.pwd))
|
281
|
-
end
|
282
|
-
|
283
|
-
test "mount singleton method is defined" do
|
284
|
-
assert_respond_to(Sys::Filesystem, :mount)
|
285
|
-
end
|
286
|
-
|
287
|
-
test "umount singleton method is defined" do
|
288
|
-
assert_respond_to(Sys::Filesystem, :umount)
|
289
|
-
end
|
290
|
-
|
291
|
-
# FFI
|
292
|
-
|
293
|
-
test "ffi functions are private" do
|
294
|
-
assert_false(Filesystem.methods.include?('statvfs'))
|
295
|
-
assert_false(Filesystem.methods.include?('strerror'))
|
296
|
-
end
|
297
|
-
|
298
|
-
test "statfs struct is expected size" do
|
299
|
-
header = @@freebsd || @@darwin ? 'sys/mount.h' : 'sys/statfs.h'
|
300
|
-
assert_equal(check_sizeof('struct statfs', header), Filesystem::Structs::Statfs.size)
|
301
|
-
end
|
302
|
-
|
303
|
-
test "statvfs struct is expected size" do
|
304
|
-
assert_equal(check_sizeof('struct statvfs', 'sys/statvfs.h'), Filesystem::Structs::Statvfs.size)
|
305
|
-
end
|
306
|
-
|
307
|
-
test "mnttab struct is expected size" do
|
308
|
-
omit_unless(@@solaris, "mnttab test skipped except on Solaris")
|
309
|
-
assert_equal(check_sizeof('struct mnttab', 'sys/mnttab.h'), Filesystem::Structs::Mnttab.size)
|
310
|
-
end
|
311
|
-
|
312
|
-
test "mntent struct is expected size" do
|
313
|
-
omit_unless(@@linux, "mnttab test skipped except on Linux")
|
314
|
-
assert_equal(check_sizeof('struct mntent', 'mntent.h'), Filesystem::Structs::Mntent.size)
|
315
|
-
end
|
316
|
-
|
317
|
-
def teardown
|
318
|
-
@dir = nil
|
319
|
-
@stat = nil
|
320
|
-
@array = nil
|
321
|
-
end
|
322
|
-
|
323
|
-
def self.shutdown
|
324
|
-
@@solaris = nil
|
325
|
-
@@linux = nil
|
326
|
-
@@freebsd = nil
|
327
|
-
@@darwin = nil
|
328
|
-
end
|
329
|
-
end
|