origen_testers 0.9.2 → 0.9.3

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: bb7e94e2ce35ea525eeb90410b24ebe55c8576b7
4
- data.tar.gz: 68d99c86782203d2ba107e3bf9233915c67d5f56
3
+ metadata.gz: ce3212799e833ec4c450e60a2ea3ebc37022db79
4
+ data.tar.gz: 8059fd5aaf0f9d7996e543101f1121aeb33f20a3
5
5
  SHA512:
6
- metadata.gz: 1cbd6405ece9a4cc5f0b71facce92e3588b81dbf7d38f1815d6780e45cf0b71400ac8d8d82258892071c750ad3a1eea04a74d453f387f31e88137088ce33ab69
7
- data.tar.gz: ad6cfc2654f121f21c14be9cf82e60075eeb0c3b7932a19ab8473a5bd169e87ecf425149eac9c2866da89d4012e1ebf2f29641abe0244963a1872d9c7d7ce98e
6
+ metadata.gz: db42da1b9ba4f47f1c8ff6319193c6cf55dc137f3b24e208db6df785c4b7180122d7a65235e403ce7e937e51efc73fb16c6611080a87042e21cb703d82ed8a06
7
+ data.tar.gz: 60a7b1d11f0d195031dc737cc8842bd114785a7f24003cf5ce48e2207ac07dac9fd63d984e5ff4ed348310535bc6b977d18fdafe416f7b5e6bf436d33f85e8d6
data/config/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module OrigenTesters
2
2
  MAJOR = 0
3
3
  MINOR = 9
4
- BUGFIX = 2
4
+ BUGFIX = 3
5
5
  DEV = nil
6
6
 
7
7
  VERSION = [MAJOR, MINOR, BUGFIX].join(".") + (DEV ? ".pre#{DEV}" : '')
@@ -1,8 +1,8 @@
1
1
  module OrigenTesters
2
2
  module SmartestBasedTester
3
- autoload :Base, 'origen_testers/smartest_based_tester/base.rb'
4
- autoload :V93K, 'origen_testers/smartest_based_tester/v93k.rb'
3
+ autoload :Base, 'origen_testers/smartest_based_tester/base'
4
+ autoload :V93K, 'origen_testers/smartest_based_tester/v93k'
5
5
  end
6
6
  # Convenience/Legacy names without the SmartestBasedTester namespace
7
- autoload :V93K, 'origen_testers/smartest_based_tester/v93k.rb'
7
+ autoload :V93K, 'origen_testers/smartest_based_tester/v93k'
8
8
  end
@@ -1,3 +1,4 @@
1
+ require 'origen_testers/smartest_based_tester/base/processors'
1
2
  module OrigenTesters
2
3
  module SmartestBasedTester
3
4
  class Base
@@ -43,7 +44,10 @@ module OrigenTesters
43
44
  @indent = 0
44
45
  @lines = []
45
46
  @stack = { on_fail: [], on_pass: [] }
46
- process(model.ast)
47
+ m = Processors::IfRanCleaner.new.process(model.ast)
48
+ m = Processors::EmptyBranchCleaner.new.process(m)
49
+ m = Processors::FlagOptimizer.new.process(m)
50
+ process(m)
47
51
  end
48
52
 
49
53
  def line(str)
