origen 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (336) hide show
  1. checksums.yaml +4 -4
  2. data/bin/ctags +0 -0
  3. data/bin/origen +165 -1
  4. data/bin/rgen +2 -0
  5. data/config/application.rb +141 -0
  6. data/config/commands.rb +72 -0
  7. data/config/development.rb +7 -0
  8. data/config/environment.rb +0 -0
  9. data/config/rgen.policy +7 -0
  10. data/config/rubocop/easy.yml +620 -0
  11. data/config/rubocop/easy_disabled.yml +271 -0
  12. data/config/rubocop/easy_enabled.yml +731 -0
  13. data/config/rubocop/strict.yml +620 -0
  14. data/config/rubocop/strict_disabled.yml +247 -0
  15. data/config/rubocop/strict_enabled.yml +755 -0
  16. data/config/users.rb +20 -0
  17. data/config/version.rb +1 -1
  18. data/helpers/url.rb +68 -0
  19. data/lib/c99/doc_interface.rb +56 -0
  20. data/lib/c99/j750_interface.rb +85 -0
  21. data/lib/c99/nvm.rb +89 -0
  22. data/lib/c99/target/mock2.rb +1 -0
  23. data/lib/c99/target/subdir/mock3.rb +1 -0
  24. data/lib/option_parser/optparse.rb +12 -0
  25. data/lib/origen/acronyms.rb +60 -0
  26. data/lib/origen/application/command_dispatcher.rb +12 -0
  27. data/lib/origen/application/configuration.rb +206 -0
  28. data/lib/origen/application/configuration_manager.rb +78 -0
  29. data/lib/origen/application/deployer.rb +367 -0
  30. data/lib/origen/application/environment.rb +186 -0
  31. data/lib/origen/application/lsf.rb +145 -0
  32. data/lib/origen/application/lsf_manager.rb +657 -0
  33. data/lib/origen/application/plugins_manager.rb +280 -0
  34. data/lib/origen/application/release.rb +359 -0
  35. data/lib/origen/application/runner.rb +246 -0
  36. data/lib/origen/application/statistics.rb +191 -0
  37. data/lib/origen/application/target.rb +374 -0
  38. data/lib/origen/application/version_tracker.rb +59 -0
  39. data/lib/origen/application/workspace_manager.rb +151 -0
  40. data/lib/origen/application.rb +746 -0
  41. data/lib/origen/bugs/bug.rb +36 -0
  42. data/lib/origen/bugs.rb +45 -0
  43. data/lib/origen/callbacks.rb +35 -0
  44. data/lib/origen/chip_mode.rb +118 -0
  45. data/lib/origen/chip_package.rb +461 -0
  46. data/lib/origen/client.rb +87 -0
  47. data/lib/origen/code_generators/actions.rb +258 -0
  48. data/lib/origen/code_generators/base.rb +57 -0
  49. data/lib/origen/code_generators/bundler.rb +17 -0
  50. data/lib/origen/code_generators/gem_setup.rb +49 -0
  51. data/lib/origen/code_generators/rake.rb +13 -0
  52. data/lib/origen/code_generators/rspec.rb +12 -0
  53. data/lib/origen/code_generators/semver.rb +39 -0
  54. data/lib/origen/code_generators/timever.rb +37 -0
  55. data/lib/origen/code_generators.rb +111 -0
  56. data/lib/origen/commands/add.rb +12 -0
  57. data/lib/origen/commands/compile.rb +62 -0
  58. data/lib/origen/commands/ctags.rb +9 -0
  59. data/lib/origen/commands/dispatch.rb +22 -0
  60. data/lib/origen/commands/environment.rb +11 -0
  61. data/lib/origen/commands/fetch.rb +63 -0
  62. data/lib/origen/commands/generate.rb +130 -0
  63. data/lib/origen/commands/interactive.rb +73 -0
  64. data/lib/origen/commands/lint.rb +82 -0
  65. data/lib/origen/commands/lsf.rb +93 -0
  66. data/lib/origen/commands/merge.rb +55 -0
  67. data/lib/origen/commands/modifications.rb +12 -0
  68. data/lib/origen/commands/new.rb +113 -0
  69. data/lib/origen/commands/plugin.rb +105 -0
  70. data/lib/origen/commands/program.rb +70 -0
  71. data/lib/origen/commands/rc.rb +442 -0
  72. data/lib/origen/commands/save.rb +56 -0
  73. data/lib/origen/commands/target.rb +27 -0
  74. data/lib/origen/commands/time.rb +127 -0
  75. data/lib/origen/commands/version.rb +17 -0
  76. data/lib/origen/commands/web.rb +221 -0
  77. data/lib/origen/commands.rb +272 -0
  78. data/lib/origen/commands_global.rb +76 -0
  79. data/lib/origen/controller.rb +94 -0
  80. data/lib/origen/core_ext/array.rb +23 -0
  81. data/lib/origen/core_ext/bignum.rb +36 -0
  82. data/lib/origen/core_ext/enumerable.rb +76 -0
  83. data/lib/origen/core_ext/fixnum.rb +46 -0
  84. data/lib/origen/core_ext/hash.rb +52 -0
  85. data/lib/origen/core_ext/module.rb +14 -0
  86. data/lib/origen/core_ext/numeric.rb +126 -0
  87. data/lib/origen/core_ext/object.rb +13 -0
  88. data/lib/origen/core_ext/range.rb +7 -0
  89. data/lib/origen/core_ext/string.rb +124 -0
  90. data/lib/origen/core_ext.rb +10 -0
  91. data/lib/origen/database/key_value_store.rb +111 -0
  92. data/lib/origen/database/key_value_stores.rb +108 -0
  93. data/lib/origen/database.rb +6 -0
  94. data/lib/origen/encodings.rb +102 -0
  95. data/lib/origen/features/feature.rb +22 -0
  96. data/lib/origen/features.rb +104 -0
  97. data/lib/origen/file_handler.rb +429 -0
  98. data/lib/origen/generator/comparator.rb +56 -0
  99. data/lib/origen/generator/compiler.rb +277 -0
  100. data/lib/origen/generator/flow.rb +49 -0
  101. data/lib/origen/generator/job.rb +131 -0
  102. data/lib/origen/generator/pattern.rb +356 -0
  103. data/lib/origen/generator/pattern_finder.rb +155 -0
  104. data/lib/origen/generator/pattern_iterator.rb +55 -0
  105. data/lib/origen/generator/renderer.rb +113 -0
  106. data/lib/origen/generator/resources.rb +40 -0
  107. data/lib/origen/generator/stage.rb +89 -0
  108. data/lib/origen/generator.rb +85 -0
  109. data/lib/origen/global_methods.rb +205 -0
  110. data/lib/origen/import_manager.rb +596 -0
  111. data/lib/origen/location/base.rb +116 -0
  112. data/lib/origen/location/map.rb +83 -0
  113. data/lib/origen/location.rb +6 -0
  114. data/lib/origen/log.rb +217 -0
  115. data/lib/origen/logger_methods.rb +56 -0
  116. data/lib/origen/mode.rb +61 -0
  117. data/lib/origen/model.rb +267 -0
  118. data/lib/origen/model_initializer.rb +45 -0
  119. data/lib/origen/nvm/block_array.rb +72 -0
  120. data/lib/origen/nvm.rb +6 -0
  121. data/lib/origen/parameters/live.rb +22 -0
  122. data/lib/origen/parameters/missing.rb +28 -0
  123. data/lib/origen/parameters/set.rb +144 -0
  124. data/lib/origen/parameters.rb +107 -0
  125. data/lib/origen/pdm.rb +218 -0
  126. data/lib/origen/pins/function_proxy.rb +36 -0
  127. data/lib/origen/pins/ground_pin.rb +6 -0
  128. data/lib/origen/pins/pin.rb +860 -0
  129. data/lib/origen/pins/pin_bank.rb +349 -0
  130. data/lib/origen/pins/pin_clock.rb +124 -0
  131. data/lib/origen/pins/pin_collection.rb +492 -0
  132. data/lib/origen/pins/pin_common.rb +206 -0
  133. data/lib/origen/pins/port.rb +268 -0
  134. data/lib/origen/pins/power_pin.rb +30 -0
  135. data/lib/origen/pins.rb +696 -0
  136. data/lib/origen/registers/bit.rb +562 -0
  137. data/lib/origen/registers/bit_collection.rb +787 -0
  138. data/lib/origen/registers/container.rb +288 -0
  139. data/lib/origen/registers/domain.rb +16 -0
  140. data/lib/origen/registers/reg.rb +1406 -0
  141. data/lib/origen/registers/reg_collection.rb +24 -0
  142. data/lib/origen/registers.rb +652 -0
  143. data/lib/origen/regression_manager.rb +251 -0
  144. data/lib/origen/remote_manager.rb +340 -0
  145. data/lib/origen/revision_control/base.rb +257 -0
  146. data/lib/origen/revision_control/design_sync.rb +276 -0
  147. data/lib/origen/revision_control/git.rb +243 -0
  148. data/lib/origen/revision_control/subversion.rb +6 -0
  149. data/lib/origen/revision_control.rb +44 -0
  150. data/lib/origen/ruby_version_check.rb +131 -0
  151. data/lib/origen/site_config.rb +61 -0
  152. data/lib/origen/specs/checkers.rb +103 -0
  153. data/lib/origen/specs/creation_info.rb +17 -0
  154. data/lib/origen/specs/doc_resource.rb +91 -0
  155. data/lib/origen/specs/exhibit.rb +17 -0
  156. data/lib/origen/specs/mode_select.rb +16 -0
  157. data/lib/origen/specs/note.rb +17 -0
  158. data/lib/origen/specs/override.rb +21 -0
  159. data/lib/origen/specs/power_supply.rb +13 -0
  160. data/lib/origen/specs/spec.rb +226 -0
  161. data/lib/origen/specs/version_history.rb +14 -0
  162. data/lib/origen/specs.rb +552 -0
  163. data/lib/origen/sub_blocks.rb +298 -0
  164. data/lib/origen/tester/api.rb +277 -0
  165. data/lib/origen/tester/bdm/bdm.rb +25 -0
  166. data/lib/origen/tester/command_based_tester.rb +46 -0
  167. data/lib/origen/tester/doc/doc.rb +226 -0
  168. data/lib/origen/tester/doc/generator/flow.rb +71 -0
  169. data/lib/origen/tester/doc/generator/flow_line.rb +203 -0
  170. data/lib/origen/tester/doc/generator/test.rb +68 -0
  171. data/lib/origen/tester/doc/generator/test_group.rb +66 -0
  172. data/lib/origen/tester/doc/generator/tests.rb +47 -0
  173. data/lib/origen/tester/doc/generator.rb +126 -0
  174. data/lib/origen/tester/doc/model.rb +162 -0
  175. data/lib/origen/tester/generator/flow_control_api.rb +606 -0
  176. data/lib/origen/tester/generator/identity_map.rb +25 -0
  177. data/lib/origen/tester/generator/placeholder.rb +13 -0
  178. data/lib/origen/tester/generator/test_numberer.rb +25 -0
  179. data/lib/origen/tester/generator.rb +271 -0
  180. data/lib/origen/tester/interface.rb +154 -0
  181. data/lib/origen/tester/j750/files.rb +45 -0
  182. data/lib/origen/tester/j750/generator/flow.rb +123 -0
  183. data/lib/origen/tester/j750/generator/flow_line.rb +288 -0
  184. data/lib/origen/tester/j750/generator/patgroup.rb +111 -0
  185. data/lib/origen/tester/j750/generator/patgroups.rb +41 -0
  186. data/lib/origen/tester/j750/generator/patset.rb +111 -0
  187. data/lib/origen/tester/j750/generator/patsets.rb +41 -0
  188. data/lib/origen/tester/j750/generator/templates/flow.txt.erb +9 -0
  189. data/lib/origen/tester/j750/generator/templates/instances.txt.erb +16 -0
  190. data/lib/origen/tester/j750/generator/templates/patgroups.txt.erb +8 -0
  191. data/lib/origen/tester/j750/generator/templates/patsets.txt.erb +10 -0
  192. data/lib/origen/tester/j750/generator/test_instance.rb +846 -0
  193. data/lib/origen/tester/j750/generator/test_instance_group.rb +60 -0
  194. data/lib/origen/tester/j750/generator/test_instances.rb +182 -0
  195. data/lib/origen/tester/j750/generator.rb +203 -0
  196. data/lib/origen/tester/j750/j750.rb +845 -0
  197. data/lib/origen/tester/j750/j750_hpt.rb +35 -0
  198. data/lib/origen/tester/j750/parser/ac_spec.rb +11 -0
  199. data/lib/origen/tester/j750/parser/ac_specs.rb +0 -0
  200. data/lib/origen/tester/j750/parser/dc_spec.rb +36 -0
  201. data/lib/origen/tester/j750/parser/dc_specs.rb +50 -0
  202. data/lib/origen/tester/j750/parser/descriptions.rb +340 -0
  203. data/lib/origen/tester/j750/parser/flow.rb +111 -0
  204. data/lib/origen/tester/j750/parser/flow_line.rb +207 -0
  205. data/lib/origen/tester/j750/parser/flows.rb +23 -0
  206. data/lib/origen/tester/j750/parser/pattern_set.rb +94 -0
  207. data/lib/origen/tester/j750/parser/pattern_sets.rb +33 -0
  208. data/lib/origen/tester/j750/parser/test_instance.rb +322 -0
  209. data/lib/origen/tester/j750/parser/test_instances.rb +26 -0
  210. data/lib/origen/tester/j750/parser/timeset.rb +15 -0
  211. data/lib/origen/tester/j750/parser/timesets.rb +0 -0
  212. data/lib/origen/tester/j750/parser.rb +104 -0
  213. data/lib/origen/tester/jlink/jlink.rb +33 -0
  214. data/lib/origen/tester/parser/description_lookup.rb +64 -0
  215. data/lib/origen/tester/parser/searchable_array.rb +32 -0
  216. data/lib/origen/tester/parser/searchable_hash.rb +32 -0
  217. data/lib/origen/tester/parser.rb +24 -0
  218. data/lib/origen/tester/time.rb +338 -0
  219. data/lib/origen/tester/timing.rb +253 -0
  220. data/lib/origen/tester/ultraflex/files.rb +45 -0
  221. data/lib/origen/tester/ultraflex/generator/flow.rb +119 -0
  222. data/lib/origen/tester/ultraflex/generator/flow_line.rb +269 -0
  223. data/lib/origen/tester/ultraflex/generator/patgroup.rb +111 -0
  224. data/lib/origen/tester/ultraflex/generator/patgroups.rb +41 -0
  225. data/lib/origen/tester/ultraflex/generator/patset.rb +111 -0
  226. data/lib/origen/tester/ultraflex/generator/patsets.rb +41 -0
  227. data/lib/origen/tester/ultraflex/generator/templates/flow.txt.erb +9 -0
  228. data/lib/origen/tester/ultraflex/generator/templates/instances.txt.erb +16 -0
  229. data/lib/origen/tester/ultraflex/generator/templates/patgroups.txt.erb +8 -0
  230. data/lib/origen/tester/ultraflex/generator/templates/patsets.txt.erb +10 -0
  231. data/lib/origen/tester/ultraflex/generator/test_instance.rb +622 -0
  232. data/lib/origen/tester/ultraflex/generator/test_instance_group.rb +60 -0
  233. data/lib/origen/tester/ultraflex/generator/test_instances.rb +174 -0
  234. data/lib/origen/tester/ultraflex/generator.rb +200 -0
  235. data/lib/origen/tester/ultraflex/parser/ac_spec.rb +11 -0
  236. data/lib/origen/tester/ultraflex/parser/ac_specs.rb +0 -0
  237. data/lib/origen/tester/ultraflex/parser/dc_spec.rb +36 -0
  238. data/lib/origen/tester/ultraflex/parser/dc_specs.rb +50 -0
  239. data/lib/origen/tester/ultraflex/parser/descriptions.rb +342 -0
  240. data/lib/origen/tester/ultraflex/parser/flow.rb +111 -0
  241. data/lib/origen/tester/ultraflex/parser/flow_line.rb +207 -0
  242. data/lib/origen/tester/ultraflex/parser/flows.rb +23 -0
  243. data/lib/origen/tester/ultraflex/parser/pattern_set.rb +94 -0
  244. data/lib/origen/tester/ultraflex/parser/pattern_sets.rb +33 -0
  245. data/lib/origen/tester/ultraflex/parser/test_instance.rb +262 -0
  246. data/lib/origen/tester/ultraflex/parser/test_instances.rb +26 -0
  247. data/lib/origen/tester/ultraflex/parser/timeset.rb +15 -0
  248. data/lib/origen/tester/ultraflex/parser/timesets.rb +0 -0
  249. data/lib/origen/tester/ultraflex/parser.rb +104 -0
  250. data/lib/origen/tester/ultraflex/ultraflex.rb +759 -0
  251. data/lib/origen/tester/v93k/generator/flow.rb +63 -0
  252. data/lib/origen/tester/v93k/generator/flow_node/print.rb +10 -0
  253. data/lib/origen/tester/v93k/generator/flow_node.rb +17 -0
  254. data/lib/origen/tester/v93k/generator/pattern.rb +16 -0
  255. data/lib/origen/tester/v93k/generator/pattern_master.rb +54 -0
  256. data/lib/origen/tester/v93k/generator/templates/_test_method.txt.erb +6 -0
  257. data/lib/origen/tester/v93k/generator/templates/_test_suite.txt.erb +11 -0
  258. data/lib/origen/tester/v93k/generator/templates/template.flow.erb +121 -0
  259. data/lib/origen/tester/v93k/generator/templates/template.pmfl.erb +9 -0
  260. data/lib/origen/tester/v93k/generator/test_function.rb +103 -0
  261. data/lib/origen/tester/v93k/generator/test_functions.rb +79 -0
  262. data/lib/origen/tester/v93k/generator/test_method.rb +46 -0
  263. data/lib/origen/tester/v93k/generator/test_methods.rb +75 -0
  264. data/lib/origen/tester/v93k/generator/test_suite.rb +54 -0
  265. data/lib/origen/tester/v93k/generator/test_suites.rb +65 -0
  266. data/lib/origen/tester/v93k/generator.rb +80 -0
  267. data/lib/origen/tester/v93k/v93k.rb +420 -0
  268. data/lib/origen/tester/vector.rb +86 -0
  269. data/lib/origen/tester/vector_generator.rb +633 -0
  270. data/lib/origen/tester/vector_pipeline.rb +150 -0
  271. data/lib/origen/tester.rb +56 -0
  272. data/lib/origen/top_level.rb +134 -0
  273. data/lib/origen/users/ldap.rb +65 -0
  274. data/lib/origen/users/user.rb +149 -0
  275. data/lib/origen/users.rb +30 -0
  276. data/lib/origen/utility/block_args.rb +93 -0
  277. data/lib/origen/utility/csv_data.rb +110 -0
  278. data/lib/origen/utility/design_sync.rb +494 -0
  279. data/lib/origen/utility/diff.rb +158 -0
  280. data/lib/origen/utility/input_capture.rb +121 -0
  281. data/lib/origen/utility/mailer.rb +143 -0
  282. data/lib/origen/utility/s_record.rb +205 -0
  283. data/lib/origen/utility/time_and_date.rb +30 -0
  284. data/lib/origen/utility.rb +12 -0
  285. data/lib/origen/version_checker.rb +117 -0
  286. data/lib/origen/version_string.rb +356 -0
  287. data/lib/origen.rb +648 -0
  288. data/lib/tasks/gem.rake +27 -22
  289. data/origen_site_config.yml +36 -0
  290. data/source_setup +17 -0
  291. data/spec/format/rgen_formatter.rb +14 -0
  292. data/templates/api_doc/README.txt.erb +24 -0
  293. data/templates/code_generators/gemfile_app.rb +4 -0
  294. data/templates/code_generators/gemfile_plugin.rb +6 -0
  295. data/templates/code_generators/gemspec.rb +33 -0
  296. data/templates/code_generators/rakefile.rb +10 -0
  297. data/templates/code_generators/spec_helper.rb +49 -0
  298. data/templates/code_generators/version.rb +8 -0
  299. data/templates/code_generators/version_time.rb +3 -0
  300. data/templates/git/gitignore.erb +33 -0
  301. data/templates/j750/_vt_flow.txt.erb +8 -0
  302. data/templates/j750/_vt_instances.txt.erb +4 -0
  303. data/templates/j750/program_sheet.txt.erb +9 -0
  304. data/templates/nanoc/Rules +74 -0
  305. data/templates/nanoc/config.yaml +77 -0
  306. data/templates/nanoc/content/favicon.ico +0 -0
  307. data/templates/nanoc/layouts/bootstrap.html.erb +63 -0
  308. data/templates/nanoc/layouts/bootstrap3.html.erb +71 -0
  309. data/templates/nanoc/layouts/freescale.html.erb +79 -0
  310. data/templates/nanoc/lib/bootstrap_filter.rb +49 -0
  311. data/templates/nanoc/lib/codeblocks_filter.rb +41 -0
  312. data/templates/nanoc/lib/default.rb +2 -0
  313. data/templates/nanoc/lib/gzip_filter.rb +16 -0
  314. data/templates/nanoc/lib/haml_code_filter.rb +41 -0
  315. data/templates/nanoc/lib/helpers.rb +1 -0
  316. data/templates/nanoc/lib/search_filter.rb +62 -0
  317. data/templates/nanoc_dynamic/content/search.js.erb +92 -0
  318. data/templates/shared/web/_logo.html +10 -0
  319. data/templates/test/_inline_sub.txt.erb +2 -0
  320. data/templates/test/environment.txt.erb +1 -0
  321. data/templates/test/inline.txt.erb +11 -0
  322. data/templates/test/inspections.txt.erb +19 -0
  323. data/templates/test/set1/_sub1.txt.erb +12 -0
  324. data/templates/test/set1/_sub4.txt.erb +1 -0
  325. data/templates/test/set1/_sub5.txt.erb +1 -0
  326. data/templates/test/set1/main.txt.erb +53 -0
  327. data/templates/test/set1/sub_dir/_sub2.txt.erb +20 -0
  328. data/templates/test/set1/sub_dir/_sub3.txt.erb +12 -0
  329. data/templates/test/set1/sub_dir/main2.txt.erb +4 -0
  330. data/templates/test/set2/template_with_no_erb_1.txt +9 -0
  331. data/templates/test/set2/template_with_no_erb_2.txt +9 -0
  332. data/templates/test/set3/_layout.html.erb +4 -0
  333. data/templates/test/set3/content.html.erb +6 -0
  334. data/templates/time/filter.rb.erb +15 -0
  335. data/templates/time/rules.rb.erb +45 -0
  336. metadata +639 -5
