Commit 3a41df7f authored by Kevin Modzelewski's avatar Kevin Modzelewski Committed by GitHub

Merge pull request #1340 from kmod/cpython_tests

These cpython tests are working now
parents 6681b73e 7747b4b2
# expected: fail
from test import test_support from test import test_support
from test.test_support import TESTFN, _4G, bigmemtest, import_module, findfile from test.test_support import TESTFN, _4G, bigmemtest, import_module, findfile
......
# expected: fail
"""Unit tests for the copy module.""" """Unit tests for the copy module."""
import copy import copy
......
# expected: fail
# Tests for rich comparisons # Tests for rich comparisons
import unittest import unittest
......
# expected: fail
"""Tests for sysconfig.""" """Tests for sysconfig."""
import unittest import unittest
......
# expected: fail
import unittest.test import unittest.test
from test import test_support from test import test_support
......
# expected: fail
"""This test checks for correct wait3() behavior. """This test checks for correct wait3() behavior.
""" """
......
# expected: fail
"""This test checks for correct wait4() behavior. """This test checks for correct wait4() behavior.
""" """
......
...@@ -1420,6 +1420,9 @@ BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs) ...@@ -1420,6 +1420,9 @@ BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs)
mode = (mode_char == 'r') ? "rb" : "wb"; mode = (mode_char == 'r') ? "rb" : "wb";
// Pyston change: this prevents leaking refs in the test_bz2.py test
Py_CLEAR(self->file);
self->file = PyObject_CallFunction((PyObject*)&PyFile_Type, "(Osi)", self->file = PyObject_CallFunction((PyObject*)&PyFile_Type, "(Osi)",
name, mode, buffering); name, mode, buffering);
if (self->file == NULL) if (self->file == NULL)
......
...@@ -6109,6 +6109,8 @@ wait_helper(pid_t pid, int status, struct rusage *ru) ...@@ -6109,6 +6109,8 @@ wait_helper(pid_t pid, int status, struct rusage *ru)
Py_DECREF(m); Py_DECREF(m);
if (struct_rusage == NULL) if (struct_rusage == NULL)
return NULL; return NULL;
// Pyston addition:
PyGC_RegisterStaticConstant(struct_rusage);
} }
/* XXX(nnorwitz): Copied (w/mods) from resource.c, there should be only one. */ /* XXX(nnorwitz): Copied (w/mods) from resource.c, there should be only one. */
......
...@@ -100,7 +100,7 @@ bool RefcountTracker::isNullable(llvm::Value* v) { ...@@ -100,7 +100,7 @@ bool RefcountTracker::isNullable(llvm::Value* v) {
} }
void RefcountTracker::refConsumed(llvm::Value* v, llvm::Instruction* inst) { void RefcountTracker::refConsumed(llvm::Value* v, llvm::Instruction* inst) {
if (llvm::isa<UndefValue>(v)) if (llvm::isa<UndefValue>(v) || llvm::isa<ConstantPointerNull>(v))
return; return;
assert(this->vars[v].reftype != RefType::UNKNOWN); assert(this->vars[v].reftype != RefType::UNKNOWN);
...@@ -109,7 +109,7 @@ void RefcountTracker::refConsumed(llvm::Value* v, llvm::Instruction* inst) { ...@@ -109,7 +109,7 @@ void RefcountTracker::refConsumed(llvm::Value* v, llvm::Instruction* inst) {
} }
void RefcountTracker::refUsed(llvm::Value* v, llvm::Instruction* inst) { void RefcountTracker::refUsed(llvm::Value* v, llvm::Instruction* inst) {
if (llvm::isa<UndefValue>(v)) if (llvm::isa<UndefValue>(v) || llvm::isa<ConstantPointerNull>(v))
return; return;
assert(this->vars[v].reftype != RefType::UNKNOWN); assert(this->vars[v].reftype != RefType::UNKNOWN);
......
...@@ -1116,6 +1116,22 @@ public: ...@@ -1116,6 +1116,22 @@ public:
operator FILE*() const { return file; } operator FILE*() const { return file; }
}; };
void throwCAPIException();
// A C++-style RAII way of doing Py_EnterRecursiveCall + Py_LeaveRecursiveCall
class _RecursiveBlockHelper {
public:
~_RecursiveBlockHelper() { Py_LeaveRecursiveCall(); }
};
#define RECURSIVE_BLOCK(S, reason) \
_RecursiveBlockHelper CAT(_recursive_helper, __LINE__); \
if (Py_EnterRecursiveCall(reason)) { \
if (S == CAPI) \
return NULL; \
else \
throwCAPIException(); \
}
// similar to Java's Array.binarySearch: // similar to Java's Array.binarySearch:
// return values are either: // return values are either:
// >= 0 : the index where a given item was found // >= 0 : the index where a given item was found
......
...@@ -220,6 +220,8 @@ void setupThread() { ...@@ -220,6 +220,8 @@ void setupThread() {
"start_new_thread", "start_new_thread",
new BoxedBuiltinFunctionOrMethod( new BoxedBuiltinFunctionOrMethod(
BoxedCode::create((void*)startNewThread, BOXED_INT, 3, false, false, "start_new_thread"), { NULL })); BoxedCode::create((void*)startNewThread, BOXED_INT, 3, false, false, "start_new_thread"), { NULL }));
thread_module->giveAttrBorrowed("start_new", thread_module->getattr(getStaticString("start_new_thread")));
thread_module->giveAttr("allocate_lock", new BoxedBuiltinFunctionOrMethod( thread_module->giveAttr("allocate_lock", new BoxedBuiltinFunctionOrMethod(
BoxedCode::create((void*)allocateLock, UNKNOWN, 0, "allocate_lock"))); BoxedCode::create((void*)allocateLock, UNKNOWN, 0, "allocate_lock")));
thread_module->giveAttr( thread_module->giveAttr(
......
...@@ -539,7 +539,7 @@ extern "C" int Py_FlushLine(void) noexcept { ...@@ -539,7 +539,7 @@ extern "C" int Py_FlushLine(void) noexcept {
return PyFile_WriteString("\n", f); return PyFile_WriteString("\n", f);
} }
void setCAPIException(STOLEN(const ExcInfo&) e) { void setCAPIException(STOLEN(const ExcInfo&) e) noexcept {
PyErr_Restore(e.type, e.value, e.traceback); PyErr_Restore(e.type, e.value, e.traceback);
} }
......
...@@ -4747,6 +4747,9 @@ Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpe ...@@ -4747,6 +4747,9 @@ Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpe
template <ExceptionStyle S> template <ExceptionStyle S>
static Box* callChosenCF(CompiledFunction* chosen_cf, BoxedClosure* closure, BoxedGenerator* generator, Box* globals, static Box* callChosenCF(CompiledFunction* chosen_cf, BoxedClosure* closure, BoxedGenerator* generator, Box* globals,
Box* oarg1, Box* oarg2, Box* oarg3, Box** oargs) noexcept(S == CAPI) { Box* oarg1, Box* oarg2, Box* oarg3, Box** oargs) noexcept(S == CAPI) {
// TODO: this should be done in the rewrite as well
RECURSIVE_BLOCK(S, " in function call");
if (S != chosen_cf->exception_style) { if (S != chosen_cf->exception_style) {
if (S == CAPI) { if (S == CAPI) {
try { try {
......
...@@ -169,7 +169,7 @@ void checkAndThrowCAPIException(); ...@@ -169,7 +169,7 @@ void checkAndThrowCAPIException();
void throwCAPIException() __attribute__((noreturn)); void throwCAPIException() __attribute__((noreturn));
void ensureCAPIExceptionSet(); void ensureCAPIExceptionSet();
struct ExcInfo; struct ExcInfo;
void setCAPIException(STOLEN(const ExcInfo&) e); void setCAPIException(STOLEN(const ExcInfo&) e) noexcept;
// Finalizer-related // Finalizer-related
void dealloc_null(Box* box); void dealloc_null(Box* box);
......
...@@ -27,7 +27,6 @@ test_bsddb185 [unknown] ...@@ -27,7 +27,6 @@ test_bsddb185 [unknown]
test_bsddb3 [unknown] test_bsddb3 [unknown]
test_bsddb [unknown] test_bsddb [unknown]
test_builtin execfile scoping issue test_builtin execfile scoping issue
test_bz2 leaks
test_capi [unknown] test_capi [unknown]
test_cd [unknown] test_cd [unknown]
test_cfgparser works when run from inside the from_cpython dir test_cfgparser works when run from inside the from_cpython dir
...@@ -54,7 +53,6 @@ test_coercion 1**1L, divmod(1, 1L); some unknown bug ...@@ -54,7 +53,6 @@ test_coercion 1**1L, divmod(1, 1L); some unknown bug
test_compileall [unknown] test_compileall [unknown]
test_compiler [unknown] test_compiler [unknown]
test_compile [unknown] test_compile [unknown]
test_copy Please debug this test in VM.
test_cprofile [unknown] test_cprofile [unknown]
test_crypt [unknown] test_crypt [unknown]
test_ctypes [unknown] test_ctypes [unknown]
...@@ -136,7 +134,6 @@ test_pydoc [unknown] ...@@ -136,7 +134,6 @@ test_pydoc [unknown]
test_random long("invalid number") test_random long("invalid number")
test_repr complex.__hash__; some unknown issues test_repr complex.__hash__; some unknown issues
test_resource fails on travis-ci: setrlimit RLIMIT_CPU not allowed to raise maximum limit test_resource fails on travis-ci: setrlimit RLIMIT_CPU not allowed to raise maximum limit
test_richcmp PyObject_Not
test_runpy [unknown] test_runpy [unknown]
test_scope eval of code object from existing function (not currently supported) test_scope eval of code object from existing function (not currently supported)
test_scriptpackages [unknown] test_scriptpackages [unknown]
...@@ -152,7 +149,6 @@ test_sundry [unknown] ...@@ -152,7 +149,6 @@ test_sundry [unknown]
test_support [unknown] test_support [unknown]
test_symtable [unknown] test_symtable [unknown]
test_syntax [unknown] test_syntax [unknown]
test_sysconfig [unknown]
test_sys_setprofile [unknown] test_sys_setprofile [unknown]
test_sys_settrace [unknown] test_sys_settrace [unknown]
test_sys [unknown] test_sys [unknown]
...@@ -173,13 +169,10 @@ test_ttk_textonly [unknown] ...@@ -173,13 +169,10 @@ test_ttk_textonly [unknown]
test_types PyErr_WarnEx test_types PyErr_WarnEx
test_undocumented_details function.func_closure test_undocumented_details function.func_closure
test_unicode argument passing issue? test_unicode argument passing issue?
test_unittest leaks
test_userdict segfault: repr of recursive dict? test_userdict segfault: repr of recursive dict?
test_userlist slice(1L, 1L) test_userlist slice(1L, 1L)
test_userstring float(1L); hangs in test_replace test_userstring float(1L); hangs in test_replace
test_wait3 [unknown] test_warnings Among other things, we don't support the -W flag
test_wait4 [unknown]
test_warnings [unknown]
test_weakref weird function-picking bug (something around float.__add__), plase also fix the weakref issue in test_abc test_weakref weird function-picking bug (something around float.__add__), plase also fix the weakref issue in test_abc
test_winreg [unknown] test_winreg [unknown]
test_winsound [unknown] test_winsound [unknown]
......
../../from_cpython/Lib/test/warning_tests.py
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment