solaris-file 0.3.4 → 0.3.5
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.
- data/CHANGES +12 -0
- data/MANIFEST +2 -4
- data/README +9 -86
- data/Rakefile +59 -0
- data/examples/{test.rb → example_solaris_file.rb} +9 -15
- data/ext/solaris/sfile.c +1 -1
- data/ext/solaris/sfile.h +1 -1
- data/solaris-file.gemspec +37 -0
- data/test/test_solaris_file.rb +290 -0
- metadata +37 -20
- data/ext/Makefile +0 -149
- data/ext/file.so +0 -0
- data/ext/mkmf.log +0 -13
- data/ext/sfile.o +0 -0
- data/ext/solaris/file.so +0 -0
- data/test/tc_solaris_file.rb +0 -174
data/CHANGES
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
== 0.3.5 - 28-Aug-2009
|
2
|
+
* Changed the license to Artistic 2.0.
|
3
|
+
* Added test-unit 2.x and sys-filesystem as development dependencies.
|
4
|
+
* Some updates to the gemspec, including license and description.
|
5
|
+
* Refactored the test suite to use the features of 2.x, added several
|
6
|
+
more tests, and now skips some tests unless it's a UFS filesystem.
|
7
|
+
* Renamed the test and example files.
|
8
|
+
|
9
|
+
== 0.3.4 - 4-Feb-2008
|
10
|
+
* Updated the extconf.rb file so that it sets the target prefix properly.
|
11
|
+
* No actual source code changes.
|
12
|
+
|
1
13
|
== 0.3.3 - 20-Aug-2007
|
2
14
|
* Added the File.door? method, and the underlying File::Stat#door? method,
|
3
15
|
that returns whether or not the file is a door file.
|
data/MANIFEST
CHANGED
data/README
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
== Description
|
2
|
-
Adds ACL support and
|
2
|
+
Adds ACL support and door methods for the File class on Solaris.
|
3
3
|
|
4
4
|
== Prerequisites
|
5
5
|
Ruby 1.8.x
|
6
6
|
|
7
7
|
== Installation
|
8
|
-
|
9
|
-
|
8
|
+
=== Gem Installation
|
9
|
+
gem install solaris-file
|
10
|
+
=== Local Installation
|
11
|
+
rake install
|
10
12
|
|
11
13
|
== Synopsis
|
12
14
|
require 'solaris/file'
|
13
15
|
|
14
16
|
f = 'some_file.txt'
|
15
|
-
acl_text = "user::rw-,user:nobody:r--,"
|
16
|
-
acl_text << "group::r--,group:sys:r--,mask:r--,other:r--"
|
17
|
+
acl_text = "user::rw-,user:nobody:r--,group::r--,group:sys:r--,mask:r--,other:r--"
|
17
18
|
|
18
19
|
File.trivial?(f) # => true (probably)
|
19
20
|
File.acl_write_text(acl_text)
|
@@ -26,92 +27,16 @@
|
|
26
27
|
File.door?("/var/run/syslog_door") # => true
|
27
28
|
File.ftype("/var/run/syslog_door") # => 'door'
|
28
29
|
|
29
|
-
== Class Methods
|
30
|
-
File.acl_count(file_name)
|
31
|
-
Returns the number of ACL entries for the file. Returns 0 if it's a
|
32
|
-
trivial file.
|
33
|
-
|
34
|
-
File.acl_read(file_name)
|
35
|
-
Returns an Array of ACLStruct's or nil if file_name is a trivial file.
|
36
|
-
|
37
|
-
Fiel.acl_read_text(file_name)
|
38
|
-
Returns a String form of the ACL entries for the file. Returns nil if
|
39
|
-
it's a trivial ACL.
|
40
|
-
|
41
|
-
File.acl_write_text(file_name, acl_string)
|
42
|
-
Accepts a formatted ACL string that set the ACL for the file. If the
|
43
|
-
string is badly formed, a File::SolarisError is raised.
|
44
|
-
|
45
|
-
File.door?(file_name)
|
46
|
-
Returns whether or not +file_name+ is a Door file.
|
47
|
-
|
48
|
-
File.ftype(file_name)
|
49
|
-
Modified so that it returns the word 'door' if +file_name+ is a door file.
|
50
|
-
|
51
|
-
File.realpath(path)
|
52
|
-
Resolves all symbolic links in +path+. Resolves to an absolute pathname
|
53
|
-
where possible.
|
54
|
-
|
55
|
-
File.resolvepath(path)
|
56
|
-
Resolves all symbolic links in +path+. All "." components are removed, as
|
57
|
-
well as all nonleading ".." components and their preceding directory
|
58
|
-
component. If leading ".." components resolve to the root directory, they
|
59
|
-
are replaced by "/".
|
60
|
-
|
61
|
-
File.trivial?(file_name)
|
62
|
-
Returns true if the file is a trivial ACL file, i.e. has no ACL entries for
|
63
|
-
additional users or groups.
|
64
|
-
|
65
|
-
= File Instance Methods
|
66
|
-
File#acl_count
|
67
|
-
Returns the number of ACL entries for the file. Returns 0 if it's a
|
68
|
-
trivial file.
|
69
|
-
|
70
|
-
File#acl_read
|
71
|
-
Returns an Array of ACLStruct's.
|
72
|
-
|
73
|
-
File#acl_read_text
|
74
|
-
Returns a String form of the ACL entries for the file. Returns nil if
|
75
|
-
it's a trivial ACL.
|
76
|
-
|
77
|
-
File#acl_write_text(acl_string)
|
78
|
-
Accepts a formatted ACL string that set the ACL for the file. If the
|
79
|
-
string is badly formed, a File::SolarisError is raised.
|
80
|
-
|
81
|
-
File#trivial?
|
82
|
-
Returns true if the file is a trivial ACL file, i.e. has no ACL entries for
|
83
|
-
additional users or groups
|
84
|
-
|
85
|
-
= File::Stat Instance Methods
|
86
|
-
File::Stat#door?
|
87
|
-
Returns whether or not the stat object is a door file.
|
88
|
-
|
89
|
-
File::Stat#ftype
|
90
|
-
Modified so that the stat object returns the word 'door' if the stat file
|
91
|
-
is a Door file.
|
92
|
-
|
93
|
-
== Constants
|
94
|
-
File::SOLARIS_VERSION
|
95
|
-
Returns the current version number of this package as a String.
|
96
|
-
|
97
|
-
== Error Classes
|
98
|
-
File::SolarisError < StandardError
|
99
|
-
Raised if anything goes wrong with any of the above methods.
|
100
|
-
|
101
30
|
== Known Bugs
|
102
31
|
None that I am aware of. Please report any bugs using the tracker on the
|
103
32
|
project page at http://www.rubyforge.org/projects/solarisutils
|
104
33
|
|
105
34
|
== Future Plans
|
106
|
-
Add
|
107
|
-
ACLStruct's.
|
35
|
+
Add acl_write methods that accept an array of ACLStruct's.
|
108
36
|
Add support for extended file attributes.
|
109
37
|
|
110
|
-
== Developer's Notes
|
111
|
-
This is a BETA release. The code is stable, the API is not.
|
112
|
-
|
113
38
|
== Copyright
|
114
|
-
(C) 2005-
|
39
|
+
(C) 2005-2009 Daniel J. Berger
|
115
40
|
All Rights Reserved
|
116
41
|
|
117
42
|
== Warranty
|
@@ -120,9 +45,7 @@ File::SolarisError < StandardError
|
|
120
45
|
warranties of merchantability and fitness for a particular purpose.
|
121
46
|
|
122
47
|
== License
|
123
|
-
|
48
|
+
Artistic 2.0
|
124
49
|
|
125
50
|
== Author
|
126
51
|
Daniel J. Berger
|
127
|
-
djberg96 [at nospam at gmail dot com]
|
128
|
-
imperator on IRC (irc.freenode.net)
|
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rbconfig'
|
5
|
+
include Config
|
6
|
+
|
7
|
+
desc "Clean the build files for the solaris-file source"
|
8
|
+
task :clean do
|
9
|
+
FileUtils.rm_rf('solaris') if File.exists?('solaris')
|
10
|
+
|
11
|
+
Dir.chdir('ext') do
|
12
|
+
FileUtils.rm_rf('sfile.c') if File.exists?('sfile.c')
|
13
|
+
FileUtils.rm_rf('sfile.h') if File.exists?('sfile.h')
|
14
|
+
sh 'make distclean' if File.exists?('file.so')
|
15
|
+
FileUtils.rm_rf('solaris/file.so') if File.exists?('solaris/file.so')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Build the solaris-file package (but don't install it)"
|
20
|
+
task :build => [:clean] do
|
21
|
+
Dir.chdir('ext') do
|
22
|
+
ruby 'extconf.rb'
|
23
|
+
sh 'make'
|
24
|
+
Dir.mkdir('solaris') unless File.exists?('solaris')
|
25
|
+
FileUtils.cp('file.so', 'solaris')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Install the solaris-file package (non-gem)"
|
30
|
+
task :install => [:build] do
|
31
|
+
Dir.chdir('ext') do
|
32
|
+
sh 'make install'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Install the solaris-file package as a gem"
|
37
|
+
task :install_gem do
|
38
|
+
ruby 'solaris-file.gemspec'
|
39
|
+
file = Dir["*.gem"].first
|
40
|
+
sh "gem install #{file}"
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Uninstall the solaris-file package. Use 'gem uninstall' for gem installs"
|
44
|
+
task :uninstall => [:clean] do
|
45
|
+
file = File.join(CONFIG['sitearchdir'], 'solaris', 'file.so')
|
46
|
+
FileUtils.rm_rf(file, :verbose => true) if File.exists?(file)
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Run the example program"
|
50
|
+
task :example => [:build] do
|
51
|
+
ruby "-Iext examples/example_solaris_file.rb"
|
52
|
+
end
|
53
|
+
|
54
|
+
Rake::TestTask.new do |t|
|
55
|
+
task :test => :build
|
56
|
+
t.libs << 'ext'
|
57
|
+
t.warning = true
|
58
|
+
t.verbose = true
|
59
|
+
end
|
@@ -1,22 +1,16 @@
|
|
1
|
-
|
2
|
-
#
|
1
|
+
#######################################################################
|
2
|
+
# example_solaris_file.rb
|
3
3
|
#
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
require "ftools"
|
10
|
-
Dir.chdir("..") if base == "examples"
|
11
|
-
Dir.mkdir("solaris") unless File.exists?("solaris")
|
12
|
-
File.copy("file.so","solaris")
|
13
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
14
|
-
Dir.chdir("examples")
|
15
|
-
end
|
16
|
-
|
4
|
+
# Example script for general futzing. You can run this script via
|
5
|
+
# the 'rake example' task.
|
6
|
+
#
|
7
|
+
# Modify as you see fit.
|
8
|
+
#######################################################################
|
17
9
|
require "solaris/file"
|
18
10
|
require "pp"
|
19
11
|
|
12
|
+
Dir.chdir File.dirname(File.expand_path(__FILE__))
|
13
|
+
|
20
14
|
puts
|
21
15
|
puts "Version: " + File::SOLARIS_VERSION
|
22
16
|
puts "-" * 20
|
data/ext/solaris/sfile.c
CHANGED
@@ -476,6 +476,6 @@ void Init_file(){
|
|
476
476
|
"acl_type", "acl_id", "acl_perm", NULL
|
477
477
|
);
|
478
478
|
|
479
|
-
/* 0.3.
|
479
|
+
/* 0.3.5: The version of the solaris-file library */
|
480
480
|
rb_define_const(rb_cFile, "SOLARIS_VERSION", rb_str_new2(SOLARIS_VERSION));
|
481
481
|
}
|
data/ext/solaris/sfile.h
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
spec = Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'solaris-file'
|
5
|
+
gem.version = '0.3.5'
|
6
|
+
gem.author = 'Daniel J. Berger'
|
7
|
+
gem.license = 'Artistic 2.0'
|
8
|
+
gem.email = 'djberg96@gmail.com'
|
9
|
+
gem.homepage = 'http://www.rubyforge.org/projects/solarisutils'
|
10
|
+
gem.platform = Gem::Platform::RUBY
|
11
|
+
gem.summary = 'ACL and other methods for the File class on Solaris'
|
12
|
+
gem.has_rdoc = true
|
13
|
+
gem.test_file = 'test/test_solaris_file.rb'
|
14
|
+
gem.extensions = ['ext/extconf.rb']
|
15
|
+
gem.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
|
16
|
+
|
17
|
+
gem.rubyforge_project = 'solarisutils'
|
18
|
+
|
19
|
+
gem.extra_rdoc_files = [
|
20
|
+
'README',
|
21
|
+
'CHANGES',
|
22
|
+
'MANIFEST',
|
23
|
+
'ext/solaris/sfile.c'
|
24
|
+
]
|
25
|
+
|
26
|
+
gem.add_development_dependency('test-unit', '>= 2.0.3')
|
27
|
+
gem.add_development_dependency('sys-filesystem', '>= 0.3.1')
|
28
|
+
|
29
|
+
gem.description = <<-EOF
|
30
|
+
The solaris-file library provides Solaris-specific access control
|
31
|
+
methods to the File class. It also provides methods for identifying
|
32
|
+
trivial and door files, interfaces for the realpath() and resolvepath()
|
33
|
+
functions, and an overloaded ftype method.
|
34
|
+
EOF
|
35
|
+
end
|
36
|
+
|
37
|
+
Gem::Builder.new(spec).build
|
@@ -0,0 +1,290 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# test_solaris_file.rb
|
3
|
+
#
|
4
|
+
# Test suite for the solaris-file package. You should run this test case
|
5
|
+
# via the 'rake test' task. Note that many tests will be skipped unless you're
|
6
|
+
# on a UFS filesystem.
|
7
|
+
###############################################################################
|
8
|
+
require 'rubygems'
|
9
|
+
gem 'test-unit'
|
10
|
+
|
11
|
+
require 'test/unit'
|
12
|
+
require 'solaris/file'
|
13
|
+
require 'sys/filesystem'
|
14
|
+
|
15
|
+
class TC_Solaris_File < Test::Unit::TestCase
|
16
|
+
def self.startup
|
17
|
+
Dir.chdir(File.dirname(File.expand_path(__FILE__)))
|
18
|
+
|
19
|
+
@@ufs = Sys::Filesystem.stat(Dir.pwd).base_type == 'ufs'
|
20
|
+
@@file1 = File.join(Dir.pwd, 'foo.txt') # trivial
|
21
|
+
@@file2 = File.join(Dir.pwd, 'bar.txt') # non-trivial
|
22
|
+
|
23
|
+
@@acl_text = 'user::rw-,user:nobody:r--,group::r--,group:sys:r--,mask:r--,other:r--'
|
24
|
+
|
25
|
+
File.open(@@file1, 'w'){ |fh| fh.puts 'foo' }
|
26
|
+
File.open(@@file2, 'w'){ |fh| fh.puts 'bar' }
|
27
|
+
end
|
28
|
+
|
29
|
+
def setup
|
30
|
+
@dir = Dir.pwd
|
31
|
+
@door = '/var/run/syslog_door'
|
32
|
+
@stat = File::Stat.new(@door)
|
33
|
+
|
34
|
+
# Make @@file2 a non-trivial file. UFS only.
|
35
|
+
if @@ufs
|
36
|
+
system("chmod A=#{@@acl_text} #{@@file2}")
|
37
|
+
end
|
38
|
+
|
39
|
+
@handle1 = File.open(@@file1)
|
40
|
+
@handle2 = File.open(@@file2)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_version
|
44
|
+
assert_equal('0.3.5', File::SOLARIS_VERSION)
|
45
|
+
end
|
46
|
+
|
47
|
+
# SINGLETON METHODS
|
48
|
+
|
49
|
+
def test_singleton_acl_read_basic
|
50
|
+
omit_unless(@@ufs, 'skipped on non-ufs filesystem')
|
51
|
+
assert_respond_to(File, :acl_read)
|
52
|
+
assert_nothing_raised{ File.acl_read(@@file1) }
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_singleton_acl_read
|
56
|
+
omit_unless(@@ufs, 'skipped on non-ufs filesystem')
|
57
|
+
assert_nil(File.acl_read(@@file1))
|
58
|
+
assert_kind_of(Array, File.acl_read(@@file2))
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_singleton_acl_read_expected_errors
|
62
|
+
assert_raise(Errno::ENOENT){ File.acl_read('bogus') }
|
63
|
+
assert_raise(ArgumentError){ File.acl_read('bogus' * 500) }
|
64
|
+
assert_raise(ArgumentError){ File.acl_read }
|
65
|
+
assert_raise(TypeError){ File.acl_read(1) }
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_singleton_acl_read_text_basic
|
69
|
+
omit_unless(@@ufs, 'skipped on non-ufs filesystem')
|
70
|
+
assert_respond_to(File, :acl_read_text)
|
71
|
+
assert_nothing_raised{ File.acl_read_text(@@file1) }
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_singleton_acl_read_text
|
75
|
+
omit_unless(@@ufs, 'skipped on non-ufs filesystem')
|
76
|
+
assert_nil(File.acl_read_text(@@file1))
|
77
|
+
assert_kind_of(String,File.acl_read_text(@@file2))
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_singleton_acl_read_text_expected_errors
|
81
|
+
assert_raise(Errno::ENOENT){ File.acl_read_text('bogus') }
|
82
|
+
assert_raise(ArgumentError){ File.acl_read_text }
|
83
|
+
assert_raise(TypeError){ File.acl_read_text(1) }
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_singleton_acl_write_text
|
87
|
+
omit_unless(@@ufs, 'skipped on non-ufs filesystem')
|
88
|
+
acl_text = 'user::rw-,group::r--,mask:r--,other:---'
|
89
|
+
assert_respond_to(File, :acl_write_text)
|
90
|
+
assert_nothing_raised{ File.acl_write_text(@@file1, acl_text) }
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_singleton_acl_write_text_expected_errors
|
94
|
+
assert_raise(File::SolarisError){ File.acl_write_text(@@file1, 'bogus') }
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_singleton_acl_trivial_basic
|
98
|
+
assert_respond_to(File, :trivial?)
|
99
|
+
assert_nothing_raised{ File.trivial?(@@file1) }
|
100
|
+
assert_boolean(File.trivial?(@@file1))
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_singleton_acl_trivial
|
104
|
+
omit_unless(@@ufs, 'skipped on non-ufs filesystem')
|
105
|
+
assert_true(File.trivial?(@@file1))
|
106
|
+
assert_false(File.trivial?(@@file2))
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_singleton_acl_trivial_expected_errors
|
110
|
+
assert_raise(Errno::ENOENT){ File.trivial?('bogus') }
|
111
|
+
assert_raise(ArgumentError){ File.trivial?('bogus' * 500) }
|
112
|
+
assert_raise(ArgumentError){ File.trivial? }
|
113
|
+
assert_raise(TypeError){ File.trivial?(1) }
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_singleton_acl_count
|
117
|
+
assert_respond_to(File, :acl_count)
|
118
|
+
assert_nothing_raised{ File.acl_count(@@file1) }
|
119
|
+
assert_kind_of(Fixnum, File.acl_count(@@file1))
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_singleton_acl_count_expected_errors
|
123
|
+
assert_raise(Errno::ENOENT){ File.acl_count('bogus') }
|
124
|
+
assert_raise(ArgumentError){ File.acl_count('bogus' * 500) }
|
125
|
+
assert_raise(ArgumentError){ File.acl_count }
|
126
|
+
assert_raise(TypeError){ File.acl_count(1) }
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_singleton_realpath_basic
|
130
|
+
assert_respond_to(File, :realpath)
|
131
|
+
assert_nothing_raised{ File.realpath(@dir) }
|
132
|
+
assert_kind_of(String, File.realpath(@dir))
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_singleton_realpath
|
136
|
+
dir1 = File.join(File.dirname(Dir.pwd), 'examples')
|
137
|
+
dir2 = File.join(Dir.pwd, '/.././examples')
|
138
|
+
|
139
|
+
assert_equal(@dir, File.realpath(@dir))
|
140
|
+
assert_equal(dir1, File.realpath(dir2))
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_singleton_realpath_expected_errors
|
144
|
+
assert_raise(Errno::ENOENT){ File.realpath('bogus') }
|
145
|
+
assert_raise(ArgumentError){ File.realpath }
|
146
|
+
assert_raise(TypeError){ File.realpath(1) }
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_singleton_resolvepath_basic
|
150
|
+
assert_respond_to(File, :resolvepath)
|
151
|
+
assert_nothing_raised{ File.resolvepath(@dir) }
|
152
|
+
assert_kind_of(String, File.resolvepath(@dir))
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_singleton_resolvepath
|
156
|
+
assert_equal(@dir, File.resolvepath(@dir))
|
157
|
+
assert_equal("../examples", File.resolvepath("../examples"))
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_singleton_resolvepath_expected_errors
|
161
|
+
assert_raise(Errno::ENOENT){ File.resolvepath('bogus') }
|
162
|
+
assert_raise(ArgumentError){ File.resolvepath }
|
163
|
+
assert_raise(TypeError){ File.resolvepath(1) }
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_singleton_is_door_basic
|
167
|
+
assert_respond_to(File, :door?)
|
168
|
+
assert_nothing_raised{ File.door?(@door) }
|
169
|
+
assert_boolean(File.door?(@door))
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_singleton_is_door
|
173
|
+
assert_true(File.door?(@door))
|
174
|
+
assert_false(File.door?(Dir.pwd))
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_singleton_is_door_expected_errors
|
178
|
+
assert_raise(Errno::ENOENT){ File.door?('bogus') }
|
179
|
+
assert_raise(ArgumentError){ File.door? }
|
180
|
+
assert_raise(TypeError){ File.door?(1) }
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_singleton_ftype_basic
|
184
|
+
assert_respond_to(File, :ftype)
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_singleton_ftype
|
188
|
+
assert_equal('door', File.ftype(@door))
|
189
|
+
assert_equal('directory', File.ftype(Dir.pwd))
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_singleton_ftype_expected_errors
|
193
|
+
assert_raise(Errno::ENOENT){ File.ftype('bogus') }
|
194
|
+
assert_raise(ArgumentError){ File.ftype }
|
195
|
+
assert_raise(TypeError){ File.ftype(1) }
|
196
|
+
end
|
197
|
+
|
198
|
+
# INSTANCE METHODS
|
199
|
+
|
200
|
+
def test_instance_acl_basic
|
201
|
+
omit_unless(@@ufs, 'skipped on non-ufs filesystem')
|
202
|
+
assert_respond_to(@handle1, :acl_read)
|
203
|
+
assert_nothing_raised{ @handle1.acl_read }
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_instance_acl
|
207
|
+
omit_unless(@@ufs, 'skipped on non-ufs filesystem')
|
208
|
+
assert_nil(@handle1.acl_read)
|
209
|
+
assert_kind_of(Array, @handle2.acl_read)
|
210
|
+
assert_kind_of(Struct::ACLStruct, @handle2.acl_read.first)
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_instance_acl_read_text_basic
|
214
|
+
omit_unless(@@ufs, 'skipped on non-ufs filesystem')
|
215
|
+
assert_respond_to(@handle1, :acl_read_text)
|
216
|
+
assert_nothing_raised{ @handle1.acl_read_text }
|
217
|
+
end
|
218
|
+
|
219
|
+
def test_instance_acl_read_text
|
220
|
+
omit_unless(@@ufs, 'skipped on non-ufs filesystem')
|
221
|
+
assert_nil(@handle1.acl_read_text)
|
222
|
+
assert_kind_of(String, @handle2.acl_read_text)
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_instance_acl_write_text
|
226
|
+
omit_unless(@@ufs, 'skipped on non-ufs filesystem')
|
227
|
+
acl_text = 'user::rw-,group::r--,mask:r--,other:---'
|
228
|
+
assert_respond_to(@handle2, :acl_write_text)
|
229
|
+
assert_nothing_raised{ @handle2.acl_write_text(acl_text) }
|
230
|
+
end
|
231
|
+
|
232
|
+
def test_instance_acl_write_text_expected_errors
|
233
|
+
assert_raise(File::SolarisError){ @handle2.acl_write_text('bogus') }
|
234
|
+
assert_raise(ArgumentError){ @handle2.acl_write_text }
|
235
|
+
assert_raise(TypeError){ @handle2.acl_write_text(1) }
|
236
|
+
end
|
237
|
+
|
238
|
+
def test_instance_acl_trivial_basic
|
239
|
+
assert_respond_to(@handle1, :trivial?)
|
240
|
+
assert_nothing_raised{ @handle1.trivial? }
|
241
|
+
assert_boolean(@handle1.trivial?)
|
242
|
+
end
|
243
|
+
|
244
|
+
def test_instance_acl_trivial
|
245
|
+
assert_true(@handle1.trivial?)
|
246
|
+
assert_false(@handle2.trivial?)
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_instance_acl_count_basic
|
250
|
+
omit_unless(@@ufs, 'skipped on non-ufs filesystem')
|
251
|
+
assert_respond_to(@handle1, :acl_count)
|
252
|
+
assert_nothing_raised{ @handle1.acl_count }
|
253
|
+
assert_kind_of(Fixnum, @handle1.acl_count)
|
254
|
+
end
|
255
|
+
|
256
|
+
def test_instance_acl_count
|
257
|
+
omit_unless(@@ufs, 'skipped on non-ufs filesystem')
|
258
|
+
assert_equal(0, @handle1.acl_count)
|
259
|
+
assert_equal(6, @handle2.acl_count)
|
260
|
+
end
|
261
|
+
|
262
|
+
def test_stat_door
|
263
|
+
assert_respond_to(@stat, :door?)
|
264
|
+
assert_true(@stat.door?)
|
265
|
+
end
|
266
|
+
|
267
|
+
def test_stat_ftype
|
268
|
+
assert_respond_to(@stat, :ftype)
|
269
|
+
assert_equal('door', @stat.ftype)
|
270
|
+
end
|
271
|
+
|
272
|
+
def teardown
|
273
|
+
@handle1.close unless @handle1.closed?
|
274
|
+
@handle2.close unless @handle2.closed?
|
275
|
+
|
276
|
+
@dir = nil
|
277
|
+
@handle1 = nil
|
278
|
+
@handle2 = nil
|
279
|
+
end
|
280
|
+
|
281
|
+
def self.shutdown
|
282
|
+
File.delete(@@file1) if File.exists?(@@file1)
|
283
|
+
File.delete(@@file2) if File.exists?(@@file2)
|
284
|
+
|
285
|
+
@@ufs = nil
|
286
|
+
@@file1 = nil
|
287
|
+
@@file2 = nil
|
288
|
+
@@acl_text = nil
|
289
|
+
end
|
290
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solaris-file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -9,11 +9,30 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-08-28 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: test-unit
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.0.3
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: sys-filesystem
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.3.1
|
34
|
+
version:
|
35
|
+
description: " The solaris-file library provides Solaris-specific access control\n methods to the File class. It also provides methods for identifying\n trivial and door files, interfaces for the realpath() and resolvepath()\n functions, and an overloaded ftype method.\n"
|
17
36
|
email: djberg96@gmail.com
|
18
37
|
executables: []
|
19
38
|
|
@@ -25,22 +44,20 @@ extra_rdoc_files:
|
|
25
44
|
- MANIFEST
|
26
45
|
- ext/solaris/sfile.c
|
27
46
|
files:
|
47
|
+
- CHANGES
|
48
|
+
- MANIFEST
|
49
|
+
- README
|
50
|
+
- Rakefile
|
51
|
+
- solaris-file.gemspec
|
52
|
+
- examples/example_solaris_file.rb
|
28
53
|
- ext/extconf.rb
|
29
|
-
- ext/solaris
|
30
54
|
- ext/solaris/sfile.c
|
31
55
|
- ext/solaris/sfile.h
|
32
|
-
-
|
33
|
-
- ext/mkmf.log
|
34
|
-
- ext/Makefile
|
35
|
-
- ext/sfile.o
|
36
|
-
- ext/file.so
|
37
|
-
- test/tc_solaris_file.rb
|
38
|
-
- examples/test.rb
|
39
|
-
- README
|
40
|
-
- CHANGES
|
41
|
-
- MANIFEST
|
56
|
+
- test/test_solaris_file.rb
|
42
57
|
has_rdoc: true
|
43
58
|
homepage: http://www.rubyforge.org/projects/solarisutils
|
59
|
+
licenses:
|
60
|
+
- Artistic 2.0
|
44
61
|
post_install_message:
|
45
62
|
rdoc_options: []
|
46
63
|
|
@@ -50,7 +67,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
67
|
requirements:
|
51
68
|
- - ">="
|
52
69
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
70
|
+
version: "0"
|
54
71
|
version:
|
55
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
73
|
requirements:
|
@@ -61,9 +78,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
78
|
requirements: []
|
62
79
|
|
63
80
|
rubyforge_project: solarisutils
|
64
|
-
rubygems_version: 1.
|
81
|
+
rubygems_version: 1.3.5
|
65
82
|
signing_key:
|
66
|
-
specification_version:
|
83
|
+
specification_version: 3
|
67
84
|
summary: ACL and other methods for the File class on Solaris
|
68
85
|
test_files:
|
69
|
-
- test/
|
86
|
+
- test/test_solaris_file.rb
|
data/ext/Makefile
DELETED
@@ -1,149 +0,0 @@
|
|
1
|
-
|
2
|
-
SHELL = /bin/sh
|
3
|
-
|
4
|
-
#### Start of system configuration section. ####
|
5
|
-
|
6
|
-
srcdir = solaris
|
7
|
-
topdir = /usr/local/lib/ruby/1.8/sparc-solaris2.10
|
8
|
-
hdrdir = $(topdir)
|
9
|
-
VPATH = $(srcdir):$(topdir):$(hdrdir)
|
10
|
-
prefix = $(DESTDIR)/usr/local
|
11
|
-
exec_prefix = $(prefix)
|
12
|
-
sitedir = $(prefix)/lib/ruby/site_ruby
|
13
|
-
rubylibdir = $(libdir)/ruby/$(ruby_version)
|
14
|
-
docdir = $(datarootdir)/doc/$(PACKAGE)
|
15
|
-
dvidir = $(docdir)
|
16
|
-
datarootdir = $(prefix)/share
|
17
|
-
archdir = $(rubylibdir)/$(arch)
|
18
|
-
sbindir = $(exec_prefix)/sbin
|
19
|
-
psdir = $(docdir)
|
20
|
-
localedir = $(datarootdir)/locale
|
21
|
-
htmldir = $(docdir)
|
22
|
-
datadir = $(datarootdir)
|
23
|
-
includedir = $(prefix)/include
|
24
|
-
infodir = $(datarootdir)/info
|
25
|
-
sysconfdir = $(prefix)/etc
|
26
|
-
mandir = $(datarootdir)/man
|
27
|
-
libdir = $(exec_prefix)/lib
|
28
|
-
sharedstatedir = $(prefix)/com
|
29
|
-
oldincludedir = $(DESTDIR)/usr/include
|
30
|
-
pdfdir = $(docdir)
|
31
|
-
sitearchdir = $(sitelibdir)/$(sitearch)
|
32
|
-
bindir = $(exec_prefix)/bin
|
33
|
-
localstatedir = $(prefix)/var
|
34
|
-
sitelibdir = $(sitedir)/$(ruby_version)
|
35
|
-
libexecdir = $(exec_prefix)/libexec
|
36
|
-
|
37
|
-
CC = cc
|
38
|
-
LIBRUBY = $(LIBRUBY_A)
|
39
|
-
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
40
|
-
LIBRUBYARG_SHARED = -R $(libdir) -L$(libdir)
|
41
|
-
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
42
|
-
|
43
|
-
RUBY_EXTCONF_H =
|
44
|
-
CFLAGS = -KPIC -dalign -fns -xbuiltin=%all -xlibmil -xtarget=ultra2e -xO5 -xipo
|
45
|
-
INCFLAGS = -I. -I. -I/usr/local/lib/ruby/1.8/sparc-solaris2.10 -I. -Isolaris -Isolaris
|
46
|
-
CPPFLAGS =
|
47
|
-
CXXFLAGS = $(CFLAGS)
|
48
|
-
DLDFLAGS = -L.
|
49
|
-
LDSHARED = ld -G
|
50
|
-
AR = ar
|
51
|
-
EXEEXT =
|
52
|
-
|
53
|
-
RUBY_INSTALL_NAME = ruby
|
54
|
-
RUBY_SO_NAME = ruby
|
55
|
-
arch = sparc-solaris2.10
|
56
|
-
sitearch = sparc-solaris2.10
|
57
|
-
ruby_version = 1.8
|
58
|
-
ruby = /usr/local/bin/ruby
|
59
|
-
RUBY = $(ruby)
|
60
|
-
RM = rm -f
|
61
|
-
MAKEDIRS = mkdir -p
|
62
|
-
INSTALL = /opt/csw/bin/ginstall -c
|
63
|
-
INSTALL_PROG = $(INSTALL) -m 0755
|
64
|
-
INSTALL_DATA = $(INSTALL) -m 644
|
65
|
-
COPY = cp
|
66
|
-
|
67
|
-
#### End of system configuration section. ####
|
68
|
-
|
69
|
-
preload =
|
70
|
-
|
71
|
-
libpath = . $(libdir)
|
72
|
-
LIBPATH = -L'.' -L'$(libdir)' -R'$(libdir)'
|
73
|
-
DEFFILE =
|
74
|
-
|
75
|
-
CLEANFILES = mkmf.log
|
76
|
-
DISTCLEANFILES =
|
77
|
-
|
78
|
-
extout =
|
79
|
-
extout_prefix =
|
80
|
-
target_prefix = /solaris
|
81
|
-
LOCAL_LIBS =
|
82
|
-
LIBS = -lsec -ldl -lcrypt -lm -lc
|
83
|
-
SRCS = sfile.c
|
84
|
-
OBJS = sfile.o
|
85
|
-
TARGET = file
|
86
|
-
DLLIB = $(TARGET).so
|
87
|
-
EXTSTATIC =
|
88
|
-
STATIC_LIB =
|
89
|
-
|
90
|
-
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
91
|
-
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
92
|
-
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
93
|
-
|
94
|
-
TARGET_SO = $(DLLIB)
|
95
|
-
CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
|
96
|
-
CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
|
97
|
-
|
98
|
-
all: $(DLLIB)
|
99
|
-
static: $(STATIC_LIB)
|
100
|
-
|
101
|
-
clean:
|
102
|
-
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
103
|
-
|
104
|
-
distclean: clean
|
105
|
-
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
106
|
-
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
107
|
-
|
108
|
-
realclean: distclean
|
109
|
-
install: install-so install-rb
|
110
|
-
|
111
|
-
install-so: $(RUBYARCHDIR)
|
112
|
-
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
113
|
-
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
114
|
-
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
|
115
|
-
install-rb: pre-install-rb install-rb-default
|
116
|
-
install-rb-default: pre-install-rb-default
|
117
|
-
pre-install-rb: Makefile
|
118
|
-
pre-install-rb-default: Makefile
|
119
|
-
$(RUBYARCHDIR):
|
120
|
-
$(MAKEDIRS) $@
|
121
|
-
|
122
|
-
site-install: site-install-so site-install-rb
|
123
|
-
site-install-so: install-so
|
124
|
-
site-install-rb: install-rb
|
125
|
-
|
126
|
-
.SUFFIXES: .c .m .cc .cxx .cpp .C .o
|
127
|
-
|
128
|
-
.cc.o:
|
129
|
-
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
130
|
-
|
131
|
-
.cxx.o:
|
132
|
-
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
133
|
-
|
134
|
-
.cpp.o:
|
135
|
-
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
136
|
-
|
137
|
-
.C.o:
|
138
|
-
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
139
|
-
|
140
|
-
.c.o:
|
141
|
-
$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
|
142
|
-
|
143
|
-
$(DLLIB): $(OBJS)
|
144
|
-
@-$(RM) $@
|
145
|
-
$(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
$(OBJS): ruby.h defines.h
|
data/ext/file.so
DELETED
Binary file
|
data/ext/mkmf.log
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
have_library: checking for main() in -lsec... -------------------- yes
|
2
|
-
|
3
|
-
"cc -o conftest -I. -I/usr/local/lib/ruby/1.8/sparc-solaris2.10 -I. -Isolaris -dalign -fns -xbuiltin=%all -xlibmil -xtarget=ultra2e -xO5 -xipo conftest.c -L'.' -L'/usr/local/lib' -R'/usr/local/lib' -L. -lruby-static -lsec -ldl -lcrypt -lm -lc"
|
4
|
-
cc: Warning: -xarch=native has been explicitly specified, or implicitly specified by a macro option, -xarch=native on this architecture implies -xarch=sparcvis which generates code that does not run on pre UltraSPARC processors
|
5
|
-
checked program was:
|
6
|
-
/* begin */
|
7
|
-
1: /*top*/
|
8
|
-
2: int main() { return 0; }
|
9
|
-
3: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
|
10
|
-
/* end */
|
11
|
-
|
12
|
-
--------------------
|
13
|
-
|
data/ext/sfile.o
DELETED
Binary file
|
data/ext/solaris/file.so
DELETED
Binary file
|
data/test/tc_solaris_file.rb
DELETED
@@ -1,174 +0,0 @@
|
|
1
|
-
###############################################################################
|
2
|
-
# tc_solaris_file.rb
|
3
|
-
#
|
4
|
-
# Test suite for the solaris-file package. You should run this test case
|
5
|
-
# via the 'rake test' task.
|
6
|
-
###############################################################################
|
7
|
-
require 'test/unit'
|
8
|
-
require 'solaris/file'
|
9
|
-
|
10
|
-
class TC_Solaris_File < Test::Unit::TestCase
|
11
|
-
def setup
|
12
|
-
Dir.chdir('test') unless File.basename(Dir.pwd) == 'test'
|
13
|
-
@dir = Dir.pwd
|
14
|
-
@file = "foo.txt" # trivial
|
15
|
-
@file2 = "bar.txt" # non-trivial
|
16
|
-
@door = "/var/run/syslog_door"
|
17
|
-
@stat = File::Stat.new(@door)
|
18
|
-
|
19
|
-
@acl_text = "user::rw-,user:nobody:r--,"
|
20
|
-
@acl_text << "group::r--,group:sys:r--,mask:r--,other:r--"
|
21
|
-
|
22
|
-
File.open(@file,"w+"){ |fh| fh.puts "foo" } unless File.exists?(@file)
|
23
|
-
File.open(@file2,"w+"){ |fh| fh.puts "bar" } unless File.exists?(@file2)
|
24
|
-
|
25
|
-
system("chmod A=#{@acl_text} #{@file2}") # Make @file2 non-trivial
|
26
|
-
|
27
|
-
@fh = File.open(@file)
|
28
|
-
@fh2 = File.open(@file2)
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_version
|
32
|
-
assert_equal('0.3.4', File::SOLARIS_VERSION)
|
33
|
-
end
|
34
|
-
|
35
|
-
# CLASS METHODS
|
36
|
-
|
37
|
-
# This yields an ACL struct for each entry
|
38
|
-
def test_class_acl_read
|
39
|
-
assert_respond_to(File,:acl_read)
|
40
|
-
assert_nothing_raised{ File.acl_read(@file) }
|
41
|
-
assert_equal(nil,File.acl_read(@file))
|
42
|
-
assert_kind_of(Array,File.acl_read(@file2))
|
43
|
-
assert_raises(Errno::ENOENT){ File.acl_read("bogus") }
|
44
|
-
assert_raises(ArgumentError){ File.acl_read("bogus"*500) }
|
45
|
-
end
|
46
|
-
|
47
|
-
# Tests the acltotext() approach
|
48
|
-
def test_class_acl_read_text
|
49
|
-
assert_respond_to(File,:acl_read_text)
|
50
|
-
assert_nothing_raised{ File.acl_read_text(@file) }
|
51
|
-
assert_kind_of(NilClass,File.acl_read_text(@file))
|
52
|
-
assert_kind_of(String,File.acl_read_text(@file2))
|
53
|
-
assert_raises(Errno::ENOENT){ File.acl_read_text("bogus") }
|
54
|
-
end
|
55
|
-
|
56
|
-
# Tests the aclfromtext() approach
|
57
|
-
def test_class_acl_write_text
|
58
|
-
text = "user::rw-,group::r--,mask:r--,other:---"
|
59
|
-
assert_respond_to(File,:acl_write_text)
|
60
|
-
assert_nothing_raised{ File.acl_write_text(@file,text) }
|
61
|
-
assert_raises(File::SolarisError){ File.acl_write_text(@file,"bogus") }
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_class_acl_trivial
|
65
|
-
assert_respond_to(File,:trivial?)
|
66
|
-
assert_nothing_raised{ File.trivial?(@file) }
|
67
|
-
assert_equal(true,File.trivial?(@file))
|
68
|
-
assert_equal(false,File.trivial?(@file2))
|
69
|
-
assert_raises(Errno::ENOENT){ File.trivial?("bogus") }
|
70
|
-
assert_raises(ArgumentError){ File.trivial?("bogus"*500) }
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_class_acl_count
|
74
|
-
assert_respond_to(File, :acl_count)
|
75
|
-
assert_nothing_raised{ File.acl_count(@file) }
|
76
|
-
assert_kind_of(Fixnum, File.acl_count(@file))
|
77
|
-
assert_raises(Errno::ENOENT){ File.acl_count("bogus") }
|
78
|
-
assert_raises(ArgumentError){ File.acl_count("bogus"*500) }
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_class_realpath
|
82
|
-
dir1 = File.dirname(Dir.pwd) + "/examples"
|
83
|
-
dir2 = Dir.pwd + "/.././examples"
|
84
|
-
|
85
|
-
assert_respond_to(File, :realpath)
|
86
|
-
assert_nothing_raised{ File.realpath(@dir) }
|
87
|
-
assert_equal(@dir, File.realpath(@dir))
|
88
|
-
assert_equal(dir1, File.realpath(dir2))
|
89
|
-
assert_raises(Errno::ENOENT){ File.realpath("bogus") }
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_class_resolvepath
|
93
|
-
assert_respond_to(File, :resolvepath)
|
94
|
-
assert_nothing_raised{ File.resolvepath(@dir) }
|
95
|
-
assert_equal(@dir, File.resolvepath(@dir))
|
96
|
-
assert_equal("../examples", File.resolvepath("../examples"))
|
97
|
-
assert_raises(Errno::ENOENT){ File.resolvepath("bogus") }
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_class_is_door
|
101
|
-
assert_respond_to(File, :door?)
|
102
|
-
assert_equal(true, File.door?(@door))
|
103
|
-
assert_equal(false, File.door?(Dir.pwd))
|
104
|
-
assert_raises(Errno::ENOENT){ File.door?("bogus") }
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_class_ftype
|
108
|
-
assert_respond_to(File, :ftype)
|
109
|
-
assert_equal('door', File.ftype(@door))
|
110
|
-
assert_equal('directory', File.ftype(Dir.pwd))
|
111
|
-
assert_raises(Errno::ENOENT){ File.ftype("bogus") }
|
112
|
-
end
|
113
|
-
|
114
|
-
# INSTANCE METHODS
|
115
|
-
|
116
|
-
def test_instance_acl
|
117
|
-
assert_respond_to(@fh, :acl_read)
|
118
|
-
assert_nothing_raised{ @fh.acl_read }
|
119
|
-
assert_equal(nil, @fh.acl_read)
|
120
|
-
assert_kind_of(Array, @fh2.acl_read)
|
121
|
-
assert_kind_of(Struct::ACLStruct, @fh2.acl_read.first)
|
122
|
-
end
|
123
|
-
|
124
|
-
# Tests the acltotext() approach
|
125
|
-
def test_instance_acl_read_text
|
126
|
-
assert_respond_to(@fh,:acl_read_text)
|
127
|
-
assert_nothing_raised{ @fh.acl_read_text }
|
128
|
-
assert_equal(nil, @fh.acl_read_text)
|
129
|
-
assert_kind_of(String, @fh2.acl_read_text)
|
130
|
-
end
|
131
|
-
|
132
|
-
# Tests the aclfromtext() approach
|
133
|
-
def test_instance_acl_write_text
|
134
|
-
text = "user::rw-,group::r--,mask:r--,other:---"
|
135
|
-
assert_respond_to(@fh2,:acl_write_text)
|
136
|
-
assert_nothing_raised{ @fh2.acl_write_text(text) }
|
137
|
-
assert_raises(File::SolarisError){ @fh2.acl_write_text("bogus") }
|
138
|
-
end
|
139
|
-
|
140
|
-
def test_instance_acl_trivial
|
141
|
-
assert_respond_to(@fh, :trivial?)
|
142
|
-
assert_nothing_raised{ @fh.trivial? }
|
143
|
-
assert_equal(true, @fh.trivial?)
|
144
|
-
assert_equal(false, @fh2.trivial?)
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_instance_acl_count
|
148
|
-
assert_respond_to(@fh,:acl_count)
|
149
|
-
assert_nothing_raised{ @fh.acl_count }
|
150
|
-
assert_kind_of(Fixnum,@fh.acl_count)
|
151
|
-
assert_equal(0, @fh.acl_count)
|
152
|
-
assert_equal(6, @fh2.acl_count)
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_stat_door
|
156
|
-
assert_respond_to(@stat, :door?)
|
157
|
-
assert_equal(true, @stat.door?)
|
158
|
-
end
|
159
|
-
|
160
|
-
def test_stat_ftype
|
161
|
-
assert_respond_to(@stat, :ftype)
|
162
|
-
assert_equal('door', @stat.ftype)
|
163
|
-
end
|
164
|
-
|
165
|
-
def teardown
|
166
|
-
@dir = nil
|
167
|
-
@fh.close
|
168
|
-
@fh2.close
|
169
|
-
File.delete(@file) if File.exists?(@file)
|
170
|
-
File.delete(@file2) if File.exists?(@file2)
|
171
|
-
@file = nil
|
172
|
-
@file2 = nil
|
173
|
-
end
|
174
|
-
end
|