[Asterisk-code-review] unittests: Add a unit test that causes a SEGV and... (asterisk[13])
George Joseph
asteriskteam at digium.com
Thu May 25 15:06:16 CDT 2017
George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/5714 )
Change subject: unittests: Add a unit test that causes a SEGV and...
......................................................................
unittests: Add a unit test that causes a SEGV and...
...that can only be run by explicitly calling it with
'test execute category /DO_NOT_RUN/ name RAISE_SEGV'
This allows us to more easily test CI and debugging tools that
should do certain things when asterisk coredumps.
To allow this a new member was added to the ast_test_info
structure named 'explicit_only'. If set by a test, the test
will be skipped during a 'test execute all' or
'test execute category ...'.
Change-Id: Ia3a11856aae4887df9a02b6b081cc777b36eb6ed
---
M include/asterisk/test.h
M main/test.c
M tests/test_pbx.c
3 files changed, 32 insertions(+), 2 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, approved
Mark Michelson: Looks good to me, but someone else must approve
George Joseph: Approved for Submit
diff --git a/include/asterisk/test.h b/include/asterisk/test.h
index 49731fe..90e772c 100644
--- a/include/asterisk/test.h
+++ b/include/asterisk/test.h
@@ -241,6 +241,14 @@
* \note The description must not end with a newline.
*/
const char *description;
+ /*!
+ * \brief Only run if explicitly named
+ *
+ * \details
+ * Run this test only if it's explicitly named on the command line.
+ * Do NOT run it as part of an execute category or execute all command.
+ */
+ unsigned int explicit_only;
};
#ifdef TEST_FRAMEWORK
diff --git a/main/test.c b/main/test.c
index e9b56eb..d22f2eb 100644
--- a/main/test.c
+++ b/main/test.c
@@ -346,7 +346,7 @@
execute = 0;
switch (mode) {
case TEST_CATEGORY:
- if (!test_cat_cmp(test->info.category, category)) {
+ if (!test_cat_cmp(test->info.category, category) && !test->info.explicit_only) {
execute = 1;
}
break;
@@ -356,7 +356,7 @@
}
break;
case TEST_ALL:
- execute = 1;
+ execute = !test->info.explicit_only;
}
if (execute) {
diff --git a/tests/test_pbx.c b/tests/test_pbx.c
index bb5d8e8..acf7484 100644
--- a/tests/test_pbx.c
+++ b/tests/test_pbx.c
@@ -323,8 +323,29 @@
return res;
}
+AST_TEST_DEFINE(segv)
+{
+ switch (cmd) {
+ case TEST_INIT:
+ info->name = "RAISE_SEGV";
+ info->category = "/DO_NOT_RUN/";
+ info->summary = "RAISES SEGV!!! (will only be run if explicitly called)";
+ info->description = "RAISES SEGV!!! (will only be run if explicitly called). "
+ "This test is mainly used for testing CI and tool failure scenarios.";
+ info->explicit_only = 1;
+ return AST_TEST_NOT_RUN;
+ case TEST_EXECUTE:
+ break;
+ }
+
+ raise(SIGSEGV);
+
+ return AST_TEST_FAIL;
+}
+
static int unload_module(void)
{
+ AST_TEST_UNREGISTER(segv);
AST_TEST_UNREGISTER(pattern_match_test);
return 0;
}
@@ -332,6 +353,7 @@
static int load_module(void)
{
AST_TEST_REGISTER(pattern_match_test);
+ AST_TEST_REGISTER(segv);
return AST_MODULE_LOAD_SUCCESS;
}
--
To view, visit https://gerrit.asterisk.org/5714
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia3a11856aae4887df9a02b6b081cc777b36eb6ed
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
More information about the asterisk-code-review
mailing list