[asterisk-commits] pabelanger: branch pabelanger/SWP-2533 r1333 - in /asterisk/team/pabelanger/S...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 5 02:57:15 UTC 2011


Author: pabelanger
Date: Tue Jan  4 20:57:11 2011
New Revision: 1333

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1333
Log:
Add dynamic modules test

Added:
    asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/
    asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/configs/
    asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/configs/ast1/
    asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/configs/ast1/modules.conf   (with props)
    asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/run-test   (with props)
    asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/test-config.yaml   (with props)
Modified:
    asterisk/team/pabelanger/SWP-2533/tests/tests.yaml

Added: asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/configs/ast1/modules.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/configs/ast1/modules.conf?view=auto&rev=1333
==============================================================================
--- asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/configs/ast1/modules.conf (added)
+++ asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/configs/ast1/modules.conf Tue Jan  4 20:57:11 2011
@@ -1,0 +1,2 @@
+[modules]
+autoload=no

Propchange: asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/configs/ast1/modules.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/configs/ast1/modules.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/configs/ast1/modules.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/run-test?view=auto&rev=1333
==============================================================================
--- asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/run-test (added)
+++ asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/run-test Tue Jan  4 20:57:11 2011
@@ -1,0 +1,187 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2010, Digium, Inc.
+Paul Belanger <pabelanger at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+import os
+import shutil
+import time
+from twisted.application import service, internet
+from twisted.internet import reactor, defer
+from starpy import manager
+
+sys.path.append("lib/python")
+from asterisk.asterisk import Asterisk
+
+workingdir = "/tmp/asterisk-testsuite/dynamic-modules"
+testdir = "tests/dynamic-modules"
+
+class moduleLoadUnloadTest:
+    def __init__(self):
+        self.passed = False
+        self.last_step = ""
+
+        reactor.callWhenRunning(self.run)
+
+        print "Creating Asterisk instance ..."
+        self.asterisk = Asterisk(base=workingdir)
+        self.asterisk.install_configs("%s/configs/ast1" % (testdir))
+
+    def stop_reactor(self):
+        print "Stopping Reactor ..."
+        if reactor.running:
+            reactor.stop()
+
+    def start_asterisk(self):
+        print "Starting Asterisk ..."
+        self.asterisk.start()
+
+    def stop_asterisk(self):
+        self.asterisk.stop()
+
+    def load_module(self, module):
+        if not self.check_file(module):
+            print module[0] + " does not exist! Skipping test."
+            return False
+
+        text = "Loaded " + module[0]
+        res = self.asterisk.cli_exec("module load " + module[0])
+        if res.count(text) > 0:
+            module[2] = True
+        return module[2]
+
+    def unload_module(self, module):
+        text = "Unloaded " + module[0]
+        res = self.asterisk.cli_exec("module unload " + module[0])
+        if res.count(text) > 0:
+            module[3] = True
+
+    def check_file(self, module):
+        module[1] = os.path.isfile(self.asterisk.base + "/usr/lib/asterisk/modules/" + module[0])
+        return module[1]
+
+    def check_failures(self, module):
+        if not module[2]:
+            print "ERROR: Loading " + module[0]
+            self.passed = False
+
+        if not module[3]:
+            print "ERROR: Unloading " + module[0]
+            self.passed = False
+
+    def run(self):
+        self.passed = True
+        preload_res = []
+        res = []
+
+        # A timeout in case things hang and fail
+        reactor.callLater(20, self.stop_reactor)
+
+        # TODO: Do not hardcode, read from source code. 
+        preload_resources = ["res_calendar", "res_curl", "res_fax", "res_odbc"]
+
+        for module in preload_resources:
+            preload_res.append([module + ".so", False, False, False])
+
+        # TODO: Do not hardcode, read from source code. 
+        # TODO: Fixed res_http_post crash
+        resources = ["res_adsi", "res_ael_share", "res_agi", "res_ais", "res_calendar_caldav", "res_calendar_exchange", "res_calendar_icalendar", "res_clialiases", "res_clioriginate", "res_config_curl", "res_config_ldap", "res_config_odbc", "res_config_pgsql", "res_config_sqlite", "res_convert", "res_crypto", "res_fax_spandsp", "res_jabber", "res_limit", "res_monitor", "res_musiconhold", "res_mutestream", "res_phoneprov", "res_pktccops", "res_realtime", "res_rtp_asterisk", "res_rtp_multicast", "res_security_log", "res_smdi", "res_snmp", "res_speech", "res_timing_dahdi", "res_timing_kqueue", "res_timing_pthread", "res_timing_timerfd"]
+
+        for module in resources:
+            res.append([module + ".so", False, False, False])
+
+        for module in preload_res:
+            self.load_module(module)
+
+        for module in res:
+            result = self.load_module(module)
+            time.sleep(1)
+
+            if not result:
+                continue
+
+            self.unload_module(module)
+            time.sleep(1)
+
+        for module in preload_res:
+            self.unload_module(module)
+
+        for module in preload_res:
+            # modules does not exist
+            if not module[1]:
+                print "WARNING: " + module[0] + " does not exist!"
+                continue
+
+            # TODO: Fix unloading of res_calendar.so
+            if module[0] == "res_calendar.so":
+                if not module[3]:
+                    continue
+
+            # TODO: Fix unloading of res_curl.so
+            if module[0] == "res_curl.so":
+                if not module[3]:
+                    continue
+
+            # TODO: Fix unloading of res_odbc.so
+            if module[0] == "res_odbc.so":
+                if not module[3]:
+                    continue
+
+            self.check_failures(module);
+
+        for module in res:
+            # modules does not exist
+            if not module[1]:
+                print "WARNING: " + module[0] + " does not exist!"
+                continue
+
+            # TODO: Fix unloading of res_adsi.so
+            if module[0] == "res_adsi.so":
+                if not module[3]:
+                    continue
+
+            # TODO: Fix loading / unloading of res_ais.so
+            if module[0] == "res_ais.so":
+                if not module[2] and not module[3]:
+                    continue
+
+            # TODO: Fix loading / unloading of res_config_sqlite.so
+            if module[0] == "res_config_sqlite.so":
+                if not module[2] and not module[3]:
+                    continue
+
+            # TODO: Fix unloading of res_crypto.so
+            if module[0] == "res_crypto.so":
+                if not module[3]:
+                    continue
+
+            # TODO: Fix loading / unloading of res_smdi.so
+            if module[0] == "res_smdi.so":
+                if not module[2] and not module[3]:
+                    continue
+
+            # TODO: Fix unloading of res_speech.so
+            if module[0] == "res_speech.so":
+                if not module[3]:
+                    continue
+
+            self.check_failures(module);
+
+def main():
+    test = moduleLoadUnloadTest()
+    test.start_asterisk()
+    reactor.run()
+    test.stop_asterisk()
+    if test.passed:
+        return 0
+    return 1
+
+if __name__ == "__main__":
+    sys.exit(main() or 0)
+
+# vim:sw=4:ts=4:expandtab:textwidth=79

