about summary refs log tree commit homepage
path: root/test/test_fdmap.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-10-18 11:21:13 +0000
committerEric Wong <normalperson@yhbt.net>2013-10-18 11:35:43 +0000
commitfe6358be43e54d91c2beb9b52ced0437ad45f913 (patch)
treeb5ab71ae89d1d7b60037bf43950f0910384d2517 /test/test_fdmap.rb
parent94acc35b6bc42ca02033d111534b6f8135a724eb (diff)
downloadyahns-fe6358be43e54d91c2beb9b52ced0437ad45f913.tar.gz
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.
Diffstat (limited to 'test/test_fdmap.rb')
-rw-r--r--test/test_fdmap.rb19
1 files changed, 19 insertions, 0 deletions
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 <normalperson@yhbt.net> 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