Skip to content

Commit 1932ddd

Browse files
committed
Enable os tests
1 parent 248a87e commit 1932ddd

File tree

6 files changed

+42
-10
lines changed

6 files changed

+42
-10
lines changed

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_os.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
*graalpython.lib-python.3.test.test_os.BlockingTests.test_blocking
12
*graalpython.lib-python.3.test.test_os.BytesFwalkTests.test_compare_to_walk
23
*graalpython.lib-python.3.test.test_os.BytesFwalkTests.test_dir_fd
34
*graalpython.lib-python.3.test.test_os.BytesFwalkTests.test_fd_leak
@@ -43,17 +44,21 @@
4344
*graalpython.lib-python.3.test.test_os.EnvironTests.test_read
4445
*graalpython.lib-python.3.test.test_os.EnvironTests.test_setdefault
4546
*graalpython.lib-python.3.test.test_os.EnvironTests.test_update
47+
*graalpython.lib-python.3.test.test_os.EnvironTests.test_update2
4648
*graalpython.lib-python.3.test.test_os.EnvironTests.test_values
4749
*graalpython.lib-python.3.test.test_os.EnvironTests.test_write
50+
*graalpython.lib-python.3.test.test_os.ExecTests.test_execv_with_bad_arglist
4851
*graalpython.lib-python.3.test.test_os.ExecTests.test_execve_with_empty_path
4952
*graalpython.lib-python.3.test.test_os.ExecTests.test_execvpe_with_bad_program
5053
*graalpython.lib-python.3.test.test_os.ExportsTests.test_os_all
5154
*graalpython.lib-python.3.test.test_os.ExtendedAttributeTests.test_fds
5255
*graalpython.lib-python.3.test.test_os.ExtendedAttributeTests.test_lpath
5356
*graalpython.lib-python.3.test.test_os.ExtendedAttributeTests.test_simple
5457
*graalpython.lib-python.3.test.test_os.FDInheritanceTests.test_dup
58+
*graalpython.lib-python.3.test.test_os.FDInheritanceTests.test_dup2
5559
*graalpython.lib-python.3.test.test_os.FDInheritanceTests.test_dup_nul
5660
*graalpython.lib-python.3.test.test_os.FDInheritanceTests.test_dup_standard_stream
61+
*graalpython.lib-python.3.test.test_os.FDInheritanceTests.test_get_set_inheritable
5762
*graalpython.lib-python.3.test.test_os.FDInheritanceTests.test_open
5863
*graalpython.lib-python.3.test.test_os.FDInheritanceTests.test_openpty
5964
*graalpython.lib-python.3.test.test_os.FDInheritanceTests.test_pipe
@@ -92,14 +97,17 @@
9297
*graalpython.lib-python.3.test.test_os.MakedirTests.test_exist_ok_existing_regular_file
9398
*graalpython.lib-python.3.test.test_os.MakedirTests.test_exist_ok_s_isgid_directory
9499
*graalpython.lib-python.3.test.test_os.MakedirTests.test_makedir
100+
*graalpython.lib-python.3.test.test_os.MakedirTests.test_mode
95101
*graalpython.lib-python.3.test.test_os.MemfdCreateTests.test_memfd_create
96102
*graalpython.lib-python.3.test.test_os.MiscTests.test_getcwd
97103
*graalpython.lib-python.3.test.test_os.MiscTests.test_getcwd_long_path
98104
*graalpython.lib-python.3.test.test_os.MiscTests.test_getcwdb
99105
*graalpython.lib-python.3.test.test_os.NonLocalSymlinkTests.test_directory_link_nonlocal
106+
*graalpython.lib-python.3.test.test_os.OSErrorTests.test_oserror_filename
100107
*graalpython.lib-python.3.test.test_os.PathTConverterTests.test_path_t_converter
101108
*graalpython.lib-python.3.test.test_os.PathTConverterTests.test_path_t_converter_and_custom_class
102109
*graalpython.lib-python.3.test.test_os.Pep383Tests.test_statvfs
110+
*graalpython.lib-python.3.test.test_os.PidTests.test_getppid
103111
*graalpython.lib-python.3.test.test_os.PidTests.test_waitpid_windows
104112
*graalpython.lib-python.3.test.test_os.PosixUidGidTests.test_setegid
105113
*graalpython.lib-python.3.test.test_os.PosixUidGidTests.test_seteuid
@@ -146,7 +154,10 @@
146154
*graalpython.lib-python.3.test.test_os.StatAttributeTests.test_statvfs_result_pickle
147155
*graalpython.lib-python.3.test.test_os.TermsizeTests.test_does_not_crash
148156
*graalpython.lib-python.3.test.test_os.TermsizeTests.test_stty_match
157+
*graalpython.lib-python.3.test.test_os.TestInvalidFD.test_blocking
149158
*graalpython.lib-python.3.test.test_os.TestInvalidFD.test_closerange
159+
*graalpython.lib-python.3.test.test_os.TestInvalidFD.test_dup
160+
*graalpython.lib-python.3.test.test_os.TestInvalidFD.test_dup2
150161
*graalpython.lib-python.3.test.test_os.TestInvalidFD.test_fchdir
151162
*graalpython.lib-python.3.test.test_os.TestInvalidFD.test_fchmod
152163
*graalpython.lib-python.3.test.test_os.TestInvalidFD.test_fchown
@@ -155,6 +166,8 @@
155166
*graalpython.lib-python.3.test.test_os.TestInvalidFD.test_fpathconf
156167
*graalpython.lib-python.3.test.test_os.TestInvalidFD.test_fstat
157168
*graalpython.lib-python.3.test.test_os.TestInvalidFD.test_fstatvfs
169+
*graalpython.lib-python.3.test.test_os.TestInvalidFD.test_fsync
170+
*graalpython.lib-python.3.test.test_os.TestInvalidFD.test_inheritable
158171
*graalpython.lib-python.3.test.test_os.TestInvalidFD.test_isatty
159172
*graalpython.lib-python.3.test.test_os.TestInvalidFD.test_lseek
160173
*graalpython.lib-python.3.test.test_os.TestInvalidFD.test_read
@@ -184,6 +197,7 @@
184197
*graalpython.lib-python.3.test.test_os.TestScandir.test_bad_path_type
185198
*graalpython.lib-python.3.test.test_os.TestScandir.test_broken_symlink
186199
*graalpython.lib-python.3.test.test_os.TestScandir.test_bytes
200+
*graalpython.lib-python.3.test.test_os.TestScandir.test_bytes_like
187201
*graalpython.lib-python.3.test.test_os.TestScandir.test_close
188202
*graalpython.lib-python.3.test.test_os.TestScandir.test_consume_iterator_twice
189203
*graalpython.lib-python.3.test.test_os.TestScandir.test_context_manager
@@ -194,7 +208,10 @@
194208
*graalpython.lib-python.3.test.test_os.TestScandir.test_fd
195209
*graalpython.lib-python.3.test.test_os.TestScandir.test_fspath_protocol
196210
*graalpython.lib-python.3.test.test_os.TestScandir.test_fspath_protocol_bytes
211+
*graalpython.lib-python.3.test.test_os.TestScandir.test_removed_dir
212+
*graalpython.lib-python.3.test.test_os.TestScandir.test_removed_file
197213
*graalpython.lib-python.3.test.test_os.TestScandir.test_repr
214+
*graalpython.lib-python.3.test.test_os.TestScandir.test_resource_warning
198215
*graalpython.lib-python.3.test.test_os.TestSendfile.test_flags
199216
*graalpython.lib-python.3.test.test_os.TestSendfile.test_headers
200217
*graalpython.lib-python.3.test.test_os.TestSendfile.test_headers_overflow_32bits
@@ -218,6 +235,7 @@
218235
*graalpython.lib-python.3.test.test_os.UtimeTests.test_utime_dir_fd
219236
*graalpython.lib-python.3.test.test_os.UtimeTests.test_utime_directory
220237
*graalpython.lib-python.3.test.test_os.UtimeTests.test_utime_fd
238+
*graalpython.lib-python.3.test.test_os.UtimeTests.test_utime_invalid_arguments
221239
*graalpython.lib-python.3.test.test_os.UtimeTests.test_utime_nofollow_symlinks
222240
*graalpython.lib-python.3.test.test_os.WalkTests.test_file_like_path
223241
*graalpython.lib-python.3.test.test_os.WalkTests.test_walk_bad_dir

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@
125125
import com.oracle.truffle.api.frame.VirtualFrame;
126126
import com.oracle.truffle.api.interop.UnsupportedMessageException;
127127
import com.oracle.truffle.api.library.CachedLibrary;
128-
import com.oracle.truffle.api.nodes.Node;
129128
import com.oracle.truffle.api.profiles.BranchProfile;
130129
import com.oracle.truffle.api.profiles.ConditionProfile;
131130

