trema 0.4.6 → 0.4.7

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.
Files changed (291) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/.travis.yml +24 -7
  4. data/Gemfile +19 -27
  5. data/Guardfile +6 -0
  6. data/README.md +13 -5
  7. data/Rakefile +418 -415
  8. data/bin/quality +2 -2
  9. data/bin/trema +103 -105
  10. data/bin/trema-config +7 -7
  11. data/build.rb +2 -2
  12. data/cruise.rb +109 -83
  13. data/features/dsl/switch_port_specifier.feature +1 -1
  14. data/features/examples/dumper.feature +9 -41
  15. data/features/examples/hello_trema.feature +1 -1
  16. data/features/examples/learning_switch.feature +7 -7
  17. data/features/examples/list_switches.feature +5 -5
  18. data/features/examples/message.set_config.feature +11 -11
  19. data/features/examples/message.vendor-action.feature +7 -7
  20. data/features/examples/message.vendor-stats-request.feature +1 -1
  21. data/features/examples/multi_learning_switch.feature +7 -7
  22. data/features/examples/openflow_message.echo.feature +15 -15
  23. data/features/examples/openflow_message.features_request.feature +12 -12
  24. data/features/examples/openflow_message.hello.feature +13 -13
  25. data/features/examples/packet_in.feature +8 -8
  26. data/features/examples/patch_panel.feature +1 -1
  27. data/features/examples/repeater_hub.feature +7 -7
  28. data/features/examples/switch_info.feature +16 -16
  29. data/features/examples/switch_monitor.feature +11 -11
  30. data/features/examples/transparent_firewall.feature +73 -0
  31. data/features/handlers/switch_ready.feature +1 -1
  32. data/features/step_definitions/misc_steps.rb +24 -24
  33. data/features/step_definitions/send_packets_steps.rb +2 -2
  34. data/features/step_definitions/stats_steps.rb +6 -6
  35. data/features/support/env.rb +15 -15
  36. data/features/support/hooks.rb +9 -9
  37. data/features/switch_event/add_forward_entry.feature +3 -3
  38. data/features/switch_event/delete_forward_entry.feature +3 -3
  39. data/features/switch_event/dump_forward_entries.feature +2 -2
  40. data/features/switch_event/set_forward_entries.feature +2 -2
  41. data/features/trema_commands/dump_flows.feature +1 -0
  42. data/features/trema_commands/help.feature +1 -0
  43. data/features/trema_commands/help_option.feature +1 -0
  44. data/features/trema_commands/kill.feature +1 -0
  45. data/features/trema_commands/killall.feature +1 -0
  46. data/features/trema_commands/port_down.feature +1 -0
  47. data/features/trema_commands/port_up.feature +1 -0
  48. data/features/trema_commands/reset_stats.feature +1 -0
  49. data/features/trema_commands/run.feature +1 -0
  50. data/features/trema_commands/send_packets.feature +2 -1
  51. data/features/trema_commands/show_stats.feature +1 -0
  52. data/features/trema_commands/up.feature +1 -0
  53. data/features/trema_commands/version.feature +1 -0
  54. data/features/trema_commands/version_option.feature +1 -0
  55. data/rubocop-todo.yml +159 -0
  56. data/ruby/blocker.rb +15 -17
  57. data/ruby/extconf.rb +19 -19
  58. data/ruby/sub-process.rb +29 -29
  59. data/ruby/trema/aggregate-stats-reply.rb +2 -2
  60. data/ruby/trema/app.rb +13 -13
  61. data/ruby/trema/cli.rb +45 -45
  62. data/ruby/trema/command.rb +14 -14
  63. data/ruby/trema/command/dump_flows.rb +5 -5
  64. data/ruby/trema/command/kill.rb +13 -13
  65. data/ruby/trema/command/killall.rb +1 -1
  66. data/ruby/trema/command/netns.rb +3 -3
  67. data/ruby/trema/command/port_down.rb +7 -7
  68. data/ruby/trema/command/port_up.rb +7 -7
  69. data/ruby/trema/command/reset_stats.rb +6 -6
  70. data/ruby/trema/command/ruby.rb +2 -2
  71. data/ruby/trema/command/run.rb +23 -23
  72. data/ruby/trema/command/send_packets.rb +9 -9
  73. data/ruby/trema/command/shell.rb +14 -16
  74. data/ruby/trema/command/show_stats.rb +9 -9
  75. data/ruby/trema/command/up.rb +4 -4
  76. data/ruby/trema/command/version.rb +1 -1
  77. data/ruby/trema/controller.rb +10 -10
  78. data/ruby/trema/custom-switch.rb +4 -4
  79. data/ruby/trema/daemon.rb +21 -21
  80. data/ruby/trema/desc-stats-reply.rb +2 -2
  81. data/ruby/trema/dsl.rb +5 -5
  82. data/ruby/trema/dsl/configuration.rb +7 -7
  83. data/ruby/trema/dsl/context.rb +10 -10
  84. data/ruby/trema/dsl/custom-switch.rb +3 -3
  85. data/ruby/trema/dsl/link.rb +2 -2
  86. data/ruby/trema/dsl/netns.rb +9 -9
  87. data/ruby/trema/dsl/parser.rb +14 -14
  88. data/ruby/trema/dsl/rswitch.rb +3 -3
  89. data/ruby/trema/dsl/run.rb +4 -4
  90. data/ruby/trema/dsl/runner.rb +20 -20
  91. data/ruby/trema/dsl/stanza.rb +5 -5
  92. data/ruby/trema/dsl/switch.rb +14 -14
  93. data/ruby/trema/dsl/syntax.rb +54 -54
  94. data/ruby/trema/dsl/vhost.rb +9 -9
  95. data/ruby/trema/dsl/vswitch.rb +4 -4
  96. data/ruby/trema/enqueue.rb +11 -11
  97. data/ruby/trema/exact-match.rb +1 -1
  98. data/ruby/trema/executables.rb +19 -19
  99. data/ruby/trema/flow-stats-reply.rb +2 -2
  100. data/ruby/trema/flow.rb +8 -8
  101. data/ruby/trema/hardware-switch.rb +2 -2
  102. data/ruby/trema/host.rb +18 -18
  103. data/ruby/trema/link.rb +9 -9
  104. data/ruby/trema/mac.rb +1 -5
  105. data/ruby/trema/match.c +0 -1
  106. data/ruby/trema/monkey-patch/integer.rb +3 -3
  107. data/ruby/trema/monkey-patch/integer/base-conversions.rb +1 -1
  108. data/ruby/trema/monkey-patch/integer/ranges.rb +2 -2
  109. data/ruby/trema/monkey-patch/integer/validators.rb +1 -1
  110. data/ruby/trema/monkey-patch/module.rb +2 -2
  111. data/ruby/trema/monkey-patch/module/class-method.rb +2 -2
  112. data/ruby/trema/monkey-patch/module/deprecation.rb +1 -1
  113. data/ruby/trema/monkey-patch/string.rb +1 -1
  114. data/ruby/trema/monkey-patch/string/inflectors.rb +7 -7
  115. data/ruby/trema/netns.rb +6 -6
  116. data/ruby/trema/network-component.rb +7 -7
  117. data/ruby/trema/ofctl.rb +13 -13
  118. data/ruby/trema/open-vswitch.rb +25 -25
  119. data/ruby/trema/openflow-switch.rb +1 -1
  120. data/ruby/trema/ordered-hash.rb +8 -8
  121. data/ruby/trema/packet-in.c +0 -1
  122. data/ruby/trema/packet-queue.rb +8 -8
  123. data/ruby/trema/packetin-filter.rb +9 -9
  124. data/ruby/trema/path.rb +32 -32
  125. data/ruby/trema/phost.rb +5 -5
  126. data/ruby/trema/port-mod.c +0 -1
  127. data/ruby/trema/port-stats-reply.rb +2 -2
  128. data/ruby/trema/port-status-add.rb +2 -2
  129. data/ruby/trema/port-status-delete.rb +2 -2
  130. data/ruby/trema/port-status-modify.rb +2 -2
  131. data/ruby/trema/port.c +0 -1
  132. data/ruby/trema/process.rb +7 -7
  133. data/ruby/trema/queue-stats-reply.rb +2 -2
  134. data/ruby/trema/ruby-switch.rb +6 -6
  135. data/ruby/trema/send-out-port.rb +11 -11
  136. data/ruby/trema/set-eth-addr.rb +5 -5
  137. data/ruby/trema/set-eth-dst-addr.rb +1 -1
  138. data/ruby/trema/set-eth-src-addr.rb +1 -1
  139. data/ruby/trema/set-ip-addr.rb +6 -6
  140. data/ruby/trema/set-ip-dst-addr.rb +1 -1
  141. data/ruby/trema/set-ip-src-addr.rb +1 -1
  142. data/ruby/trema/set-ip-tos.rb +6 -6
  143. data/ruby/trema/set-transport-dst-port.rb +2 -2
  144. data/ruby/trema/set-transport-port.rb +7 -7
  145. data/ruby/trema/set-transport-src-port.rb +3 -3
  146. data/ruby/trema/set-vlan-priority.rb +6 -6
  147. data/ruby/trema/set-vlan-vid.rb +6 -6
  148. data/ruby/trema/shell.rb +10 -10
  149. data/ruby/trema/shell/down.rb +3 -3
  150. data/ruby/trema/shell/killall.rb +1 -1
  151. data/ruby/trema/shell/link.rb +14 -14
  152. data/ruby/trema/shell/reset_stats.rb +6 -6
  153. data/ruby/trema/shell/run.rb +7 -7
  154. data/ruby/trema/shell/send_packets.rb +3 -3
  155. data/ruby/trema/shell/show_stats.rb +7 -7
  156. data/ruby/trema/shell/up.rb +5 -5
  157. data/ruby/trema/shell/vhost.rb +4 -4
  158. data/ruby/trema/shell/vswitch.rb +7 -7
  159. data/ruby/trema/stats-helper.rb +3 -3
  160. data/ruby/trema/stats-reply.c +0 -1
  161. data/ruby/trema/strip-vlan-header.rb +1 -1
  162. data/ruby/trema/switch-daemon.rb +9 -9
  163. data/ruby/trema/switch-manager.rb +9 -9
  164. data/ruby/trema/switch.rb +7 -7
  165. data/ruby/trema/table-stats-reply.rb +2 -2
  166. data/ruby/trema/timers.rb +12 -12
  167. data/ruby/trema/trema.c +0 -1
  168. data/ruby/trema/tremashark.rb +1 -1
  169. data/ruby/trema/util.rb +25 -27
  170. data/ruby/trema/vendor-action.rb +10 -10
  171. data/ruby/trema/vendor-stats-reply.rb +2 -2
  172. data/ruby/trema/version.rb +1 -1
  173. data/spec/spec_helper.rb +50 -52
  174. data/spec/support/action.rb +9 -12
  175. data/spec/support/mandatory-option.rb +15 -18
  176. data/spec/support/matchers/constant.rb +7 -7
  177. data/spec/support/openflow-message.rb +76 -79
  178. data/spec/support/port-status.rb +7 -10
  179. data/spec/trema/app_spec.rb +27 -27
  180. data/spec/trema/barrier-reply_spec.rb +10 -10
  181. data/spec/trema/barrier-request_spec.rb +35 -35
  182. data/spec/trema/cli_spec.rb +63 -63
  183. data/spec/trema/controller_spec.rb +3 -3
  184. data/spec/trema/default-logger_spec.rb +4 -4
  185. data/spec/trema/dsl/configuration_spec.rb +47 -47
  186. data/spec/trema/dsl/link_spec.rb +11 -11
  187. data/spec/trema/dsl/run_spec.rb +19 -19
  188. data/spec/trema/dsl/runner_spec.rb +91 -91
  189. data/spec/trema/dsl/switch_spec.rb +16 -16
  190. data/spec/trema/dsl/syntax_spec.rb +22 -22
  191. data/spec/trema/dsl/vhost_spec.rb +37 -37
  192. data/spec/trema/dsl/vswitch_spec.rb +21 -21
  193. data/spec/trema/echo-reply_spec.rb +29 -29
  194. data/spec/trema/echo-request_spec.rb +54 -54
  195. data/spec/trema/enqueue_spec.rb +25 -25
  196. data/spec/trema/error_spec.rb +30 -30
  197. data/spec/trema/executables_spec.rb +20 -20
  198. data/spec/trema/features-reply_spec.rb +41 -41
  199. data/spec/trema/features-request_spec.rb +35 -35
  200. data/spec/trema/flow-mod_spec.rb +32 -32
  201. data/spec/trema/flow-removed_spec.rb +62 -62
  202. data/spec/trema/get-config-reply_spec.rb +14 -12
  203. data/spec/trema/get-config-request_spec.rb +35 -35
  204. data/spec/trema/hardware-switch_spec.rb +12 -12
  205. data/spec/trema/hello_spec.rb +17 -17
  206. data/spec/trema/host_spec.rb +71 -71
  207. data/spec/trema/link_spec.rb +13 -13
  208. data/spec/trema/list-switches-reply_spec.rb +10 -10
  209. data/spec/trema/match_spec.rb +41 -41
  210. data/spec/trema/open-vswitch_spec.rb +45 -45
  211. data/spec/trema/openflow-error_spec.rb +67 -65
  212. data/spec/trema/packet-in_spec.rb +450 -446
  213. data/spec/trema/packet-out_spec.rb +42 -42
  214. data/spec/trema/packetin-filter_spec.rb +5 -5
  215. data/spec/trema/port-mod_spec.rb +32 -32
  216. data/spec/trema/port-status-add_spec.rb +3 -3
  217. data/spec/trema/port-status-delete_spec.rb +3 -3
  218. data/spec/trema/port-status-modify_spec.rb +16 -16
  219. data/spec/trema/port-status_spec.rb +2 -2
  220. data/spec/trema/port_spec.rb +21 -21
  221. data/spec/trema/process_spec.rb +22 -22
  222. data/spec/trema/queue-get-config-reply_spec.rb +21 -20
  223. data/spec/trema/queue-get-config-request_spec.rb +24 -24
  224. data/spec/trema/send-out-port_spec.rb +42 -42
  225. data/spec/trema/set-config_spec.rb +31 -31
  226. data/spec/trema/set-eth-addr_spec.rb +21 -21
  227. data/spec/trema/set-ip-addr_spec.rb +29 -29
  228. data/spec/trema/set-ip-tos_spec.rb +26 -26
  229. data/spec/trema/set-transport-dst-port_spec.rb +22 -22
  230. data/spec/trema/set-transport-src-port_spec.rb +22 -22
  231. data/spec/trema/set-vlan-priority_spec.rb +23 -23
  232. data/spec/trema/set-vlan-vid_spec.rb +23 -23
  233. data/spec/trema/shell/vhost_spec.rb +21 -21
  234. data/spec/trema/shell/vswitch_spec.rb +30 -30
  235. data/spec/trema/stats-reply_spec.rb +183 -173
  236. data/spec/trema/stats-request_spec.rb +66 -66
  237. data/spec/trema/strip-vlan-header_spec.rb +11 -11
  238. data/spec/trema/switch-daemon_spec.rb +34 -34
  239. data/spec/trema/switch-disconnected_spec.rb +17 -17
  240. data/spec/trema/switch-manager_spec.rb +6 -6
  241. data/spec/trema/tremashark_spec.rb +4 -4
  242. data/spec/trema/util_spec.rb +35 -35
  243. data/spec/trema/vendor-action_spec.rb +26 -26
  244. data/spec/trema/vendor_spec.rb +27 -27
  245. data/spec/trema_spec.rb +2 -2
  246. data/src/examples/cbench_switch/cbench-switch.rb +3 -3
  247. data/src/examples/dumper/dumper.rb +31 -31
  248. data/src/examples/hello_trema/hello-trema.rb +2 -2
  249. data/src/examples/learning_switch/fdb.rb +14 -14
  250. data/src/examples/learning_switch/learning-switch.rb +12 -10
  251. data/src/examples/learning_switch/learning_switch.c +22 -39
  252. data/src/examples/list_switches/list-switches.rb +3 -3
  253. data/src/examples/match_compare/match-compare.rb +20 -20
  254. data/src/examples/multi_learning_switch/multi-learning-switch.rb +12 -12
  255. data/src/examples/openflow_message/echo.rb +4 -4
  256. data/src/examples/openflow_message/example.rb +7 -7
  257. data/src/examples/openflow_message/features-request.rb +31 -31
  258. data/src/examples/openflow_message/hello.rb +2 -2
  259. data/src/examples/openflow_message/set-config.rb +4 -4
  260. data/src/examples/openflow_message/vendor-action.rb +3 -3
  261. data/src/examples/openflow_message/vendor-stats-request.rb +9 -9
  262. data/src/examples/packet_in/packet-in.rb +2 -2
  263. data/src/examples/patch_panel/patch-panel.rb +9 -9
  264. data/src/examples/repeater_hub/repeater-hub.rb +4 -4
  265. data/src/examples/repeater_hub/repeater-hub_spec.rb +65 -65
  266. data/src/examples/simple_router/arp-table.rb +7 -7
  267. data/src/examples/simple_router/interface.rb +10 -10
  268. data/src/examples/simple_router/routing-table.rb +4 -4
  269. data/src/examples/simple_router/simple-router.rb +3 -3
  270. data/src/examples/switch_info/switch-info.rb +9 -9
  271. data/src/examples/switch_monitor/switch-monitor.rb +4 -4
  272. data/src/examples/traffic_monitor/counter.rb +6 -6
  273. data/src/examples/traffic_monitor/fdb.rb +4 -4
  274. data/src/examples/traffic_monitor/traffic-monitor.rb +12 -12
  275. data/src/examples/transparent_firewall/README.md +61 -0
  276. data/src/examples/transparent_firewall/aggregated-delegated-afrinic.txt +713 -0
  277. data/src/examples/transparent_firewall/aggregated-delegated-apnic.txt +3440 -0
  278. data/src/examples/transparent_firewall/aggregated-delegated-arin.txt +11342 -0
  279. data/src/examples/transparent_firewall/aggregated-delegated-lacnic.txt +1937 -0
  280. data/src/examples/transparent_firewall/aggregated-delegated-ripencc.txt +7329 -0
  281. data/src/examples/transparent_firewall/block-rfc1918.rb +86 -0
  282. data/src/examples/transparent_firewall/pass-delegated.rb +178 -0
  283. data/src/examples/transparent_firewall/regen_aggregated.sh +53 -0
  284. data/src/examples/transparent_firewall/stats-to-cidrs.rb +59 -0
  285. data/src/lib/messenger.c +14 -5
  286. data/src/lib/openflow_message.c +0 -5
  287. data/tasks/rubocop.rake +22 -0
  288. data/trema +1 -1
  289. data/trema-config +1 -1
  290. data/trema.gemspec +22 -22
  291. metadata +30 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5d236d112d0ec7ea07f28665ac7def9a03ad148
