The logic in this test was wrong, but masked by other problems still existing in our python bindings. The fourth test claims to fail during only chunk, but passed '42' as the user_data for callback which requires that err.value be 0; if .chunk had actually failed, err.value should be non-zero. We're overloading a single user_data int to try and control two orthogonal things (what to expect in err, and whether to fail); let's instead make the callback user_data a tuple. Fixes: e7d29712 --- python/t/505-aio-pread-callback.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/python/t/505-aio-pread-callback.py b/python/t/505-aio-pread-callback.py index 8d71c38..3a90a0c 100644 --- a/python/t/505-aio-pread-callback.py +++ b/python/t/505-aio-pread-callback.py @@ -34,19 +34,19 @@ def chunk (user_data, buf2, offset, s, err): assert s == nbd.READ_DATA def callback (user_data, err): - print ("in callback, user_data %d" % user_data) - if user_data <= 43: + print ("in callback, user_data %d,%d" % user_data) + if user_data[0] == 42: assert err.value == 0 else: assert err.value == errno.EPROTO err.value = errno.ENOMEM - assert user_data == 42 + assert user_data[1] == 42 # First try: succeed in both callbacks buf = nbd.Buffer (512) cookie = h.aio_pread_structured (buf, 0, lambda *args: chunk (42, *args), - lambda *args: callback (42, *args)) + lambda *args: callback ((42, 42), *args)) while not (h.aio_command_completed (cookie)): h.poll (-1) @@ -60,7 +60,7 @@ assert buf == expected buf = nbd.Buffer (512) cookie = h.aio_pread_structured (buf, 0, lambda *args: chunk (42, *args), - lambda *args: callback (43, *args)) + lambda *args: callback ((42, 43), *args)) try: while not (h.aio_command_completed (cookie)): h.poll (-1) @@ -72,7 +72,7 @@ except nbd.Error as ex: buf = nbd.Buffer (512) cookie = h.aio_pread_structured (buf, 0, lambda *args: chunk (43, *args), - lambda *args: callback (44, *args)) + lambda *args: callback ((43, 43), *args)) try: while not (h.aio_command_completed (cookie)): h.poll (-1) @@ -84,7 +84,7 @@ except nbd.Error as ex: buf = nbd.Buffer (512) cookie = h.aio_pread_structured (buf, 0, lambda *args: chunk (43, *args), - lambda *args: callback (42, *args)) + lambda *args: callback ((43, 42), *args)) try: while not (h.aio_command_completed (cookie)): h.poll (-1) -- 2.20.1