diff options
author | Ryan S. Arnold <ryan.arnold@linaro.org> | 2015-05-19 14:25:56 -0500 |
---|---|---|
committer | Ryan S. Arnold <ryan.arnold@linaro.org> | 2015-05-19 14:25:56 -0500 |
commit | 0c34d72b5e31b1b49b6605f8d7a50307d3ebb87d (patch) | |
tree | b5701eee8e87bfa8d07b5c478db26e7daa635ec5 /testsuite | |
parent | 2bf43860829ce185b4780fa33797150e34138942 (diff) |
Improve handling of supdate option as it relates to the md5sums file.
[Linaro Bugzilla 1536] - https://bugs.linaro.org/show_bug.cgi?id=1536
Only move md5sums to md5sums.bak if it actually exists.
Don't exit early (with success) from fetch_http() if ${supdate} = no
because if fetch_http() is called the first time with supdate=no (user
error) the source won't actually exist.
Improve upon patch by Rob Savoye by making sure that ${getfile} file exists
if ${supdate} = no, otherwise return an error.
Add fetch_http() tests to testsuite/test.sh.
Change-Id: I9a7989ea42f96662bf2e88d0ae4f7534439030f2
Diffstat (limited to 'testsuite')
-rwxr-xr-x | testsuite/test.sh | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/testsuite/test.sh b/testsuite/test.sh index 5e080c18..f007f5eb 100755 --- a/testsuite/test.sh +++ b/testsuite/test.sh @@ -525,6 +525,57 @@ else fi # ---------------------------------------------------------------------------------- +echo "============= fetch_http() tests ================" + +# It doesn't exist yet, so it should error out if we try to fetch with supdate=no. +out="`supdate=no fetch_http infrastructure/gmp-5.1.3.tar.xz 2>/dev/null`" +if test $? -gt 0 -a ! -e ${local_snapshots}/infrastructure/gmp-5.1.3.tar.xz; then + pass "fetch_http infrastructure/gmp-5.1.3.tar.xz with \${supdate}=no" +else + fail "fetch_http infrastructure/gmp-5.1.3.tar.xz with \${supdate}=no" +fi + +# Now try to download it with supdate=yes (default) unspecified and it should +# work and return 0 and show the file has been downloaded. +out="`fetch_http infrastructure/gmp-5.1.3.tar.xz 2>/dev/null`" +if test $? -eq 0 -a -e ${local_snapshots}/infrastructure/gmp-5.1.3.tar.xz; then + pass "fetch_http infrastructure/gmp-5.1.3.tar.xz (implicit \${supdate}=yes)" +else + fail "fetch_http infrastructure/gmp-5.1.3.tar.xz (implicit \${supdate}=yes)" +fi + +# Get a timestamp of the first downloaded version. +gmp_stamp1=`stat -c %X ${local_snapshots}/infrastructure/gmp-5.1.3.tar.xz` + +# Sleep so that the timestamps differ (if they will) +sleep 1s + +# Try to download it again with supdate=yes explicit and it +# should return 0 (that we've already downloaded it) but not download again. +out="`supdate=yes fetch_http infrastructure/gmp-5.1.3.tar.xz 2>/dev/null`" +ret=$? + +# Compare the second timestamp to make sure they're equal. +gmp_stamp2=`stat -c %X ${local_snapshots}/infrastructure/gmp-5.1.3.tar.xz` + +if test $ret -eq 0 -a ${gmp_stamp1} -eq ${gmp_stamp2}; then + pass "fetch_http infrastructure/gmp-5.1.3.tar.xz with \${supdate}=yes" +else + fail "fetch_http infrastructure/gmp-5.1.3.tar.xz with \${supdate}=yes" +fi + +out="`fetch_http md5sums 2>/dev/null`" +if test $? -eq 0; then + pass "fetch_http md5sums" +else + fail "fetch_http md5sums" +fi + +# remove md5sums so we can test fetch(). +if test ! -e "${local_snapshots}/md5sums"; then + rm ${local_snapshots}/md5sums +fi + echo "============= fetch() tests ================" out="`fetch md5sums 2>/dev/null`" if test $? -eq 0; then |