Class: Watobo::FuzzCounter

Inherits:
FuzzGenerator show all
Defined in:
lib/watobo/core/fuzz_gen.rb

Instance Attribute Summary collapse

Attributes inherited from FuzzGenerator

#actions, #genType, #info, #name, #numRequests

Instance Method Summary collapse

Methods inherited from FuzzGenerator

#addAction, #is_generator?, #removeAction, #run

Constructor Details

#initialize(fuzzer_tag, prefs) ⇒ FuzzCounter

Returns a new instance of FuzzCounter.



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/watobo/core/fuzz_gen.rb', line 141

def initialize(fuzzer_tag, prefs)
  super(fuzzer_tag)
  @genType = "Counter"
  @start = prefs[:start]
  @stop =  prefs[:stop]

  @count = prefs[:count] || 0
  @step = ( prefs[:step] and prefs[:step] != 0 ) ? prefs[:step] : 1

  if @stop < @start and @step > 0 then
    @step = @step * -1
  end
  @info = "start=#{@start}/stop=#{@stop}/step=#{@step}"
  @numRequests = (( @stop - @start ) / @step).abs

end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



123
124
125
# File 'lib/watobo/core/fuzz_gen.rb', line 123

def count
  @count
end

#startObject (readonly)

Returns the value of attribute start.



123
124
125
# File 'lib/watobo/core/fuzz_gen.rb', line 123

def start
  @start
end

#stepObject (readonly)

Returns the value of attribute step.



123
124
125
# File 'lib/watobo/core/fuzz_gen.rb', line 123

def step
  @step
end

#stopObject (readonly)

Returns the value of attribute stop.



123
124
125
# File 'lib/watobo/core/fuzz_gen.rb', line 123

def stop
  @stop
end

Instance Method Details

#generateObject



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/watobo/core/fuzz_gen.rb', line 125

def generate
  return false if @start.nil?
  return false if @stop.nil? and @count.nil?

  if @stop == 0 and @count > 0 then
    @stop = @start + @count
  end

  return 0 if @start == @stop

  @start.step(@stop, @step) do |i|
    yield i.to_s
  end

end