@@ -219,8 +218,8 @@ public void initialize(PythonCore core) {
219218
"HAVE_MKDIRAT", "HAVE_OPENAT", "HAVE_READLINKAT", "HAVE_RENAMEAT", "HAVE_SYMLINKAT", "HAVE_UNLINKAT");
220219
// Not implemented yet:
221220
// "HAVE_FCHOWN", "HAVE_FCHOWNAT", "HAVE_FEXECVE", "HAVE_FPATHCONF", "HAVE_FSTATVFS",
222-
// "HAVE_FUTIMESAT", "HAVE_LINKAT", "HAVE_LCHFLAGS", "HAVE_LCHMOD", "HAVE_LCHOWN", "HAVE_LSTAT",
223-
// "HAVE_MEMFD_CREATE", "HAVE_MKFIFOAT", "HAVE_MKNODAT",
221+
// "HAVE_FUTIMESAT", "HAVE_LINKAT", "HAVE_LCHFLAGS", "HAVE_LCHMOD", "HAVE_LCHOWN",
222+
// "HAVE_LSTAT", "HAVE_MEMFD_CREATE", "HAVE_MKFIFOAT", "HAVE_MKNODAT"
224223
if (PosixConstants.HAVE_FUTIMENS.value) {
225224
haveFunctions.add("HAVE_FUTIMENS");
226225
}
@@ -398,7 +397,7 @@ private void execv(VirtualFrame frame, PosixPath path, Object argv, SequenceStor
398397
}
399398
Object[] opaqueArgs = new Object[args.length];
400399
for (int i = 0; i < args.length; ++i) {
401-
opaqueArgs[i] = toOpaquePathNode.execute(frame, args[i]);
400+
opaqueArgs[i] = toOpaquePathNode.execute(frame, args[i], i == 0);
402401
}
403402
// TODO ValueError "execv() arg 2 first element cannot be empty"
404403

