Commit a833369b authored by Vicent Marti's avatar Vicent Marti

lua: Fix tests to work in strict mode

parent 818eac98
require("test_helper") local suite = require("test_helper")
local TestClang = {}
TestClang = {}
function TestClang:test_probe_read1() function TestClang:test_probe_read1()
local text = [[ local text = [[
...@@ -329,4 +328,4 @@ function TestClang:test_syntax_error() ...@@ -329,4 +328,4 @@ function TestClang:test_syntax_error()
BPF, {text=[[int failure(void *ctx) { if (); return 0; }]]}) BPF, {text=[[int failure(void *ctx) { if (); return 0; }]]})
end end
os.exit(LuaUnit.run()) suite("TestClang", TestClang)
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 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; }]]} local b = BPF:new{text=[[int entry(void) { return 1; }]]}
assert_equals(b:dump_func("entry"), raw) assert_equals(b:dump_func("entry"), raw)
end end
os.exit(LuaUnit.run()) suite("TestDump", TestDump)
...@@ -12,6 +12,12 @@ USE_EXPECTED_ACTUAL_IN_ASSERT_EQUALS = false ...@@ -12,6 +12,12 @@ USE_EXPECTED_ACTUAL_IN_ASSERT_EQUALS = false
EXPORT_ASSERT_TO_GLOBALS = true EXPORT_ASSERT_TO_GLOBALS = true
require("luaunit") require("luaunit")
BCC = require("bcc.init") rawset(_G, "BCC", require("bcc.init"))
BPF = BCC.BPF rawset(_G, "BPF", BCC.BPF)
log.enabled = false log.enabled = false
return function (name, f)
rawset(_G, name, f)
os.exit(LuaUnit.run())
end
require("test_helper") local suite = require("test_helper")
local ffi = require("ffi") local ffi = require("ffi")
local TestUprobes = {}
ffi.cdef[[ ffi.cdef[[
int getpid(void); int getpid(void);
void malloc_stats(void); void malloc_stats(void);
]] ]]
TestUprobes = {}
function TestUprobes:test_simple_library() function TestUprobes:test_simple_library()
local text = [[ local text = [[
#include <uapi/linux/ptrace.h> #include <uapi/linux/ptrace.h>
...@@ -68,4 +67,4 @@ function TestUprobes:teardown() ...@@ -68,4 +67,4 @@ function TestUprobes:teardown()
BPF.cleanup_probes() BPF.cleanup_probes()
end end
os.exit(LuaUnit.run()) suite("TestUprobes", TestUprobes)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment