pacct 0.8.2-universal-linux → 0.8.3-universal-linux
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/ext/pacct/pacct_c.c +9 -19
- data/lib/pacct/version.rb +1 -1
- data/spec/entry_spec.rb +17 -7
- metadata +35 -50
data/ext/pacct/pacct_c.c
CHANGED
@@ -41,22 +41,11 @@ static VALUE known_groups_by_id = Qnil;
|
|
41
41
|
static int pageSize;
|
42
42
|
static long ticksPerSecond;
|
43
43
|
|
44
|
-
//Converts a comp_t to a
|
44
|
+
//Converts a comp_t to a ulong
|
45
45
|
static unsigned long comp_t_to_ulong(comp_t c) {
|
46
46
|
return (unsigned long)(c & 0x1fff) << (((c >> 13) & 0x7) * 3);
|
47
47
|
}
|
48
48
|
|
49
|
-
//Prints a number in binary (for debugging)
|
50
|
-
static void print_bin(unsigned long val) {
|
51
|
-
//Cast prevents warning
|
52
|
-
unsigned long bits = (unsigned long)1 << (sizeof(unsigned long) * 8 - 1);
|
53
|
-
putchar('0' + ((val & bits) > 0));
|
54
|
-
while(bits >>= 1) {
|
55
|
-
putchar('0' + ((val & bits) > 0));
|
56
|
-
}
|
57
|
-
putchar('\n');
|
58
|
-
}
|
59
|
-
|
60
49
|
//Converts a long to a comp_t
|
61
50
|
//To consider: make sure the value is positive?
|
62
51
|
//To consider: more unit testing?
|
@@ -74,16 +63,15 @@ static comp_t ulong_to_comp_t(unsigned long l) {
|
|
74
63
|
} else {
|
75
64
|
size_t div_bits, rem_bits;
|
76
65
|
bits -= 13;
|
77
|
-
|
78
|
-
if(div_bits >= 8) {
|
79
|
-
rb_raise(rb_eRangeError, "Exponent overflow in ulong_to_comp_t: Value %lu is too large.", l);
|
80
|
-
}
|
81
|
-
rem_bits = bits - div_bits * 3;
|
66
|
+
rem_bits = bits % 3;
|
82
67
|
if(rem_bits) {
|
83
|
-
|
68
|
+
bits += (3 - rem_bits);
|
69
|
+
}
|
70
|
+
if(bits >= 24) {
|
71
|
+
rb_raise(rb_eRangeError, "Exponent overflow in ulong_to_comp_t: Value %lu is too large.", l);
|
84
72
|
}
|
85
73
|
//To consider: remove '&'?
|
86
|
-
return ((l >> bits) & 0x1fff) | ((
|
74
|
+
return ((l >> bits) & 0x1fff) | ((bits / 3) << 13);
|
87
75
|
}
|
88
76
|
}
|
89
77
|
|
@@ -855,5 +843,7 @@ void Init_pacct_c() {
|
|
855
843
|
rb_define_module_function(mTest, "write_failure", test_write_failure, 0);
|
856
844
|
rb_define_module_function(mTest, "read_failure", test_read_failure, 0);
|
857
845
|
rb_define_module_function(mTest, "comp_t_to_ulong", test_comp_t_to_ulong, 1);
|
846
|
+
//To do: create unit test.
|
847
|
+
rb_define_module_function(mTest, "ulong_to_comp_t", test_ulong_to_comp_t, 1);
|
858
848
|
}
|
859
849
|
}
|
data/lib/pacct/version.rb
CHANGED
data/spec/entry_spec.rb
CHANGED
@@ -8,13 +8,23 @@ describe Pacct::Entry do
|
|
8
8
|
comp_t_to_ulong.call((3 << 13) | 20).should eql(20 << 9)
|
9
9
|
end
|
10
10
|
|
11
|
-
#To do: unit test this (eventually).
|
12
|
-
=begin
|
13
11
|
it "correctly converts integers to \"comp_t\"s" do
|
14
|
-
|
12
|
+
ulong_to_comp_t = Pacct::Test.method(:ulong_to_comp_t)
|
13
|
+
comp_t_to_ulong = Pacct::Test.method(:comp_t_to_ulong)
|
14
|
+
ulong_to_comp_t.call(1).should eql 1
|
15
|
+
ulong_to_comp_t.call(1 << 3).should eql(8)
|
16
|
+
ulong_to_comp_t.call(20 << 9).should eql((1 << 13) | (20 << 6))
|
17
|
+
ulong_to_comp_t.call((1 << 13) - 1).should eql((1 << 13) - 1)
|
18
|
+
#Upper limit of comp_t
|
19
|
+
ulong_to_comp_t.call(((1 << 13) - 1) << 21).should eql((1 << 16) - 1)
|
20
|
+
#Check for proper truncation.
|
21
|
+
ulong_to_comp_t.call((((1 << 13) - 1) << 21) + 1).should eql((1 << 16) - 1)
|
22
|
+
#Overflow
|
23
|
+
expect {
|
24
|
+
ulong_to_comp_t.call(1 << (13 + 21))
|
25
|
+
}.to raise_error("Exponent overflow in ulong_to_comp_t: Value 17179869184 is too large.")
|
15
26
|
end
|
16
|
-
|
17
|
-
|
27
|
+
|
18
28
|
it "raises an error when a comp_t overflows" do
|
19
29
|
e = Pacct::Entry.new
|
20
30
|
expect {
|
@@ -31,7 +41,7 @@ describe Pacct::Entry do
|
|
31
41
|
it "raises an error when encountering unknown user/group IDs" do
|
32
42
|
log = Pacct::Log.new('snapshot/pacct_invalid_ids')
|
33
43
|
log.each_entry do |entry|
|
34
|
-
#This assumes that these users and groups don't actually exist.
|
44
|
+
#This assumes that these users and groups don't actually exist on the testing system.
|
35
45
|
#If, for some odd reason, they _do_ exist, this test will fail.
|
36
46
|
expect { entry.user_name }.to raise_error(
|
37
47
|
Errno::ENODATA.new('Unable to obtain user name for ID 4294967295').to_s)
|
@@ -43,4 +53,4 @@ describe Pacct::Entry do
|
|
43
53
|
Errno::ENODATA.new("Unable to obtain group ID for name '_____ _'").to_s)
|
44
54
|
end
|
45
55
|
end
|
46
|
-
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,46 +1,40 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pacct
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.8.3
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 8
|
9
|
-
- 2
|
10
|
-
version: 0.8.2
|
11
6
|
platform: universal-linux
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Ben Merritt
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-05-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rspec
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
32
22
|
type: :development
|
33
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
34
30
|
description: A C extension library for parsing accounting files in acct(5) format
|
35
|
-
email:
|
31
|
+
email:
|
36
32
|
- blm768@gmail.com
|
37
33
|
executables: []
|
38
|
-
|
39
|
-
extensions:
|
34
|
+
extensions:
|
40
35
|
- ext/pacct/extconf.rb
|
41
36
|
extra_rdoc_files: []
|
42
|
-
|
43
|
-
files:
|
37
|
+
files:
|
44
38
|
- .gitignore
|
45
39
|
- Gemfile
|
46
40
|
- LICENSE.txt
|
@@ -62,38 +56,29 @@ files:
|
|
62
56
|
- spec/spec_helper.rb
|
63
57
|
homepage: https://github.com/blm768/pacct
|
64
58
|
licenses: []
|
65
|
-
|
66
59
|
post_install_message:
|
67
60
|
rdoc_options: []
|
68
|
-
|
69
|
-
require_paths:
|
61
|
+
require_paths:
|
70
62
|
- lib
|
71
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
64
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
77
|
-
|
78
|
-
- 0
|
79
|
-
version: "0"
|
80
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
70
|
none: false
|
82
|
-
requirements:
|
83
|
-
- -
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
|
86
|
-
segments:
|
87
|
-
- 0
|
88
|
-
version: "0"
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
89
75
|
requirements: []
|
90
|
-
|
91
76
|
rubyforge_project:
|
92
|
-
rubygems_version: 1.8.
|
77
|
+
rubygems_version: 1.8.23
|
93
78
|
signing_key:
|
94
79
|
specification_version: 3
|
95
80
|
summary: A C extension library for parsing accounting files in acct(5) format
|
96
|
-
test_files:
|
81
|
+
test_files:
|
97
82
|
- spec/entry_spec.rb
|
98
83
|
- spec/log_spec.rb
|
99
84
|
- spec/pacct_spec.rb
|