Changeset 1238 for TI05-delivery


Ignore:
Timestamp:
26/06/06 16:16:23 (13 years ago)
Author:
spascoe
Message:

Fixed the client API testcase problem. The client and server modules
cannot be linked into the same python interpreter, presumably because of
symbol conflicts. This should only be an issue during testing so I've created
the runclient.py script to circumvent it. There are now a set of test cases that wrap both client and server in python.

bbftp.c has been ammended to ensure all global variables are reset on each
invocation of bbftpc_main().

Location:
TI05-delivery/trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/trunk/lib/python/delivery/server.py

    r1195 r1238  
    99@author Stephen Pascoe 
    1010""" 
     11 
     12#!NOTE: Importing bbftpd and bbftpc together is dangerous and will cause stange errors. 
     13import sys 
     14if sys.modules.has_key('delivery.bbftpc'): 
     15    raise ImportError, "delivery.bbftpc extension already loaded.  You cannot use both client and server extensions together" 
     16 
    1117 
    1218import bbftpd 
  • TI05-delivery/trunk/setup.py

    r1198 r1238  
    117117                                    ('_LARGEFILE64_SOURCE', 1), 
    118118                                    ('NDG_PYTHON_EMBED', 1), 
    119                                     ('NDG_DELIVERY_VERSION', '"%s"' % version)], 
     119                                    ('NDG_DELIVERY_VERSION', version)], 
    120120                   include_dirs = [bbftpd_home+'/includes', bbftpd_home+'/bbftpd'], 
    121121                   libraries = ['crypt', 'crypto'], 
     
    126126                                    ('_LARGEFILE64_SOURCE', 1), 
    127127                                    ('NDG_PYTHON_EMBED', 1), 
    128                                     ('NDG_DELIVERY_VERSION', '"%s"' % version)], 
     128                                    ('NDG_DELIVERY_VERSION', version)], 
    129129                   include_dirs = [bbftpc_home+'/includes', bbftpc_home+'/bbftpc'], 
    130130                   libraries = ['crypt', 'crypto'], 
  • TI05-delivery/trunk/src/bbftp-client-3.2.0/bbftpc/bbftp.c

    r1157 r1238  
    370370 
    371371#ifdef NDG_PYTHON_EMBED 
     372/** Reset all global variables to how they were first initialised. 
     373 */ 
     374void bbftpc_reset_globals(void) { 
     375 
     376  state   = SETTOZERO ; 
     377  timestamp = SETTOZERO ; 
     378   
     379  protocolmin = 2 ;  
     380  protocolmax = 3 ;  
     381  //int     protocol ; 
     382  debug = SETTOZERO ; 
     383  verbose = SETTOZERO ; 
     384  warning = SETTOZERO ; 
     385  statoutput = SETTOZERO ; 
     386  globaltrymax = NBTRYMAX ; 
     387  newcontrolport = CONTROLPORT ; 
     388  usessh = SETTOZERO ; 
     389  sshbatchmode  = SETTOZERO ; 
     390  sshchildpid   = SETTOZERO ; 
     391  sshidentityfile = NULL ; 
     392  sshremotecmd = NULL ; 
     393  sshcmd = NULL ; 
     394   
     395  usecert = SETTOZERO ; 
     396  useprivate = SETTOZERO ; 
     397  privatestr = NULL ; 
     398   
     399  //struct sockaddr_in hisctladdr ; 
     400  //struct sockaddr_in myctladdr ; 
     401  bbftprc = NULL ; 
     402  //int     localumask ; 
     403#if defined(WITH_RFIO) || defined(WITH_RFIO64) 
     404  localcos  = SETTOZERO ; 
     405#endif 
     406   
     407  newcmd = NULL; 
     408  //int remoterfio; 
     409  //int localrfio; 
     410  sendwinsize     = 256 ; 
     411  recvwinsize     = 256 ; 
     412  nbport = 1 ; 
     413  ackto                 = ACKTO; 
     414  recvcontrolto = CONTROLSOCKTO; 
     415  sendcontrolto = SENDCONTROLTO; 
     416  datato                        = DATASOCKTO; 
     417   
     418  remoteumask = SETTOZERO ; 
     419  remotecos   = -1 ; 
     420  remotedir = NULL ; 
     421  //int     incontrolsock ; 
     422  //int     outcontrolsock ; 
     423  myexitcode = SETTOZERO ; 
     424  hostname   = NULL ; 
     425  hp = NULL ; 
     426  username   = NULL ; 
     427  password   = NULL ; 
     428#ifdef CERTIFICATE_AUTH 
     429  service    = NULL ; 
     430#endif 
     431  mychildren = NULL ; 
     432  //int     nbpidchild ; 
     433#ifdef CASTOR 
     434  castfd = -1 ; 
     435  castfilename = NULL ; 
     436#endif 
     437  transferoption = TROPT_TMP | TROPT_DIR | TROPT_MODE | TROPT_ACC;  
     438  filemode ; 
     439  lastaccess[9] ; 
     440  lastmodif[9] ; 
     441  buffersizeperstream = 256 ; 
     442  //int     requestedstreamnumber ; 
     443  //my64_t  filesize ; 
     444  curfilename = NULL ; 
     445  realfilename   = NULL ; 
     446  myports        = NULL ; 
     447  mysockets      = NULL ; 
     448  readbuffer     = NULL ; 
     449  compbuffer     = NULL ;  
     450  resfd = -1 ; 
     451  simulation_mode = SETTOZERO; 
     452   
     453  connectionisbroken = SETTOZERO ; 
     454   
     455  pasvport_min = 0 ; 
     456  pasvport_max = 0 ; 
     457   
     458  commandList = NULL; 
     459  first = NULL; 
     460  iterator = NULL; 
     461} 
     462 
     463#endif // NDG_PYTHON_EMBED 
     464 
     465 
     466#ifdef NDG_PYTHON_EMBED 
    372467bbftpc_main(int argc, char **argv, char **envp) { 
     468  bbftpc_reset_globals(); 
     469   
    373470#else 
    374471main(argc, argv, envp) 
  • TI05-delivery/trunk/src/python_ext/bbftpc.c

    r1187 r1238  
    7373  Py_DECREF(client_args); 
    7474 
    75   for (i=0; i<argv_s.argc; i++) { 
    76     fprintf(stderr, "delivery.bbftpc.run argument: %s\n", argv_s.argv[i]); 
    77   } 
    78    
    7975  bbftpc_main(argv_s.argc, argv_s.argv, environ); 
    8076  ndg_argv_clear(&argv_s); ndg_argv_free(&argv_s); 
  • TI05-delivery/trunk/test/test_embedded.py

    r1195 r1238  
    224224 
    225225        lines = self._readSyslog() 
     226 
    226227        self.assertLines(['.*AuthContext received Auth message: NDG-Delivery-client %s' % VERSION], lines) 
    227228 
     
    339340# Embedded client test case currently segfaults :-( 
    340341# 
    341 ## import delivery.bbftpc 
    342 ## import StringIO 
    343  
    344 ## class PythonClientAuthOK(AuthOK): 
    345 ##     """Repeat AuthOK tests with a python-embedded client. 
    346 ##     """ 
    347  
    348 ##     def _runClient(self, cmd, debug=False, user="testcase", privatestr=None): 
    349 ##         """Run the client. 
    350 ##         """ 
    351  
    352 ##         #print "Waiting for gdb connect, pid = %d" % os.getpid() 
    353 ##         #time.sleep(15) 
    354  
    355 ##         if debug: 
    356 ##             f = "-d" 
    357 ##         else: 
    358 ##             f = "-m" 
    359  
    360 ##         # Tell bbftp to dump output to a file which is then opened for reading. 
    361 ##         tmp = tempfile.mktemp('test_bbftpd') 
    362 ##         args = ['-e', cmd, f, '-u', user, 
    363 ##                 #'-o', tmp, '-f', tmp, 
    364 ##                 '-r', '1'] 
    365  
    366 ##         if privatestr != None: 
    367 ##             args += ['-P', privatestr] 
    368  
    369 ##         args.append('localhost') 
    370 ##         print "Running client with args: %s" % (args,) 
    371  
    372 ##         delivery.bbftpc.run(args) 
    373  
    374 ##         #fh = open(tmp) 
    375 ##         #os.remove(tmp) 
    376 ##         fh = StringIO.StringIO('') 
    377  
    378 ##         return fh 
     342 
     343class PythonClientAuthOK(AuthOK): 
     344    """Repeat AuthOK tests with a python-embedded client. 
     345    """ 
     346 
     347    def _runClient(self, cmd, debug=False, user="testcase", privatestr=None): 
     348        """Run the client. 
     349        """ 
     350 
     351        if debug: 
     352            f = "-d" 
     353        else: 
     354            f = "-m" 
     355 
     356        args = ['-e', repr(cmd), f, '-u', user, 
     357                '-r', '1'] 
     358 
     359        if privatestr != None: 
     360            args += ['-P', privatestr] 
     361 
     362        args.append('localhost') 
     363 
     364        fh = os.popen('%s/test/runclient.py %s' % (HOME, ' '.join(args))) 
     365 
     366        return fh 
    379367 
    380368if __name__ == '__main__': 
Note: See TracChangeset for help on using the changeset viewer.