diff mbox

tests: honour HWSIM_TEST_LOG_DIR variable

Message ID 1448383198-4354-1-git-send-email-johannes@sipsolutions.net
State Accepted
Headers show

Commit Message

Johannes Berg Nov. 24, 2015, 4:39 p.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

If /tmp has a relatively small size limit, or multiple people run the
tests on the same machine, using the same output directory can easily
cause problems.

Make the test framework honour the new HWSIM_TEST_LOG_DIR environment
variable to make it easier to avoid those problems.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 tests/hwsim/vm/parallel-vm.py | 15 ++++++++-------
 tests/hwsim/vm/parallel-vm.sh |  6 +++++-
 tests/hwsim/vm/vm-run.sh      |  6 +++++-
 3 files changed, 18 insertions(+), 9 deletions(-)

Comments

Jouni Malinen Nov. 27, 2015, 9:25 p.m. UTC | #1
On Tue, Nov 24, 2015 at 05:39:58PM +0100, Johannes Berg wrote:
> If /tmp has a relatively small size limit, or multiple people run the
> tests on the same machine, using the same output directory can easily
> cause problems.
> 
> Make the test framework honour the new HWSIM_TEST_LOG_DIR environment
> variable to make it easier to avoid those problems.

Thanks, applied.
diff mbox

Patch

diff --git a/tests/hwsim/vm/parallel-vm.py b/tests/hwsim/vm/parallel-vm.py
index 40ab5e397714..e40d44fbad86 100755
--- a/tests/hwsim/vm/parallel-vm.py
+++ b/tests/hwsim/vm/parallel-vm.py
@@ -352,6 +352,13 @@  def main():
                    help="run tests under valgrind")
     p.add_argument('params', nargs='*')
     args = p.parse_args()
+
+    dir = os.environ.get('HWSIM_TEST_LOG_DIR', '/tmp/hwsim-test-logs')
+    try:
+        os.makedirs(dir)
+    except:
+        pass
+
     num_servers = args.num_servers
     rerun_failures = not args.no_retry
     if args.debug:
@@ -363,7 +370,7 @@  def main():
         extra_args += [ '--long' ]
     if args.codecov:
         print "Code coverage - build separate binaries"
-        logdir = "/tmp/hwsim-test-logs/" + str(timestamp)
+        logdir = os.path.join(dir, str(timestamp))
         os.makedirs(logdir)
         subprocess.check_call([os.path.join(scriptsdir, 'build-codecov.sh'),
                                logdir])
@@ -390,12 +397,6 @@  def main():
     if len(tests) == 0:
         sys.exit("No test cases selected")
 
-    dir = '/tmp/hwsim-test-logs'
-    try:
-        os.mkdir(dir)
-    except:
-        pass
-
     if args.shuffle:
         from random import shuffle
         shuffle(tests)
diff --git a/tests/hwsim/vm/parallel-vm.sh b/tests/hwsim/vm/parallel-vm.sh
index b2fd0786fd7b..f9e22d95b6af 100755
--- a/tests/hwsim/vm/parallel-vm.sh
+++ b/tests/hwsim/vm/parallel-vm.sh
@@ -9,7 +9,11 @@  if [ -z "$NUM" ]; then
 fi
 shift
 
-LOGS=/tmp/hwsim-test-logs
+if [ -n "$HWSIM_TEST_LOG_DIR" ] ; then
+	LOGS="$HWSIM_TEST_LOG_DIR"
+else
+	LOGS=/tmp/hwsim-test-logs
+fi
 mkdir -p $LOGS
 DATE=$(date +%s)
 
diff --git a/tests/hwsim/vm/vm-run.sh b/tests/hwsim/vm/vm-run.sh
index 98af2a4156c2..ab4df4c100be 100755
--- a/tests/hwsim/vm/vm-run.sh
+++ b/tests/hwsim/vm/vm-run.sh
@@ -6,7 +6,11 @@  if [ -z "$TESTDIR" ] ; then
 	TESTDIR=$(pwd)/../
 fi
 
-LOGS=/tmp/hwsim-test-logs
+if [ -n "$HWSIM_TEST_LOG_DIR" ] ; then
+	LOGS="$HWSIM_TEST_LOG_DIR"
+else
+	LOGS=/tmp/hwsim-test-logs
+fi
 
 # increase the memory size if you want to run with valgrind, 512 MB works
 MEMORY=192