Skip to content

Commit bb663cf

Browse files
committed
Disabled flock tests on darwin, fixed linux/darwin constant in openat
1 parent de6475f commit bb663cf

File tree

2 files changed

+26
-5
lines changed
  • graalpython

2 files changed

+26
-5
lines changed

graalpython/com.oracle.graal.python.cext/posix/posix.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,28 @@ int32_t set_inheritable(int32_t fd, int32_t inheritable) {
107107
int32_t call_openat(int32_t dirFd, const char *pathname, int32_t flags, int32_t mode) {
108108
int fixedFlags = flags;
109109
// TODO remove this once we properly synchronize constants between Java and C
110-
if (flags & 64) {
111-
fixedFlags &= ~64;
110+
111+
#define WRONG_O_CLOEXEC 524288
112+
#define WRONG_O_APPEND 1024
113+
#define WRONG_O_TRUNC 512
114+
#define WRONG_O_EXCL 128
115+
#define WRONG_O_CREAT 64
116+
117+
fixedFlags &= ~(WRONG_O_CLOEXEC | WRONG_O_APPEND | WRONG_O_TRUNC | WRONG_O_EXCL | WRONG_O_CREAT);
118+
119+
if (flags & WRONG_O_CREAT) {
112120
fixedFlags |= O_CREAT;
113121
}
114-
if (flags & 524288) {
115-
fixedFlags &= ~524288;
122+
if (flags & WRONG_O_EXCL) {
123+
fixedFlags |= O_EXCL;
124+
}
125+
if (flags & WRONG_O_TRUNC) {
126+
fixedFlags |= O_TRUNC;
127+
}
128+
if (flags & WRONG_O_APPEND) {
129+
fixedFlags |= O_APPEND;
130+
}
131+
if (flags & WRONG_O_CLOEXEC) {
116132
fixedFlags |= O_CLOEXEC;
117133
}
118134
return openat(fixDirFd(dirFd), pathname, fixedFlags, mode);

graalpython/com.oracle.graal.python.test/src/tests/test_fcntl.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def posix_module_backend(self):
5151
import tempfile
5252
import time
5353
import unittest
54+
import sys
5455

5556
PREFIX = 'select_graalpython_test'
5657
TEMP_DIR = tempfile.gettempdir()
@@ -82,18 +83,22 @@ def python_flock_blocks_sh_flock(python_flock_type, sh_flock_type):
8283

8384
class FcntlTests(unittest.TestCase):
8485
@unittest.skipUnless(__graalpython__.posix_module_backend() != 'java', 'No support in Truffle API (GR-28740)')
86+
@unittest.skipUnless(sys.platform != 'darwin', 'MacOSX does not have flock utility')
8587
def test_flock_x_and_x(self):
8688
python_flock_blocks_sh_flock(fcntl.LOCK_EX, 'x')
8789

8890
@unittest.skipUnless(__graalpython__.posix_module_backend() != 'java', 'No support in Truffle API (GR-28740)')
91+
@unittest.skipUnless(sys.platform != 'darwin', 'MacOSX does not have flock utility')
8992
def test_flock_x_and_s(self):
9093
python_flock_blocks_sh_flock(fcntl.LOCK_EX, 's')
9194

9295
@unittest.skipUnless(__graalpython__.posix_module_backend() != 'java', 'No support in Truffle API (GR-28740)')
96+
@unittest.skipUnless(sys.platform != 'darwin', 'MacOSX does not have flock utility')
9397
def test_flock_s_and_x(self):
9498
python_flock_blocks_sh_flock(fcntl.LOCK_SH, 'x')
9599

96100
@unittest.skipUnless(__graalpython__.posix_module_backend() != 'java', 'No support in Truffle API (GR-28740)')
101+
@unittest.skipUnless(sys.platform != 'darwin', 'MacOSX does not have flock utility')
97102
def test_flock_s_and_s(self):
98103
os.close(os.open(TEST_FILENAME_FULL_PATH, os.O_WRONLY | os.O_CREAT))
99104
file = os.open(TEST_FILENAME_FULL_PATH, os.O_WRONLY)
@@ -104,4 +109,4 @@ def test_flock_s_and_s(self):
104109
assert p.poll() == 42
105110
finally:
106111
fcntl.flock(file, fcntl.LOCK_UN)
107-
os.close(file)
112+
os.close(file)

0 commit comments

Comments
 (0)