Remove unused test files for lua-resty-signal

This commit is contained in:
Théophile Diot 2025-01-16 10:27:39 +01:00
parent 1590573968
commit e918e26c8a
No known key found for this signature in database
GPG key ID: FA995104A0BA376A
4 changed files with 0 additions and 390 deletions

View file

@ -1,32 +0,0 @@
package t::TestKiller;
use v5.10.1;
use Test::Nginx::Socket::Lua -Base;
add_block_preprocessor(sub {
my $block = shift;
my $http_config = $block->http_config // '';
my $init_by_lua_block = $block->init_by_lua_block // 'require "resty.core"';
$http_config .= <<_EOC_;
lua_package_path "./lib/?.lua;../lua-resty-core/lib/?.lua;../lua-resty-lrucache/lib/?.lua;;";
lua_package_cpath "./?.so;;";
init_by_lua_block {
$init_by_lua_block
}
_EOC_
$block->set_value("http_config", $http_config);
if (!defined $block->error_log) {
$block->set_value("no_error_log", "[error]");
}
if (!defined $block->request) {
$block->set_value("request", "GET /t");
}
});
1;

View file

@ -1,207 +0,0 @@
# vi:ft=
use lib '.';
use t::TestKiller;
plan tests => 3 * blocks();
no_long_string();
#no_diff();
run_tests();
__DATA__
=== TEST 1: returns an error if signal is unknown
--- config
location = /t {
content_by_lua_block {
local resty_signal = require "resty.signal"
local ok, err = resty_signal.kill(pid, "FOO")
if not ok then
ngx.say("failed to send FOO signal: ", err)
return
end
ngx.say("ok")
}
}
--- response_body
failed to send FOO signal: unknown signal name
=== TEST 2: send NONE to a non-existing process
--- config
location = /t {
content_by_lua_block {
local resty_signal = require "resty.signal"
local say = ngx.say
local ngx_pipe = require "ngx.pipe"
local proc = assert(ngx_pipe.spawn("echo ok"))
local pid = assert(proc:pid())
assert(proc:wait())
local ok, err = resty_signal.kill(pid, "NONE")
if not ok then
ngx.say("failed to send NONE signal: ", err)
return
end
ngx.say("ok")
}
}
--- response_body
failed to send NONE signal: No such process
=== TEST 3: send TERM to a non-existing process
--- config
location = /t {
content_by_lua_block {
local resty_signal = require "resty.signal"
local say = ngx.say
local ngx_pipe = require "ngx.pipe"
local proc = assert(ngx_pipe.spawn("echo ok"))
local pid = assert(proc:pid())
assert(proc:wait())
local ok, err = resty_signal.kill(pid, "TERM")
if not ok then
ngx.say("failed to send TERM signal: ", err)
return
end
ngx.say("ok")
}
}
--- response_body
failed to send TERM signal: No such process
=== TEST 4: send NONE to an existing process
--- config
location = /t {
content_by_lua_block {
local resty_signal = require "resty.signal"
local say = ngx.say
local ngx_pipe = require "ngx.pipe"
local proc = assert(ngx_pipe.spawn("echo ok"))
local pid = assert(proc:pid())
-- assert(proc:wait())
for i = 1, 2 do
ngx.say("i = ", i)
local ok, err = resty_signal.kill(pid, "NONE")
if not ok then
ngx.say("failed to send NONE signal: ", err)
return
end
end
ngx.say("ok")
}
}
--- response_body
i = 1
i = 2
ok
=== TEST 5: send TERM to an existing process
--- config
location = /t {
content_by_lua_block {
local resty_signal = require "resty.signal"
local say = ngx.say
local ngx_pipe = require "ngx.pipe"
local proc = assert(ngx_pipe.spawn("echo ok"))
local pid = assert(proc:pid())
-- assert(proc:wait())
for i = 1, 2 do
ngx.say("i = ", i)
local ok, err = resty_signal.kill(pid, "TERM")
if not ok then
ngx.say("failed to send TERM signal: ", err)
return
end
ngx.sleep(0.01)
end
ngx.say("ok")
}
}
--- response_body
i = 1
i = 2
failed to send TERM signal: No such process
=== TEST 6: send KILL to an existing process
--- config
location = /t {
content_by_lua_block {
local resty_signal = require "resty.signal"
local say = ngx.say
local ngx_pipe = require "ngx.pipe"
local proc = assert(ngx_pipe.spawn("echo ok"))
local pid = assert(proc:pid())
-- assert(proc:wait())
for i = 1, 2 do
ngx.say("i = ", i)
local ok, err = resty_signal.kill(pid, "KILL")
if not ok then
ngx.say("failed to send KILL signal: ", err)
return
end
ngx.sleep(0.01)
end
ngx.say("ok")
}
}
--- response_body
i = 1
i = 2
failed to send KILL signal: No such process
=== TEST 7: send TERM signal value, 15, directly to an existing process
--- config
location = /t {
content_by_lua_block {
local resty_signal = require "resty.signal"
local say = ngx.say
local ngx_pipe = require "ngx.pipe"
local proc = assert(ngx_pipe.spawn("echo ok"))
local pid = assert(proc:pid())
-- assert(proc:wait())
for i = 1, 2 do
ngx.say("i = ", i)
local ok, err = resty_signal.kill(pid, 15)
if not ok then
ngx.say("failed to send TERM signal: ", err)
return
end
ngx.sleep(0.01)
end
ngx.say("ok")
}
}
--- response_body
i = 1
i = 2
failed to send TERM signal: No such process

