From 90340eb8f2c5bf820eabd3c25fb39e45285b1c40 Mon Sep 17 00:00:00 2001 From: Hleb Valoshka <375gnu@gmail.com> Date: Wed, 4 Sep 2013 15:07:19 +0300 Subject: Create own directory for every unix socket in unit tests [ew: this avoids a TOCTOU issue for multiple test invocations] Signed-off-by: Eric Wong --- test/test_unix_connect.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'test/test_unix_connect.rb') diff --git a/test/test_unix_connect.rb b/test/test_unix_connect.rb index 007f422..60cb8c0 100644 --- a/test/test_unix_connect.rb +++ b/test/test_unix_connect.rb @@ -3,6 +3,7 @@ require 'io/nonblock' $-w = true require 'kgio' require 'tempfile' +require 'tmpdir' class SubSocket < Kgio::Socket attr_accessor :foo @@ -14,7 +15,8 @@ end class TestKgioUnixConnect < Test::Unit::TestCase def setup - tmp = Tempfile.new('kgio_unix_1') + @tmpdir = Dir.mktmpdir('kgio_unix_1') + tmp = Tempfile.new('kgio_unix_1', @tmpdir) @path = tmp.path File.unlink(@path) tmp.close rescue nil @@ -25,6 +27,7 @@ class TestKgioUnixConnect < Test::Unit::TestCase def teardown @srv.close unless @srv.closed? File.unlink(@path) + FileUtils.remove_entry_secure(@tmpdir) Kgio.accept_cloexec = true end -- cgit v1.2.3-24-ge0c7