[asterisk-commits] russell: testsuite/asterisk/trunk r120 - in /asterisk/trunk: ./ asterisktests...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 24 06:57:56 CDT 2010
Author: russell
Date: Wed Mar 24 06:50:41 2010
New Revision: 120
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=120
Log:
update docs a bit, make output less verbose, force always running from within asterisk source tree
Added:
asterisk/trunk/lib/
asterisk/trunk/lib/python/
asterisk/trunk/lib/python/asterisk/
- copied from r115, asterisk/trunk/asterisktestsuite/
asterisk/trunk/lib/python/asterisk/version.py
- copied, changed from r115, asterisk/trunk/asterisktestsuite/asteriskversion.py
Removed:
asterisk/trunk/asterisktestsuite/
asterisk/trunk/lib/python/asterisk/asteriskversion.py
Modified:
asterisk/trunk/README.txt
asterisk/trunk/runtests.py
Modified: asterisk/trunk/README.txt
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/README.txt?view=diff&rev=120&r1=119&r2=120
==============================================================================
--- asterisk/trunk/README.txt (original)
+++ asterisk/trunk/README.txt Wed Mar 24 06:50:41 2010
@@ -11,10 +11,14 @@
--- 0) Table of Contents
--------------------------------------------------------------------------------
+ Using the Test Suite:
1) Introduction
- 2) Test Anatomy
- 3) Test Configuration
- 4) Test Suite System Requirements
+ 2) Test Suite System Requirements
+ 3) Running the Test Suite
+
+ Writing Tests:
+ 4) Test Anatomy
+ 5) Test Configuration
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
@@ -38,8 +42,52 @@
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
+---------------------------------------------------------------------------------
+--- 2) Test Suite System Requirements
--------------------------------------------------------------------------------
---- 2) Test Anatomy
+
+Required:
+ - python >= 2.4
+ - python-yaml
+
+Optional (needed by specific tests):
+ - bash
+ - SIPp
+ - asttest
+
+--------------------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+---------------------------------------------------------------------------------
+--- 3) Running the Test Suite
+--------------------------------------------------------------------------------
+
+Get the Asterisk source tree you want to test:
+ $ svn co http://svn.digium.com/svn/asterisk/trunk asterisk-trunk
+ $ cd asterisk-trunk
+
+Build it.
+ $ ./configure && make
+
+Check out the test suite inside of the Asterisk source tree. In this case, we
+will have the testsuite directory inside of the asterisk-trunk directory.
+ $ svn co http://svn.digium.com/svn/testsuite/asterisk/trunk testsuite
+ $ cd testsuite
+
+List the tests:
+ $ ./runtests.py -l
+
+Run the tests:
+ # ./runtests.py
+
+For more syntax informatino:
+ $ ./runtests.py --hep
+
+--------------------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+-------------------------------------------------------------------------------
+--- 4) Test Anatomy
--------------------------------------------------------------------------------
a) File layout
@@ -91,7 +139,7 @@
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
---- 3) Test Configuration
+--- 5) Test Configuration
--------------------------------------------------------------------------------
Test configuration lives in a file called "test-config.yaml". The
@@ -134,21 +182,5 @@
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
---------------------------------------------------------------------------------
---- 4) Test Suite System Requirements
---------------------------------------------------------------------------------
-
-Required:
- - python >= 2.4
- - python-yaml
-
-Optional (needed by specific tests):
- - bash
- - SIPp
- - asttest
-
---------------------------------------------------------------------------------
---------------------------------------------------------------------------------
-
================================================================================
================================================================================
Copied: asterisk/trunk/lib/python/asterisk/version.py (from r115, asterisk/trunk/asterisktestsuite/asteriskversion.py)
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/version.py?view=diff&rev=120&p1=asterisk/trunk/asterisktestsuite/asteriskversion.py&r1=115&p2=asterisk/trunk/lib/python/asterisk/version.py&r2=120
==============================================================================
--- asterisk/trunk/asterisktestsuite/asteriskversion.py (original)
+++ asterisk/trunk/lib/python/asterisk/version.py Wed Mar 24 06:50:41 2010
@@ -12,15 +12,15 @@
import unittest
-VERSION_HDR = "/usr/include/asterisk/version.h"
+VERSION_HDR = "../include/asterisk/version.h"
class AsteriskVersion:
- def __init__(self, version=None):
+ def __init__(self, version=None, path=VERSION_HDR):
if version is not None:
self.version_str = version
else:
- self.version_str = self.__get_ast_version()
+ self.version_str = self.__get_ast_version(path)
if self.version_str[:3] == "SVN":
self.__parse_svn_version()
@@ -77,19 +77,22 @@
self.revision = match.group("revision")
self.parent = match.group("parent")
- def __get_ast_version(self):
+ def __get_ast_version(self, path):
'''
Determine the version of Asterisk installed from the installed version.h.
'''
v = ""
try:
- f = open(VERSION_HDR, "r")
+ f = open(path, "r")
match = re.search("ASTERISK_VERSION\s+\"(.*)\"", f.read())
if match is not None:
v = match.group(1)
f.close()
+ except IOError:
+ print "I/O Error getting Asterisk version from %s" % path
except:
- print "Failed to open %s to get Asterisk version." % VERSION_HDR
+ print "Unexpected error getting version from %s: %s" % (path,
+ sys.exc_info()[0])
return v
Modified: asterisk/trunk/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/runtests.py?view=diff&rev=120&r1=119&r2=120
==============================================================================
--- asterisk/trunk/runtests.py (original)
+++ asterisk/trunk/runtests.py Wed Mar 24 06:50:41 2010
@@ -14,7 +14,9 @@
import time
import yaml
-from asterisktestsuite.asteriskversion import AsteriskVersion
+sys.path.append("lib/python")
+
+from asterisk.version import AsteriskVersion
TESTS_CONFIG = "tests/tests.yaml"
@@ -142,19 +144,6 @@
f.close()
self.total_time = 0.0
-
- # Check to see if this has been executed within a sub directory of an
- # Asterisk source tree. This is required so that we can execute
- # install and uninstall targets of the Asterisk Makefile in between
- # tests.
- self.within_ast_tree = os.path.exists("../main/asterisk.c")
- if self.within_ast_tree is False:
- print "*** WARNING ***\n" \
- "runtests has not been executed from within a\n" \
- "subdirectory of an Asterisk source tree. This\n" \
- "is required for being able to uninstall and install\n" \
- "Asterisk in between tests.\n" \
- "***************\n"
self.tests = [
TestConfig(t["test"], ast_version) for t in self.config["tests"]
@@ -188,13 +177,14 @@
print "--> Running test '%s' ...\n" % t.test_name
# Establish Preconditions
-
- if self.within_ast_tree is True:
- os.chdir("..")
- os.system("make uninstall-all")
- os.system("make install")
- os.system("make samples")
- os.chdir(test_suite_dir)
+ os.chdir("..")
+ print "Uninstalling Asterisk ... "
+ os.system("make uninstall-all > /dev/null 2>&1")
+ print "Installing Asterisk ... "
+ os.system("make install > /dev/null 2>&1")
+ print "Installing sample configuration ... "
+ os.system("make samples > /dev/null 2>&1")
+ os.chdir(test_suite_dir)
# Run Test
@@ -266,11 +256,20 @@
help="List tests instead of running them.")
(options, args) = parser.parse_args(argv)
- try:
- ast_version = AsteriskVersion()
- except:
- print "Failed to get Asterisk version. Is Asterisk installed?"
+ # Check to see if this has been executed within a sub directory of an
+ # Asterisk source tree. This is required so that we can execute
+ # install and uninstall targets of the Asterisk Makefile in between
+ # tests.
+ if os.path.exists("../main/asterisk.c") is False:
+ print "*** ERROR ***\n" \
+ "runtests has not been executed from within a\n" \
+ "subdirectory of an Asterisk source tree. This\n" \
+ "is required for being able to uninstall and install\n" \
+ "Asterisk in between tests.\n" \
+ "***************\n"
return 1
+
+ ast_version = AsteriskVersion()
test_suite = TestSuite(ast_version)
More information about the asterisk-commits
mailing list