[Piglit] [PATCH 0/6] Recursion tests v2 and fix OOM tests

Jose Fonseca jfonseca at vmware.com
Thu Jul 28 04:22:53 PDT 2011



----- Original Message -----
> This patch series does a couple things.  First, it adds the ability
> to
> limit the amount of memory that a test can use.  There are several
> test cases (including ones added in this series) that can exhaust
> system memory on failing implementations.  Setting the rlimit
> prevents
> this unfriendly behavior.  The rlimit can be set either via the
> command line (-rlimit option) or in the .shader_test file (rlimit in
> the requirements section).
> 
> The second thing it does is resubmit my GLSL recursion tests with an
> rlimit set in all.tests.
> 
> Finally, it sets an rlimit for the glsl-*-explosion tests and removes
> them from the blacklist.
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
> 

Another place to do this is in the piglit python framework, via subprocess's preexec_fn argument.

I have code to do that for several OSes in a bunch of scripts I use to automate many GL testsuites with Hudson/Jenkins. I'm working on folding some of these into piglit python framework, but I haven't been able to do this.

FWIW, below are the relevant bits:

    # http://www.velocityreviews.com/forums/t587425-python-system-information.html

    _meminfo_re = re.compile(r'^(?P<key>\S*):\s*(?P<value>\d*)\s*kB' )

    def meminfo():
        """-> dict of data from meminfo (str:int).
        Values are in kilobytes.
        """
        result = {}
        for line in open('/proc/meminfo'):
            match = _meminfo_re.match(line)
            if match:
                key, value = match.groups(['key', 'value'])
                result[key] = int(value) * 1024
        return result

    def total_physical_memory():
        return meminfo()['MemTotal']

    def preexec_fn():
        # http://stackoverflow.com/questions/1689505/python-ulimit-and-nice-for-subprocess-call-subprocess-popen
        import resource

        # Generate core files so that we can see back traces
        if sys.platform == 'darwin':
            lim = resource.RLIM_INFINITY
        else:
            lim = 128*1024*1024
        resource.setrlimit(resource.RLIMIT_CORE, (lim, lim))
        
        # Don't let the test program to use more than 3/4 of the physical memory, to prevent excessive swapping, or termination of the test harness programs via OOM
        maxmem = total_physical_memory()*3/4
        resource.setrlimit(resource.RLIMIT_AS, (maxmem, maxmem))

    p = subprocess.Popen(
        args, 
        preexec_fn = preexec_fn,
    )

I also have code for timeouts etc.


IMHO, the python harness is a better place for health monitoring / limit enforcing, first because in certain OSes (such as Window) is impossible to do from inside the program reliably; second because it makes it easier to integrate w


I also think this should be enabled in all tests, not just these ones.


Jose


More information about the Piglit mailing list