diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-03 12:19:48 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-03 12:19:48 +0000 |
commit | f1b297d5138e6415d422a1a8d67ece351112646a (patch) | |
tree | f5b70198c24e2d37ff2404bb1f613f3c7fcd0348 /test | |
parent | 92d4dde3cf20e52bad9fb2d17cf0d059c8f68fef (diff) | |
download | rspamd-f1b297d5138e6415d422a1a8d67ece351112646a.tar.gz rspamd-f1b297d5138e6415d422a1a8d67ece351112646a.zip |
[Feature] Improve tests for siphash
- Add fuzz tests
- Add variable length input tests
- Check sanity of siphash implementation on start
Diffstat (limited to 'test')
-rw-r--r-- | test/lua/unit/siphash.lua | 67 |
1 files changed, 55 insertions, 12 deletions
diff --git a/test/lua/unit/siphash.lua b/test/lua/unit/siphash.lua index 1c773b45e..398060847 100644 --- a/test/lua/unit/siphash.lua +++ b/test/lua/unit/siphash.lua @@ -4,26 +4,69 @@ context("Siphash check functions", function() local ffi = require("ffi") ffi.cdef[[ void rspamd_cryptobox_init (void); - size_t siphash24_test(bool generic); + size_t siphash24_test(bool generic, size_t niters, size_t len); + bool siphash24_fuzz (size_t cycles); double rspamd_get_ticks (void); ]] - + ffi.C.rspamd_cryptobox_init() - - test("Siphash test reference vectors", function() + + test("Siphash test reference vectors (1KB)", function() + local t1 = ffi.C.rspamd_get_ticks() + local res = ffi.C.siphash24_test(true, 100000, 1024) + local t2 = ffi.C.rspamd_get_ticks() + + print("Refrence siphash (1KB): " .. tostring(t2 - t1) .. " sec") + assert_not_equal(res, 0) + end) + test("Siphash test optimized vectors (1KB)", function() + local t1 = ffi.C.rspamd_get_ticks() + local res = ffi.C.siphash24_test(false, 100000, 1024) + local t2 = ffi.C.rspamd_get_ticks() + + print("Optimized siphash (1KB): " .. tostring(t2 - t1) .. " sec") + assert_not_equal(res, 0) + end) + test("Siphash test reference vectors (5B)", function() + local t1 = ffi.C.rspamd_get_ticks() + local res = ffi.C.siphash24_test(true, 1000000, 5) + local t2 = ffi.C.rspamd_get_ticks() + + print("Refrence siphash (5B): " .. tostring(t2 - t1) .. " sec") + assert_not_equal(res, 0) + end) + test("Siphash test optimized vectors (5B)", function() + local t1 = ffi.C.rspamd_get_ticks() + local res = ffi.C.siphash24_test(false, 1000000, 5) + local t2 = ffi.C.rspamd_get_ticks() + + print("Optimized siphash (5B): " .. tostring(t2 - t1) .. " sec") + assert_not_equal(res, 0) + end) + test("Siphash test reference vectors (50B)", function() local t1 = ffi.C.rspamd_get_ticks() - local res = ffi.C.siphash24_test(true) + local res = ffi.C.siphash24_test(true, 1000000, 50) local t2 = ffi.C.rspamd_get_ticks() - - print("Refrence siphash: " .. tostring(t2 - t1) .. " sec") + + print("Refrence siphash (50B): " .. tostring(t2 - t1) .. " sec") assert_not_equal(res, 0) end) - test("Siphash test optimized vectors", function() + test("Siphash test optimized vectors (50B)", function() local t1 = ffi.C.rspamd_get_ticks() - local res = ffi.C.siphash24_test(false) + local res = ffi.C.siphash24_test(false, 1000000, 50) local t2 = ffi.C.rspamd_get_ticks() - - print("Optimized siphash: " .. tostring(t2 - t1) .. " sec") + + print("Optimized siphash (50B): " .. tostring(t2 - t1) .. " sec") + assert_not_equal(res, 0) + end) + test("Siphash fuzz test (1000 iters)", function() + local res = ffi.C.siphash24_fuzz(1000) + + assert_not_equal(res, 0) + end) + test("Siphash fuzz test (10000 iters)", function() + local res = ffi.C.siphash24_fuzz(10000) + assert_not_equal(res, 0) end) -end)
\ No newline at end of file +end) |