summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/tests/fetch.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 7fcf57e7ea..e69b4b05f3 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -11,6 +11,7 @@ import hashlib
11import tempfile 11import tempfile
12import collections 12import collections
13import os 13import os
14import signal
14import tarfile 15import tarfile
15from bb.fetch2 import URI 16from bb.fetch2 import URI
16from bb.fetch2 import FetchMethod 17from bb.fetch2 import FetchMethod
@@ -22,6 +23,24 @@ def skipIfNoNetwork():
22 return unittest.skip("network test") 23 return unittest.skip("network test")
23 return lambda f: f 24 return lambda f: f
24 25
26class TestTimeout(Exception):
27 pass
28
29class Timeout():
30
31 def __init__(self, seconds):
32 self.seconds = seconds
33
34 def handle_timeout(self, signum, frame):
35 raise TestTimeout("Test failed: timeout reached")
36
37 def __enter__(self):
38 signal.signal(signal.SIGALRM, self.handle_timeout)
39 signal.alarm(self.seconds)
40
41 def __exit__(self, exc_type, exc_val, exc_tb):
42 signal.alarm(0)
43
25class URITest(unittest.TestCase): 44class URITest(unittest.TestCase):
26 test_uris = { 45 test_uris = {
27 "http://www.google.com/index.html" : { 46 "http://www.google.com/index.html" : {