diff --git a/tests/Makefile b/tests/Makefile index dc41837..506162a 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,8 +1,20 @@ PATH := ../deps/luajit/usr/local/bin:$(PATH) +TEST_SAVEFILE_URL='https://github.com/Igalia/pflua-test/blob/master/savefiles/wingolog.org.pcap?raw=true' +TEST_SAVEFILE=data/wingolog.pcap +PFLUA_QUICKCHECK=../tools/pflua-quickcheck all: @true -check: +check: quickcheck ./test-matches data - #$(MAKE) -C pfquickcheck # Fix NaN bug and luajit setup for travis-ci + +$(TEST_SAVEFILE): + wget --output-document $@ $(TEST_SAVEFILE_URL) + +quickcheck: $(TEST_SAVEFILE) + # $(PFLUA_QUICKCHECK) properties/opt_eq_unopt $(TEST_SAVEFILE) test-filters # Fix NaN bug + # $(PFLUA_QUICKCHECK) properties/opt_eq_unopt $(TEST_SAVEFILE) # Fix NaN bug + $(PFLUA_QUICKCHECK) properties/pflua_math_eq_libpcap_math + +.SERIAL: all diff --git a/tests/pfquickcheck/Makefile b/tests/pfquickcheck/Makefile deleted file mode 100644 index 6d2243e..0000000 --- a/tests/pfquickcheck/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -check: quickcheck - -TEST_SAVEFILE_URL='https://github.com/Igalia/pflua-test/blob/master/savefiles/wingolog.org.pcap?raw=true' -TEST_SAVEFILE=../data/wingolog.pcap - -$(TEST_SAVEFILE): - wget --output-document $@ $(TEST_SAVEFILE_URL) - -quickcheck: $(TEST_SAVEFILE) - ./pflua-quickcheck properties/opt_eq_unopt $(TEST_SAVEFILE) test-filters - ./pflua-quickcheck properties/opt_eq_unopt $(TEST_SAVEFILE) - ./pflua-quickcheck --iterations=50 properties/pflua_math_eq_libpcap_math - -.SERIAL: all diff --git a/tests/pfquickcheck/pfcompile.lua b/tests/pfquickcheck/pfcompile.lua index 854bb53..10a2047 100644 --- a/tests/pfquickcheck/pfcompile.lua +++ b/tests/pfquickcheck/pfcompile.lua @@ -1,6 +1,5 @@ #!/usr/bin/env luajit module(..., package.seeall) -package.path = package.path .. ";../../src/?.lua" local backend = require("pf.backend") diff --git a/tests/pfquickcheck/pflang_math.lua b/tests/pfquickcheck/pflang_math.lua index e32f963..ac1097f 100644 --- a/tests/pfquickcheck/pflang_math.lua +++ b/tests/pfquickcheck/pflang_math.lua @@ -1,12 +1,11 @@ #!/usr/bin/env luajit module(..., package.seeall) -package.path = package.path .. ";../../src/?.lua" local io = require("io") local codegen = require("pf.backend") local expand = require("pf.expand") local parse = require("pf.parse") -local pfcompile = require("pfcompile") +local pfcompile = require("pfquickcheck.pfcompile") local libpcap = require("pf.libpcap") local bpf = require("pf.bpf") local utils = require("pf.utils") diff --git a/tests/pfquickcheck/properties/fail.lua b/tests/properties/fail.lua similarity index 100% rename from tests/pfquickcheck/properties/fail.lua rename to tests/properties/fail.lua diff --git a/tests/pfquickcheck/properties/opt_eq_unopt.lua b/tests/properties/opt_eq_unopt.lua similarity index 80% rename from tests/pfquickcheck/properties/opt_eq_unopt.lua rename to tests/properties/opt_eq_unopt.lua index 3bdd32c..2a77179 100644 --- a/tests/pfquickcheck/properties/opt_eq_unopt.lua +++ b/tests/properties/opt_eq_unopt.lua @@ -1,7 +1,7 @@ #!/usr/bin/env luajit -- -*- lua -*- module(..., package.seeall) -package.path = package.path .. ";../../src/?.lua" +package.path = package.path .. ";../?.lua;../../src/?.lua" local ffi = require("ffi") local parse = require("pf.parse") @@ -12,20 +12,8 @@ local codegen = require('pf.backend') local utils = require('pf.utils') local pp = utils.pp -local pflua_ir = require('pflua_ir') -local pfcompile = require('pfcompile') - -local function load_packets(file) - local header, ptr, ptr_end = savefile.open_and_mmap(file) - local ret = {} - while ptr < ptr_end do - local record = ffi.cast("struct pcap_record *", ptr) - local packet = ffi.cast("unsigned char *", record + 1) - table.insert(ret, { packet=packet, len=record.incl_len }) - ptr = packet + record.incl_len - end - return ret -end +local pflua_ir = require('pfquickcheck.pflua_ir') +local pfcompile = require('pfquickcheck.pfcompile') local function load_filters(file) local ret = {} @@ -82,7 +70,7 @@ function handle_prop_args(prop_args) end local capture, filter_list = prop_args[1], prop_args[2] - local packets = load_packets(capture) + local packets = savefile.load_packets(capture) local filters if filter_list then filters = load_filters(filter_list) diff --git a/tests/pfquickcheck/properties/pflua_math_eq_libpcap_math.lua b/tests/properties/pflua_math_eq_libpcap_math.lua similarity index 79% rename from tests/pfquickcheck/properties/pflua_math_eq_libpcap_math.lua rename to tests/properties/pflua_math_eq_libpcap_math.lua index d5be6a0..4ceea95 100644 --- a/tests/pfquickcheck/properties/pflua_math_eq_libpcap_math.lua +++ b/tests/properties/pflua_math_eq_libpcap_math.lua @@ -1,7 +1,8 @@ #!/usr/bin/env luajit -- -*- lua -*- module(..., package.seeall) -local pflang_math = require("pflang_math") +package.path = package.path .. ";../?.lua;../../src/?.lua" +local pflang_math = require("pfquickcheck.pflang_math") function property() arithmetic_expr = table.concat(pflang_math.PflangArithmetic(), ' ') diff --git a/tests/pfquickcheck/properties/trivial.lua b/tests/properties/trivial.lua similarity index 100% rename from tests/pfquickcheck/properties/trivial.lua rename to tests/properties/trivial.lua diff --git a/tests/pfquickcheck/pflua-quickcheck b/tools/pflua-quickcheck similarity index 80% rename from tests/pfquickcheck/pflua-quickcheck rename to tools/pflua-quickcheck index bf978d9..f100b8b 100755 --- a/tests/pfquickcheck/pflua-quickcheck +++ b/tools/pflua-quickcheck @@ -1,6 +1,6 @@ #!/usr/bin/env luajit -- -*- lua -*- -package.path = package.path .. ";../../src/?.lua" +package.path = package.path .. ";../src/?.lua" local quickcheck = require('pf.quickcheck')