aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lua/tvb.lua44
1 files changed, 43 insertions, 1 deletions
diff --git a/test/lua/tvb.lua b/test/lua/tvb.lua
index 25c0daacf3..6b63ff447a 100644
--- a/test/lua/tvb.lua
+++ b/test/lua/tvb.lua
@@ -45,7 +45,16 @@ end
--
-- CHANGE THIS TO MATCH HOW MANY TESTS THERE ARE
--
-local taptests = { [FRAME]=4, [OTHER]=312 }
+-- The number of tests in a specific category (other than FRAME) is the
+-- number of times execute() is called by any function below testing().
+-- From the user's perspective, it can be calculated with the following
+-- formula:
+--
+-- N = number of execute() you call +
+-- number of verifyFields() * (1 + number of fields) +
+-- number of verifyResults() * (1 + 2 * number of values)
+--
+local taptests = { [FRAME]=4, [OTHER]=318 }
local function getResults()
print("\n-----------------------------\n")
@@ -146,6 +155,8 @@ local testfield =
REL_OID = ProtoField.rel_oid("test.basic.rel_oid", "Basic Relative OID"),
ABSOLUTE_LOCAL = ProtoField.absolute_time("test.basic.absolute.local","Basic absolute local"),
ABSOLUTE_UTC = ProtoField.absolute_time("test.basic.absolute.utc", "Basic absolute utc", 1001),
+ IPv4 = ProtoField.ipv4 ("test.basic.ipv4", "Basic ipv4 address"),
+ IPv6 = ProtoField.ipv6 ("test.basic.ipv6", "Basic ipv6 address"),
-- GUID = ProtoField.guid ("test.basic.guid", "Basic GUID"),
},
@@ -192,6 +203,8 @@ local getfield =
REL_OID = Field.new ("test.basic.rel_oid"),
ABSOLUTE_LOCAL = Field.new ("test.basic.absolute.local"),
ABSOLUTE_UTC = Field.new ("test.basic.absolute.utc"),
+ IPv4 = Field.new ("test.basic.ipv4"),
+ IPv6 = Field.new ("test.basic.ipv6"),
-- GUID = Field.new ("test.basic.guid"),
},
@@ -498,6 +511,35 @@ function test_proto.dissector(tvbuf,pktinfo,root)
-- verifyFields("basic.GUID", guid_match_fields)
+----------------------------------------
+ testing(OTHER, "tree:add ipv6")
+
+ local tvb = ByteArray.new("20010db8 00000000 0000ff00 00428329"):tvb("IPv6")
+ local IPv6 = testfield.basic.IPv6
+ local ipv6_match_fields = {}
+
+ execute ("ipv6", pcall (callTreeAdd, tree, IPv6, tvb:range(0,16)))
+ addMatchFields(ipv6_match_fields, Address.ipv6('2001:0db8:0000:0000:0000:ff00:0042:8329'))
+
+ verifyFields("basic.IPv6", ipv6_match_fields)
+
+----------------------------------------
+ testing(OTHER, "tree:add ipv4")
+
+ local tvb = ByteArray.new("7f000001"):tvb("IPv4")
+ local IPv4 = testfield.basic.IPv4
+ local ipv4_match_fields = {}
+
+ execute ("ipv4", pcall (callTreeAdd, tree, IPv4, tvb:range(0,4)))
+ addMatchFields(ipv4_match_fields, Address.ip('127.0.0.1'))
+
+ -- TODO: currently, tree:add_le only works for numeric values, not IPv4
+ -- addresses. Test this in the future.
+
+ -- execute ("ipv4", pcall (callTreeAddLE, tree, IPv4, tvb:range(0,4)))
+ -- addMatchFields(ipv4_match_fields, Address.ip('1.0.0.127'))
+
+ verifyFields("basic.IPv4", ipv4_match_fields)
----------------------------------------
testing(OTHER, "tree:add_packet_field Bytes")