Commit e5ccd0db authored by Adam P. Goucher's avatar Adam P. Goucher

Coverage

parent 2a8f8eaa
Pipeline #54814328 passed with stages
in 8 minutes and 11 seconds
......@@ -57,10 +57,10 @@ def ensure_stack(required):
try:
import resource
sl, hl = resource.getrlimit(resource.RLIMIT_STACK)
if (sl < required):
if 0 < sl < required: # Pythonic chained comparators
resource.setrlimit(resource.RLIMIT_STACK, (required, hl))
sl, hl = resource.getrlimit(resource.RLIMIT_STACK)
return (sl, hl)
return (sl, hl)
except Exception as e:
return None
......@@ -182,6 +182,7 @@ class WrappedLibrary(object):
def __init__(self, soname, local_bash=None, local_python='python'):
self.last_power = 800
soname = os.path.abspath(soname)
if local_bash is None:
......@@ -222,13 +223,14 @@ class WrappedLibrary(object):
if (powerof2 > 65536):
raise ValueError("%s exceeds maximum of 2 ^^ 5" % pname)
if (powerof2 > 800):
if (powerof2 > self.last_power):
x = self('EnsureStack', powerof2 * 768)
if x is None:
import warnings
warnings.warn("Could not ensure stack size, probably due to running on Windows. Expect segfaults soon.")
else:
print("Stack size limit increased to (%d, %d)" % x)
self.last_power = powerof2
def __del__(self):
......
......@@ -14,6 +14,12 @@ class TestGoL(unittest.TestCase):
self.sess = lifelib.load_rules('b3s23')
self.lt = self.sess.lifetree(memory=1000, n_layers=4)
def test_ulimit(self):
self.sess.lifelib.ensure_limit(10000, 1)
self.sess.lifelib.ensure_limit(20000, 1)
self.sess.lifelib.ensure_limit(10000, 1)
def test_components(self):
pat = self.lt.pattern('''7b3o5b3o16b3o5b3o$6bo2bo5bo2bo15bo2bo3bo2bo$6bo3bo3bo3bo15bo9bo$7b4o3b
......
......@@ -2,7 +2,7 @@ import unittest
import lifelib
import os
oca_rules = ['g4b2ikn3ais345', 'b36s23', 'g3b3s23', 'r7b65t95s65t114', 'g11b3s23', 'r2b1e7108s3e7c80']
oca_rules = ['g4b2ikn3ais345', 'b36s23', 'g3b3s23', 'r7b65t95s65t114', 'g11b3s23', 'r2b1e7108s3e7c80', 'b347s3456f038k234567l0346']
class TestOtherRules(unittest.TestCase):
......@@ -15,6 +15,13 @@ class TestOtherRules(unittest.TestCase):
self.sess = lifelib.load_rules(*oca_rules)
def test_bsfkl(self):
lt = self.sess.lifetree()
apgcode = 'xq20_xeefz77_y2g5zw55'
ss = lt.pattern(apgcode, 'b347s3456f038k234567l0346')
self.assertEqual(ss.period, 20)
def test_uint64(self):
try:
......
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