diff options
| -rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 19 |
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 | |||
| 11 | import tempfile | 11 | import tempfile |
| 12 | import collections | 12 | import collections |
| 13 | import os | 13 | import os |
| 14 | import signal | ||
| 14 | import tarfile | 15 | import tarfile |
| 15 | from bb.fetch2 import URI | 16 | from bb.fetch2 import URI |
| 16 | from bb.fetch2 import FetchMethod | 17 | from 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 | ||
| 26 | class TestTimeout(Exception): | ||
| 27 | pass | ||
| 28 | |||
| 29 | class 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 | |||
| 25 | class URITest(unittest.TestCase): | 44 | class URITest(unittest.TestCase): |
| 26 | test_uris = { | 45 | test_uris = { |
| 27 | "http://www.google.com/index.html" : { | 46 | "http://www.google.com/index.html" : { |
