mincore 0.0.9.3.pre.6 → 0.0.9.3.pre.7
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
- data/bin/cachedel.rb +31 -0
- data/mincore.gemspec +2 -2
- data/test/mincore_test.rb +13 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e5c35f3711938cde082b35aa1028132c750477a
|
4
|
+
data.tar.gz: 0e96b1aa962394b0c0f0a5f1e3617a31c563f6f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0e2e583d91760146b5da9714af8801962739e6b35fc0388b1411a4db8f96a7042d31f043afa28c3b1221eacbbb1c722067bed6b02641037c56389744cc2bfaf
|
7
|
+
data.tar.gz: 5de7a220501f2ec55b5fedcea2850092e5da0d389cb05fbcae938d6e93a740ca1a51778cd791a143e8261db6663ab570d5033a93780d4d739cb0f8ece75c9066
|
data/bin/cachedel.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Simple script to _attempt_ to purge the cached pages of a (single) file.
|
3
|
+
|
4
|
+
require 'mincore'
|
5
|
+
|
6
|
+
def process_errno(e)
|
7
|
+
puts e.message
|
8
|
+
exit 1
|
9
|
+
end
|
10
|
+
|
11
|
+
def process_unknown_exception(e)
|
12
|
+
puts "Unknown caught exception: #{e.message}"
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
|
16
|
+
def process_file(filename)
|
17
|
+
begin
|
18
|
+
retcode = File.cachedel(filename, 2)
|
19
|
+
puts "retcode=#{retcode}" if ENV["DEBUG"]
|
20
|
+
exit retcode unless retcode == 0
|
21
|
+
rescue Errno::EBADF => e
|
22
|
+
process_errno e
|
23
|
+
rescue Errno::EACCES => e
|
24
|
+
process_errno e
|
25
|
+
rescue Exception => e
|
26
|
+
process_unknown_exception e
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
process_file(ARGV[0])
|
31
|
+
|
data/mincore.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'mincore'
|
3
|
-
s.version = '0.0.9.3.pre.
|
3
|
+
s.version = '0.0.9.3.pre.7'
|
4
4
|
s.date = '2013-11-19'
|
5
5
|
|
6
6
|
s.homepage = 'http://github.com/noushi/ruby-mincore'
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
#s.files = ["lib/mincore.rb"]
|
22
22
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
23
23
|
|
24
|
-
s.executables
|
24
|
+
s.executables = ["cachestats.rb", "cachedel.rb"]
|
25
25
|
|
26
26
|
s.add_runtime_dependency "RubyInline", [">= 3.10.1"]
|
27
27
|
s.add_development_dependency "RubyInline", [">= 3.10.1"]
|
data/test/mincore_test.rb
CHANGED
@@ -93,10 +93,20 @@ class MincoreTest < Test::Unit::TestCase
|
|
93
93
|
_generic_cachedel_test 0
|
94
94
|
end
|
95
95
|
|
96
|
+
# This test works when the file size is big enough (worked with 4MB and 40MB).
|
97
|
+
# On smaller files, file keeps being cached (tried with <400KB)
|
96
98
|
def test_cachedel_non_empty_file
|
97
|
-
_generic_cachedel_test
|
99
|
+
_generic_cachedel_test 4000
|
98
100
|
end
|
99
101
|
|
102
|
+
def test_cachedel_devnull
|
103
|
+
assert_raise(Errno::EBADF) { File.cachedel("/dev/null") }
|
104
|
+
end
|
105
|
+
|
106
|
+
# don't run this as root, mincore() will succeed!
|
107
|
+
def test_cachedel_etcshadow
|
108
|
+
assert_raise(Errno::EACCES) { File.cachedel("/etc/shadow") }
|
109
|
+
end
|
100
110
|
|
101
111
|
def _generic_mincore_test(size_kb, result=nil, delete=true)
|
102
112
|
size = size_kb * 1024
|
@@ -145,7 +155,8 @@ class MincoreTest < Test::Unit::TestCase
|
|
145
155
|
assert_equal ret, pieces.tinify, f.describe
|
146
156
|
else
|
147
157
|
ret = [[true, f.numpages]]
|
148
|
-
|
158
|
+
feeling_lucky = true # see test_cachedel_non_empty_file() doc to understand this
|
159
|
+
if feeling_lucky or ret != pieces.tinify #The code/test is still valid even if the file is fully kept cached
|
149
160
|
assert_not_equal ret, pieces.tinify, f.describe
|
150
161
|
end
|
151
162
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mincore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.9.3.pre.
|
4
|
+
version: 0.0.9.3.pre.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reda NOUSHI
|
@@ -45,6 +45,7 @@ description: " mincore provides Ruby bindings for Linux cache manipulation, \
|
|
45
45
|
email: reda_noushi@yahoo.com
|
46
46
|
executables:
|
47
47
|
- cachestats.rb
|
48
|
+
- cachedel.rb
|
48
49
|
extensions: []
|
49
50
|
extra_rdoc_files: []
|
50
51
|
files:
|
@@ -55,6 +56,7 @@ files:
|
|
55
56
|
- README.md
|
56
57
|
- Rakefile
|
57
58
|
- TODO
|
59
|
+
- bin/cachedel.rb
|
58
60
|
- bin/cachestats.rb
|
59
61
|
- bin/ci/before_build.sh
|
60
62
|
- lib/mincore.rb
|
@@ -82,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
84
|
version: 1.3.1
|
83
85
|
requirements: []
|
84
86
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.0.3
|
86
88
|
signing_key:
|
87
89
|
specification_version: 4
|
88
90
|
summary: Ruby bindings for Linux cache manipulation
|
@@ -90,4 +92,3 @@ test_files:
|
|
90
92
|
- test/mincore_test.rb
|
91
93
|
- test/test_helper.rb
|
92
94
|
- test/tinify_test.rb
|
93
|
-
has_rdoc:
|