summaryrefslogtreecommitdiff
path: root/test/ruby/test_process.rb
AgeCommit message (Collapse)Author
2021-10-25process.c: Add Process._fork (#5017)Yusuke Endoh
* process.c: Add Process._fork This API is supposed for application monitoring libraries to hook fork event. [Feature #17795] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Notes: Merged-By: mame <mame@ruby-lang.org>
2021-10-07test/ruby/test_process (test_no_curdir): tentatively skipped on SolarisYusuke Endoh
The test gets stuck on Solaris CI. http://rubyci.s3.amazonaws.com/solaris11-gcc/ruby-master/log/20211006T050007Z.fail.html.gz#test-all ``` [14558/21042] TestProcess#test_no_curdirtimeout: output interval exceeds 1800.0 seconds. timeout: the process group 3857 is alive. ``` Related to ee89543e09a2d4e4c503267c248ba7bfffa668cb
2021-10-04Fix regression on Solaris after change to use realpath on loaded featuresJeremy Evans
After the change to use realpath on loaded features, Solaris CI started failing in test_no_curdir (which tests behavior for running ruby without a working directory). I was able to trace the problem to the following call chain: rb_call_inits->Init_Thread->Init_thread_sync->rb_provide-> get_loaded_features_index->rb_check_realpath->rb_dir_getwd_ospath-> ruby_getcwd This will throw an exception, but because Ruby hasn't been fully initialized at the point the exception is thrown, it just exits with a status of 1. The bug here is that rb_check_realpath should not raise an exception, it should return nil. This bug is hit on Solaris because Solaris uses the realpath emulation instead of native realpath, and the realpath emualation raised instead of returning nil if the mode was RB_REALPATH_CHECK. Use rb_rescue in the realpath emulation if the mode is RB_REALPATH_CHECK, and swallow any exceptions raised and return nil. Notes: Merged: https://github.com/ruby/ruby/pull/4935
2021-10-04Revert rescue around internal realpath call on SolarisJeremy Evans
Solaris CI still has a problem even with these commits, so it doesn't appear to fix the issue. Reverting both 84e8e2a39bba874433b661bd378165bd03c9d6aa and bfd2f159f0c60ef8ac5bce6042edd25a571769b7.
2021-10-04Only rescue realpath calls during require on SolarisJeremy Evans
Remove temporary skip of test_no_curdir to see if this fixes the problem. Notes: Merged: https://github.com/ruby/ruby/pull/4931
2021-10-02Temporarily skip test_no_curdir test to avoid CI failures on SolarisJeremy Evans
2021-09-14Handle overwriting Object::ENV in spawnJeremy Evans
Instead of looking for Object::ENV (which can be overwritten), directly look for the envtbl variable. As that is static in hash.c, and the lookup code is in process.c, add a couple non-static functions that will return envtbl (or envtbl#to_hash). Fixes [Bug #18164] Notes: Merged: https://github.com/ruby/ruby/pull/4834
2021-06-29Prefer qualified names under ThreadNobuyoshi Nakada
2021-05-17[Win32] long path name support [Bug #12551]Gabriel Nagy
Implement long path support on Windows by applying Microsoft's recommended application manifest. To make this work on both Visual C++ and MinGW, include the manifest as a resource when generating the resource files. This way it will be embedded into the executables generated by both compilers. It's important for the manifest resource to have ID 1, otherwise GCC will embed a default manifest. Note that in addition to this, the user needs to have [long paths enabled] either by modifying the registry or by enabling a group policy. [long paths enabled]: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd#enable-long-paths-in-windows-10-version-1607-and-later Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/4505 Merged-By: nobu <nobu@ruby-lang.org>
2021-01-13Rename RubyVM::MJIT to RubyVM::JITTakashi Kokubun
because the name "MJIT" is an internal code name, it's inconsistent with --jit while they are related to each other, and I want to discourage future JIT implementation-specific (e.g. MJIT-specific) APIs by this rename. [Feature #17490]
2020-12-24Store errno in struct rb_process_statusNobuyoshi Nakada
To propagate errno in the fiber thread scheduler hook. Returns nil when no terminated process. Notes: Merged: https://github.com/ruby/ruby/pull/3998
2020-12-16Fixed marshal compatibility of Process::StatusNobuyoshi Nakada
2020-12-11RDoc states that Process::Status.wait returns nil if cannot waitNobuyoshi Nakada
2020-12-09Add support for non-blocking `Process.wait`.Samuel Williams
Notes: Merged: https://github.com/ruby/ruby/pull/3853
2020-12-04Guard all accesses to RubyVM::MJIT with defined?(RubyVM::MJIT) &&Benoit Daloze
* Otherwise those tests, etc cannot run on alternative Ruby implementations.
2020-05-30test/ruby/test_process.rb: GID.from_name may raise Errno:ESRCHYusuke Endoh
getgrnam(3) says: ``` ERRORS 0 or ENOENT or ESRCH or EBADF or EPERM or ... The given name or gid was not found. ``` Process::GID.from_name raises an ArgumentError for 0, but Errno::ESRCH for ESRCH. Actually, WSL 2 raises Errno::ESRCH. This change accepts all exceptions above.
2020-05-10Run rb_syswait on exec failureTakashi Kokubun
not only when !w but also when w == WAITPID_LOCK_ONLY. See also: f7c0cc36920a4ed14a3ab1ca6cfdf18ceff1e5d5 and a2264342063260d660b99872eaf5080f6ab08e81. We thought this change was an oversight in the latter commit. Without this change, the test fails like: $ make test-all TESTS="../test/ruby/test_process.rb -n test_exec_failure_leaves_no_child" RUN_OPTS="--jit" ... 1) Failure: TestProcess#test_exec_failure_leaves_no_child [/home/k0kubun/src/github.com/ruby/ruby/test/ruby/test_process.rb:2493]: Expected [[26799, #<Process::Status: pid 26799 exit 127>]] to be empty. Co-Authored-By: Yusuke Endoh <mame@ruby-lang.org>
2020-04-17test/ruby/test_process.rb: Skip GID.from_name on AndroidYusuke Endoh
The user management on Android seems very different https://rubyci.org/logs/rubyci.s3.amazonaws.com/android28-x86_64/ruby-master/log/20200416T234122Z.fail.html.gz
2020-04-16Preserve encoding in error messages for invalid user/group nameNobuyoshi Nakada
2020-04-16Added tests for Process::UID.from_name and Process::GID.from_nameNobuyoshi Nakada
2020-04-16Preserve encoding in error message for invalid env exec optionNobuyoshi Nakada
2020-04-16Added test for invalid env exec optionNobuyoshi Nakada
2020-03-07Removed unnecessary `chomp`Nobuyoshi Nakada
As `String#split` with the default argument drops trailing newline as a separator, preceding `String#chomp` is futile.
2020-02-11Restart timer thread even after preparation failedNobuyoshi Nakada
If the timer thread is left stopped, memory crash or segfault can happen.
2020-02-07Removed useless empty linesNobuyoshi Nakada
2019-12-17test/ruby/test_process.rb: suppress "unused variable" warningYusuke Endoh
2019-12-16Kernel#abort without arguments should print error infoNobuyoshi Nakada
[Bug #16424] Notes: Merged: https://github.com/ruby/ruby/pull/2754
2019-10-15Try to avoid random failureKazuhiro NISHIYAMA
https://rubyci.org/logs/rubyci.s3.amazonaws.com/openbsd-current/ruby-master/log/20191015T070011Z.fail.html.gz ``` 1) Failure: TestProcess#test_kill_at_spawn_failure [/home/chkbuild/chkbuild/tmp/build/20191015T070011Z/ruby/test/ruby/test_process.rb:2276]: [ruby-core:69304] [Bug #11166]. <#<Thread:0x000009f60a7cac40@/home/chkbuild/chkbuild/tmp/build/20191015T070011Z/ruby/test/ruby/test_process.rb:2272 dead>> expected but was <nil>. ``
2019-09-09Make test-all and test-spec runnable on AndroidYusuke Endoh
Calling some syscall functions such as Dir.chroot causes SIGSYS instead of EPERM on Android. This change skips all tests that stops the test-suite run.
2019-08-06Give up stabilizing TestProcess on Travis osxTakashi Kokubun
They have been too unstable. Revert "Extend sleep before sending USR1 in TestProcess" This reverts commit aaf69a8ba866193863a7eafe5c6044844bd71bc3. Revert "Extend sleep before sending USR1 in TestProcess" This reverts commit 076f3fcf11a061394d3d5f8c671512df1e983023.
2019-08-05Refined assertion messagesNobuyoshi Nakada
2019-08-05Fixed assertionNobuyoshi Nakada
The regexp should be expected to match the error message.
2019-08-04Extend sleep before sending USR1 in TestProcessTakashi Kokubun
just like 076f3fcf11a061394d3d5f8c671512df1e983023. This test also hanged on Travis osx https://travis-ci.org/ruby/ruby/jobs/567547060
2019-08-01Extend sleep before sending USR1 in TestProcessTakashi Kokubun
because the test seems to hang there forever: https://travis-ci.org/ruby/ruby/jobs/566409880
2019-06-30Removed unused variablesNobuyoshi Nakada
2019-05-31Keep vm->orig_progname aliveAlan Wu
`vm->orig_progname` can be different from `vm->progname` when user code assigns to `$0`. While `vm->progname` is kept alive by the global table, nothing marked `vm->orig_progname`. [Bug #15887]
2019-05-26test/ruby/test_process.rb: Use EnvUtil.timeout for timeout scale factorYusuke Endoh
https://rubyci.org/logs/rubyci.s3.amazonaws.com/solaris11s-sunc/ruby-master/log/20190526T052508Z.fail.html.gz
2018-12-26test/ruby/test_process.rb (test_execopts_uid): rescue Errno::EACCESmame
The tests fail under the following condition: * executed as a root * the code is in a directory that uid:30000 user cannot access (e.g., /root) So, this change rescues Errno::EACCES explicitly. Also, this change adds `exception: true` to `Kernel#system` calls. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-17Fix test failure if ENV["USER"] doesn't match Process.euidnormal
When dropping privileges to run tests, ENV["USER"] could be set to a user that doesn't match Process.euid, which causes this test to fail with Errno::EPERM. Try to get the name for the current euid, and only fallback to ENV["USER"] if that doesn't work. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-16Refine error message for time intervalnobu
* time.c (time_timespec): Time interval value can be zero, not only positive. [ruby-dev:50709] [Bug #15420] From: shuujii (Shuji KOBAYASHI) <shuujii@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-03process.c: fix ETXTBUSY from MJIT compiler processnormal
This affects test/ruby/test_process.rb (test_execopt_env_path). Since MJIT uses vfork+execve in a separate thread, there can be small window in-between vfork and execve where tmp_script.cmd is held open by the vforked child. vfork only pauses the MJIT thread, not any Ruby Threads, so our call to Process.spawn will hit ETXTBUSY in that window unless we fork. main thread | MJIT thread ---------------------------------------------------- fd = open(tmp) | | | vfork for CC | CC running write | | --------------- fchmod | | sees "fd" here close(fd) | | Process.spawn called | | vfork (spawn)| (new process) | | | execve => TXTBUSY | | | | | execve (FD_CLOEXEC on fd) | | vfork returns | Holding the waitpid_lock whenever we intend to spawn a process prevents the MJIT thread from spawning a process while we are spawning in Ruby-land. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-22io + socket: make pipes and sockets nonblocking by defaultnormal
All normal Ruby IO methods (IO#read, IO#gets, IO#write, ...) are all capable of appearing to be "blocking" when presented with a file description with the O_NONBLOCK flag set; so there is little risk of incompatibility within Ruby-using programs. The biggest compatibility risk is when spawning external programs. As a result, stdin, stdout, and stderr are now always made blocking before exec-family calls. This change will make an event-oriented MJIT usable if it is waiting on pipes on POSIX_like platforms. It is ALSO necessary to take advantage of (proposed lightweight concurrency (aka "auto-Fiber") or any similar proposal for network concurrency: https://bugs.ruby-lang.org/issues/13618 Named-pipe (FIFO) are NOT yet non-blocking by default since they are rarely-used and may introduce compatibility problems and extra syscall overhead for a common path. Please revert this commit if there are problems and if I am afk since I am afk a lot, lately. [ruby-core:89950] [Bug #14968] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20Skip known MJIT random test failuresk0kubun
Let me silence this until I have time to work on them, and make the CI usable for testing other features. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20process.c: do not try to pause MJITk0kubun
while child handler is disabled. trying to fix [Bug #15320] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-19test_process.rb: Process.daemon seems irrelevant [ci skip]k0kubun
in the backtrace: http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1468677 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-19revert r65807k0kubun
it didn't work. http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1468677 and skips broken tests for now. But this issue should be fixed soon. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-07Generalize r65594nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-07test_process.rb: avoid test failure by r65588k0kubun
on macOS. https://travis-ci.org/ruby/ruby/jobs/451709313 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22revisit more MJIT test skipsk0kubun
r65308 passed both trunk-mjit and trunk-mjit-wait CIs. MJIT copy job looks working fine. Then this commit skips 5 more tests. Some of them were skipped in a very early stage and may still need to be skipped, but I want to confirm them since they haven't been changed for a long time. And this prefers having inline information on `RubyVM::MJIT.enabled?`. This commit makes it easier to confirm whether there's suspicious test skip by RubyVM::MJIT.enabled? or not. After this commit, tentatively we're not skipping tests for MJIT other than `assert_no_memory_leak` ones. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22revert r65292 and r65297k0kubun
now mjit CIs are stable. Let me try this to confirm if it's fixed or not. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e