tweek 1.0.0 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7068bcfbf27d73e5c1a20c2f5d52671a8d0ce968
4
- data.tar.gz: 8458e63c00fd12cc564a7e7aa3198aecfefe65b7
3
+ metadata.gz: 2b847609877ba323a4f9feb924b503cd80f9f553
4
+ data.tar.gz: 28ca6b95b8f2481c00b85aadf4ef2b4aa690f78d
5
5
  SHA512:
6
- metadata.gz: c09dfbf71eca18073c90a87616d46084f2ec6572d659c5a23beaf9c1044e33d984030d30ac24ff74a4e871f066ddf994529373cfdbe3f69af018c06de22d2b84
7
- data.tar.gz: 7c85c2be58f9a2de5383a7f5caa0c433d30678f6a46eb12e7a32191d0c91a65eba57858ef6bb7b07894659958ab9d98bb046836b179623f72c32b071182d890d
6
+ metadata.gz: dd5be7941a09e0351df76b35e99efe7e5a5d905691f656f7fa577b3e15c303fab0296b716cddbf79faf12f3f74185e063b3a367e7c94d7a33099053c69aed342
7
+ data.tar.gz: 2ef05e618352ec963c405a9f05cc8b279e29f97c3fd2d847cdd1750352f790f559e44acc7475c638d2e24be98c01fe8a45cbfb616f7e5b352e8459193f79d13f
data/README.md CHANGED
@@ -72,7 +72,8 @@ Use `tweek -s` to show them.
72
72
  ## Settings File Format
73
73
 
74
74
  The settings file is a plaintext file encoded in UTF-8 (if you are running Ruby 2.0 or
75
- above) or US-ASCII otherwise.
75
+ above) or US-ASCII otherwise. Although settings files can have any name, please observe the
76
+ convention of using a file extension of `.twk`.
76
77
 
77
78
  The overall syntax of the file was designed to be Ruby-like so that enabling syntax
78
79
  highlighting (using Ruby as the language) makes it very readable.
data/bin/tweek CHANGED
@@ -1,13 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
3
  # A script to check a variety of Linux system settings
4
- # See settings/sample.set for a description of these.
4
+ # See settings/sample.twk for a description of these.
5
5
  # By Nick Townsend, June 2017
6
6
  #
7
7
  require 'rubygems'
8
8
 
9
9
  require 'optparse'
10
- require 'ostruct'
11
10
  require 'tweek'
12
11
  require 'tweek/file'
13
12
  require 'tweek/version'
@@ -18,14 +17,16 @@ trap('INT') do
18
17
  end
19
18
 
20
19
  gflag = false
20
+ sflag = false
21
+ qflag = false
21
22
  distro = nil
22
23
  distro_ver = nil
23
24
  kernel_ver = nil
24
25
  OptionParser.new do |o|
25
26
  o.banner = "Usage: #{$0} [options] [settings_file...]"
26
27
  o.separator ""
27
- o.separator "Check the system parameters specified in the settings files"
28
- o.separator "(If not supplied then built-in defaults are used)"
28
+ o.separator "Check and/or update the system parameters specified in the settings files"
29
+ o.separator "(If not supplied then built-in samples are used)"
29
30
  o.separator "Options:"
30
31
  o.on('--distro=NAME', "Set Distro (default uses lsb_release)" ) do |d|
31
32
  distro = d
@@ -39,14 +40,20 @@ OptionParser.new do |o|
39
40
  o.on( '-g', '--generate', "Generate a copy of the input file(s)", "containing current values on STDOUT" ) do
40
41
  gflag = true
41
42
  end
43
+ o.on( '-q', '--quiet', "No output (default false)" ) do
44
+ qflag = true
45
+ end
42
46
  o.on( '-s', '--show', "Write the default parameters to STDOUT",
43
47
  "Use as a fully documented starting point"
44
48
  ) do
45
- File.open(File.expand_path('../../settings/sample.set',__FILE__)).each_line do |l|
49
+ File.open(File.expand_path('../../settings/sample.twk',__FILE__)).each_line do |l|
46
50
  STDOUT.puts l # no copy_stream in 1.8.7
47
51
  end
48
52
  exit
49
53
  end
54
+ o.on( '--set', "Set the tweak file(s)" ) do
55
+ sflag = true
56
+ end
50
57
  o.on('-v', "--version", "Show version") do
51
58
  puts Tweek::VERSION
52
59
  exit
@@ -83,9 +90,13 @@ if kernel_ver.nil?
83
90
  exit 2
84
91
  end
85
92
  end
86
- cs = Tweek::File.new(gflag, true, distro, distro_ver, kernel_ver)
93
+ cs = Tweek::File.new(distro, distro_ver, kernel_ver, gflag, qflag, sflag)
87
94
  if ARGV.empty?
88
- fh = File.open(File.expand_path('../../settings/sample.set',__FILE__))
95
+ if sflag
96
+ puts "You can't update the system with the sample settings, specify one or more Tweek files!"
97
+ exit 2
98
+ end
99
+ fh = File.open(File.expand_path('../../settings/sample.twk',__FILE__))
89
100
  else
90
101
  fh = ARGF
91
102
  end
data/lib/tweek.rb CHANGED
@@ -31,6 +31,15 @@ module Tweek
31
31
  ::File.open("/proc/sys/#{name}", &:read).chomp.gsub(/\s+/,' ') rescue $!.message
32
32
  end
33
33
 
34
+ def self.set_sysctl name, value
35
+ begin
36
+ ::File.open("/proc/sys/#{name}", "w"){|f| f.write value}
37
+ value
38
+ rescue
39
+ $!.message
40
+ end
41
+ end
42
+
34
43
  def self.net_driver name
35
44
  ::File.basename(::File.readlink("/sys/class/net/#{name}/device/driver"))
36
45
  end
data/lib/tweek/file.rb CHANGED
@@ -1,14 +1,13 @@
1
1
  require 'rubygems'
2
- require 'optparse'
3
- require 'ostruct'
4
2
  require 'tweek'
5
3
  require 'tweek/section'
4
+ require 'tweek/entry'
6
5
 
7
6
  class Tweek::File
8
7
 
9
- attr_reader :distro, :distro_version, :kernel_version
8
+ attr_reader :distro, :distro_version, :kernel_version, :gflag, :qflag, :sflag
10
9
 
11
- def initialize( gflag, tty, distro, distro_version, kernel_version)
10
+ def initialize( distro, distro_version, kernel_version, gflag = false, qflag = true, sflag = false)
12
11
  @distro = distro
13
12
  @distro_version = Gem::Version.new(distro_version)
14
13
  @kernel_version = Gem::Version.new(kernel_version)
@@ -18,34 +17,43 @@ class Tweek::File
18
17
  @skips = []
19
18
  @warns = []
20
19
  @generated = []
20
+ if gflag
21
+ @generated << "# Generated at #{Time.now.strftime("%c %Z")}"
22
+ @generated << "# Distro: #{@distro} Version: #{@distro_version} Kernel: #{@kernel_version}"
23
+ end
21
24
  @gflag = gflag
22
- @tty = tty
25
+ @qflag = qflag
26
+ @sflag = sflag
23
27
  end
24
28
 
25
- def generate type, e
29
+ # Generate an output file recording what was found (check) or done (set)
30
+ #
31
+ def generate type, entry
26
32
  return unless @gflag
27
33
  case type
28
34
  when :line
29
- @generated.push "#{e.line}#{e.comment}"
35
+ @generated.push "#{entry.line}#{entry.comment}"
30
36
  when :section
31
- @generated.push "#{e.type} #{e.list} #{e.comment}"
37
+ return if entry.type.nil?
38
+ @generated.push "#{entry.type} #{entry.list} #{entry.comment}"
32
39
  when :entry
33
- cond = e.cond.nil? ? "": " if #{e.cond}"
34
- if e.actual.nil?
35
- line = "#{e.param} = #{e.value}#{cond}"
40
+ cond = entry.cond.nil? ? "": " if #{entry.cond}"
41
+ if entry.actual.nil?
42
+ line = "#{entry.param} = #{entry.value}#{cond}"
36
43
  note = "[condition not met]"
