diff mbox

[test_fetch_md5sums_fix] testsuite/test.sh: Always override ${local_snapshots} for tests.

Message ID 1381788893-22979-1-git-send-email-ryan.arnold@linaro.org
State New
Headers show

Commit Message

Ryan S. Arnold Oct. 14, 2013, 10:14 p.m. UTC
From: "Ryan S. Arnold" <ryan.arnold@linaro.org>

Use a temporary directory /tmp/cbuild.XXX/snapshots for the snapshots
directory used in tests.  Otherwise it might mangle the local_snapshots
directory of an active build.  This patch fixes a case where running the
testsuite from within an active build directory will move the snapshots
directory to snapshots.bak.  The fix now uses a new temp directory for
every test run.
---
 testsuite/test.sh | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

Comments

Ryan S. Arnold Oct. 15, 2013, 3:02 a.m. UTC | #1
On Mon, Oct 14, 2013 at 5:14 PM, Ryan S. Arnold <ryan.arnold@linaro.org> wrote:
> From: "Ryan S. Arnold" <ryan.arnold@linaro.org>
>
> Use a temporary directory /tmp/cbuild.XXX/snapshots for the snapshots
> directory used in tests.  Otherwise it might mangle the local_snapshots
> directory of an active build.  This patch fixes a case where running the
> testsuite from within an active build directory will move the snapshots
> directory to snapshots.bak.  The fix now uses a new temp directory for
> every test run.
> ---
>  testsuite/test.sh | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/testsuite/test.sh b/testsuite/test.sh
> index b3d3778..3cb2356 100755
> --- a/testsuite/test.sh
> +++ b/testsuite/test.sh
> @@ -16,20 +16,26 @@ if test -e "${PWD}/host.conf"; then
>  else
>      warning "no host.conf file!"
>      remote_snapshots=http://cbuild.validation.linaro.org/snapshots
> -    local_snapshots=test_snapshots
>      wget_bin=/usr/bin/wget
>      wget_quiet=yes
>  fi
>
> +# We always override $local_snapshots so that we don't damage or move the
> +# local_snapshots directory of an existing build.
> +local_snapshots="`mktemp -d /tmp/cbuild2.XXX`/snapshots"
> +
> +# Let's make sure that the snapshots portion of the directory is created before
> +# we use it just to be safe.
> +out="`mkdir -p ${local_snapshots}`"
> +if test "$?" -gt 1; then
> +    exit 1
> +fi
> +
>  # Since we're testing, we don't load the host.conf file, instead
>  # we create false values that stay consistent.
>  cbuild_top=/build/cbuild2/test
>  hostname=test.foobar.org
>  target=x86_64-linux-gnu
> -#remote_snapshots=http://cbuild.validation.linaro.org/snapshots
> -#local_snapshots=test_snapshots
> -#wget_bin=/usr/bin/wget
> -#wget_quiet=yes
>
>  if test x"$1" = x"-v"; then
>      debug=yes
> @@ -151,11 +157,6 @@ fi
>
>  # ----------------------------------------------------------------------------------
>  echo "============= fetch() tests ================"
> -if test -d "${local_snapshots}"; then
> -    notice "${local_snapshots} directory exists.  Moving it to ${local_snapshots}.bak."
> -    mv ${local_snapshots} ${local_snapshots}.bak
> -fi
> -
>  out="`fetch md5sums`"
>  if test $? -eq 0; then
>      pass "fetch md5sums"
> --
> 1.8.3.1
>

Committed

commit 019ec88cda60b1c3e32d6ac23f5c65ea76085f7b
Author: Ryan S. Arnold <ryan.arnold@linaro.org>
Date:   Mon Oct 14 21:57:59 2013 -0500

    testsuite/test.sh: Always override ${local_snapshots} for tests.

    Use a temporary directory /tmp/cbuild.XXX/snapshots for the snapshots
    directory used in tests.  Otherwise it might mangle the local_snapshots
    directory of an active build.  This patch fixes a case where running the
    testsuite from within an active build directory will move the snapshots
    directory to snapshots.bak.  The fix now uses a new temp directory for
    every test run.
diff mbox

Patch

diff --git a/testsuite/test.sh b/testsuite/test.sh
index b3d3778..3cb2356 100755
--- a/testsuite/test.sh
+++ b/testsuite/test.sh
@@ -16,20 +16,26 @@  if test -e "${PWD}/host.conf"; then
 else
     warning "no host.conf file!"
     remote_snapshots=http://cbuild.validation.linaro.org/snapshots
-    local_snapshots=test_snapshots
     wget_bin=/usr/bin/wget
     wget_quiet=yes
 fi
 
+# We always override $local_snapshots so that we don't damage or move the
+# local_snapshots directory of an existing build.
+local_snapshots="`mktemp -d /tmp/cbuild2.XXX`/snapshots"
+
+# Let's make sure that the snapshots portion of the directory is created before
+# we use it just to be safe.
+out="`mkdir -p ${local_snapshots}`"
+if test "$?" -gt 1; then
+    exit 1
+fi
+
 # Since we're testing, we don't load the host.conf file, instead
 # we create false values that stay consistent.
 cbuild_top=/build/cbuild2/test
 hostname=test.foobar.org
 target=x86_64-linux-gnu
-#remote_snapshots=http://cbuild.validation.linaro.org/snapshots
-#local_snapshots=test_snapshots
-#wget_bin=/usr/bin/wget
-#wget_quiet=yes
 
 if test x"$1" = x"-v"; then
     debug=yes
@@ -151,11 +157,6 @@  fi
 
 # ----------------------------------------------------------------------------------
 echo "============= fetch() tests ================"
-if test -d "${local_snapshots}"; then
-    notice "${local_snapshots} directory exists.  Moving it to ${local_snapshots}.bak."
-    mv ${local_snapshots} ${local_snapshots}.bak
-fi
-
 out="`fetch md5sums`"
 if test $? -eq 0; then
     pass "fetch md5sums"