Project

General

Profile

Actions

Bug #18002

open

s390x: Tests failing without LC_ALL env

Added by jaruga (Jun Aruga) about 1 month ago. Updated 12 days ago.

Status:
Open
Priority:
Normal
Target version:
-
[ruby-core:104376]

Description

The following failures happened in RubyCI on our s390x Ubuntu focal server.
On the server, RubyCI (ruby/chkbuild) is executed with LC_ALL not set, by cron.
I found the unset LC_ALL causes the failures on the s390x server. This does not happen on x86_64 Fedora 33 on my local machine.

I was able to reproduce the failures on the master branch dbd1887d04f5ff7c2a1f0a27d7339133a on the server.

Reproducer

$ uname -m
s390x

$ autoconf

$ ./configure \
  --prefix=${HOME}/local/ruby-master-9d96837 \
  --enable-shared

$ make

Without LC_ALL

Then run the tests without LC_ALL.

$ unset LC_ALL

$ echo $LC_ALL
  <= empty
$ make test-all TESTS="-v test/ruby/test_file.rb -n TestFile#test_realpath_encoding"
Run options:-
  --seed=85060
  "--ruby=./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems"
  --excludes-dir=./test/excludes
  --name=!/memory_leak/
  -v
  -n
  TestFile#test_realpath_encoding

# Running tests:

[1/0] TestFile#test_realpath_encoding = 0.00 s

  1) Failure:
TestFile#test_realpath_encoding [/home/jaruga/git/ruby/ruby2/test/ruby/test_file.rb:284]:
<"/tmp/rubytest-realpath20210621-3365652-za1wql/A\u0391\u0410\u0531\u10A0\u05D0\u2C00\u3042"> expected but was
<"/tmp/rubytest-realpath20210621-3365652-za1wql/A\u00CE\u0091\u00D0\u0090\u00D4\u00B1\u00E1\u0082\u00A0\u00D7\u0090\u00E2\u00B0\u0080\u00E3\u0081\u0082">.

Finished tests in 0.007217s, 138.5674 tests/s, 692.8372 assertions/s.
1 tests, 5 assertions, 1 failures, 0 errors, 0 skips
ruby -v: ruby 3.1.0dev (2021-06-18T10:13:36Z master 9d96837dbd) [s390x-linux]
make: *** [uncommon.mk:803: yes-test-all] Error 1
$ make test-all TESTS="-v test/irb/test_context.rb -n TestIRB::TestContext#test_eval_input_with_invalid_byte_sequence_exception"
Run options:-
  --seed=74635
  "--ruby=./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems"
  --excludes-dir=./test/excludes
  --name=!/memory_leak/
  -v
  -n
  TestIRB::TestContext#test_eval_input_with_invalid_byte_sequence_exception

# Running tests:

[1/0] TestIRB::TestContext#test_eval_input_with_invalid_byte_sequence_exception = 0.00 s

  1) Failure:
TestIRB::TestContext#test_eval_input_with_invalid_byte_sequence_exception [/home/jaruga/git/ruby/ruby2/test/irb/test_context.rb:505]:
Expected /\(irb\):1:in `fuga': A\\xF3B \(RuntimeError\)\n/
to match
  "(irb):1:in `fuga': A�B (RuntimeError)\n"+
  "\tfrom (irb):1:in `hoge'\n"+
  "\tfrom (irb):1:in `<main>'\n"
after 1 patterns with 0 characters.

Finished tests in 0.007640s, 130.8819 tests/s, 785.2916 assertions/s.
1 tests, 6 assertions, 1 failures, 0 errors, 0 skips
ruby -v: ruby 3.1.0dev (2021-06-18T10:13:36Z master 9d96837dbd) [s390x-linux]
make: *** [uncommon.mk:803: yes-test-all] Error 1

With export LC_ALL=C

On the export LC_ALL=C (LC_ALL=C without export is not enough to pass the tests)

$ export LC_ALL=C

$ echo $LC_ALL
C
$ make test-all TESTS="-v test/ruby/test_file.rb -n TestFile#test_realpath_encoding"
Run options: 
  --seed=89696
  "--ruby=./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems"
  --excludes-dir=./test/excludes
  --name=!/memory_leak/
  -v
  -n
  TestFile#test_realpath_encoding

# Running tests:

[1/0] TestFile#test_realpath_encoding = 0.00 s
Finished tests in 0.004715s, 212.0691 tests/s, 1060.3455 assertions/s.
1 tests, 5 assertions, 0 failures, 0 errors, 0 skips