37
44
  else
38
- line = "#{e.param} = #{e.actual}#{cond}"
39
- if e.value === e.actual
45
+ entry.swap!
46
+ line = "#{entry.param} = #{entry.actual}#{cond}"
47
+ if entry.value === entry.actual
40
48
  note = nil
41
49
  else
42
- note = "[expected #{e.value}]"
50
+ note = "[#{entry.set ? 'was' : 'expected'} #{entry.value}]"
43
51
  end
44
52
  end
45
- if e.comment.nil?
53
+ if entry.comment.nil?
46
54
  @generated.push (note ? line + " # " + note : line)
47
55
  else
48
- @generated.push (note ? line + " " + comment + " " + note : line + " " + comment)
56
+ @generated.push (note ? line + " " + entry.comment + " " + note : line + " " + entry.comment)
49
57
  end
50
58
  end
51
59
  end
@@ -96,10 +104,10 @@ class Tweek::File
96
104
  def assert_equal expected, actual, msg = ''
97
105
  @nparams += 1
98
106
  if expected === actual
99
- STDERR.print "." if @tty
107
+ STDERR.print "." if not @qflag and STDERR.isatty
100
108
  return 0
101
109
  else
102
- STDERR.print "F" if @tty
110
+ STDERR.print "F" if not @qflag and STDERR.isatty
103
111
  @mismatches.push "#{msg}: Expected #{expected}\n#{" "*(msg.size+4)}Actual #{actual}"
104
112
  end
105
113
  return 1
@@ -108,23 +116,23 @@ class Tweek::File
108
116
  # Read the entire file and split into sections
109
117
  #
110
118
  def read_sections handle
111
- section = Tweek::Section.new(0,'<initial>','','')
119
+ section = Tweek::Section.new( 0, nil, '', '' )
112
120
  while line = handle.gets
113
121
  line.chomp!
114
122
  if (line =~ /^=begin/)..(line =~ /^=end/)
115
- section.push OpenStruct.new( :line => line, :lineno => handle.lineno )
123
+ section.push Tweek::Entry.new( :line => line, :lineno => handle.lineno )
116
124
  next
117
125
  end
118
126
 
