[asterisk-commits] Testsuite: avoid accidental use of alternate tmp (testsuite[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 9 08:23:22 CST 2016


Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/4452 )

Change subject: Testsuite: avoid accidental use of alternate tmp
......................................................................


Testsuite: avoid accidental use of alternate tmp

The alternate /var/tmp directory for asterisk-testsuite
temporary files will be automatically selected- when it
has more blocks available then /tmp. This can happen in
CentOS 7 where /tmp is mounted on a smaller tmpfs.

However if /tmp and /var/tmp are on the same filesystem
and the available space changes slightly between calls,
the testsuite could mistakenly select /var/tmp where it
was not necessary.  By changing the comparison function
to treat small differences in available space the same,
this problem is avoided.

ASTERISK-26602 #close

Change-Id: Ia1bc3ded873e917960478f31c257c93cd28fb4aa
---
M lib/python/asterisk/asterisk.py
1 file changed, 7 insertions(+), 4 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/lib/python/asterisk/asterisk.py b/lib/python/asterisk/asterisk.py
index bfde74f..1ec1ebc 100755
--- a/lib/python/asterisk/asterisk.py
+++ b/lib/python/asterisk/asterisk.py
@@ -313,12 +313,15 @@
     """
 
     def compare_free_space(x, y):
+        if os.stat(y).st_dev == os.stat(x).st_dev:
+            return 0
         # statvfs can return a long; comparison functions must return an
-        # int. Hence the checks that occur here.
-        blocks_avail = os.statvfs(y).f_bavail - os.statvfs(x).f_bavail
-        if (blocks_avail > 0):
+        # int.  Where both are same filesystem, bavail might change from
+        # one call to the next, but hopefully it is not more than 1000.
+        difference = os.statvfs(y).f_bavail - os.statvfs(x).f_bavail
+        if (difference > 1000):
             return 1
-        elif (blocks_avail < 0):
+        elif (difference < 1000):
             return -1
         else:
             return 0

-- 
To view, visit https://gerrit.asterisk.org/4452
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia1bc3ded873e917960478f31c257c93cd28fb4aa
Gerrit-PatchSet: 3
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Scott Griepentrog <sgriepentrog at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-commits mailing list