@@ -0,0 +1,12 @@
1
+ module OrigenTesters
2
+ module SmartestBasedTester
3
+ class Base
4
+ module Processors
5
+ # Include any V93K specific AST processors here
6
+ autoload :IfRanCleaner, 'origen_testers/smartest_based_tester/base/processors/if_ran_cleaner'
7
+ autoload :EmptyBranchCleaner, 'origen_testers/smartest_based_tester/base/processors/empty_branch_cleaner'
8
+ autoload :FlagOptimizer, 'origen_testers/smartest_based_tester/base/processors/flag_optimizer'
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,49 @@
1
+ module OrigenTesters
2
+ module SmartestBasedTester
3
+ class Base
4
+ module Processors
5
+ class EmptyBranchCleaner < ATP::Processor
6
+ # Delete any on-fail child if it's 'empty'
7
+ def on_test(node)
8
+ on_pass = node.find(:on_pass)
9
+ on_fail = node.find(:on_fail)
10
+ unless on_fail.nil?
11
+ n = node.remove(on_fail) if branch_is_empty?(on_fail)
12
+ return n
13
+ end
14
+ node
15
+ end
16
+
17
+ # Returns true if:
18
+ # - node is completely empty
19
+ # - only child is (continue) node
20
+ # - only two children, one continue and one set-result
21
+ def branch_is_empty?(node)
22
+ children = node.children.dup
23
+ return true if children.nil?
24
+
25
+ # test for only-child situation
26
+ first_born = children.shift
27
+ if children.empty?
28
+ if first_born == n0(:continue)
29
+ return true
30
+ else
31
+ return false
32
+ end
33
+ end
34
+
35
+ # if only 2 children, check qualificataions, else done and return false
36
+ next_born = children.shift
37
+ if children.empty?
38
+ if (first_born.type == :continue && next_born.type == :set_result) ||
39
+ (first_born.type == :set_result && next_born.type == :continue)
40
+ return true
41
+ end
42
+ end
43
+ false
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,143 @@
1
+ module OrigenTesters
2
+ module SmartestBasedTester
3
+ class Base
4
+ module Processors
5
+ class FlagOptimizer < ATP::Processor
6
+ attr_reader :run_flag_table
7
+ # This optimizes the AST such that any adjacent flow noes that
8
+ #
9
+ # For example this AST:
10
+ # (flow
11
+ # (test
12
+ # (name "test1")
13
+ # (on-fail
14
+ # (set-run-flag "t1_FAILED")))
15
+ # (run-flag "t1_FAILED" true
16
+ # (test
17
+ # (name "test2"))
18
+ # (test
19
+ # (name "test3")))
20
+ # (test
21
+ # (name "test4")
22
+ # (on-pass
23
+ # (set-run-flag "t4_PASSED"))
24
+ # (on-fail
25
+ # (continue)))
26
+ # (run-flag "t4_PASSED" true
27
+ # (test
28
+ # (name "test5"))
29
+ # (test
30
+ # (name "test6"))))
31
+ #
32
+ # Will be optimized to this:
33
+ # (flow
34
+ # (test
35
+ # (name "test1")
36
+ # (on-fail
37
+ # (test
38
+ # (name "test2"))
39
+ # (test
40
+ # (name "test3"))))
41
+ # (test
42
+ # (name "test4")
43
+ # (on-pass
44
+ # (test
45
+ # (name "test5"))
46
+ # (test
47
+ # (name "test6")))
48
+ # (on-fail
49
+ # (continue))))
50
+
51
+ # Processes the AST and tabulates occurences of unique set_run_flag nodes
52
+ class ExtractRunFlagTable < ATP::Processor
53
+ # Hash table of run_flag name with number of times used
54
+ attr_reader :run_flag_table
55
+
56
+ # Reset hash table
57
+ def initialize
58
+ @run_flag_table = {}
59
+ end
60
+
61
+ # For run_flag nodes, increment # of occurences for specified flag
62
+ def on_run_flag(node)
63
+ children = node.children.dup
64
+ name = children.shift
65
+ state = children.shift
66
+ unless name.is_a?(Array)
67
+ if @run_flag_table[name.to_sym].nil?
68
+ @run_flag_table[name.to_sym] = 1
69
+ else
70
+ @run_flag_table[name.to_sym] += 1
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ # Only run this on top level flow and consider adjacent nodes, no need for
77
+ # looking at nested conditions.
78
+ def on_flow(node)
79
+ # Pre-process the AST for # of occurences of each run-flag used
80
+ t = ExtractRunFlagTable.new
81
+ t.process(node)
82
+ @run_flag_table = t.run_flag_table
83
+
84
+ name, *nodes = *node
85
+ results = []
86
+ node_a = nil
87
+ nodes.each do |node_b|
88
+ if node_a && node_a.type == :test && node_b.type == :run_flag
89
+ result, node_a = remove_run_flag(node_a, node_b)
90
+ results << result
91
+ else
92
+ results << node_a unless node_a.nil?
93
+ node_a = node_b
94
+ end
95
+ end
96
+ results << node_a unless node_a.nil?
97
+ node.updated(nil, [name] + results)
98
+ end
99
+
100
+ # Given two adjacent nodes, where the first (a) is a test and the second (b)
101
+ # is a run_flag, determine if (a) conditionally sets the same flag that (b)
102
+ # uses. If it does, do a logical replacement, if not, move on quietly.
103
+ def remove_run_flag(node_a, node_b)
104
+ on_pass = node_a.find(:on_pass)
105
+ on_fail = node_a.find(:on_fail)
106
+
107
+ unless on_pass.nil? && on_fail.nil?
108
+ if on_pass.nil?
109
+ flag_node = on_fail.find(:set_run_flag)
110
+ conditional = [flag_node, on_fail]
111
+ else
112
+ flag_node = on_pass.find(:set_run_flag)
113
+ conditional = [flag_node, on_pass]
114
+ end
115
+ end
116
+ unless conditional.nil?
117
+ children = node_b.children.dup
118
+ name = children.shift
119
+ # remove the '_RAN' here so it won't match and if_ran cases are ignored
120
+ name = name.gsub(/_RAN$/, '') unless name.is_a?(Array)
121
+ state = children.shift
122
+ *nodes = *children
123
+ flag_node_b = n2(:set_run_flag, name, 'auto_generated') if state == true
124
+
125
+ if conditional.first == flag_node_b
126
+ n = conditional.last.dup
127
+ result = node_a.remove(n)
128
+ n = n.remove(conditional.first) if @run_flag_table[name.to_sym] == 1
129
+ n = n.remove(n0(:continue)) if n.type == :on_fail
130
+ s = n.find(:set_result) if n.type == :on_fail
131
+ n = n.remove(s) if s
132
+ n = n.updated(nil, n.children + (nodes.is_a?(Array) ? nodes : [nodes]))
133
+ result = result.updated(nil, result.children + (n.is_a?(Array) ? n : [n]))
134
+ return result, nil
135
+ end
136
+ end
137
+ [node_a, node_b]
138
+ end
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,34 @@
1
+ module OrigenTesters
2
+ module SmartestBasedTester
3
+ class Base
4
+ module Processors
5
+ class IfRanCleaner < ATP::Processor
6
+ def on_test(node)
7
+ on_pass = node.find(:on_pass)
8
+ on_fail = node.find(:on_fail)
9
+
10
+ unless on_pass.nil? || on_fail.nil?
11
+ set_run_flag = on_fail.find(:set_run_flag)
12
+ set_result = on_fail.find(:set_result)
13
+ unless set_run_flag.nil? || set_result.nil?
14
+ children = set_run_flag.children.dup
15
+ name = children.shift
16
+ ag_string = children.shift
17
+
18
+ if name =~ /_RAN$/ && ag_string == 'auto_generated'
19
+ f = on_fail.dup
20
+ f = f.remove(set_result)
21
+ n = node.remove(on_fail)
22
+ n = n.updated(nil, n.children + (f.is_a?(Array) ? f : [f]))
23
+ return n
24
+ end
25
+
26
+ end
27
+ end
28
+ node
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -294,4 +294,28 @@ Flow.create interface: 'OrigenTesters::Test::Interface' do
294
294
  unless_flag :my_flag do
295
295
  test :test3
296
296
  end
297
+
298
+ if tester.v93k?
299
+ log "This should retain the set-run-flag in the else conditional"
300
+ func :test22, id: :at22
301
+
302
+ if_failed :at22 do
303
+ func :test22a
304
+ func :test22b
305
+ end
306
+
307
+ func :test22c
308
+ func :test22d
309
+
310
+ if_failed :at22 do
311
+ func :test22e
312
+ func :test22f
313
+ end
314
+ end
315
+
316
+ if tester.v93k?
317
+ log "This should optimize away then/else branches that are empty"
318
+ func :test36, continue: true
319
+ func :test36b, bin: 12, continue:true
320
+ end
297
321
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: origen_testers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen McGinty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-28 00:00:00.000000000 Z
11
+ date: 2017-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: origen
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.5.3
47
+ version: 0.5.4
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.5.3
54
+ version: 0.5.4
55
55
  description:
56
56
  email:
57
57
  - stephen.f.mcginty@gmail.com
@@ -239,6 +239,10 @@ files:
239
239
  - lib/origen_testers/smartest_based_tester/base/generator.rb
240
240
  - lib/origen_testers/smartest_based_tester/base/pattern_compiler.rb
241
241
  - lib/origen_testers/smartest_based_tester/base/pattern_master.rb
242
+ - lib/origen_testers/smartest_based_tester/base/processors.rb
243
+ - lib/origen_testers/smartest_based_tester/base/processors/empty_branch_cleaner.rb
244
+ - lib/origen_testers/smartest_based_tester/base/processors/flag_optimizer.rb
245
+ - lib/origen_testers/smartest_based_tester/base/processors/if_ran_cleaner.rb
242
246
  - lib/origen_testers/smartest_based_tester/base/test_method.rb
243
247
  - lib/origen_testers/smartest_based_tester/base/test_methods.rb
244
248
  - lib/origen_testers/smartest_based_tester/base/test_methods/ac_tml.rb