File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change 11package daemon
22
3- import "testing"
3+ import (
4+ "bytes"
5+ "net"
6+ "testing"
7+ )
48
59func TestGetAvailableGwAddress (t * testing.T ) {
610 addr , err := GetAvailableGwAddress ("" )
@@ -75,3 +79,31 @@ func TestDeletePeer(t *testing.T) {
7579 t .Fatal ("Port has not been deleted" )
7680 }
7781}
82+
83+ func TestGenerateRandomName (t * testing.T ) {
84+ results := make (map [string ]bool )
85+ for i := 0 ; i <= 100 ; i ++ {
86+ result , err := GenerateRandomName ("foo" , 12 )
87+ if err != nil {
88+ t .Fatal (err )
89+ }
90+ if results [result ] != false {
91+ t .Fatal ("generated name not unique" )
92+ }
93+ results [result ] = true
94+ }
95+ }
96+
97+ func TestGenerateMacAddress (t * testing.T ) {
98+ ip := net .ParseIP ("1.1.1.1" )
99+ mac := generateMacAddr (ip )
100+ if mac [0 ] != 0x02 {
101+ t .Fatal ("first byte should be 0x02" )
102+ }
103+ if mac [1 ] != 0x42 {
104+ t .Fatal ("second byte should be 0x42" )
105+ }
106+ if ! bytes .Equal (mac [2 :], ip .To4 ()) {
107+ t .Fatal ("remaning bytes should be ipv4 address" )
108+ }
109+ }
You can’t perform that action at this time.
0 commit comments