summaryrefslogtreecommitdiff
path: root/tests/test-l7.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-l7.py')
-rwxr-xr-xtests/test-l7.py32
1 files changed, 25 insertions, 7 deletions
diff --git a/tests/test-l7.py b/tests/test-l7.py
index aed34f411..e5f473b56 100755
--- a/tests/test-l7.py
+++ b/tests/test-l7.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2015 Nicira, Inc.
+# Copyright (c) 2015, 2016 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -48,24 +48,42 @@ def get_ftpd():
return server
+def get_tftpd():
+ try:
+ from tftpy import TftpServer, TftpShared
+
+ class OVSTFTPServer(TftpServer):
+ def __init__(self, listen, handler=None):
+ (ip, port) = listen
+ self.ip = ip
+ self.port = port
+ TftpServer.__init__(self, tftproot='./')
+
+ def serve_forever(self):
+ self.listen(self.ip, self.port)
+ server = [OVSTFTPServer, None, TftpShared.DEF_TFTP_PORT]
+ except ImportError:
+ server = None
+ pass
+ return server
+
+
def main():
SERVERS = {
'http': [TCPServer, SimpleHTTPRequestHandler, 80],
'http6': [TCPServerV6, SimpleHTTPRequestHandler, 80],
+ 'ftp': get_ftpd(),
+ 'tftp': get_tftpd(),
}
- ftpd = get_ftpd()
- if ftpd is not None:
- SERVERS['ftp'] = ftpd
-
- protocols = [srv for srv in SERVERS]
+ protocols = [srv for srv in SERVERS if SERVERS[srv] is not None]
parser = argparse.ArgumentParser(
description='Run basic application servers.')
parser.add_argument('proto', default='http', nargs='?',
help='protocol to serve (%s)' % protocols)
args = parser.parse_args()
- if args.proto not in SERVERS:
+ if args.proto not in protocols:
parser.print_help()
exit(1)