ruby -v: ruby 3.1.0dev (2021-06-18T10:13:36Z master 9d96837dbd) [s390x-linux]
$ make test-all TESTS="-v test/irb/test_context.rb -n TestIRB::TestContext#test_eval_input_with_invalid_byte_sequence_exception"
Run options: 
  --seed=67965
  "--ruby=./miniruby -I./lib -I. -I.ext/common  ./tool/runruby.rb --extout=.ext  -- --disable-gems"
  --excludes-dir=./test/excludes
  --name=!/memory_leak/
  -v
  -n
  TestIRB::TestContext#test_eval_input_with_invalid_byte_sequence_exception

# Running tests:

[1/0] TestIRB::TestContext#test_eval_input_with_invalid_byte_sequence_exception = 0.00 s
Finished tests in 0.007877s, 126.9448 tests/s, 761.6689 assertions/s.
1 tests, 6 assertions, 0 failures, 0 errors, 0 skips

ruby -v: ruby 3.1.0dev (2021-06-18T10:13:36Z master 9d96837dbd) [s390x-linux]

Possible Solution

Fix the tests not depending on the external LC_ALL condition.

Actions #1

Updated by jaruga (Jun Aruga) about 1 month ago

  • Subject changed from s390x: Tests failing on LC_ALL is not set to s390x: Tests failing without LC_ALL env

Updated by jaruga (Jun Aruga) 12 days ago

$ make test-all TESTS="-v test/ruby/test_file.rb -n TestFile#test_realpath_encoding"

For the 1st failed test, I created a minimal reproducer.

$ cat test.rb 
require 'fileutils'

fsenc = Encoding.find("filesystem")
# => #<Encoding:ISO-8859-1> if `unset LC_ALL` on s390x.
# => #<Encoding:US-ASCII> if `export LC_ALL=C` on s390x.
tst = "A" + "\u0391"
tmpdir = '/tmp/rubytest1'

FileUtils.rm_rf(tmpdir) if Dir.exists?(tmpdir)
Dir.mkdir(tmpdir)

open(File.join(tmpdir, tst), "w") {}
a = File.join(tmpdir, "x")
File.symlink(tst, a)
p File.join(tmpdir, tst).to_s.bytes.to_s
p File.realpath(a).to_s.bytes.to_s
abort 'Failed' unless File.join(tmpdir, tst) == File.realpath(a)

On the above s390x machine with the latest master Ruby (commit: 84fea8ee39249ff9e7a03c407e5d16ad93074f3e),

$ uname -m
s390x
$ export LC_ALL=C

$ ~/local/ruby-master-84fea8e/bin/ruby -e 'p Encoding.find("filesystem")'
#<Encoding:US-ASCII>

$ ~/local/ruby-master-84fea8e/bin/ruby test.rb 
"[47, 116, 109, 112, 47, 114, 117, 98, 121, 116, 101, 115, 116, 49, 47, 65, 206, 145]"
"[47, 116, 109, 112, 47, 114, 117, 98, 121, 116, 101, 115, 116, 49, 47, 65, 206, 145]"

$ unset LC_ALL

$ ~/local/ruby-master-84fea8e/bin/ruby -e 'p Encoding.find("filesystem")'
#<Encoding:ISO-8859-1>

$ ~/local/ruby-master-84fea8e/bin/ruby test.rb 
"[47, 116, 109, 112, 47, 114, 117, 98, 121, 116, 101, 115, 116, 49, 47, 65, 206, 145]"
"[47, 116, 109, 112, 47, 114, 117, 98, 121, 116, 101, 115, 116, 49, 47, 65, 195, 142, 194, 145]"
Failed

Is this a bug in File.realpath or the test code on unset LC_ALL invalid? I tried to modify the test not to depend on a value of LC_ALL. But I have no idea about it.

Updated by jaruga (Jun Aruga) 12 days ago

Here is the status under the /tmp/rubytest1 (tmpdir).

ruby01|s390x$ unset LC_ALL
ruby01|s390x$ ls -l /tmp/rubytest1
total 0
-rw-r--r-- 1 jaruga sudo 0 Jul 12 12:21 'A�'$'\221'
lrwxrwxrwx 1 jaruga sudo 3 Jul 12 12:21  x -> 'A�'$'\221'
Actions

Also available in: Atom PDF