mirror of
https://github.com/moparisthebest/spdylay
synced 2024-11-17 06:55:02 -05:00
Verify that the expected version of spdy is used.
This commit is contained in:
parent
3b1b4a6ca0
commit
4e085a21ea
@ -12,7 +12,6 @@ __author__ = 'Jim Morrison <jim@twist.com>'
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
|
||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
@ -24,10 +23,11 @@ def _run_server(port, args):
|
|||||||
srcdir = os.environ.get('srcdir', '.')
|
srcdir = os.environ.get('srcdir', '.')
|
||||||
testdata = '%s/testdata' % srcdir
|
testdata = '%s/testdata' % srcdir
|
||||||
top_builddir = os.environ.get('top_builddir', '..')
|
top_builddir = os.environ.get('top_builddir', '..')
|
||||||
base_args = ['%s/examples/spdyd' % top_builddir, str(port), '-d', testdata,
|
base_args = ['%s/examples/spdyd' % top_builddir, '-d', testdata]
|
||||||
'%s/privkey.pem' % testdata, '%s/cacert.pem' % testdata]
|
|
||||||
if args:
|
if args:
|
||||||
base_args.extend(args)
|
base_args.extend(args)
|
||||||
|
base_args.extend([str(port), '%s/privkey.pem' % testdata,
|
||||||
|
'%s/cacert.pem' % testdata])
|
||||||
return subprocess.Popen(base_args)
|
return subprocess.Popen(base_args)
|
||||||
|
|
||||||
def _check_server_up(port):
|
def _check_server_up(port):
|
||||||
@ -44,7 +44,11 @@ def _kill_server(server):
|
|||||||
class EndToEndSpdyTests(unittest.TestCase):
|
class EndToEndSpdyTests(unittest.TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
cls.server = _run_server(_PORT, None)
|
cls.setUpServer([])
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpServer(cls, args):
|
||||||
|
cls.server = _run_server(_PORT, args)
|
||||||
_check_server_up(_PORT)
|
_check_server_up(_PORT)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -54,29 +58,33 @@ class EndToEndSpdyTests(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
build_dir = os.environ.get('top_builddir', '..')
|
build_dir = os.environ.get('top_builddir', '..')
|
||||||
self.client = '%s/examples/spdycat' % build_dir
|
self.client = '%s/examples/spdycat' % build_dir
|
||||||
|
self.stdout = 'No output'
|
||||||
|
|
||||||
|
def call(self, path, args):
|
||||||
|
full_args = [self.client,'http://localhost:%d%s' % (_PORT, path)] + args
|
||||||
|
p = subprocess.Popen(full_args, stdout=subprocess.PIPE,
|
||||||
|
stdin=subprocess.PIPE)
|
||||||
|
self.stdout, self.stderr = p.communicate()
|
||||||
|
return p.returncode
|
||||||
|
|
||||||
|
|
||||||
|
class EndToEndSpdy2Tests(EndToEndSpdyTests):
|
||||||
def testSimpleRequest(self):
|
def testSimpleRequest(self):
|
||||||
self.assertEquals(
|
self.assertEquals(0, self.call('/', []))
|
||||||
0, subprocess.call([self.client, 'http://localhost:%d/' % _PORT]))
|
|
||||||
|
def testSimpleRequestSpdy3(self):
|
||||||
|
self.assertEquals(0, self.call('/', ['-v', '-3']))
|
||||||
|
self.assertIn('NPN selected the protocol: spdy/3', self.stdout)
|
||||||
|
|
||||||
|
|
||||||
class EndToEndSpdy3Tests(unittest.TestCase):
|
class EndToEndSpdy3Tests(EndToEndSpdyTests):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
cls.server = _run_server(_PORT, '-3')
|
cls.setUpServer(['-3'])
|
||||||
_check_server_up(_PORT)
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def tearDownClass(cls):
|
|
||||||
_kill_server(cls.server)
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
build_dir = os.environ.get('top_builddir', '..')
|
|
||||||
self.client = '%s/examples/spdycat' % build_dir
|
|
||||||
|
|
||||||
def testSimpleRequest(self):
|
def testSimpleRequest(self):
|
||||||
self.assertEquals(
|
self.assertEquals(0, self.call('/', ['-v']))
|
||||||
0, subprocess.call([self.client, 'http://localhost:%d/' % _PORT]))
|
self.assertIn('NPN selected the protocol: spdy/3', self.stdout)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user