@@ -0,0 +1,606 @@
1
+ module Origen
2
+ module Tester
3
+ module Generator
4
+ module FlowControlAPI
5
+ # Flow control methods related to flow context
6
+ FLOW_METHODS = [
7
+ # Methods in arrays are aliases, the primary name is the first one
8
+ [:if_enable, :if_enabled, :enable, :enabled],
9
+ [:unless_enable, :unless_enabled],
10
+ [:if_job, :if_jobs],
11
+ [:unless_job, :unless_jobs]
12
+ ]
13
+
14
+ # Flow control methods related to a relationship with another test
15
+ RELATION_METHODS = [
16
+ # Methods in arrays are aliases, the primary name is the first one
17
+ :if_ran,
18
+ :unless_ran,
19
+ [:if_failed, :unless_passed],
20
+ [:if_passed, :unless_failed],
21
+ [:if_any_passed, :unless_all_failed],
22
+ [:if_all_passed, :unless_any_failed],
23
+ [:if_any_failed, :unless_all_passed],
24
+ [:if_all_failed, :unless_any_passed]
25
+ ]
26
+
27
+ # Returns true if the test context generated from the supplied options + existing context
28
+ # wrappers is different from that which was applied to the previous test.
29
+ def context_changed?(options = {})
30
+ current_context[:hash_code] != summarize_context(options)[:hash_code]
31
+ end
32
+
33
+ # @api private
34
+ def save_context(options = {})
35
+ # If the test has requested to use the current context...
36
+ if options[:context] == :current
37
+ replace_context_with_current(options)
38
+ else
39
+ @current_context = summarize_context(options)
40
+ options.merge(@current_context[:context])
41
+ end
42
+ end
43
+
44
+ # Returns a hash representing the current context, that is the context that was applied
45
+ # to the last test.
46
+ #
47
+ # The hash contains two items:
48
+ #
49
+ # * :context contains a hash that summarises the flow control options that have been
50
+ # used, for example it may contain something like: :if_enable => "data_collection"
51
+ # * :hash_code returns a hash-code for the values contained in the :context arrary. Any
52
+ # two equivalent contexts will have the same :hash_code, therefore this can be used
53
+ # to easily check the equivalence of any two contexts.
54
+ def current_context
55
+ @current_context ||= save_context
56
+ end
57
+
58
+ # @api private
59
+ #
60
+ # Removes any context options from the given options hash and merges in the current
61
+ # context
62
+ def replace_context_with_current(options)
63
+ options = options.merge({})
64
+ [FLOW_METHODS, RELATION_METHODS].flatten.each do |m|
65
+ options.delete(m)
66
+ end
67
+ options.merge(current_context[:context])
68
+ end
69
+
70
+ # Returns a hash like that returned by current_context based on the given set of options +
71
+ # existing context wrappers.
72
+ def summarize_context(options = {})
73
+ code = []
74
+ context = {}
75
+ (FLOW_METHODS + RELATION_METHODS).each do |m|
76
+ primary = m.is_a?(Array) ? m.first : m
77
+ val = false
78
+ [m].flatten.each do |m|
79
+ if options[m]
80
+ val = options[m]
81
+ elsif instance_variable_get("@#{m}_block")
82
+ val = instance_variable_get("@#{m}_block")
83
+ end
84
+ end
85
+ if val
86
+ code << primary
87
+ code << val
88
+ context[primary] = val
89
+ end
90
+ end
91
+ { hash_code: code.flatten.hash, context: context }
92
+ end
93
+
94
+ # All tests generated within the given block will be assigned the given enable word.
95
+ #
96
+ # If a test encountered within the block already has another enable word assigned to it then
97
+ # an error will be raised.
98
+ def if_enable(word, _options = {})
99
+ @if_enable_block = word
100
+ yield word
101
+ @if_enable_block = nil
102
+ end
103
+ alias_method :if_enabled, :if_enable
104
+
105
+ # All tests generated will not run unless the given enable word is asserted.
106
+ def unless_enable(word, options = {})
107
+ @unless_enable_block = word unless options[:or]
108
+ yield word
109
+ @unless_enable_block = nil
110
+ end
111
+ alias_method :unless_enabled, :unless_enable
112
+
113
+ # All tests generated within the given block will be enabled only for the given jobs.
114
+ def if_job(*jobs)
115
+ jobs = jobs.flatten
116
+ @if_job_block = @if_job_block ? @if_job_block + jobs : jobs
117
+ yield
118
+ @if_job_block = nil
119
+ end
120
+ alias_method :if_jobs, :if_job
121
+
122
+ # All tests generated within the given block will be enabled only for the given jobs.
123
+ def unless_job(*jobs)
124
+ jobs = jobs.flatten
125
+ @unless_job_block = @unless_job_block ? @unless_job_block + jobs : jobs
126
+ yield
127
+ @unless_job_block = nil
128
+ end
129
+ alias_method :unless_jobs, :unless_job
130
+
131
+ # All tests generated within the given block will only run if the given test id has also
132
+ # run earlier in the flow
133
+ def if_ran(test_id, options = {})
134
+ test_id = Origen.interface.filter_id(test_id, options)
135
+ return if options.key?(:if) && !options[:if]
136
+ return if options.key?(:unless) && options[:unless]
137
+ if @if_ran_block
138
+ fail 'Sorry but nesting of if_ran is not currently supported!'
139
+ end
140
+ @if_ran_block = test_id
141
+ yield
142
+ @if_ran_block = nil
143
+ end
144
+
145
+ # All tests generated within the given block will only run if the given test id has not
146
+ # run earlier in the flow
147
+ def unless_ran(test_id, options = {})
148
+ test_id = Origen.interface.filter_id(test_id, options)
149
+ return if options.key?(:if) && !options[:if]
150
+ return if options.key?(:unless) && options[:unless]
151
+ if @unless_ran_block
152
+ fail 'Sorry but nesting of unless_ran is not currently supported!'
153
+ end
154
+ @unless_ran_block = test_id
155
+ yield
156
+ @unless_ran_block = nil
157
+ end
158
+
159
+ # All tests generated within the given block will only run if the given test id has
160
+ # failed earlier in the flow
161
+ def if_failed(test_id, options = {})
162
+ test_id = Origen.interface.filter_id(test_id, options)
163
+ return if options.key?(:if) && !options[:if]
164
+ return if options.key?(:unless) && options[:unless]
165
+ if @if_failed_block
166
+ fail 'Sorry but nesting of if_failed is not currently supported!'
167
+ end
168
+ @if_failed_block = test_id
169
+ yield
170
+ @if_failed_block = nil
171
+ end
172
+ alias_method :unless_passed, :if_failed
173
+
174
+ # All tests generated within the given block will only run if the given test id has
175
+ # passed earlier in the flow
176
+ def if_passed(test_id, options = {})
177
+ test_id = Origen.interface.filter_id(test_id, options)
178
+ return if options.key?(:if) && !options[:if]
179
+ return if options.key?(:unless) && options[:unless]
180
+ if @if_passed_block
181
+ fail 'Sorry but nesting of if_passed is not currently supported!'
182
+ end
183
+ @if_passed_block = test_id
184
+ yield
185
+ @if_passed_block = nil
186
+ end
187
+ alias_method :unless_failed, :if_passed
188
+
189
+ # All tests generated within the given block will only run if the given test id has
190
+ # passed ON ANY SITE earlier in the flow
191
+ def if_any_passed(test_id, options = {})
192
+ test_id = Origen.interface.filter_id(test_id, options)
193
+ return if conditionally_deactivated?(options)
194
+ if @if_any_passed_block
195
+ fail 'Sorry but nesting of if_any_passed is not currently supported!'
196
+ end
197
+ @if_any_passed_block = test_id
198
+ yield
199
+ @if_any_passed_block = nil
200
+ end
201
+ alias_method :unless_all_failed, :if_any_passed
202
+
203
+ # All tests generated within the given block will only run if the given test id has
204
+ # passed ON ALL SITES earlier in the flow
205
+ def if_all_passed(test_id, options = {})
206
+ test_id = Origen.interface.filter_id(test_id, options)
207
+ return if conditionally_deactivated?(options)
208
+ if @if_all_passed_block
209
+ fail 'Sorry but nesting of if_all_passed is not currently supported!'
210
+ end
211
+ @if_all_passed_block = test_id
212
+ yield
213
+ @if_all_passed_block = nil
214
+ end
215
+ alias_method :unless_any_failed, :if_all_passed
216
+
217
+ # All tests generated within the given block will only run if the given test id has
218
+ # failed ON ANY SITE earlier in the flow
219
+ def if_any_failed(test_id, options = {})
220
+ test_id = Origen.interface.filter_id(test_id, options)
221
+ return if conditionally_deactivated?(options)
222
+ if @if_any_failed_block
223
+ fail 'Sorry but nesting of if_any_failed is not currently supported!'
224
+ end
225
+ @if_any_failed_block = test_id
226
+ yield
227
+ @if_any_failed_block = nil
228
+ end
229
+ alias_method :unless_all_passed, :if_any_failed
230
+
231
+ # All tests generated within the given block will only run if the given test id has
232
+ # failed ON ALL SITES earlier in the flow
233
+ def if_all_failed(test_id, options = {})
234
+ test_id = Origen.interface.filter_id(test_id, options)
235
+ return if conditionally_deactivated?(options)
236
+ if @if_all_failed_block
237
+ fail 'Sorry but nesting of if_all_failed is not currently supported!'
238
+ end
239
+ @if_all_failed_block = test_id
240
+ yield
241
+ @if_all_failed_block = nil
242
+ end
243
+ alias_method :unless_any_passed, :if_all_failed
244
+
245
+ def conditionally_deactivated?(options)
246
+ (options.key?(:if) && !options[:if]) ||
247
+ (options.key?(:unless) && options[:unless])
248
+ end
249
+
250
+ def find_by_id(id, options = {}) # :nodoc:
251
+ options = {
252
+ search_other_flows: true
253
+ }.merge(options)
254
+ # Look within the current flow for a match first
255
+ t = identity_map[id.to_sym]
256
+ return t if t
257
+ # If no match then look across other flow modules for a match
258
+ # This currently returns the first match, should it raise an error on multiple?
259
+ if options[:search_other_flows]
260
+ Origen.interface.flow_generators.any? do |flow|
261
+ t = flow.find_by_id(id, search_other_flows: false)
262
+ end
263
+ end
264
+ t
265
+ end
266
+
267
+ def identity_map # :nodoc:
268
+ @identity_map ||= {}
269
+ end
270
+
271
+ # If a class that includes this module has a finalize method it must
272
+ # call apply_relationships
273
+ def finalize(_options = {}) # :nodoc:
274
+ apply_relationships
275
+ end
276
+
277
+ def apply_relationships # :nodoc:
278
+ if @relationships
279
+ @relationships.each do |rel|
280
+ t = find_by_id(rel[:target_id])
281
+ fail "Test not found with ID: #{rel[:target_id]}, referenced in flow: #{filename}" unless t
282
+ t.id = rel[:target_id]
283
+ confirm_valid_context(t, rel[:dependent])
284
+ case rel[:type]
285
+ # The first cases here contain J750 logic, these should be replaced
286
+ # with the call method style used for the later cases when time permits.
287
+ when :failed
288
+ if rel[:dependent].respond_to?(:run_if_failed)
289
+ rel[:dependent].run_if_failed(rel[:target_id])
290
+ else
291
+ t.continue_on_fail
292
+ flag = t.set_flag_on_fail
293
+ rel[:dependent].flag_true = flag
294
+ end
295
+ when :passed
296
+ if rel[:dependent].respond_to?(:run_if_passed)
297
+ rel[:dependent].run_if_passed(rel[:target_id])
298
+ else
299
+ t.continue_on_fail
300
+ flag = t.set_flag_on_pass
301
+ rel[:dependent].flag_true = flag
302
+ end
303
+ when :if_ran, :unless_ran
304
+ if rel[:type] == :if_ran
305
+ if rel[:dependent].respond_to?(:run_if_ran)
306
+ rel[:dependent].run_if_ran(rel[:target_id])
307
+ else
308
+ # t.continue_on_fail
309
+ flag = t.set_flag_on_ran
310
+ rel[:dependent].flag_true = flag
311
+ end
312
+ else
313
+ if rel[:dependent].respond_to?(:run_unless_ran)
314
+ rel[:dependent].run_unless_ran(rel[:target_id])
315
+ else
316
+ # t.continue_on_fail
317
+ flag = t.set_flag_on_ran
318
+ rel[:dependent].flag_clear = flag
319
+ end
320
+ end
321
+ when :any_passed
322
+ rel[:dependent].run_if_any_passed(t)
323
+ when :all_passed
324
+ rel[:dependent].run_if_all_passed(t)
325
+ when :any_failed
326
+ rel[:dependent].run_if_any_failed(t)
327
+ when :all_failed
328
+ rel[:dependent].run_if_all_failed(t)
329
+ else
330
+ fail 'Unknown relationship type!'
331
+ end
332
+ end
333
+ @relationships = nil
334
+ end
335
+ end
336
+
337
+ def confirm_valid_context(_test, _dependent) # :nodoc:
338
+ # TODO: Add some validation checks here, for example make sure the dependent
339
+ # executes in the same job(s) as the test, otherwise the dependent will
340
+ # never be hit and will cause a validation error.
341
+ end
342
+
343
+ def record_id(test, options = {})
344
+ if options[:id]
345
+ @@existing_ids ||= []
346
+ if @@existing_ids.include?(options[:id].to_sym)
347
+ fail "The ID '#{test.id}' is not unique, it has already been assigned!"
348
+ else
349
+ @@existing_ids << options[:id].to_sym
350
+ end
351
+ identity_map[options[:id].to_sym] = test
352
+ end
353
+ end
354
+
355
+ # @api private
356
+ def at_run_start
357
+ @@existing_ids = nil
358
+ @@labels = nil
359
+ end
360
+ alias_method :reset_globals, :at_run_start
361
+
362
+ # As generation of render and imports is not linear its possible that the test being
363
+ # referenced does not exist in the collection yet.
364
+ # Therefore the required relationship will be recorded for now and applied later upon
365
+ # closing the generator at which point the complete final collection will be available.
366
+ #
367
+ # Note - as of v2.0.1.dev64 the above is no longer true - imports are generated linearly.
368
+ # Therefore parent test should always already exist and it is possible that this relationship
369
+ # handling could be cleaned up considerably.
370
+ #
371
+ # However we should keep it around for now as it may come in useful when other tester
372
+ # platforms are supported in the future.
373
+ def track_relationships(test_options = {}) # :nodoc:
374
+ [:id, RELATION_METHODS].flatten.each do |id|
375
+ if test_options[id]
376
+ test_options[id] = Origen.interface.filter_id(test_options[id], test_options)
377
+ end
378
+ end
379
+ options = extract_relation_options!(test_options)
380
+ current_test = yield test_options
381
+ record_id(current_test, test_options)
382
+ @relationships ||= []
383
+ target_id = options[:if_failed] || options[:unless_passed] || @if_failed_block
384
+ if target_id
385
+ @relationships << {
386
+ type: :failed,
387
+ target_id: target_id,
388
+ dependent: current_test
389
+ }
390
+ end
391
+ target_id = options[:if_passed] || options[:unless_failed] || @if_passed_block
392
+ if target_id
393
+ @relationships << {
394
+ type: :passed,
395
+ target_id: target_id,
396
+ dependent: current_test
397
+ }
398
+ end
399
+ target_id = options.delete(:if_ran) || @if_ran_block
400
+ if target_id
401
+ @relationships << {
402
+ type: :if_ran,
403
+ target_id: target_id,
404
+ dependent: current_test
405
+ }
406
+ end
407
+ target_id = options.delete(:unless_ran) || @unless_ran_block
408
+ if target_id
409
+ @relationships << {
410
+ type: :unless_ran,
411
+ target_id: target_id,
412
+ dependent: current_test
413
+ }
414
+ end
415
+ target_id = options[:if_any_passed] || options[:unless_all_failed] || @if_any_passed_block
416
+ if target_id
417
+ @relationships << {
418
+ type: :any_passed,
419
+ target_id: target_id,
420
+ dependent: current_test
421
+ }
422
+ end
423
+ target_id = options[:if_all_passed] || options[:unless_any_failed] || @if_all_passed_block
424
+ if target_id
425
+ @relationships << {
426
+ type: :all_passed,
427
+ target_id: target_id,
428
+ dependent: current_test
429
+ }
430
+ end
431
+ target_id = options[:if_any_failed] || options[:unless_all_passed] || @if_any_failed_block
432
+ if target_id
433
+ @relationships << {
434
+ type: :any_failed,
435
+ target_id: target_id,
436
+ dependent: current_test
437
+ }
438
+ end
439
+ target_id = options[:if_all_failed] || options[:unless_any_passed] || @if_all_failed_block
440
+ if target_id
441
+ @relationships << {
442
+ type: :all_failed,
443
+ target_id: target_id,
444
+ dependent: current_test
445
+ }
446
+ end
447
+ if test_options[:context] == :current # Context has already been applied
448
+ current_test
449
+ else
450
+ apply_current_context!(current_test)
451
+ end
452
+ end
453
+
454
+ def apply_current_context!(line) # :nodoc:
455
+ if @if_enable_block
456
+ if line.enable && line.enable != @if_enable_block
457
+ fail "Cannot apply enable word '#{@if_enable_block}' to '#{line.parameter}', it already has '#{line.enable}'"
458
+ else
459
+ line.enable = @if_enable_block
460
+ end
461
+ end
462
+ if @unless_enable_block
463
+ line.unless_enable = @unless_enable_block
464
+ end
465
+ line.if_job = @if_job_block if @if_job_block
466
+ line.unless_job = @unless_job_block if @unless_job_block
467
+ line
468
+ end
469
+
470
+ # Removes any flow relationship options from given hash and returns them
471
+ # in a new hash
472
+ def extract_relation_options!(options) # :nodoc:
473
+ opts = {}
474
+ RELATION_METHODS.flatten.each do |o|
475
+ opts[o] = options.delete(o)
476
+ end
477
+ opts
478
+ end
479
+
480
+ def extract_flow_control_options!(options)
481
+ opts = {}
482
+ FLOW_METHODS.flatten.each do |o|
483
+ if options.key?(o)
484
+ opts[o] = options.delete(o)
485
+ end
486
+ end
487
+ opts
488
+ end
489
+
490
+ def generate_unique_label(id = nil)
491
+ id = 'label' if !id || id == ''
492
+ label = "#{Origen.interface.app_identifier}_#{id}"
493
+ label.gsub!(' ', '_')
494
+ label.upcase!
495
+ @@labels ||= {}
496
+ @@labels[Origen.tester.class] ||= {}
497
+ @@labels[Origen.tester.class][label] ||= 0
498
+ @@labels[Origen.tester.class][label] += 1
499
+ "#{label}_#{@@labels[Origen.tester.class][label]}"
500
+ end
501
+
502
+ module Interface
503
+ # Implement this method in your application interface if you want to
504
+ # sanitize all ID references used in the flow control API.
505
+ # For example you could use this to append a flow name prefix to every
506
+ # ID reference within a flow which can help with ID duplication problems
507
+ # when flow snippets are re-used.
508
+ def filter_id(id, _options = {})
509
+ id
510
+ end
511
+
512
+ def extract_relation_options!(*args)
513
+ flow.extract_relation_options!(*args)
514
+ end
515
+
516
+ def extract_flow_control_options!(*args)
517
+ flow.extract_flow_control_options!(*args)
518
+ end
519
+
520
+ # Alias for flow#if_enable
521
+ def if_enable(*args, &block)
522
+ flow.if_enable(*args, &block)
523
+ end
524
+ alias_method :if_enabled, :if_enable
525
+
526
+ # Alias for flow#unless_enable
527
+ def unless_enable(*args, &block)
528
+ flow.unless_enable(*args, &block)
529
+ end
530
+ alias_method :unless_enabled, :unless_enable
531
+
532
+ # Alias for flow#if_job
533
+ def if_job(*args, &block)
534
+ flow.if_job(*args, &block)
535
+ end
536
+
537
+ # Alias for flow#unless_job
538
+ def unless_job(*args, &block)
539
+ flow.unless_job(*args, &block)
540
+ end
541
+
542
+ # Alias for flow#unless_ran
543
+ def unless_ran(*args, &block)
544
+ flow.unless_ran(*args, &block)
545
+ end
546
+
547
+ # Alias for flow#if_ran
548
+ def if_ran(*args, &block)
549
+ flow.if_ran(*args, &block)
550
+ end
551
+
552
+ # Alias for flow#if_failed
553
+ def if_failed(*args, &block)
554
+ flow.if_failed(*args, &block)
555
+ end
556
+ alias_method :unless_passed, :if_failed
557
+
558
+ # Alias for flow#if_passed
559
+ def if_passed(*args, &block)
560
+ flow.if_passed(*args, &block)
561
+ end
562
+ alias_method :unless_failed, :if_passed
563
+
564
+ # Alias for flow#if_any_passed
565
+ def if_any_passed(*args, &block)
566
+ flow.if_any_passed(*args, &block)
567
+ end
568
+ alias_method :unless_all_failed, :if_any_passed
569
+
570
+ # Alias for flow#if_all_passed
571
+ def if_all_passed(*args, &block)
572
+ flow.if_all_passed(*args, &block)
573
+ end
574
+ alias_method :unless_any_failed, :if_all_passed
575
+
576
+ # Alias for flow#if_any_failed
577
+ def if_any_failed(*args, &block)
578
+ flow.if_any_failed(*args, &block)
579
+ end
580
+ alias_method :unless_all_passed, :if_any_failed
581
+
582
+ # Alias for flow#if_all_failed
583
+ def if_all_failed(*args, &block)
584
+ flow.if_all_failed(*args, &block)
585
+ end
586
+ alias_method :unless_any_passed, :if_all_failed
587
+
588
+ # Alias for flow#skip
589
+ def skip(*args, &block)
590
+ flow.skip(*args, &block)
591
+ end
592
+
593
+ # Alias for flow#current_context
594
+ def current_context(*args, &block)
595
+ flow.current_context(*args, &block)
596
+ end
597
+
598
+ # Alias for flow#context_changed?
599
+ def context_changed?(*args, &block)
600
+ flow.context_changed?(*args, &block)
601
+ end
602
+ end
603
+ end
604
+ end
605
+ end
606
+ end
@@ -0,0 +1,25 @@
1
+ module Origen
2
+ module Tester
3
+ module Generator
4
+ class IdentityMap
5
+ def initialize
6
+ @store = {}
7
+ @versions = {}
8
+ end
9
+
10
+ def current_version_of(obj)
11
+ map = map_for(obj)
12
+ if map
13
+ map[:replaced_by] || map[:instance]
14
+ else
15
+ obj
16
+ end
17
+ end
18
+
19
+ def map_for(obj)
20
+ @store[obj.object_id]
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,13 @@
1
+ module Origen
2
+ module Tester
3
+ module Generator
4
+ class Placeholder
5
+ attr_accessor :type, :file, :options, :id
6
+
7
+ def initialize(type, file, options = {})
8
+ @type, @file, @options = type, file, options
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,25 @@
1
+ module Origen
2
+ module Tester
3
+ module Generator
4
+ class TestNumberer
5
+ # Will return a test number for the given test.
6
+ #
7
+ # @param [Hash] options Options to customize the number generation
8
+ # @option options [Integer] :bits (6) The number of bits in the DAC code
9
+ # @option options [Float] :range (1.26) The range parameter, see code formula
10
+ # @option options [Integer] :offset (0) The o
11
+ def test_number_for(_test_name, options = {})
12
+ options = {
13
+
14
+ }.merge(options)
15
+ end
16
+
17
+ private
18
+
19
+ def store_file
20
+ @store_file ||= Pathname.new "#{Origen.root}/.test_program/test_numbers"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end