Hi Sam, Thanks for the post. The website for the code is:
https://github.com/doctest/doctest I have been using this and I can port tests between Linux and RTEMS. I like it because it works and it is a single header. There is no need to build and link libraries. Chris On 16/6/2023 11:07 pm, Sam Price wrote: > /* Tell doctest to not use its own main */ > #define DOCTEST_CONFIG_IMPLEMENT > /* tell doctest to not use sigint that rtems does not have */ > #define DOCTEST_CONFIG_NO_POSIX_SIGNALS > #include "doctest.h" > > /* Setup command line part */ > const char rtems_test_name[] = "DOCTEST UNIT TESTS"; > > static int run_doctest_tests(int argc, char **argv) { > > // Initialize doctest context > doctest::Context context(argc, argv); > > int test_result = context.run(); // run queries, or run tests unless --no-run > > if(context.shouldExit()) // honor query flags and --exit > return test_result; > return 0; > } > > rtems_shell_cmd_t Shell_DOCTEST_Command = { > "doctest", /* name */ > "doctest [doctest options]", /* usage */ > "tests", /* topic */ > run_doctest_tests, /* command */ > NULL, /* alias */ > NULL /* next */ > }; > > /* Inside of your Init add the following prior to starting shell */ > rtems_task Init(rtems_task_argument ignored) > { > .... > > rtems_shell_add_cmd_struct(&Shell_DOCTEST_Command); > /* Note i made this high priority, some of my tests require priority access. > */ > /* It may be better to use 100, and use the following in your test > rtems_task_priority old_priority; > rtems_task_set_priority(RTEMS_SELF, 0, &old_priority); > ... > rtems_task_set_priority(RTEMS_SELF, old_priority, 0x0); > */ > > rtems_shell_init("shell0", 20 * 1024, 2, "/dev/console", 0, 1, NULL); > ... > } > > TEST_CASE("testing the addition function") { > CHECK((2 + 2) == 4); > CHECK((2 + 2) == 4.0); > } > _______________________________________________ > devel mailing list > devel@rtems.org > http://lists.rtems.org/mailman/listinfo/devel _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel