Blame SOURCES/0004-Test-for-reset-fixes-refcount-bug.patch

fcfddd
From 206c15ea32e05ae98827d00626a101e33a7bec70 Mon Sep 17 00:00:00 2001
fcfddd
From: zanee <zanee>
fcfddd
Date: Wed, 28 Apr 2010 16:03:40 +0000
fcfddd
Subject: [PATCH 4/5] Test for reset fixes refcount bug
fcfddd
fcfddd
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
fcfddd
---
fcfddd
 tests/test_reset.py |   74 +++++++++++++++++++++++++++++++++++++++++++++++++++
fcfddd
 1 files changed, 74 insertions(+), 0 deletions(-)
fcfddd
 create mode 100644 tests/test_reset.py
fcfddd
fcfddd
diff --git a/tests/test_reset.py b/tests/test_reset.py
fcfddd
new file mode 100644
fcfddd
index 0000000..c350d17
fcfddd
--- /dev/null
fcfddd
+++ b/tests/test_reset.py
fcfddd
@@ -0,0 +1,74 @@
fcfddd
+#!/usr/bin/python
fcfddd
+
fcfddd
+import sys
fcfddd
+import pycurl
fcfddd
+
fcfddd
+saw_error = 1
fcfddd
+
fcfddd
+def main():
fcfddd
+        global saw_error
fcfddd
+
fcfddd
+        pycurl.global_init(pycurl.GLOBAL_DEFAULT)
fcfddd
+
fcfddd
+        outf = file("/dev/null", "rb+")
fcfddd
+        cm = pycurl.CurlMulti()
fcfddd
+
fcfddd
+        # Set multi handle's options
fcfddd
+        cm.setopt(pycurl.M_PIPELINING, 1)
fcfddd
+
fcfddd
+        eh = pycurl.Curl()
fcfddd
+
fcfddd
+        for x in range(1, 20):
fcfddd
+
fcfddd
+                eh.setopt(pycurl.WRITEDATA, outf)
fcfddd
+                eh.setopt(pycurl.URL, sys.argv[1])
fcfddd
+                cm.add_handle(eh)
fcfddd
+
fcfddd
+                while 1:
fcfddd
+                        ret, active_handles = cm.perform()
fcfddd
+                        if ret != pycurl.E_CALL_MULTI_PERFORM:
fcfddd
+                                break
fcfddd
+
fcfddd
+                while active_handles:
fcfddd
+                        ret = cm.select(1.0)
fcfddd
+                        if ret == -1:
fcfddd
+                                continue
fcfddd
+                        while 1:
fcfddd
+                                ret, active_handles = cm.perform()
fcfddd
+                                if ret != pycurl.E_CALL_MULTI_PERFORM:
fcfddd
+                                        break
fcfddd
+
fcfddd
+                count, good, bad = cm.info_read()
fcfddd
+
fcfddd
+                for h, en, em in bad:
fcfddd
+                        print "Transfer to %s failed with %d, %s\n" % \
fcfddd
+                            (h.getinfo(pycurl.EFFECTIVE_URL), en, em)
fcfddd
+                        raise RuntimeError
fcfddd
+
fcfddd
+                for h in good:
fcfddd
+                        httpcode = h.getinfo(pycurl.RESPONSE_CODE)
fcfddd
+                        if httpcode != 200:
fcfddd
+                                print "Transfer to %s failed with code %d\n" %\
fcfddd
+                                    (h.getinfo(pycurl.EFFECTIVE_URL), httpcode)
fcfddd
+                                raise RuntimeError
fcfddd
+
fcfddd
+                        else:
fcfddd
+                                print "Recd %d bytes from %s" % \
fcfddd
+                                    (h.getinfo(pycurl.SIZE_DOWNLOAD),
fcfddd
+                                    h.getinfo(pycurl.EFFECTIVE_URL))
fcfddd
+
fcfddd
+                cm.remove_handle(eh)
fcfddd
+                eh.reset()
fcfddd
+
fcfddd
+        eh.close()
fcfddd
+        cm.close()
fcfddd
+        outf.close()
fcfddd
+
fcfddd
+        pycurl.global_cleanup()
fcfddd
+
fcfddd
+
fcfddd
+if __name__ == '__main__':
fcfddd
+        if len(sys.argv) != 2:
fcfddd
+                print "Usage: %s <url>" % sys.argv[0]
fcfddd
+                sys.exit(2)
fcfddd
+        main()
fcfddd
-- 
fcfddd
1.7.1
fcfddd