119
127
  comment = line.slice!(/#.*$/)
120
128
  if line.empty?
121
- section.push OpenStruct.new( :line => line, :lineno => handle.lineno, :comment => comment )
129
+ section.push Tweek::Entry.new( :line => line, :lineno => handle.lineno, :comment => comment )
122
130
  next
123
131
  end
124
132
 
125
133
  if /^\s*([A-Z0-9]+)\s*(.*?)\s*$/ =~ line # We've hit a new section
126
134
  section.process(self)
127
- section = Tweek::Section.new(handle.lineno, $1, $2, comment)
135
+ section = Tweek::Section.new( handle.lineno, $1, $2, comment )
128
136
  next
129
137
  end
130
138
 
@@ -132,8 +140,8 @@ class Tweek::File
132
140
  if $4 and $4.strip.empty?
133
141
  error "#{handle.lineno}: Missing condition after 'if'"
134
142
  else
135
- section.push OpenStruct.new( :lineno => handle.lineno, :param => $1, :value => $2,
136
- :cond => $4, :comment => comment )
143
+ section.push Tweek::Entry.new( :lineno => handle.lineno, :param => $1, :value => $2,
144
+ :cond => $4, :comment => comment )
137
145
  end
138
146
  next
139
147
  end
@@ -144,13 +152,12 @@ class Tweek::File
144
152
  end
145
153
 
146
154
  def results
147
- STDERR.puts "\nDistro: #{@distro} Version: #{@distro_version} Kernel: #{@kernel_version}"
148
- STDERR.puts "\n#{@nparams} parameters checked, #{@skips.size} conditions not met, #{@mismatches.size} mismatches, #{@warns.size} warnings, #{@errors.size} errors"
149
- STDERR.puts "\n#{@errors.join("\n")}" unless @errors.empty?
150
- STDERR.puts "\n#{@warns.join("\n")}" unless @warns.empty?
151
- STDERR.puts "\n#{@mismatches.join("\n")}" unless @mismatches.empty?
152
- if @gflag
153
- @generated.unshift "# Generated at #{Time.now.strftime("%c %Z")}\n# Distro: #{@distro} Version: #{@distro_version} Kernel: #{@kernel_version}"
155
+ unless @qflag
156
+ STDERR.puts "\nDistro: #{@distro} Version: #{@distro_version} Kernel: #{@kernel_version}"
157
+ STDERR.puts "\n#{@nparams} parameters checked, #{@skips.size} conditions not met, #{@mismatches.size} mismatches, #{@warns.size} warnings, #{@errors.size} errors"
158
+ STDERR.puts "\n#{@errors.join("\n")}" unless @errors.empty?
159
+ STDERR.puts "\n#{@warns.join("\n")}" unless @warns.empty?
160
+ STDERR.puts "\n#{@mismatches.join("\n")}" unless @mismatches.empty?
154
161
  @generated.each { |l| STDOUT.puts l}
155
162
  end
156
163
  return @mismatches.size
data/lib/tweek/section.rb CHANGED
@@ -8,6 +8,7 @@
8
8
  class Tweek::Section < Array
9
9
 
10
10
  attr_reader :lineno, :type, :list, :comment
11
+
11
12
  def initialize lineno, type, list, comment
12
13
  @lineno = lineno
13
14
  @type = type
@@ -15,65 +16,64 @@ class Tweek::Section < Array
15
16
  @comment = comment
16
17
  end
17
18
 
18
- def section_entry
19
- OpenStruct.new(:lineno => lineno, :type => type, :list => list, :comment => comment )
20
- end
21
-
22
19
  # Iterate through each entry in the section.
23
20
  # If it's a comment then pass to the generate method
24
21
  # If it has a condition which is not met then pass to generate
25
22
  # If it passes yield the entry
26
23
  #
27
- def each_entry cs, &block
24
+ def each_entry twf, &block
28
25
  self.each do |entry|
29
26
  if entry.line
30
- cs.generate :line, entry
27
+ twf.generate :line, entry
31
28
  next
32
29
  end
33
30
  begin
34
- if cs.condfail entry.cond
35
- cs.generate :entry, entry
36
- cs.skipcond entry
31
+ if twf.condfail entry.cond
32
+ twf.generate :entry, entry
33
+ twf.skipcond entry
37
34
  next
38
35
  end
39
36
  yield entry
40
37
  rescue Exception => e
41
- cs.error "#{entry.lineno}: #{e.message}"
38
+ twf.error "#{entry.lineno}: #{e.message}"
42
39
  end
43
40
  end
44
41
  end
45
42
 
46
- def process cs
43
+ def process twf
47
44
 
48
- cs.generate :section, section_entry unless type == '<initial>'
45
+ twf.generate :section, Tweek::Entry.new( :lineno => lineno, :type => type, :list => list, :comment => comment )
49
46
 
50
47
  return if self.empty?
51
48
 
52
- case type
53
- when '<initial>'
54
- each_entry (cs) do |entry|
49
+ case self.type
50
+ when nil
51
+ each_entry (twf) do |entry|
55
52
  end
56
53
 
57
54
  when 'BLKDEV' # BLOCK DEVICE PARAMETERS
58
55
 
56
+ twf.warn "Set is not currently implemented for #{type} section" if twf.sflag
57
+
59
58
  Dir.chdir('/dev')
60
59
  devices = Dir.glob(self.list.split(' ').map{|dev| dev.gsub(/^\/dev\//,'')})
61
60
 
62
- cs.warn "Block device check skipped: no devices found" if devices.empty?
61
+ twf.warn "Block device check skipped: no devices found" if devices.empty?
63
62
 
64
63
  devices.each do |blk|
65
- each_entry (cs) do |entry|
64
+ each_entry (twf) do |entry|
66
65
  entry.actual = Tweek.blk_param(blk, entry.param)
67
66
  if entry.param == 'scheduler'
68
67
  entry.actual = entry.actual.slice(/\[(.*?)\]/,1) unless entry.actual == 'none'
69
68
  end
70
- cs.assert_equal entry.value, entry.actual, "/dev/#{blk} #{entry.param}"
71
- cs.generate :entry, entry
69
+ twf.assert_equal entry.value, entry.actual, "/dev/#{blk} #{entry.param}"
70
+ twf.generate :entry, entry
72
71
  end
73
72
  end
74
73
 
75
74
  when 'KERNEL' # KERNEL PARAMETERS
76
- each_entry (cs) do |entry|
75
+ twf.warn "Set is not currently implemented for #{type} section" if twf.sflag
76
+ each_entry (twf) do |entry|
77
77
  actual = /\b(#{entry.param})(=\S+)?\b/.match(Tweek.bootline)
78
78
  case
79
79
  when (entry.value == 'true' and actual)
@@ -92,32 +92,38 @@ class Tweek::Section < Array
92
92
  expected = entry.value
93
93
  observed = actual.nil? ? 'was not found' : actual[2][1..-1]
94
94
  end
95
- cs.assert_equal expected, observed, "Kernel parameter #{entry.param}"
95
+ twf.assert_equal expected, observed, "Kernel parameter #{entry.param}"
96
96
  entry.actual = !actual.nil?
97
- cs.generate :entry, entry
97
+ twf.generate :entry, entry
98
98
  end
99
99
 
100
100
  when 'CLOCKSOURCE'
101
- each_entry (cs) do |entry|
101
+ twf.warn "Set is not currently implemented for #{type} section" if twf.sflag
102
+ each_entry (twf) do |entry|
102
103
  entry.actual = Tweek.clocksource(entry.param)
103
- cs.assert_equal entry.value, entry.actual, entry.param
104
- cs.generate :entry, entry
104
+ twf.assert_equal entry.value, entry.actual, entry.param
105
+ twf.generate :entry, entry
105
106
  end
106
107
 
107
108
  when 'SYSCTL' # SYSCTL SETTINGS
108
- each_entry (cs) do |entry|
109
+ each_entry (twf) do |entry|
109
110
  file = entry.param.gsub(/\./,'/')
110
111
  entry.actual = Tweek.sysctl(file)
111
- cs.assert_equal entry.value, entry.actual, entry.param
112
- cs.generate :entry, entry
112
+ twf.assert_equal entry.value, entry.actual, entry.param
113
+ if twf.sflag
114
+ entry.value = Tweek.set_sysctl(file, entry.value)
115
+ entry.set = true
116
+ end
117
+ twf.generate :entry, entry
113
118
  end
114
119
 
115
120
  when 'NET' # NETWORK DEVICES
121
+ twf.warn "Set is not currently implemented for #{type} section" if twf.sflag
116
122
  devices = self.list.split(' ').map{|dev| dev.gsub(/^\/dev\//,'')}
117
- cs.warn "Network device check skipped: no devices found" if devices.empty?
123
+ twf.warn "Network device check skipped: no devices found" if devices.empty?
118
124
 
119
125
  devices.each do |netdev|
120
- each_entry (cs) do |entry|
126
+ each_entry (twf) do |entry|
121
127
 
122
128
  case entry.param
123
129
  when 'driver'
@@ -131,7 +137,7 @@ class Tweek::Section < Array
131
137
  entry.actual = balpid.zero? ? 'IRQ balance daemon not running' : 'balance'
132
138
  else
133
139
  if balpid.zero?
134
- handle_irqs(netdev, cs, entry)
140
+ handle_irqs(netdev, twf, entry)
135
141
  next
136
142
  else
137
143
  entry.actual = 'IRQ balance daemon running'
@@ -142,46 +148,48 @@ class Tweek::Section < Array
142
148
  begin
143
149
  entry.actual = Tweek.net_param(netdev, entry.param)
144
150
  rescue
145
- cs.error "#{entry.lineno}: Network parameter #{entry.param} not handled: #{$!.message}"
151
+ twf.error "#{entry.lineno}: Network parameter #{entry.param} not handled: #{$!.message}"
146
152
  next
147
153
  end
148
154
  end
149
155
 
150
- cs.assert_equal entry.value, entry.actual, entry.param
151
- cs.generate :entry, entry
156
+ twf.assert_equal entry.value, entry.actual, entry.param
157
+ twf.generate :entry, entry
152
158
  end
153
159
  end
154
160
 
155
161
  when 'EXT4' # EXT4 filesystems info via `dumpe2fs -h /dev/#{device}`
162
+ twf.warn "Set is not currently implemented for #{type} section" if twf.sflag
156
163
  mounted = Tweek.mounted
157
164
  mounts = Dir.glob(self.list.split(' '))
158
165
  mounts.each do |mount|
159
166
  unless this = mounted.select{|m| (mount == m[0] or mount == m[1]) and m[2] == 'ext4'}.first
160
- cs.warn "EXT4 path #{mount} is not mounted or is not mounted as ext4"
167
+ twf.warn "EXT4 path #{mount} is not mounted or is not mounted as ext4"
161
168
  next
162
169
  end
163
170
  device = this[0].gsub('/dev/','')
164
171
  optstring = File.open("/proc/fs/ext4/#{device}/options",&:read)
165
172
  options = Hash[optstring.scan(/([^=\s]+)=([^=\s,]+)/)] # options a=b
166
173
  optstring.split(/\n/).reject{|o| o.index('=')}.each{|o| options[o] = 'true'}
167
- each_entry (cs) do |entry|
174
+ each_entry (twf) do |entry|
168
175
  entry.actual = options[entry.param] || "<not found>"
169
- cs.assert_equal entry.value, entry.actual, "EXT4 #{mount}: #{entry.param}"
170
- cs.generate :entry, entry
176
+ twf.assert_equal entry.value, entry.actual, "EXT4 #{mount}: #{entry.param}"
177
+ twf.generate :entry, entry
171
178
  end
172
179
  end
173
180
 
174
181
  when 'XFS' # XFS filesystems info via `xfs_info`
182
+ twf.warn "Set is not currently implemented for #{type} section" if twf.sflag
175
183
  # Dynamically via: /proc/fs/xfs/... ?
176
184
  mounts = self.list.split(' ')
177
185
  if mounts.empty?
178
- cs.warn "#{self.lineno}: XFS device check skipped: no mountpoints found"
186
+ twf.warn "#{self.lineno}: XFS device check skipped: no mountpoints found"
179
187
  end
180
188
  mounts.each do |mount|
181
189
  xfsinfo = Tweek.xfsinfo(mount)
182
190
  unless xfsinfo
183
- cs.warn "No XFS filesystem at #{mount}"
184
- each_entry (cs) { |entry| cs.generate :entry, entry }
191
+ twf.warn "No XFS filesystem at #{mount}"
192
+ each_entry (twf) { |entry| twf.generate :entry, entry }
185
193
  next
186
194
  end
187
195
  data = Hash[xfsinfo.slice!(/^meta-data.*(?=^naming)/m).scan(/([^=\s]+)=([^=\s,]+)/)]
@@ -190,27 +198,27 @@ class Tweek::Section < Array
190
198
  realtime = Hash[xfsinfo.slice!(/^realtime.*$/m).scan(/([^=\s]+)=([^=\s,]+)/)]
191
199
  xfsparms = { 'data' => data, 'naming' => naming, 'log' => log, 'realtime' => realtime }
192
200
 
193
- each_entry (cs) do |entry|
201
+ each_entry (twf) do |entry|
194
202
  parameter = entry.param.split('.',2)
195
203
  entry.actual = xfsparms[parameter[0]][parameter[1]] rescue "<invalid name>"
196
- cs.assert_equal entry.value, entry.actual, "XFS #{mount}: #{entry.param}"
197
- cs.generate :entry, entry
204
+ twf.assert_equal entry.value, entry.actual, "XFS #{mount}: #{entry.param}"
205
+ twf.generate :entry, entry
198
206
  end
199
207
  end
200
208
 
201
209
  else
202
- cs.error "#{self.lineno}: Unknown type #{self.type}"
210
+ twf.error "#{self.lineno}: Unknown type #{self.type}"
203
211
  end
204
212
 
205
213
  end
206
214
 
207
- def handle_irqs netdev, cs, entry
215
+ def handle_irqs netdev, twf, entry
208
216
  irqs = Tweek.irqs(netdev)
209
217
 
210
218
  if irqs.empty?
211
- cs.warn "#{netdev} IRQ check skipped: none found"
219
+ twf.warn "#{netdev} IRQ check skipped: none found"
212
220
  entry.actual = 'null'
213
- cs.generate :entry, entry
221
+ twf.generate :entry, entry
214
222
  return
215
223
  end
216
224
 
@@ -232,7 +240,7 @@ class Tweek::Section < Array
232
240
  expected_rps << "0000"
233
241
  expected_rss << sprintf("%04x", 1<<ix)
234
242
  else
235
- cs.warn "#{netdev} IRQ strategy '#{entry.value}' can't handle #{ncores} cores"
243
+ twf.warn "#{netdev} IRQ strategy '#{entry.value}' can't handle #{ncores} cores"
236
244
  return
237
245
  end
238
246
 
@@ -248,7 +256,7 @@ class Tweek::Section < Array
248
256
  expected_rps << ("00000000," * 3) + "fffefe00"
249
257
  expected_rss << ("00000000," * 3) + sprintf("%08x", 1<<(ix+1))
250
258
  else
251
- cs.warn "#{netdev} IRQ strategy '#{entry.value}' can't handle IRQ#{ix}"
259
+ twf.warn "#{netdev} IRQ strategy '#{entry.value}' can't handle IRQ#{ix}"
252
260
  return
253
261
  end
254
262
 
@@ -261,27 +269,27 @@ class Tweek::Section < Array
261
269
  expected_rps << ("00000000," * 2) + "ffff0000," + "ffe00000"
262
270
  expected_rss << ("00000000," * 3) + sprintf("%08x", 1<<(ix + 9))
263
271
  else
264
- cs.warn "#{netdev} IRQ strategy '#{entry.value}' can't handle IRQ#{ix}"
272
+ twf.warn "#{netdev} IRQ strategy '#{entry.value}' can't handle IRQ#{ix}"
265
273
  return
266
274
  end
267
275
 
268
276
  else
269
- cs.error "#{entry.lineno}: Can't handle #{ncores} cores in IRQ strategy '#{entry.value}'"
277
+ twf.error "#{entry.lineno}: Can't handle #{ncores} cores in IRQ strategy '#{entry.value}'"
270
278
  return
271
279
  end
272
280
 
273
281
  else
274
- cs.error "#{entry.lineno}: Unrecognized #{netdev} IRQ strategy '#{entry.value}'"
282
+ twf.error "#{entry.lineno}: Unrecognized #{netdev} IRQ strategy '#{entry.value}'"
275
283
  return
276
284
  end
277
285
  end
278
286
  irqs.each_with_index do |irq, ix|
279
287
  actual_rss = Tweek.net_rss(irq)
280
- mismatches += cs.assert_equal expected_rss[ix], actual_rss, "#{netdev}_irq_#{irq}_rss"
288
+ mismatches += twf.assert_equal expected_rss[ix], actual_rss, "#{netdev}_irq_#{irq}_rss"
281
289
  end
282
290
  irqs.each_with_index do |irq, ix|
283
291
  actual_rps = Tweek.net_rps(netdev, ix)
284
- mismatches += cs.assert_equal expected_rps[ix], actual_rps, "#{netdev}_irq_#{irq}_rps"
292
+ mismatches += twf.assert_equal expected_rps[ix], actual_rps, "#{netdev}_irq_#{irq}_rps"
285
293
  end
286
294
  entry.actual = 'null' if mismatches > 0
287
295
  return
data/lib/tweek/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tweek
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tweek
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Townsend
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-22 00:00:00.000000000 Z
11
+ date: 2017-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -68,7 +68,7 @@ files:
68
68
  - lib/tweek/file.rb
69
69
  - lib/tweek/section.rb
70
70
  - lib/tweek/version.rb
71
- - settings/sample.set
71
+ - settings/sample.twk
72
72
  homepage: https://github.com/townsen/tweek
73
73
  licenses:
74
74
  - MIT