Add. Test for memory leaks
This commit is contained in:
parent
f36ef258ec
commit
cf3203eae3
74
rockspecs/lua-curl-0.3.8-2.rockspec
Normal file
74
rockspecs/lua-curl-0.3.8-2.rockspec
Normal file
@ -0,0 +1,74 @@
|
||||
package = "Lua-cURL"
|
||||
version = "0.3.8-2"
|
||||
|
||||
source = {
|
||||
url = "https://github.com/Lua-cURL/Lua-cURLv3/archive/v0.3.8.zip",
|
||||
dir = "Lua-cURLv3-0.3.8",
|
||||
}
|
||||
|
||||
description = {
|
||||
summary = "Lua binding to libcurl",
|
||||
detailed = [[
|
||||
]],
|
||||
homepage = "https://github.com/Lua-cURL",
|
||||
license = "MIT/X11"
|
||||
}
|
||||
|
||||
dependencies = {
|
||||
"lua >= 5.1, < 5.4"
|
||||
}
|
||||
|
||||
external_dependencies = {
|
||||
platforms = {
|
||||
windows = {
|
||||
CURL = {
|
||||
header = "curl/curl.h",
|
||||
library = "libcurl",
|
||||
}
|
||||
};
|
||||
unix = {
|
||||
CURL = {
|
||||
header = "curl/curl.h",
|
||||
-- library = "curl",
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
build = {
|
||||
copy_directories = {'doc', 'examples', 'test'},
|
||||
|
||||
type = "builtin",
|
||||
|
||||
platforms = {
|
||||
windows = { modules = {
|
||||
lcurl = {
|
||||
libraries = {"libcurl", "ws2_32"},
|
||||
}
|
||||
}},
|
||||
unix = { modules = {
|
||||
lcurl = {
|
||||
libraries = {"curl"},
|
||||
}
|
||||
}}
|
||||
},
|
||||
|
||||
modules = {
|
||||
["cURL" ] = "src/lua/cURL.lua",
|
||||
["cURL.safe" ] = "src/lua/cURL/safe.lua",
|
||||
["cURL.utils" ] = "src/lua/cURL/utils.lua",
|
||||
["cURL.impl.cURL" ] = "src/lua/cURL/impl/cURL.lua",
|
||||
|
||||
lcurl = {
|
||||
sources = {
|
||||
"src/l52util.c", "src/lceasy.c", "src/lcerror.c",
|
||||
"src/lchttppost.c", "src/lcurl.c", "src/lcutils.c",
|
||||
"src/lcmulti.c", "src/lcshare.c", "src/lcmime.c",
|
||||
},
|
||||
incdirs = { "$(CURL_INCDIR)" },
|
||||
libdirs = { "$(CURL_LIBDIR)" }
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,16 @@ local fname = "./test.download"
|
||||
|
||||
local utils = require "utils"
|
||||
|
||||
local function weak_ptr(val)
|
||||
return setmetatable({value = val},{__mode = 'v'})
|
||||
end
|
||||
|
||||
local function gc_collect()
|
||||
for i = 1, 5 do
|
||||
collectgarbage("collect")
|
||||
end
|
||||
end
|
||||
|
||||
-- Bug. libcurl 7.56.0 does not add `Content-Type: text/plain`
|
||||
local text_plain = utils.is_curl_eq(7,56,0) and 'test/plain' or 'text/plain'
|
||||
|
||||
@ -213,6 +223,38 @@ end
|
||||
|
||||
end
|
||||
|
||||
local _ENV = TEST_CASE'multi memory leak' if ENABLE then
|
||||
|
||||
local m
|
||||
|
||||
function teardown()
|
||||
if m then m:close() end
|
||||
m = nil
|
||||
end
|
||||
|
||||
function test_basic()
|
||||
local ptr do
|
||||
local multi = assert(scurl.multi())
|
||||
ptr = weak_ptr(multi)
|
||||
end
|
||||
gc_collect()
|
||||
|
||||
assert_nil(ptr.value)
|
||||
end
|
||||
|
||||
function test_socket_action()
|
||||
local ptr do
|
||||
local multi = assert(scurl.multi())
|
||||
multi:setopt_socketfunction(function() end)
|
||||
ptr = weak_ptr(multi)
|
||||
end
|
||||
gc_collect()
|
||||
|
||||
assert_nil(ptr.value)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local _ENV = TEST_CASE'form' if ENABLE then
|
||||
|
||||
local post
|
||||
|
Loading…
x
Reference in New Issue
Block a user