summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-08-14 09:56:51 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-08-18 07:08:51 +0200
commitc7289484348fc33f77dc99e74a8d0a298144514d (patch)
treef4272cf0be5f41e55e5427b657d303ff071654ca
parentlibtest: Use a destructor (diff)
downloadrtems-c7289484348fc33f77dc99e74a8d0a298144514d.tar.bz2
libtest: Add T_push_plan() and T_pop_plan()
Update #3199.
-rw-r--r--cpukit/include/rtems/test.h6
-rw-r--r--cpukit/libtest/t-test.c15
-rw-r--r--testsuites/libtests/ttest01/init.c4
-rw-r--r--testsuites/libtests/ttest01/test-plan.c21
4 files changed, 44 insertions, 2 deletions
diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h
index ccab6c4a95..935e796bf0 100644
--- a/cpukit/include/rtems/test.h
+++ b/cpukit/include/rtems/test.h
@@ -2168,6 +2168,12 @@ void T_check_rsc_success(const T_check_context *, uint32_t);
void T_plan(unsigned int);
+extern const T_fixture T_empty_fixture;
+
+void T_push_plan(T_fixture_node *, unsigned int);
+
+void T_pop_plan(void);
+
void T_check_step(const T_check_context *, unsigned int);
#define T_flags_step(a, flags) \
diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c
index 3f9046a891..11f1cf70e9 100644
--- a/cpukit/libtest/t-test.c
+++ b/cpukit/libtest/t-test.c
@@ -550,6 +550,21 @@ void T_plan(unsigned int planned_steps)
expected);
}
+const T_fixture T_empty_fixture;
+
+void
+T_push_plan(T_fixture_node *node, unsigned int planned_steps)
+{
+ T_push_fixture(node, &T_empty_fixture);
+ T_plan(planned_steps);
+}
+
+void
+T_pop_plan(void)
+{
+ T_pop_fixture();
+}
+
void
T_check_step(const T_check_context *t, unsigned int expected)
{
diff --git a/testsuites/libtests/ttest01/init.c b/testsuites/libtests/ttest01/init.c
index 8636cdadd4..c0ccee9aa4 100644
--- a/testsuites/libtests/ttest01/init.c
+++ b/testsuites/libtests/ttest01/init.c
@@ -182,8 +182,8 @@ run_initialize(void)
T_set_putchar(censor_putchar, ctx, &ctx->putchar, &ctx->putchar_arg);
}
-static const char expected_final[] = "Z:ttest01:C:343:N:1335:F:795:D:0.689999\n"
-"Y:ReportHash:SHA256:525591019364543d5694dd09fef3bf2f0b7db69694f959e4298f22f4f9803fef\n";
+static const char expected_final[] = "Z:ttest01:C:344:N:1339:F:795:D:0.691999\n"
+"Y:ReportHash:SHA256:23dd328162c564ada3c4de97446801018ade051aaec3308bb9a7ef8f98041d67\n";
static void
run_finalize(void)
diff --git a/testsuites/libtests/ttest01/test-plan.c b/testsuites/libtests/ttest01/test-plan.c
index 4a550f34fa..d7632b8590 100644
--- a/testsuites/libtests/ttest01/test-plan.c
+++ b/testsuites/libtests/ttest01/test-plan.c
@@ -34,6 +34,19 @@ T_TEST_CASE(steps)
T_step(2);
}
+static T_fixture_node nested_plan_node;
+
+T_TEST_CASE(nested_plan)
+{
+ T_plan(2);
+ T_step(0);
+ T_push_plan(&nested_plan_node, 2);
+ T_step(0);
+ T_step(1);
+ T_pop_plan();
+ T_step(1);
+}
+
#include "t-self-test.h"
T_TEST_OUTPUT(wrong_step,
@@ -65,6 +78,14 @@ T_TEST_OUTPUT(steps,
"P:2:0:UI1:test-plan.c:34\n"
"E:steps:N:3:F:0:D:0.001000\n");
+T_TEST_OUTPUT(nested_plan,
+"B:nested_plan\n"
+"P:0:0:UI1:test-plan.c:42\n"
+"P:1.0:0:UI1:test-plan.c:44\n"
+"P:1.1:0:UI1:test-plan.c:45\n"
+"P:1:0:UI1:test-plan.c:47\n"
+"E:nested_plan:N:4:F:0:D:0.001000\n");
+
/*
* The license is at the end of the file to be able to use the test code and
* output in examples in the documentation. This is also the reason for the