summaryrefslogtreecommitdiffstats
path: root/meta/classes/sanity.bbclass
diff options
context:
space:
mode:
authorJoshua Lock <josh@linux.intel.com>2011-06-29 14:55:03 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-07-07 13:45:28 +0100
commit9569e2b3471e0c61f2f105f8d611a1ba71cd93d0 (patch)
treebcf2a1f9776faaa8e6ae090887253bb1ba696e1d /meta/classes/sanity.bbclass
parent8338c2dd19b2770cfc29ab87b2ce59d4c5034477 (diff)
downloadpoky-9569e2b3471e0c61f2f105f8d611a1ba71cd93d0.tar.gz
sanity: implement network connectivity test
Sanity test to verify files can be fetched from the network using git, http and https fetchers point users at a page to help get set up in the case of a failure. Requires a variable CONNECTIVITY_CHECK_URIS to be set, using the same pattern as SRC_URI, of URI's to test against. The variable CONNECTIVITY_CHECK_MSG can be set to provide a custom error message, such as a pointer to some help, when this check fails. Addresses [YOCTO #933] (From OE-Core rev: 8fdea2a1ac8875a42b3a57f0fd7b530f851c20e9) Signed-off-by: Joshua Lock <josh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/sanity.bbclass')
-rw-r--r--meta/classes/sanity.bbclass37
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
40def check_sanity_version_change(data): 42def 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
84def 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
82def check_sanity(e): 119def check_sanity(e):
83 from bb import note, error, data, __version__ 120 from bb import note, error, data, __version__
84 121