@@ -2115,15 +2114,27 @@ private Object checkPath(Object path) {
21152114
* Similar to {@code PyUnicode_FSConverter}, but the actual conversion is delegated to the
21162115
* {@link PosixSupportLibrary} implementation.
21172116
*/
2118-
abstract static class ObjectToOpaquePathNode extends Node {
2119-
abstract Object execute(VirtualFrame frame, Object obj);
2117+
abstract static class ObjectToOpaquePathNode extends PNodeWithRaise {
2118+
abstract Object execute(VirtualFrame frame, Object obj, boolean checkEmpty);
21202119

2121-
@Specialization
2122-
Object doIt(VirtualFrame frame, Object obj,
2120+
@Specialization(guards = "!checkEmpty")
2121+
Object noCheck(VirtualFrame frame, Object obj, @SuppressWarnings("unused") boolean checkEmpty,
21232122
@Cached FspathNode fspathNode,
21242123
@Cached StringOrBytesToOpaquePathNode stringOrBytesToOpaquePathNode) {
21252124
return stringOrBytesToOpaquePathNode.execute(fspathNode.call(frame, obj));
21262125
}
2126+
2127+
@Specialization(replaces = "noCheck", limit = "2")
2128+
Object withCheck(VirtualFrame frame, Object obj, boolean checkEmpty,
2129+
@Cached FspathNode fspathNode,
2130+
@CachedLibrary("obj") PythonObjectLibrary lib,
2131+
@Cached StringOrBytesToOpaquePathNode stringOrBytesToOpaquePathNode) {
2132+
Object stringOrBytes = fspathNode.call(frame, obj);
2133+
if (checkEmpty && lib.lengthWithFrame(obj, frame) == 0) {
2134+
throw raise(ValueError, ErrorMessages.EXECV_ARG2_FIRST_ELEMENT_CANNOT_BE_EMPTY);
2135+
}
2136+
return stringOrBytesToOpaquePathNode.execute(stringOrBytes);
2137+
}
21272138
}
21282139

21292140
abstract static class ConvertToTimespecBaseNode extends PythonBuiltinBaseNode {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixSubprocessModuleBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Object[] doSequence(VirtualFrame frame, Object processArgs,
138138
throw raise(RuntimeError, ErrorMessages.ARGS_CHANGED_DURING_ITERATION);
139139
}
140140
Object o = getItemNode.execute(frame, argsStorage, i);
141-
argsArray[i] = objectToOpaquePathNode.execute(frame, o);
141+
argsArray[i] = objectToOpaquePathNode.execute(frame, o, false);
142142
}
143143
return argsArray;
144144
}
@@ -241,7 +241,7 @@ int forkExec(VirtualFrame frame, Object[] args, Object executableList, boolean c
241241

242242
Object[] processArgs = args;
243243
int[] fdsToKeep = convertFdSequence(frame, fdsToKeepTuple, lenNode, getItemNode, castToIntNode);
244-
Object cwd = PGuards.isPNone(cwdObj) ? null : objectToOpaquePathNode.execute(frame, cwdObj);
244+
Object cwd = PGuards.isPNone(cwdObj) ? null : objectToOpaquePathNode.execute(frame, cwdObj, false);
245245

246246
byte[] sysExecutable = fsEncode(getContext().getOption(PythonOptions.Executable));
247247
// TODO unlike CPython, this accepts a dict (if the keys are integers (0, 1, ..., len-1)

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/ErrorMessages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ public abstract class ErrorMessages {
237237
public static final String EXCEPTION_CAUSES_MUST_DERIVE_FROM_BASE_EX = "exception causes must derive from BaseException";
238238
public static final String EXCEPTIONS_MUST_BE_CLASSES_OR_INSTANCES_DERIVING_FROM_BASE_EX = "exceptions must be classes or instances deriving from BaseException, not %p";
239239
public static final String EXCEPTIONS_MUST_DERIVE_FROM_BASE_EX = "exceptions must derive from BaseException";
240+
public static final String EXECV_ARG2_FIRST_ELEMENT_CANNOT_BE_EMPTY = "execv() arg 2 first element cannot be empty";
240241
public static final String EXPECTED_ARG_TYPES_S_S_BUT_NOT_P_P = "expected argument types (%s) or (%s) but not (%p, %p)";
241242
public static final String EXPECTED_AT_MOST_D_ARGS_GOT_D = "%s expected at most %d arguments, got %d";
242243
public static final String EXPECTED_BYTESLIKE_GOT_P = "expected a bytes-like object, %p found";

graalpython/lib-python/3/test/test_os.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3981,6 +3981,7 @@ def test_context_manager_exception(self):
39813981
with self.check_no_resource_warning():
39823982
del iterator
39833983

3984+
@support.impl_detail("relies on GC", graalvm=False)
39843985
def test_resource_warning(self):
39853986
self.create_file("file.txt")
39863987
self.create_file("file2.txt")

graalpython/lib-python/3/test/test_subprocess.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ def is_env_var_to_ignore(n):
685685
return ('VERSIONER' in n or '__CF' in n or # MacOS
686686
n == 'LD_PRELOAD' or n.startswith('SANDBOX') or # Gentoo
687687
n == 'PWD' or n == 'SHLVL' or # Graalpython bash launcher
688+
n.startswith('JAVA_MAIN_CLASS') or # JVM on MacOS
688689
n == 'LC_CTYPE') # Locale coercion triggered
689690

690691
with subprocess.Popen([sys.executable, "-c",

0 commit comments

Comments
 (0)