forked from snabbco/snabb
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework Dockerfile so that it installs code in a more useful place, much easier for reuse. Rework tests to be more standalone and work against installed version. Signed-off-by: Justin Cormack <justin@specialbusservice.com>
- Loading branch information
1 parent
24f7789
commit b85382d
Showing
13 changed files
with
99 additions
and
21 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
FROM alpine:3.4 | ||
|
||
RUN apk update && apk add luajit strace | ||
RUN apk update && apk add luajit luajit-dev strace && mkdir -p /usr/share/lua/5.1 | ||
|
||
COPY . . | ||
COPY syscall.lua /usr/share/lua/5.1/ | ||
COPY syscall /usr/share/lua/5.1/syscall/ | ||
|
||
ENTRYPOINT ["luajit"] |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
sut: | ||
build: . | ||
command: test/test.lua | ||
command: /test/test.lua | ||
volumes: | ||
- ./test:/test |
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,81 @@ | ||
-- misc helper functions | ||
|
||
local require, error, assert, tonumber, tostring, | ||
setmetatable, pairs, ipairs, unpack, rawget, rawset, | ||
pcall, type, table, string, math = | ||
require, error, assert, tonumber, tostring, | ||
setmetatable, pairs, ipairs, unpack, rawget, rawset, | ||
pcall, type, table, string, math | ||
|
||
local debug, collectgarbage = require "debug", collectgarbage | ||
|
||
local ffi = require "ffi" | ||
local bit = require "bit" | ||
|
||
local h = {} | ||
|
||
-- generic assert helper, mainly for tests | ||
function h.assert(cond, err, ...) | ||
if not cond then | ||
error(tostring(err or "unspecified error")) -- annoyingly, assert does not call tostring! | ||
end | ||
collectgarbage("collect") -- force gc, to test for bugs | ||
if type(cond) == "function" then return cond, err, ... end | ||
if cond == true then return ... end | ||
return cond, ... | ||
end | ||
|
||
-- endian conversion | ||
if ffi.abi("be") then -- nothing to do | ||
function h.htonl(b) return b end | ||
function h.htons(b) return b end | ||
function h.convle32(b) return bit.bswap(b) end -- used by file system capabilities, always stored as le | ||
else | ||
function h.htonl(b) return bit.bswap(b) end | ||
function h.htons(b) return bit.rshift(bit.bswap(b), 16) end | ||
function h.convle32(b) return b end -- used by file system capabilities, always stored as le | ||
end | ||
h.ntohl = h.htonl -- reverse is the same | ||
h.ntohs = h.htons -- reverse is the same | ||
|
||
function h.octal(s) return tonumber(s, 8) end | ||
local octal = h.octal | ||
|
||
function h.split(delimiter, text) | ||
if delimiter == "" then return {text} end | ||
if #text == 0 then return {} end | ||
local list = {} | ||
local pos = 1 | ||
while true do | ||
local first, last = text:find(delimiter, pos) | ||
if first then | ||
list[#list + 1] = text:sub(pos, first - 1) | ||
pos = last + 1 | ||
else | ||
list[#list + 1] = text:sub(pos) | ||
break | ||
end | ||
end | ||
return list | ||
end | ||
|
||
function h.trim(s) -- TODO should replace underscore with space | ||
return (s:gsub("^%s*(.-)%s*$", "%1")) | ||
end | ||
|
||
local split, trim = h.split, h.trim | ||
|
||
h.divmod = function(a, b) | ||
return math.floor(a / b), a % b | ||
end | ||
|
||
h.booltoc = setmetatable({ | ||
[0] = 0, | ||
[1] = 1, | ||
[false] = 0, | ||
[true] = 1, | ||
}, {__call = function(tb, arg) return tb[arg or 0] end}) -- allow nil as false | ||
|
||
function h.ctobool(i) return tonumber(i) ~= 0 end | ||
|
||
return h |
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
File renamed without changes.
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
File renamed without changes.
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