summaryrefslogtreecommitdiff
path: root/tests/instances.tcl
diff options
context:
space:
mode:
authorAndy Pan <panjf2000@gmail.com>2021-01-20 04:57:30 +0800
committerGitHub <noreply@github.com>2021-01-19 22:57:30 +0200
commitfb66e2e24943018961321d13e46ee2ab66de882a (patch)
tree04075a8d909bc1eba249ecb1aaf1b4705fc84823 /tests/instances.tcl
parentaaf71b380ed5ef8d5d63f8a60733c35202c5b838 (diff)
downloadredis-fb66e2e24943018961321d13e46ee2ab66de882a.tar.gz
Use FD_CLOEXEC in Sentinel, so that FDs don't leak to the scripts it runs (#8242)
Sentinel uses execve to run scripts, so it needs to use FD_CLOEXEC on all file descriptors, so that they're not accessible by the script it runs. This commit includes a change to the sentinel tests, which verifies no FDs are left opened when the script is executed.
Diffstat (limited to 'tests/instances.tcl')
-rw-r--r--tests/instances.tcl14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/instances.tcl b/tests/instances.tcl
index 18eb1a402..5b25bcc97 100644
--- a/tests/instances.tcl
+++ b/tests/instances.tcl
@@ -400,6 +400,11 @@ proc check_leaks instance_types {
# Execute all the units inside the 'tests' directory.
proc run_tests {} {
+ set sentinel_fd_leaks_file "sentinel_fd_leaks"
+ if { [file exists $sentinel_fd_leaks_file] } {
+ file delete $sentinel_fd_leaks_file
+ }
+
set tests [lsort [glob ../tests/*]]
foreach test $tests {
if {$::run_matching ne {} && [string match $::run_matching $test] == 0} {
@@ -414,7 +419,14 @@ proc run_tests {} {
# Print a message and exists with 0 / 1 according to zero or more failures.
proc end_tests {} {
- if {$::failed == 0} {
+ set sentinel_fd_leaks_file "sentinel_fd_leaks"
+ if { [file exists $sentinel_fd_leaks_file] } {
+ puts [colorstr red "WARNING: sentinel test(s) failed, there are leaked fds in sentinel:"]
+ exec cat $sentinel_fd_leaks_file
+ exit 1
+ }
+
+ if {$::failed == 0 } {
puts "GOOD! No errors."
exit 0
} else {