Skip to content

Commit

Permalink
lua: Fix tests to work in strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
vmg committed Apr 1, 2016
1 parent 818eac9 commit a833369
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
7 changes: 3 additions & 4 deletions tests/lua/test_clang.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require("test_helper")

TestClang = {}
local suite = require("test_helper")
local TestClang = {}

function TestClang:test_probe_read1()
local text = [[
Expand Down Expand Up @@ -329,4 +328,4 @@ function TestClang:test_syntax_error()
BPF, {text=[[int failure(void *ctx) { if (); return 0; }]]})
end

os.exit(LuaUnit.run())
suite("TestClang", TestClang)
7 changes: 4 additions & 3 deletions tests/lua/test_dump.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
require("test_helper")
local suite = require("test_helper")
local TestDump = {}

function test_dump_func()
function TestDump:test_dump_func()
local raw = "\xb7\x00\x00\x00\x01\x00\x00\x00\x95\x00\x00\x00\x00\x00\x00\x00"
local b = BPF:new{text=[[int entry(void) { return 1; }]]}
assert_equals(b:dump_func("entry"), raw)
end

os.exit(LuaUnit.run())
suite("TestDump", TestDump)
10 changes: 8 additions & 2 deletions tests/lua/test_helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ USE_EXPECTED_ACTUAL_IN_ASSERT_EQUALS = false
EXPORT_ASSERT_TO_GLOBALS = true
require("luaunit")

BCC = require("bcc.init")
BPF = BCC.BPF
rawset(_G, "BCC", require("bcc.init"))
rawset(_G, "BPF", BCC.BPF)

log.enabled = false

return function (name, f)
rawset(_G, name, f)
os.exit(LuaUnit.run())
end
7 changes: 3 additions & 4 deletions tests/lua/test_uprobes.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
require("test_helper")
local suite = require("test_helper")
local ffi = require("ffi")
local TestUprobes = {}

ffi.cdef[[
int getpid(void);
void malloc_stats(void);
]]

TestUprobes = {}

function TestUprobes:test_simple_library()
local text = [[
#include <uapi/linux/ptrace.h>
Expand Down Expand Up @@ -68,4 +67,4 @@ function TestUprobes:teardown()
BPF.cleanup_probes()
end

os.exit(LuaUnit.run())
suite("TestUprobes", TestUprobes)

0 comments on commit a833369

Please sign in to comment.