From 34265d52654ddb2171a10a1b67bdfa4eb10906e1 Mon Sep 17 00:00:00 2001
From: Kinsey Moore <kmoore@digium.com>
Date: Thu, 16 Aug 2012 22:45:33 +0000
Subject: [PATCH] Add module reload instrumentation for TEST_FRAMEWORK

This adds AMI events for module reloads when Asterisk is built with
TEST_FRAMEWORK enabled and corrects generation of the module load AMI
event.

(issue PQ-1126)
........

Merged revisions 371393 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 371394 from http://svn.asterisk.org/svn/asterisk/branches/10
........

Merged revisions 371395 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@371396 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 main/loader.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/main/loader.c b/main/loader.c
index d824083496..1da6ef2fa5 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -750,6 +750,8 @@ int ast_module_reload(const char *name)
 		}
 
 		if (!info->reload) {	/* cannot be reloaded */
+			/* Nothing to reload, so reload is successful */
+			ast_test_suite_event_notify("MODULE_RELOAD", "Message: %s", cur->resource);
 			if (res < 1)	/* store result if possible */
 				res = 1;	/* 1 = no reload() method */
 			continue;
@@ -757,7 +759,9 @@ int ast_module_reload(const char *name)
 
 		res = 2;
 		ast_verb(3, "Reloading module '%s' (%s)\n", cur->resource, info->description);
-		info->reload();
+		if (!info->reload()) {
+			ast_test_suite_event_notify("MODULE_RELOAD", "Message: %s", cur->resource);
+		}
 	}
 	AST_LIST_UNLOCK(&module_list);
 
@@ -910,7 +914,9 @@ int ast_load_resource(const char *resource_name)
 	int res;
 	AST_LIST_LOCK(&module_list);
 	res = load_resource(resource_name, 0, NULL, 0);
-	ast_test_suite_event_notify("MODULE_LOAD", "Message: %s", resource_name);
+	if (!res) {
+		ast_test_suite_event_notify("MODULE_LOAD", "Message: %s", resource_name);
+	}
 	AST_LIST_UNLOCK(&module_list);
 
 	return res;
-- 
GitLab