From fe6358be43e54d91c2beb9b52ced0437ad45f913 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 18 Oct 2013 11:21:13 +0000 Subject: test and fix client expiry This is rarely-called code, but we need to be sure we can expire clients correctly when thresholds are reached. We also correctly handle negative values of the client_expire_threshold directive. --- test/test_fdmap.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/test_fdmap.rb (limited to 'test/test_fdmap.rb') diff --git a/test/test_fdmap.rb b/test/test_fdmap.rb new file mode 100644 index 0000000..3525dca --- /dev/null +++ b/test/test_fdmap.rb @@ -0,0 +1,19 @@ +# Copyright (C) 2013, Eric Wong and all contributors +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +require_relative 'helper' + +class TestFdmap < Testcase + def test_fdmap_negative + fdmap = Yahns::Fdmap.new(Logger.new($stderr), -5) + nr = fdmap.instance_variable_get :@client_expire_threshold + assert_operator nr, :>, 0 + assert_equal nr, Process.getrlimit(:NOFILE)[0] - 5 + end + + def test_fdmap_float + fdmap = Yahns::Fdmap.new(Logger.new($stderr), 0.5) + nr = fdmap.instance_variable_get :@client_expire_threshold + assert_operator nr, :>, 0 + assert_equal nr, Process.getrlimit(:NOFILE)[0]/2 + end +end -- cgit v1.2.3-24-ge0c7