File: 44-resolvers-gc.lua

package info (click to toggle)
lua-cqueues 20200726-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,848 kB
  • sloc: ansic: 23,623; sh: 2,984; makefile: 24
file content (33 lines) | stat: -rwxr-xr-x 549 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
_=[[
	. "${0%%/*}/regress.sh"
	exec runlua -j- "$0" "$@"
]]

require"regress".export".*"

local resolvers = require"cqueues.dns.resolvers"

local function caughtleak()
	local pool = resolvers.stub()

	local gotleak

	pool:onleak(function () gotleak = true end)
	pool:get()

	for i=1,10 do
		collectgarbage"collect"
	end

	return gotleak
end

check(caughtleak(), "resolver leak not detected")

if jit then
	_VERSION = "Lua 5.2" -- pretend that we support __gc on tables
	check(not caughtleak(), "expected not to catch leak")
end

say("OK")