Changeset 1670

Show
Ignore:
Timestamp:
07/21/08 13:41:06 (6 months ago)
Author:
alo
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee/trunk/ChangeLog

    r1665 r1670  
     12008-07-21  Alvaro Lopez Ortega  <alvaro@alobbs.com> 
     2 
     3        * qa/run-tests.py (mainloop_iterator): Fixes a really nasty bug 
     4        that was making the QA sets to report weird errors. 
     5 
    162008-07-18  Alvaro Lopez Ortega  <alvaro@alobbs.com> 
    27 
  • cherokee/trunk/qa/base.py

    r1667 r1670  
    1717from conf import * 
    1818from util import * 
     19 
     20DEFAULT_READ = 8192 
    1921 
    2022def importfile(path): 
     
    4143         
    4244    def _initialize (self): 
    43         self.ssl               = None 
    44         self.reply             = ""      # "200 OK".. 
    45         self.version           = None    # HTTP/x.y: 9, 0 or 1 
    46         self.reply_err         = None    # 200 
     45        self.ssl                     = None 
     46        self.reply                   = ""      # "200 OK".. 
     47        self.version                 = None    # HTTP/x.y: 9, 0 or 1 
     48        self.reply_err               = None    # 200 
     49 
     50    def _safe_read (self, s): 
     51         while True:  
     52            try: 
     53                if self.ssl: 
     54                    return self.ssl.read (DEFAULT_READ) 
     55                else: 
     56                    return s.recv (DEFAULT_READ) 
     57            except socket.error, (err, strerr): 
     58                if err == errno.EAGAIN or \ 
     59                   err == errno.EWOULDBLOCK or \ 
     60                   err == errno.EINPROGRESS: 
     61                    continue 
     62            raise 
    4763 
    4864    def _do_request (self, port, ssl): 
     
    8399        while True: 
    84100            try: 
    85                 if self.ssl: 
    86                     d = self.ssl.read(8192) 
    87                 else: 
    88                     d = s.recv(8192) 
    89             except: 
     101                d = self._safe_read (s) 
     102            except Exception, e: 
    90103                d = '' 
    91104 
     
    97110 
    98111    def _parse_output (self): 
    99         if (len(self.reply) == 0): 
     112        if not len(self.reply): 
    100113            raise Exception("Empty header") 
    101              
    102         lines = string.split(self.reply, "\n") 
    103         reply = lines[0]         
    104  
     114 
     115        # Protocol version 
     116        reply = self.reply.split('\r', 1)[0] 
    105117        if reply[:8] == "HTTP/0.9": 
    106118            self.version = 9 
     
    112124            raise Exception("Invalid header, len=%d: '%s'" % (len(reply), reply)) 
    113125 
     126        # Error code 
    114127        reply = reply[9:] 
    115  
    116128        try: 
    117129            self.reply_err = int (reply[:3]) 
    118130        except: 
    119131            raise Exception("Invalid header, version=%d len=%d: '%s'" % (self.version, len(reply), reply)) 
    120  
    121         return 0 
    122132 
    123133    def _check_result_expected_item (self, item): 
  • cherokee/trunk/qa/run-tests.py

    r1667 r1670  
    363363                if not its_clean: 
    364364                    print e 
    365                     print obj 
     365                    print_sec(obj) 
    366366                    clean_up() 
    367367                sys.exit(1) 
     
    370370                if not its_clean: 
    371371                    print MESSAGE_FAILED 
    372                     print obj 
     372                    print_sec (obj) 
    373373                    clean_up() 
    374374                sys.exit(1) 
     
    396396    time.sleep(t) 
    397397 
    398     thread.start_new_thread (mainloop_iterator, (objs[:], False)) 
     398    thread.start_new_thread (mainloop_iterator, (copy.deepcopy(objs), False)) 
    399399 
    400400# Execute the tests 
  • cherokee/trunk/qa/util.py

    r1609 r1670  
    1 import os, sys, time, random 
     1import os, sys, time, random, fcntl 
     2 
    23from conf import * 
    34 
     
    220221    return cherokee_build_info_has ("Built-in", module) 
    221222 
     223def print_sec (content): 
     224    fcntl.flock (sys.stdout, fcntl.LOCK_EX) 
     225    print content 
     226    fcntl.flock (sys.stdout, fcntl.LOCK_UN)