Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bio-rd
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
bio-rd
Commits
96896e20
Commit
96896e20
authored
5 years ago
by
Marcus Weiner
Browse files
Options
Downloads
Patches
Plain Diff
Split packet tests
parent
08676601
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Packet/ospfv3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
protocols/ospf/packetv3/decode_test.go
+0
-60
0 additions, 60 deletions
protocols/ospf/packetv3/decode_test.go
protocols/ospf/packetv3/smoke_test.go
+68
-0
68 additions, 0 deletions
protocols/ospf/packetv3/smoke_test.go
with
68 additions
and
60 deletions
protocols/ospf/packetv3/
packet
_test.go
→
protocols/ospf/packetv3/
decode
_test.go
+
0
−
60
View file @
96896e20
...
...
@@ -2,74 +2,14 @@ package packetv3_test
import
(
"bytes"
"fmt"
"io"
"os"
"testing"
"github.com/bio-routing/bio-rd/net"
ospf
"github.com/bio-routing/bio-rd/protocols/ospf/packetv3"
"github.com/bio-routing/bio-rd/protocols/ospf/packetv3/fixtures"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
var
files
=
[]
string
{
"OSPFv3_multipoint_adjacencies.cap"
,
"OSPFv3_broadcast_adjacency.cap"
,
"OSPFv3_NBMA_adjacencies.cap"
,
}
var
dir
string
func
init
()
{
cwd
,
err
:=
os
.
Getwd
()
if
err
!=
nil
{
panic
(
err
)
}
dir
=
cwd
+
"/fixtures/"
}
func
TestDecodeDumps
(
t
*
testing
.
T
)
{
for
_
,
path
:=
range
files
{
t
.
Run
(
path
,
func
(
t
*
testing
.
T
)
{
testDecodeFile
(
t
,
dir
+
path
)
})
}
}
func
testDecodeFile
(
t
*
testing
.
T
,
path
string
)
{
fmt
.
Printf
(
"Testing on file: %s
\n
"
,
path
)
r
,
f
:=
fixtures
.
PacketReader
(
t
,
path
)
defer
f
.
Close
()
var
packetCount
int
for
{
data
,
_
,
err
:=
r
.
ReadPacketData
()
if
err
==
io
.
EOF
{
break
}
if
err
!=
nil
{
t
.
Error
(
err
)
return
}
t
.
Run
(
fmt
.
Sprintf
(
"Packet_%03d"
,
packetCount
+
1
),
func
(
t
*
testing
.
T
)
{
payload
,
src
,
dst
,
err
:=
fixtures
.
Payload
(
data
)
if
err
!=
nil
{
t
.
Error
(
err
)
return
}
buf
:=
bytes
.
NewBuffer
(
payload
)
if
_
,
_
,
err
:=
ospf
.
DeserializeOSPFv3Message
(
buf
,
src
,
dst
);
err
!=
nil
{
t
.
Error
(
err
)
}
})
packetCount
++
}
}
type
test
struct
{
name
string
input
[]
byte
...
...
This diff is collapsed.
Click to expand it.
protocols/ospf/packetv3/smoke_test.go
0 → 100644
+
68
−
0
View file @
96896e20
package
packetv3_test
import
(
"bytes"
"fmt"
"io"
"os"
"testing"
ospf
"github.com/bio-routing/bio-rd/protocols/ospf/packetv3"
"github.com/bio-routing/bio-rd/protocols/ospf/packetv3/fixtures"
)
var
files
=
[]
string
{
"OSPFv3_multipoint_adjacencies.cap"
,
"OSPFv3_broadcast_adjacency.cap"
,
"OSPFv3_NBMA_adjacencies.cap"
,
}
var
dir
string
func
init
()
{
cwd
,
err
:=
os
.
Getwd
()
if
err
!=
nil
{
panic
(
err
)
}
dir
=
cwd
+
"/fixtures/"
}
func
TestDecodeDumps
(
t
*
testing
.
T
)
{
for
_
,
path
:=
range
files
{
t
.
Run
(
path
,
func
(
t
*
testing
.
T
)
{
testDecodeFile
(
t
,
dir
+
path
)
})
}
}
func
testDecodeFile
(
t
*
testing
.
T
,
path
string
)
{
fmt
.
Printf
(
"Testing on file: %s
\n
"
,
path
)
r
,
f
:=
fixtures
.
PacketReader
(
t
,
path
)
defer
f
.
Close
()
var
packetCount
int
for
{
data
,
_
,
err
:=
r
.
ReadPacketData
()
if
err
==
io
.
EOF
{
break
}
if
err
!=
nil
{
t
.
Error
(
err
)
return
}
t
.
Run
(
fmt
.
Sprintf
(
"Packet_%03d"
,
packetCount
+
1
),
func
(
t
*
testing
.
T
)
{
payload
,
src
,
dst
,
err
:=
fixtures
.
Payload
(
data
)
if
err
!=
nil
{
t
.
Error
(
err
)
return
}
buf
:=
bytes
.
NewBuffer
(
payload
)
if
_
,
_
,
err
:=
ospf
.
DeserializeOSPFv3Message
(
buf
,
src
,
dst
);
err
!=
nil
{
t
.
Error
(
err
)
}
})
packetCount
++
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment