[Python-bugs-list] [ python-Bugs-678264 ] test_resource fails when file size is limited

SourceForge.net noreply@sourceforge.net
Sun, 30 Mar 2003 12:25:06 -0800


Bugs item #678264, was opened at 2003-01-31 13:06
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=678264&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Neal Norwitz (nnorwitz)
>Assigned to: Martin v. Löwis (loewis)
Summary: test_resource fails when file size is limited

Initial Comment:
test_resource does:

   print resource.RLIM_INFINITY == max

I'm not sure of the benefit of this line.  For machines 
which have limited file sizes, it causes the test to fail.  
Otherwise the test seems to work properly.

----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2003-03-30 15:25

Message:
Logged In: YES 
user_id=33168

Hmmm, sounds like a lot of work.  How about something like this:

    expected_max = resource.RLIM_INFINITY
    if expected_max != max:
        # read the file resource limit
        fsize_ulimit = os.popen('ulimit -f').read()
        try:
            # convert the file size to bytes (from 512 byte
blocks)
            expected_max = int(fsize_ulimit.strip()) * 512
        except ValueError:
            raise TestSkipped, "unable to determine expected
resource value"
    print expected_max == max

This works, but I'm pretty sure this is not portable.  On
Linux blocks are 1k.  This only works when the block size is
512 bytes.  Shall we close this bug as a test environment
problem and won't fix?

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2003-03-30 11:15

Message:
Logged In: YES 
user_id=21627

The rationale of the line is explained in the comment: The
code tests whether the limit is a really large number, i.e.
whether represenation of large limits works.

Unfortunately, it doesn't  (which is a separate issue): On
Linux, RLIM_INFINITY is reported as -1. This comes from
RLIM_INFINITY being the larges unsigned long long number,
i.e. 0xffffffffffffffffuLL. The resource module represents
this incorrectly.

I think there is no way to verify that Python computes the
real limit correctly (unless we invoke the shell's ulimit
for comparison). So you could weaken the test to verify that
the limit is non-negative (and, as a side effect, verify
that it doesn't raise an exception).

If you do so, you'll also have to fix the implementation, so
that the weakened-strengthened test passes on Linux.

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2003-03-03 17:17

Message:
Logged In: YES 
user_id=33168

Martin, welcome back!  Now I get to assign some bugs to you
to see if you have any input. :-)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=678264&group_id=5470