trema 0.4.3 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,8 +28,10 @@
28
28
  #define SWITCH_STATE_CONNECTED 0
29
29
  #define SWITCH_STATE_WAIT_HELLO 1
30
30
  #define SWITCH_STATE_WAIT_FEATURES_REPLY 2
31
- #define SWITCH_STATE_COMPLETED 3
32
- #define SWITCH_STATE_DISCONNECTED 4
31
+ #define SWITCH_STATE_WAIT_REGISTRATION 3
32
+ #define SWITCH_STATE_COMPLETED 4
33
+ #define SWITCH_STATE_DISCONNECTED 5
34
+ #define SWITCH_STATE_CONNECTION_FAILED 6
33
35
 
34
36
 
35
37
  struct switch_info {
@@ -63,6 +65,8 @@ struct switch_info {
63
65
  bool running_timer;
64
66
 
65
67
  uint32_t echo_request_xid;
68
+
69
+ int retry_count;
66
70
  };
67
71
 
68
72
 
data/trema.gemspec CHANGED
@@ -26,9 +26,9 @@ Gem::Specification.new do | gem |
26
26
  gem.test_files = `git ls-files -- {spec,features}/*`.split( "\n" )
27
27
 
28
28
  gem.add_dependency "bundler"
29
- gem.add_dependency "gli", "~> 2.8.0"
30
- gem.add_dependency "paper_house", "~> 0.4.0"
31
- gem.add_dependency "pio", "~> 0.2.4"
29
+ gem.add_dependency "gli", "~> 2.8.1"
30
+ gem.add_dependency "paper_house", "~> 0.5.0"
31
+ gem.add_dependency "pio", "~> 0.2.6"
32
32
  gem.add_dependency "rake", "~> 10.1.0"
33
33
  gem.add_dependency "rdoc", "~> 4.0.1"
34
34
  end
@@ -179,14 +179,6 @@ mock_basename( char *path ) {
179
179
  }
180
180
 
181
181
 
182
- int
183
- mock_rename( char *oldpath, char *newpath ) {
184
- check_expected( oldpath );
185
- check_expected( newpath );
186
- return ( int ) mock();
187
- }
188
-
189
-
190
182
  void
191
183
  mock_warn( const char *format, ... ) {
192
184
  UNUSED( format );
@@ -256,6 +248,9 @@ test_daemonize_fail_if_setsid_fail() {
256
248
 
257
249
  static void
258
250
  test_write_pid_succeed() {
251
+ extern int locked_fd;
252
+
253
+ locked_fd = -1;
259
254
  will_return( mock_open, 1111 );
260
255
  will_return( mock_lockf, 0 );
261
256
 
@@ -282,6 +277,9 @@ test_write_pid_succeed() {
282
277
 
283
278
  static void
284
279
  test_write_pid_fail_if_open_fail() {
280
+ extern int locked_fd;
281
+
282
+ locked_fd = -1;
285
283
  will_return( mock_open, -1 );
286
284
 
287
285
  // Test if correctly opened.
@@ -298,6 +296,9 @@ test_write_pid_fail_if_open_fail() {
298
296
 
299
297
  static void
300
298
  test_write_pid_fail_if_lockf_fail() {
299
+ extern int locked_fd;
300
+
301
+ locked_fd = -1;
301
302
  will_return( mock_open, 1111 );
302
303
  will_return( mock_lockf, -1 );
303
304
 
@@ -660,39 +661,39 @@ test_read_pid_fail_if_readlink_fail() {
660
661
 
661
662
  static void
662
663
  test_rename_pid_successed() {
663
- // Test if correctly unlink.
664
- expect_string( mock_unlink, pathname, "/home/yasuhito/trema/tmp/hello.pid" );
665
- errno = ENOENT;
666
- will_return( mock_unlink, -1 );
667
- // Test if correctly rename.
668
- expect_string( mock_rename, oldpath, "/home/yasuhito/trema/tmp/bye.pid" );
669
- expect_string( mock_rename, newpath, "/home/yasuhito/trema/tmp/hello.pid" );
670
- will_return( mock_rename, 0 );
664
+ extern int locked_fd;
671
665
 
672
- // Go
673
- rename_pid( "/home/yasuhito/trema/tmp", "bye", "hello" );
674
- }
666
+ locked_fd = 2222;
667
+ will_return( mock_open, 1111 );
668
+ will_return( mock_lockf, 0 );
669
+
670
+ // Test if correctly opened.
671
+ char new_path[] = "/home/yasuhito/trema/tmp/hello.pid";
672
+ char buffer[] = "1234\n";
673
+ expect_string( mock_open, pathname, new_path );
674
+ expect_value( mock_open, flags, ( O_RDWR | O_CREAT ) );
675
+ expect_value( mock_open, mode, 0600 );
675
676
 
677
+ // Test if correctly locked.
678
+ expect_value( mock_lockf, fd, 1111 );
679
+ expect_value( mock_lockf, cmd, F_TLOCK );
680
+ expect_value( mock_lockf, len, 0 );
676
681
 
677
- static void
678
- test_rename_pid_fail_if_rename_fail() {
679
- // Test if correctly unlink.
680
- expect_string( mock_unlink, pathname, "/home/yasuhito/trema/tmp/hello.pid" );
681
- errno = ENOENT;
682
- will_return( mock_unlink, -1 );
683
- // Test if correctly rename.
684
- expect_string( mock_rename, oldpath, "/home/yasuhito/trema/tmp/bye.pid" );
685
- expect_string( mock_rename, newpath, "/home/yasuhito/trema/tmp/hello.pid" );
686
- errno = ENOENT;
687
- will_return( mock_rename, -1 );
682
+ // Test if correctly written.
683
+ expect_value( mock_write, fd, 1111 );
684
+ expect_string( mock_write, buf, buffer );
685
+ expect_value( mock_write, count, strlen( buffer ) );
688
686
 
689
- expect_string( mock_die, message, "Could not rename a PID file from "
690
- "/home/yasuhito/trema/tmp/bye.pid"
691
- " to "
692
- "/home/yasuhito/trema/tmp/hello.pid." );
687
+ expect_value( mock_close, fd, 2222 );
688
+
689
+ will_return( mock_unlink, 0 );
690
+
691
+ // Test if correctly unlinked.
692
+ char old_path[] = "/home/yasuhito/trema/tmp/bye.pid";
693
+ expect_string( mock_unlink, pathname, old_path );
693
694
 
694
695
  // Go
695
- expect_assert_failure( rename_pid( "/home/yasuhito/trema/tmp", "bye", "hello" ) );
696
+ rename_pid( "/home/yasuhito/trema/tmp", "bye", "hello" );
696
697
  }
697
698
 
698
699
 
@@ -731,7 +732,6 @@ main() {
731
732
 
732
733
  // rename_pid() tests.
733
734
  unit_test( test_rename_pid_successed ),
734
- unit_test( test_rename_pid_fail_if_rename_fail ),
735
735
 
736
736
  };
737
737
  return run_tests( tests );
@@ -146,8 +146,13 @@ mock_kill( pid_t pid, int sig ) {
146
146
 
147
147
 
148
148
  unsigned int
149
- mock_sleep( unsigned int seconds ) {
150
- check_expected( seconds );
149
+ mock_clock_nanosleep( clockid_t clock_id, int flags, struct timespec *request, struct timespec *remain) {
150
+ check_expected( clock_id );
151
+ check_expected( flags );
152
+ assert_true( request != NULL );
153
+ check_expected( request->tv_sec );
154
+ check_expected( request->tv_nsec );
155
+ check_expected( remain );
151
156
  return ( unsigned int ) mock();
152
157
  }
153
158
 
@@ -906,8 +911,12 @@ test_terminate_trema_process_when_retry_count_1() {
906
911
  expect_value_count( mock_kill, sig, 0, 2 );
907
912
  will_return_count( mock_kill, 0, 2 );
908
913
  will_return_count( mock_kill, -1, 1 );
909
- expect_value_count( mock_sleep, seconds, 1, 1 );
910
- will_return_count( mock_sleep, 0, 1 );
914
+ expect_value_count( mock_clock_nanosleep, clock_id, CLOCK_MONOTONIC, 1 );
915
+ expect_value_count( mock_clock_nanosleep, flags, 0, 1 );
916
+ expect_value_count( mock_clock_nanosleep, request->tv_sec, 0, 1 );
917
+ expect_value_count( mock_clock_nanosleep, request->tv_nsec, 500000000, 1 );
918
+ expect_value_count( mock_clock_nanosleep, remain, NULL, 1 );
919
+ will_return_count( mock_clock_nanosleep, 0, 1 );
911
920
 
912
921
  // Go
913
922
  assert_true( terminate_trema_process( PID ) );
@@ -922,8 +931,12 @@ test_terminate_trema_process_when_retry_count_10() {
922
931
  expect_value_count( mock_kill, sig, 0, 11 );
923
932
  will_return_count( mock_kill, 0, 11 );
924
933
  will_return_count( mock_kill, -1, 1 );
925
- expect_value_count( mock_sleep, seconds, 1, 10 );
926
- will_return_count( mock_sleep, 0, 10 );
934
+ expect_value_count( mock_clock_nanosleep, clock_id, CLOCK_MONOTONIC, 10 );
935
+ expect_value_count( mock_clock_nanosleep, flags, 0, 10 );
936
+ expect_value_count( mock_clock_nanosleep, request->tv_sec, 0, 10 );
937
+ expect_value_count( mock_clock_nanosleep, request->tv_nsec, 500000000, 10 );
938
+ expect_value_count( mock_clock_nanosleep, remain, NULL, 10 );
939
+ will_return_count( mock_clock_nanosleep, 0, 10 );
927
940
 
928
941
  // Go
929
942
  assert_true( terminate_trema_process( PID ) );
@@ -937,8 +950,12 @@ test_terminate_trema_process_when_over_max_retry_count() {
937
950
  expect_value_count( mock_kill, sig, SIGTERM, 1 );
938
951
  expect_value_count( mock_kill, sig, 0, 11 );
939
952
  will_return_count( mock_kill, 0, 12 );
940
- expect_value_count( mock_sleep, seconds, 1, 10 );
941
- will_return_count( mock_sleep, 0, 10 );
953
+ expect_value_count( mock_clock_nanosleep, clock_id, CLOCK_MONOTONIC, 10 );
954
+ expect_value_count( mock_clock_nanosleep, flags, 0, 10 );
955
+ expect_value_count( mock_clock_nanosleep, request->tv_sec, 0, 10 );
956
+ expect_value_count( mock_clock_nanosleep, request->tv_nsec, 500000000, 10 );
957
+ expect_value_count( mock_clock_nanosleep, remain, NULL, 10 );
958
+ will_return_count( mock_clock_nanosleep, 0, 10 );
942
959
 
943
960
  // Go
944
961
  assert_true( !terminate_trema_process( PID ) );
metadata CHANGED
@@ -1,115 +1,132 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: trema
3
- version: !ruby/object:Gem::Version
4
- version: 0.4.3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 7
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 4
9
+ - 4
10
+ version: 0.4.4
5
11
  platform: ruby
6
- authors:
12
+ authors:
7
13
  - Yasuhito Takamiya
8
14
  autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
- date: 2013-10-04 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-10-28 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ hash: 3
27
+ segments:
28
+ - 0
29
+ version: "0"
14
30
  name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
31
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: gli
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: 2.8.0
34
32
  type: :runtime
33
+ requirement: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ hash: 45
41
+ segments:
42
+ - 2
43
+ - 8
44
+ - 1
45
+ version: 2.8.1
46
+ name: gli
35
47
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
48
+ type: :runtime
49
+ requirement: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ version_requirements: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
38
54
  - - ~>
39
- - !ruby/object:Gem::Version
40
- version: 2.8.0
41
- - !ruby/object:Gem::Dependency
55
+ - !ruby/object:Gem::Version
56
+ hash: 11
57
+ segments:
58
+ - 0
59
+ - 5
60
+ - 0
61
+ version: 0.5.0
42
62
  name: paper_house
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ~>
46
- - !ruby/object:Gem::Version
47
- version: 0.4.0
48
- type: :runtime
49
63
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
64
+ type: :runtime
65
+ requirement: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ version_requirements: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
52
70
  - - ~>
53
- - !ruby/object:Gem::Version
54
- version: 0.4.0
55
- - !ruby/object:Gem::Dependency
71
+ - !ruby/object:Gem::Version
72
+ hash: 27
73
+ segments:
74
+ - 0
75
+ - 2
76
+ - 6
77
+ version: 0.2.6
56
78
  name: pio
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 0.2.4
62
- type: :runtime
63
79
  prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ~>
67
- - !ruby/object:Gem::Version
68
- version: 0.2.4
69
- - !ruby/object:Gem::Dependency
70
- name: rake
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ~>
74
- - !ruby/object:Gem::Version
75
- version: 10.1.0
76
80
  type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
81
+ requirement: *id004
82
+ - !ruby/object:Gem::Dependency
83
+ version_requirements: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
80
86
  - - ~>
81
- - !ruby/object:Gem::Version
87
+ - !ruby/object:Gem::Version
88
+ hash: 75
89
+ segments:
90
+ - 10
91
+ - 1
92
+ - 0
82
93
  version: 10.1.0
83
- - !ruby/object:Gem::Dependency
84
- name: rdoc
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ~>
88
- - !ruby/object:Gem::Version
89
- version: 4.0.1
90
- type: :runtime
94
+ name: rake
91
95
  prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
96
+ type: :runtime
97
+ requirement: *id005
98
+ - !ruby/object:Gem::Dependency
99
+ version_requirements: &id006 !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
94
102
  - - ~>
95
- - !ruby/object:Gem::Version
103
+ - !ruby/object:Gem::Version
104
+ hash: 61
105
+ segments:
106
+ - 4
107
+ - 0
108
+ - 1
96
109
  version: 4.0.1
97
- description: Trema is a full-stack, easy-to-use framework for developing OpenFlow
98
- controllers in Ruby and C.
99
- email:
110
+ name: rdoc
111
+ prerelease: false
112
+ type: :runtime
113
+ requirement: *id006
114
+ description: Trema is a full-stack, easy-to-use framework for developing OpenFlow controllers in Ruby and C.
115
+ email:
100
116
  - yasuhito@gmail.com
101
- executables:
117
+ executables:
102
118
  - trema
103
119
  - trema-config
104
- extensions:
120
+ extensions:
105
121
  - Rakefile
106
- extra_rdoc_files:
122
+ extra_rdoc_files:
107
123
  - README.md
108
- files:
124
+ files:
109
125
  - .gitignore
110
126
  - .ruby-version
111
127
  - .travis.yml
112
128
  - .yardopts
129
+ - CONTRIBUTING.md
113
130
  - Doxyfile
114
131
  - Gemfile
115
132
  - README.md
@@ -391,7 +408,6 @@ files:
391
408
  - spec/trema/host_spec.rb
392
409
  - spec/trema/link_spec.rb
393
410
  - spec/trema/list-switches-reply_spec.rb
394
- - spec/trema/mac_spec.rb
395
411
  - spec/trema/match_spec.rb
396
412
  - spec/trema/open-vswitch_spec.rb
397
413
  - spec/trema/openflow-error_spec.rb
@@ -795,28 +811,40 @@ files:
795
811
  - vendor/ruby-ifconfig-1.2/test/unit/tc_openbsd.rb
796
812
  - vendor/ruby-ifconfig-1.2/test/unit/tc_sunos.rb
797
813
  homepage: http://github.com/trema/trema
798
- licenses:
814
+ licenses:
799
815
  - GPL2
800
- metadata: {}
801
816
  post_install_message:
802
817
  rdoc_options: []
803
- require_paths:
818
+
819
+ require_paths:
804
820
  - ruby
805
- required_ruby_version: !ruby/object:Gem::Requirement
806
- requirements:
807
- - - '>='
808
- - !ruby/object:Gem::Version
821
+ required_ruby_version: !ruby/object:Gem::Requirement
822
+ none: false
823
+ requirements:
824
+ - - ">="
825
+ - !ruby/object:Gem::Version
826
+ hash: 57
827
+ segments:
828
+ - 1
829
+ - 8
830
+ - 7
809
831
  version: 1.8.7
810
- required_rubygems_version: !ruby/object:Gem::Requirement
811
- requirements:
812
- - - '>='
813
- - !ruby/object:Gem::Version
814
- version: '0'
832
+ required_rubygems_version: !ruby/object:Gem::Requirement
833
+ none: false
834
+ requirements:
835
+ - - ">="
836
+ - !ruby/object:Gem::Version
837
+ hash: 3
838
+ segments:
839
+ - 0
840
+ version: "0"
815
841
  requirements: []
842
+
816
843
  rubyforge_project:
817
- rubygems_version: 2.0.3
844
+ rubygems_version: 1.8.25
818
845
  signing_key:
819
- specification_version: 4
846
+ specification_version: 3
820
847
  summary: Full-stack OpenFlow framework.
821
848
  test_files: []
849
+
822
850
  has_rdoc: