ruby / spec

The Ruby Spec Suite aka ruby/spec
MIT License
588 stars 384 forks source link

Process constant values are platform-dependent on Linux #1150

Open matoro opened 2 months ago

matoro commented 2 months ago

Hi, in core/process/constants_spec.rb there are a few tests which explicitly test the values of the RLIMIT_* constants. These will fail on platforms which use different values for these constants. Example test failure on SPARC:

1)
Process::Constants has the correct constant values on Linux FAILED
Expected 7 == 6
to be truthy but was false
/var/tmp/portage/dev-lang/ruby-3.2.3/work/ruby-3.2.3/spec/ruby/core/process/constants_spec.rb:45:in `block (3 levels) in <top (required)>'
/var/tmp/portage/dev-lang/ruby-3.2.3/work/ruby-3.2.3/spec/ruby/core/process/constants_spec.rb:3:in `<top (required)>'

The default value is indeed 6: https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/resource.h#L26-L28

But this can be overridden on a per-architecture basis, e.g. SPARC overrides it to 7: https://github.com/torvalds/linux/blob/master/arch/sparc/include/uapi/asm/resource.h#L11-L16

At a quick glance, both Alpha and MIPS are also affected by this specifically for RLIMIT_NPROC, but other architectures may be affected for other resource constants.