4
- data.tar.gz: 05ee642924ce569f3c2cd3aa565a5534dae6ba30
3
+ metadata.gz: ae1944272fd94df71dde7f37cae09d3adc26caec
4
+ data.tar.gz: 4e93bf7477c418a53cb9bdf2365776ce8e866419
5
5
  SHA512:
6
- metadata.gz: b3e0b32a3d66e9c29a2b0448525a377a480b0bc18c0509b5eab85c0f27ebb78c11e1886bdd31227fe0a421c9880d6abbb969f83635a8f1536be94b6ba3ac5a1f
7
- data.tar.gz: d1ebcf9d3b41d159e30b2b778f0783500bff5d5fe41f4afa3eede21b111d134537d8ee5b7e5aa5d5f7ad6579046924ef379508407e18001bdaabad2cf7c7d1e0
6
+ metadata.gz: 908ea883109bb2c7a65b556f9d700634a0668837c1400d1daa849bbdf915ff44896fb6d40ff32516940950448bc4daf0bf8dff213de1eae9b02028812d293aa9
7
+ data.tar.gz: fecf42a4b7599f5b8f9177ffc8625b28faf7cd65650591fb57f08608328f04f641d4cf1ececf51e8422fe418626ddac99c130a01502b1afc741f0195de1a04c6
@@ -0,0 +1 @@
1
+ inherit_from: rubocop-todo.yml
@@ -1,21 +1,38 @@
1
1
  language: ruby
2
2
 
3
- script: "rake travis"
3
+ before_install:
4
+ - gem update bundler
5
+ - sudo apt-get update -qq
6
+ - sudo apt-get install libpcap-dev -qq
7
+ bundler_args: --without development
8
+
9
+ env:
10
+ global:
11
+ - secure: "roJa3FuYA6gLdV0vtUe1GyuAU2WQ+E+jraT9QeKKHRQSU2TKYgeJ7MmxG3vSpIoZsHEdmrZh0UVTrMO436UHAG5V+qbSmP2gld0vSI2qDQ2dXbNoAIVUHex2oCDTa5OC0sJbz9W8Yrd0XoTY0O5gObPn6QfTzAHKgPz7ZC9bBwo="
4
12
 
5
13
  rvm:
6
- - 1.8.7
7
14
  - 1.9.3
8
15
  - 2.0.0
16
+ - 2.1.0
17
+ - ruby-head
9
18
 
10
19
  branches:
11
20
  only:
12
21
  - master
13
22
  - develop
14
23
 
15
- before_install:
16
- - sudo apt-get update -qq
17
- - sudo apt-get install libpcap-dev -qq
18
- - gem install bundler
24
+ matrix:
25
+ allow_failures:
26
+ - rvm: 2.1.0
27
+ - rvm: ruby-head
28
+ fast_finish: true
29
+
30
+ script: bundle exec rake travis
19
31
 
20
32
  notifications:
21
- webhooks: http://trema-hubot.herokuapp.com/hubot/travis?room=1
33
+ webhooks:
34
+ urls:
35
+ - https://webhooks.gitter.im/e/ca7b2e631cab5cddce0d
36
+ on_success: always
37
+ on_failure: always
38
+ on_start: always
data/Gemfile CHANGED
@@ -1,36 +1,28 @@
1
- source "https://rubygems.org"
2
-
1
+ source 'https://rubygems.org'
3
2
 
4
3
  # Include dependencies from trema.gemspec. DRY!
5
4
  gemspec
6
5
 
7
6
  # Add dependencies required to use your gem here.
8
7
 
