test/sources: skip if net namespace setup fails
Try to check if we can setup the net namespace and if that fails skip the test.
This commit is contained in:
parent
83aa4a29df
commit
ea3dad17fc
1 changed files with 9 additions and 0 deletions
|
|
@ -57,6 +57,14 @@ def fileServer(directory):
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
def can_setup_netns() -> bool:
|
||||||
|
try:
|
||||||
|
with netns():
|
||||||
|
return True
|
||||||
|
except: # pylint: disable=bare-except
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def runFileServer(barrier, directory):
|
def runFileServer(barrier, directory):
|
||||||
class Handler(http.server.SimpleHTTPRequestHandler):
|
class Handler(http.server.SimpleHTTPRequestHandler):
|
||||||
def __init__(self, request, client_address, server):
|
def __init__(self, request, client_address, server):
|
||||||
|
|
@ -68,6 +76,7 @@ def runFileServer(barrier, directory):
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(test.TestBase.have_test_data(), "no test-data access")
|
@unittest.skipUnless(test.TestBase.have_test_data(), "no test-data access")
|
||||||
|
@unittest.skipUnless(can_setup_netns(), "network namespace setup failed")
|
||||||
class TestSources(test.TestBase):
|
class TestSources(test.TestBase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.sources = os.path.join(self.locate_test_data(), "sources")
|
self.sources = os.path.join(self.locate_test_data(), "sources")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue