Project

General

Profile

Actions

Bug #12910

closed

TestFileUtils#test_chown_R_force might get stuck when process has no supplementary groups

Added by vo.x (Vit Ondruch) almost 6 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0dev (2016-11-07 trunk 56664) [x86_64-linux]
[ruby-core:78053]

Description

Testing build of Ruby using systemd-nspawn, the test suite gets always stuck when executing TestFileUtils#test_chown_R_force. Pressing Ctrl+C, it proceeds with following backtrace:

  1) Failure:
TestFileUtils#test_chown_R_force [/builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:1261]:
exceptions on 2 threads:
#<Thread:0x0055600e846cf0@/builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:18 sleep>:
/builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit/assertions.rb:762:in `value':  (Interrupt)
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit/assertions.rb:762:in `assert_join_threads'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:23:in `block in assert_output_lines'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:16:in `pipe'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:16:in `assert_output_lines'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:1261:in `test_chown_R_force'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:1029:in `run_test'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:1269:in `run'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit/testcase.rb:18:in `run'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:941:in `block in _run_suite'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:934:in `map'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:934:in `_run_suite'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:914:in `_run_suite'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:494:in `block in _run_suites'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:492:in `each'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:492:in `_run_suites'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:530:in `_run_suites'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:885:in `_run_anything'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:1096:in `run_tests'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:1083:in `block in _run'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:1082:in `each'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:1082:in `_run'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:1070:in `run'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:682:in `run'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:33:in `run'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:991:in `run'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit.rb:995:in `run'
	from ./test/runner.rb:40:in `<main>'
---
#<Thread:0x0055600e8469f8@/builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:19 dead>:
/builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/minitest/unit.rb:201:in `assert': File group ownership of "tmp/dir" unexpected:
 Expected: <>
   Actual: <135>
 (MiniTest::Assertion)
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/lib/test/unit/assertions.rb:37:in `assert'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/fileasserts.rb:95:in `assert_ownership_group'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:1278:in `block (2 levels) in test_chown_R_force'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:1273:in `each'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:1273:in `block in test_chown_R_force'
	from /builddir/build/BUILD/ruby-2.4.0-r56664/test/fileutils/test_fileutils.rb:20:in `block (2 levels) in assert_output_lines'

And there are two issues with this:

  1. It should simply fail and not get stuck, no matter what.

  2. For some reason, the test expects there will be some supplementary groups available, but there are non in the container. The following patch makes the test suite pass, although it apparently doesn't test everything, since some tests expects more than one group:

$ git show
commit 43934fbbf16c7f19e07ae1de17fce6697fb137cc
Author: Vít Ondruch <vondruch@redhat.com>
Date:   Tue Nov 8 16:25:24 2016 +0100

    Use primary group as well as supplementary groups.
    
    I might happen in certain environments (systemd-nspawn) that process has
    no supplementary groups, but primary groups should be enough to pass most
    of the tests.

diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb
index 0ff0aad..fa5b24d 100644
--- a/test/fileutils/test_fileutils.rb
+++ b/test/fileutils/test_fileutils.rb
@@ -142,7 +142,7 @@ def mymkdir(path)
 
   def setup
     @prevdir = Dir.pwd
-    @groups = Process.groups if have_file_perm?
+    @groups = [Process.gid, Process.groups].flatten if have_file_perm?
     tmproot = @tmproot = Dir.mktmpdir "fileutils"
     Dir.chdir tmproot
     my_rm_rf 'data'; mymkdir 'data'
Actions

Also available in: Atom PDF