Skip to content

Commit 8962412

Browse files
Revert "[libc] skip test and return ENOSYS when processm_release unavailable (#117951)"
This reverts commit 819b155.
1 parent 758d8b9 commit 8962412

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

libc/src/sys/mman/linux/process_mrelease.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
namespace LIBC_NAMESPACE_DECL {
2020

2121
LLVM_LIBC_FUNCTION(int, process_mrelease, (int pidfd, unsigned int flags)) {
22-
#ifdef SYS_process_mrelease
2322
long ret =
2423
LIBC_NAMESPACE::syscall_impl<int>(SYS_process_mrelease, pidfd, flags);
2524

@@ -29,13 +28,6 @@ LLVM_LIBC_FUNCTION(int, process_mrelease, (int pidfd, unsigned int flags)) {
2928
}
3029

3130
return 0;
32-
#else
33-
// The system call is not available.
34-
(void)pidfd;
35-
(void)flags;
36-
libc_errno = ENOSYS;
37-
return -1;
38-
#endif
3931
}
4032

4133
} // namespace LIBC_NAMESPACE_DECL

libc/test/src/sys/mman/linux/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ add_libc_unittest(
197197
libc.src.signal.kill
198198
libc.include.signal
199199
libc.src.stdlib.exit
200-
libc.src.signal.raise
201200
libc.src.__support.OSUtil.osutil
202201
libc.src.__support.threads.sleep
203202
libc.test.UnitTest.ErrnoSetterMatcher

libc/test/src/sys/mman/linux/process_mrelease_test.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
10+
#include "src/__support/threads/sleep.h"
1011
#include "src/errno/libc_errno.h"
1112
#include "src/signal/kill.h"
12-
#include "src/signal/raise.h"
1313
#include "src/stdlib/exit.h"
1414
#include "src/sys/mman/process_mrelease.h"
1515
#include "src/unistd/close.h"
@@ -18,7 +18,7 @@
1818
#include "test/UnitTest/LibcTest.h"
1919

2020
#include <sys/syscall.h>
21-
#if defined(SYS_process_mrelease) && defined(SYS_pidfd_open)
21+
2222
using namespace LIBC_NAMESPACE::testing::ErrnoSetterMatcher;
2323

2424
int pidfd_open(pid_t pid, unsigned int flags) {
@@ -30,11 +30,13 @@ TEST(LlvmLibcProcessMReleaseTest, NoError) {
3030
EXPECT_GE(child_pid, 0);
3131

3232
if (child_pid == 0) {
33-
// pause the child process
34-
LIBC_NAMESPACE::raise(SIGSTOP);
33+
// Child process: wait a bit then exit gracefully.
34+
LIBC_NAMESPACE::sleep_briefly();
35+
LIBC_NAMESPACE::exit(0);
3536
} else {
3637
// Parent process: wait a bit and then kill the child.
3738
// Give child process some time to start.
39+
LIBC_NAMESPACE::sleep_briefly();
3840
int pidfd = pidfd_open(child_pid, 0);
3941
EXPECT_GE(pidfd, 0);
4042

@@ -52,9 +54,12 @@ TEST(LlvmLibcProcessMReleaseTest, ErrorNotKilled) {
5254
EXPECT_GE(child_pid, 0);
5355

5456
if (child_pid == 0) {
55-
// pause the child process
56-
LIBC_NAMESPACE::raise(SIGSTOP);
57+
// Child process: wait a bit then exit gracefully.
58+
LIBC_NAMESPACE::sleep_briefly();
59+
LIBC_NAMESPACE::exit(0);
5760
} else {
61+
// Give child process some time to start.
62+
LIBC_NAMESPACE::sleep_briefly();
5863
int pidfd = pidfd_open(child_pid, 0);
5964
EXPECT_GE(pidfd, 0);
6065

@@ -67,4 +72,3 @@ TEST(LlvmLibcProcessMReleaseTest, ErrorNotKilled) {
6772
TEST(LlvmLibcProcessMReleaseTest, ErrorNonExistingPidfd) {
6873
EXPECT_THAT(LIBC_NAMESPACE::process_mrelease(-1, 0), Fails(EBADF));
6974
}
70-
#endif

0 commit comments

Comments
 (0)