9
- # Add dependencies to develop your gem here.
10
- # Include everything needed to run rake, tests, features, etc.
11
- group :development do
12
- gem "aruba", "~> 0.5.3"
13
- gem "cucumber", "~> 1.3.8"
14
- gem "flay", "~> 2.4.0"
15
- gem "flog", "~> 4.2.0"
16
- gem "rcov", "~> 1.0.0" if RUBY_VERSION < "1.9.0"
17
- gem "redcarpet", "~> 2.3.0" if RUBY_VERSION < "1.9.0"
18
- gem "redcarpet", "~> 3.0.0" if RUBY_VERSION >= "1.9.0"
19
- gem "reek", "~> 1.3.4"
20
- gem "relish", "~> 0.7"
21
- gem "rspec", "~> 2.14.1"
22
- gem "yard", "~> 0.8.7.2"
23
- gem 'guard', '~> 1.8.3' if RUBY_VERSION < '1.9.0'
24
- gem 'guard', '~> 2.2.2' if RUBY_VERSION >= '1.9.0'
25
- gem 'guard-bundler', '~> 1.0.0' if RUBY_VERSION < '1.9.0'
26
- gem 'guard-bundler', '~> 2.0.0' if RUBY_VERSION >= '1.9.0'
27
- gem 'mime-types', '~> 1.25' if RUBY_VERSION < '1.9.0'
28
- gem 'mime-types', '~> 2.0' if RUBY_VERSION >= '1.9.0'
8
+ group :docs do
9
+ gem 'relish', '~> 0.7'
10
+ gem 'yard', '~> 0.8.7.4'
29
11
  end
30
12
 
13
+ group :development do
14
+ gem 'guard', '~> 2.6.1'
15
+ gem 'guard-bundler', '~> 2.0.0'
16
+ gem 'guard-rubocop', '~> 1.1.0'
17
+ end
31
18
 
32
- ### Local variables:
33
- ### mode: Ruby
34
- ### coding: utf-8-unix
35
- ### indent-tabs-mode: nil
36
- ### End:
19
+ group :test do
20
+ gem 'aruba', '~> 0.5.4'
21
+ gem 'codeclimate-test-reporter', require: nil
22
+ gem 'cucumber', '~> 1.3.15'
23
+ gem 'flay', '~> 2.4.0'
24
+ gem 'flog', '~> 4.2.0'
25
+ gem 'reek', '~> 1.3.7'
26
+ gem 'rspec', '~> 2.14.1'
27
+ gem 'rubocop', '~> 0.20.1', platforms: [:ruby_19, :ruby_20, :ruby_21]
28
+ end
data/Guardfile CHANGED
@@ -6,3 +6,9 @@ guard :bundler do
6
6
  # Uncomment next line if your Gemfile contains the `gemspec' command.
7
7
  watch(/^.+\.gemspec/)
8
8
  end
9
+
10
+ guard :rubocop do
11
+ watch(/.+\.rb$/)
12
+ watch(/.+\.rake$/)
13
+ watch(/(?:.+\/)?\.rubocop\.yml$/) { |m| File.dirname(m[0]) }
14
+ end
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  Welcome to Trema
2
2
  ================
3
3
 
4
- [![Gem Version](https://badge.fury.io/rb/trema.png)](http://badge.fury.io/rb/trema)
5
- [![Build Status](https://secure.travis-ci.org/trema/trema.png?branch=develop)](http://travis-ci.org/trema/trema)
6
- [![Code Climate](https://codeclimate.com/github/trema/trema.png)](https://codeclimate.com/github/trema/trema)
7
- [![Dependency Status](https://gemnasium.com/trema/trema.png)](https://gemnasium.com/trema/trema)
4
+ [![Gem Version](http://img.shields.io/gem/v/trema.svg?style=flat)][gem]
5
+ [![Build Status](http://img.shields.io/travis/trema/trema/develop.svg?style=flat)][travis]
6
+ [![Code Climate](http://img.shields.io/codeclimate/github/trema/trema.svg?style=flat)][codeclimate]
7
+ [![Coverage Status](http://img.shields.io/codeclimate/coverage/github/trema/trema.svg?style=flat)][codeclimate]
8
+ [![Dependency Status](http://img.shields.io/gemnasium/trema/trema.svg?style=flat)][gemnasium]
9
+ [![Gitter chat](http://img.shields.io/badge/GITTER-trema-blue.svg?style=flat)][gitter]
8
10
 
9
11
  Trema is a OpenFlow controller framework that includes everything
10
12
  needed to create OpenFlow controllers in Ruby and C.
@@ -21,6 +23,12 @@ emulates an OpenFlow-based network and end-hosts is provided for
21
23
  testing your own controllers. For debugging, a wireshark plug-in to
22
24
  diagnose internal data-flows among functional modules is provided.
23
25
 
26
+ [gem]: https://rubygems.org/gems/trema
27
+ [travis]: http://travis-ci.org/trema/trema
28
+ [codeclimate]: https://codeclimate.com/github/trema/trema
29
+ [gemnasium]: https://gemnasium.com/trema/trema
30
+ [gitter]: https://gitter.im/trema/trema
31
+
24
32
 
25
33
  Supported Platforms
26
34
  -------------------
@@ -57,7 +65,7 @@ Getting Started
57
65
  $ sudo /var/lib/gems/1.8/bin/update_rubygems
58
66
 
59
67
  (In Fedora 16-19)
60
- $ sudo yum install gcc make git ruby rubygems ruby-devel libpcap-devel libsqlite3x-devel glib2-devel
68
+ $ sudo yum install tar gcc make git ruby rubygems ruby-devel libpcap-devel libsqlite3x-devel glib2-devel
61
69
 
62
70
  2.Install Trema at the command prompt:
63
71
 
data/Rakefile CHANGED
@@ -16,13 +16,12 @@
16
16
  #
17
17
 
18
18
 
19
- $LOAD_PATH.unshift( File.expand_path( File.dirname( __FILE__ ) + "/ruby" ) )
19
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/ruby'))
20
20
 
21
21
 
22
- require "rubygems"
23
- require "rake"
24
- require "trema/executables"
25
- require "trema/path"
22
+ require 'rake'
23
+ require 'trema/executables'
24
+ require 'trema/path'
26
25
 
27
26
 
28
27
  task :default => :build_trema
@@ -31,7 +30,7 @@ directory Trema.log
31
30
  directory Trema.pid
32
31
  directory Trema.sock
33
32
 
34
- desc "Build Trema"
33
+ desc 'Build Trema'
35
34
  task :build_trema => [
36
35
  Trema.log,
37
36
  Trema.pid,
@@ -47,135 +46,135 @@ task :build_trema => [
47
46
  ]
48
47
 
49
48
 
50
- require "paper_house"
51
- require "trema/version"
49
+ require 'paper_house'
50
+ require 'trema/version'
52
51
 
53
52
 
54
53
  CFLAGS = [
55
- "-g",
56
- "-std=gnu99",
57
- "-D_GNU_SOURCE",
58
- "-fno-strict-aliasing",
59
- "-Wall",
60
- "-Wextra",
61
- "-Wformat=2",
62
- "-Wcast-qual",
63
- "-Wcast-align",
64
- "-Wwrite-strings",
65
- "-Wconversion",
66
- "-Wfloat-equal",
67
- "-Wpointer-arith",
54
+ '-g',
55
+ '-std=gnu99',
56
+ '-D_GNU_SOURCE',
57
+ '-fno-strict-aliasing',
58
+ '-Wall',
59
+ '-Wextra',
60
+ '-Wformat=2',
61
+ '-Wcast-qual',
62
+ '-Wcast-align',
63
+ '-Wwrite-strings',
64
+ '-Wconversion',
65
+ '-Wfloat-equal',
66
+ '-Wpointer-arith'
68
67
  ]
69
- CFLAGS << "-Werror" if RUBY_VERSION < "1.9.0"
68
+ CFLAGS << '-Werror' if RUBY_VERSION < '1.9.0'
70
69
 
71
70
 
72
- desc "Build Trema C library (static library)."
73
- task "libtrema:static" => "vendor:openflow"
74
- PaperHouse::StaticLibraryTask.new "libtrema:static" do | task |
75
- task.library_name = "libtrema"
71
+ desc 'Build Trema C library (static library).'
72
+ task 'libtrema:static' => 'vendor:openflow'
73
+ PaperHouse::StaticLibraryTask.new 'libtrema:static' do | task |
74
+ task.library_name = 'libtrema'
76
75
  task.target_directory = Trema.lib
77
76
  task.sources = "#{ Trema.include }/*.c"
78
77
  task.cflags = CFLAGS
79
- task.includes = [ Trema.openflow ]
78
+ task.includes = [Trema.openflow]
80
79
  end
81
80
 
82
81
 
83
- desc "Build Trema C library (coverage)."
84
- task "libtrema:gcov" => [ "vendor:openflow" ]
85
- PaperHouse::StaticLibraryTask.new "libtrema:gcov" do | task |
86
- task.library_name = "libtrema"
82
+ desc 'Build Trema C library (coverage).'
83
+ task 'libtrema:gcov' => ['vendor:openflow']
84
+ PaperHouse::StaticLibraryTask.new 'libtrema:gcov' do | task |
85
+ task.library_name = 'libtrema'
87
86
  task.target_directory = "#{ Trema.home }/objects/unittests"
88
87
  task.sources = "#{ Trema.include }/*.c"
89
- task.includes = [ Trema.openflow ]
90
- task.cflags = [ "--coverage" ] + CFLAGS
88
+ task.includes = [Trema.openflow]
89
+ task.cflags = ['--coverage'] + CFLAGS
91
90
  end
92
91
 
93
92
 
94
- desc "Build Trema C library (shared library)."
95
- task "libtrema:shared" => "vendor:openflow"
96
- PaperHouse::SharedLibraryTask.new "libtrema:shared" do | task |
97
- task.library_name = "libtrema"
93
+ desc 'Build Trema C library (shared library).'
94
+ task 'libtrema:shared' => 'vendor:openflow'
95
+ PaperHouse::SharedLibraryTask.new 'libtrema:shared' do | task |
96
+ task.library_name = 'libtrema'
98
97
  task.target_directory = Trema.lib
99
98
  task.version = Trema::VERSION
100
99
  task.sources = "#{ Trema.include }/*.c"
101
- task.includes = [ Trema.openflow ]
100
+ task.includes = [Trema.openflow]
102
101
  task.cflags = CFLAGS
103
102
  end
104
103
 
105
104
 
106
- desc "Build Trema Ruby library."
107
- task "rubylib" => "libtrema:static"
108
- PaperHouse::RubyExtensionTask.new "rubylib" do | task |
109
- task.library_name = "trema"
105
+ desc 'Build Trema Ruby library.'
106
+ task 'rubylib' => 'libtrema:static'
107
+ PaperHouse::RubyExtensionTask.new 'rubylib' do | task |
108
+ task.library_name = 'trema'
110
109
  task.target_directory = Trema.ruby
111
110
  task.sources = "#{ Trema.ruby }/trema/*.c"
112
- task.includes = [ Trema.include, Trema.openflow ]
111
+ task.includes = [Trema.include, Trema.openflow]
113
112
  task.cflags = CFLAGS
114
- task.ldflags = [ "-Wl,-Bsymbolic", "-L#{ Trema.lib }" ]
113
+ task.ldflags = ['-Wl,-Bsymbolic', "-L#{ Trema.lib }"]
115
114
  task.library_dependencies = [
116
- "trema",
117
- "sqlite3",
118
- "pthread",
119
- "rt",
120
- "dl",
121
- "crypt",
122
- "m"
115
+ 'trema',
116
+ 'sqlite3',
117
+ 'pthread',
118
+ 'rt',
119
+ 'dl',
120
+ 'crypt',
121
+ 'm'
123
122
  ]
124
123
  end
125
124
 
126
125
 
127
- desc "Build switch manager."
128
- task :switch_manager => "libtrema:static"
126
+ desc 'Build switch manager.'
127
+ task :switch_manager => 'libtrema:static'
129
128
 
130
129
  PaperHouse::ExecutableTask.new :switch_manager do | task |
131
- task.target_directory = File.dirname( Trema::Executables.switch_manager )
130
+ task.target_directory = File.dirname(Trema::Executables.switch_manager)
132
131
  task.sources = [
133
- "src/switch_manager/dpid_table.c",
134
- "src/switch_manager/event_forward_entry_manipulation.c",
135
- "src/switch_manager/secure_channel_listener.c",
136
- "src/switch_manager/switch_manager.c",
137
- "src/switch_manager/switch_option.c",
132
+ 'src/switch_manager/dpid_table.c',
133
+ 'src/switch_manager/event_forward_entry_manipulation.c',
134
+ 'src/switch_manager/secure_channel_listener.c',
135
+ 'src/switch_manager/switch_manager.c',
136
+ 'src/switch_manager/switch_option.c'
138
137
  ]
139
- task.includes = [ Trema.include, Trema.openflow ]
138
+ task.includes = [Trema.include, Trema.openflow]
140
139
  task.cflags = CFLAGS
141
140
  task.ldflags = "-L#{ Trema.lib }"
142
141
  task.library_dependencies = [
143
- "trema",
144
- "sqlite3",
145
- "pthread",
146
- "rt",
147
- "dl",
142
+ 'trema',
143
+ 'sqlite3',
144
+ 'pthread',
145
+ 'rt',
146
+ 'dl'
148
147
  ]
149
148
  end
150
149
 
151
150
 
152
- desc "Build switch daemon."
153
- task :switch_daemon => "libtrema:static"
151
+ desc 'Build switch daemon.'
152
+ task :switch_daemon => 'libtrema:static'
154
153
 
155
154
  PaperHouse::ExecutableTask.new :switch_daemon do | task |
156
- task.executable_name = File.basename( Trema::Executables.switch )
157
- task.target_directory = File.dirname( Trema::Executables.switch )
155
+ task.executable_name = File.basename(Trema::Executables.switch)
156
+ task.target_directory = File.dirname(Trema::Executables.switch)
158
157
  task.sources = [
159
- "src/switch_manager/cookie_table.c",
160
- "src/switch_manager/event_forward_entry_manipulation.c",
161
- "src/switch_manager/ofpmsg_recv.c",
162
- "src/switch_manager/ofpmsg_send.c",
163
- "src/switch_manager/secure_channel_receiver.c",
164
- "src/switch_manager/secure_channel_sender.c",
165
- "src/switch_manager/service_interface.c",
166
- "src/switch_manager/switch.c",
167
- "src/switch_manager/switch_option.c",
168
- "src/switch_manager/xid_table.c",
158
+ 'src/switch_manager/cookie_table.c',
159
+ 'src/switch_manager/event_forward_entry_manipulation.c',
160
+ 'src/switch_manager/ofpmsg_recv.c',
161
+ 'src/switch_manager/ofpmsg_send.c',
162
+ 'src/switch_manager/secure_channel_receiver.c',
163
+ 'src/switch_manager/secure_channel_sender.c',
164
+ 'src/switch_manager/service_interface.c',
165
+ 'src/switch_manager/switch.c',
166
+ 'src/switch_manager/switch_option.c',
167
+ 'src/switch_manager/xid_table.c'
169
168
  ]
170
- task.includes = [ Trema.include, Trema.openflow ]
169
+ task.includes = [Trema.include, Trema.openflow]
171
170
  task.cflags = CFLAGS
172
171
  task.ldflags = "-L#{ Trema.lib }"
173
172
  task.library_dependencies = [
174
- "trema",
175
- "sqlite3",
176
- "pthread",
177
- "rt",
178
- "dl",
173
+ 'trema',
174
+ 'sqlite3',
175
+ 'pthread',
176
+ 'rt',
177
+ 'dl'
179
178
  ]
180
179
  end
181
180
 
@@ -184,63 +183,63 @@ end
184
183
  # Extract OpenFlow reference implementation
185
184
  ################################################################################
186
185
 
187
- task "vendor:openflow" => Trema.openflow_h
186
+ task 'vendor:openflow' => Trema.openflow_h
188
187
  file Trema.openflow_h => Trema.objects do
189
188
  sh "tar xzf #{ Trema.vendor_openflow }.tar.gz -C #{ Trema.vendor }"
190
189
  cp_r "#{ Trema.vendor_openflow }/include/openflow", Trema.objects
191
190
  end
192
191
  directory Trema.objects
193
192
 
194
- CLOBBER.include( Trema.vendor_openflow ) if FileTest.exists?( Trema.vendor_openflow )
195
- CLOBBER.include( File.join( Trema.objects, "openflow" ) ) if FileTest.exists?( File.join( Trema.objects, "openflow" ) )
193
+ CLOBBER.include(Trema.vendor_openflow) if FileTest.exists?(Trema.vendor_openflow)
194
+ CLOBBER.include(File.join(Trema.objects, 'openflow')) if FileTest.exists?(File.join(Trema.objects, 'openflow'))
196
195
 
197
196
 
198
197
  ################################################################################
199
198
  # Build phost
200
199
  ################################################################################
201
200
 
202
- task "vendor:phost" => [ Trema::Executables.phost, Trema::Executables.cli ]
201
+ task 'vendor:phost' => [Trema::Executables.phost, Trema::Executables.cli]
203
202
 
204
203
  def phost_src
205
- File.join Trema.vendor_phost, "src"
204
+ File.join Trema.vendor_phost, 'src'
206
205
  end
207
206
 
208
207
  def phost_objects
209
- FileList[ File.join( phost_src, "*.o" ) ]
208
+ FileList[ File.join(phost_src, '*.o')]
210
209
  end
211
210
 
212
211
  def phost_vendor_binary
213
- File.join phost_src, "phost"
212
+ File.join phost_src, 'phost'
214
213
  end
215
214
 
216
215
  def phost_cli_vendor_binary
217
- File.join phost_src, "cli"
216
+ File.join phost_src, 'cli'
218
217
  end
219
218
 
220
219
  def phost_clean_targets
221
- ( phost_objects + [ phost_vendor_binary, phost_cli_vendor_binary ] ).select do | each |
220
+ ( phost_objects + [phost_vendor_binary, phost_cli_vendor_binary]).select do | each |
222
221
  FileTest.exists? each
223
222
  end
224
223
  end
225
224
 
226
225
  file Trema::Executables.phost do
227
226
  cd phost_src do
228
- sh "make"
227
+ sh 'make'
229
228
  end
230
- mkdir_p File.dirname( Trema::Executables.phost )
231
- install File.join( phost_src, "phost" ), Trema::Executables.phost, :mode => 0755
229
+ mkdir_p File.dirname(Trema::Executables.phost)
230
+ install File.join(phost_src, 'phost'), Trema::Executables.phost, :mode => 0755
232
231
  end
233
232
 
234
233
  file Trema::Executables.cli do
235
234
  cd phost_src do
236
- sh "make"
235
+ sh 'make'
237
236
  end
238
- mkdir_p File.dirname( Trema::Executables.cli )
239
- install File.join( phost_src, "cli" ), Trema::Executables.cli, :mode => 0755
237
+ mkdir_p File.dirname(Trema::Executables.cli)
238
+ install File.join(phost_src, 'cli'), Trema::Executables.cli, :mode => 0755
240
239
  end
241
240
 
242
241
  CLEAN.include phost_clean_targets
243
- CLOBBER.include( Trema.phost ) if FileTest.exists?( Trema.phost )
242
+ CLOBBER.include(Trema.phost) if FileTest.exists?(Trema.phost)
244
243
 
245
244
 
246
245
  ################################################################################
@@ -248,10 +247,10 @@ CLOBBER.include( Trema.phost ) if FileTest.exists?( Trema.phost )
248
247
  ################################################################################
249
248
 
250
249
  task :vendor => [
251
- "vendor:oflops",
252
- "vendor:openflow",
253
- "vendor:openvswitch",
254
- "vendor:phost",
250
+ 'vendor:oflops',
251
+ 'vendor:openflow',
252
+ 'vendor:openvswitch',
253
+ 'vendor:phost'
255
254
  ]
256
255
 
257
256
 
@@ -259,40 +258,40 @@ task :vendor => [
259
258
  # Build Open vSwitch
260
259
  ################################################################################
261
260
 
262
- task "vendor:openvswitch" => Trema::Executables.ovs_openflowd
261
+ task 'vendor:openvswitch' => Trema::Executables.ovs_openflowd
263
262
  file Trema::Executables.ovs_openflowd do
264
263
  sh "tar xzf #{ Trema.vendor_openvswitch }.tar.gz -C #{ Trema.vendor }"
265
264
  cd Trema.vendor_openvswitch do
266
265
  sh "./configure --prefix=#{ Trema.openvswitch } --with-rundir=#{ Trema.sock }"
267
- sh "make install"
268
- cp "./tests/test-openflowd", Trema::Executables.ovs_openflowd
266
+ sh 'make install'
267
+ cp './tests/test-openflowd', Trema::Executables.ovs_openflowd
269
268
  end
270
269
  end
271
270
 
272
- CLEAN.include( Trema.vendor_openvswitch ) if FileTest.exists?( Trema.vendor_openvswitch )
273
- CLOBBER.include( Trema.openvswitch ) if FileTest.exists?( Trema.openvswitch )
271
+ CLEAN.include(Trema.vendor_openvswitch) if FileTest.exists?(Trema.vendor_openvswitch)
272
+ CLOBBER.include(Trema.openvswitch) if FileTest.exists?(Trema.openvswitch)
274
273
 
275
274
 
276
275
  ################################################################################
277
276
  # Build packetin filter
278
277
  ################################################################################
279
278
 
280
- desc "Build packetin filter."
281
- task :packetin_filter => "libtrema:static"
279
+ desc 'Build packetin filter.'
280
+ task :packetin_filter => 'libtrema:static'
282
281
 
283
282
  PaperHouse::ExecutableTask.new :packetin_filter do | task |
284
- task.executable_name = File.basename( Trema::Executables.packetin_filter )
285
- task.target_directory = File.dirname( Trema::Executables.packetin_filter )
286
- task.sources = [ "src/packetin_filter/*.c" ]
287
- task.includes = [ Trema.include, Trema.openflow ]
283
+ task.executable_name = File.basename(Trema::Executables.packetin_filter)
284
+ task.target_directory = File.dirname(Trema::Executables.packetin_filter)
285
+ task.sources = ['src/packetin_filter/*.c']
286
+ task.includes = [Trema.include, Trema.openflow]
288
287
  task.cflags = CFLAGS
289
288
  task.ldflags = "-L#{ Trema.lib }"
290
289
  task.library_dependencies = [
291
- "trema",
292
- "sqlite3",
293
- "pthread",
294
- "rt",
295
- "dl",
290
+ 'trema',
291
+ 'sqlite3',
292
+ 'pthread',
293
+ 'rt',
294
+ 'dl'
296
295
  ]
297
296
  end
298
297
 
@@ -302,37 +301,37 @@ end
302
301
  ################################################################################
303
302
 
304
303
  def cbench_command
305
- File.join Trema.objects, "oflops/bin/cbench"
304
+ File.join Trema.objects, 'oflops/bin/cbench'
306
305
  end
307
306
 
308
- task "vendor:oflops" => cbench_command
307
+ task 'vendor:oflops' => cbench_command
309
308
  file cbench_command => Trema.openflow_h do
310
309
  sh "tar xzf #{ Trema.vendor_oflops }.tar.gz -C #{ Trema.vendor }"
311
310
  cd Trema.vendor_oflops do
312
311
  sh "./configure --prefix=#{ Trema.oflops } --with-openflow-src-dir=#{ Trema.vendor_openflow }"
313
- sh "make install"
312
+ sh 'make install'
314
313
  end
315
314
  end
316
315
 
317
- CLEAN.include( Trema.oflops ) if FileTest.exists?( Trema.oflops )
318
- CLOBBER.include( Trema.vendor_oflops ) if FileTest.exists?( Trema.vendor_oflops )
316
+ CLEAN.include(Trema.oflops) if FileTest.exists?(Trema.oflops)
317
+ CLOBBER.include(Trema.vendor_oflops) if FileTest.exists?(Trema.vendor_oflops)
319
318
 
320
319
 
321
320
  ################################################################################
322
321
  # cmockery
323
322
  ################################################################################
324
323
 
325
- task "vendor:cmockery" => Trema.libcmockery_a
324
+ task 'vendor:cmockery' => Trema.libcmockery_a
326
325
  file Trema.libcmockery_a do
327
326
  sh "tar xzf #{ Trema.vendor_cmockery }.tar.gz -C #{ Trema.vendor }"
328
327
  cd Trema.vendor_cmockery do
329
- sh "./configure --prefix=#{ Trema.cmockery }"
330
- sh "make install"
328
+ sh "./configure --disable-shared --prefix=#{ Trema.cmockery }"
329
+ sh 'make install'
331
330
  end
332
331
  end
333
332
 
334
- CLEAN.include( Trema.vendor_cmockery ) if FileTest.exists?( Trema.vendor_cmockery )
335
- CLOBBER.include( Trema.cmockery ) if FileTest.exists?( Trema.cmockery )
333
+ CLEAN.include(Trema.vendor_cmockery) if FileTest.exists?(Trema.vendor_cmockery)
334
+ CLOBBER.include(Trema.cmockery) if FileTest.exists?(Trema.cmockery)
336
335
 
337
336
 
338
337
  ################################################################################
@@ -340,45 +339,45 @@ CLOBBER.include( Trema.cmockery ) if FileTest.exists?( Trema.cmockery )
340
339
  ################################################################################
341
340
 
342
341
  $standalone_examples = [
343
- "cbench_switch",
344
- "dumper",
345
- "learning_switch",
346
- "list_switches",
347
- "multi_learning_switch",
348
- "packet_in",
349
- "repeater_hub",
350
- "switch_info",
351
- "switch_monitor",
352
- "traffic_monitor",
342
+ 'cbench_switch',
343
+ 'dumper',
344
+ 'learning_switch',
345
+ 'list_switches',
346
+ 'multi_learning_switch',
347
+ 'packet_in',
348
+ 'repeater_hub',
349
+ 'switch_info',
350
+ 'switch_monitor',
351
+ 'traffic_monitor'
353
352
  ]
354
353
 
355
- desc "Build examples."
354
+ desc 'Build examples.'
356
355
  task :examples =>
357
356
  $standalone_examples.map { | each | "examples:#{ each }" } +
358
357
  [
359
- "examples:openflow_switch",
360
- "examples:openflow_message",
361
- "examples:switch_event_config",
362
- "examples:packetin_filter_config"
358
+ 'examples:openflow_switch',
359
+ 'examples:openflow_message',
360
+ 'examples:switch_event_config',
361
+ 'examples:packetin_filter_config'
363
362
  ]
364
363
 
365
364
  $standalone_examples.each do | each |
366
365
  name = "examples:#{ each }"
367
366
 
368
- task name => "libtrema:static"
367
+ task name => 'libtrema:static'
369
368
  PaperHouse::ExecutableTask.new name do | task |
370
369
  task.executable_name = each
371
- task.target_directory = File.join( Trema.objects, "examples", each )
372
- task.sources = [ "src/examples/#{ each }/*.c" ]
373
- task.includes = [ Trema.include, Trema.openflow ]
370
+ task.target_directory = File.join(Trema.objects, 'examples', each)
371
+ task.sources = ["src/examples/#{ each }/*.c"]
372
+ task.includes = [Trema.include, Trema.openflow]
374
373
  task.cflags = CFLAGS
375
374
  task.ldflags = "-L#{ Trema.lib }"
376
375
  task.library_dependencies = [
377
- "trema",
378
- "sqlite3",
379
- "pthread",
380
- "rt",
381
- "dl",
376
+ 'trema',
377
+ 'sqlite3',
378
+ 'pthread',
379
+ 'rt',
380
+ 'dl'
382
381
  ]
383
382
  end
384
383
  end
@@ -389,29 +388,29 @@ end
389
388
  ################################################################################
390
389
 
391
390
  $openflow_switches = [
392
- "hello_switch",
393
- "echo_switch",
391
+ 'hello_switch',
392
+ 'echo_switch'
394
393
  ]
395
394
 
396
- task "examples:openflow_switch" => $openflow_switches.map { | each | "examples:openflow_switch:#{ each }" }
395
+ task 'examples:openflow_switch' => $openflow_switches.map { | each | "examples:openflow_switch:#{ each }" }
397
396
 
398
397
  $openflow_switches.each do | each |
399
398
  name = "examples:openflow_switch:#{ each }"
400
399
 
401
- task name => "libtrema:static"
400
+ task name => 'libtrema:static'
402
401
  PaperHouse::ExecutableTask.new name do | task |
403
402
  task.executable_name = each
404
- task.target_directory = File.join( Trema.objects, "examples", "openflow_switch" )
405
- task.sources = [ "src/examples/openflow_switch/#{ each }.c" ]
406
- task.includes = [ Trema.include, Trema.openflow ]
403
+ task.target_directory = File.join(Trema.objects, 'examples', 'openflow_switch')
404
+ task.sources = ["src/examples/openflow_switch/#{ each }.c"]
405
+ task.includes = [Trema.include, Trema.openflow]
407
406
  task.cflags = CFLAGS
408
407
  task.ldflags = "-L#{ Trema.lib }"
409
408
  task.library_dependencies = [
410
- "trema",
411
- "sqlite3",
412
- "pthread",
413
- "rt",
414
- "dl",
409
+ 'trema',
410
+ 'sqlite3',
411
+ 'pthread',
412
+ 'rt',
413
+ 'dl'
415
414
  ]
416
415
  end
417
416
  end
@@ -422,32 +421,32 @@ end
422
421
  ################################################################################
423
422
 
424
423
  $openflow_messages = [
425
- "echo",
426
- "features_request",
427
- "hello",
428
- "set_config",
429
- "vendor_action",
424
+ 'echo',
425
+ 'features_request',
426
+ 'hello',
427
+ 'set_config',
428
+ 'vendor_action'
430
429
  ]
431
430
 
432
- task "examples:openflow_message" => $openflow_messages.map { | each | "examples:openflow_message:#{ each }" }
431
+ task 'examples:openflow_message' => $openflow_messages.map { | each | "examples:openflow_message:#{ each }" }
433
432
 
434
433
  $openflow_messages.each do | each |
435
434
  name = "examples:openflow_message:#{ each }"
436
435
 
437
- task name => "libtrema:static"
436
+ task name => 'libtrema:static'
438
437
  PaperHouse::ExecutableTask.new name do | task |
439
438
  task.executable_name = each
440
- task.target_directory = File.join( Trema.objects, "examples", "openflow_message" )
441
- task.sources = [ "src/examples/openflow_message/#{ each }.c" ]
442
- task.includes = [ Trema.include, Trema.openflow ]
439
+ task.target_directory = File.join(Trema.objects, 'examples', 'openflow_message')
440
+ task.sources = ["src/examples/openflow_message/#{ each }.c"]
441
+ task.includes = [Trema.include, Trema.openflow]
443
442
  task.cflags = CFLAGS
444
443
  task.ldflags = "-L#{ Trema.lib }"
445
444
  task.library_dependencies = [
446
- "trema",
447
- "sqlite3",
448
- "pthread",
449
- "rt",
450
- "dl",
445
+ 'trema',
446
+ 'sqlite3',
447
+ 'pthread',
448
+ 'rt',
449
+ 'dl'
451
450
  ]
452
451
  end
453
452
  end
@@ -458,31 +457,31 @@ end
458
457
  ###############################################################################
459
458
 
460
459
  $switch_event_config = [
461
- "add_forward_entry",
462
- "delete_forward_entry",
463
- "set_forward_entries",
464
- "dump_forward_entries",
460
+ 'add_forward_entry',
461
+ 'delete_forward_entry',
462
+ 'set_forward_entries',
463
+ 'dump_forward_entries'
465
464
  ]
466
465
 
467
- task "examples:switch_event_config" => $switch_event_config.map { | each | "examples:switch_event_config:#{ each }" }
466
+ task 'examples:switch_event_config' => $switch_event_config.map { | each | "examples:switch_event_config:#{ each }" }
468
467
 
469
468
  $switch_event_config.each do | each |
470
469
  name = "examples:switch_event_config:#{ each }"
471
470
 
472
- task name => "libtrema:static"
471
+ task name => 'libtrema:static'
473
472
  PaperHouse::ExecutableTask.new name do | task |
474
473
  task.executable_name = each
475
- task.target_directory = File.join( Trema.objects, "examples", "switch_event_config" )
476
- task.sources = [ "src/examples/switch_event_config/#{ each }.c" ]
477
- task.includes = [ Trema.include, Trema.openflow ]
474
+ task.target_directory = File.join(Trema.objects, 'examples', 'switch_event_config')
475
+ task.sources = ["src/examples/switch_event_config/#{ each }.c"]
476
+ task.includes = [Trema.include, Trema.openflow]
478
477
  task.cflags = CFLAGS
479
478
  task.ldflags = "-L#{ Trema.lib }"
480
479
  task.library_dependencies = [
481
- "trema",
482
- "sqlite3",
483
- "pthread",
484
- "rt",
485
- "dl",
480
+ 'trema',
481
+ 'sqlite3',
482
+ 'pthread',
483
+ 'rt',
484
+ 'dl'
486
485
  ]
487
486
  end
488
487
  end
@@ -493,32 +492,32 @@ end
493
492
  ################################################################################
494
493
 
495
494
  $packetin_filter_config = [
496
- "add_filter",
497
- "delete_filter",
498
- "delete_filter_strict",
499
- "dump_filter",
500
- "dump_filter_strict",
495
+ 'add_filter',
496
+ 'delete_filter',
497
+ 'delete_filter_strict',
498
+ 'dump_filter',
499
+ 'dump_filter_strict'
501
500
  ]
502
501
 
503
- task "examples:packetin_filter_config" => $packetin_filter_config.map { | each | "examples:packetin_filter_config:#{ each }" }
502
+ task 'examples:packetin_filter_config' => $packetin_filter_config.map { | each | "examples:packetin_filter_config:#{ each }" }
504
503
 
505
504
  $packetin_filter_config.each do | each |
506
505
  name = "examples:packetin_filter_config:#{ each }"
507
506
 
508
- task name => "libtrema:static"
507
+ task name => 'libtrema:static'
509
508
  PaperHouse::ExecutableTask.new name do | task |
510
509
  task.executable_name = each
511
- task.target_directory = File.join( Trema.objects, "examples", "packetin_filter_config" )
512
- task.sources = [ "src/examples/packetin_filter_config/#{ each }.c", "src/examples/packetin_filter_config/utils.c"]
513
- task.includes = [ Trema.include, Trema.openflow ]
510
+ task.target_directory = File.join(Trema.objects, 'examples', 'packetin_filter_config')
511
+ task.sources = ["src/examples/packetin_filter_config/#{ each }.c", 'src/examples/packetin_filter_config/utils.c']
512
+ task.includes = [Trema.include, Trema.openflow]
514
513
  task.cflags = CFLAGS
515
514
  task.ldflags = "-L#{ Trema.lib }"
516
515
  task.library_dependencies = [
517
- "trema",
518
- "sqlite3",
519
- "pthread",
520
- "rt",
521
- "dl",
516
+ 'trema',
517
+ 'sqlite3',
518
+ 'pthread',
519
+ 'rt',
520
+ 'dl'
522
521
  ]
523
522
  end
524
523
  end
@@ -529,77 +528,75 @@ end
529
528
  ################################################################################
530
529
 
531
530
  def cbench_command
532
- File.join Trema.objects, "oflops/bin/cbench"
531
+ File.join Trema.objects, 'oflops/bin/cbench'
533
532
  end
534
533
 
535
534
 
536
535
  def cbench_latency_mode_options
537
- "--port 6653 --switches 1 --loops 10 --delay 1000"
536
+ '--port 6653 --switches 1 --loops 10 --delay 1000'
538
537
  end
539
538
 
540
539
 
541
540
  def cbench_throughput_mode_options
542
- cbench_latency_mode_options + " --throughput"
541
+ cbench_latency_mode_options + ' --throughput'
543
542
  end
544
543
 
545
544
 
546
- def cbench controller, options
547
- begin
548
- sh "#{ controller }"
549
- sh "#{ cbench_command } #{ options }"
550
- ensure
551
- sh "./trema killall"
552
- end
545
+ def cbench(controller, options)
546
+ sh "#{ controller }"
547
+ sh "#{ cbench_command } #{ options }"
548
+ ensure
549
+ sh './trema killall'
553
550
  end
554
551
 
555
552
 
556
553
  def cbench_c_controller
557
- "./trema run ./objects/examples/cbench_switch/cbench_switch -d"
554
+ './trema run ./objects/examples/cbench_switch/cbench_switch -d'
558
555
  end
559
556
 
560
557
 
561
558
  def cbench_ruby_controller
562
- "./trema run src/examples/cbench_switch/cbench-switch.rb -d"
559
+ './trema run src/examples/cbench_switch/cbench-switch.rb -d'
563
560
  end
564
561
 
565
562
 
566
- def run_cbench controller
563
+ def run_cbench(controller)
567
564
  cbench controller, cbench_latency_mode_options
568
565
  cbench controller, cbench_throughput_mode_options
569
566
  end
570
567
 
571
568
 
572
- def cbench_profile options
573
- valgrind = "valgrind --tool=callgrind --trace-children=yes"
569
+ def cbench_profile(options)
570
+ valgrind = 'valgrind --tool=callgrind --trace-children=yes'
574
571
  begin
575
572
  sh "#{ valgrind } #{ cbench_c_controller }"
576
573
  sh "#{ cbench_command } #{ options }"
577
574
  ensure
578
- sh "./trema killall"
575
+ sh './trema killall'
579
576
  end
580
577
  end
581
578
 
582
- CLEAN.include FileList[ "callgrind.out.*" ]
579
+ CLEAN.include FileList[ 'callgrind.out.*']
583
580
 
584
581
 
585
- desc "Run the c cbench switch controller to benchmark"
586
- task "cbench" => "cbench:ruby"
582
+ desc 'Run the c cbench switch controller to benchmark'
583
+ task 'cbench' => 'cbench:ruby'
587
584
 
588
585
 
589
- desc "Run the c cbench switch controller to benchmark"
590
- task "cbench:c" => :default do
586
+ desc 'Run the c cbench switch controller to benchmark'
587
+ task 'cbench:c' => :default do
591
588
  run_cbench cbench_c_controller
592
589
  end
593
590
 
594
591
 
595
- desc "Run the ruby cbench switch controller to benchmark"
596
- task "cbench:ruby" => :default do
592
+ desc 'Run the ruby cbench switch controller to benchmark'
593
+ task 'cbench:ruby' => :default do
597
594
  run_cbench cbench_ruby_controller
598
595
  end
599
596
 
600
597
 
601
- desc "Run cbench with profiling enabled."
602
- task "cbench:profile" => :default do
598
+ desc 'Run cbench with profiling enabled.'
599
+ task 'cbench:profile' => :default do
603
600
  cbench_profile cbench_latency_mode_options
604
601
  cbench_profile cbench_throughput_mode_options
605
602
  end
@@ -610,32 +607,32 @@ end
610
607
  ################################################################################
611
608
 
612
609
  $management_commands = [
613
- "application",
614
- "echo",
615
- "set_logging_level",
616
- "show_stats",
610
+ 'application',
611
+ 'echo',
612
+ 'set_logging_level',
613
+ 'show_stats'
617
614
  ]
618
615
 
619
- desc "Build management commands."
616
+ desc 'Build management commands.'
620
617
  task :management_commands => $management_commands.map { | each | "management:#{ each }" }
621
618
 
622
619
  $management_commands.each do | each |
623
620
  name = "management:#{ each }"
624
621
 
625
- task name => "libtrema:static"
622
+ task name => 'libtrema:static'
626
623
  PaperHouse::ExecutableTask.new name do | task |
627
624
  task.executable_name = each
628
- task.target_directory = File.join( Trema.objects, "management" )
629
- task.sources = [ "src/management/#{ each }.c" ]
630
- task.includes = [ Trema.include, Trema.openflow ]
625
+ task.target_directory = File.join(Trema.objects, 'management')
626
+ task.sources = ["src/management/#{ each }.c"]
627
+ task.includes = [Trema.include, Trema.openflow]
631
628
  task.cflags = CFLAGS
632
629
  task.ldflags = "-L#{ Trema.lib }"
633
630
  task.library_dependencies = [
634
- "trema",
635
- "sqlite3",
636
- "pthread",
637
- "rt",
638
- "dl",
631
+ 'trema',
632
+ 'sqlite3',
633
+ 'pthread',
634
+ 'rt',
635
+ 'dl'
639
636
  ]
640
637
  end
641
638
  end
@@ -645,106 +642,106 @@ end
645
642
  # Tremashark
646
643
  ################################################################################
647
644
 
648
- desc "Build tremashark."
649
- task :tremashark => [ :packet_capture, :syslog_relay, :stdin_relay, :openflow_wireshark_plugin, "libtrema:static" ]
645
+ desc 'Build tremashark.'
646
+ task :tremashark => [:packet_capture, :syslog_relay, :stdin_relay, :openflow_wireshark_plugin, 'libtrema:static']
650
647
 
651
648
  PaperHouse::ExecutableTask.new :tremashark do | task |
652
- task.executable_name = File.basename( Trema::Executables.tremashark )
653
- task.target_directory = File.dirname( Trema::Executables.tremashark )
649
+ task.executable_name = File.basename(Trema::Executables.tremashark)
650
+ task.target_directory = File.dirname(Trema::Executables.tremashark)
654
651
  task.sources = [
655
- "src/tremashark/pcap_queue.c",
656
- "src/tremashark/queue.c",
657
- "src/tremashark/tremashark.c",
652
+ 'src/tremashark/pcap_queue.c',
653
+ 'src/tremashark/queue.c',
654
+ 'src/tremashark/tremashark.c'
658
655
  ]
659
- task.includes = [ Trema.include, Trema.openflow ]
656
+ task.includes = [Trema.include, Trema.openflow]
660
657
  task.cflags = CFLAGS
661
658
  task.ldflags = "-L#{ Trema.lib }"
662
659
  task.library_dependencies = [
663
- "trema",
664
- "sqlite3",
665
- "pthread",
666
- "rt",
667
- "dl",
668
- "pcap"
660
+ 'trema',
661
+ 'sqlite3',
662
+ 'pthread',
663
+ 'rt',
664
+ 'dl',
665
+ 'pcap'
669
666
  ]
670
667
  end
671
668
 
672
669
 
673
- task :packet_capture => "libtrema:static"
670
+ task :packet_capture => 'libtrema:static'
674
671
 
675
672
  PaperHouse::ExecutableTask.new :packet_capture do | task |
676
- task.executable_name = File.basename( Trema::Executables.packet_capture )
677
- task.target_directory = File.dirname( Trema::Executables.packet_capture )
673
+ task.executable_name = File.basename(Trema::Executables.packet_capture)
674
+ task.target_directory = File.dirname(Trema::Executables.packet_capture)
678
675
  task.sources = [
679
- "src/tremashark/packet_capture.c",
680
- "src/tremashark/queue.c",
676
+ 'src/tremashark/packet_capture.c',
677
+ 'src/tremashark/queue.c'
681
678
  ]
682
- task.includes = [ Trema.include, Trema.openflow ]
679
+ task.includes = [Trema.include, Trema.openflow]
683
680
  task.cflags = CFLAGS
684
681
  task.ldflags = "-L#{ Trema.lib }"
685
682
  task.library_dependencies = [
686
- "trema",
687
- "sqlite3",
688
- "pthread",
689
- "rt",
690
- "dl",
691
- "pcap"
683
+ 'trema',
684
+ 'sqlite3',
685
+ 'pthread',
686
+ 'rt',
687
+ 'dl',
688
+ 'pcap'
692
689
  ]
693
690
  end
694
691
 
695
692
 
696
- task :syslog_relay => "libtrema:static"
693
+ task :syslog_relay => 'libtrema:static'
697
694
 
698
695
  PaperHouse::ExecutableTask.new :syslog_relay do | task |
699
- task.executable_name = File.basename( Trema::Executables.syslog_relay )
700
- task.target_directory = File.dirname( Trema::Executables.syslog_relay )
701
- task.sources = [ "src/tremashark/syslog_relay.c" ]
702
- task.includes = [ Trema.include, Trema.openflow ]
696
+ task.executable_name = File.basename(Trema::Executables.syslog_relay)
697
+ task.target_directory = File.dirname(Trema::Executables.syslog_relay)
698
+ task.sources = ['src/tremashark/syslog_relay.c']
699
+ task.includes = [Trema.include, Trema.openflow]
703
700
  task.cflags = CFLAGS
704
701
  task.ldflags = "-L#{ Trema.lib }"
705
702
  task.library_dependencies = [
706
- "trema",
707
- "sqlite3",
708
- "pthread",
709
- "rt",
710
- "dl",
711
- "pcap"
703
+ 'trema',
704
+ 'sqlite3',
705
+ 'pthread',
706
+ 'rt',
707
+ 'dl',
708
+ 'pcap'
712
709
  ]
713
710
  end
714
711
 
715
712
 
716
- task :stdin_relay => "libtrema:static"
713
+ task :stdin_relay => 'libtrema:static'
717
714
 
718
715
  PaperHouse::ExecutableTask.new :stdin_relay do | task |
719
- task.executable_name = File.basename( Trema::Executables.stdin_relay )
720
- task.target_directory = File.dirname( Trema::Executables.stdin_relay )
721
- task.sources = [ "src/tremashark/stdin_relay.c" ]
722
- task.includes = [ Trema.include, Trema.openflow ]
716
+ task.executable_name = File.basename(Trema::Executables.stdin_relay)
717
+ task.target_directory = File.dirname(Trema::Executables.stdin_relay)
718
+ task.sources = ['src/tremashark/stdin_relay.c']
719
+ task.includes = [Trema.include, Trema.openflow]
723
720
  task.cflags = CFLAGS
724
721
  task.ldflags = "-L#{ Trema.lib }"
725
722
  task.library_dependencies = [
726
- "trema",
727
- "sqlite3",
728
- "pthread",
729
- "rt",
730
- "dl",
731
- "pcap"
723
+ 'trema',
724
+ 'sqlite3',
725
+ 'pthread',
726
+ 'rt',
727
+ 'dl',
728
+ 'pcap'
732
729
  ]
733
730
  end
734
731
 
735
732
 
736
- $packet_openflow_so = File.join( Trema.vendor_openflow_git, "utilities", "wireshark_dissectors", "openflow", "packet-openflow.so" )
737
- $wireshark_plugins_dir = File.join( File.expand_path( "~" ), ".wireshark", "plugins" )
738
- $wireshark_plugin = File.join( $wireshark_plugins_dir, File.basename( $packet_openflow_so ) )
733
+ $packet_openflow_so = File.join(Trema.vendor_openflow_git, 'utilities', 'wireshark_dissectors', 'openflow', 'packet-openflow.so')
734
+ $wireshark_plugins_dir = File.join(File.expand_path('~'), '.wireshark', 'plugins')
735
+ $wireshark_plugin = File.join($wireshark_plugins_dir, File.basename($packet_openflow_so))
739
736
 
740
737
  file $packet_openflow_so do
741
738
  sh "tar xzf #{ Trema.vendor_openflow_git }.tar.gz -C #{ Trema.vendor }"
742
- cd File.dirname( $packet_openflow_so ) do
743
- sh "make"
739
+ cd File.dirname($packet_openflow_so) do
740
+ sh 'make'
744
741
  end
745
742
  end
746
743
 
747
- file $wireshark_plugin => [ $packet_openflow_so, $wireshark_plugins_dir ] do
744
+ file $wireshark_plugin => [$packet_openflow_so, $wireshark_plugins_dir] do
748
745
  cp $packet_openflow_so, $wireshark_plugins_dir
749
746
  end
750
747
 
@@ -752,7 +749,7 @@ directory $wireshark_plugins_dir
752
749
 
753
750
  task :openflow_wireshark_plugin => $wireshark_plugin
754
751
 
755
- CLEAN.include( Trema.vendor_openflow_git ) if FileTest.exists?( Trema.vendor_openflow_git )
752
+ CLEAN.include(Trema.vendor_openflow_git) if FileTest.exists?(Trema.vendor_openflow_git)
756
753
 
757
754
 
758
755
  ################################################################################
@@ -760,7 +757,7 @@ CLEAN.include( Trema.vendor_openflow_git ) if FileTest.exists?( Trema.vendor_ope
760
757
  ################################################################################
761
758
 
762
759
  begin
763
- require "bundler/gem_tasks"
760
+ require 'bundler/gem_tasks'
764
761
  rescue LoadError
765
762
  $stderr.puts $!.to_s
766
763
  end
@@ -771,7 +768,7 @@ end
771
768
  ################################################################################
772
769
 
773
770
  task :relish do
774
- sh "relish push trema/trema"
771
+ sh 'relish push trema/trema'
775
772
  end
776
773
 
777
774
 
@@ -781,28 +778,28 @@ end
781
778
 
782
779
  def libtrema_unit_tests
783
780
  {
784
- :byteorder_test => [ :log, :utility, :wrapper, :trema_wrapper ],
785
- :daemon_test => [ :log, :utility, :wrapper, :trema_wrapper ],
786
- :ether_test => [ :buffer, :log, :utility, :wrapper, :trema_wrapper ],
781
+ :byteorder_test => [:log, :utility, :wrapper, :trema_wrapper],
782
+ :daemon_test => [:log, :utility, :wrapper, :trema_wrapper],
783
+ :ether_test => [:buffer, :log, :utility, :wrapper, :trema_wrapper],
787
784
  :external_callback_test => [],
788
- :messenger_test => [ :doubly_linked_list, :hash_table, :event_handler, :linked_list, :utility, :wrapper, :timer, :log, :trema_wrapper ],
789
- :openflow_application_interface_test => [ :buffer, :byteorder, :hash_table, :doubly_linked_list, :linked_list, :log, :openflow_message, :packet_info, :stat, :trema_wrapper, :utility, :wrapper ],
790
- :openflow_message_test => [ :buffer, :byteorder, :linked_list, :log, :packet_info, :utility, :wrapper, :trema_wrapper ],
791
- :packet_info_test => [ :buffer, :log, :utility, :wrapper, :trema_wrapper ],
792
- :stat_test => [ :hash_table, :doubly_linked_list, :log, :utility, :wrapper, :trema_wrapper ],
793
- :timer_test => [ :log, :utility, :wrapper, :doubly_linked_list, :trema_wrapper ],
794
- :trema_test => [ :utility, :log, :wrapper, :doubly_linked_list, :trema_private, :trema_wrapper ],
785
+ :messenger_test => [:doubly_linked_list, :hash_table, :event_handler, :linked_list, :utility, :wrapper, :timer, :log, :trema_wrapper],
786
+ :openflow_application_interface_test => [:buffer, :byteorder, :hash_table, :doubly_linked_list, :linked_list, :log, :openflow_message, :packet_info, :stat, :trema_wrapper, :utility, :wrapper],
787
+ :openflow_message_test => [:buffer, :byteorder, :linked_list, :log, :packet_info, :utility, :wrapper, :trema_wrapper],
788
+ :packet_info_test => [:buffer, :log, :utility, :wrapper, :trema_wrapper],
789
+ :stat_test => [:hash_table, :doubly_linked_list, :log, :utility, :wrapper, :trema_wrapper],
790
+ :timer_test => [:log, :utility, :wrapper, :doubly_linked_list, :trema_wrapper],
791
+ :trema_test => [:utility, :log, :wrapper, :doubly_linked_list, :trema_private, :trema_wrapper]
795
792
  }
796
793
  end
797
794
 
798
795
 
799
- def test_c_files test
800
- names = [ test.to_s.gsub( /_test$/, "" ) ] + libtrema_unit_tests[ test ]
796
+ def test_c_files(test)
797
+ names = [test.to_s.gsub(/_test$/, '')] + libtrema_unit_tests[ test]
801
798
  names.collect do | each |
802
799
  if each == :buffer
803
- [ "src/lib/buffer.c", "unittests/buffer_stubs.c" ]
800
+ ['src/lib/buffer.c', 'unittests/buffer_stubs.c']
804
801
  elsif each == :wrapper
805
- [ "src/lib/wrapper.c", "unittests/wrapper_stubs.c" ]
802
+ ['src/lib/wrapper.c', 'unittests/wrapper_stubs.c']
806
803
  else
807
804
  "src/lib/#{ each }.c"
808
805
  end
@@ -810,28 +807,28 @@ def test_c_files test
810
807
  end
811
808
 
812
809
 
813
- directory "objects/unittests"
810
+ directory 'objects/unittests'
814
811
 
815
812
  task :build_old_unittests => libtrema_unit_tests.keys.map { | each | "unittests:#{ each }" }
816
813
 
817
814
  libtrema_unit_tests.keys.each do | each |
818
815
  PaperHouse::ExecutableTask.new "unittests:#{ each }" do | task |
819
816
  name = "unittests:#{ each }"
820
- task name => [ "vendor:cmockery", "vendor:openflow", "objects/unittests" ]
817
+ task name => ['vendor:cmockery', 'vendor:openflow', 'objects/unittests']
821
818
 
822
819
  task.executable_name = each.to_s
823
- task.target_directory = File.join( Trema.home, "unittests/objects" )
824
- task.sources = test_c_files( each ) + [ "unittests/lib/#{ each }.c" ]
825
- task.includes = [ Trema.include, Trema.openflow, File.dirname( Trema.cmockery_h ), "unittests" ]
826
- task.cflags = [ "-DUNIT_TESTING", "--coverage", CFLAGS ]
827
- task.ldflags = "-DUNIT_TESTING -L#{ File.dirname Trema.libcmockery_a } --coverage --static"
820
+ task.target_directory = File.join(Trema.home, 'unittests/objects')
821
+ task.sources = test_c_files(each) + ["unittests/lib/#{ each }.c"]
822
+ task.includes = [Trema.include, Trema.openflow, File.dirname(Trema.cmockery_h), 'unittests']
823
+ task.cflags = ['-DUNIT_TESTING', '--coverage', CFLAGS]
824
+ task.ldflags = "-DUNIT_TESTING -L#{ File.dirname Trema.libcmockery_a } --coverage"
828
825
  task.library_dependencies = [
829
- "cmockery",
830
- "sqlite3",
831
- "pthread",
832
- "rt",
833
- "dl",
834
- "pcap"
826
+ 'cmockery',
827
+ 'sqlite3',
828
+ 'pthread',
829
+ 'rt',
830
+ 'dl',
831
+ 'pcap'
835
832
  ]
836
833
  end
837
834
  end
@@ -839,54 +836,54 @@ end
839
836
 
840
837
  # new unittest
841
838
  $tests = [
842
- "objects/unittests/buffer_test",
843
- "objects/unittests/doubly_linked_list_test",
844
- "objects/unittests/ether_test",
845
- "objects/unittests/event_forward_interface_test",
846
- "objects/unittests/hash_table_test",
847
- "objects/unittests/linked_list_test",
848
- "objects/unittests/log_test",
849
- "objects/unittests/packetin_filter_interface_test",
850
- "objects/unittests/packet_info_test",
851
- "objects/unittests/packet_parser_test",
852
- "objects/unittests/persistent_storage_test",
853
- "objects/unittests/trema_private_test",
854
- "objects/unittests/utility_test",
855
- "objects/unittests/wrapper_test",
856
- "objects/unittests/match_table_test",
857
- "objects/unittests/message_queue_test",
858
- "objects/unittests/management_interface_test",
859
- "objects/unittests/management_service_interface_test",
839
+ 'objects/unittests/buffer_test',
840
+ 'objects/unittests/doubly_linked_list_test',
841
+ 'objects/unittests/ether_test',
842
+ 'objects/unittests/event_forward_interface_test',
843
+ 'objects/unittests/hash_table_test',
844
+ 'objects/unittests/linked_list_test',
845
+ 'objects/unittests/log_test',
846
+ 'objects/unittests/packetin_filter_interface_test',
847
+ 'objects/unittests/packet_info_test',
848
+ 'objects/unittests/packet_parser_test',
849
+ 'objects/unittests/persistent_storage_test',
850
+ 'objects/unittests/trema_private_test',
851
+ 'objects/unittests/utility_test',
852
+ 'objects/unittests/wrapper_test',
853
+ 'objects/unittests/match_table_test',
854
+ 'objects/unittests/message_queue_test',
855
+ 'objects/unittests/management_interface_test',
856
+ 'objects/unittests/management_service_interface_test'
860
857
  ]
861
858
 
862
- task :build_unittests => $tests.map { | each | "unittests:" + File.basename( each ) }
859
+ task :build_unittests => $tests.map { | each | 'unittests:' + File.basename(each) }
863
860
 
864
861
  $tests.each do | _each |
865
- each = File.basename( _each )
862
+ each = File.basename(_each)
866
863
 
867
- task "unittests:#{ each }" => [ "libtrema:gcov", "vendor:cmockery" ]
864
+ task "unittests:#{ each }" => ['libtrema:gcov', 'vendor:cmockery']
868
865
  PaperHouse::ExecutableTask.new "unittests:#{ each }" do | task |
869
866
  task.executable_name = each.to_s
870
- task.target_directory = File.join( Trema.home, "unittests/objects" )
871
- task.sources = [ "unittests/lib/#{ each }.c", "unittests/cmockery_trema.c" ]
872
- task.includes = [ Trema.include, Trema.openflow, File.dirname( Trema.cmockery_h ), "unittests" ]
873
- task.cflags = [ "--coverage", CFLAGS ]
874
- task.ldflags = "-L#{ File.dirname Trema.libcmockery_a } -Lobjects/unittests --coverage --static"
867
+ task.target_directory = File.join(Trema.home, 'unittests/objects')
868
+ task.sources = ["unittests/lib/#{ each }.c", 'unittests/cmockery_trema.c']
869
+ task.includes = [Trema.include, Trema.openflow, File.dirname(Trema.cmockery_h), 'unittests']
870
+ task.cflags = ['--coverage', CFLAGS]
871
+ task.ldflags = "-L#{ File.dirname Trema.libcmockery_a } -Lobjects/unittests --coverage"
875
872
  task.library_dependencies = [
876
- "trema",
877
- "cmockery",
878
- "sqlite3",
879
- "pthread",
880
- "rt",
881
- "dl",
873
+ 'trema',
874
+ 'cmockery',
875
+ 'sqlite3',
876
+ 'pthread',
877
+ 'rt',
878
+ 'dl'
882
879
  ]
883
880
  end
884
881
  end
885
882
 
886
883
 
887
- desc "Run unittests"
888
- task :unittests => [ :build_old_unittests, :build_unittests ] do
889
- Dir.glob( "unittests/objects/*_test" ).each do | each |
884
+ desc 'Run unittests'
885
+ task :unittests => [:build_old_unittests, :build_unittests] do
886
+ Dir.glob('unittests/objects/*_test').each do | each |
890
887
  puts "Running #{ each }..."
891
888
  sh each
892
889
  end
@@ -897,41 +894,41 @@ end
897
894
  # Tests
898
895
  ################################################################################
899
896
 
900
- task :travis => [ :clobber, :build_trema, "spec:travis" ]
897
+ task :travis => [:clobber, :build_trema, 'spec:travis']
901
898
 
902
899
 
903
900
  begin
904
- require "rspec/core"
905
- require "rspec/core/rake_task"
901
+ require 'rspec/core'
902
+ require 'rspec/core/rake_task'
906
903
 
907
904
  task :spec => :build_trema
908
905
  RSpec::Core::RakeTask.new do | task |
909
906
  task.verbose = $trace
910
- task.pattern = FileList[ "spec/**/*_spec.rb" ]
911
- task.rspec_opts = "--format documentation --color"
907
+ task.pattern = FileList[ 'spec/**/*_spec.rb']
908
+ task.rspec_opts = '--format documentation --color'
912
909
  end
913
910
 
914
- task "spec:actions" => :build_trema
915
- RSpec::Core::RakeTask.new( "spec:actions" ) do | task |
911
+ task 'spec:actions' => :build_trema
912
+ RSpec::Core::RakeTask.new('spec:actions') do | task |
916
913
  task.verbose = $trace
917
- task.pattern = FileList[ "spec/**/*_spec.rb" ]
918
- task.rspec_opts = "--tag type:actions --format documentation --color"
914
+ task.pattern = FileList[ 'spec/**/*_spec.rb']
915
+ task.rspec_opts = '--tag type:actions --format documentation --color'
919
916
  end
920
917
 
921
918
 
922
- task "spec:travis" => :build_trema
923
- RSpec::Core::RakeTask.new( "spec:travis" ) do | task |
919
+ task 'spec:travis' => :build_trema
920
+ RSpec::Core::RakeTask.new('spec:travis') do | task |
924
921
  task.verbose = $trace
925
- task.pattern = FileList[ "spec/trema/hello_spec.rb", "spec/trema/echo-*_spec.rb" ]
926
- task.rspec_opts = "--tag ~sudo --format documentation --color"
922
+ task.pattern = FileList[ 'spec/trema/hello_spec.rb', 'spec/trema/echo-*_spec.rb']
923
+ task.rspec_opts = '--tag ~sudo --format documentation --color'
927
924
  end
928
925
 
929
926
 
930
927
  task :rcov => :build_trema
931
- RSpec::Core::RakeTask.new( :rcov ) do | spec |
932
- spec.pattern = "spec/**/*_spec.rb"
928
+ RSpec::Core::RakeTask.new(:rcov) do | spec |
929
+ spec.pattern = 'spec/**/*_spec.rb'
933
930
  spec.rcov = true
934
- spec.rcov_opts = [ "-x", "gems" ]
931
+ spec.rcov_opts = ['-x', 'gems']
935
932
  end
936
933
  rescue LoadError
937
934
  $stderr.puts $!.to_s
@@ -939,10 +936,16 @@ end
939
936
 
940
937
 
941
938
  begin
942
- require "cucumber/rake/task"
939
+ require 'cucumber/rake/task'
940
+
943
941
  task :features => :build_trema
944
- Cucumber::Rake::Task.new( :features ) do | t |
945
- t.cucumber_opts = "features --tags ~@wip"
942
+ Cucumber::Rake::Task.new(:features) do | t |
943
+ t.cucumber_opts = '--tags @critical --tags ~@wip'
944
+ end
945
+
946
+ task 'features:all' => :build_trema
947
+ Cucumber::Rake::Task.new('features:all') do | t |
948
+ t.cucumber_opts = '--tags ~@wip'
946
949
  end
947
950
  rescue LoadError
948
951
  $stderr.puts $!.to_s
@@ -953,21 +956,21 @@ end
953
956
  # Code Quality Tasks
954
957
  ################################################################################
955
958
 
956
- $ruby_sources = FileList[ "ruby/**/*.rb", "src/**/*.rb" ]
959
+ $ruby_sources = FileList[ 'ruby/**/*.rb', 'src/**/*.rb']
957
960
 
958
961
 
959
- desc "Enforce Ruby code quality with static analysis of code"
960
- task :quality => [ :reek, :flog, :flay ]
962
+ desc 'Enforce Ruby code quality with static analysis of code'
963
+ task :quality => [:reek, :flog, :flay]
961
964
 
962
965
 
963
966
  begin
964
- require "reek/rake/task"
967
+ require 'reek/rake/task'
965
968
 
966
969
  Reek::Rake::Task.new do | t |
967
970
  t.fail_on_error = false
968
971
  t.verbose = false
969
- t.ruby_opts = [ "-rubygems" ]
970
- t.reek_opts = "--quiet"
972
+ t.ruby_opts = ['-rubygems']
973
+ t.reek_opts = '--quiet'
971
974
  t.source_files = $ruby_sources
972
975
  end
973
976
  rescue LoadError
@@ -976,21 +979,21 @@ end
976
979
 
977
980
 
978
981
  begin
979
- require "flog"
982
+ require 'flog'
980
983
 
981
- desc "Analyze for code complexity"
984
+ desc 'Analyze for code complexity'
982
985
  task :flog do
983
- flog = Flog.new( :continue => true )
984
- flog.flog *$ruby_sources
986
+ flog = Flog.new(:continue => true)
987
+ flog.flog(*$ruby_sources)
985
988
  threshold = 10
986
989
 
987
990
  bad_methods = flog.totals.select do | name, score |
988
- ( not ( /##{flog.no_method}$/=~ name ) ) and score > threshold
991
+ ( not ( /##{flog.no_method}$/ =~ name)) && score > threshold
989
992
  end
990
993
  bad_methods.sort do | a, b |
991
- a[ 1 ] <=> b[ 1 ]
994
+ a[ 1] <=> b[ 1]
992
995
  end.reverse.each do | name, score |
993
- puts "%8.1f: %s" % [ score, name ]
996
+ puts '%8.1f: %s' % [score, name]
994
997
  end
995
998
  unless bad_methods.empty?
996
999
  $stderr.puts "#{ bad_methods.size } methods have a flog complexity > #{ threshold }"
@@ -1002,12 +1005,12 @@ end
1002
1005
 
1003
1006
 
1004
1007
  begin
1005
- require "flay"
1006
- require "flay_task"
1008
+ require 'flay'
1009
+ require 'flay_task'
1007
1010
 
1008
1011
  FlayTask.new do | t |
1009
1012
  t.dirs = $ruby_sources.collect do | each |
1010
- each[ /[^\/]+/ ]
1013
+ each[ /[^\/]+/]
1011
1014
  end.uniq
1012
1015
  t.threshold = 0
1013
1016
  t.verbose = true
@@ -1017,17 +1020,21 @@ rescue LoadError
1017
1020
  end
1018
1021
 
1019
1022
 
1023
+ task :travis => :rubocop
1024
+ task :quality => :rubocop
1025
+
1026
+
1020
1027
  ################################################################################
1021
1028
  # YARD
1022
1029
  ################################################################################
1023
1030
 
1024
1031
  begin
1025
- require "yard"
1032
+ require 'yard'
1026
1033
 
1027
1034
  YARD::Rake::YardocTask.new do | t |
1028
- t.files = [ "ruby/trema/**/*.c", "ruby/trema/**/*.rb" ]
1029
- t.options = [ "--no-private" ]
1030
- t.options << "--debug" << "--verbose" if $trace
1035
+ t.files = ['ruby/trema/**/*.c', 'ruby/trema/**/*.rb']
1036
+ t.options = ['--no-private']
1037
+ t.options << '--debug' << '--verbose' if $trace
1031
1038
  end
1032
1039
  rescue LoadError
1033
1040
  $stderr.puts $!.to_s
@@ -1038,9 +1045,9 @@ end
1038
1045
  # TODO, FIXME etc.
1039
1046
  ################################################################################
1040
1047
 
1041
- desc "Print list of notes."
1048
+ desc 'Print list of notes.'
1042
1049
  task :notes do
1043
- keywords = [ "TODO", "FIXME", "XXX" ]
1050
+ keywords = ['TODO', 'FIXME', 'XXX']
1044
1051
  keywords.each do | each |
1045
1052
  system "find src unittests -name '*.c' | xargs grep -n #{ each }"
1046
1053
  system "find ruby spec features -name '*.rb' | xargs grep -n #{ each }"
@@ -1048,8 +1055,4 @@ task :notes do
1048
1055
  end
1049
1056
 
1050
1057
 
1051
- ### Local variables:
1052
- ### mode: Ruby
1053
- ### coding: utf-8-unix
1054
- ### indent-tabs-mode: nil
1055
- ### End:
1058
+ Dir.glob('tasks/*.rake').each { |each| import each }