[asterisk-commits] wdoekes: testsuite/asterisk/trunk r3672 - /asterisk/trunk/lib/python/asterisk/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 20 15:10:13 CDT 2013


Author: wdoekes
Date: Wed Mar 20 15:10:09 2013
New Revision: 3672

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3672
Log:
Shorten the individual test paths in /tmp so AF_UNIX limits aren't reached.

Previously the test suite would create /tmp/asterisk-testsuite/full/test/name
paths in which /var/run/asterisk/asterisk.ctl would be created. When the test
name was a bit long, the full path name of the unix socket would become longer
than allowed: rasterisk couldn't communicate with the asterisken started for
the test.

This patch reduces the /full/test/name/ to a single md5 hash, consuming only
32 bytes. Symlinks are added to the md5-named paths for human consumption.

Review: https://reviewboard.asterisk.org/r/2399/

Modified:
    asterisk/trunk/lib/python/asterisk/TestCase.py

Modified: asterisk/trunk/lib/python/asterisk/TestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/TestCase.py?view=diff&rev=3672&r1=3671&r2=3672
==============================================================================
--- asterisk/trunk/lib/python/asterisk/TestCase.py (original)
+++ asterisk/trunk/lib/python/asterisk/TestCase.py Wed Mar 20 15:10:09 2013
@@ -15,6 +15,7 @@
 import time
 import traceback
 import uuid
+from hashlib import md5
 from twisted.internet import reactor, defer
 from twisted.python import failure
 from starpy import manager, fastagi
@@ -56,7 +57,24 @@
             self.test_name = os.path.dirname(sys.argv[0])
         else:
             self.test_name = test_path
-        self.base = self.test_name.replace("tests/", "", 1)
+
+        # We're not using /tmp//full//test//name because it gets so long that
+        # it doesn't fit in AF_UNIX paths (limited to around 108 chars) used
+        # for the rasterisk CLI connection. As a quick fix, we hash the path
+        # using md5, to make it unique enough.
+        self.realbase = self.test_name.replace("tests/", "", 1)
+        self.base = md5(self.realbase).hexdigest()
+        # We provide a symlink to it from a named path.
+        named_dir = os.path.join(Asterisk.test_suite_root, self.realbase)
+        try:
+            os.makedirs(os.path.dirname(named_dir))
+        except OSError:
+            pass
+        try:
+            os.symlink(os.path.join(Asterisk.test_suite_root, self.base), named_dir)
+        except OSError:
+            pass
+
         self.ast = []
         self.ami = []
         self.fastagi = []




More information about the asterisk-commits mailing list