View file

@ -1,35 +0,0 @@
# vi:ft=
use lib '.';
use t::TestKiller;
plan tests => 3 * blocks();
no_long_string();
#no_diff();
run_tests();
__DATA__
=== TEST 1: failure to load librestysignal.so
--- config
location = /t {
content_by_lua_block {
local cpath = package.cpath
package.cpath = "/foo/?.so;/bar/?.so;"
local ok, perr = pcall(require, "resty.signal")
if not ok then
ngx.say(perr)
end
package.cpath = cpath
}
}
--- response_body
could not load librestysignal.so from the following paths:
/foo/librestysignal.so
/bar/librestysignal.so
--- no_error_log
[error]

View file

@ -1,116 +0,0 @@
# vi:ft=
use lib '.';
use t::TestKiller;
plan tests => 3 * blocks();
no_long_string();
#no_diff();
run_tests();
__DATA__
=== TEST 1: signals whose values are specified by POSIX
--- config
location = /t {
content_by_lua_block {
local resty_signal = require "resty.signal"
local ffi = require "ffi"
local say = ngx.say
local signum = resty_signal.signum
for i, signame in ipairs{ "ABRT", "ALRM", "HUP", "INT", "KILL",
"QUIT", "TERM", "TRAP", "BLAH" } do
say(signame, ": ", tostring(signum(signame)))
end
local linux_signals = {
NONE = 0,
HUP = 1,
INT = 2,
QUIT = 3,
ILL = 4,
TRAP = 5,
ABRT = 6,
BUS = 7,
FPE = 8,
KILL = 9,
USR1 = 10,
SEGV = 11,
USR2 = 12,
PIPE = 13,
ALRM = 14,
TERM = 15,
CHLD = 17,
CONT = 18,
STOP = 19,
TSTP = 20,
TTIN = 21,
TTOU = 22,
URG = 23,
XCPU = 24,
XFSZ = 25,
VTALRM = 26,
PROF = 27,
WINCH = 28,
IO = 29,
PWR = 30
}
local macosx_signals = {
HUP = 1,
INT = 2,
QUIT = 3,
ILL = 4,
TRAP = 5,
ABRT = 6,
EMT = 7,
FPE = 8,
KILL = 9,
BUS = 10,
SEGV = 11,
SYS = 12,
PIPE = 13,
ALRM = 14,
TERM = 15,
URG = 16,
STOP = 17,
TSTP = 18,
CONT = 19,
CHLD = 20,
TTIN = 21,
TTOU = 22,
IO = 23,
XCPU = 24,
XFSZ = 25,
VTALRM = 26,
PROF = 27,
WINCH = 28,
INFO = 29,
USR1 = 30,
USR2 = 31
}
if ffi.os == "Linux" then
for signame, num in pairs(linux_signals) do
assert(num == tonumber(signum(signame)))
end
elseif ffi.os == "OSX" then
for signame, num in pairs(macosx_signals) do
assert(num == tonumber(signum(signame)))
end
end
}
}
--- response_body
ABRT: 6
ALRM: 14
HUP: 1
INT: 2
KILL: 9
QUIT: 3
TERM: 15
TRAP: 5
BLAH: nil