trema 0.3.21 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ruby-version +1 -1
- data/Gemfile +4 -4
- data/README.md +6 -9
- data/Rakefile +508 -24
- data/build.rb +4 -9
- data/cruise.rb +3 -3
- data/features/switch_event/add_forward_entry.feature +1 -0
- data/features/switch_event/delete_forward_entry.feature +1 -0
- data/features/switch_event/dump_forward_entries.feature +1 -0
- data/features/switch_event/set_forward_entries.feature +1 -0
- data/ruby/trema/compat.h +36 -0
- data/ruby/trema/controller.c +23 -7
- data/ruby/trema/default-logger.c +1 -1
- data/ruby/trema/features-reply.c +1 -1
- data/ruby/trema/switch-event.c +11 -10
- data/ruby/trema/switch.c +11 -11
- data/ruby/trema/version.rb +1 -1
- data/spec/support/matchers/constant.rb +25 -0
- data/spec/trema/barrier-request_spec.rb +1 -0
- data/spec/trema/controller_spec.rb +11 -28
- data/spec/trema/error_spec.rb +0 -46
- data/spec/trema/packet-out_spec.rb +1 -1
- data/spec/trema/port-status_spec.rb +8 -5
- data/spec/trema_spec.rb +64 -24
- data/src/lib/checks.h +2 -2
- data/src/lib/messenger.c +3 -3
- data/src/lib/openflow_message.c +8 -1
- data/src/lib/openflow_message.h +1 -0
- data/src/lib/openflow_switch_interface.c +1 -1
- data/src/switch_manager/secure_channel_listener.c +1 -1
- data/src/switch_manager/secure_channel_receiver.c +1 -1
- data/trema.gemspec +3 -3
- data/unittests/lib/daemon_test.c +1 -1
- data/unittests/lib/hash_table_test.c +1 -1
- metadata +87 -113
- data/.mono.rant +0 -4107
- data/Rantfile +0 -739
data/Rakefile
CHANGED
@@ -32,12 +32,22 @@ directory Trema.pid
|
|
32
32
|
directory Trema.sock
|
33
33
|
|
34
34
|
desc "Build Trema"
|
35
|
-
task :build_trema => [
|
36
|
-
|
37
|
-
|
35
|
+
task :build_trema => [
|
36
|
+
Trema.log,
|
37
|
+
Trema.pid,
|
38
|
+
Trema.sock,
|
39
|
+
:management_commands,
|
40
|
+
:rubylib,
|
41
|
+
:switch_manager,
|
42
|
+
:switch_daemon,
|
43
|
+
:packetin_filter,
|
44
|
+
:tremashark,
|
45
|
+
:vendor,
|
46
|
+
:examples
|
47
|
+
]
|
38
48
|
|
39
49
|
|
40
|
-
require "
|
50
|
+
require "paper_house"
|
41
51
|
require "trema/version"
|
42
52
|
|
43
53
|
|
@@ -46,7 +56,6 @@ CFLAGS = [
|
|
46
56
|
"-std=gnu99",
|
47
57
|
"-D_GNU_SOURCE",
|
48
58
|
"-fno-strict-aliasing",
|
49
|
-
"-Werror",
|
50
59
|
"-Wall",
|
51
60
|
"-Wextra",
|
52
61
|
"-Wformat=2",
|
@@ -57,6 +66,7 @@ CFLAGS = [
|
|
57
66
|
"-Wfloat-equal",
|
58
67
|
"-Wpointer-arith",
|
59
68
|
]
|
69
|
+
CFLAGS << "-Werror" if RUBY_VERSION < "1.9.0"
|
60
70
|
|
61
71
|
|
62
72
|
desc "Build Trema C library (static library)."
|
@@ -71,7 +81,7 @@ end
|
|
71
81
|
|
72
82
|
|
73
83
|
desc "Build Trema C library (coverage)."
|
74
|
-
task "libtrema:gcov" => "vendor:openflow"
|
84
|
+
task "libtrema:gcov" => [ "vendor:openflow" ]
|
75
85
|
PaperHouse::StaticLibraryTask.new "libtrema:gcov" do | task |
|
76
86
|
task.library_name = "libtrema"
|
77
87
|
task.target_directory = "#{ Trema.home }/objects/unittests"
|
@@ -247,6 +257,30 @@ CLEAN.include Trema.vendor_openvswitch
|
|
247
257
|
CLOBBER.include Trema.openvswitch
|
248
258
|
|
249
259
|
|
260
|
+
################################################################################
|
261
|
+
# Build packetin filter
|
262
|
+
################################################################################
|
263
|
+
|
264
|
+
desc "Build packetin filter."
|
265
|
+
task :packetin_filter => "libtrema:static"
|
266
|
+
|
267
|
+
PaperHouse::ExecutableTask.new :packetin_filter do | task |
|
268
|
+
task.executable_name = File.basename( Trema::Executables.packetin_filter )
|
269
|
+
task.target_directory = File.dirname( Trema::Executables.packetin_filter )
|
270
|
+
task.sources = [ "src/packetin_filter/*.c" ]
|
271
|
+
task.includes = [ Trema.include, Trema.openflow ]
|
272
|
+
task.cflags = CFLAGS
|
273
|
+
task.ldflags = "-L#{ Trema.lib }"
|
274
|
+
task.library_dependencies = [
|
275
|
+
"trema",
|
276
|
+
"sqlite3",
|
277
|
+
"pthread",
|
278
|
+
"rt",
|
279
|
+
"dl",
|
280
|
+
]
|
281
|
+
end
|
282
|
+
|
283
|
+
|
250
284
|
################################################################################
|
251
285
|
# Build oflops
|
252
286
|
################################################################################
|
@@ -285,6 +319,195 @@ CLEAN.include Trema.vendor_cmockery
|
|
285
319
|
CLOBBER.include Trema.cmockery
|
286
320
|
|
287
321
|
|
322
|
+
################################################################################
|
323
|
+
# Build examples
|
324
|
+
################################################################################
|
325
|
+
|
326
|
+
$standalone_examples = [
|
327
|
+
"cbench_switch",
|
328
|
+
"dumper",
|
329
|
+
"learning_switch",
|
330
|
+
"list_switches",
|
331
|
+
"multi_learning_switch",
|
332
|
+
"packet_in",
|
333
|
+
"repeater_hub",
|
334
|
+
"switch_info",
|
335
|
+
"switch_monitor",
|
336
|
+
"traffic_monitor",
|
337
|
+
]
|
338
|
+
|
339
|
+
desc "Build examples."
|
340
|
+
task :examples =>
|
341
|
+
$standalone_examples.map { | each | "examples:#{ each }" } +
|
342
|
+
[
|
343
|
+
"examples:openflow_switch",
|
344
|
+
"examples:openflow_message",
|
345
|
+
"examples:switch_event_config",
|
346
|
+
"examples:packetin_filter_config"
|
347
|
+
]
|
348
|
+
|
349
|
+
$standalone_examples.each do | each |
|
350
|
+
name = "examples:#{ each }"
|
351
|
+
|
352
|
+
task name => "libtrema:static"
|
353
|
+
PaperHouse::ExecutableTask.new name do | task |
|
354
|
+
task.executable_name = each
|
355
|
+
task.target_directory = File.join( Trema.objects, "examples", each )
|
356
|
+
task.sources = [ "src/examples/#{ each }/*.c" ]
|
357
|
+
task.includes = [ Trema.include, Trema.openflow ]
|
358
|
+
task.cflags = CFLAGS
|
359
|
+
task.ldflags = "-L#{ Trema.lib }"
|
360
|
+
task.library_dependencies = [
|
361
|
+
"trema",
|
362
|
+
"sqlite3",
|
363
|
+
"pthread",
|
364
|
+
"rt",
|
365
|
+
"dl",
|
366
|
+
]
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
|
371
|
+
################################################################################
|
372
|
+
# Build openflow switches
|
373
|
+
################################################################################
|
374
|
+
|
375
|
+
$openflow_switches = [
|
376
|
+
"hello_switch",
|
377
|
+
"echo_switch",
|
378
|
+
]
|
379
|
+
|
380
|
+
task "examples:openflow_switch" => $openflow_switches.map { | each | "examples:openflow_switch:#{ each }" }
|
381
|
+
|
382
|
+
$openflow_switches.each do | each |
|
383
|
+
name = "examples:openflow_switch:#{ each }"
|
384
|
+
|
385
|
+
task name => "libtrema:static"
|
386
|
+
PaperHouse::ExecutableTask.new name do | task |
|
387
|
+
task.executable_name = each
|
388
|
+
task.target_directory = File.join( Trema.objects, "examples", "openflow_switch" )
|
389
|
+
task.sources = [ "src/examples/openflow_switch/#{ each }.c" ]
|
390
|
+
task.includes = [ Trema.include, Trema.openflow ]
|
391
|
+
task.cflags = CFLAGS
|
392
|
+
task.ldflags = "-L#{ Trema.lib }"
|
393
|
+
task.library_dependencies = [
|
394
|
+
"trema",
|
395
|
+
"sqlite3",
|
396
|
+
"pthread",
|
397
|
+
"rt",
|
398
|
+
"dl",
|
399
|
+
]
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
403
|
+
|
404
|
+
################################################################################
|
405
|
+
# Build openflow messages
|
406
|
+
################################################################################
|
407
|
+
|
408
|
+
$openflow_messages = [
|
409
|
+
"echo",
|
410
|
+
"features_request",
|
411
|
+
"hello",
|
412
|
+
"set_config",
|
413
|
+
"vendor_action",
|
414
|
+
]
|
415
|
+
|
416
|
+
task "examples:openflow_message" => $openflow_messages.map { | each | "examples:openflow_message:#{ each }" }
|
417
|
+
|
418
|
+
$openflow_messages.each do | each |
|
419
|
+
name = "examples:openflow_message:#{ each }"
|
420
|
+
|
421
|
+
task name => "libtrema:static"
|
422
|
+
PaperHouse::ExecutableTask.new name do | task |
|
423
|
+
task.executable_name = each
|
424
|
+
task.target_directory = File.join( Trema.objects, "examples", "openflow_message" )
|
425
|
+
task.sources = [ "src/examples/openflow_message/#{ each }.c" ]
|
426
|
+
task.includes = [ Trema.include, Trema.openflow ]
|
427
|
+
task.cflags = CFLAGS
|
428
|
+
task.ldflags = "-L#{ Trema.lib }"
|
429
|
+
task.library_dependencies = [
|
430
|
+
"trema",
|
431
|
+
"sqlite3",
|
432
|
+
"pthread",
|
433
|
+
"rt",
|
434
|
+
"dl",
|
435
|
+
]
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
|
440
|
+
###############################################################################
|
441
|
+
# Build switch_event_config
|
442
|
+
###############################################################################
|
443
|
+
|
444
|
+
$switch_event_config = [
|
445
|
+
"add_forward_entry",
|
446
|
+
"delete_forward_entry",
|
447
|
+
"set_forward_entries",
|
448
|
+
"dump_forward_entries",
|
449
|
+
]
|
450
|
+
|
451
|
+
task "examples:switch_event_config" => $switch_event_config.map { | each | "examples:switch_event_config:#{ each }" }
|
452
|
+
|
453
|
+
$switch_event_config.each do | each |
|
454
|
+
name = "examples:switch_event_config:#{ each }"
|
455
|
+
|
456
|
+
task name => "libtrema:static"
|
457
|
+
PaperHouse::ExecutableTask.new name do | task |
|
458
|
+
task.executable_name = each
|
459
|
+
task.target_directory = File.join( Trema.objects, "examples", "switch_event_config" )
|
460
|
+
task.sources = [ "src/examples/switch_event_config/#{ each }.c" ]
|
461
|
+
task.includes = [ Trema.include, Trema.openflow ]
|
462
|
+
task.cflags = CFLAGS
|
463
|
+
task.ldflags = "-L#{ Trema.lib }"
|
464
|
+
task.library_dependencies = [
|
465
|
+
"trema",
|
466
|
+
"sqlite3",
|
467
|
+
"pthread",
|
468
|
+
"rt",
|
469
|
+
"dl",
|
470
|
+
]
|
471
|
+
end
|
472
|
+
end
|
473
|
+
|
474
|
+
|
475
|
+
################################################################################
|
476
|
+
# Build packetin_filter_config
|
477
|
+
################################################################################
|
478
|
+
|
479
|
+
$packetin_filter_config = [
|
480
|
+
"add_filter",
|
481
|
+
"delete_filter",
|
482
|
+
"delete_filter_strict",
|
483
|
+
"dump_filter",
|
484
|
+
"dump_filter_strict",
|
485
|
+
]
|
486
|
+
|
487
|
+
task "examples:packetin_filter_config" => $packetin_filter_config.map { | each | "examples:packetin_filter_config:#{ each }" }
|
488
|
+
|
489
|
+
$packetin_filter_config.each do | each |
|
490
|
+
name = "examples:packetin_filter_config:#{ each }"
|
491
|
+
|
492
|
+
task name => "libtrema:static"
|
493
|
+
PaperHouse::ExecutableTask.new name do | task |
|
494
|
+
task.executable_name = each
|
495
|
+
task.target_directory = File.join( Trema.objects, "examples", "packetin_filter_config" )
|
496
|
+
task.sources = [ "src/examples/packetin_filter_config/#{ each }.c", "src/examples/packetin_filter_config/utils.c"]
|
497
|
+
task.includes = [ Trema.include, Trema.openflow ]
|
498
|
+
task.cflags = CFLAGS
|
499
|
+
task.ldflags = "-L#{ Trema.lib }"
|
500
|
+
task.library_dependencies = [
|
501
|
+
"trema",
|
502
|
+
"sqlite3",
|
503
|
+
"pthread",
|
504
|
+
"rt",
|
505
|
+
"dl",
|
506
|
+
]
|
507
|
+
end
|
508
|
+
end
|
509
|
+
|
510
|
+
|
288
511
|
################################################################################
|
289
512
|
# Run cbench benchmarks
|
290
513
|
################################################################################
|
@@ -367,16 +590,159 @@ end
|
|
367
590
|
|
368
591
|
|
369
592
|
################################################################################
|
370
|
-
#
|
593
|
+
# Build management commands
|
371
594
|
################################################################################
|
372
595
|
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
596
|
+
$management_commands = [
|
597
|
+
"application",
|
598
|
+
"echo",
|
599
|
+
"set_logging_level",
|
600
|
+
"show_stats",
|
601
|
+
]
|
602
|
+
|
603
|
+
desc "Build management commands."
|
604
|
+
task :management_commands => $management_commands.map { | each | "management:#{ each }" }
|
605
|
+
|
606
|
+
$management_commands.each do | each |
|
607
|
+
name = "management:#{ each }"
|
608
|
+
|
609
|
+
task name => "libtrema:static"
|
610
|
+
PaperHouse::ExecutableTask.new name do | task |
|
611
|
+
task.executable_name = each
|
612
|
+
task.target_directory = File.join( Trema.objects, "management" )
|
613
|
+
task.sources = [ "src/management/#{ each }.c" ]
|
614
|
+
task.includes = [ Trema.include, Trema.openflow ]
|
615
|
+
task.cflags = CFLAGS
|
616
|
+
task.ldflags = "-L#{ Trema.lib }"
|
617
|
+
task.library_dependencies = [
|
618
|
+
"trema",
|
619
|
+
"sqlite3",
|
620
|
+
"pthread",
|
621
|
+
"rt",
|
622
|
+
"dl",
|
623
|
+
]
|
624
|
+
end
|
377
625
|
end
|
378
626
|
|
379
627
|
|
628
|
+
################################################################################
|
629
|
+
# Tremashark
|
630
|
+
################################################################################
|
631
|
+
|
632
|
+
desc "Build tremashark."
|
633
|
+
task :tremashark => [ :packet_capture, :syslog_relay, :stdin_relay, :openflow_wireshark_plugin, "libtrema:static" ]
|
634
|
+
|
635
|
+
PaperHouse::ExecutableTask.new :tremashark do | task |
|
636
|
+
task.executable_name = File.basename( Trema::Executables.tremashark )
|
637
|
+
task.target_directory = File.dirname( Trema::Executables.tremashark )
|
638
|
+
task.sources = [
|
639
|
+
"src/tremashark/pcap_queue.c",
|
640
|
+
"src/tremashark/queue.c",
|
641
|
+
"src/tremashark/tremashark.c",
|
642
|
+
]
|
643
|
+
task.includes = [ Trema.include, Trema.openflow ]
|
644
|
+
task.cflags = CFLAGS
|
645
|
+
task.ldflags = "-L#{ Trema.lib }"
|
646
|
+
task.library_dependencies = [
|
647
|
+
"trema",
|
648
|
+
"sqlite3",
|
649
|
+
"pthread",
|
650
|
+
"rt",
|
651
|
+
"dl",
|
652
|
+
"pcap"
|
653
|
+
]
|
654
|
+
end
|
655
|
+
|
656
|
+
|
657
|
+
task :packet_capture => "libtrema:static"
|
658
|
+
|
659
|
+
PaperHouse::ExecutableTask.new :packet_capture do | task |
|
660
|
+
task.executable_name = File.basename( Trema::Executables.packet_capture )
|
661
|
+
task.target_directory = File.dirname( Trema::Executables.packet_capture )
|
662
|
+
task.sources = [
|
663
|
+
"src/tremashark/packet_capture.c",
|
664
|
+
"src/tremashark/queue.c",
|
665
|
+
]
|
666
|
+
task.includes = [ Trema.include, Trema.openflow ]
|
667
|
+
task.cflags = CFLAGS
|
668
|
+
task.ldflags = "-L#{ Trema.lib }"
|
669
|
+
task.library_dependencies = [
|
670
|
+
"trema",
|
671
|
+
"sqlite3",
|
672
|
+
"pthread",
|
673
|
+
"rt",
|
674
|
+
"dl",
|
675
|
+
"pcap"
|
676
|
+
]
|
677
|
+
end
|
678
|
+
|
679
|
+
|
680
|
+
task :syslog_relay => "libtrema:static"
|
681
|
+
|
682
|
+
PaperHouse::ExecutableTask.new :syslog_relay do | task |
|
683
|
+
task.executable_name = File.basename( Trema::Executables.syslog_relay )
|
684
|
+
task.target_directory = File.dirname( Trema::Executables.syslog_relay )
|
685
|
+
task.sources = [ "src/tremashark/syslog_relay.c" ]
|
686
|
+
task.includes = [ Trema.include, Trema.openflow ]
|
687
|
+
task.cflags = CFLAGS
|
688
|
+
task.ldflags = "-L#{ Trema.lib }"
|
689
|
+
task.library_dependencies = [
|
690
|
+
"trema",
|
691
|
+
"sqlite3",
|
692
|
+
"pthread",
|
693
|
+
"rt",
|
694
|
+
"dl",
|
695
|
+
"pcap"
|
696
|
+
]
|
697
|
+
end
|
698
|
+
|
699
|
+
|
700
|
+
task :stdin_relay => "libtrema:static"
|
701
|
+
|
702
|
+
PaperHouse::ExecutableTask.new :stdin_relay do | task |
|
703
|
+
task.executable_name = File.basename( Trema::Executables.stdin_relay )
|
704
|
+
task.target_directory = File.dirname( Trema::Executables.stdin_relay )
|
705
|
+
task.sources = [ "src/tremashark/stdin_relay.c" ]
|
706
|
+
task.includes = [ Trema.include, Trema.openflow ]
|
707
|
+
task.cflags = CFLAGS
|
708
|
+
task.ldflags = "-L#{ Trema.lib }"
|
709
|
+
task.library_dependencies = [
|
710
|
+
"trema",
|
711
|
+
"sqlite3",
|
712
|
+
"pthread",
|
713
|
+
"rt",
|
714
|
+
"dl",
|
715
|
+
"pcap"
|
716
|
+
]
|
717
|
+
end
|
718
|
+
|
719
|
+
|
720
|
+
$packet_openflow_so = File.join( Trema.vendor_openflow_git, "utilities", "wireshark_dissectors", "openflow", "packet-openflow.so" )
|
721
|
+
$wireshark_plugins_dir = File.join( File.expand_path( "~" ), ".wireshark", "plugins" )
|
722
|
+
$wireshark_plugin = File.join( $wireshark_plugins_dir, File.basename( $packet_openflow_so ) )
|
723
|
+
|
724
|
+
file $packet_openflow_so do
|
725
|
+
sh "tar xzf #{ Trema.vendor_openflow_git }.tar.gz -C #{ Trema.vendor }"
|
726
|
+
cd File.dirname( $packet_openflow_so ) do
|
727
|
+
sh "make"
|
728
|
+
end
|
729
|
+
end
|
730
|
+
|
731
|
+
file $wireshark_plugin => [ $packet_openflow_so, $wireshark_plugins_dir ] do
|
732
|
+
cp $packet_openflow_so, $wireshark_plugins_dir
|
733
|
+
end
|
734
|
+
|
735
|
+
directory $wireshark_plugins_dir
|
736
|
+
|
737
|
+
task :openflow_wireshark_plugin => $wireshark_plugin
|
738
|
+
|
739
|
+
CLEAN.include Trema.vendor_openflow_git
|
740
|
+
|
741
|
+
|
742
|
+
################################################################################
|
743
|
+
# Maintenance Tasks
|
744
|
+
################################################################################
|
745
|
+
|
380
746
|
begin
|
381
747
|
require "bundler/gem_tasks"
|
382
748
|
rescue LoadError
|
@@ -394,11 +760,119 @@ end
|
|
394
760
|
|
395
761
|
|
396
762
|
################################################################################
|
397
|
-
#
|
763
|
+
# C Unit tests.
|
398
764
|
################################################################################
|
399
765
|
|
400
|
-
|
401
|
-
|
766
|
+
def libtrema_unit_tests
|
767
|
+
{
|
768
|
+
:byteorder_test => [ :log, :utility, :wrapper, :trema_wrapper ],
|
769
|
+
:daemon_test => [ :log, :utility, :wrapper, :trema_wrapper ],
|
770
|
+
:ether_test => [ :buffer, :log, :utility, :wrapper, :trema_wrapper ],
|
771
|
+
:messenger_test => [ :doubly_linked_list, :hash_table, :event_handler, :linked_list, :utility, :wrapper, :timer, :log, :trema_wrapper ],
|
772
|
+
:openflow_application_interface_test => [ :buffer, :byteorder, :hash_table, :doubly_linked_list, :linked_list, :log, :openflow_message, :packet_info, :stat, :trema_wrapper, :utility, :wrapper ],
|
773
|
+
:openflow_message_test => [ :buffer, :byteorder, :linked_list, :log, :packet_info, :utility, :wrapper, :trema_wrapper ],
|
774
|
+
:packet_info_test => [ :buffer, :log, :utility, :wrapper, :trema_wrapper ],
|
775
|
+
:stat_test => [ :hash_table, :doubly_linked_list, :log, :utility, :wrapper, :trema_wrapper ],
|
776
|
+
:timer_test => [ :log, :utility, :wrapper, :doubly_linked_list, :trema_wrapper ],
|
777
|
+
:trema_test => [ :utility, :log, :wrapper, :doubly_linked_list, :trema_private, :trema_wrapper ],
|
778
|
+
}
|
779
|
+
end
|
780
|
+
|
781
|
+
|
782
|
+
def test_c_files test
|
783
|
+
names = [ test.to_s.gsub( /_test$/, "" ) ] + libtrema_unit_tests[ test ]
|
784
|
+
names.collect do | each |
|
785
|
+
if each == :buffer
|
786
|
+
[ "src/lib/buffer.c", "unittests/buffer_stubs.c" ]
|
787
|
+
elsif each == :wrapper
|
788
|
+
[ "src/lib/wrapper.c", "unittests/wrapper_stubs.c" ]
|
789
|
+
else
|
790
|
+
"src/lib/#{ each }.c"
|
791
|
+
end
|
792
|
+
end.flatten
|
793
|
+
end
|
794
|
+
|
795
|
+
|
796
|
+
directory "objects/unittests"
|
797
|
+
|
798
|
+
task :build_old_unittests => libtrema_unit_tests.keys.map { | each | "unittests:#{ each }" }
|
799
|
+
|
800
|
+
libtrema_unit_tests.keys.each do | each |
|
801
|
+
PaperHouse::ExecutableTask.new "unittests:#{ each }" do | task |
|
802
|
+
name = "unittests:#{ each }"
|
803
|
+
task name => [ "vendor:cmockery", "vendor:openflow", "objects/unittests" ]
|
804
|
+
|
805
|
+
task.executable_name = each.to_s
|
806
|
+
task.target_directory = File.join( Trema.home, "unittests/objects" )
|
807
|
+
task.sources = test_c_files( each ) + [ "unittests/lib/#{ each }.c" ]
|
808
|
+
task.includes = [ Trema.include, Trema.openflow, File.dirname( Trema.cmockery_h ), "unittests" ]
|
809
|
+
task.cflags = [ "-DUNIT_TESTING", "--coverage", CFLAGS ]
|
810
|
+
task.ldflags = "-DUNIT_TESTING -L#{ File.dirname Trema.libcmockery_a } --coverage --static"
|
811
|
+
task.library_dependencies = [
|
812
|
+
"cmockery",
|
813
|
+
"sqlite3",
|
814
|
+
"pthread",
|
815
|
+
"rt",
|
816
|
+
"dl",
|
817
|
+
"pcap"
|
818
|
+
]
|
819
|
+
end
|
820
|
+
end
|
821
|
+
|
822
|
+
|
823
|
+
# new unittest
|
824
|
+
$tests = [
|
825
|
+
"objects/unittests/buffer_test",
|
826
|
+
"objects/unittests/doubly_linked_list_test",
|
827
|
+
"objects/unittests/ether_test",
|
828
|
+
"objects/unittests/event_forward_interface_test",
|
829
|
+
"objects/unittests/hash_table_test",
|
830
|
+
"objects/unittests/linked_list_test",
|
831
|
+
"objects/unittests/log_test",
|
832
|
+
"objects/unittests/packetin_filter_interface_test",
|
833
|
+
"objects/unittests/packet_info_test",
|
834
|
+
"objects/unittests/packet_parser_test",
|
835
|
+
"objects/unittests/persistent_storage_test",
|
836
|
+
"objects/unittests/trema_private_test",
|
837
|
+
"objects/unittests/utility_test",
|
838
|
+
"objects/unittests/wrapper_test",
|
839
|
+
"objects/unittests/match_table_test",
|
840
|
+
"objects/unittests/message_queue_test",
|
841
|
+
"objects/unittests/management_interface_test",
|
842
|
+
"objects/unittests/management_service_interface_test",
|
843
|
+
]
|
844
|
+
|
845
|
+
task :build_unittests => $tests.map { | each | "unittests:" + File.basename( each ) }
|
846
|
+
|
847
|
+
$tests.each do | _each |
|
848
|
+
each = File.basename( _each )
|
849
|
+
|
850
|
+
task "unittests:#{ each }" => [ "libtrema:gcov", "vendor:cmockery" ]
|
851
|
+
PaperHouse::ExecutableTask.new "unittests:#{ each }" do | task |
|
852
|
+
task.executable_name = each.to_s
|
853
|
+
task.target_directory = File.join( Trema.home, "unittests/objects" )
|
854
|
+
task.sources = [ "unittests/lib/#{ each }.c", "unittests/cmockery_trema.c" ]
|
855
|
+
task.includes = [ Trema.include, Trema.openflow, File.dirname( Trema.cmockery_h ), "unittests" ]
|
856
|
+
task.cflags = [ "--coverage", CFLAGS ]
|
857
|
+
task.ldflags = "-L#{ File.dirname Trema.libcmockery_a } -Lobjects/unittests --coverage --static"
|
858
|
+
task.library_dependencies = [
|
859
|
+
"trema",
|
860
|
+
"cmockery",
|
861
|
+
"sqlite3",
|
862
|
+
"pthread",
|
863
|
+
"rt",
|
864
|
+
"dl",
|
865
|
+
]
|
866
|
+
end
|
867
|
+
end
|
868
|
+
|
869
|
+
|
870
|
+
desc "Run unittests"
|
871
|
+
task :unittests => [ :build_old_unittests, :build_unittests ] do
|
872
|
+
Dir.glob( "unittests/objects/*_test" ).each do | each |
|
873
|
+
puts "Running #{ each }..."
|
874
|
+
sh each
|
875
|
+
end
|
402
876
|
end
|
403
877
|
|
404
878
|
|
@@ -406,7 +880,7 @@ end
|
|
406
880
|
# Tests
|
407
881
|
################################################################################
|
408
882
|
|
409
|
-
task :travis => [ :
|
883
|
+
task :travis => [ :clobber, :build_trema, "spec:travis" ]
|
410
884
|
|
411
885
|
|
412
886
|
begin
|
@@ -463,11 +937,6 @@ end
|
|
463
937
|
################################################################################
|
464
938
|
|
465
939
|
$ruby_sources = FileList[ "ruby/**/*.rb", "src/**/*.rb" ]
|
466
|
-
$quality_targets = if ENV[ "QUALITY_TARGETS" ]
|
467
|
-
ENV[ "QUALITY_TARGETS" ].split
|
468
|
-
else
|
469
|
-
$ruby_sources
|
470
|
-
end
|
471
940
|
|
472
941
|
|
473
942
|
desc "Enforce Ruby code quality with static analysis of code"
|
@@ -478,23 +947,24 @@ begin
|
|
478
947
|
require "reek/rake/task"
|
479
948
|
|
480
949
|
Reek::Rake::Task.new do | t |
|
481
|
-
t.fail_on_error =
|
950
|
+
t.fail_on_error = false
|
482
951
|
t.verbose = false
|
483
952
|
t.ruby_opts = [ "-rubygems" ]
|
484
953
|
t.reek_opts = "--quiet"
|
485
|
-
t.source_files = $
|
954
|
+
t.source_files = $ruby_sources
|
486
955
|
end
|
487
956
|
rescue LoadError
|
488
957
|
$stderr.puts $!.to_s
|
489
958
|
end
|
490
959
|
|
960
|
+
|
491
961
|
begin
|
492
962
|
require "flog"
|
493
963
|
|
494
964
|
desc "Analyze for code complexity"
|
495
965
|
task :flog do
|
496
966
|
flog = Flog.new( :continue => true )
|
497
|
-
flog.flog *$
|
967
|
+
flog.flog *$ruby_sources
|
498
968
|
threshold = 10
|
499
969
|
|
500
970
|
bad_methods = flog.totals.select do | name, score |
|
@@ -506,7 +976,7 @@ begin
|
|
506
976
|
puts "%8.1f: %s" % [ score, name ]
|
507
977
|
end
|
508
978
|
unless bad_methods.empty?
|
509
|
-
|
979
|
+
$stderr.puts "#{ bad_methods.size } methods have a flog complexity > #{ threshold }"
|
510
980
|
end
|
511
981
|
end
|
512
982
|
rescue LoadError
|
@@ -547,6 +1017,20 @@ rescue LoadError
|
|
547
1017
|
end
|
548
1018
|
|
549
1019
|
|
1020
|
+
################################################################################
|
1021
|
+
# TODO, FIXME etc.
|
1022
|
+
################################################################################
|
1023
|
+
|
1024
|
+
desc "Print list of notes."
|
1025
|
+
task :notes do
|
1026
|
+
keywords = [ "TODO", "FIXME", "XXX" ]
|
1027
|
+
keywords.each do | each |
|
1028
|
+
system "find src unittests -name '*.c' | xargs grep -n #{ each }"
|
1029
|
+
system "find ruby spec features -name '*.rb' | xargs grep -n #{ each }"
|
1030
|
+
end
|
1031
|
+
end
|
1032
|
+
|
1033
|
+
|
550
1034
|
### Local variables:
|
551
1035
|
### mode: Ruby
|
552
1036
|
### coding: utf-8-unix
|
data/build.rb
CHANGED
@@ -18,16 +18,11 @@
|
|
18
18
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
19
19
|
#
|
20
20
|
|
21
|
-
require "rbconfig"
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
)
|
28
|
-
|
29
|
-
result = system "cd #{ File.dirname( __FILE__ ) } && #{ RUBY_PATH } .mono.rant #{ ARGV.join ' ' }"
|
30
|
-
abort "#{ $0 } aborted!" unless result
|
22
|
+
Dir.chdir File.dirname( __FILE__ ) do
|
23
|
+
result = system( "bundle exec rake #{ ARGV.join ' ' }" )
|
24
|
+
abort "#{ $0 } aborted!" unless result
|
25
|
+
end
|
31
26
|
|
32
27
|
|
33
28
|
### Local variables:
|
data/cruise.rb
CHANGED
@@ -303,7 +303,7 @@ end
|
|
303
303
|
def test message
|
304
304
|
puts message
|
305
305
|
cd Trema.home do
|
306
|
-
sh "
|
306
|
+
sh "rake clean"
|
307
307
|
begin
|
308
308
|
yield
|
309
309
|
ensure
|
@@ -315,7 +315,7 @@ end
|
|
315
315
|
|
316
316
|
def run_unit_test
|
317
317
|
test "Running unit tests ..." do
|
318
|
-
sh "
|
318
|
+
sh "rake unittests"
|
319
319
|
sh "rake spec"
|
320
320
|
end
|
321
321
|
measure_coverage
|
@@ -359,7 +359,7 @@ $options.parse! ARGV
|
|
359
359
|
|
360
360
|
def init_cruise
|
361
361
|
sh "bundle"
|
362
|
-
sh "rake
|
362
|
+
sh "rake clobber"
|
363
363
|
end
|
364
364
|
|
365
365
|
|