quality: Add test cases for barrier messages
This commit is contained in:
parent
211d703366
commit
578c0d1bdc
4 changed files with 99 additions and 18 deletions
|
|
@ -1158,6 +1158,36 @@ defmodule OfpActionTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "Openflow.Action.NxStackPush" do
|
||||
test "with push:NXM_NX_REG0[]" do
|
||||
push = Openflow.Action.NxStackPush.new(field: :reg0)
|
||||
|
||||
assert push.n_bits == 32
|
||||
assert push.offset == 0
|
||||
|
||||
push
|
||||
|> Openflow.Action.to_binary()
|
||||
|> Openflow.Action.read()
|
||||
|> Enum.at(0)
|
||||
|> Kernel.==(push)
|
||||
|> assert()
|
||||
end
|
||||
|
||||
test "with push:NXM_NX_REG0[1..31]" do
|
||||
push = Openflow.Action.NxStackPush.new(field: :reg0, offset: 1, n_bits: 31)
|
||||
|
||||
assert push.n_bits == 31
|
||||
assert push.offset == 1
|
||||
|
||||
push
|
||||
|> Openflow.Action.to_binary()
|
||||
|> Openflow.Action.read()
|
||||
|> Enum.at(0)
|
||||
|> Kernel.==(push)
|
||||
|> assert()
|
||||
end
|
||||
end
|
||||
|
||||
describe "Openflow.Action.NxSetTunnel" do
|
||||
test "with set_tunnel:0x1" do
|
||||
set_tunnel = Openflow.Action.NxSetTunnel.new(1)
|
||||
|
|
|
|||
52
test/ofp_barrier_test.exs
Normal file
52
test/ofp_barrier_test.exs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
defmodule OfpBarrierTest do
|
||||
use ExUnit.Case
|
||||
doctest Openflow
|
||||
|
||||
describe "Openflow.Barrier.Request" do
|
||||
test "generate and parse without argument" do
|
||||
barrier = Openflow.Barrier.Request.new()
|
||||
|
||||
barrier
|
||||
|> Openflow.to_binary()
|
||||
|> Openflow.read()
|
||||
|> Kernel.elem(1)
|
||||
|> Kernel.==(barrier)
|
||||
|> assert()
|
||||
end
|
||||
|
||||
test "generate and parse with argument" do
|
||||
barrier = Openflow.Barrier.Request.new(1)
|
||||
|
||||
barrier
|
||||
|> Openflow.to_binary()
|
||||
|> Openflow.read()
|
||||
|> Kernel.elem(1)
|
||||
|> Kernel.==(barrier)
|
||||
|> assert()
|
||||
end
|
||||
end
|
||||
|
||||
describe "Openflow.Barrier.Reply" do
|
||||
test "generate and parse without argument" do
|
||||
barrier = Openflow.Barrier.Reply.new()
|
||||
|
||||
barrier
|
||||
|> Openflow.to_binary()
|
||||
|> Openflow.read()
|
||||
|> Kernel.elem(1)
|
||||
|> Kernel.==(barrier)
|
||||
|> assert()
|
||||
end
|
||||
|
||||
test "generate and parse with argument" do
|
||||
barrier = Openflow.Barrier.Reply.new(1)
|
||||
|
||||
barrier
|
||||
|> Openflow.to_binary()
|
||||
|> Openflow.read()
|
||||
|> Kernel.elem(1)
|
||||
|> Kernel.==(barrier)
|
||||
|> assert()
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue