HP/UX 11 test_socket failure

Anders Qvist <[email protected]> Sat, 19 Oct 2002 00:20:03 +0200
Newsgroups gmane.comp.python.snake-farm.user
Message-ID <[email protected]>
Guido, you said a while back that the test_failure

test test_socket failed -- Traceback (most recent call last):
  File "/mp/slaskdisk/tmp/xenofarm/python/taylor.lysator.liu.se/buildtmp/dist/python/dist/src/Lib/test/test_socket.py", line 495, in testRecv
    self.fail("Error trying to do non-blocking recv.")
  File "/mp/slaskdisk/tmp/xenofarm/python/taylor.lysator.liu.se/buildtmp/dist/python/dist/src/Lib/unittest.py", line 260, in fail
    raise self.failureException, msg
AssertionError: Error trying to do non-blocking recv.

.. was due to some timeout being too short. I can't seem to find your
comment.

Anyway, this is the relevant failing code:

    def testRecv(self):
        # Testing non-blocking recv
        conn, addr = self.serv.accept()
        conn.setblocking(0)
        try:
            msg = conn.recv(len(MSG))
        except socket.error:
            pass
        else:
495>        self.fail("Error trying to do non-blocking recv.")
        read, write, err = select.select([conn], [], [])
        if conn in read:
            msg = conn.recv(len(MSG))
            self.assertEqual(msg, MSG)
        else:
            self.fail("Error during select call to non-blocking socket.")

    def _testRecv(self):
        self.cli.connect((HOST, PORT))
        time.sleep(0.1)
        self.cli.send(MSG)

If I understand the test correctly, it is first trying to read from
the newly accepted socket, which should fail with a socket.error, as
there is no data to be read yet (the client sleeps and no select call
yet). However, it seems there is no exception being raised; adding a:

    except:
        self.fail("gazonk")

isn't triggered. Lengthening the client sleep statement to one second
doesn't help, either. It seems msg is a zero length string:

    if (type(msg) == types.StringType): print "foo"

... gives foo.

Does this mean that some underlying system call returns something
unexpected on HP/UX? Find out in the next installment of the
mystery of the non-blocking socket; part 2: HP/UX socket API. (I gotta
go away for a day and will be back sunday).

--
Anders "Quest" Qvist

"We've all heard that a million monkeys banging on a million typewriters
will eventually reproduce the entire works of Shakespeare. Now, thanks 
to the Internet, we know this is not true." -- Robert Wilensky