diff options
-rw-r--r-- | meta/classes/sanity.bbclass | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass index 720777a399..c9d37c9d88 100644 --- a/meta/classes/sanity.bbclass +++ b/meta/classes/sanity.bbclass | |||
@@ -35,6 +35,8 @@ def check_sanity_tmpdir_change(tmpdir, data): | |||
35 | 35 | ||
36 | # Check that TMPDIR isn't on a filesystem with limited filename length (eg. eCryptFS) | 36 | # Check that TMPDIR isn't on a filesystem with limited filename length (eg. eCryptFS) |
37 | testmsg = check_create_long_filename(tmpdir, "TMPDIR") | 37 | testmsg = check_create_long_filename(tmpdir, "TMPDIR") |
38 | # Check that we can fetch from various network transports | ||
39 | testmsg = testmsg + check_connectivity(data) | ||
38 | return testmsg | 40 | return testmsg |
39 | 41 | ||
40 | def check_sanity_version_change(data): | 42 | def check_sanity_version_change(data): |
@@ -79,6 +81,41 @@ def check_create_long_filename(filepath, pathname): | |||
79 | return "Failed to create a file in %s: %s" % (pathname, strerror) | 81 | return "Failed to create a file in %s: %s" % (pathname, strerror) |
80 | return "" | 82 | return "" |
81 | 83 | ||
84 | def check_connectivity(d): | ||
85 | # URI's to check can be set in the CONNECTIVITY_CHECK_URIS variable | ||
86 | # using the same syntax as for SRC_URI. If the variable is not set | ||
87 | # the check is skipped | ||
88 | test_uris = (bb.data.getVar('CONNECTIVITY_CHECK_URIS', d, True) or "").split() | ||
89 | retval = "" | ||
90 | |||
91 | # Only check connectivity if network enabled and the | ||
92 | # CONNECTIVITY_CHECK_URIS are set | ||
93 | network_enabled = not bb.data.getVar('BB_NO_NETWORK', d, True) | ||
94 | check_enabled = len(test_uris) | ||
95 | if check_enabled and network_enabled: | ||
96 | data = bb.data.createCopy(d) | ||
97 | bookmark = os.getcwd() | ||
98 | dldir = bb.data.expand('${TMPDIR}/sanity', data) | ||
99 | bb.data.setVar('DL_DIR', dldir, data) | ||
100 | |||
101 | try: | ||
102 | fetcher = bb.fetch2.Fetch(test_uris, data) | ||
103 | fetcher.download() | ||
104 | fetcher.clean(test_uris) | ||
105 | except Exception: | ||
106 | # Allow the message to be configured so that users can be | ||
107 | # pointed to a support mechanism. | ||
108 | msg = bb.data.getVar('CONNECTIVITY_CHECK_MSG', d, True) or "" | ||
109 | if len(msg) == 0: | ||
110 | msg = "Failed to fetch test data from the network. Please ensure your network is configured correctly.\n" | ||
111 | retval = msg | ||
112 | finally: | ||
113 | # Make sure we tidy up the cruft | ||
114 | oe.path.remove(dldir) | ||
115 | os.chdir(bookmark) | ||
116 | |||
117 | return retval | ||
118 | |||
82 | def check_sanity(e): | 119 | def check_sanity(e): |
83 | from bb import note, error, data, __version__ | 120 | from bb import note, error, data, __version__ |
84 | 121 | ||