trema 0.3.21 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rantfile DELETED
@@ -1,739 +0,0 @@
1
- #
2
- # Copyright (C) 2008-2013 NEC Corporation
3
- #
4
- # This program is free software; you can redistribute it and/or modify
5
- # it under the terms of the GNU General Public License, version 2, as
6
- # published by the Free Software Foundation.
7
- #
8
- # This program is distributed in the hope that it will be useful,
9
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- # GNU General Public License for more details.
12
- #
13
- # You should have received a copy of the GNU General Public License along
14
- # with this program; if not, write to the Free Software Foundation, Inc.,
15
- # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
- #
17
-
18
-
19
- $LOAD_PATH.unshift File.expand_path( File.join File.dirname( __FILE__ ), "ruby" )
20
- $LOAD_PATH.unshift File.expand_path( File.join File.dirname( __FILE__ ), "vendor", "ruby-ifconfig-1.2", "lib" )
21
-
22
-
23
- require "trema/executables"
24
- require "trema/path"
25
- require "trema/dsl/parser"
26
- require "trema/version"
27
-
28
- import "c/dependencies"
29
- import "directedrule"
30
-
31
-
32
- ################################################################################
33
- # Main tasks
34
- ################################################################################
35
-
36
- desc "Build trema."
37
- task :default => [
38
- "libtrema:static",
39
- :management_commands,
40
- :rubylib,
41
- :switch_manager,
42
- :switch_daemon,
43
- :packetin_filter,
44
- :tremashark,
45
- :packet_capture,
46
- :syslog_relay,
47
- :stdin_relay,
48
- :vendor,
49
- :examples
50
- ]
51
-
52
-
53
- task :examples => [
54
- "examples:cbench_switch",
55
- "examples:dumper",
56
- "examples:learning_switch",
57
- "examples:list_switches",
58
- "examples:multi_learning_switch",
59
- "examples:openflow_switch",
60
- "examples:openflow_message",
61
- "examples:packet_in",
62
- "examples:repeater_hub",
63
- "examples:switch_event_config",
64
- "examples:packetin_filter_config",
65
- "examples:switch_info",
66
- "examples:switch_monitor",
67
- "examples:traffic_monitor",
68
- ]
69
-
70
-
71
- task :management_commands => [
72
- "management_commands:application",
73
- "management_commands:echo",
74
- "management_commands:set_logging_level",
75
- "management_commands:show_stats",
76
- ]
77
-
78
-
79
- import "clean"
80
-
81
- desc "Cleanup generated files."
82
- gen Clean
83
-
84
- var[ :clean ] << Trema.objects
85
- var[ :clean ] << File.join( Trema.home, "objects/unittests" )
86
- var[ :clean ] << File.join( Trema.home, "unittests/objects" )
87
- var[ :clean ] << Trema::DSL::Context::PATH
88
-
89
-
90
- desc "Cleanup everything."
91
- task :distclean => :clean
92
-
93
-
94
- desc "Generate build.rb."
95
- task :buildrb do
96
- sys "rant-import --force --imports c/dependencies,directedrule,clean,sys/tgz build.rb"
97
- sys "chmod +x build.rb"
98
- end
99
-
100
-
101
- ################################################################################
102
- # Helpers
103
- ################################################################################
104
-
105
- def objects path
106
- File.join Trema.objects, path
107
- end
108
-
109
-
110
- def dependency name
111
- file = ".#{ name }.dependency"
112
- var[ :clean ] << file
113
- ".#{ name }.dependency"
114
- end
115
-
116
-
117
- ################################################################################
118
- # !!!!!! DO NOT MODIFY !!!!!!
119
- ################################################################################
120
-
121
- var :CFLAGS => "-g -std=gnu99 -D_GNU_SOURCE -fno-strict-aliasing -Werror -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wfloat-equal -Wpointer-arith"
122
-
123
-
124
- ################################################################################
125
- # Run cbench benchmarks.
126
- ################################################################################
127
-
128
- desc "Run the c cbench switch controller to benchmark"
129
- task :cbench => "cbench:ruby"
130
-
131
-
132
- desc "Run the ruby cbench switch controller to benchmark"
133
- task "cbench:ruby" do
134
- sys "rake cbench:ruby"
135
- end
136
-
137
-
138
- desc "Run the c cbench switch controller to benchmark"
139
- task "cbench:c" do
140
- sys "rake cbench:c"
141
- end
142
-
143
-
144
- desc "Run cbench with profiling enabled."
145
- task "cbench:profile" do
146
- sys "rake cbench:profile"
147
- end
148
-
149
-
150
- ################################################################################
151
- # Build vendor/*
152
- ################################################################################
153
-
154
- import "sys/tgz"
155
-
156
-
157
- task :vendor do
158
- sys "rake vendor"
159
- end
160
-
161
- task :distclean => :clobber
162
-
163
- task :clobber do
164
- sys "rake clobber"
165
- end
166
-
167
-
168
- #
169
- # OpenFlow reference implementation
170
- #
171
-
172
- gen Directory, Trema.objects
173
-
174
- task "vendor:openflow" => Trema.openflow_h
175
- file Trema.openflow_h do
176
- sys "rake vendor:openflow"
177
- end
178
-
179
-
180
- #
181
- # Use the Stanford openflow reference software to compile and copy the wireshark
182
- # plugin to enable viewing of openflow messages.
183
- # The plugin would be compiled and copied to your home directory
184
- # (.wireshark/plugins) if it is found, otherwise it is left for you to copy
185
- # from openflow.git/utilities/wireshark_dissectors/openflow directory
186
- #
187
- desc "Build openflow wireshark plugin"
188
- task :openflow_wireshark_plugin => Trema.vendor_openflow_git
189
- file Trema.vendor_openflow_git do | t |
190
- sys.unpack_tgz "#{ t.name }.tar.gz", :in => Trema.vendor
191
- subpath = "utilities/wireshark_dissectors/openflow"
192
- sys.cd "#{ Trema.vendor_openflow_git }/#{ subpath }" do
193
- sys "make"
194
- plugin_path = "#{ File.expand_path(" ~ ") }/.wireshark/plugins"
195
- sys.cp "packet-openflow.so", plugin_path if File.directory?( plugin_path )
196
- end
197
- end
198
-
199
-
200
- task "openflow_wireshark_plugin:clean" => "openflow_wireshark_plugin:distclean"
201
- task "openflow_wireshark_plugin:distclean" do
202
- sys.rm_rf Trema.vendor_openflow_git
203
- end
204
-
205
-
206
- #
207
- # cmockery
208
- #
209
-
210
- task "vendor:cmockery" => Trema.libcmockery_a
211
- file Trema.libcmockery_a do
212
- sys "rake vendor:cmockery"
213
- end
214
-
215
-
216
- ################################################################################
217
- # Build libtrema.{a,so}
218
- ################################################################################
219
-
220
- libtrema = File.join( Trema.lib, "libtrema.a" )
221
- libtrema_so = File.join( Trema.lib, "libtrema.so." ) + Trema::VERSION
222
- libtrema_gcov = File.join( "#{ Trema.home }/objects/unittests", "libtrema.a" )
223
-
224
- desc "Build trema library (static library)."
225
- task "libtrema:static" => libtrema
226
- file libtrema do | t |
227
- sys "rake libtrema:static"
228
- end
229
-
230
- desc "Build trema library (shared library)."
231
- task "libtrema:shared" => libtrema_so
232
- file libtrema_so do | t |
233
- sys "rake libtrema:shared"
234
- end
235
-
236
- desc "Build trema library (coverage)."
237
- task "libtrema:gcov" => libtrema_gcov
238
- file libtrema_gcov do | t |
239
- sys "rake libtrema:gcov"
240
- end
241
-
242
-
243
- ################################################################################
244
- # Build trema.so (ruby library)
245
- ################################################################################
246
-
247
- desc "Build ruby library."
248
- task :rubylib do
249
- sys "rake rubylib"
250
- end
251
-
252
-
253
- ################################################################################
254
- # Build switch manager
255
- ################################################################################
256
-
257
- desc "Build switch manager."
258
- task :switch_manager do
259
- sys "rake switch_manager"
260
- end
261
-
262
-
263
- desc "Build switch."
264
- task :switch_daemon do
265
- sys "rake switch_daemon"
266
- end
267
-
268
-
269
- ################################################################################
270
- # Build packetin filter
271
- ################################################################################
272
-
273
- gen C::Dependencies, dependency( "packetin_filter" ),
274
- :search => [ "src/packetin_filter", Trema.include ], :sources => sys[ "src/packetin_filter/*.{c,h}" ]
275
-
276
- gen Action do
277
- source dependency( "packetin_filter" )
278
- end
279
-
280
-
281
- gen Directory, objects( "packetin_filter" )
282
-
283
- packetin_filter_objects = gen DirectedRule, objects( "packetin_filter" ) => [ "src/packetin_filter" ], :o => :c do | t |
284
- sys "gcc -I#{ Trema.include } -I#{ Trema.openflow } #{ var :CFLAGS } -c -o #{ t.name } #{ t.source }"
285
- end
286
-
287
- desc "Build packetin filter."
288
- task :packetin_filter => Trema::Executables.packetin_filter
289
- file Trema::Executables.packetin_filter => packetin_filter_objects.candidates + [ libtrema ] do | t |
290
- sys "gcc -L#{ Trema.lib } -o #{ t.name } #{ sys.sp t.prerequisites } -ltrema -lpthread -lsqlite3 -ldl -lrt"
291
- end
292
-
293
-
294
- ################################################################################
295
- # tremashark
296
- ################################################################################
297
-
298
- tremashark_objects_dir = objects( "tremashark" )
299
-
300
- gen C::Dependencies, dependency( "tremashark" ),
301
- :search => [ "src/tremashark", Trema.include ], :sources => sys[ "src/tremashark/*.{c,h}" ]
302
-
303
- gen Action do
304
- source dependency( "tremashark" )
305
- end
306
-
307
-
308
- gen Directory, tremashark_objects_dir
309
-
310
- gen DirectedRule, tremashark_objects_dir => [ "src/tremashark" ], :o => :c do | t |
311
- sys "gcc -I#{ Trema.include } -I#{ Trema.openflow } #{ var :CFLAGS } -c -o #{ t.name } #{ t.source }"
312
- end
313
-
314
-
315
- tremashark_objects = [
316
- "pcap_queue.o",
317
- "queue.o",
318
- "tremashark.o",
319
- ].collect do | each |
320
- File.join tremashark_objects_dir, each
321
- end
322
-
323
- desc "Build tremashark."
324
- task :tremashark => Trema::Executables.tremashark
325
- file Trema::Executables.tremashark => tremashark_objects + [ libtrema ] do | t |
326
- sys "gcc -L#{ Trema.lib } -o #{ t.name } #{ sys.sp t.prerequisites } -ltrema -lsqlite3 -ldl -lrt -lpcap -lpthread"
327
- end
328
-
329
-
330
- packet_capture_objects = [
331
- "packet_capture.o",
332
- "queue.o",
333
- ].collect do | each |
334
- File.join tremashark_objects_dir, each
335
- end
336
-
337
- desc "Build packet_capture."
338
- task :packet_capture => Trema::Executables.packet_capture
339
- file Trema::Executables.packet_capture => packet_capture_objects + [ libtrema ] do | t |
340
- sys "gcc -L#{ Trema.lib } -o #{ t.name } #{ sys.sp t.prerequisites } -ltrema -lsqlite3 -ldl -lrt -lpcap -lpthread"
341
- end
342
-
343
-
344
- syslog_relay_objects = [
345
- "syslog_relay.o",
346
- ].collect do | each |
347
- File.join tremashark_objects_dir, each
348
- end
349
-
350
- desc "Build syslog_relay."
351
- task :syslog_relay => Trema::Executables.syslog_relay
352
- file Trema::Executables.syslog_relay => syslog_relay_objects + [ libtrema ] do | t |
353
- sys "gcc -L#{ Trema.lib } -o #{ t.name } #{ sys.sp t.prerequisites } -ltrema -lsqlite3 -ldl -lrt -lpcap -lpthread"
354
- end
355
-
356
-
357
- stdin_relay_objects = [
358
- "stdin_relay.o",
359
- ].collect do | each |
360
- File.join tremashark_objects_dir, each
361
- end
362
-
363
- desc "Build stdin_relay."
364
- task :stdin_relay => Trema::Executables.stdin_relay
365
- file Trema::Executables.stdin_relay => stdin_relay_objects + [ libtrema ] do | t |
366
- sys "gcc -L#{ Trema.lib } -o #{ t.name } #{ sys.sp t.prerequisites } -ltrema -lsqlite3 -ldl -lrt -lpcap -lpthread"
367
- end
368
-
369
-
370
- ################################################################################
371
- # Build management commands
372
- ################################################################################
373
-
374
- management_commands = [
375
- "application",
376
- "echo",
377
- "set_logging_level",
378
- "show_stats",
379
- ]
380
-
381
- management_source_dir = "src/management"
382
- management_objects_dir = objects( "management" )
383
-
384
- gen C::Dependencies, dependency( "management" ),
385
- :search => [ Trema.include ], :sources => sys[ "#{ management_source_dir }/*.{c,h}" ]
386
-
387
- gen Action do
388
- source dependency( "management" )
389
- end
390
-
391
- gen Directory, management_objects_dir
392
-
393
-
394
- gen DirectedRule, management_objects_dir => [ management_source_dir ], :o => :c do | t |
395
- sys "gcc -I#{ Trema.include } -I#{ Trema.openflow } #{ var :CFLAGS } -c -o #{ t.name } #{ t.source }"
396
- end
397
-
398
-
399
- management_commands.each do | each |
400
- target = File.join( management_objects_dir, each )
401
- desc "Build #{ each } management command."
402
- task "management_commands:#{ each }" => target
403
- file target => [ File.join( management_objects_dir, "#{ each }.o" ), libtrema ] do | t |
404
- sys "gcc -L#{ Trema.lib } -o #{ t.name } #{ t.source } -ltrema -lsqlite3 -ldl -lrt -lpthread"
405
- end
406
- end
407
-
408
-
409
- ################################################################################
410
- # Build standalone examples
411
- ################################################################################
412
-
413
- standalone_examples = [
414
- "cbench_switch",
415
- "dumper",
416
- "learning_switch",
417
- "list_switches",
418
- "multi_learning_switch",
419
- "packet_in",
420
- "repeater_hub",
421
- "switch_info",
422
- "switch_monitor",
423
- "traffic_monitor",
424
- ]
425
-
426
- standalone_examples.each do | each |
427
- objects_dir = objects( "examples/#{ each }" )
428
- target = objects( "examples/#{ each }/#{ each }" )
429
-
430
- gen C::Dependencies, dependency( each ),
431
- :search => [ "src/examples/#{ each }", Trema.include ], :sources => sys[ "src/examples/#{ each }/*.{c,h}" ]
432
-
433
- gen Action do
434
- source dependency( each )
435
- end
436
-
437
-
438
- gen Directory, objects_dir
439
-
440
- objects = gen DirectedRule, objects_dir => [ "src/examples/#{ each }" ], :o => :c do | t |
441
- sys "gcc -I#{ Trema.include } -I#{ Trema.openflow } #{ var :CFLAGS } -c -o #{ t.name } #{ t.source }"
442
- end
443
-
444
-
445
- desc "Build #{ each } example."
446
- task "examples:#{ each }" => target
447
- file target => objects.candidates + [ libtrema ] do | t |
448
- sys "gcc -L#{ Trema.lib } -o #{ t.name } #{ sys.sp t.prerequisites } -ltrema -lsqlite3 -ldl -lrt -lpthread"
449
- end
450
- end
451
-
452
-
453
- ########################################################################################
454
- # Build openflow switches
455
- ################################################################################
456
-
457
- openflow_switches = [
458
- "hello_switch",
459
- "echo_switch",
460
- ]
461
-
462
- openflow_switch_source_dir = "src/examples/openflow_switch"
463
- openflow_switch_objects_dir = objects( "examples/openflow_switch" )
464
-
465
- gen C::Dependencies, dependency( "openflow_switch" ),
466
- :search => [ Trema.include ], :sources => sys[ "#{ openflow_switch_source_dir }/*.{c,h}" ]
467
-
468
- gen Action do
469
- source dependency( "openflow_switch" )
470
- end
471
-
472
- gen Directory, openflow_switch_objects_dir
473
-
474
-
475
- gen DirectedRule, openflow_switch_objects_dir => [ openflow_switch_source_dir ], :o => :c do | t |
476
- sys "gcc -I#{ Trema.include } -I#{ Trema.openflow } #{ var :CFLAGS } -c -o #{ t.name } #{ t.source }"
477
- end
478
-
479
-
480
- openflow_switches.each do | each |
481
- target = File.join( openflow_switch_objects_dir, each )
482
- task "examples:openflow_switch" => target
483
- file target => [ File.join( openflow_switch_objects_dir, "#{ each }.o" ), libtrema ] do | t |
484
- sys "gcc -L#{ Trema.lib } -o #{ t.name } #{ t.source } -ltrema -lsqlite3 -ldl -lrt -lpthread"
485
- end
486
- end
487
-
488
-
489
- ################################################################################
490
- # Build openflow messages
491
- ################################################################################
492
-
493
- openflow_messages = [
494
- "echo",
495
- "features_request",
496
- "hello",
497
- "set_config",
498
- "vendor_action",
499
- ]
500
-
501
- openflow_message_source_dir = "src/examples/openflow_message"
502
- openflow_message_objects_dir = objects( "examples/openflow_message" )
503
-
504
- gen C::Dependencies, dependency( "openflow_message" ),
505
- :search => [ Trema.include ], :sources => sys[ "#{ openflow_message_source_dir }/*.{c,h}" ]
506
-
507
- gen Action do
508
- source dependency( "openflow_message" )
509
- end
510
-
511
- gen Directory, openflow_message_objects_dir
512
-
513
-
514
- gen DirectedRule, openflow_message_objects_dir => [ openflow_message_source_dir ], :o => :c do | t |
515
- sys "gcc -I#{ Trema.include } -I#{ Trema.openflow } #{ var :CFLAGS } -c -o #{ t.name } #{ t.source }"
516
- end
517
-
518
-
519
- openflow_messages.each do | each |
520
- target = File.join( openflow_message_objects_dir, each )
521
- task "examples:openflow_message" => target
522
- file target => [ File.join( openflow_message_objects_dir, "#{ each }.o" ), libtrema ] do | t |
523
- sys "gcc -L#{ Trema.lib } -o #{ t.name } #{ t.source } -ltrema -lsqlite3 -ldl -lrt -lpthread"
524
- end
525
- end
526
-
527
-
528
- ###############################################################################
529
- # Build switch_event_config
530
- ###############################################################################
531
-
532
- switch_event_config = [
533
- "add_forward_entry",
534
- "delete_forward_entry",
535
- "set_forward_entries",
536
- "dump_forward_entries",
537
- ]
538
-
539
- switch_event_config_source_dir = "src/examples/switch_event_config"
540
- switch_event_config_objects_dir = objects( "examples/switch_event_config" )
541
-
542
- gen C::Dependencies, dependency( "switch_event_config" ),
543
- :search => [ Trema.include ], :sources => sys[ "#{ switch_event_config_source_dir }/*.{c,h}" ]
544
-
545
- gen Action do
546
- source dependency( "switch_event_config" )
547
- end
548
-
549
- gen Directory, switch_event_config_objects_dir
550
-
551
-
552
- gen DirectedRule, switch_event_config_objects_dir => [ switch_event_config_source_dir ], :o => :c do | t |
553
- sys "gcc -I#{ Trema.include } -I#{ Trema.openflow } #{ var :CFLAGS } -c -o #{ t.name } #{ t.source }"
554
- end
555
-
556
-
557
- switch_event_config.each do | each |
558
- target = File.join( switch_event_config_objects_dir, each )
559
- task "examples:switch_event_config" => target
560
- file target => [
561
- File.join( switch_event_config_objects_dir, "#{ each }.o" ),
562
- libtrema
563
- ] do | t |
564
- sys "gcc -L#{ Trema.lib } -o #{ t.name } #{ t.source } -ltrema -lsqlite3 -ldl -lrt -lpthread"
565
- end
566
- end
567
-
568
-
569
- ################################################################################
570
- # Build packetin_filter_config
571
- ################################################################################
572
-
573
- packetin_filter_config = [
574
- "add_filter",
575
- "delete_filter",
576
- "delete_filter_strict",
577
- "dump_filter",
578
- "dump_filter_strict",
579
- ]
580
-
581
- packetin_filter_config_source_dir = "src/examples/packetin_filter_config"
582
- packetin_filter_config_objects_dir = objects( "examples/packetin_filter_config" )
583
-
584
- gen C::Dependencies, dependency( "packetin_filter_config" ),
585
- :search => [ Trema.include ], :sources => sys[ "#{ packetin_filter_config_source_dir }/*.{c,h}" ]
586
-
587
- gen Action do
588
- source dependency( "packetin_filter_config" )
589
- end
590
-
591
- gen Directory, packetin_filter_config_objects_dir
592
-
593
-
594
- gen DirectedRule, packetin_filter_config_objects_dir => [ packetin_filter_config_source_dir ], :o => :c do | t |
595
- sys "gcc -I#{ Trema.include } -I#{ Trema.openflow } #{ var :CFLAGS } -c -o #{ t.name } #{ t.source }"
596
- end
597
-
598
-
599
- packetin_filter_config.each do | each |
600
- packetin_filter_config_utils_o = File.join( packetin_filter_config_objects_dir, "utils.o" )
601
- target = File.join( packetin_filter_config_objects_dir, each )
602
- task "examples:packetin_filter_config" => target
603
- file target => [
604
- File.join( packetin_filter_config_objects_dir, "#{ each }.o" ),
605
- packetin_filter_config_utils_o,
606
- libtrema
607
- ] do | t |
608
- sys "gcc -L#{ Trema.lib } -o #{ t.name } #{ t.source } #{ packetin_filter_config_utils_o } -ltrema -lsqlite3 -ldl -lrt -lpthread"
609
- end
610
- end
611
-
612
-
613
- ################################################################################
614
- # Unit tests.
615
- ################################################################################
616
-
617
- def libtrema_unit_tests
618
- {
619
- :byteorder_test => [ :log, :utility, :wrapper, :trema_wrapper ],
620
- :daemon_test => [ :log, :utility, :wrapper, :trema_wrapper ],
621
- :ether_test => [ :buffer, :log, :utility, :wrapper, :trema_wrapper ],
622
- :messenger_test => [ :doubly_linked_list, :hash_table, :event_handler, :linked_list, :utility, :wrapper, :timer, :log, :trema_wrapper ],
623
- :openflow_application_interface_test => [ :buffer, :byteorder, :hash_table, :doubly_linked_list, :linked_list, :log, :openflow_message, :packet_info, :stat, :trema_wrapper, :utility, :wrapper ],
624
- :openflow_message_test => [ :buffer, :byteorder, :linked_list, :log, :packet_info, :utility, :wrapper, :trema_wrapper ],
625
- :packet_info_test => [ :buffer, :log, :utility, :wrapper, :trema_wrapper ],
626
- :stat_test => [ :hash_table, :doubly_linked_list, :log, :utility, :wrapper, :trema_wrapper ],
627
- :timer_test => [ :log, :utility, :wrapper, :doubly_linked_list, :trema_wrapper ],
628
- :trema_test => [ :utility, :log, :wrapper, :doubly_linked_list, :trema_private, :trema_wrapper ],
629
- }
630
- end
631
-
632
-
633
- def test_object_files test
634
- names = [ test.to_s.gsub( /_test$/, "" ) ] + libtrema_unit_tests[ test ]
635
- names.collect do | each |
636
- if each == :buffer
637
- [ "unittests/objects/buffer.o", "unittests/objects/buffer_stubs.o" ]
638
- elsif each == :wrapper
639
- [ "unittests/objects/wrapper.o", "unittests/objects/wrapper_stubs.o" ]
640
- else
641
- "unittests/objects/#{ each }.o"
642
- end
643
- end.flatten
644
- end
645
-
646
-
647
- gen C::Dependencies, dependency( "unittests" ),
648
- :search => [ Trema.include, "unittests" ], :sources => sys[ "unittests/lib/*.c", "src/lib/*.{c,h}" ]
649
-
650
- gen Action do
651
- source dependency( "unittests" )
652
- end
653
-
654
-
655
- gen Directory, "unittests/objects"
656
- gen Directory, "objects/unittests"
657
-
658
- gen DirectedRule, "unittests/objects" => [ "unittests", "unittests/lib", "src/lib" ], :o => :c do | t |
659
- sys "gcc -I#{ Trema.include } -I#{ Trema.openflow } -I#{ File.dirname Trema.cmockery_h } -Iunittests -DUNIT_TESTING --coverage #{ var :CFLAGS } -c -o #{ t.name } #{ t.source }"
660
- end
661
-
662
-
663
- libtrema_unit_tests.keys.each do | each |
664
- target = "unittests/objects/#{ each }"
665
-
666
- task :build_old_unittests => [ "vendor:openflow", target ]
667
- task target => "vendor:cmockery"
668
- file target => test_object_files( each ) + [ "#{ target }.o" ] do | t |
669
- sys "gcc -L#{ File.dirname Trema.libcmockery_a } -o #{ t.name } #{ sys.sp t.prerequisites } -DUNIT_TESTING -lrt -lcmockery -lsqlite3 -ldl -lpthread --coverage --static"
670
- end
671
- end
672
-
673
-
674
- # new unittest
675
- tests = [
676
- "objects/unittests/buffer_test",
677
- "objects/unittests/doubly_linked_list_test",
678
- "objects/unittests/ether_test",
679
- "objects/unittests/event_forward_interface_test",
680
- "objects/unittests/hash_table_test",
681
- "objects/unittests/linked_list_test",
682
- "objects/unittests/log_test",
683
- "objects/unittests/packetin_filter_interface_test",
684
- "objects/unittests/packet_info_test",
685
- "objects/unittests/packet_parser_test",
686
- "objects/unittests/persistent_storage_test",
687
- "objects/unittests/trema_private_test",
688
- "objects/unittests/utility_test",
689
- "objects/unittests/wrapper_test",
690
- "objects/unittests/match_table_test",
691
- "objects/unittests/message_queue_test",
692
- "objects/unittests/management_interface_test",
693
- "objects/unittests/management_service_interface_test",
694
- ]
695
-
696
-
697
- file "objects/unittests/cmockery_trema.o" do | t |
698
- sys "gcc --coverage -c unittests/#{ File.basename t.name, ".o" }.c -o #{ t.name } #{ var :CFLAGS } -I#{ Trema.include } -I#{ File.dirname Trema.cmockery_h } -Iunittests"
699
- end
700
-
701
-
702
- tests.each do | each |
703
- task :build_unittests => [ "libtrema:gcov", each ]
704
- task each => [ "libtrema:gcov", "vendor:cmockery", "objects/unittests/cmockery_trema.o" ]
705
- file each => "unittests/lib/#{ File.basename each }.c" do | t |
706
- sys "gcc --coverage -c unittests/lib/#{ File.basename t.name }.c -o #{ each }.o #{ var :CFLAGS } -I#{ Trema.include } -I#{ Trema.openflow } -I#{ File.dirname Trema.cmockery_h } -Iunittests"
707
- sys "gcc --coverage -o #{ t.name } #{ each }.o objects/unittests/cmockery_trema.o -Lobjects/unittests -L#{ File.dirname Trema.libcmockery_a } -ltrema -lrt -lcmockery -lsqlite3 -ldl -lpthread --static"
708
- end
709
- end
710
-
711
-
712
- desc "Run unittests"
713
- task :unittests => [ :build_old_unittests, :build_unittests ] do
714
- ( sys[ "unittests/objects/*_test" ] + tests ).each do | each |
715
- puts "Running #{ each }..."
716
- sys each
717
- end
718
- end
719
-
720
-
721
- ################################################################################
722
- # TODO, FIXME etc.
723
- ################################################################################
724
-
725
- desc "Print list of notes."
726
- task :notes do
727
- keywords = [ "TODO", "FIXME", "XXX" ]
728
- keywords.each do | key |
729
- system "find src unittests -name '*.c' | xargs grep -n #{ key }"
730
- system "find ruby spec features -name '*.rb' | xargs grep -n #{ key }"
731
- end
732
- end
733
-
734
-
735
- ### Local variables:
736
- ### mode: Ruby
737
- ### coding: utf-8-unix
738
- ### indent-tabs-mode: nil
739
- ### End: