diff options
author | Holger Freyther <zecke@selfish.org> | 2007-04-14 22:54:34 +0000 |
---|---|---|
committer | Holger Freyther <zecke@selfish.org> | 2007-04-14 22:54:34 +0000 |
commit | a6e79a93f66296c231d339b160704b0165a3c2e3 (patch) | |
tree | 10352f38c877f954eaa2f9c47fc01b942948ae01 | |
parent | 17a4b29ac8bc47ae75bafa0889709a15f1a05393 (diff) | |
download | openembedded-org.openembedded.oetest.tar.gz |
modules/chksum_checker/chksum.py: Generate a checksum.ini from already downloaded filesorg.openembedded.oetest
This code generates a sorted checksums.ini file from the files
already downloaded and stored in the DL_DIR of the test. Only
http, https and ftp protocols will be used as protocols and the
checksums.ini will be saved in the current working dir
-rw-r--r-- | modules/chksum_checker/chksum.py | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/modules/chksum_checker/chksum.py b/modules/chksum_checker/chksum.py index 236a14a67d..7080c8922c 100644 --- a/modules/chksum_checker/chksum.py +++ b/modules/chksum_checker/chksum.py @@ -34,6 +34,8 @@ from bittest import TestItem +import bb, os + class TestCase: """ A simple test case @@ -45,12 +47,18 @@ class TestCase: """ def setup(self, config): - print "Create" - pass + self.checksum_tuple_dict = {} def finish(self, config): - print "Finish" - pass + f = file("checksums.ini", "w+") + keys = self.checksum_tuple_dict.keys() + keys.sort() + for fi in keys: + (md5,sha) = self.checksum_tuple_dict[fi] + print >> f, "[%s]" % fi + print >> f, "md5=%s" % md5 + print >> f, "sha256=%s" % sha + print >> f, "" def test(self,file_name, file_data): """ @@ -58,7 +66,21 @@ class TestCase: You can use whatever you want """ - return TestItem(file_name,False,"The Test Failed") + uris = (bb.data.getVar("SRC_URI", file_data, True) or "").split() + bb.fetch.init(uris, file_data) + for uri in uris: + localpath = bb.fetch.localpath(uri, file_data) + (type,host,path,_,_,_) = bb.decodeurl(uri) + uri = "%s://%s%s" % (type,host,path) + + if not type in ["http", "ftp", "https"]: + continue + if not uri in self.checksum_tuple_dict and os.path.exists(localpath): + md5sum = os.popen("md5sum %s" % localpath).read().split()[0] + shasum = os.popen("sha256sum %s" % localpath).read().split()[0] + self.checksum_tuple_dict[uri] = (md5sum,shasum) + + return TestItem(file_name,True, "Psst, we did not test at all") def test_name(self): """ |