Propchange: asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/run-test
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/run-test
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/run-test
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/test-config.yaml?view=auto&rev=1333
==============================================================================
--- asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/test-config.yaml (added)
+++ asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/test-config.yaml Tue Jan  4 20:57:11 2011
@@ -1,0 +1,11 @@
+testinfo:
+    summary:     'Test dynamicly loading and unloading modules'
+    description: |
+        'This test provides a basic sanity check on Asterisk
+        modules.'
+
+properties:
+    minversion: '1.8'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'

Propchange: asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/pabelanger/SWP-2533/tests/dynamic-modules/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/team/pabelanger/SWP-2533/tests/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/SWP-2533/tests/tests.yaml?view=diff&rev=1333&r1=1332&r2=1333
==============================================================================
--- asterisk/team/pabelanger/SWP-2533/tests/tests.yaml (original)
+++ asterisk/team/pabelanger/SWP-2533/tests/tests.yaml Tue Jan  4 20:57:11 2011
@@ -1,6 +1,7 @@
 # Enter tests here in the order they should be considered for execution:
 tests:
     - test: 'example'
+    - test: 'dynamic-modules'
     - dir: 'manager'
     - test: 'rfc2833_dtmf_detect'
     - test: 'sip_channel_params'




More information about the asterisk-commits mailing list