Skip to content

Commit 58adb3f

Browse files
committed
[GR-10979] patch out unittests which cause a SEGFAULT
PullRequest: graalpython/130
2 parents d185928 + a8eac46 commit 58adb3f

File tree

12 files changed

+40
-7
lines changed

12 files changed

+40
-7
lines changed

graalpython/com.oracle.graal.python.cext/src/capi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,12 @@ const char* PyTruffle_StringToCstr(void* o, int32_t strLen) {
261261

262262
const char* PyTruffle_ByteArrayToNative(const void* jbyteArray, int len) {
263263
int i;
264-
char* barr = (const char*) malloc(len * sizeof(char));
265-
264+
int size = len != 0 ? len : 1;
265+
char* barr = (const char*) malloc(size * sizeof(char));
266+
barr[0] = '\0';
266267
for(i=0; i < len; i++) {
267268
barr[i] = (char) polyglot_get_array_element(jbyteArray, i);
268269
}
269-
270270
return (const char*) barr;
271271
}
272272

graalpython/lib-graalpython/object.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ def _getstate(obj):
8888
return state
8989

9090

91+
def reduce_1(obj, proto):
92+
import copyreg
93+
return copyreg._reduce_ex(obj, proto)
94+
95+
9196
def reduce_2(obj, proto, args, kwargs):
9297
cls = obj.__class__
9398

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
ndarray = None
2828

2929
try:
30-
import struct
30+
# skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
31+
# import struct
32+
struct = None
3133
except ImportError:
3234
struct = None
3335

@@ -43,7 +45,6 @@
4345
except ImportError:
4446
numpy_array = None
4547

46-
4748
SHORT_TEST = True
4849

4950

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ def testApproximateCos1(self):
615615
s += num / fact * sign
616616
self.assertAlmostEqual(math.cos(1), s)
617617

618+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
618619
def test_copy_deepcopy_pickle(self):
619620
r = F(13, 7)
620621
dr = DummyFraction(13, 7)

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ def testAcos(self):
276276
self.assertRaises(ValueError, math.acos, -1 - eps)
277277
self.assertTrue(math.isnan(math.acos(NAN)))
278278

279+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
279280
def testAcosh(self):
280281
self.assertRaises(TypeError, math.acosh)
281282
self.ftest('acosh(1)', math.acosh(1), 0)
@@ -297,6 +298,7 @@ def testAsin(self):
297298
self.assertRaises(ValueError, math.asin, -1 - eps)
298299
self.assertTrue(math.isnan(math.asin(NAN)))
299300

301+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
300302
def testAsinh(self):
301303
self.assertRaises(TypeError, math.asinh)
302304
self.ftest('asinh(0)', math.asinh(0), 0)
@@ -447,6 +449,7 @@ def testCopysign(self):
447449
# similarly, copysign(2., NAN) could be 2. or -2.
448450
self.assertEqual(abs(math.copysign(2., NAN)), 2.)
449451

452+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
450453
def testCos(self):
451454
self.assertRaises(TypeError, math.cos)
452455
self.ftest('cos(-pi/2)', math.cos(-math.pi/2), 0, abs_tol=ulp(1))
@@ -461,6 +464,7 @@ def testCos(self):
461464
self.assertRaises(ValueError, math.cos, NINF)
462465
self.assertTrue(math.isnan(math.cos(NAN)))
463466

467+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
464468
def testCosh(self):
465469
self.assertRaises(TypeError, math.cosh)
466470
self.ftest('cosh(0)', math.cosh(0), 1)
@@ -1013,6 +1017,7 @@ def testSin(self):
10131017
self.assertRaises(ValueError, math.sin, NINF)
10141018
self.assertTrue(math.isnan(math.sin(NAN)))
10151019

1020+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
10161021
def testSinh(self):
10171022
self.assertRaises(TypeError, math.sinh)
10181023
self.ftest('sinh(0)', math.sinh(0), 0)
@@ -1032,6 +1037,7 @@ def testSqrt(self):
10321037
self.assertRaises(ValueError, math.sqrt, NINF)
10331038
self.assertTrue(math.isnan(math.sqrt(NAN)))
10341039

1040+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
10351041
def testTan(self):
10361042
self.assertRaises(TypeError, math.tan)
10371043
self.ftest('tan(0)', math.tan(0), 0)
@@ -1045,6 +1051,7 @@ def testTan(self):
10451051
self.assertRaises(ValueError, math.tan, NINF)
10461052
self.assertTrue(math.isnan(math.tan(NAN)))
10471053

1054+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
10481055
def testTanh(self):
10491056
self.assertRaises(TypeError, math.tanh)
10501057
self.ftest('tanh(0)', math.tanh(0), 0)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ def test_instance_dict_leak(self):
361361
memio = self.ioclass()
362362
memio.foo = 1
363363

364+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
364365
def test_pickling(self):
365366
buf = self.buftype("1234567890")
366367
memio = self.ioclass(buf)
@@ -442,6 +443,7 @@ def test_read1(self):
442443
self.assertRaises(TypeError, memio.read1)
443444
self.assertEqual(memio.read(), buf)
444445

446+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
445447
def test_readinto(self):
446448
buf = self.buftype("1234567890")
447449
memio = self.ioclass(buf)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ def copy(self, obj, proto):
511511
with support.swap_item(sys.modules, 'operator', self.module2):
512512
return pickle.loads(pickled)
513513

514+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
514515
def test_attrgetter(self):
515516
attrgetter = self.module.attrgetter
516517
class A:
@@ -539,6 +540,7 @@ class A:
539540
self.assertEqual(repr(f2), repr(f))
540541
self.assertEqual(f2(a), f(a))
541542

543+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
542544
def test_itemgetter(self):
543545
itemgetter = self.module.itemgetter
544546
a = 'ABCDE'
@@ -554,6 +556,7 @@ def test_itemgetter(self):
554556
self.assertEqual(repr(f2), repr(f))
555557
self.assertEqual(f2(a), f(a))
556558

559+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
557560
def test_methodcaller(self):
558561
methodcaller = self.module.methodcaller
559562
class A:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ def test_repr(self):
358358
self.assertEqual(repr(range(1, 2)), 'range(1, 2)')
359359
self.assertEqual(repr(range(1, 2, 3)), 'range(1, 2, 3)')
360360

361+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
361362
def test_pickling(self):
362363
testcases = [(13,), (0, 11), (-22, 10), (20, 3, -1),
363364
(13, 21, 3), (-2, 2, 2), (2**65, 2**65+2)]

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def tearDown(self):
196196
class TestAsciiFileShelve(TestShelveBase):
197197
_args={'protocol':0}
198198
_in_mem = False
199+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
199200
class TestBinaryFileShelve(TestShelveBase):
200201
_args={'protocol':1}
201202
_in_mem = False

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def bigendian_to_native(value):
3030
return string_reverse(value)
3131

3232
class StructTest(unittest.TestCase):
33+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
3334
def test_isbigendian(self):
3435
self.assertEqual((struct.pack('=i', 1)[0] == 0), ISBIGENDIAN)
3536

@@ -54,6 +55,7 @@ def test_consistence(self):
5455
self.assertRaises(struct.error, struct.unpack, 'iii', s)
5556
self.assertRaises(struct.error, struct.unpack, 'i', s)
5657

58+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
5759
def test_transitiveness(self):
5860
c = b'a'
5961
b = 1
@@ -78,6 +80,7 @@ def test_transitiveness(self):
7880
self.assertEqual(int(100 * dp), int(100 * d))
7981
self.assertEqual(tp, t)
8082

83+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
8184
def test_new_features(self):
8285
# Test some of the new features in detail
8386
# (format, argument, big-endian result, little-endian result, asymmetric)
@@ -332,6 +335,7 @@ def assertStructError(func, *args, **kwargs):
332335
assertStructError(struct.pack, format, 0)
333336
assertStructError(struct.unpack, format, b"")
334337

338+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
335339
def test_p_code(self):
336340
# Test p ("Pascal string") code.
337341
for code, input, expected, expectedback in [
@@ -348,6 +352,7 @@ def test_p_code(self):
348352
(got,) = struct.unpack(code, got)
349353
self.assertEqual(got, expectedback)
350354

355+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
351356
def test_705836(self):
352357
# SF bug 705836. "<f" and ">f" had a severe rounding bug, where a carry
353358
# from the low-order discarded bits could propagate into the exponent
@@ -381,6 +386,7 @@ def test_705836(self):
381386
big = math.ldexp(big, 127 - 24)
382387
self.assertRaises(OverflowError, struct.pack, ">f", big)
383388

389+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
384390
def test_1530559(self):
385391
for code, byteorder in iter_integer_formats():
386392
format = byteorder + code
@@ -475,6 +481,7 @@ def test_unpack_with_buffer(self):
475481
value, = struct.unpack('>I', data)
476482
self.assertEqual(value, 0x12345678)
477483

484+
@unittest.skipIfGraalPython(reason="not yet supported, causes SEGFAULT")
478485
def test_bool(self):
479486
class ExplodingBool(object):
480487
def __bool__(self):

0 commit comments

Comments
 (0)