Changeset 979 for TI05-delivery/trunk


Ignore:
Timestamp:
22/05/06 16:44:22 (13 years ago)
Author:
spascoe
Message:

Added TestCase? that checks private_auth initialisation and finalisation routines
happen.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/trunk/test/test_bbftpd.py

    r974 r979  
    1010import os, signal, time, syslog 
    1111from glob import glob 
    12  
     12import re 
    1313 
    1414class ExtendedAPITestCase(unittest.TestCase): 
     
    3737        except Exception, e: 
    3838            self.fail(e) 
     39 
     40    def testStartupWithSyslog(self): 
     41        try: 
     42            self._startServer() 
     43            pid = self._getServerPids()[0] 
     44            self._stopServer(pid) 
     45 
     46            lines = self._readSyslog() 
     47            self.assert_(len(lines) == 2) 
     48            self.assert_(re.search('initialising private auth', lines[0])) 
     49            self.assert_(re.search('finalising private auth', lines[1])) 
     50 
     51        except Exception, e: 
     52            self.fail(e) 
     53             
    3954 
    4055    #------------------------------------------------------------------------------ 
     
    6580        raise RuntimeError, 'Failed to stop server' 
    6681 
     82    def _readSyslog(self, logfile="/var/log/messages"): 
     83        """Get all bbftpd messages from syslog for this test case. 
     84 
     85        @note: This requires read access to the logfile 
     86        """ 
     87 
     88        # Read the logfile into a buffer 
     89        log = open(logfile).readlines() 
     90 
     91        # Find the latest testcase marker 
     92        start_i = 0 
     93        for i in xrange(len(log)-1, -1, -1): 
     94            if re.search('test_bbftpd.py: Starting ExtendedAPITestCase', log[i]): 
     95                start_i = i+1 
     96                break 
     97        if not start_i: 
     98            raise RuntimeError, "Can't find test case entry in syslog" 
     99 
     100        filtered_log = [] 
     101        for line in log[start_i:]: 
     102            if re.search(r'test_bbftpd.py:|bbftpd .*:', line): 
     103                filtered_log.append(line) 
     104 
     105        return filtered_log 
     106 
     107 
    67108 
    68109if __name__ == '__main__': 
Note: See TracChangeset for help on using the changeset viewer.