-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test framework, docs and multi-iovec fixes #141
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
local lib = require("core.lib") | ||
local packet = require "core.packet" | ||
local link = require("core.link") | ||
local config = require("core.config") | ||
local app = require("core.app") | ||
local basic_apps = require("apps.basic.basic_apps") | ||
local Intel82599 = require "apps.intel.intel_app".Intel82599 | ||
|
||
|
||
local PCIdevA, PCIdevB = '0000:05:00.0', '0000:8a:00.0' | ||
|
||
|
||
local function _unhex(s) | ||
local d = {} | ||
for b in s:gmatch('[0-9a-fA-F][0-9a-fA-F]') do | ||
d[#d+1] = tonumber(b, 16) | ||
end | ||
return string.char(unpack(d)) | ||
end | ||
|
||
local function pad(s, n) | ||
if not n then return s end | ||
return (s..('\0'):rep(n)):sub(1, n) | ||
end | ||
|
||
local function make_packet(s, padlen) | ||
return packet.from_data( | ||
_unhex('FF:FF:FF:FF:FF:FF').. | ||
_unhex('52:54:00:01:01:01').. | ||
_unhex('08:00').. | ||
pad(s, padlen).. | ||
_unhex('00 00 00 00') | ||
) | ||
end | ||
|
||
local function make_split_packet(s, padlen) | ||
return packet.from_data( | ||
_unhex('FF:FF:FF:FF:FF:FF').. | ||
_unhex('52:54:00:01:01:01').. | ||
_unhex('08:00'), | ||
pad(s, padlen).. | ||
_unhex('00 00 00 00') | ||
) | ||
end | ||
|
||
local function _set_dst(p, dst) | ||
if #dst ~= 6 then dst = _unhex(dst) end | ||
assert(#dst==6, "wrong address length") | ||
packet.fill_data(p, dst, 0) | ||
return p | ||
end | ||
|
||
local function _set_src(p, src) | ||
if #src ~= 6 then src = _unhex(src) end | ||
assert(#src==6, "wrong address length") | ||
packet.fill_data(p, src, 6) | ||
return p | ||
end | ||
|
||
|
||
return { | ||
sf_to_sf = { | ||
__setup = function () | ||
local c = config.new() | ||
config.app(c, 'source1', basic_apps.Join) | ||
-- config.app(c, 'source2', basic_apps.Source) | ||
config.app(c, 'nicA', Intel82599, ([[{pciaddr='%s'}]]):format(PCIdevA)) | ||
config.app(c, 'nicB', Intel82599, ([[{pciaddr='%s'}]]):format(PCIdevB)) | ||
config.app(c, 'sink', basic_apps.Classifier) | ||
config.link(c, 'source1.out -> nicA.rx') | ||
-- config.link(c, 'source2.out -> nicB.rx') | ||
config.link(c, 'nicA.tx -> sink.in1') | ||
config.link(c, 'nicB.tx -> sink.in2') | ||
app.configure(c) | ||
end, | ||
|
||
t = { | ||
single_iovec = { | ||
broadcast = function () | ||
local p = make_packet('some payload', 42) | ||
_set_dst(p, 'FF:FF:FF:FF:FF:FF') | ||
app.app_table.sink:setPatterns({same=packet.tostring(p)}) | ||
link.transmit(app.app_table.source1.output.out, p) | ||
app.main({duration = 1, report={showlinks=false}}) | ||
assert(app.app_table.sink:repSequence() == 'in2:same') | ||
end, | ||
unicast = function () | ||
local p = make_packet('some payload', 42) | ||
_set_dst(p, '52:54:00:01:01:01') | ||
app.app_table.sink:setPatterns({same=packet.tostring(p)}) | ||
link.transmit(app.app_table.source1.output.out, p) | ||
app.main({duration = 1, report={showlinks=false}}) | ||
assert(app.app_table.sink:repSequence() == 'in2:same') | ||
end, | ||
}, | ||
|
||
split_header = { | ||
broadcast = function () | ||
local p = make_split_packet('some payload', 42) | ||
_set_dst(p, 'FF:FF:FF:FF:FF:FF') | ||
app.app_table.sink:setPatterns({same=packet.tostring(p)}) | ||
link.transmit(app.app_table.source1.output.out, p) | ||
app.main({duration = 1, report={showlinks=false}}) | ||
assert(app.app_table.sink:repSequence() == 'in2:same') | ||
end, | ||
unicast = function () | ||
local p = make_split_packet('some payload', 42) | ||
_set_dst(p, '52:54:00:01:01:01') | ||
app.app_table.sink:setPatterns({same=packet.tostring(p)}) | ||
link.transmit(app.app_table.source1.output.out, p) | ||
app.main({duration = 1, report={showlinks=false}}) | ||
assert(app.app_table.sink:repSequence() == 'in2:same') | ||
end, | ||
}, | ||
}, | ||
}, | ||
|
||
sf_to_vf = { | ||
__setup = function () | ||
local c = config.new() | ||
config.app(c, 'source1', basic_apps.Join) | ||
config.app(c, 'nicAs', Intel82599, ([[{ | ||
-- Single App on NIC A | ||
pciaddr = '%s', | ||
macaddr = '52:54:00:01:01:01', | ||
}]]):format(PCIdevA)) | ||
config.app(c, 'nicBm0', Intel82599, ([[{ | ||
-- first VF on NIC B | ||
pciaddr = '%s', | ||
vmdq = true, | ||
macaddr = '52:54:00:02:02:02', | ||
}]]):format(PCIdevB)) | ||
config.app(c, 'nicBm1', Intel82599, ([[{ | ||
-- second VF on NIC B | ||
pciaddr = '%s', | ||
vmdq = true, | ||
macaddr = '52:54:00:03:03:03', | ||
}]]):format(PCIdevB)) | ||
config.app(c, 'sink', basic_apps.Classifier) | ||
config.link(c, 'source1.out -> nicAs.rx') | ||
config.link(c, 'nicAs.tx -> sink.in1') | ||
config.link(c, 'nicBm0.tx -> sink.in2') | ||
config.link(c, 'nicBm1.tx -> sink.in3') | ||
app.configure(c) | ||
end, | ||
t = { | ||
single_iovec = { | ||
broadcast = function () | ||
local p = make_packet('broadcast content', 42) | ||
_set_dst(p, 'FF:FF:FF:FF:FF:FF') | ||
app.app_table.sink:setPatterns({same=packet.tostring(p)}) | ||
link.transmit(app.app_table.source1.output.out, p) | ||
app.main({duration = 1, report={showlinks=false}}) | ||
assert(app.app_table.sink:repSequence() == 'in2:same,in3:same') | ||
end, | ||
unicast = function () | ||
local p = make_packet('some payload', 42) | ||
_set_dst(p, '52:54:00:02:02:02') | ||
app.app_table.sink:setPatterns({same=packet.tostring(p)}) | ||
link.transmit(app.app_table.source1.output.out, p) | ||
app.main({duration = 1, report={showlinks=false}}) | ||
assert(app.app_table.sink:repSequence() == 'in2:same') | ||
end, | ||
}, | ||
split_header = { | ||
broadcast = function () | ||
local p = make_split_packet('broadcast content', 42) | ||
_set_dst(p, 'FF:FF:FF:FF:FF:FF') | ||
app.app_table.sink:setPatterns({same=packet.tostring(p)}) | ||
link.transmit(app.app_table.source1.output.out, p) | ||
app.main({duration = 1, report={showlinks=false}}) | ||
assert(app.app_table.sink:repSequence() == 'in2:same,in3:same') | ||
end, | ||
unicast = function () | ||
local p = make_split_packet('some payload', 42) | ||
_set_dst(p, '52:54:00:02:02:02') | ||
app.app_table.sink:setPatterns({same=packet.tostring(p)}) | ||
link.transmit(app.app_table.source1.output.out, p) | ||
app.main({duration = 1, report={showlinks=false}}) | ||
assert(app.app_table.sink:repSequence() == 'in2:same') | ||
end, | ||
}, | ||
|
||
|
||
}, | ||
}, | ||
|
||
local_A_dev = { | ||
Broadcast = function () | ||
local p = packet.from_data( | ||
_unhex('FF:FF:FF:FF:FF:FF').. | ||
_unhex('52:54:00:01:01:01').. | ||
_unhex('08:00').. | ||
'this is the payload'.. | ||
_unhex('00:00:00:00') | ||
) | ||
end, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what's with all the new naming conventions in the code base _foo, __bar, baz_mt, etc? can't we just call things foo, bar, and baz? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh, right... just to clarify a little:
_foo()
are private. typically locals... Lua doesn't care about that convention, but i've used it at some places to make it evident that these aren't functions that can be called somewhere else. In this specific snippet there are several local functions that are created just for the tests. if they're too ugly i'm not against removing the leading_
.__setup()
is a function that runs before each other entry on the same group.sf_to_vf
seems shorter thanSingleFunctionToVirtualFunction
. Not sure which looks better in the report...xxx_mt
are usually metatables, but i'm not sure i've used that too frequently here...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't
^__[a-z]
and^_[a-z]
reserved in Lua? I vaguely remember Roberto saying something on that matter...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to http://www.lua.org/manual/5.1/manual.html#2.1 only those with uppercase after the
_
, like_VERSION
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right! Thank you for clarification (and sorry for not looking it up).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I simply observe that our code base has a rich mix of different programming styles :-) and it will be an interesting exercise to make it more consistent over time. However I reckon that now the important thing is to add the functionality/tests that we need and not worry too much about minor consistency. It will be fun to fight/edit it later :).