Beaglebone QEP driver design question
Hi all, I have a very basic version of the QEP driver for the Beaglebone black working now. I will tidy up my code and submit a patch in the next few days. For first patches that are likely to require a bit of discussion etc, is the best idea to still submit them to this list per the normal process, or is there an alternative approach that would be better? (The patch adds several files and modifies several existing ones). Secondly, I have an RTEMS style question. The driver would work best if I had a small struct that contained a few properties about the driver configuration. One such property is difficult to intuit from the state of the registers and so would be better in a separate data structure. This would mean that the code might look something like this: typedef struct { BBB_PWMSS pwmss_id; BBB_QEP_COUNT_MODE mode; } bbb_eqep_t; rtems_status_code beagle_qep_init(bbb_eqep_t* eqep); int32_t beagle_qep_get_position(bbb_eqep_t* eqep); Is that in keeping with the RTEMS approach? Looking at some of the other BSPs I see similar approaches for other drivers that need to track state for multiple instances of hardware. Your advice is appreciated. Cheers, James Fitzsimons ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Reworking MIPS Fenv support
Hello everyone, As I was reworking the MIPS fenv support I realised it wasn't as bad as ARM fenv since there is no mangle files There are just headers and extern inline function definitions in the fenv.c file That greatly decreased the margin of error So, I though instead of complete rework I make changes in the existing fenv-softfp.h file So as it has softfloat similar to RISC-V And as only either hard float or soft float definitions are picked at the linking part So the errors are not much likely to occur -- Thanks - Eshan ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: Doubt regarding thread creation in RTEMS
Hi, Could you please explain what _User_extensions_Thread_start does? It's hard to understand it all by myself since it has a lot of other information related to objects. The brief for it says: /** * @brief Starts a thread. * * @param created The thread to start. */ This is exactly what my doubt was. When we unlocked the node by setting the state to ready by calling _Thread_Clear_state_locked, shouldn't the node be scheduled if the scheduler sees it fit? Why are we enabling thread dispatch on the current cpu (Shouldn't it depend on the affinity of the thread)? Please tell me what happens in principle after calling _Thread_Clear_state_locked(). Thank you. On Tue, Jul 21, 2020 at 11:42 AM Richi Dubey wrote: > Hi, > > _Thread_Clear_state_locked( the_thread, STATES_ALL_SET ); > > I did have a look at it, it unblocks the node belonging to the_thread, > I'll go through everything again. > > When you use the debugger to figure out what is going on I would step in >> to each function you don't know. > > Got it. Thank you. > > > On Mon, Jul 20, 2020 at 9:24 PM Sebastian Huber < > sebastian.hu...@embedded-brains.de> wrote: > >> On 20/07/2020 17:16, Richi Dubey wrote: >> >> > Hi, >> > >> > I am trying to map out how a task gets scheduled according to a >> > scheduling algorithm once a user writes rtems_task_create() and later >> > rtems_task_start() in the source file. >> > >> > On debugging with gdb, I came to realize that the >> > >> > rtems_task_start() function calls _Thread_Start() >> > (cpukit/rtems/src/taskstart.c : 56) then _Thread_Start() calls >> > _Thread_Dispatch_enable() ( cpukit/score/src/threadstart.c : 50 ) then >> > _Thread_Dispatch_enable() calls _Thread_Do_dispatch( ) >> > (cpukit/score/src/threaddispatch.c : 377) >> > and _Thread_Do_dispatch calls _Thread_Get_heir_and_make_it_executing() >> > (threaddispatch.c : 282). >> > >> > _Thread_Get_heir_and_make_it_executing( cpu_self ) forcefully executes >> > the heir thread on the cpu_self. >> > (cpukit/include/rtems/score/threadimpl.h : 1117) >> > >> > If I am right, this flow of code makes the thread created by >> > rtems_task_create(..., id) execute on a CPU when rtems_task_start(..., >> > id) is called. Shouldn't this decision of executing a thread on any >> > CPU be in the hands of the scheduler? I'd be grateful if someone >> > could provide their views on this. >> >> Yes, the scheduler decides which of the ready threads gets a scheduler >> assigned. In _Thread_Start() please have a look at: >> >> _Thread_Clear_state_locked( the_thread, STATES_ALL_SET ); >> >> > >> > Also, what is thread_dispatch_disable_level? >> >> This is a per-CPU variable. If thread_dispatch_disable_level != 0, then >> thread changes are prohibited on this processor. If it changes from 1 to >> 0, then it is checked if a thread dispatch is necessary. >> >> > Please know that I skipped reading some if conditions and some code >> > related to ISRs and other things that weren't directly related to >> > scheduling. >> When you use the debugger to figure out what is going on I would step in >> to each function you don't know. >> > ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH] score: Improve _Thread_Start() description
--- cpukit/include/rtems/score/threadimpl.h | 35 - 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h index b4b85ffa90..355311867d 100644 --- a/cpukit/include/rtems/score/threadimpl.h +++ b/cpukit/include/rtems/score/threadimpl.h @@ -211,14 +211,37 @@ bool _Thread_Initialize( ); /** - * @brief Initializes thread and executes it. + * @brief Starts the specified thread. * - * This routine initializes the executable information for a thread - * and makes it ready to execute. After this routine executes, the - * thread competes with all other threads for CPU time. + * If the thread is not in the dormant state, the routine returns immediately + * false and performs no actions. * - * @param the_thread The thread to be started. - * @param entry The thread entry information. + * Otherwise, this routine initializes the executable information for the + * thread and makes it ready to execute. After the call of this routine, the + * thread competes with all other ready threads for CPU time. + * + * Then the routine enables the local interrupts as indicated by the ISR lock + * context. + * + * Then the thread start user extensions are called with thread dispatching + * disabled and interrupts enabled after making the thread ready. Please note + * that in SMP configurations, the thread switch and begin user extensions may + * be called in parallel on another processor. + * + * Then thread dispatching is enabled and another threads may execute before + * the routine returns. + * + * @param[in, out] the_thread is the thread to start. + * + * @param entry is the thread entry information. + * + * @param[in, out] is the ISR lock context which shall be used to disable the + * local interrupts before the call of this routine. + * + * @retval true The thread was in the dormant state and was sucessefully + * started. + * + * @retval false Otherwise. */ bool _Thread_Start( Thread_Control *the_thread, -- 2.26.2 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: Doubt regarding thread creation in RTEMS
On 21/07/2020 14:36, Richi Dubey wrote: Could you please explain what _User_extensions_Thread_start does? It's hard to understand it all by myself since it has a lot of other information related to objects. The brief for it says: /** * @brief Starts a thread. * * @param created The thread to start. */ This is exactly what my doubt was. When we unlocked the node by setting the state to ready by calling _Thread_Clear_state_locked, shouldn't the node be scheduled if the scheduler sees it fit? Why are we enabling thread dispatch on the current cpu (Shouldn't it depend on the affinity of the thread)? Please tell me what happens in principle after calling _Thread_Clear_state_locked(). I tried to improve the _Thread_Start() description: https://lists.rtems.org/pipermail/devel/2020-July/060764.html ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: Benchmarking RTEMS on PPC vs ARM multicore
On Mon, Jul 20, 2020 at 10:55 PM Sebastian Huber wrote: > > Hello Gedare, > > what kind of performance benchmarking do you have in mind? > The immediate goal is going to be performance comparison of RTEMS in baremetal vs hosted in a paravirtual environment. I haven't planned out the experiment yet, but probably some microbenchmarks of common operations, and maybe some application benchmarks if some make sense. > To benchmark the clustered scheduling, you need at least a system with > separated L2 caches, e.g. T4240 and LS1088A. > Thanks, that is not an immediate requirement for me, but good to know. > We don't have BSPs for the QorIQ Layerscape platform. The chips are > quite complex. > Also good to know. > I haven't looked closely at the Xilinx Zynq but it seems they only have > up to four cores and one L2 cache. We have a BSP for the Xilinx Zynq > UltraScale+ (I neveer tested it). So maybe select one of them with 4 > core and the T2080. > Yeah, that was my initial thought as well after a brief discussion with Joel. It would also be a good opportunity to put the UltraScale+ BSP to work. Thanks for the thoughtful feedback, it has helped narrow the choices down to two. Gedare ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 0/1] eng: Update test framework chapter
You find a generated document here: https://ftp.rtems.org/pub/rtems/people/sebh/eng2.pdf Sebastian Huber (1): eng: Update test framework chapter eng/index.rst | 4 +- eng/test-framework.rst| 185 -- images/eng/interrupt-test.odg | Bin 0 -> 14829 bytes images/eng/interrupt-test.pdf | Bin 0 -> 14153 bytes images/eng/interrupt-test.png | Bin 0 -> 75272 bytes 5 files changed, 178 insertions(+), 11 deletions(-) create mode 100644 images/eng/interrupt-test.odg create mode 100644 images/eng/interrupt-test.pdf create mode 100644 images/eng/interrupt-test.png -- 2.26.2 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 1/1] eng: Update test framework chapter
Document the dynamic text fixtures, utility functions, and the interrupt test support. Update #3199. --- eng/index.rst | 4 +- eng/test-framework.rst| 185 -- images/eng/interrupt-test.odg | Bin 0 -> 14829 bytes images/eng/interrupt-test.pdf | Bin 0 -> 14153 bytes images/eng/interrupt-test.png | Bin 0 -> 75272 bytes 5 files changed, 178 insertions(+), 11 deletions(-) create mode 100644 images/eng/interrupt-test.odg create mode 100644 images/eng/interrupt-test.pdf create mode 100644 images/eng/interrupt-test.png diff --git a/eng/index.rst b/eng/index.rst index 8f91c5e..f6b02ec 100644 --- a/eng/index.rst +++ b/eng/index.rst @@ -11,8 +11,8 @@ RTEMS Software Engineering (|version|) .. topic:: Copyrights and License -| |copy| 2018, 2019 embedded brains GmbH -| |copy| 2018, 2019 Sebastian Huber +| |copy| 2018, 2020 embedded brains GmbH +| |copy| 2018, 2020 Sebastian Huber | |copy| 1988, 2015 On-Line Applications Research Corporation (OAR) .. include:: ../common/license.rst diff --git a/eng/test-framework.rst b/eng/test-framework.rst index b6411b5..582718d 100644 --- a/eng/test-framework.rst +++ b/eng/test-framework.rst @@ -1,7 +1,7 @@ .. SPDX-License-Identifier: CC-BY-SA-4.0 -.. Copyright (C) 2018, 2019 embedded brains GmbH -.. Copyright (C) 2018, 2019 Sebastian Huber +.. Copyright (C) 2018, 2020 embedded brains GmbH +.. Copyright (C) 2018, 2020 Sebastian Huber Software Test Framework *** @@ -144,13 +144,41 @@ macro followed by a function body: The test case `name` must be a valid C designator. The test case names must be unique within the test suite. The `fixture` must point to a statically -initialized read-only object of type `T_fixture`. The test fixture -provides methods to setup, stop and tear down a test case. A context is passed -to the methods. The initial context is defined by the read-only fixture -object. The context can be obtained by the `T_fixture_context()` -function. It can be set within the scope of one test case by the -`T_set_fixture_context()` function. This can be used for example to -dynamically allocate a test environment in the setup method. +initialized read-only object of type `T_fixture`. + +.. code-block:: c + +typedef struct T_fixture { +void (*setup)(void *context); +void (*stop)(void *context); +void (*teardown)(void *context); +void (*scope)(void *context, char *buffer, size_t size); +void *initial_context; +} T_fixture; + +The test fixture provides methods to setup, stop, and teardown a test case as +well as to give the scope for log messags. A context is passed to each of the +methods. The initial context is defined by the read-only fixture object. The +context can be obtained by the `T_fixture_context()` function. It can be set +within the scope of one test case by the `T_set_fixture_context()` function. +This can be used for example to dynamically allocate a test environment in the +setup method. + +The test case fixtures of a test case are organized as a stack. Fixtures can +be dynamically added to a test case and removed from a test case via the +`T_push_fixture()` and `T_pop_fixture()` functions. + +.. code-block:: c + +void *T_push_fixture(T_fixture_node *node, const T_fixture *fixture); + +void T_pop_fixture(void); + +The `T_push_fixture()` function needs an uninitialized fixture node which must +exist until `T_pop_fixture()` is called. It returns the initial context of the +fixture. At the end of a test case all pushed fixtures are popped +automatically. A call of `T_pop_fixture()` invokes the teardown method of the +fixture and must correspond to a previous call to `T_push_fixture()`. .. code-block:: c :caption: Test Fixture Example @@ -1028,6 +1056,34 @@ RTEMS, floating-point operations are only supported in special tasks and may be forbidden in interrupt context. The formatted output functions provided by the test framework work in every context. +Utility +--- + +You can stop a test case via the ``T_stop()`` function. This function does not +return. You can indicate unreachable code paths with the ``T_unreachable()`` +function. If this function is called, then the test case stops. + +You can busy wait with the ``T_busy()`` function: + +.. code-block:: c + +void T_busy(uint_fast32_t count); + +It performs a busy loop with the specified iteration count. This function is +optimized to not perform memory accesses and should have a small jitter. + +You can get an interation count for the ``T_busy()`` function which corresponds +roughly to one clock tick interval with the ``T_get_one_clock_tick_busy()`` +function: + +.. code-block:: c + +uint_fast32_t T_get_one_clock_tick_busy(void); + +This function requires a clock driver. It must be called from thread context +with interrupts enabled. It may return a different value each time it is +called
[PATCH 10/33] libtest: Add T_stop()
Update #3199. --- cpukit/include/rtems/test.h | 8 cpukit/libtest/t-test.c | 12 +--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index 09afc29593..8af810def7 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -95,6 +95,12 @@ typedef struct T_fixture_node { * @{ */ +#ifdef __cplusplus +#define T_NO_RETURN [[ noreturn ]] +#else +#define T_NO_RETURN _Noreturn +#endif + typedef struct T_case_context { const char *name; void (*body)(void); @@ -2243,6 +2249,8 @@ void *T_push_fixture(T_fixture_node *, const T_fixture *); void T_pop_fixture(void); +T_NO_RETURN void T_stop(void); + /** * @brief Gets the scope for nested fixtures. * diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c index e74b4d3495..4c5746fc5c 100644 --- a/cpukit/libtest/t-test.c +++ b/cpukit/libtest/t-test.c @@ -423,8 +423,8 @@ T_add_failure(T_context *ctx) memory_order_relaxed); } -static void -T_stop(T_context *ctx) +T_NO_RETURN static void +T_do_stop(T_context *ctx) { T_fixture_node *node; @@ -445,6 +445,12 @@ T_stop(T_context *ctx) longjmp(ctx->case_begin_context, 1); } +T_NO_RETURN void +T_stop(void) +{ + T_do_stop(&T_instance); +} + void T_plan(unsigned int planned_steps) { T_context *ctx; @@ -568,7 +574,7 @@ T_check_true(bool ok, const T_check_context *t, const char *fmt, ...) } if ((t->flags & T_CHECK_STOP) != 0) { - T_stop(ctx); + T_do_stop(ctx); } } else if ((t->flags & T_CHECK_QUIET) == 0 && ctx->verbosity >= T_VERBOSE) { -- 2.26.2 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 08/33] libtest: Add T_get_scope()
Update #3199. --- cpukit/include/rtems/test.h | 23 ++ cpukit/libtest/t-test.c | 39 + 2 files changed, 62 insertions(+) diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index 04f92dd1f4..09afc29593 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -2243,6 +2243,29 @@ void *T_push_fixture(T_fixture_node *, const T_fixture *); void T_pop_fixture(void); +/** + * @brief Gets the scope for nested fixtures. + * + * This function should help implementing scope fixture methods. The parameter + * layout allows efficient code generation for this method. + * + * @param desc is the description table. It shall be a NULL-terminated array + * which references arrays of descriptive strings. + * + * @param buf is the buffer for the scope string. + * + * @param n is the size of the scope buffer in characters. + * + * @param second_indices is an array of indices defining which descriptive + * string is used for each entry in the description table. + */ +void T_get_scope( + const char * const * const *desc, + char *buf, + size_t n, + const size_t *second_indices +); + #ifdef __rtems__ #define T_TEST_CASE_FIXTURE(name, fixture) \ void T_case_body_##name(void); \ diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c index bf9b68cdf2..e74b4d3495 100644 --- a/cpukit/libtest/t-test.c +++ b/cpukit/libtest/t-test.c @@ -1095,3 +1095,42 @@ T_pop_fixture(void) memset(node, 0, sizeof(*node)); } + +void +T_get_scope(const char * const * const *desc, char *buf, size_t n, +const size_t *second_indices) +{ + size_t i; + + i = 0; + + while (true) { + const char * const *desc2; + size_t m; + + desc2 = desc[i]; + + if (desc2 == NULL) { + return; + } + + if (n > 1) { + buf[0] = '/'; + --n; + ++buf; + } else { + return; + } + + m = strlcpy(buf, desc2[second_indices[i]], n); + + if (m < n) { + n -= m; + buf += m; + } else { + return; + } + + ++i; + } +} -- 2.26.2 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 09/33] libtest: Split POSIX Keys support
Update #3199. --- cpukit/Makefile.am | 1 + cpukit/libtest/t-test-rtems-objs.c | 95 +++ cpukit/libtest/t-test-rtems-posix-keys.c | 115 +++ cpukit/libtest/t-test-rtems.h| 62 4 files changed, 193 insertions(+), 80 deletions(-) create mode 100644 cpukit/libtest/t-test-rtems-posix-keys.c create mode 100644 cpukit/libtest/t-test-rtems.h diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index a119055abb..ce25efe10b 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -1870,6 +1870,7 @@ librtemstest_a_SOURCES += libtest/t-test-rtems-fds.c librtemstest_a_SOURCES += libtest/t-test-rtems-heap.c librtemstest_a_SOURCES += libtest/t-test-rtems-measure.c librtemstest_a_SOURCES += libtest/t-test-rtems-objs.c +librtemstest_a_SOURCES += libtest/t-test-rtems-posix-keys.c librtemstest_a_SOURCES += libtest/t-test-time.c project_lib_LIBRARIES += libftpd.a diff --git a/cpukit/libtest/t-test-rtems-objs.c b/cpukit/libtest/t-test-rtems-objs.c index a5d6b4d72f..72447fd22f 100644 --- a/cpukit/libtest/t-test-rtems-objs.c +++ b/cpukit/libtest/t-test-rtems-objs.c @@ -1,7 +1,15 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file * - * Copyright (C) 2018 embedded brains GmbH + * @ingroup RTEMSTestFramework + * + * @brief RTEMS Objects Support for Test Framework + */ + +/* + * Copyright (C) 2018 embedded brains GmbH (http://www.embedded-brains.de) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,15 +35,15 @@ #undef __STRICT_ANSI__ +#include "t-test-rtems.h" + #include #include -#include #include -#include -static Objects_Maximum +Objects_Maximum T_objects_count(Objects_APIs api, uint16_t cls) { const Objects_Information *information; @@ -56,7 +64,7 @@ T_objects_count(Objects_APIs api, uint16_t cls) return count; } -static void +void T_objects_check(Objects_APIs api, uint16_t cls, Objects_Maximum *expected, const char *name) { @@ -372,76 +380,3 @@ T_check_rtems_timers(T_event event, const char *name) break; }; } - -static Objects_Maximum T_posix_key_count; - -static ssize_t T_posix_key_value_count; - -static POSIX_Keys_Control * -T_get_next_posix_key(Objects_Id *id) -{ - return (POSIX_Keys_Control *) - _Objects_Get_next(*id, &_POSIX_Keys_Information, id); -} - -static ssize_t -T_get_active_posix_key_value_pairs(void) -{ - ssize_t count; - Objects_Id id; - POSIX_Keys_Control *the_key; - - count = 0; - id = OBJECTS_ID_INITIAL_INDEX; - - while ((the_key = T_get_next_posix_key(&id)) != NULL ) { - count += (ssize_t) - _Chain_Node_count_unprotected(&the_key->Key_value_pairs); - _Objects_Allocator_unlock(); - } - - return count; -} - -static void -T_posix_keys_run_initialize(void) -{ - T_posix_key_count = T_objects_count(OBJECTS_POSIX_API, - OBJECTS_POSIX_KEYS); - T_posix_key_value_count = T_get_active_posix_key_value_pairs(); -} - -static void -T_posix_keys_case_end(void) -{ - ssize_t count; - ssize_t delta; - - T_objects_check(OBJECTS_POSIX_API, OBJECTS_POSIX_KEYS, - &T_posix_key_count, "POSIX key"); - - count = T_get_active_posix_key_value_pairs(); - delta = count - T_posix_key_value_count; - - if (delta != 0) { - T_posix_key_value_count = count; - T_check_true(false, NULL, "POSIX key value pair leak (%zi)", delta); - } -} - -void -T_check_posix_keys(T_event event, const char *name) -{ - (void)name; - - switch (event) { - case T_EVENT_RUN_INITIALIZE_EARLY: - T_posix_keys_run_initialize(); - break; - case T_EVENT_CASE_END: - T_posix_keys_case_end(); - break; - default: - break; - }; -} diff --git a/cpukit/libtest/t-test-rtems-posix-keys.c b/cpukit/libtest/t-test-rtems-posix-keys.c new file mode 100644 index 00..0769f68ba8 --- /dev/null +++ b/cpukit/libtest/t-test-rtems-posix-keys.c @@ -0,0 +1,115 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFramework + * + * @brief RTEMS POSIX Keys Support for Test Framework + */ + +/* + * Copyright (C) 2018 embedded brains GmbH (http://www.embedded-brains.de) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in th
[PATCH 02/33] libtest: Move to
Update #3199. --- cpukit/headers.am | 2 +- cpukit/include/{t.h => rtems/test.h}| 0 cpukit/libtest/t-test-checks-eno.c | 2 +- cpukit/libtest/t-test-checks-psx.c | 2 +- cpukit/libtest/t-test-checks.c | 2 +- cpukit/libtest/t-test-hash-sha256.c | 2 +- cpukit/libtest/t-test-malloc.c | 2 +- cpukit/libtest/t-test-rtems-context.c | 2 +- cpukit/libtest/t-test-rtems-fds.c | 2 +- cpukit/libtest/t-test-rtems-heap.c | 2 +- cpukit/libtest/t-test-rtems-measure.c | 2 +- cpukit/libtest/t-test-rtems-objs.c | 2 +- cpukit/libtest/t-test-rtems.c | 2 +- cpukit/libtest/t-test-time.c| 2 +- cpukit/libtest/t-test.c | 2 +- testsuites/libtests/ttest01/init.c | 2 +- testsuites/libtests/ttest01/test-assert.c | 2 +- testsuites/libtests/ttest01/test-checks.c | 2 +- testsuites/libtests/ttest01/test-destructor.c | 2 +- testsuites/libtests/ttest01/test-eno.c | 2 +- testsuites/libtests/ttest01/test-example.c | 2 +- testsuites/libtests/ttest01/test-fixture.c | 2 +- testsuites/libtests/ttest01/test-leak.c | 2 +- testsuites/libtests/ttest01/test-log.c | 2 +- testsuites/libtests/ttest01/test-malloc.c | 2 +- testsuites/libtests/ttest01/test-plan.c | 2 +- testsuites/libtests/ttest01/test-psx.c | 2 +- testsuites/libtests/ttest01/test-rtems.c| 2 +- testsuites/libtests/ttest01/test-simple.c | 2 +- testsuites/libtests/ttest01/test-step.c | 2 +- testsuites/libtests/ttest01/test-task-context.c | 2 +- testsuites/libtests/ttest01/test-time.c | 2 +- testsuites/libtests/ttest01/test-verbosity.c| 2 +- testsuites/smptests/smpmulticast01/init.c | 2 +- 34 files changed, 33 insertions(+), 33 deletions(-) rename cpukit/include/{t.h => rtems/test.h} (100%) diff --git a/cpukit/headers.am b/cpukit/headers.am index 248707dc8a..f74e0228da 100644 --- a/cpukit/headers.am +++ b/cpukit/headers.am @@ -17,7 +17,6 @@ include_HEADERS += include/poll.h include_HEADERS += include/rtems.h include_HEADERS += include/sha256.h include_HEADERS += include/sha512.h -include_HEADERS += include/t.h include_HEADERS += include/xz.h include_HEADERS += include/zconf.h include_HEADERS += include/zlib.h @@ -172,6 +171,7 @@ include_rtems_HEADERS += include/rtems/telnetd.h include_rtems_HEADERS += include/rtems/termios_printk.h include_rtems_HEADERS += include/rtems/termios_printk_cnf.h include_rtems_HEADERS += include/rtems/termiostypes.h +include_rtems_HEADERS += include/rtems/test.h include_rtems_HEADERS += include/rtems/tftp.h include_rtems_HEADERS += include/rtems/thread.h include_rtems_HEADERS += include/rtems/timecounter.h diff --git a/cpukit/include/t.h b/cpukit/include/rtems/test.h similarity index 100% rename from cpukit/include/t.h rename to cpukit/include/rtems/test.h diff --git a/cpukit/libtest/t-test-checks-eno.c b/cpukit/libtest/t-test-checks-eno.c index c33b196206..d18a3bd273 100644 --- a/cpukit/libtest/t-test-checks-eno.c +++ b/cpukit/libtest/t-test-checks-eno.c @@ -25,7 +25,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include diff --git a/cpukit/libtest/t-test-checks-psx.c b/cpukit/libtest/t-test-checks-psx.c index 58e9fb64f5..e14ce65246 100644 --- a/cpukit/libtest/t-test-checks-psx.c +++ b/cpukit/libtest/t-test-checks-psx.c @@ -1,4 +1,4 @@ -#include +#include #include diff --git a/cpukit/libtest/t-test-checks.c b/cpukit/libtest/t-test-checks.c index b9e1f7b5f5..7824fa54c1 100644 --- a/cpukit/libtest/t-test-checks.c +++ b/cpukit/libtest/t-test-checks.c @@ -25,7 +25,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include diff --git a/cpukit/libtest/t-test-hash-sha256.c b/cpukit/libtest/t-test-hash-sha256.c index 4793a508e5..25584cce14 100644 --- a/cpukit/libtest/t-test-hash-sha256.c +++ b/cpukit/libtest/t-test-hash-sha256.c @@ -25,7 +25,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #if defined(__rtems__) #include diff --git a/cpukit/libtest/t-test-malloc.c b/cpukit/libtest/t-test-malloc.c index 83f32bebf5..369bff9a57 100644 --- a/cpukit/libtest/t-test-malloc.c +++ b/cpukit/libtest/t-test-malloc.c @@ -25,7 +25,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include diff --git a/cpukit/libtest/t-test-rtems-context.c b/cpukit/libtest/t-test-rtems-context.c index 82c93f9afe..10f7322d92 100644 --- a/cpukit/libtest/t-test-rtems-context.c +++ b/cpukit/libtest/t-test-rtems-context.c @@ -27,7 +27,7 @@ #undef __STRICT_ANSI__ -#include +#include #include #include diff --git a/cpukit/libtest/t-test-rtems-fds.c b/cpukit/libtest/t-test-rtems-fds.c index a836c9f9bd..57957925ad 100644 --- a/cpukit/libtest/t-test-rtems-fds.c +++ b/cpukit/libtest/t-test-rtems-fds.c
[PATCH 03/33] libtest: Add T_busy()
Update #3199. --- cpukit/Makefile.am| 1 + cpukit/include/rtems/simple-test.h| 12 +--- cpukit/include/rtems/test.h | 4 +- cpukit/libtest/t-test-busy.c | 58 +++ cpukit/libtest/testbusy.c | 20 +-- .../spintrcritical_support/intrcritical.c | 3 +- 6 files changed, 68 insertions(+), 30 deletions(-) create mode 100644 cpukit/libtest/t-test-busy.c diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index abf18d176f..7f89f6a283 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -1857,6 +1857,7 @@ librtemstest_a_SOURCES += libtest/testextension.c librtemstest_a_SOURCES += libtest/testparallel.c librtemstest_a_SOURCES += libtest/testwrappers.c librtemstest_a_SOURCES += libtest/t-test.c +librtemstest_a_SOURCES += libtest/t-test-busy.c librtemstest_a_SOURCES += libtest/t-test-checks.c librtemstest_a_SOURCES += libtest/t-test-checks-eno.c librtemstest_a_SOURCES += libtest/t-test-checks-psx.c diff --git a/cpukit/include/rtems/simple-test.h b/cpukit/include/rtems/simple-test.h index 873b8482af..5f73e92055 100644 --- a/cpukit/include/rtems/simple-test.h +++ b/cpukit/include/rtems/simple-test.h @@ -305,17 +305,7 @@ void rtems_test_parallel( void rtems_test_busy_cpu_usage(time_t seconds, long nanoseconds); /** - * @brief Performs a busy loop with the specified iteration count. - * - * This function is optimized to not perform memory accesses and should have a - * small jitter. - * - * @param[in] count The iteration count. - */ -void rtems_test_busy(uint_fast32_t count); - -/** - * @brief Returns a count value for rtems_test_busy() which yields roughly a + * @brief Returns a count value for T_busy() which yields roughly a * duration of one clock tick. */ uint_fast32_t rtems_test_get_one_tick_busy_count(void); diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index ecdc03f94c..4c14e8d217 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 2018, 2019 embedded brains GmbH + * Copyright (C) 2017, 2020 embedded brains GmbH * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -2261,6 +2261,8 @@ void T_case_body_##name(void) #define T_TEST_CASE(name) T_TEST_CASE_FIXTURE(name, NULL) +void T_busy(uint_fast32_t); + void T_report_hash_sha256(T_event, const char *); void T_check_heap(T_event, const char *); diff --git a/cpukit/libtest/t-test-busy.c b/cpukit/libtest/t-test-busy.c new file mode 100644 index 00..3bf149b8bb --- /dev/null +++ b/cpukit/libtest/t-test-busy.c @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl + * + * @brief Implementation of T_busy(). + */ + +/* + * Copyright (C) 2014, 2020 embedded brains GmbH (http://www.embedded-brains.de) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +/* + * It is important that we actually use the same T_busy() function at the + * various places. So, the compiler must not inline this function. Take care + * of link time optimization. + */ +__attribute__((__noinline__)) void +T_busy(uint_fast32_t count) +{ + uint_fast32_t i; + + i = 0; + + do { + __asm__ volatile (""); + ++i; + } while (i < count); +} diff --git a/cpukit/libtest/testbusy.c b/cpukit/libtest/testbusy.c index 4dd6f500a9..68a38fbbf9 100644 --- a/cpukit/libtest/testbusy.c +++ b/cpukit/libtest/
[PATCH 04/33] libtest: Add T_get_one_clock_tick_busy()
Update #3199. --- cpukit/Makefile.am| 1 + cpukit/include/rtems/simple-test.h| 6 - cpukit/include/rtems/test.h | 2 + cpukit/libtest/t-test-busy-tick.c | 121 ++ cpukit/libtest/testbusy.c | 73 --- .../spintrcritical_support/intrcritical.c | 2 +- 6 files changed, 125 insertions(+), 80 deletions(-) create mode 100644 cpukit/libtest/t-test-busy-tick.c diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index 7f89f6a283..a119055abb 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -1858,6 +1858,7 @@ librtemstest_a_SOURCES += libtest/testparallel.c librtemstest_a_SOURCES += libtest/testwrappers.c librtemstest_a_SOURCES += libtest/t-test.c librtemstest_a_SOURCES += libtest/t-test-busy.c +librtemstest_a_SOURCES += libtest/t-test-busy-tick.c librtemstest_a_SOURCES += libtest/t-test-checks.c librtemstest_a_SOURCES += libtest/t-test-checks-eno.c librtemstest_a_SOURCES += libtest/t-test-checks-psx.c diff --git a/cpukit/include/rtems/simple-test.h b/cpukit/include/rtems/simple-test.h index 5f73e92055..42f5235af8 100644 --- a/cpukit/include/rtems/simple-test.h +++ b/cpukit/include/rtems/simple-test.h @@ -304,12 +304,6 @@ void rtems_test_parallel( */ void rtems_test_busy_cpu_usage(time_t seconds, long nanoseconds); -/** - * @brief Returns a count value for T_busy() which yields roughly a - * duration of one clock tick. - */ -uint_fast32_t rtems_test_get_one_tick_busy_count(void); - /** @} */ #ifdef __cplusplus diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index 4c14e8d217..b68f303e16 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -2263,6 +2263,8 @@ void T_case_body_##name(void) void T_busy(uint_fast32_t); +uint_fast32_t T_get_one_clock_tick_busy(void); + void T_report_hash_sha256(T_event, const char *); void T_check_heap(T_event, const char *); diff --git a/cpukit/libtest/t-test-busy-tick.c b/cpukit/libtest/t-test-busy-tick.c new file mode 100644 index 00..3613f8ed72 --- /dev/null +++ b/cpukit/libtest/t-test-busy-tick.c @@ -0,0 +1,121 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl + * + * @brief Implementation of T_get_one_clock_tick_busy(). + */ + +/* + * Copyright (C) 2014, 2020 embedded brains GmbH (http://www.embedded-brains.de) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include + +static uint_fast32_t +T_estimate_busy_loop_maximum(void) +{ + uint_fast32_t initial; + uint_fast32_t units; + + initial = rtems_clock_get_ticks_since_boot(); + units = 0; + + while (initial == rtems_clock_get_ticks_since_boot()) { + ++units; + } + + return units; +} + +static uint_fast32_t +T_wait_for_tick_change(void) +{ + uint_fast32_t initial; + uint_fast32_t now; + + initial = rtems_clock_get_ticks_since_boot(); + + do { + now = rtems_clock_get_ticks_since_boot(); + } while (now == initial); + + return now; +} + +uint_fast32_t +T_get_one_clock_tick_busy(void) +{ + uint_fast32_t last; + uint_fast32_t now; + uint_fast32_t a; + uint_fast32_t b; + uint_fast32_t m; + + /* Choose a lower bound */ + a = 1; + + /* Estimate an upper bound */ + + T_wait_for_tick_change(); + b = 2 * T_estimate_busy_loop_maximum(); + + while (true) { + last = T_wait_for_tick_change(); + T_busy(b); + now = rtems_clock_get_ticks_since_b
[PATCH 12/33] libtest: Make check message optional
This macro magic is in line with C11 and C++11, but limits the maximum count of arguments. Update #3199. --- cpukit/include/rtems/test.h | 107 +++--- testsuites/libtests/ttest01/init.c| 4 +- testsuites/libtests/ttest01/test-checks.c | 23 + 3 files changed, 97 insertions(+), 37 deletions(-) diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index c0227b5465..d14bb9fe2d 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -114,6 +114,7 @@ void T_case_register(T_case_context *); #define T_CHECK_QUIET 2U +/* If you change this value, you have to adjust T_VA_ARGS_KIND() as well */ #define T_CHECK_FMT 4U #define T_CHECK_STEP_FLAG 8U @@ -135,22 +136,46 @@ typedef struct { const char *msg; } T_check_context_msg; +#define T_VA_ARGS_FIRST(...) T_VA_ARGS_FIRST_SELECT(__VA_ARGS__, throw_away) +#define T_VA_ARGS_FIRST_SELECT(first, ...) first + +/* + * The T_VA_ARGS_MORE() supports up to nine arguments. It expands to nothing + * if only one argument is given. It expands to a comma and the second and + * following arguments if at least two arguments are present. The 4U shall + * correspond to T_CHECK_FMT. + */ +#define T_VA_ARGS_MORE(...) \ +T_VA_ARGS_XEXPAND(T_VA_ARGS_KIND(__VA_ARGS__), __VA_ARGS__) +#define T_VA_ARGS_XEXPAND(kind, ...) T_VA_ARGS_EXPAND(kind, __VA_ARGS__) +#define T_VA_ARGS_EXPAND(kind, ...) T_VA_ARGS_EXPAND_##kind(__VA_ARGS__) +#define T_VA_ARGS_EXPAND_0U(first) +#define T_VA_ARGS_EXPAND_4U(first, ...) , __VA_ARGS__ +#define T_VA_ARGS_KIND(...) \ +T_VA_ARGS_SELECT(__VA_ARGS__, \ +4U, 4U, 4U, 4U, 4U, 4U, 4U, 4U, 0U, throw_away) +#define T_VA_ARGS_SELECT(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, ...) a10 + void T_check(const T_check_context *, bool, ...); extern const T_check_context T_special; -#define T_flags_true(a, flags, ...)\ +#define T_flags_true(flags, ...) \ { \ static const T_check_context T_check_instance = { \ - T_FILE_NAME, __LINE__, (flags) | T_CHECK_FMT }; \ - T_check(&T_check_instance, a, __VA_ARGS__); \ + T_FILE_NAME, __LINE__, \ + (flags) | T_VA_ARGS_KIND(__VA_ARGS__) };\ + T_check(&T_check_instance, \ + T_VA_ARGS_FIRST(__VA_ARGS__) T_VA_ARGS_MORE(__VA_ARGS__)); \ } -#define T_flags_eq(a, e, flags, ...) \ -T_flags_true((a) == (e), flags, __VA_ARGS__) +#define T_flags_eq(flags, a, ...) \ +T_flags_true(flags, \ +(a) == (T_VA_ARGS_FIRST(__VA_ARGS__)) T_VA_ARGS_MORE(__VA_ARGS__)) -#define T_flags_ne(a, e, flags, ...) \ -T_flags_true((a) != (e), flags, __VA_ARGS__) +#define T_flags_ne(flags, a, ...) \ +T_flags_true(flags, \ +(a) != (T_VA_ARGS_FIRST(__VA_ARGS__)) T_VA_ARGS_MORE(__VA_ARGS__)) void T_check_eq_ptr(const T_check_context_msg *, const void *, const void *); @@ -658,19 +683,28 @@ T_verbosity T_set_verbosity(T_verbosity); * @{ */ -#define T_true(a, ...) T_flags_true(a, 0, __VA_ARGS__) -#define T_assert_true(a, ...) T_flags_true(a, T_CHECK_STOP, __VA_ARGS__) -#define T_quiet_true(a, ...) T_flags_true(a, T_CHECK_QUIET, __VA_ARGS__) -#define T_step_true(s, a, ...) T_flags_true(a, T_CHECK_STEP(s), __VA_ARGS__) -#define T_step_assert_true(s, a, ...) \ -T_flags_true(a, T_CHECK_STEP(s) | T_CHECK_STOP, __VA_ARGS__) - -#define T_false(a, ...) T_flags_true(!(a), 0, __VA_ARGS__) -#define T_assert_false(a, ...) T_flags_true(!(a), T_CHECK_STOP, __VA_ARGS__) -#define T_quiet_false(a, ...) T_flags_true(!(a), T_CHECK_QUIET, __VA_ARGS__) -#define T_step_false(s, a, ...) T_flags_true(!(a), T_CHECK_STEP(s), __VA_ARGS__) -#define T_step_assert_false(s, a, ...) \ -T_flags_true(!(a), T_CHECK_STEP(s) | T_CHECK_STOP, __VA_ARGS__) +#define T_true(...) T_flags_true(0, __VA_ARGS__) +#define T_assert_true(...) T_flags_true(T_CHECK_STOP, __VA_ARGS__) +#define T_quiet_true(...) T_flags_true(T_CHECK_QUIET, __VA_ARGS__) +#define T_step_true(s, ...) T_flags_true(T_CHECK_STEP(s), __VA_ARGS__) +#define T_step_assert_true(s, ...) \ +T_flags_true(T_CHECK_STEP(s) | T_CHECK_STOP, __VA_ARGS__) + +#define T_false(...) \ +T_flags_true(0, \ +!(T_VA_ARGS_FIRST(__VA_ARGS__)) T_VA_ARGS_MORE(__VA_ARGS__)) +#define T_assert_false(...) \ +T_flags_true(T_CHECK_STOP, \ +!(T_VA_ARGS_FIRST(__VA_ARGS__)) T_VA_ARGS_MORE(__VA_ARGS__)) +#define T_quiet_false(...) \ +T_flags_true(T_CHECK_QUIET, \ +!(T_VA_ARGS_FIRST(__VA_ARGS__)) T_VA_ARGS_MORE(__VA_ARGS__)) +#define T_step_false(s, ...) \ +T_flags_true(T_CHECK_STEP(s), \ +!(T_VA_ARGS_FIRST(__VA_ARGS__)) T_VA_ARGS_MORE(__VA_ARGS__)) +#define T_step_assert_false(s, ...) \ +T_flags_true(T_CHECK_STEP(s) | T_CHECK_STOP, \ +!(T_VA_ARGS_FIRS
[PATCH 00/33] Test framework improvements
This patch set adds a couple of improvements to the test framework: * The header file changes from to . * Support for a stack of test fixtures. This helps to write test building blocks. * The test check messages are now optional. * The support for interrupt tests and change all the interrupt critical tests to use this new test support. This should address the sporadic failures and timeouts. For the documentation please have a look at: https://ftp.rtems.org/pub/rtems/people/sebh/eng2.pdf Sebastian Huber (33): libtest: to libtest: Move to libtest: Add T_busy() libtest: Add T_get_one_clock_tick_busy() libtest: Add T_make_runner() libtest: Support custom scope messages via fixture libtest: Add push/pop fixture support libtest: Add T_get_scope() libtest: Split POSIX Keys support libtest: Add T_stop() libtest: Add T_CHECK_FMT libtest: Make check message optional libtest: Add T_unreachable() libtest: Add quiet assert NULL pointer checks libtest: Add rtems_test_run() libtest: Add T_interrupt_test() psxintrcritical01: Use T_interrupt_test() spintrcritical01/2/3/4/5: Use T_interrupt_test() spintrcritical06/spintrcritical07: Remove tests spintrcritical08: Use T_interrupt_test() spintrcritical09: Use T_interrupt_test() spintrcritical10: Use T_interrupt_test() spintrcritical11/12: Use T_interrupt_test() spintrcritical13/14: Use T_interrupt_test() spintrcritical15: Use T_interrupt_test() spintrcritical16: Use T_interrupt_test() spintrcritical18: Use T_interrupt_test() spintrcritical20: Use T_interrupt_test() spintrcritical21: Use T_interrupt_test() spintrcritical22: Use T_interrupt_test() spintrcritical23: Use T_interrupt_test() spintrcritical24: Use T_interrupt_test() spintrcritical_support: Remove cpukit/Makefile.am|5 + cpukit/headers.am |3 +- cpukit/include/rtems/doxygen-appl-config.h| 3736 + cpukit/include/rtems/simple-test.h| 327 ++ cpukit/include/rtems/test.h | 2653 ++-- cpukit/include/t.h| 2379 --- cpukit/libtest/t-test-busy-tick.c | 121 + cpukit/libtest/t-test-busy.c | 58 + cpukit/libtest/t-test-checks-eno.c| 10 +- cpukit/libtest/t-test-checks-psx.c| 10 +- cpukit/libtest/t-test-checks.c| 194 +- cpukit/libtest/t-test-hash-sha256.c |2 +- cpukit/libtest/t-test-interrupt.c | 420 ++ cpukit/libtest/t-test-malloc.c|2 +- cpukit/libtest/t-test-rtems-context.c |8 +- cpukit/libtest/t-test-rtems-fds.c |5 +- cpukit/libtest/t-test-rtems-heap.c|6 +- cpukit/libtest/t-test-rtems-measure.c |2 +- cpukit/libtest/t-test-rtems-objs.c| 100 +- cpukit/libtest/t-test-rtems-posix-keys.c | 116 + cpukit/libtest/t-test-rtems.c | 10 +- cpukit/libtest/t-test-rtems.h | 62 + cpukit/libtest/t-test-time.c |2 +- cpukit/libtest/t-test.c | 279 +- cpukit/libtest/testbeginend.c |2 +- cpukit/libtest/testbusy.c | 89 +- cpukit/libtest/testextension.c|2 +- cpukit/libtest/testparallel.c |2 +- cpukit/libtest/testrun.c | 87 + cpukit/libtest/testwrappers.c |2 +- spec/build/cpukit/librtemstest.yml|1 + testsuites/ada/support/initimpl.h |2 +- testsuites/libtests/Makefile.am |9 + testsuites/libtests/block08/system.h |2 +- testsuites/libtests/block09/init.c|2 +- testsuites/libtests/block10/init.c|2 +- testsuites/libtests/capture01/system.h|2 +- testsuites/libtests/configure.ac |1 + testsuites/libtests/dl01/dl01-o1.c|2 +- testsuites/libtests/dl02/dl02-o1.c|2 +- testsuites/libtests/dl02/dl02-o2.c|2 +- testsuites/libtests/dl05/dl05-o5.cc |2 +- testsuites/libtests/dl06/dl06-o1.c|2 +- testsuites/libtests/dl06/dl06-o2.c|2 +- testsuites/libtests/dl07/dl07-o1.c|2 +- testsuites/libtests/dl07/dl07-o2.c|2 +- testsuites/libtests/dl07/dl07-o3.c|2 +- testsuites/libtests/dl07/dl07-o4.c|2 +- testsuites/libtests/dl07/dl07-o5.c|2 +- testsuites/libtests/dl08/dl08-o1.c|2 +- testsuites/libtests/dl08/dl08-o2.c|2 +- testsuites/libtests/dl08/dl08-o3.c|2 +- testsuites/libtests/dl08/dl08-o4.c|2 +- testsuites/libtests/dl08/dl08-o5.c|2 +- .../dl08/dl08-o6-123456789-123456789.c|2 +- testsuites/libtests/dl09/dl09-o1.c
[PATCH 14/33] libtest: Add quiet assert NULL pointer checks
Update #3199. --- cpukit/include/rtems/test.h | 4 1 file changed, 4 insertions(+) diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index 06c5772296..5d4c676d16 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -761,6 +761,8 @@ T_verbosity T_set_verbosity(T_verbosity); #define T_null(a) T_flags_null(a, 0, #a) #define T_assert_null(a) T_flags_null(a, T_CHECK_STOP, #a) #define T_quiet_null(a) T_flags_null(a, T_CHECK_QUIET, #a) +#define T_quiet_assert_null(a) \ +T_flags_null(a, T_CHECK_QUIET | T_CHECK_STOP, #a) #define T_step_null(s, a) T_flags_null(a, T_CHECK_STEP(s), #a) #define T_step_assert_null(s, a) \ T_flags_null(a, T_CHECK_STEP(s) | T_CHECK_STOP, #a) @@ -768,6 +770,8 @@ T_verbosity T_set_verbosity(T_verbosity); #define T_not_null(a) T_flags_not_null(a, 0, #a) #define T_assert_not_null(a) T_flags_not_null(a, T_CHECK_STOP, #a) #define T_quiet_not_null(a) T_flags_not_null(a, T_CHECK_QUIET, #a) +#define T_quiet_assert_not_null(a) \ +T_flags_not_null(a, T_CHECK_QUIET | T_CHECK_STOP, #a) #define T_step_not_null(s, a) T_flags_not_null(a, T_CHECK_STEP(s), #a) #define T_step_assert_not_null(s, a) \ T_flags_not_null(a, T_CHECK_STEP(s) | T_CHECK_STOP, #a) -- 2.26.2 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 05/33] libtest: Add T_make_runner()
Update #3199. --- cpukit/include/rtems/test.h | 2 ++ cpukit/libtest/t-test.c | 10 -- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index b68f303e16..a1a976d7ff 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -2209,6 +2209,8 @@ void T_putchar_default(int, void *); int T_main(const T_config *); +void T_make_runner(void); + bool T_is_runner(void); void T_run_initialize(const T_config *); diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c index 16018335c9..a0336fa461 100644 --- a/cpukit/libtest/t-test.c +++ b/cpukit/libtest/t-test.c @@ -330,7 +330,7 @@ T_scope(char *buf) } static void -T_set_runner(T_context *ctx) +T_do_make_runner(T_context *ctx) { #ifdef __rtems__ ISR_Level level; @@ -353,6 +353,12 @@ T_set_runner(T_context *ctx) #endif } +void +T_make_runner(void) +{ + T_do_make_runner(&T_instance); +} + int T_printf(char const *fmt, ...) { @@ -719,7 +725,7 @@ T_do_run_initialize(const T_config *config) ctx->overall_steps = 0; ctx->overall_failures = 0; - T_set_runner(ctx); + T_do_make_runner(ctx); T_actions_forward(config, T_EVENT_RUN_INITIALIZE_EARLY, config->name); T_do_log(ctx, T_QUIET, "A:%s\n", config->name); T_system(ctx); -- 2.26.2 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 06/33] libtest: Support custom scope messages via fixture
Update #3199. --- cpukit/include/rtems/test.h| 1 + cpukit/libtest/t-test.c| 32 -- testsuites/libtests/ttest01/init.c | 2 +- testsuites/libtests/ttest01/test-fixture.c | 24 ++-- 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index a1a976d7ff..2362e5b804 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -62,6 +62,7 @@ typedef struct T_fixture { void (*setup)(void *); void (*stop)(void *); void (*teardown)(void *); + void (*scope)(void *, char *, size_t); void *initial_context; } T_fixture; diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c index a0336fa461..aa04f09139 100644 --- a/cpukit/libtest/t-test.c +++ b/cpukit/libtest/t-test.c @@ -49,7 +49,7 @@ #define T_LINE_SIZE 128 -#define T_SCOPE_SIZE 5 +#define T_SCOPE_SIZE 64 typedef struct { pthread_spinlock_t lock; @@ -285,9 +285,10 @@ T_thread_name(const Thread_Control *th, char *buf) #endif static const char * -T_scope(char *buf) +T_scope(T_context *ctx, char *buf) { const char *r; + const T_case_context *tc; #if defined(__rtems__) ISR_Level level; @@ -326,6 +327,20 @@ T_scope(char *buf) r = buf; #endif + tc = ctx->current_case; + if (tc != NULL) { + const T_fixture *fixture; + + fixture = tc->fixture; + if (fixture != NULL && fixture->scope != NULL) { + size_t n; + + n = strlen(r); + (*fixture->scope)(ctx->fixture_context, buf + n, + T_SCOPE_SIZE - n); + } + } + return r; } @@ -522,7 +537,7 @@ T_check_true(bool ok, const T_check_context *t, const char *fmt, ...) step != T_CHECK_STEP_FROM_FLAGS(t->flags)) { T_add_failure(ctx); T_printf("F:%u:%i:%s:%s:%i:planned step (%u)\n", step, - T_cpu(), T_scope(scope), T_file(t), t->line, + T_cpu(), T_scope(ctx, scope), T_file(t), t->line, T_CHECK_STEP_FROM_FLAGS(t->flags)); } else if (!ok) { T_add_failure(ctx); @@ -530,11 +545,12 @@ T_check_true(bool ok, const T_check_context *t, const char *fmt, ...) if (ctx->verbosity >= T_NORMAL) { if ((t->flags & T_CHECK_QUIET) == 0) { T_printf("F:%u:%i:%s:%s:%i:", - step, T_cpu(), T_scope(scope), + step, T_cpu(), T_scope(ctx, scope), T_file(t), t->line); } else { T_printf("F:*:%i:%s:%s:%i:", T_cpu(), - T_scope(scope), T_file(t), t->line); + T_scope(ctx, scope), T_file(t), + t->line); } va_start(ap, fmt); @@ -550,12 +566,12 @@ T_check_true(bool ok, const T_check_context *t, const char *fmt, ...) } else if ((t->flags & T_CHECK_QUIET) == 0 && ctx->verbosity >= T_VERBOSE) { T_printf("P:%u:%i:%s:%s:%i\n", step, T_cpu(), - T_scope(scope), T_file(t), t->line); + T_scope(ctx, scope), T_file(t), t->line); } } else if (!ok) { T_add_failure(ctx); - T_printf("F:*:%i:%s:*:*:", T_cpu(), T_scope(scope)); + T_printf("F:*:%i:%s:*:*:", T_cpu(), T_scope(ctx, scope)); va_start(ap, fmt); T_vprintf(fmt, ap); @@ -802,7 +818,7 @@ T_do_case_end(T_context *ctx, const T_case_context *tc) T_printf("F:*:%i:%s:*:*:actual steps (%u), " "planned steps (%u)\n", T_cpu(), - T_scope(scope), steps, planned_steps); + T_scope(ctx, scope), steps, planned_steps); } } diff --git a/testsuites/libtests/ttest01/init.c b/testsuites/libtests/ttest01/init.c index a30211317e..1763a21616 100644 --- a/testsuites/libtests/ttest01/init.c +++ b/testsuites/libtests/ttest01/init.c @@ -183,7 +183,7 @@ run_initialize(void) } static const char expected_final[] = "Z:ttest01:C:342:N:1316:F:791:D:0.687999\n" -"Y:ReportHash:SHA256:d4c293b499e6e557afcf6123cb604e8976cc5b987021f1f8c9f6193fc38a386e\n"; +"Y:ReportHash:SHA256:efd7b69ac3ec0cac31fa147008bba87a077e6d53c0cfb8a836a4de2ae90ecc27\n"; static void run_finalize(void) diff --git a/testsuites/libtests/ttest01/
[PATCH 15/33] libtest: Add rtems_test_run()
Update #3199. --- cpukit/Makefile.am | 1 + cpukit/include/rtems/simple-test.h | 14 + cpukit/libtest/testrun.c | 87 ++ spec/build/cpukit/librtemstest.yml | 1 + 4 files changed, 103 insertions(+) create mode 100644 cpukit/libtest/testrun.c diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index ce25efe10b..89edaefb17 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -1855,6 +1855,7 @@ librtemstest_a_SOURCES += libtest/testbeginend.c librtemstest_a_SOURCES += libtest/testbusy.c librtemstest_a_SOURCES += libtest/testextension.c librtemstest_a_SOURCES += libtest/testparallel.c +librtemstest_a_SOURCES += libtest/testrun.c librtemstest_a_SOURCES += libtest/testwrappers.c librtemstest_a_SOURCES += libtest/t-test.c librtemstest_a_SOURCES += libtest/t-test-busy.c diff --git a/cpukit/include/rtems/simple-test.h b/cpukit/include/rtems/simple-test.h index 42f5235af8..d5580bdebb 100644 --- a/cpukit/include/rtems/simple-test.h +++ b/cpukit/include/rtems/simple-test.h @@ -304,6 +304,20 @@ void rtems_test_parallel( */ void rtems_test_busy_cpu_usage(time_t seconds, long nanoseconds); +/** + * @brief Runs the test cases of the RTEMS Test Framework using a default + * configuration in the context of a task. + * + * The application must provide rtems_test_name. + * + * @param arg is the task argument. + * @param state is the test state. + */ +RTEMS_NO_RETURN void rtems_test_run( + rtems_task_argumentarg, + const RTEMS_TEST_STATE state +); + /** @} */ #ifdef __cplusplus diff --git a/cpukit/libtest/testrun.c b/cpukit/libtest/testrun.c new file mode 100644 index 00..5f5c3ebe66 --- /dev/null +++ b/cpukit/libtest/testrun.c @@ -0,0 +1,87 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSAPI + * + * @brief Implementation of rtems_test_run_default(). + */ + +/* + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +static char buffer[ 512 ]; + +static const T_action actions[] = { + T_report_hash_sha256, + T_check_task_context, + T_check_file_descriptors, + T_check_rtems_barriers, + T_check_rtems_extensions, + T_check_rtems_message_queues, + T_check_rtems_partitions, + T_check_rtems_periods, + T_check_rtems_regions, + T_check_rtems_semaphores, + T_check_rtems_tasks, + T_check_rtems_timers, + T_check_posix_keys +}; + +static const T_config config = { + .name = rtems_test_name, + .buf = buffer, + .buf_size = sizeof( buffer ), + .putchar = T_putchar_default, + .verbosity = T_VERBOSE, + .now = T_now_clock, + .action_count = T_ARRAY_SIZE( actions ), + .actions = actions +}; + +void rtems_test_run( + rtems_task_argumentarg, + const RTEMS_TEST_STATE state +) +{ + (void) arg; + + rtems_test_begin( rtems_test_name, state ); + T_register(); + + if ( T_main( &config ) == 0 ) { +rtems_test_end( rtems_test_name ); + } + + rtems_test_exit( 0 ); +} diff --git a/spec/build/cpukit/librtemstest.yml b/spec/build/cpukit/librtemstest.yml index f6c6fb53e6..227baf1960 100644 --- a/spec/build/cpukit/librtemstest.yml +++ b/spec/build/cpukit/librtemstest.yml @@ -15,6 +15,7 @@ source: - cpukit/libtest/testbusy.c - cpukit/libtest/testextension.c - cpukit/libtest/testparallel.c +- cpukit/libtest/testrundefault.c - cpukit/libtest/testwrappers.c - cpukit/libtest/t-test.c - cpukit/libtest/t-test-checks.c -- 2.26.2 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 21/33] spintrcritical09: Use T_interrupt_test()
--- testsuites/sptests/Makefile.am| 4 +- testsuites/sptests/spintrcritical09/init.c| 121 +++--- .../spintrcritical09/spintrcritical09.scn | 28 +++- 3 files changed, 103 insertions(+), 50 deletions(-) diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 4e3a3f0009..9f66b66371 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1250,9 +1250,7 @@ if TEST_spintrcritical09 sp_tests += spintrcritical09 sp_screens += spintrcritical09/spintrcritical09.scn sp_docs += spintrcritical09/spintrcritical09.doc -spintrcritical09_SOURCES = spintrcritical09/init.c \ - spintrcritical_support/intrcritical.c \ - spintrcritical_support/intrcritical.h +spintrcritical09_SOURCES = spintrcritical09/init.c spintrcritical09_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical09) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support diff --git a/testsuites/sptests/spintrcritical09/init.c b/testsuites/sptests/spintrcritical09/init.c index 63cfa2b5fb..890d90b4a8 100644 --- a/testsuites/sptests/spintrcritical09/init.c +++ b/testsuites/sptests/spintrcritical09/init.c @@ -1,4 +1,6 @@ /* + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * * COPYRIGHT (c) 1989-2012. * On-Line Applications Research Corporation (OAR). * @@ -11,8 +13,8 @@ #include "config.h" #endif -#include -#include +#include +#include #include #include @@ -20,82 +22,117 @@ const char rtems_test_name[] = "SPINTRCRITICAL 9"; -static Thread_Control *thread; - -static rtems_id Semaphore; +typedef struct { + Thread_Control *thread; + rtems_idsemaphore; + volatile bool early; +} test_context; -static bool case_hit; - -static bool is_interrupt_timeout(void) +static bool is_interrupt_timeout( test_context *ctx ) { - Thread_Wait_flags flags = _Thread_Wait_flags_get( thread ); + Thread_Wait_flags flags = _Thread_Wait_flags_get( ctx->thread ); return flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_READY_AGAIN ); } -static rtems_timer_service_routine test_release_from_isr( - rtems_id timer, - void *arg -) +static T_interrupt_test_state interrupt( void *arg ) { - Per_CPU_Control *cpu_self = _Per_CPU_Get(); - Watchdog_Header *header = &cpu_self->Watchdog.Header[ PER_CPU_WATCHDOG_TICKS ]; - Watchdog_Control *watchdog = (Watchdog_Control *) header->first; + test_context *ctx; + Per_CPU_Control*cpu_self; + Watchdog_Header*header; + Watchdog_Control *watchdog; + T_interrupt_test_state state; + + ctx = arg; + cpu_self = _Per_CPU_Get(); + header = &cpu_self->Watchdog.Header[ PER_CPU_WATCHDOG_TICKS ]; + watchdog = (Watchdog_Control *) header->first; if ( watchdog != NULL && watchdog->expire == cpu_self->Watchdog.ticks && watchdog->routine == _Thread_Timeout ) { +ISR_Level level; + +_ISR_Local_disable( level ); _Watchdog_Per_CPU_remove( watchdog, cpu_self, header ); +_ISR_Local_enable( level ); -(*watchdog->routine)( watchdog ); +( *watchdog->routine )( watchdog ); -if ( is_interrupt_timeout() ) { - case_hit = true; +if ( is_interrupt_timeout( ctx ) ) { + state = T_INTERRUPT_TEST_DONE; +} else { + state = T_INTERRUPT_TEST_LATE; +} + } else { +if ( ctx->early ) { + state = T_INTERRUPT_TEST_EARLY; +} else { + state = T_INTERRUPT_TEST_LATE; } } + + return state; } -static bool test_body( void *arg ) +static void prepare( void *arg ) { - (void) arg; + test_context *ctx; + rtems_status_code sc; - rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 ); - - return case_hit; + ctx = arg; + ctx->early = true; + sc = rtems_semaphore_obtain( ctx->semaphore, RTEMS_NO_WAIT, 0 ); + T_quiet_true( sc == RTEMS_SUCCESSFUL || sc == RTEMS_UNSATISFIED ); } -static rtems_task Init( - rtems_task_argument ignored -) +static void action( void *arg ) { - rtems_status_code sc; + test_context *ctx; + rtems_status_code sc; + + ctx = arg; + ctx->early = false; + sc = rtems_semaphore_obtain( ctx->semaphore, RTEMS_DEFAULT_OPTIONS, 1 ); + T_quiet_rsc( sc, RTEMS_TIMEOUT ); +} - TEST_BEGIN(); +static const T_interrupt_test_config config = { + .prepare = prepare, + .action = action, + .interrupt = interrupt, + .max_iteration_count = 1 +}; - thread = _Thread_Get_executing(); +T_TEST_CASE( SemaphoreObtainInterrupt ) +{ + test_context ctx; + rtems_status_code sc; + T_interrupt_test_state state; + + ctx.thread = _Thread_Get_executing(); - puts( "Init - Test may not be able to detect case is hit reliably" ); - puts( "Init - Trying to generate timeout from ISR while blocking" ); sc = rtems_semaphore_create( rtems_build_name( 'S', 'M', '1', ' ' ), 0, RTEMS_DEFAULT_ATTRIBUTES, RTEMS_NO_PRIORITY, -&Semaphore +&ctx.semaphor
[PATCH 13/33] libtest: Add T_unreachable()
Update #3199. --- cpukit/include/rtems/test.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index d14bb9fe2d..06c5772296 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -2294,6 +2294,9 @@ void T_pop_fixture(void); T_NO_RETURN void T_stop(void); +#define T_unreachable() \ +do { T_true(false, "Unreachable"); T_stop(); } while (0) + /** * @brief Gets the scope for nested fixtures. * -- 2.26.2 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 07/33] libtest: Add push/pop fixture support
Update #3199. --- cpukit/include/rtems/test.h| 11 +++ cpukit/libtest/t-test.c| 110 + testsuites/libtests/ttest01/init.c | 4 +- testsuites/libtests/ttest01/test-fixture.c | 105 ++-- 4 files changed, 200 insertions(+), 30 deletions(-) diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index 2362e5b804..04f92dd1f4 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -66,6 +66,13 @@ typedef struct T_fixture { void *initial_context; } T_fixture; +typedef struct T_fixture_node { + struct T_fixture_node *next; + struct T_fixture_node *previous; + const T_fixture *fixture; + void *context; +} T_fixture_node; + #define T_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) /* @@ -2232,6 +2239,10 @@ void *T_fixture_context(void); void T_set_fixture_context(void *); +void *T_push_fixture(T_fixture_node *, const T_fixture *); + +void T_pop_fixture(void); + #ifdef __rtems__ #define T_TEST_CASE_FIXTURE(name, fixture) \ void T_case_body_##name(void); \ diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c index aa04f09139..bf9b68cdf2 100644 --- a/cpukit/libtest/t-test.c +++ b/cpukit/libtest/t-test.c @@ -1,7 +1,7 @@ /* * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (C) 2018, 2019 embedded brains GmbH + * Copyright (C) 2018, 2020 embedded brains GmbH * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -62,7 +62,8 @@ typedef struct { T_verbosity verbosity; const T_case_context *registered_cases; const T_case_context *current_case; - void *fixture_context; + T_fixture_node *fixtures; + T_fixture_node case_fixture; LIST_HEAD(, T_destructor) destructors; T_time case_begin_time; atomic_uint planned_steps; @@ -288,7 +289,7 @@ static const char * T_scope(T_context *ctx, char *buf) { const char *r; - const T_case_context *tc; + T_fixture_node *node; #if defined(__rtems__) ISR_Level level; @@ -327,19 +328,23 @@ T_scope(T_context *ctx, char *buf) r = buf; #endif - tc = ctx->current_case; - if (tc != NULL) { + node = &ctx->case_fixture; + + do { const T_fixture *fixture; - fixture = tc->fixture; + fixture = node->fixture; + if (fixture != NULL && fixture->scope != NULL) { size_t n; n = strlen(r); - (*fixture->scope)(ctx->fixture_context, buf + n, + (*fixture->scope)(node->context, buf + n, T_SCOPE_SIZE - n); } - } + + node = node->previous; + } while (node != NULL); return r; } @@ -421,18 +426,20 @@ T_add_failure(T_context *ctx) static void T_stop(T_context *ctx) { - const T_case_context *tc; + T_fixture_node *node; - tc = ctx->current_case; + node = ctx->fixtures; - if (tc != NULL) { + while (node != NULL) { const T_fixture *fixture; - fixture = tc->fixture; + fixture = node->fixture; if (fixture != NULL && fixture->stop != NULL) { - (*fixture->stop)(ctx->fixture_context); + (*fixture->stop)(node->context); } + + node = node->next; } longjmp(ctx->case_begin_context, 1); @@ -478,13 +485,13 @@ T_set_verbosity(T_verbosity verbosity) void * T_fixture_context(void) { - return T_instance.fixture_context; + return T_instance.fixtures->context; } void T_set_fixture_context(void *context) { - T_instance.fixture_context = context; + T_instance.fixtures->context = context; } const char * @@ -730,6 +737,7 @@ T_do_run_initialize(const T_config *config) ctx->buf_mask = 0; } + ctx->fixtures = &ctx->case_fixture; atomic_store_explicit(&ctx->buf_head, 0, memory_order_relaxed); ctx->buf_tail = 0; ctx->putchar = config->putchar; @@ -761,6 +769,7 @@ T_do_case_begin(T_context *ctx, const T_case_context *tc) fixture = tc->fixture; ctx->verbosity = config->verbosity; ctx->current_case = tc; + ctx->fixtures = &ctx->case_fixture; LIST_INIT(&ctx->destructors); atomic_store_explicit(&ctx->planned_steps, UINT_MAX, memory_order_relaxed); @@ -773,10 +782,11 @@ T_do_case_begin(T_context *ctx, const T_case_context *tc) T_actions_forward(config, T_EVENT_CASE_BEGIN, tc->name); if (fixture != NULL) { - ctx->fixture_context = fixture->initial_context; + ctx->case_fixt
[PATCH 20/33] spintrcritical08: Use T_interrupt_test()
--- testsuites/sptests/Makefile.am| 4 +- testsuites/sptests/spintrcritical08/init.c| 165 +++--- .../spintrcritical08/spintrcritical08.scn | 30 +++- 3 files changed, 131 insertions(+), 68 deletions(-) diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index bbfabbaa36..4e3a3f0009 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1240,9 +1240,7 @@ if TEST_spintrcritical08 sp_tests += spintrcritical08 sp_screens += spintrcritical08/spintrcritical08.scn sp_docs += spintrcritical08/spintrcritical08.doc -spintrcritical08_SOURCES = spintrcritical08/init.c \ - spintrcritical_support/intrcritical.c \ - spintrcritical_support/intrcritical.h +spintrcritical08_SOURCES = spintrcritical08/init.c spintrcritical08_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical08) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support diff --git a/testsuites/sptests/spintrcritical08/init.c b/testsuites/sptests/spintrcritical08/init.c index aab5701ed4..1191ca6f9c 100644 --- a/testsuites/sptests/spintrcritical08/init.c +++ b/testsuites/sptests/spintrcritical08/init.c @@ -1,4 +1,6 @@ /* + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * * COPYRIGHT (c) 1989-2012. * On-Line Applications Research Corporation (OAR). * @@ -11,111 +13,158 @@ #include "config.h" #endif -#include -#include +#include + +#include +#include + #include #include const char rtems_test_name[] = "SPINTRCRITICAL 8"; -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument argument); - -static rtems_id Period; - -static volatile bool case_hit = false; - -static Thread_Control *thread; +typedef struct { + rtems_idperiod; + Thread_Control *thread; + volatile bool early; + volatile bool late; +} test_context; -static rtems_rate_monotonic_period_states getState(void) +static rtems_rate_monotonic_period_states getState(test_context *ctx) { Rate_monotonic_Control *the_period; ISR_lock_Contextlock_context; - the_period = _Rate_monotonic_Get( Period, &lock_context ); - rtems_test_assert( the_period != NULL ); + the_period = _Rate_monotonic_Get( ctx->period, &lock_context ); + T_quiet_assert_not_null( the_period ); _ISR_lock_ISR_enable( &lock_context ); return the_period->state; } -static rtems_timer_service_routine test_release_from_isr( - rtems_id timer, - void *arg -) +static T_interrupt_test_state interrupt( void *arg ) { - Per_CPU_Control *cpu = _Per_CPU_Get(); - Watchdog_Header *header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_TICKS ]; - Watchdog_Control *watchdog = (Watchdog_Control *) header->first; + test_context *ctx; + Per_CPU_Control*cpu_self; + Watchdog_Header*header; + Watchdog_Control *watchdog; + T_interrupt_test_state state; + + state = T_interrupt_test_get_state(); + + if (state != T_INTERRUPT_TEST_ACTION) { +return T_INTERRUPT_TEST_CONTINUE; + } + + ctx = arg; + cpu_self = _Per_CPU_Get(); + header = &cpu_self->Watchdog.Header[ PER_CPU_WATCHDOG_TICKS ]; + watchdog = (Watchdog_Control *) header->first; if ( watchdog != NULL - && watchdog->expire == cpu->Watchdog.ticks + && watchdog->expire == cpu_self->Watchdog.ticks && watchdog->routine == _Rate_monotonic_Timeout ) { -Thread_Wait_flags flags = _Thread_Wait_flags_get( thread ); +Thread_Wait_flags flags = _Thread_Wait_flags_get( ctx->thread ); +ISR_Level level; -_Watchdog_Per_CPU_remove_ticks( watchdog ); +_ISR_Local_disable( level ); +_Watchdog_Per_CPU_remove( watchdog, cpu_self, header ); +_ISR_Local_enable( level ); -rtems_test_assert( getState() == RATE_MONOTONIC_ACTIVE ); +T_quiet_eq_int( getState( ctx ), RATE_MONOTONIC_ACTIVE ); (*watchdog->routine)( watchdog ); if ( flags == RATE_MONOTONIC_INTEND_TO_BLOCK ) { - rtems_test_assert( -_Thread_Wait_flags_get( thread ) == RATE_MONOTONIC_READY_AGAIN + T_quiet_eq( +_Thread_Wait_flags_get( ctx->thread ), +RATE_MONOTONIC_READY_AGAIN ); - rtems_test_assert( getState() == RATE_MONOTONIC_ACTIVE ); - case_hit = true; + T_quiet_eq_int( getState( ctx ), RATE_MONOTONIC_ACTIVE ); + state = T_INTERRUPT_TEST_DONE; +} else { + state = T_INTERRUPT_TEST_LATE; +} + } else { +if ( ctx->early ) { + state = T_INTERRUPT_TEST_EARLY; +} else if ( ctx->late ) { + state = T_INTERRUPT_TEST_LATE; +} else { + state = T_INTERRUPT_TEST_CONTINUE; } } + + return state; } -static bool test_body( void *arg ) +static void prepare( void *arg ) { + test_context *ctx; rtems_status_code sc; - (void) arg; + ctx = arg; + ctx->early = true; + ctx->late = false; - sc = rtems_rate_monotonic_cancel( Period ); - rtems_test_assert( sc == RTEMS_SUCCESSFUL ); + sc = r
[PATCH 19/33] spintrcritical06/spintrcritical07: Remove tests
These two tests check conditions which no longer exist in the thread queue implementation. The are obsolete since the change to use red-black trees for the priority queues. --- testsuites/sptests/Makefile.am| 23 --- testsuites/sptests/configure.ac | 2 - testsuites/sptests/spintrcritical06/init.c| 2 - .../spintrcritical06/spintrcritical06.doc | 28 .../spintrcritical06/spintrcritical06.scn | 6 - .../spintrcritical06/spintrcritical06impl.h | 145 -- testsuites/sptests/spintrcritical07/init.c| 2 - .../spintrcritical07/spintrcritical07.doc | 28 .../spintrcritical07/spintrcritical07.scn | 6 - 9 files changed, 242 deletions(-) delete mode 100644 testsuites/sptests/spintrcritical06/init.c delete mode 100644 testsuites/sptests/spintrcritical06/spintrcritical06.doc delete mode 100644 testsuites/sptests/spintrcritical06/spintrcritical06.scn delete mode 100644 testsuites/sptests/spintrcritical06/spintrcritical06impl.h delete mode 100644 testsuites/sptests/spintrcritical07/init.c delete mode 100644 testsuites/sptests/spintrcritical07/spintrcritical07.doc delete mode 100644 testsuites/sptests/spintrcritical07/spintrcritical07.scn diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 3bdb0fe232..bbfabbaa36 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1236,29 +1236,6 @@ spintrcritical05_CPPFLAGS = $(AM_CPPFLAGS) \ -I$(top_srcdir)/spintrcritical_support endif -if TEST_spintrcritical06 -sp_tests += spintrcritical06 -sp_screens += spintrcritical06/spintrcritical06.scn -sp_docs += spintrcritical06/spintrcritical06.doc -spintrcritical06_SOURCES = spintrcritical06/init.c \ - spintrcritical_support/intrcritical.c \ - spintrcritical_support/intrcritical.h -spintrcritical06_CPPFLAGS = $(AM_CPPFLAGS) \ - $(TEST_FLAGS_spintrcritical06) $(support_includes) \ - -I$(top_srcdir)/spintrcritical_support -endif - -if TEST_spintrcritical07 -sp_tests += spintrcritical07 -sp_screens += spintrcritical07/spintrcritical07.scn -sp_docs += spintrcritical07/spintrcritical07.doc -spintrcritical07_SOURCES = spintrcritical07/init.c \ - spintrcritical_support/intrcritical.c -spintrcritical07_CPPFLAGS = $(AM_CPPFLAGS) \ - $(TEST_FLAGS_spintrcritical07) $(support_includes) \ - -I$(top_srcdir)/spintrcritical_support -endif - if TEST_spintrcritical08 sp_tests += spintrcritical08 sp_screens += spintrcritical08/spintrcritical08.scn diff --git a/testsuites/sptests/configure.ac b/testsuites/sptests/configure.ac index 9476e3b0d7..460917dd04 100644 --- a/testsuites/sptests/configure.ac +++ b/testsuites/sptests/configure.ac @@ -174,8 +174,6 @@ RTEMS_TEST_CHECK([spintrcritical02]) RTEMS_TEST_CHECK([spintrcritical03]) RTEMS_TEST_CHECK([spintrcritical04]) RTEMS_TEST_CHECK([spintrcritical05]) -RTEMS_TEST_CHECK([spintrcritical06]) -RTEMS_TEST_CHECK([spintrcritical07]) RTEMS_TEST_CHECK([spintrcritical08]) RTEMS_TEST_CHECK([spintrcritical09]) RTEMS_TEST_CHECK([spintrcritical10]) diff --git a/testsuites/sptests/spintrcritical06/init.c b/testsuites/sptests/spintrcritical06/init.c deleted file mode 100644 index d8fedae772..00 --- a/testsuites/sptests/spintrcritical06/init.c +++ /dev/null @@ -1,2 +0,0 @@ -#define PRIORITY_NO_TIMEOUT_FORWARD -#include "spintrcritical06impl.h" diff --git a/testsuites/sptests/spintrcritical06/spintrcritical06.doc b/testsuites/sptests/spintrcritical06/spintrcritical06.doc deleted file mode 100644 index 6100a91218..00 --- a/testsuites/sptests/spintrcritical06/spintrcritical06.doc +++ /dev/null @@ -1,28 +0,0 @@ -# COPYRIGHT (c) 1989-2009. -# On-Line Applications Research Corporation (OAR). -# -# The license and distribution terms for this file may be -# found in the file LICENSE in this distribution or at -# http://www.rtems.org/license/LICENSE. -# - -This file describes the directives and concepts tested by this test set. - -test set name: spintrcritical06 - -directives: - - _Thread_queue_Enqueue_priority -- interrupt synchronization - rtems_task_restart - _Thread_queue_Extract_priority - -concepts: - -+ Ensure that removing the "search task" from the thread queue while we - are looping and enqueuing another works as expected. This case is where - the TCB we are using as a current pointer is removed from the thread queue - when we flash interrupts WHILE SEARCHING FORWARD. - -NOTE: There is no way to know this case is hit from a test perspective. The - test just runs and we check the coverage report. diff --git a/testsuites/sptests/spintrcritical06/spintrcritical06.scn b/testsuites/sptests/spintrcritical06/spintrcritical06.scn deleted file mode 100644 index fdcf91c4f1..00 --- a/testsuites/sptests/spintrcritical06/spintrcritical06.scn +++ /dev/null @@ -1,6 +0,0 @@ -*** TEST INTERRUPT CRITICAL SECTION 06 *** -Init - Trying to generate semaphore release from IS
[PATCH 33/33] spintrcritical_support: Remove
This test support was replaced by T_interrupt_test() is no longer used. --- .../spintrcritical_support/intrcritical.c | 172 -- .../spintrcritical_support/intrcritical.h | 52 -- 2 files changed, 224 deletions(-) delete mode 100644 testsuites/sptests/spintrcritical_support/intrcritical.c delete mode 100644 testsuites/sptests/spintrcritical_support/intrcritical.h diff --git a/testsuites/sptests/spintrcritical_support/intrcritical.c b/testsuites/sptests/spintrcritical_support/intrcritical.c deleted file mode 100644 index b6c6dad169..00 --- a/testsuites/sptests/spintrcritical_support/intrcritical.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * COPYRIGHT (c) 1989-2009. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#define INTERRUPT_CRITICAL_NAME rtems_build_name( 'I', 'C', 'R', 'I' ) - -typedef struct { - uint_fast32_t minimum; - uint_fast32_t maximum; - uint_fast32_t maximum_current; - rtems_timer_service_routine_entry tsr; - rtems_id timer; - uint64_t t0; - uint64_t t1; -} interrupt_critical_control; - -static interrupt_critical_control interrupt_critical; - -static void wait_for_tick_change( void ) -{ - rtems_interval initial = rtems_clock_get_ticks_since_boot(); - rtems_interval now; - - do { -now = rtems_clock_get_ticks_since_boot(); - } while ( now == initial ); -} - -static bool interrupt_critical_busy_wait( void ) -{ - uint_fast32_t max = interrupt_critical.maximum_current; - bool reset = max <= interrupt_critical.minimum; - - if ( reset ) { -interrupt_critical.maximum_current = interrupt_critical.maximum; - } else { -interrupt_critical.maximum_current = max - 1; - } - - T_busy( max ); - - return reset; -} - -void interrupt_critical_section_test_support_initialize( - rtems_timer_service_routine_entry tsr -) -{ - uint_fast32_t m; - - interrupt_critical.tsr = tsr; - - if ( tsr != NULL && interrupt_critical.timer == 0 ) { -rtems_status_code sc = rtems_timer_create( - INTERRUPT_CRITICAL_NAME, - &interrupt_critical.timer -); -rtems_test_assert( sc == RTEMS_SUCCESSFUL ); - } - - m = T_get_one_clock_tick_busy(); - - interrupt_critical.minimum = 0; - interrupt_critical.maximum = m; - interrupt_critical.maximum_current = m; -} - -static void timer_fire_after(void) -{ - if ( interrupt_critical.tsr != NULL ) { -rtems_status_code sc = rtems_timer_fire_after( - interrupt_critical.timer, - 1, - interrupt_critical.tsr, - NULL -); -rtems_test_assert( sc == RTEMS_SUCCESSFUL ); - } -} - -bool interrupt_critical_section_test_support_delay(void) -{ - timer_fire_after(); - - return interrupt_critical_busy_wait(); -} - -static void thread_switch( Thread_Control *executing, Thread_Control *heir ) -{ - (void) executing; - (void) heir; - - if ( interrupt_critical.t1 == 0 && heir->is_idle ) { -interrupt_critical.t1 = rtems_clock_get_uptime_nanoseconds(); - } -} - -static const rtems_extensions_table extensions = { - .thread_switch = thread_switch -}; - -bool interrupt_critical_section_test( - bool ( *test_body )( void * ), - void*test_body_arg, - rtems_timer_service_routine_entrytsr -) -{ - bool done; - rtems_status_code sc; - rtems_id id; - uint64_t delta; - uint_fast32_t busy_delta; - int retries = 3; - - interrupt_critical_section_test_support_initialize( tsr ); - - sc = rtems_extension_create( -INTERRUPT_CRITICAL_NAME, -&extensions, -&id - ); - rtems_test_assert( sc == RTEMS_SUCCESSFUL ); - - wait_for_tick_change(); - timer_fire_after(); - - /* Get estimate for test body duration */ - interrupt_critical.t0 = rtems_clock_get_uptime_nanoseconds(); - done = ( *test_body )( test_body_arg ); - if ( interrupt_critical.t1 == 0 ) { -interrupt_critical.t1 = rtems_clock_get_uptime_nanoseconds(); - } - - /* Update minimum */ - - delta = interrupt_critical.t1 - interrupt_critical.t0; - busy_delta = (uint_fast32_t) -( ( interrupt_critical.maximum * ( 2 * delta ) ) - / rtems_configuration_get_nanoseconds_per_tick() ); - - if ( busy_delta < interrupt_critical.maximum ) { -interrupt_critical.minimum = interrupt_critical.maximum - busy_delta; - } - - sc = rtems_extension_delete( id ); - rtems_test_assert( sc == RTEMS_SUCCESSFUL ); - - while ( !done && retries >= 0 ) { -wait_for_tick_change(); - -if ( interrupt_critical_section_test_support_delay() ) { - --retries; -} - -done = ( *test_body )( test_body_arg ); - } - - return done; -} diff --git a/testsuites/sptests/spintrcritical_support/intrcritical.h b/testsuites/sptests/spintrcritical_support/intrcritical.h deleted file mode 100644 index ac
[PATCH 18/33] spintrcritical01/2/3/4/5: Use T_interrupt_test()
--- testsuites/sptests/Makefile.am| 16 +-- .../spintrcritical01/spintrcritical01.scn | 30 - .../spintrcritical01/spintrcritical01impl.h | 121 ++ .../spintrcritical02/spintrcritical02.scn | 30 - .../spintrcritical03/spintrcritical03.scn | 30 - .../spintrcritical04/spintrcritical04.scn | 30 - .../spintrcritical05/spintrcritical05.scn | 30 - 7 files changed, 191 insertions(+), 96 deletions(-) diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 62bb1aa685..3bdb0fe232 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1190,9 +1190,7 @@ if TEST_spintrcritical01 sp_tests += spintrcritical01 sp_screens += spintrcritical01/spintrcritical01.scn sp_docs += spintrcritical01/spintrcritical01.doc -spintrcritical01_SOURCES = spintrcritical01/init.c \ - spintrcritical_support/intrcritical.c \ - spintrcritical_support/intrcritical.h +spintrcritical01_SOURCES = spintrcritical01/init.c spintrcritical01_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical01) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support @@ -1202,8 +1200,7 @@ if TEST_spintrcritical02 sp_tests += spintrcritical02 sp_screens += spintrcritical02/spintrcritical02.scn sp_docs += spintrcritical02/spintrcritical02.doc -spintrcritical02_SOURCES = spintrcritical02/init.c \ - spintrcritical_support/intrcritical.c +spintrcritical02_SOURCES = spintrcritical02/init.c spintrcritical02_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical02) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support @@ -1213,8 +1210,7 @@ if TEST_spintrcritical03 sp_tests += spintrcritical03 sp_screens += spintrcritical03/spintrcritical03.scn sp_docs += spintrcritical03/spintrcritical03.doc -spintrcritical03_SOURCES = spintrcritical03/init.c \ - spintrcritical_support/intrcritical.c +spintrcritical03_SOURCES = spintrcritical03/init.c spintrcritical03_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical03) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support @@ -1224,8 +1220,7 @@ if TEST_spintrcritical04 sp_tests += spintrcritical04 sp_screens += spintrcritical04/spintrcritical04.scn sp_docs += spintrcritical04/spintrcritical04.doc -spintrcritical04_SOURCES = spintrcritical04/init.c \ - spintrcritical_support/intrcritical.c +spintrcritical04_SOURCES = spintrcritical04/init.c spintrcritical04_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical04) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support @@ -1235,8 +1230,7 @@ if TEST_spintrcritical05 sp_tests += spintrcritical05 sp_screens += spintrcritical05/spintrcritical05.scn sp_docs += spintrcritical05/spintrcritical05.doc -spintrcritical05_SOURCES = spintrcritical05/init.c \ - spintrcritical_support/intrcritical.c +spintrcritical05_SOURCES = spintrcritical05/init.c spintrcritical05_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical05) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support diff --git a/testsuites/sptests/spintrcritical01/spintrcritical01.scn b/testsuites/sptests/spintrcritical01/spintrcritical01.scn index cb51f99ae7..417c078724 100644 --- a/testsuites/sptests/spintrcritical01/spintrcritical01.scn +++ b/testsuites/sptests/spintrcritical01/spintrcritical01.scn @@ -1,6 +1,24 @@ -*** TEST INTERRUPT CRITICAL SECTION 01 *** -Init - Trying to generate semaphore release from ISR while blocking -Init - Variation is: FIFO/Without Timeout -Support - rtems_timer_create - creating timer 1 -Init - Case hit -*** END OF TEST INTERRUPT CRITICAL SECTION 01 *** +*** BEGIN OF TEST SPINTRCRITICAL 1 *** +*** TEST VERSION: 6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d +*** TEST STATE: EXPECTED_PASS +*** TEST BUILD: RTEMS_DEBUG RTEMS_POSIX_API RTEMS_SMP +*** TEST TOOLS: 10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4) +A:SPINTRCRITICAL 1 +S:Platform:RTEMS +S:Compiler:10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4) +S:Version:6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d +S:BSP:realview_pbx_a9_qemu +S:RTEMS_DEBUG:1 +S:RTEMS_MULTIPROCESSING:0 +S:RTEMS_POSIX_API:1 +S:RTEMS_PROFILING:0 +S:RTEMS_SMP:1 +B:SemaphoreReleaseFIFOWithoutTimeout +P:0:0:UI1:spintrcritical01impl.h:133 +P:1:0:UI1:spintrcritical01impl.h:136 +P:2:0:UI1:spintrcritical01impl.h:139 +E:SemaphoreReleaseFIFOWithoutTimeout:N:3:F:0:D:0.991790 +Z:SPINTRCRITICAL 1:C:1:N:3:F:0:D:0.992984 +Y:ReportHash:SHA256:5ae7281f5dd710e1c043bbff2fa3ddff47dc22aa5c35cff545601c8156ec1a87 + +*** END OF TEST SPINTRCRITICAL 1 *** diff --git a/testsuites/sptests/spintrcritical01/spintrcritical01impl.h b/testsuites/sptests/spintrcritical01/spintrcritical01impl.h index 5c480b4bb3..3f66143b74 100644 --- a/testsuites/sptests/spintrcritical01/spintrcritical01impl.h +++ b/testsuites/sptests/spintrcr
[PATCH 27/33] spintrcritical18: Use T_interrupt_test()
--- testsuites/sptests/Makefile.am| 4 +- testsuites/sptests/spintrcritical18/init.c| 146 -- .../spintrcritical18/spintrcritical18.scn | 30 +++- 3 files changed, 131 insertions(+), 49 deletions(-) diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 136a8378b5..5df21b89af 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1330,9 +1330,7 @@ if TEST_spintrcritical18 sp_tests += spintrcritical18 sp_screens += spintrcritical18/spintrcritical18.scn sp_docs += spintrcritical18/spintrcritical18.doc -spintrcritical18_SOURCES = spintrcritical18/init.c \ - spintrcritical_support/intrcritical.h \ - spintrcritical_support/intrcritical.c +spintrcritical18_SOURCES = spintrcritical18/init.c spintrcritical18_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical18) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support diff --git a/testsuites/sptests/spintrcritical18/init.c b/testsuites/sptests/spintrcritical18/init.c index 000f081f60..1ac9483c86 100644 --- a/testsuites/sptests/spintrcritical18/init.c +++ b/testsuites/sptests/spintrcritical18/init.c @@ -1,11 +1,5 @@ /* - * Copyright (c) 2012 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * + * Copyright (C) 2012, 2020 embedded brains GmbH (http://www.embedded-brains.de) * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -16,8 +10,8 @@ #include "config.h" #endif -#include -#include +#include +#include const char rtems_test_name[] = "SPINTRCRITICAL 18"; @@ -29,22 +23,22 @@ const char rtems_test_name[] = "SPINTRCRITICAL 18"; #define PRIORITY_HIGH 1 -#define ASSERT_SC(sc) rtems_test_assert( (sc) == RTEMS_SUCCESSFUL ) - typedef struct { rtems_id middle_priority_task; rtems_id high_priority_task; bool high_priority_task_activated; + volatile bool early; + volatile bool switching; + volatile bool late; + long potential_hits; } test_context; -static test_context global_ctx; - -static void wake_up(rtems_id task) +static void wake_up( rtems_id task ) { rtems_status_code sc; sc = rtems_event_send( task, WAKE_UP ); - ASSERT_SC( sc ); + T_quiet_rsc_success( sc ); } static void wait_for_wake_up( void ) @@ -58,18 +52,43 @@ static void wait_for_wake_up( void ) RTEMS_NO_TIMEOUT, &events ); - ASSERT_SC( sc ); - rtems_test_assert( events == WAKE_UP ); + T_quiet_rsc_success( sc ); + T_quiet_eq_u32( events, WAKE_UP ); } -static void active_high_priority_task( rtems_id timer, void *arg ) +static T_interrupt_test_state active_high_priority_task( void *arg ) { - /* The arg is NULL */ - test_context *ctx = &global_ctx; + test_context *ctx = arg; + T_interrupt_test_state state; + + state = T_interrupt_test_change_state( +T_INTERRUPT_TEST_ACTION, +T_INTERRUPT_TEST_ACTION + ); + + if ( state != T_INTERRUPT_TEST_ACTION ) { +return T_INTERRUPT_TEST_CONTINUE; + } - rtems_test_assert( !ctx->high_priority_task_activated ); + T_quiet_false( ctx->high_priority_task_activated ); ctx->high_priority_task_activated = true; wake_up( ctx->high_priority_task ); + + if ( ctx->early ) { +state = T_INTERRUPT_TEST_EARLY; + } else if ( ctx->late ) { +state = T_INTERRUPT_TEST_LATE; + } else { +++ctx->potential_hits; + +if ( ctx->potential_hits > 13 ) { + state = T_INTERRUPT_TEST_DONE; +} else { + state = T_INTERRUPT_TEST_CONTINUE; +} + } + + return state; } static void middle_priority_task( rtems_task_argument arg ) @@ -78,8 +97,9 @@ static void middle_priority_task( rtems_task_argument arg ) while ( true ) { wait_for_wake_up(); +ctx->late = true; -rtems_test_assert( !ctx->high_priority_task_activated ); +T_quiet_false( ctx->high_priority_task_activated ); } } @@ -90,26 +110,60 @@ static void high_priority_task( rtems_task_argument arg ) while ( true ) { wait_for_wake_up(); -rtems_test_assert( ctx->high_priority_task_activated ); +T_quiet_true( ctx->high_priority_task_activated ); ctx->high_priority_task_activated = false; } } -static bool test_body( void *arg ) +static void prepare( void *arg ) { test_context *ctx = arg; + ctx->early = true; + ctx->switching = false; + ctx->late = false; +} + +static void action( void *arg ) +{ + test_context *ctx = arg; + + ctx->early = false; wake_up( ctx->middle_priority_task ); +} - return false; +static void blocked( void *arg ) +{ + test_context *ctx = arg; + T_interrupt_test_state state; + + state = T_interrupt_test_change_state( +T_INTERRUPT_TEST_ACTION, +T_INTERRUPT_TEST_LATE + ); + + if ( state == T_INTERRUPT_TEST_ACTION ) { +ctx->switching = true; +T_busy( 100 ); +ctx->switching = false; + } } -static void Init( rtems_tas
[PATCH 22/33] spintrcritical10: Use T_interrupt_test()
--- testsuites/sptests/Makefile.am| 4 +- testsuites/sptests/spintrcritical10/init.c| 198 +++--- .../spintrcritical10/spintrcritical10.scn | 33 ++- 3 files changed, 109 insertions(+), 126 deletions(-) diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 9f66b66371..ceea27565f 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1260,9 +1260,7 @@ if TEST_spintrcritical10 sp_tests += spintrcritical10 sp_screens += spintrcritical10/spintrcritical10.scn sp_docs += spintrcritical10/spintrcritical10.doc -spintrcritical10_SOURCES = spintrcritical10/init.c \ - spintrcritical_support/intrcritical.c \ - spintrcritical_support/intrcritical.h +spintrcritical10_SOURCES = spintrcritical10/init.c spintrcritical10_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical10) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support diff --git a/testsuites/sptests/spintrcritical10/init.c b/testsuites/sptests/spintrcritical10/init.c index fff1991cbc..8210853588 100644 --- a/testsuites/sptests/spintrcritical10/init.c +++ b/testsuites/sptests/spintrcritical10/init.c @@ -2,7 +2,7 @@ * COPYRIGHT (c) 1989-2012. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2013 embedded brains GmbH. + * Copyright (c) 2013, 2020 embedded brains GmbH. * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -14,13 +14,15 @@ #endif #include -#include +#include #include #include const char rtems_test_name[] = "SPINTRCRITICAL 10"; +#define MAX_ITERATION_COUNT 1 + #define GREEN RTEMS_EVENT_0 #define RED RTEMS_EVENT_1 @@ -30,9 +32,7 @@ const char rtems_test_name[] = "SPINTRCRITICAL 10"; #define DEADBEEF 0xdeadbeef typedef struct { - rtems_id timer; Thread_Control *thread; - bool hit; } test_context; static bool blocks_for_event(Thread_Wait_flags flags) @@ -47,15 +47,20 @@ static bool interrupts_blocking_op(Thread_Wait_flags flags) flags == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_INTEND_TO_BLOCK); } -static void any_satisfy_before_timeout(rtems_id timer, void *arg) +static T_interrupt_test_state any_satisfy_before_timeout_interrupt(void *arg) { rtems_status_code sc; test_context *ctx = arg; Thread_Control *thread = ctx->thread; Thread_Wait_flags flags = _Thread_Wait_flags_get(thread); + T_interrupt_test_state state; if (blocks_for_event(flags)) { -ctx->hit = interrupts_blocking_op(flags); +if (interrupts_blocking_op(flags)) { + state = T_INTERRUPT_TEST_DONE; +} else { + state = T_INTERRUPT_TEST_LATE; +} rtems_test_assert( *(rtems_event_set *) thread->Wait.return_argument == DEADBEEF @@ -85,7 +90,7 @@ static void any_satisfy_before_timeout(rtems_id timer, void *arg) ); rtems_test_assert(_Thread_Wait_get_status(thread) == STATUS_SUCCESSFUL); -if (ctx->hit) { +if (state == T_INTERRUPT_TEST_DONE) { rtems_test_assert( _Thread_Wait_flags_get(thread) == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_READY_AGAIN) @@ -93,18 +98,20 @@ static void any_satisfy_before_timeout(rtems_id timer, void *arg) } rtems_test_assert(thread->Wait.count == EVENTS); + } else { +state = T_INTERRUPT_TEST_EARLY; } - sc = rtems_timer_reset(timer); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); + return state; } -static bool test_body_any_satisfy_before_timeout(void *arg) +static void any_satisfy_before_timeout_action(void *arg) { - test_context *ctx = arg; rtems_status_code sc; rtems_event_set out; + (void) arg; + out = DEADBEEF; sc = rtems_event_receive(EVENTS, RTEMS_EVENT_ANY | RTEMS_WAIT, 1, &out); rtems_test_assert(sc == RTEMS_SUCCESSFUL); @@ -114,45 +121,38 @@ static bool test_body_any_satisfy_before_timeout(void *arg) sc = rtems_event_receive(EVENTS, RTEMS_EVENT_ANY | RTEMS_NO_WAIT, 0, &out); rtems_test_assert(sc == RTEMS_SUCCESSFUL); rtems_test_assert(out == RED); - - return ctx->hit; } -static void test_any_satisfy_before_timeout(test_context *ctx) -{ - rtems_status_code sc; - - puts( -"Init - Trying to generate any satisfied before timeout " -"while blocking on event" - ); - - ctx->hit = false; - - sc = rtems_timer_fire_after(ctx->timer, 1, any_satisfy_before_timeout, ctx); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); - - interrupt_critical_section_test( -test_body_any_satisfy_before_timeout, -ctx, -NULL - ); +static const T_interrupt_test_config any_satisfy_before_timeout_config = { + .action = any_satisfy_before_timeout_action, + .interrupt = any_satisfy_before_timeout_interrupt, + .max_iteration_count = MAX_ITERATION_COUNT +}; - sc = rtems_timer_cancel(ctx->timer); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); +T_TEST_CASE(EventAnySatisfyBeforeTimeout) +{ + test_context ctx; + T_interr
[PATCH 23/33] spintrcritical11/12: Use T_interrupt_test()
--- testsuites/sptests/Makefile.am| 7 +- .../spintrcritical11/spintrcritical11.scn | 30 - .../spintrcritical11/spintrcritical11impl.h | 110 -- .../spintrcritical12/spintrcritical12.scn | 30 - 4 files changed, 126 insertions(+), 51 deletions(-) diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index ceea27565f..f9dcd0d570 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1270,9 +1270,7 @@ if TEST_spintrcritical11 sp_tests += spintrcritical11 sp_screens += spintrcritical11/spintrcritical11.scn sp_docs += spintrcritical11/spintrcritical11.doc -spintrcritical11_SOURCES = spintrcritical11/init.c \ - spintrcritical_support/intrcritical.c \ - spintrcritical_support/intrcritical.h +spintrcritical11_SOURCES = spintrcritical11/init.c spintrcritical11_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical11) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support @@ -1282,8 +1280,7 @@ if TEST_spintrcritical12 sp_tests += spintrcritical12 sp_screens += spintrcritical12/spintrcritical12.scn sp_docs += spintrcritical12/spintrcritical12.doc -spintrcritical12_SOURCES = spintrcritical12/init.c \ - spintrcritical_support/intrcritical.c +spintrcritical12_SOURCES = spintrcritical12/init.c spintrcritical12_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical12) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support diff --git a/testsuites/sptests/spintrcritical11/spintrcritical11.scn b/testsuites/sptests/spintrcritical11/spintrcritical11.scn index 9451d04292..26f38d037e 100644 --- a/testsuites/sptests/spintrcritical11/spintrcritical11.scn +++ b/testsuites/sptests/spintrcritical11/spintrcritical11.scn @@ -1,6 +1,24 @@ -*** TEST INTERRUPT CRITICAL SECTION 11 *** -Init - Test may not be able to detect case is hit reliably -Init - Trying to generate event send from ISR while blocking -Init - Variation is: Event Any condition -Support - rtems_timer_create - creating timer 1 -*** END OF TEST INTERRUPT CRITICAL SECTION 11 *** +*** BEGIN OF TEST SPINTRCRITICAL 11 *** +*** TEST VERSION: 6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d +*** TEST STATE: EXPECTED_PASS +*** TEST BUILD: RTEMS_DEBUG RTEMS_POSIX_API RTEMS_SMP +*** TEST TOOLS: 10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4) +A:SPINTRCRITICAL 11 +S:Platform:RTEMS +S:Compiler:10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4) +S:Version:6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d +S:BSP:realview_pbx_a9_qemu +S:RTEMS_DEBUG:1 +S:RTEMS_MULTIPROCESSING:0 +S:RTEMS_POSIX_API:1 +S:RTEMS_PROFILING:0 +S:RTEMS_SMP:1 +B:EventReceiveInterruptAny +P:0:0:UI1:spintrcritical11impl.h:113 +L:potential hits = 999 +P:1:0:UI1:spintrcritical11impl.h:116 +E:EventReceiveInterruptAny:N:2:F:0:D:1.058417 +Z:SPINTRCRITICAL 11:C:1:N:2:F:0:D:1.059457 +Y:ReportHash:SHA256:e666eb8c6287c596e6d1851fea90f50fdcc8a52c7799ede485964d09de3fc9ed + +*** END OF TEST SPINTRCRITICAL 11 *** diff --git a/testsuites/sptests/spintrcritical11/spintrcritical11impl.h b/testsuites/sptests/spintrcritical11/spintrcritical11impl.h index fb0d320dea..dfa312f0b5 100644 --- a/testsuites/sptests/spintrcritical11/spintrcritical11impl.h +++ b/testsuites/sptests/spintrcritical11/spintrcritical11impl.h @@ -1,4 +1,6 @@ /* + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * * COPYRIGHT (c) 1989-2012. * On-Line Applications Research Corporation (OAR). * @@ -11,24 +13,20 @@ #include "config.h" #endif -#include -#include - -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument argument); -rtems_timer_service_routine test_release_from_isr(rtems_id timer, void *arg); +#include -rtems_id Main_task; +#include +#include #if defined(EVENT_ANY) #define TEST_NAME "11" - #define TEST_STRING"Event Any condition" + #define TEST_STRINGAny #define EVENTS_TO_SEND 0x1 #define EVENTS_TO_RECEIVE 0x3 #elif defined(EVENT_ALL) #define TEST_NAME "12" - #define TEST_STRING"Event All condition" + #define TEST_STRINGAll #define EVENTS_TO_SEND 0x3 #define EVENTS_TO_RECEIVE 0x3 @@ -39,41 +37,88 @@ rtems_id Main_task; const char rtems_test_name[] = "SPINTRCRITICAL " TEST_NAME; -rtems_timer_service_routine test_release_from_isr( - rtems_id timer, - void *arg -) +typedef struct { + rtems_id main_task; + long potential_hits; + volatile bool early; + volatile bool late; +} test_context; + +static T_interrupt_test_state interrupt( void *arg ) { - (void) rtems_event_send( Main_task, EVENTS_TO_SEND ); + test_context *ctx; + T_interrupt_test_state state; + rtems_status_code sc; + + state = T_interrupt_test_get_state(); + + if ( state != T_INTERRUPT_TEST_ACTION ) { +return T_INTERRUPT_TEST
[PATCH 24/33] spintrcritical13/14: Use T_interrupt_test()
--- testsuites/sptests/Makefile.am| 7 +- .../spintrcritical13/spintrcritical13.scn | 31 +++- .../spintrcritical13/spintrcritical13impl.h | 150 -- .../spintrcritical14/spintrcritical14.scn | 31 +++- 4 files changed, 151 insertions(+), 68 deletions(-) diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index f9dcd0d570..7dbc829ddf 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1290,9 +1290,7 @@ if TEST_spintrcritical13 sp_tests += spintrcritical13 sp_screens += spintrcritical13/spintrcritical13.scn sp_docs += spintrcritical13/spintrcritical13.doc -spintrcritical13_SOURCES = spintrcritical13/init.c \ - spintrcritical_support/intrcritical.c \ - spintrcritical_support/intrcritical.h +spintrcritical13_SOURCES = spintrcritical13/init.c spintrcritical13_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical13) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support @@ -1302,8 +1300,7 @@ if TEST_spintrcritical14 sp_tests += spintrcritical14 sp_screens += spintrcritical14/spintrcritical14.scn sp_docs += spintrcritical14/spintrcritical14.doc -spintrcritical14_SOURCES = spintrcritical14/init.c \ - spintrcritical_support/intrcritical.c +spintrcritical14_SOURCES = spintrcritical14/init.c spintrcritical14_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical14) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support diff --git a/testsuites/sptests/spintrcritical13/spintrcritical13.scn b/testsuites/sptests/spintrcritical13/spintrcritical13.scn index 712706caae..8181218b5f 100644 --- a/testsuites/sptests/spintrcritical13/spintrcritical13.scn +++ b/testsuites/sptests/spintrcritical13/spintrcritical13.scn @@ -1,7 +1,24 @@ -*** TEST INTERRUPT CRITICAL SECTION 13 *** -Init - Trying to generate timer fire from ISR while firing -Init - Variation is: Timer Fire After -Init - There is no way for the test to know if it hits the case -Init - rtems_timer_create - OK -Support - rtems_timer_create - creating timer 1 -*** END OF TEST INTERRUPT CRITICAL SECTION 13 *** +*** BEGIN OF TEST SPINTRCRITICAL 13 *** +*** TEST VERSION: 6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d +*** TEST STATE: EXPECTED_PASS +*** TEST BUILD: RTEMS_DEBUG RTEMS_POSIX_API RTEMS_SMP +*** TEST TOOLS: 10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4) +A:SPINTRCRITICAL 13 +S:Platform:RTEMS +S:Compiler:10.0.1 20200406 (RTEMS 6, RSB bec88a6dd856892c3e66e4598252ea07d7a0d762, Newlib ece49e4) +S:Version:6.0.0.929e49a54ab4d2d18c9fb8d03610614f63e25b8d +S:BSP:realview_pbx_a9_qemu +S:RTEMS_DEBUG:1 +S:RTEMS_MULTIPROCESSING:0 +S:RTEMS_POSIX_API:1 +S:RTEMS_PROFILING:0 +S:RTEMS_SMP:1 +B:TimerFireAfterInterrupt +P:0:0:UI1:spintrcritical13impl.h:131 +P:1:0:UI1:spintrcritical13impl.h:134 +P:2:0:UI1:spintrcritical13impl.h:137 +E:TimerFireAfterInterrupt:N:3:F:0:D:0.116053 +Z:SPINTRCRITICAL 13:C:1:N:3:F:0:D:0.117144 +Y:ReportHash:SHA256:66bf247c36962dc930b099cc4979215b4cadb41edd8925097a91e8e7a4356725 + +*** END OF TEST SPINTRCRITICAL 13 *** diff --git a/testsuites/sptests/spintrcritical13/spintrcritical13impl.h b/testsuites/sptests/spintrcritical13/spintrcritical13impl.h index e284d3c33d..b378937801 100644 --- a/testsuites/sptests/spintrcritical13/spintrcritical13impl.h +++ b/testsuites/sptests/spintrcritical13/spintrcritical13impl.h @@ -1,4 +1,6 @@ /* + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * @@ -11,17 +13,19 @@ #include "config.h" #endif -#include -#include +#include + +#include +#include #if defined(FIRE_AFTER) #define TEST_NAME "13" - #define TEST_STRING"Timer Fire After" + #define TEST_STRINGTimerFireAfterInterrupt #define TEST_DIRECTIVE rtems_timer_fire_after #elif defined(SERVER_FIRE_AFTER) #define TEST_NAME "14" - #define TEST_STRING"Timer Server Fire After" + #define TEST_STRINGTimerServerFireAfterInterrupt #define TEST_DIRECTIVE rtems_timer_server_fire_after #else @@ -30,71 +34,120 @@ const char rtems_test_name[] = "SPINTRCRITICAL " TEST_NAME; -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument argument); -rtems_timer_service_routine test_release_from_isr(rtems_id timer, void *arg); -rtems_timer_service_routine TimerMethod(rtems_id timer, void *arg); - -rtems_id Timer; +typedef struct { + rtems_id timer; + long potential_hits; + volatile bool early; + volatile bool late; +} test_context; -rtems_timer_service_routine TimerMethod( +static rtems_timer_service_routine TimerMethod( rtems_id timer, void *arg ) { + (void) timer; + (void) arg; } -rtems_timer_service_routine test_release_from_isr( - rtems_id timer, - void *arg -) +static T_interrupt_test_state interrupt( void
[PATCH 26/33] spintrcritical16: Use T_interrupt_test()
--- testsuites/sptests/Makefile.am| 4 +- testsuites/sptests/spintrcritical16/init.c| 135 +++--- .../spintrcritical16/spintrcritical16.scn | 31 +++- 3 files changed, 109 insertions(+), 61 deletions(-) diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 0cf00f7fa6..136a8378b5 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1320,9 +1320,7 @@ if TEST_spintrcritical16 sp_tests += spintrcritical16 sp_screens += spintrcritical16/spintrcritical16.scn sp_docs += spintrcritical16/spintrcritical16.doc -spintrcritical16_SOURCES = spintrcritical16/init.c \ - spintrcritical_support/intrcritical.c \ - spintrcritical_support/intrcritical.h +spintrcritical16_SOURCES = spintrcritical16/init.c spintrcritical16_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical16) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support diff --git a/testsuites/sptests/spintrcritical16/init.c b/testsuites/sptests/spintrcritical16/init.c index 1879cbd189..f32776fe4a 100644 --- a/testsuites/sptests/spintrcritical16/init.c +++ b/testsuites/sptests/spintrcritical16/init.c @@ -1,4 +1,6 @@ /* + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * @@ -11,88 +13,121 @@ #include "config.h" #endif -#include -#include +#include +#include #include const char rtems_test_name[] = "SPINTRCRITICAL 16"; -static Thread_Control *Main_TCB; - -static rtems_id Semaphore; - -static bool case_hit; +typedef struct { + Thread_Control *thread; + rtems_idsemaphore; +} test_context; -static bool interrupts_blocking_op(void) +static T_interrupt_test_state interrupt( void *arg ) { - Thread_Wait_flags flags = _Thread_Wait_flags_get( Main_TCB ); + test_context *ctx; + T_interrupt_test_state state; + Thread_Wait_flags flags; + rtems_status_code sc; - return -flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_INTEND_TO_BLOCK ); -} + ctx = arg; + state = T_interrupt_test_change_state( +T_INTERRUPT_TEST_ACTION, +T_INTERRUPT_TEST_ACTION + ); -static rtems_timer_service_routine test_release_from_isr( - rtems_id timer, - void *arg -) -{ - if ( interrupts_blocking_op() ) { -case_hit = true; -(void) rtems_semaphore_release( Semaphore ); + if (state != T_INTERRUPT_TEST_ACTION) { +return T_INTERRUPT_TEST_CONTINUE; } - if ( Main_TCB->Wait.queue != NULL ) { -_Thread_Timeout( &Main_TCB->Timer.Watchdog ); + flags = _Thread_Wait_flags_get( ctx->thread ); + + if ( +flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_INTEND_TO_BLOCK ) + ) { +state = T_INTERRUPT_TEST_DONE; + } else if ( +flags == ( THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_BLOCKED ) + ) { +state = T_INTERRUPT_TEST_LATE; + } else { +state = T_INTERRUPT_TEST_EARLY; } + + sc = rtems_semaphore_release( ctx->semaphore ); + T_quiet_rsc_success( sc ); + + return state; } -static bool test_body( void *arg ) +static void action( void *arg ) { + test_context *ctx; rtems_status_code sc; - (void) arg; + ctx = arg; + sc = rtems_semaphore_obtain( ctx->semaphore, RTEMS_DEFAULT_OPTIONS, 2 ); + T_quiet_rsc_success( sc ); +} + +static void blocked( void *arg ) +{ + test_context *ctx; + T_interrupt_test_state state; + rtems_status_code sc; - sc = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 2 ); - rtems_test_assert( sc == RTEMS_SUCCESSFUL || sc == RTEMS_TIMEOUT ); + ctx = arg; + state = T_interrupt_test_change_state( +T_INTERRUPT_TEST_ACTION, +T_INTERRUPT_TEST_LATE + ); - return case_hit; + if ( state == T_INTERRUPT_TEST_ACTION ) { +sc = rtems_semaphore_release( ctx->semaphore ); +T_quiet_rsc_success( sc ); + } } -static rtems_task Init( - rtems_task_argument ignored -) +static const T_interrupt_test_config config = { + .action = action, + .interrupt = interrupt, + .blocked = blocked, + .max_iteration_count = 1 +}; + +/* + * Trying to generate timeout of a thread that had its blocking request + * satisfied while blocking but before time timeout. + */ +T_TEST_CASE( SemaphoreSatisfyBeforeTimeout ) { - rtems_status_code sc; + test_context ctx; + rtems_status_code sc; + T_interrupt_test_state state; - TEST_BEGIN(); - puts( -"Init - Trying to generate timeout of a thread that had its blocking\n" -"Init - request satisfied while blocking but before time timeout" - ); + ctx.thread = _Thread_Get_executing(); - puts( "Init - rtems_semaphore_create - OK" ); sc = rtems_semaphore_create( rtems_build_name( 'S', 'M', '1', ' ' ), 0, RTEMS_DEFAULT_ATTRIBUTES, RTEMS_NO_PRIORITY, -&Semaphore +&ctx.semaphore ); - directive_failed( sc, "rtems_semaphore_create of SM1" ); - - Main_TCB = _Thread_Get_executing(); + T_assert_rsc_success( sc ); -
[PATCH 32/33] spintrcritical24: Use T_interrupt_test()
--- testsuites/sptests/Makefile.am| 4 +- testsuites/sptests/spintrcritical24/init.c| 128 +- .../spintrcritical24/spintrcritical24.scn | 32 + 3 files changed, 125 insertions(+), 39 deletions(-) diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 14826811dc..5404ba4302 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1380,9 +1380,7 @@ if TEST_spintrcritical24 sp_tests += spintrcritical24 sp_screens += spintrcritical24/spintrcritical24.scn sp_docs += spintrcritical24/spintrcritical24.doc -spintrcritical24_SOURCES = spintrcritical24/init.c \ - spintrcritical_support/intrcritical.h \ - spintrcritical_support/intrcritical.c +spintrcritical24_SOURCES = spintrcritical24/init.c spintrcritical24_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical24) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support diff --git a/testsuites/sptests/spintrcritical24/init.c b/testsuites/sptests/spintrcritical24/init.c index 785ebacadd..d02fdcaebf 100644 --- a/testsuites/sptests/spintrcritical24/init.c +++ b/testsuites/sptests/spintrcritical24/init.c @@ -1,11 +1,5 @@ /* - * Copyright (c) 2017 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * + * Copyright (C) 2017, 2020 embedded brains GmbH (http://www.embedded-brains.de) * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -17,25 +11,29 @@ #endif #include +#include #include +#include #include -#include #include - -#include -#include +#include +#include +#include const char rtems_test_name[] = "SPINTRCRITICAL 24"; typedef struct { int fd; + rtems_libio_t *iop; + long early_count; + long late_count; + long potential_hit_count; long append_count; long no_append_count; + volatile bool closed; } test_context; -static test_context test_instance; - static const char path[] = "generic"; static int handler_close(rtems_libio_t *iop) @@ -43,6 +41,7 @@ static int handler_close(rtems_libio_t *iop) test_context *ctx; ctx = IMFS_generic_get_context_by_iop(iop); + ctx->closed = true; if (rtems_libio_iop_is_append(iop)) { ++ctx->append_count; @@ -67,67 +66,126 @@ static const IMFS_node_control node_control = { .node_destroy = IMFS_node_destroy_default }; -static void do_fcntl(rtems_id timer, void *arg) +static T_interrupt_test_state interrupt(void *arg) { - /* The arg is NULL */ test_context *ctx; + T_interrupt_test_state state; int rv; + unsigned int flags; + + state = T_interrupt_test_change_state( +T_INTERRUPT_TEST_ACTION, +T_INTERRUPT_TEST_ACTION + ); - ctx = &test_instance; + if (state != T_INTERRUPT_TEST_ACTION) { +return T_INTERRUPT_TEST_CONTINUE; + } + + ctx = arg; + flags = rtems_libio_iop_flags_set(ctx->iop, 0); + + if ((flags & LIBIO_FLAGS_OPEN) != 0) { +++ctx->early_count; +state = T_INTERRUPT_TEST_EARLY; + } else if (ctx->closed) { +++ctx->late_count; +state = T_INTERRUPT_TEST_LATE; + } else { +++ctx->potential_hit_count; + +if (ctx->potential_hit_count >= 13) { + state = T_INTERRUPT_TEST_DONE; +} else { + state = T_INTERRUPT_TEST_CONTINUE; +} + } rv = fcntl(ctx->fd, F_SETFL, O_APPEND); if (rv != 0) { -rtems_test_assert(rv == -1); -rtems_test_assert(errno == EBADF); +T_quiet_psx_error(rv, EBADF); } + + return state; } -static bool test_body(void *arg) +static void prepare(void *arg) { test_context *ctx; - int rv; ctx = arg; ctx->fd = open(path, O_RDWR); - rtems_test_assert(ctx->fd >= 0); + T_quiet_ge_int(ctx->fd, 0); + + ctx->closed = false; + ctx->iop = rtems_libio_iop(ctx->fd); +} + +static void action(void *arg) +{ + test_context *ctx; + int rv; + T_interrupt_test_state state; + + ctx = arg; rv = close(ctx->fd); - rtems_test_assert(rv == 0); + T_quiet_psx_success(rv); - return false; + do { +state = T_interrupt_test_get_state(); + } while (state == T_INTERRUPT_TEST_ACTION); } -static void test(test_context *ctx) +static const T_interrupt_test_config config = { + .prepare = prepare, + .action = action, + .interrupt = interrupt, + .max_iteration_count = 1 +}; + +T_TEST_CASE(CloseInterrupt) { + test_context ctx; const char *path = "generic"; int rv; + T_interrupt_test_state state; + + memset(&ctx, 0, sizeof(ctx)); rv = IMFS_make_generic_node( path, S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, &node_control, -ctx +&ctx ); - rtems_test_assert(rv == 0); + T_psx_success(rv); + + state = T_interrupt_test(&config, &ctx); + T_eq_int(state, T_INTERRUPT_TEST_DONE); - interrupt_critical_section_test(test_body, ctx, do_fcntl); + T_log(T_NORMAL, "early count = %ld", ctx.early_count); + T_log(T_NORMAL, "late count = %ld
[PATCH 11/33] libtest: Add T_CHECK_FMT
Rename internal function T_check_true() to T_check() and use the new flag T_CHECK_FMT to indicate if a format string is present. This is a preparation step to make the format string optional. Make the check context the first parameter. The API remains the same. Update #3199. --- cpukit/include/rtems/test.h | 338 --- cpukit/libtest/t-test-checks-eno.c | 8 +- cpukit/libtest/t-test-checks-psx.c | 8 +- cpukit/libtest/t-test-checks.c | 192 ++--- cpukit/libtest/t-test-rtems-context.c| 6 +- cpukit/libtest/t-test-rtems-fds.c| 3 +- cpukit/libtest/t-test-rtems-heap.c | 4 +- cpukit/libtest/t-test-rtems-objs.c | 3 +- cpukit/libtest/t-test-rtems-posix-keys.c | 3 +- cpukit/libtest/t-test-rtems.c| 8 +- cpukit/libtest/t-test.c | 100 +++ 11 files changed, 343 insertions(+), 330 deletions(-) diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index 8af810def7..c0227b5465 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -114,7 +114,9 @@ void T_case_register(T_case_context *); #define T_CHECK_QUIET 2U -#define T_CHECK_STEP_FLAG 4U +#define T_CHECK_FMT 4U + +#define T_CHECK_STEP_FLAG 8U #define T_CHECK_STEP_TO_FLAGS(step) ((unsigned int)(step) << 8) @@ -133,13 +135,15 @@ typedef struct { const char *msg; } T_check_context_msg; -void T_check_true(bool, const T_check_context *, const char *, ...); +void T_check(const T_check_context *, bool, ...); + +extern const T_check_context T_special; #define T_flags_true(a, flags, ...)\ { \ static const T_check_context T_check_instance = { \ - T_FILE_NAME, __LINE__, flags }; \ - T_check_true(a, &T_check_instance, __VA_ARGS__);\ + T_FILE_NAME, __LINE__, (flags) | T_CHECK_FMT }; \ + T_check(&T_check_instance, a, __VA_ARGS__); \ } #define T_flags_eq(a, e, flags, ...) \ @@ -148,484 +152,486 @@ void T_check_true(bool, const T_check_context *, const char *, ...); #define T_flags_ne(a, e, flags, ...) \ T_flags_true((a) != (e), flags, __VA_ARGS__) -void T_check_eq_ptr(const void *, const T_check_context_msg *, const void *); +void T_check_eq_ptr(const T_check_context_msg *, const void *, const void *); #define T_flags_eq_ptr(a, e, flags, sa, se)\ { \ static const T_check_context_msg T_check_instance = { \ - { T_FILE_NAME, __LINE__, flags }, sa " == " se }; \ - T_check_eq_ptr(a, &T_check_instance, e);\ + { T_FILE_NAME, __LINE__, (flags) | T_CHECK_FMT }, \ + sa " == " se }; \ + T_check_eq_ptr(&T_check_instance, a, e);\ } -void T_check_ne_ptr(const void *, const T_check_context_msg *, const void *); +void T_check_ne_ptr(const T_check_context_msg *, const void *, const void *); #define T_flags_ne_ptr(a, e, flags, sa, se)\ { \ static const T_check_context_msg T_check_instance = { \ - { T_FILE_NAME, __LINE__, flags }, sa " != " se }; \ - T_check_ne_ptr(a, &T_check_instance, e);\ + { T_FILE_NAME, __LINE__, (flags) | T_CHECK_FMT }, \ + sa " != " se }; \ + T_check_ne_ptr(&T_check_instance, a, e);\ } -void T_check_null(const void *, const T_check_context_msg *); +void T_check_null(const T_check_context_msg *, const void *); #define T_flags_null(a, flags, sa) \ { \ static const T_check_context_msg T_check_instance = { \ - { T_FILE_NAME, __LINE__, flags }, sa }; \ - T_check_null(a, &T_check_instance); \ + { T_FILE_NAME, __LINE__, (flags) | T_CHECK_FMT }, sa }; \ + T_check_null(&T_check_instance, a); \ } -void T_check_not_null(const void *, const T_check_context_msg *); +void T_check_not_null(const T_check_context_msg *, const void *); #define T_flags_not_null(a, flags, sa) \ { \ static const T_check_context_msg T_check_instance = { \ - { T_FILE_NAME, __LINE__, flags }, sa }; \ - T_check_not_null(a, &T_check_instance);
[PATCH 17/33] psxintrcritical01: Use T_interrupt_test()
--- testsuites/psxtests/Makefile.am | 3 +- testsuites/psxtests/psxintrcritical01/init.c | 135 -- .../psxintrcritical01/psxintrcritical01.scn | 33 - 3 files changed, 121 insertions(+), 50 deletions(-) diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am index 1f9e4233ec..d89bcd8801 100755 --- a/testsuites/psxtests/Makefile.am +++ b/testsuites/psxtests/Makefile.am @@ -525,8 +525,7 @@ if TEST_psxintrcritical01 psx_tests += psxintrcritical01 psx_screens += psxintrcritical01/psxintrcritical01.scn psx_docs += psxintrcritical01/psxintrcritical01.doc -psxintrcritical01_SOURCES = psxintrcritical01/init.c \ - ../sptests/spintrcritical_support/intrcritical.c +psxintrcritical01_SOURCES = psxintrcritical01/init.c psxintrcritical01_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_psxintrcritical01) $(support_includes) \ -I$(top_srcdir)/../sptests/spintrcritical_support diff --git a/testsuites/psxtests/psxintrcritical01/init.c b/testsuites/psxtests/psxintrcritical01/init.c index 9830c41b71..dd46c03475 100644 --- a/testsuites/psxtests/psxintrcritical01/init.c +++ b/testsuites/psxtests/psxintrcritical01/init.c @@ -1,4 +1,6 @@ /* + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * * COPYRIGHT (c) 1989-2012. * On-Line Applications Research Corporation (OAR). * @@ -11,73 +13,122 @@ #include "config.h" #endif -#include -#include +#include #include +#include +#include + const char rtems_test_name[] = "PSXINTRCRITICAL 1"; -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument ignored); +typedef struct { + timer_t timer; + struct itimerspec spec; + volatile bool early; + volatile bool late; + long early_count; + long late_count; + long potential_hits; +} test_context; -#define TEST_NAME "01" -#define TEST_STRING"POSIX Timer" +#define POSIX_TIMER_RELATIVE 0 -static timer_t Timer; -static struct itimerspec TimerParams; +static void prepare(void *arg) +{ + test_context *ctx; -#define POSIX_TIMER_RELATIVE 0 + ctx = arg; + ctx->early = false; + ctx->late = false; +} -static bool test_body( void *arg ) +static void action(void *arg) { + test_context *ctx; int rv; - (void) arg; + ctx = arg; + ctx->early = true; + rv = timer_settime(ctx->timer, POSIX_TIMER_RELATIVE, &ctx->spec, NULL); + ctx->late = true; + T_quiet_psx_success(rv); - rv = timer_settime(Timer, POSIX_TIMER_RELATIVE, &TimerParams, NULL); - rtems_test_assert( rv == 0 ); - - return false; + while (T_interrupt_test_get_state() == T_INTERRUPT_TEST_ACTION) { +/* Wait */ + } } -static rtems_timer_service_routine test_release_from_isr( - rtems_id timer, - void *arg -) +static T_interrupt_test_state interrupt(void *arg) { - test_body( NULL ); + test_context *ctx; + T_interrupt_test_state state; + int rv; + + state = T_interrupt_test_get_state(); + + if (state != T_INTERRUPT_TEST_ACTION) { +return T_INTERRUPT_TEST_EARLY; + } + + ctx = arg; + rv = timer_settime(ctx->timer, POSIX_TIMER_RELATIVE, &ctx->spec, NULL); + T_quiet_psx_success(rv); + + if (ctx->late) { +++ctx->late_count; +return T_INTERRUPT_TEST_LATE; + } else if (ctx->early) { +++ctx->early_count; +return T_INTERRUPT_TEST_EARLY; + } else { +++ctx->potential_hits; + +if (ctx->potential_hits > 13) { + return T_INTERRUPT_TEST_DONE; +} else { + return T_INTERRUPT_TEST_CONTINUE; +} + } } -rtems_task Init( - rtems_task_argument ignored -) +static const T_interrupt_test_config config = { + .prepare = prepare, + .action = action, + .interrupt = interrupt, + .max_iteration_count = 1 +}; + +T_TEST_CASE(PSXSetTimerInterrupt) { + test_context ctx; int sc; + T_interrupt_test_state state; - TEST_BEGIN(); - - puts( "Init - Trying to generate timer fire from ISR while firing" ); - puts( "Init - Variation is: " TEST_STRING ); - - puts( "Init - There is no way for the test to know if it hits the case" ); + memset(&ctx, 0, sizeof(ctx)); /* create POSIX Timer */ - sc = timer_create (CLOCK_REALTIME, NULL, &Timer); - if ( sc == -1 ) { -perror ("Error in timer creation\n"); -rtems_test_exit(0); - } + sc = timer_create (CLOCK_REALTIME, NULL, &ctx.timer); + T_psx_success(sc); /* we don't care if it ever fires */ - TimerParams.it_interval.tv_sec = 10; - TimerParams.it_interval.tv_nsec = 0; - TimerParams.it_value.tv_sec = 10; - TimerParams.it_value.tv_nsec= 0; + ctx.spec.it_interval.tv_sec = 10; + ctx.spec.it_value.tv_sec = 10; + + state = T_interrupt_test(&config, &ctx); + T_eq_int(state, T_INTERRUPT_TEST_DONE); - interrupt_critical_section_test( test_body, NULL, test_release_from_isr ); + T_log(T_NORMAL, "early count = %ld", ctx.early_count); + T_log(T_NORMAL, "late count = %ld", ctx.late_count); + T_log(T_NORMAL, "potential hits = %ld", ctx.potential_hits);
[PATCH 29/33] spintrcritical21: Use T_interrupt_test()
--- testsuites/sptests/Makefile.am| 3 +- testsuites/sptests/spintrcritical21/init.c| 220 ++ .../spintrcritical21/spintrcritical21.scn | 27 ++- testsuites/sptests/spintrcritical21/system.h | 39 4 files changed, 149 insertions(+), 140 deletions(-) delete mode 100644 testsuites/sptests/spintrcritical21/system.h diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 56e7da0462..78fe657051 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1350,8 +1350,7 @@ if TEST_spintrcritical21 sp_tests += spintrcritical21 sp_screens += spintrcritical21/spintrcritical21.scn sp_docs += spintrcritical21/spintrcritical21.doc -spintrcritical21_SOURCES = spintrcritical21/init.c \ - spintrcritical_support/intrcritical.c +spintrcritical21_SOURCES = spintrcritical21/init.c spintrcritical21_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical21) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support diff --git a/testsuites/sptests/spintrcritical21/init.c b/testsuites/sptests/spintrcritical21/init.c index faa48f717c..b265d7b641 100644 --- a/testsuites/sptests/spintrcritical21/init.c +++ b/testsuites/sptests/spintrcritical21/init.c @@ -1,6 +1,8 @@ /* * Classic API Signal to Task from ISR * + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). * @@ -13,67 +15,74 @@ #include "config.h" #endif -#define CONFIGURE_INIT -#include "system.h" - -#include +#include +#include #include #include const char rtems_test_name[] = "SPINTRCRITICAL 21"; -/* - * ERROR CHECKING NOTE: - * - * We are either at dispatch disable level 1 or 2. Either way, it is - * safer not to check the dispatch level explicitly so we are using - * fatal_directive_check_status_only() not directive_failed(). - */ - -static volatile bool case_hit; +#define MAX_ITERATION_COUNT 1 -static rtems_id main_task; +typedef struct { + rtems_idmain_task; + Thread_Control *main_thread; + rtems_idother_task; +} test_context; -static Thread_Control *main_thread; - -static rtems_id other_task; +static bool is_blocked( Thread_Wait_flags flags ) +{ + return flags == ( THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_BLOCKED ); +} -static bool is_case_hit( void ) +static bool interrupts_blocking_op( Thread_Wait_flags flags ) { - return _Thread_Wait_flags_get( main_thread) + return flags == ( THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_INTEND_TO_BLOCK ); } -static rtems_timer_service_routine test_event_from_isr( - rtems_id timer, - void *arg +static T_interrupt_test_state event_from_isr_interrupt( + void *arg ) { - rtems_status_code status; + test_context *ctx; + T_interrupt_test_state state; + Thread_Wait_flags flags; + rtems_status_code status; - if ( is_case_hit() ) { + ctx = arg; + flags = _Thread_Wait_flags_get( ctx->main_thread ); + + if ( interrupts_blocking_op( flags ) ) { /* * This event send hits the critical section but sends to * another task so doesn't impact this critical section. */ -status = rtems_event_send( other_task, 0x02 ); -fatal_directive_check_status_only( status, RTEMS_SUCCESSFUL, "event send" ); +status = rtems_event_send( ctx->other_task, 0x02 ); +T_quiet_rsc_success( status ); /* * This event send hits the main task but doesn't satisfy * it's blocking condition so it will still block */ -status = rtems_event_send( main_task, 0x02 ); -fatal_directive_check_status_only( status, RTEMS_SUCCESSFUL, "event send" ); - -case_hit = true; +status = rtems_event_send( ctx->main_task, 0x02 ); +T_quiet_rsc_success( status ); + +state = T_INTERRUPT_TEST_DONE; + } else if ( is_blocked( flags ) ) { +state = T_INTERRUPT_TEST_LATE; + } else { +state = T_INTERRUPT_TEST_EARLY; } - status = rtems_event_send( main_task, 0x01 ); - fatal_directive_check_status_only( status, RTEMS_SUCCESSFUL, "event send" ); + + status = rtems_event_send( ctx->main_task, 0x01 ); + T_quiet_rsc_success( status ); + + return state; } -static bool test_body_event_from_isr( void *arg ) +static void event_from_isr_action( void *arg ) { rtems_status_code status; rtems_event_set out; @@ -81,30 +90,72 @@ static bool test_body_event_from_isr( void *arg ) (void) arg; status = rtems_event_receive( 0x01, RTEMS_DEFAULT_OPTIONS, 0, &out ); - rtems_test_assert( status == RTEMS_SUCCESSFUL ); + T_quiet_rsc_success( status ); +} + +static const T_interrupt_test_config event_from_isr_config = { + .action = event_from_isr_action, + .interrupt = event_from_isr_interrupt, + .max_iteration_count = MAX_ITERATION_COUNT +}; + +T_TEST_CASE(EventFromISR) +{ + test_context ctx; + T_interrupt_test_state state; + rtems_statu
[PATCH 28/33] spintrcritical20: Use T_interrupt_test()
--- testsuites/sptests/Makefile.am| 3 +- testsuites/sptests/spintrcritical20/init.c| 145 +++--- .../spintrcritical20/spintrcritical20.scn | 32 +++- 3 files changed, 121 insertions(+), 59 deletions(-) diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 5df21b89af..56e7da0462 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1340,8 +1340,7 @@ if TEST_spintrcritical20 sp_tests += spintrcritical20 sp_screens += spintrcritical20/spintrcritical20.scn sp_docs += spintrcritical20/spintrcritical20.doc -spintrcritical20_SOURCES = spintrcritical20/init.c \ - spintrcritical_support/intrcritical.c +spintrcritical20_SOURCES = spintrcritical20/init.c spintrcritical20_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical20) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support diff --git a/testsuites/sptests/spintrcritical20/init.c b/testsuites/sptests/spintrcritical20/init.c index 60af3adebd..0ab2e15698 100644 --- a/testsuites/sptests/spintrcritical20/init.c +++ b/testsuites/sptests/spintrcritical20/init.c @@ -1,11 +1,5 @@ /* - * Copyright (c) 2013 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * + * Copyright (C) 2013, 2020 embedded brains GmbH (http://www.embedded-brains.de) * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -16,8 +10,11 @@ #include "config.h" #endif -#include -#include +#include + +#include +#include + #include #include #include @@ -36,10 +33,10 @@ typedef struct { bool thread_queue_was_null; bool status_was_successful; bool status_was_timeout; + volatile bool early; + volatile bool late; } test_context; -static test_context ctx_instance; - static void semaphore_task(rtems_task_argument arg) { test_context *ctx = (test_context *) arg; @@ -52,37 +49,63 @@ static void semaphore_task(rtems_task_argument arg) RTEMS_WAIT, RTEMS_NO_TIMEOUT ); -rtems_test_assert(sc == RTEMS_SUCCESSFUL || sc == RTEMS_TIMEOUT); +T_quiet_true(sc == RTEMS_SUCCESSFUL || sc == RTEMS_TIMEOUT); + } +} + +static T_interrupt_test_state interrupt(void *arg) +{ + test_context *ctx = arg; + T_interrupt_test_state state; + rtems_status_code sc; + + state = T_interrupt_test_change_state( +T_INTERRUPT_TEST_ACTION, +T_INTERRUPT_TEST_ACTION + ); + + if (state != T_INTERRUPT_TEST_ACTION) { +return T_INTERRUPT_TEST_CONTINUE; } + + sc = rtems_semaphore_release(ctx->semaphore_id); + T_quiet_rsc_success(sc); + + if ( ctx->early ) { +state = T_INTERRUPT_TEST_EARLY; + } else if ( ctx->late ) { +state = T_INTERRUPT_TEST_LATE; + } else if ( +ctx->thread_queue_was_null + && ctx->status_was_successful + && ctx->status_was_timeout + ) { +state = T_INTERRUPT_TEST_DONE; + } else { +state = T_INTERRUPT_TEST_CONTINUE; + } + + return state; } -static void release_semaphore(rtems_id timer, void *arg) +static void prepare(void *arg) { - /* The arg is NULL */ - test_context *ctx = &ctx_instance; - rtems_status_code sc = rtems_semaphore_release(ctx->semaphore_id); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); + test_context *ctx = arg; + + ctx->early = true; + ctx->late = false; } -static bool test_body(void *arg) +static void action(void *arg) { test_context *ctx = arg; - int busy; Per_CPU_Control *cpu_self; + T_interrupt_test_state state; cpu_self = _Thread_Dispatch_disable(); + ctx->early = false; - rtems_test_assert( -_Thread_Wait_get_status( ctx->semaphore_task_tcb ) == STATUS_SUCCESSFUL - ); - - /* - * Spend some time to make it more likely that we hit the test condition - * below. - */ - for (busy = 0; busy < 1000; ++busy) { -__asm__ volatile (""); - } + T_quiet_rsc_success(_Thread_Wait_get_status( ctx->semaphore_task_tcb )); if (ctx->semaphore_task_tcb->Wait.queue == NULL) { ctx->thread_queue_was_null = true; @@ -98,34 +121,42 @@ static bool test_body(void *arg) ctx->status_was_timeout = true; break; default: - rtems_test_assert(0); + T_unreachable(); break; } + ctx->late = true; _Thread_Dispatch_enable(cpu_self); - return ctx->thread_queue_was_null -&& ctx->status_was_successful -&& ctx->status_was_timeout; + do { +state = T_interrupt_test_get_state(); + } while (state == T_INTERRUPT_TEST_ACTION); } -static void Init(rtems_task_argument ignored) +static const T_interrupt_test_config config = { + .prepare = prepare, + .action = action, + .interrupt = interrupt, + .max_iteration_count = 1 +}; + +T_TEST_CASE(SemaphoreObtainTimeoutInterrupt) { - test_context *ctx = &ctx_instance; + test_context ctx; rtems_status_code sc; + T_interrupt_test_state state; - TEST_BEGIN(); - - ctx->master_task = rtems_ta
[PATCH 30/33] spintrcritical22: Use T_interrupt_test()
--- testsuites/sptests/Makefile.am| 4 +- testsuites/sptests/spintrcritical22/init.c| 103 +++--- .../spintrcritical22/spintrcritical22.scn | 20 3 files changed, 87 insertions(+), 40 deletions(-) diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 78fe657051..f35eeed664 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1360,9 +1360,7 @@ if TEST_spintrcritical22 sp_tests += spintrcritical22 sp_screens += spintrcritical22/spintrcritical22.scn sp_docs += spintrcritical22/spintrcritical22.doc -spintrcritical22_SOURCES = spintrcritical22/init.c \ - spintrcritical_support/intrcritical.h \ - spintrcritical_support/intrcritical.c +spintrcritical22_SOURCES = spintrcritical22/init.c spintrcritical22_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical22) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support diff --git a/testsuites/sptests/spintrcritical22/init.c b/testsuites/sptests/spintrcritical22/init.c index b7cd430867..a73499c888 100644 --- a/testsuites/sptests/spintrcritical22/init.c +++ b/testsuites/sptests/spintrcritical22/init.c @@ -1,11 +1,5 @@ /* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * + * Copyright (C) 2014, 2020 embedded brains GmbH (http://www.embedded-brains.de) * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -17,7 +11,8 @@ #endif #include -#include +#include + #include const char rtems_test_name[] = "SPINTRCRITICAL 22"; @@ -26,11 +21,8 @@ typedef struct { rtems_id semaphore_id; Semaphore_Control *semaphore_control; Thread_Control *main_task_control; - volatile bool done; } test_context; -static test_context ctx_instance; - static Semaphore_Control *get_semaphore_control(rtems_id id) { Thread_queue_Context queue_context; @@ -43,19 +35,21 @@ static Semaphore_Control *get_semaphore_control(rtems_id id) return sem; } -static void release_semaphore(rtems_id timer, void *arg) +static T_interrupt_test_state release_semaphore(void *arg) { - /* The arg is NULL */ - test_context *ctx = &ctx_instance; + test_context *ctx = arg; rtems_status_code sc; + Thread_Wait_flags flags; + T_interrupt_test_state state; + + flags = _Thread_Wait_flags_get(ctx->main_task_control); if ( -_Thread_Wait_flags_get(ctx->main_task_control) - == (THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_INTEND_TO_BLOCK) +flags == (THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_INTEND_TO_BLOCK) ) { CORE_semaphore_Control *sem; -ctx->done = true; +state = T_INTERRUPT_TEST_DONE; sc = rtems_semaphore_release(ctx->semaphore_id); rtems_test_assert(sc == RTEMS_SUCCESSFUL); @@ -67,12 +61,33 @@ static void release_semaphore(rtems_id timer, void *arg) sem = &ctx->semaphore_control->Core_control.Semaphore; rtems_test_assert(sem->count == 0); } else { +if (flags == (THREAD_WAIT_CLASS_EVENT | THREAD_WAIT_STATE_BLOCKED)) { + state = T_INTERRUPT_TEST_LATE; +} else { + state = T_INTERRUPT_TEST_EARLY; +} + sc = rtems_semaphore_release(ctx->semaphore_id); rtems_test_assert(sc == RTEMS_SUCCESSFUL); } + + return state; +} + +static void action(void *arg) +{ + test_context *ctx = arg; + rtems_status_code sc; + + sc = rtems_semaphore_obtain( +ctx->semaphore_id, +RTEMS_WAIT, +2 + ); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); } -static bool test_body(void *arg) +static void prepare(void *arg) { test_context *ctx = arg; rtems_status_code sc; @@ -83,43 +98,59 @@ static bool test_body(void *arg) 0 ); rtems_test_assert(sc == RTEMS_SUCCESSFUL || sc == RTEMS_UNSATISFIED); +} - sc = rtems_semaphore_obtain( -ctx->semaphore_id, -RTEMS_WAIT, -2 +static void blocked(void *arg) +{ + test_context *ctx = arg; + rtems_status_code sc; + + T_interrupt_test_change_state( +T_INTERRUPT_TEST_ACTION, +T_INTERRUPT_TEST_LATE ); - rtems_test_assert(sc == RTEMS_SUCCESSFUL || sc == RTEMS_TIMEOUT); - return ctx->done; + sc = rtems_semaphore_release(ctx->semaphore_id); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); } -static void Init(rtems_task_argument ignored) +static const T_interrupt_test_config config = { + .prepare = prepare, + .action = action, + .interrupt = release_semaphore, + .blocked = blocked, + .max_iteration_count = 1 +}; + +T_TEST_CASE(InterruptSemaphoreObtain) { - test_context *ctx = &ctx_instance; + test_context ctx; rtems_status_code sc; + T_interrupt_test_state state; - TEST_BEGIN(); - - ctx->main_task_control = _Thread_Get_executing(); + ctx.main_task_control = _Thread_Get_executing(); sc = rtems_semaphore_create( rtems_build_name('S', 'E', 'M', 'A'), 1, RTEMS_SIMPLE_BINARY_SEMAPHO
[PATCH 25/33] spintrcritical15: Use T_interrupt_test()
--- testsuites/sptests/Makefile.am| 4 +- testsuites/sptests/spintrcritical15/init.c| 133 -- .../spintrcritical15/spintrcritical15.scn | 34 - 3 files changed, 117 insertions(+), 54 deletions(-) diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index 7dbc829ddf..0cf00f7fa6 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1310,9 +1310,7 @@ if TEST_spintrcritical15 sp_tests += spintrcritical15 sp_screens += spintrcritical15/spintrcritical15.scn sp_docs += spintrcritical15/spintrcritical15.doc -spintrcritical15_SOURCES = spintrcritical15/init.c \ - spintrcritical_support/intrcritical.c \ - spintrcritical_support/intrcritical.h +spintrcritical15_SOURCES = spintrcritical15/init.c spintrcritical15_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical15) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support diff --git a/testsuites/sptests/spintrcritical15/init.c b/testsuites/sptests/spintrcritical15/init.c index 9de33b3cfb..ba917d2a0b 100644 --- a/testsuites/sptests/spintrcritical15/init.c +++ b/testsuites/sptests/spintrcritical15/init.c @@ -1,4 +1,6 @@ /* + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * * COPYRIGHT (c) 1989-2009. * On-Line Applications Research Corporation (OAR). * @@ -11,89 +13,133 @@ #include "config.h" #endif -#include -#include +#include +#include -const char rtems_test_name[] = "SPINTRCRITICAL 15"; +#include -/* forward declarations to avoid warnings */ -rtems_task Init(rtems_task_argument argument); -rtems_task Secondary_task(rtems_task_argument ignored); +const char rtems_test_name[] = "SPINTRCRITICAL 15"; #define INIT_PRIORITY 2 #define BLOCKER_PRIORITY 1 -rtems_id Secondary_task_id; -rtems_id Semaphore; +typedef struct { + rtems_id secondary_task_id; + rtems_id semaphore; + Thread_Control *main_thread; +} test_context; -rtems_task Secondary_task( - rtems_task_argument ignored -) +static rtems_task Secondary_task( rtems_task_argument arg ) { - rtems_status_code sc; + test_context *ctx; + rtems_status_code sc; + + ctx = (test_context *) arg; while (1) { -sc = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 ); -fatal_directive_status( sc, RTEMS_TIMEOUT, "rtems_semaphore_obtain" ); +sc = rtems_semaphore_obtain( ctx->semaphore, RTEMS_DEFAULT_OPTIONS, 1 ); +T_quiet_rsc( sc, RTEMS_TIMEOUT ); } } -static bool test_body( void *arg ) +static T_interrupt_test_state interrupt(void *arg) { - rtems_status_code sc; + test_context *ctx; + Thread_Wait_flags flags; + T_interrupt_test_state state; + + ctx = arg; + flags = _Thread_Wait_flags_get( ctx->main_thread ); + + if ( +flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_INTEND_TO_BLOCK ) + ) { +state = T_INTERRUPT_TEST_DONE; + } else if ( +flags == ( THREAD_WAIT_CLASS_OBJECT | THREAD_WAIT_STATE_BLOCKED ) + ) { +state = T_INTERRUPT_TEST_LATE; + } else { +state = T_INTERRUPT_TEST_EARLY; + } - (void) arg; + return state; +} - sc = rtems_task_restart( Secondary_task_id, 1 ); - rtems_test_assert( sc == RTEMS_SUCCESSFUL ); +static void prepare( void *arg ) +{ + test_context *ctx; + rtems_status_code sc; - sc = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 ); - rtems_test_assert( sc == RTEMS_TIMEOUT ); + ctx = arg; + sc = rtems_task_restart( ctx->secondary_task_id, (rtems_task_argument) ctx ); + T_quiet_rsc_success( sc ); +} - return false; +static void action( void *arg ) +{ + test_context *ctx; + rtems_status_code sc; + + ctx = arg; + sc = rtems_semaphore_obtain( ctx->semaphore, RTEMS_DEFAULT_OPTIONS, 1 ); + T_quiet_rsc( sc, RTEMS_TIMEOUT ); } -rtems_task Init( - rtems_task_argument ignored -) +static const T_interrupt_test_config config = { + .prepare = prepare, + .action = action, + .interrupt = interrupt, + .max_iteration_count = 1 +}; + +T_TEST_CASE( SemaphoreObtainBlockedInterrupt ) { - rtems_status_code sc; + test_context ctx; + rtems_status_code sc; + T_interrupt_test_state state; - TEST_BEGIN(); - puts( -"Init - Trying to generate timeout of a thread while another is blocking\n" -"Init - on the same thread queue\n" -"Init - There is no way for the test to know if it hits the case" - ); + ctx.main_thread = _Thread_Get_executing(); - puts( "Init - rtems_semaphore_create - OK" ); sc = rtems_semaphore_create( rtems_build_name( 'S', 'M', '1', ' ' ), 0, RTEMS_DEFAULT_ATTRIBUTES, RTEMS_NO_PRIORITY, -&Semaphore +&ctx.semaphore ); - directive_failed( sc, "rtems_semaphore_create of SM1" ); + T_assert_rsc_success( sc ); - puts( "Init - rtems_task_create - OK" ); sc = rtems_task_create( rtems_build_name( 'B', 'L', 'C', 'K' ), BLOCKER_PRIORITY, RTEMS_MINIMUM_STACK_S
[PATCH 16/33] libtest: Add T_interrupt_test()
Update #3199. --- cpukit/Makefile.am | 1 + cpukit/include/rtems/test.h | 28 ++ cpukit/libtest/t-test-interrupt.c | 420 testsuites/libtests/Makefile.am | 9 + testsuites/libtests/configure.ac| 1 + testsuites/libtests/ttest02/init.c | 176 ++ testsuites/libtests/ttest02/ttest02.doc | 11 + testsuites/libtests/ttest02/ttest02.scn | 37 +++ 8 files changed, 683 insertions(+) create mode 100644 cpukit/libtest/t-test-interrupt.c create mode 100644 testsuites/libtests/ttest02/init.c create mode 100644 testsuites/libtests/ttest02/ttest02.doc create mode 100644 testsuites/libtests/ttest02/ttest02.scn diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am index 89edaefb17..75e119ea3c 100644 --- a/cpukit/Makefile.am +++ b/cpukit/Makefile.am @@ -1864,6 +1864,7 @@ librtemstest_a_SOURCES += libtest/t-test-checks.c librtemstest_a_SOURCES += libtest/t-test-checks-eno.c librtemstest_a_SOURCES += libtest/t-test-checks-psx.c librtemstest_a_SOURCES += libtest/t-test-hash-sha256.c +librtemstest_a_SOURCES += libtest/t-test-interrupt.c librtemstest_a_SOURCES += libtest/t-test-malloc.c librtemstest_a_SOURCES += libtest/t-test-rtems.c librtemstest_a_SOURCES += libtest/t-test-rtems-context.c diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index 5d4c676d16..628efcb505 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -2360,6 +2360,34 @@ void T_busy(uint_fast32_t); uint_fast32_t T_get_one_clock_tick_busy(void); +typedef enum { + T_INTERRUPT_TEST_INITIAL, + T_INTERRUPT_TEST_ACTION, + T_INTERRUPT_TEST_BLOCKED, + T_INTERRUPT_TEST_CONTINUE, + T_INTERRUPT_TEST_DONE, + T_INTERRUPT_TEST_EARLY, + T_INTERRUPT_TEST_INTERRUPT, + T_INTERRUPT_TEST_LATE, + T_INTERRUPT_TEST_TIMEOUT +} T_interrupt_test_state; + +typedef struct { + void (*prepare)(void *); + void (*action)(void *); + T_interrupt_test_state (*interrupt)(void *); + void (*blocked)(void *); + uint32_t max_iteration_count; +} T_interrupt_test_config; + +T_interrupt_test_state T_interrupt_test_change_state(T_interrupt_test_state, +T_interrupt_test_state); + +T_interrupt_test_state T_interrupt_test_get_state(void); + +T_interrupt_test_state T_interrupt_test(const T_interrupt_test_config *config, +void *arg); + void T_report_hash_sha256(T_event, const char *); void T_check_heap(T_event, const char *); diff --git a/cpukit/libtest/t-test-interrupt.c b/cpukit/libtest/t-test-interrupt.c new file mode 100644 index 00..f97369105f --- /dev/null +++ b/cpukit/libtest/t-test-interrupt.c @@ -0,0 +1,420 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl + * + * @brief Implementation of T_interrupt_test(). + */ + +/* + * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#include +#include +#include +#include +#include +#include + +typedef T_interrupt_test_state (*T_interrupt_test_handler)(void *); + +#define T_INTERRUPT_SAMPLE_COUNT 8 + +typedef struct { + uint_fast32_t one_tick_busy; + int64_t t0; + Thread_Control *self; + Atomic_Uint state; + void (*prepare)(void *); + void (*action)(void *); + T_interrupt_test_state (*interrupt)(void *); + void (*blocked)(void *); + void *arg; + Watchdog_Control wdg; + User_extensions_Control ext; + T_fixture_node node; +} T_interrupt_context; + +typedef struct
[PATCH 31/33] spintrcritical23: Use T_interrupt_test()
--- testsuites/sptests/Makefile.am| 4 +- testsuites/sptests/spintrcritical23/init.c| 117 -- .../spintrcritical23/spintrcritical23.scn | 20 +++ 3 files changed, 97 insertions(+), 44 deletions(-) diff --git a/testsuites/sptests/Makefile.am b/testsuites/sptests/Makefile.am index f35eeed664..14826811dc 100644 --- a/testsuites/sptests/Makefile.am +++ b/testsuites/sptests/Makefile.am @@ -1370,9 +1370,7 @@ if TEST_spintrcritical23 sp_tests += spintrcritical23 sp_screens += spintrcritical23/spintrcritical23.scn sp_docs += spintrcritical23/spintrcritical23.doc -spintrcritical23_SOURCES = spintrcritical23/init.c \ - spintrcritical_support/intrcritical.h \ - spintrcritical_support/intrcritical.c +spintrcritical23_SOURCES = spintrcritical23/init.c spintrcritical23_CPPFLAGS = $(AM_CPPFLAGS) \ $(TEST_FLAGS_spintrcritical23) $(support_includes) \ -I$(top_srcdir)/spintrcritical_support diff --git a/testsuites/sptests/spintrcritical23/init.c b/testsuites/sptests/spintrcritical23/init.c index 70907f0112..6fbbaf37e0 100644 --- a/testsuites/sptests/spintrcritical23/init.c +++ b/testsuites/sptests/spintrcritical23/init.c @@ -1,11 +1,5 @@ /* - * Copyright (c) 2015, 2017 embedded brains GmbH. All rights reserved. - * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * + * Copyright (C) 2015, 2020 embedded brains GmbH (http://www.embedded-brains.de) * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -16,8 +10,8 @@ #include "config.h" #endif -#include -#include +#include +#include #include @@ -33,18 +27,26 @@ typedef struct { Scheduler_priority_Node *scheduler_node; rtems_task_priority priority_task; rtems_task_priority priority_interrupt; - bool done; + volatile bool early; + volatile bool late; } test_context; -static test_context ctx_instance; - -static void change_priority(rtems_id timer, void *arg) +static T_interrupt_test_state interrupt(void *arg) { - /* The arg is NULL */ - test_context *ctx = &ctx_instance; + test_context *ctx = arg; + T_interrupt_test_state state; rtems_interrupt_lock_context lock_context; unsigned int next_priority; + state = T_interrupt_test_change_state( +T_INTERRUPT_TEST_ACTION, +T_INTERRUPT_TEST_ACTION + ); + + if (state != T_INTERRUPT_TEST_ACTION) { +return T_INTERRUPT_TEST_CONTINUE; + } + rtems_interrupt_lock_acquire(&ctx->lock, &lock_context); next_priority = SCHEDULER_PRIORITY_UNMAP( @@ -67,16 +69,34 @@ static void change_priority(rtems_id timer, void *arg) priority_interrupt, &previous ); -rtems_test_assert(sc == RTEMS_SUCCESSFUL); -rtems_test_assert(previous == priority_task); +T_quiet_rsc_success(sc); +T_quiet_eq_u32(previous, priority_task); -ctx->done = true; +state = T_INTERRUPT_TEST_DONE; } else { rtems_interrupt_lock_release(&ctx->lock, &lock_context); + +if ( ctx->early ) { + state = T_INTERRUPT_TEST_EARLY; +} else if ( ctx->late ) { + state = T_INTERRUPT_TEST_LATE; +} else { + state = T_INTERRUPT_TEST_CONTINUE; +} } + + return state; } -static bool test_body(void *arg) +static void prepare(void *arg) +{ + test_context *ctx = arg; + + ctx->early = true; + ctx->late = false; +} + +static void action(void *arg) { test_context *ctx = arg; rtems_status_code sc; @@ -85,6 +105,7 @@ static bool test_body(void *arg) rtems_task_priority priority_task; rtems_task_priority priority_interrupt; rtems_task_priority previous; + T_interrupt_test_state state; rtems_interrupt_lock_acquire(&ctx->lock, &lock_context); @@ -96,44 +117,60 @@ static bool test_body(void *arg) rtems_interrupt_lock_release(&ctx->lock, &lock_context); + ctx->early = false; sc = rtems_task_set_priority( ctx->task_id, priority_task, &previous ); - rtems_test_assert(sc == RTEMS_SUCCESSFUL); - rtems_test_assert(previous == priority_last); + T_quiet_rsc_success(RTEMS_SUCCESSFUL); + T_quiet_eq_u32(previous, priority_last); + ctx->late = true; + + state = T_interrupt_test_change_state( +T_INTERRUPT_TEST_ACTION, +T_INTERRUPT_TEST_ACTION + ); - if (ctx->done) { + if (state == T_INTERRUPT_TEST_DONE) { sc = rtems_task_set_priority( ctx->task_id, RTEMS_CURRENT_PRIORITY, &previous ); -rtems_test_assert(sc == RTEMS_SUCCESSFUL); -rtems_test_assert(previous == priority_interrupt); +T_quiet_rsc_success(sc); +T_quiet_eq_u32(previous, priority_interrupt); } - - return ctx->done; } -static void Init(rtems_task_argument arg) -{ - test_context *ctx = &ctx_instance; +static const T_interrupt_test_config config = { + .prepare = prepare, + .action = action, + .interrupt = interrupt, + .max_iteration_count = 1 +}; - TEST_BEGIN(); - - rtems_interrupt_lock_initialize(&ctx->lock,
Re: [PATCH] score: Improve _Thread_Start() description
On Tue, Jul 21, 2020 at 7:23 AM Sebastian Huber wrote: > > --- > cpukit/include/rtems/score/threadimpl.h | 35 - > 1 file changed, 29 insertions(+), 6 deletions(-) > > diff --git a/cpukit/include/rtems/score/threadimpl.h > b/cpukit/include/rtems/score/threadimpl.h > index b4b85ffa90..355311867d 100644 > --- a/cpukit/include/rtems/score/threadimpl.h > +++ b/cpukit/include/rtems/score/threadimpl.h > @@ -211,14 +211,37 @@ bool _Thread_Initialize( > ); > > /** > - * @brief Initializes thread and executes it. > + * @brief Starts the specified thread. > * > - * This routine initializes the executable information for a thread > - * and makes it ready to execute. After this routine executes, the > - * thread competes with all other threads for CPU time. > + * If the thread is not in the dormant state, the routine returns immediately > + * false and performs no actions. > * > - * @param the_thread The thread to be started. > - * @param entry The thread entry information. > + * Otherwise, this routine initializes the executable information for the > + * thread and makes it ready to execute. After the call of this routine, the > + * thread competes with all other ready threads for CPU time. > + * > + * Then the routine enables the local interrupts as indicated by the ISR lock > + * context. > + * > + * Then the thread start user extensions are called with thread dispatching > + * disabled and interrupts enabled after making the thread ready. Please > note > + * that in SMP configurations, the thread switch and begin user extensions > may > + * be called in parallel on another processor. > + * > + * Then thread dispatching is enabled and another threads may execute before "other threads" or "another thread" > + * the routine returns. > + * > + * @param[in, out] the_thread is the thread to start. > + * > + * @param entry is the thread entry information. > + * > + * @param[in, out] is the ISR lock context which shall be used to disable the > + * local interrupts before the call of this routine. > + * > + * @retval true The thread was in the dormant state and was sucessefully > + * started. > + * > + * @retval false Otherwise. > */ Thanks, nice clarification > bool _Thread_Start( >Thread_Control *the_thread, > -- > 2.26.2 > > ___ > 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
Re: Reworking MIPS Fenv support
Hi Eshan, That sounds good and reasonable. Work with Joel to prepare your patches, and hopefully this time goes smoother. On Tue, Jul 21, 2020 at 5:32 AM Eshan Dhawan wrote: > > Hello everyone, > As I was reworking the MIPS fenv support > I realised it wasn't as bad as ARM fenv since there is no mangle files > There are just headers and extern inline function definitions in the fenv.c > file > That greatly decreased the margin of error > So, I though instead of complete rework > I make changes in the existing fenv-softfp.h file > So as it has softfloat similar to RISC-V > And as only either hard float or soft float definitions are picked at the > linking part > So the errors are not much likely to occur > > -- > Thanks > - Eshan ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [GSoC 2020]: Weekly thread: Preparing RSB recipies for EPICS
[UPDATE]: The error was actually a mismatch of names which was fixed with the following changes: --- diff --git a/source-builder/config/epics-7-1.cfg b/source-builder/config/epics-7-1.cfg index fe1fb458..ea25f284 100644 --- a/source-builder/config/epics-7-1.cfg +++ b/source-builder/config/epics-7-1.cfg @@ -10,7 +10,7 @@ %define epics_version 3afec267ab08568ea454789e562450b00feea5c0 -Name: epics-%{epics_version}-%{_host}-%{release} +Name: epicsBaseOwnPlayground-%{epics_version}-%{_host}-%{release} Summary: EPICS v%{epics_version} for target %{_target} on host %{_host} Version: %{epics_version} Release: %{release} @@ -19,7 +19,8 @@ URL:https://epics.mpg.de/ # # Source # -%source set epics --rsb-file=epics-%{epics_version}.zip https://github.com/hjunkes/epicsBaseOwnPlayground/archive/%{epics_version}.zip +%source set epics --rsb-file=epicsBaseOwnPlayground-%{epics_version}.tar.gz https://github.com/hjunkes/epicsBaseOwnPlayground/archive/%{epics_version}.tar.gz + # # Prepare the source code. @@ -27,25 +28,20 @@ URL: https://epics.mpg.de/ %prep build_top=$(pwd) - source_dir_epics="epics-%{epics_version}" + source_dir_epics="epicsBaseOwnPlayground-%{epics_version}" - %source setup epics -q -n epics-%{epics_version} + %source setup epics -q -n epicsBaseOwnPlayground-%{epics_version} cd ${build_top} %build build_top=$(pwd) - - - %{build_directory} - - mkdir -p ${build_dir} - cd ${build_dir} + cd ${source_dir_epics} - %{host_build_flags} + %{build_build_flags} - #cd ${source_dir_epics} + %{__make} PREFIX=%{_prefix} ./configure \ --prefix=%{_prefix} -- After this, I ran the command `../source-builder/sb-builder --prefix=/home/mritunjay/development --log=log_epics epics-7-1 --trace` again. The error that has come now was expected because the changes I made in epicsBaseOwnPlayground/configure file were done manually and here it has to be done through a script. The changes that I did manually were; in epics-base/configure/CONFIG_SITE > set > CROSS_COMPILER_TARGET_ARCHS= > What I entered: CROSS_COMPILER_TARGET_ARCHS= RTEMS-pc386-qemu > e.g. RTEMS-pc386 > or RTEMS-xilinx_zynq_a9_qemu > > in epics-base/configure/os there must be a file for the target used, > e.g. > CONFIG.Common.RTEMS-xilinx_zynq_a9_qemu > or > CONFIG.Common.RTEMS-pc386 > Checked. CONFIG.Common.RTEMS-pc386 was there > > Then you have to set in configure/os/CONFIG_SITE.Common.RTEMS > where to find RTEMS: > > # Where to find RTEMS > # > # APS: > #RTEMS_VERSION = 4.10.2 > #RTEMS_BASE = /usr/local/vw/rtems/rtems-$(RTEMS_VERSION) In my system, I entered this: #FHI RTEMS_VERSION = 5 RTEMS_BASE = /home/mritunjay/development/rtems/$(RTEMS_VERSION) I have a doubt on how to implement the above changes in the `source-builder/config/epics-7-1.cfg` to make it work. Do we have to write a patch? And what will be the best way to do it? The latest error looks somewhat like this which is because I have to change the configurations in epics directory. The question is how to accomplish it through the script. ../../configure/os/CONFIG.Common.RTEMS:36: /Users/junkes/MVME6100/RTEMS/rtems-5/powerpc-rtems5/beatnik/Makefile.inc: No such file or directory Thanks Mritunjay On Tue, Jul 21, 2020 at 4:09 AM Mritunjay Sharma < mritunjaysharma...@gmail.com> wrote: > Hello all, > > I went through the > https://docs.rtems.org/branches/master/user/rsb/index.html > and started writing a recipe for building EPICS 7. > > The code is based on a very raw idea just now and > so was expected to give errors. > > The code can be found here: > https://github.com/mritunjaysharma394/rtems-source-builder/blob/epics-support/source-builder/config/epics-7-1.cfg > > After this, just to check, what errors it might gave, > I ran the following command: > > ../source-builder/sb-builder --prefix=/home/mritunjay/development > --log=log_epics epics-7-1 --trace > > This gave me the following error: > > `+ cd epics-3afec267ab08568ea454789e562450b00feea5c0 > /home/mritunjay/development/rtems/src/rsb_GSoC/rtems/build/epics-3afec267ab08568ea454789e562450b00feea5c0-x86_64-linux-gnu-1/do-build: > 90: cd: can't cd to epics-3afec267ab08568ea454789e562450b00feea5c0 > shell cmd failed: /bin/sh -ex > > /home/mritunjay/development/rtems/src/rsb_GSoC/rtems/build/epics-3afec267ab08568ea454789e562450b00feea5c0-x86_64-linux-gnu-1/do-build > error: building > epics-3afec267ab08568ea454789e562450b00feea5c0-x86_64-linux-gnu-1` > > I think there seems to be some problem with naming the directory. > I request you all to kindly help with the error as well as please check > the code > to see if I am on the right path. > I am attaching the log and trace file as well. > > Thanks, > Mritunjay > > > ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 1/1] eng: Update test framework chapter
Thanks, a couple typos, and some suggestions for clarification. On Tue, Jul 21, 2020 at 8:49 AM Sebastian Huber wrote: > > Document the dynamic text fixtures, utility functions, and the interrupt > test support. > > Update #3199. > --- > eng/index.rst | 4 +- > eng/test-framework.rst| 185 -- > images/eng/interrupt-test.odg | Bin 0 -> 14829 bytes > images/eng/interrupt-test.pdf | Bin 0 -> 14153 bytes > images/eng/interrupt-test.png | Bin 0 -> 75272 bytes > 5 files changed, 178 insertions(+), 11 deletions(-) > create mode 100644 images/eng/interrupt-test.odg > create mode 100644 images/eng/interrupt-test.pdf > create mode 100644 images/eng/interrupt-test.png > > diff --git a/eng/index.rst b/eng/index.rst > index 8f91c5e..f6b02ec 100644 > --- a/eng/index.rst > +++ b/eng/index.rst > @@ -11,8 +11,8 @@ RTEMS Software Engineering (|version|) > > .. topic:: Copyrights and License > > -| |copy| 2018, 2019 embedded brains GmbH > -| |copy| 2018, 2019 Sebastian Huber > +| |copy| 2018, 2020 embedded brains GmbH > +| |copy| 2018, 2020 Sebastian Huber > | |copy| 1988, 2015 On-Line Applications Research Corporation (OAR) > > .. include:: ../common/license.rst > diff --git a/eng/test-framework.rst b/eng/test-framework.rst > index b6411b5..582718d 100644 > --- a/eng/test-framework.rst > +++ b/eng/test-framework.rst > @@ -1,7 +1,7 @@ > .. SPDX-License-Identifier: CC-BY-SA-4.0 > > -.. Copyright (C) 2018, 2019 embedded brains GmbH > -.. Copyright (C) 2018, 2019 Sebastian Huber > +.. Copyright (C) 2018, 2020 embedded brains GmbH > +.. Copyright (C) 2018, 2020 Sebastian Huber > > Software Test Framework > *** > @@ -144,13 +144,41 @@ macro followed by a function body: > > The test case `name` must be a valid C designator. The test case names must > be > unique within the test suite. The `fixture` must point to a statically > -initialized read-only object of type `T_fixture`. The test fixture > -provides methods to setup, stop and tear down a test case. A context is > passed > -to the methods. The initial context is defined by the read-only fixture > -object. The context can be obtained by the `T_fixture_context()` > -function. It can be set within the scope of one test case by the > -`T_set_fixture_context()` function. This can be used for example to > -dynamically allocate a test environment in the setup method. > +initialized read-only object of type `T_fixture`. > + > +.. code-block:: c > + > +typedef struct T_fixture { > +void (*setup)(void *context); > +void (*stop)(void *context); > +void (*teardown)(void *context); > +void (*scope)(void *context, char *buffer, size_t size); > +void *initial_context; > +} T_fixture; > + > +The test fixture provides methods to setup, stop, and teardown a test case as > +well as to give the scope for log messags. A context is passed to each of > the typo: messages > +methods. The initial context is defined by the read-only fixture object. > The > +context can be obtained by the `T_fixture_context()` function. It can be set "setting" the context means changing the value of initial_context to point elsewhere? This would mean the fixture is not read-only > +within the scope of one test case by the `T_set_fixture_context()` function. > +This can be used for example to dynamically allocate a test environment in > the > +setup method. > + > +The test case fixtures of a test case are organized as a stack. Fixtures can > +be dynamically added to a test case and removed from a test case via the > +`T_push_fixture()` and `T_pop_fixture()` functions. > + > +.. code-block:: c > + > +void *T_push_fixture(T_fixture_node *node, const T_fixture *fixture); > + > +void T_pop_fixture(void); > + > +The `T_push_fixture()` function needs an uninitialized fixture node which > must > +exist until `T_pop_fixture()` is called. It returns the initial context of > the > +fixture. At the end of a test case all pushed fixtures are popped > +automatically. A call of `T_pop_fixture()` invokes the teardown method of > the > +fixture and must correspond to a previous call to `T_push_fixture()`. > > .. code-block:: c > :caption: Test Fixture Example > @@ -1028,6 +1056,34 @@ RTEMS, floating-point operations are only supported in > special tasks and may be > forbidden in interrupt context. The formatted output functions provided by > the > test framework work in every context. > > +Utility > +--- > + > +You can stop a test case via the ``T_stop()`` function. This function does > not > +return. You can indicate unreachable code paths with the ``T_unreachable()`` > +function. If this function is called, then the test case stops. > + > +You can busy wait with the ``T_busy()`` function: > + > +.. code-block:: c > + > +void T_busy(uint_fast32_t count); > + > +It performs a busy loop with the specified iteration
Re: [GSoC 2020]: Weekly thread: Preparing RSB recipies for EPICS
On Tue, Jul 21, 2020 at 10:42 AM Mritunjay Sharma wrote: > > [UPDATE]: The error was actually a mismatch of names which was fixed with the > following > changes: > --- > > diff --git a/source-builder/config/epics-7-1.cfg > b/source-builder/config/epics-7-1.cfg > index fe1fb458..ea25f284 100644 > --- a/source-builder/config/epics-7-1.cfg > +++ b/source-builder/config/epics-7-1.cfg > @@ -10,7 +10,7 @@ > > %define epics_version 3afec267ab08568ea454789e562450b00feea5c0 > > -Name: epics-%{epics_version}-%{_host}-%{release} > +Name: epicsBaseOwnPlayground-%{epics_version}-%{_host}-%{release} > Summary: EPICS v%{epics_version} for target %{_target} on host %{_host} > Version: %{epics_version} > Release: %{release} > @@ -19,7 +19,8 @@ URL: https://epics.mpg.de/ > # > # Source > # > -%source set epics --rsb-file=epics-%{epics_version}.zip > https://github.com/hjunkes/epicsBaseOwnPlayground/archive/%{epics_version}.zip > +%source set epics --rsb-file=epicsBaseOwnPlayground-%{epics_version}.tar.gz > https://github.com/hjunkes/epicsBaseOwnPlayground/archive/%{epics_version}.tar.gz > + > > # > # Prepare the source code. > @@ -27,25 +28,20 @@ URL: https://epics.mpg.de/ > %prep >build_top=$(pwd) > > - source_dir_epics="epics-%{epics_version}" > + source_dir_epics="epicsBaseOwnPlayground-%{epics_version}" > > - %source setup epics -q -n epics-%{epics_version} > + %source setup epics -q -n epicsBaseOwnPlayground-%{epics_version} > We will eventually want this to work from the upstream EPICS. >cd ${build_top} > > %build >build_top=$(pwd) > > - > - > - %{build_directory} > - > - mkdir -p ${build_dir} > - cd ${build_dir} > + cd ${source_dir_epics} > > - %{host_build_flags} > + %{build_build_flags} > > - #cd ${source_dir_epics} > + %{__make} PREFIX=%{_prefix} > >./configure \ > --prefix=%{_prefix} > > > -- > > After this, I ran the command > > `../source-builder/sb-builder --prefix=/home/mritunjay/development > --log=log_epics epics-7-1 --trace` > > again. The error that has come now was expected because the changes I made in > epicsBaseOwnPlayground/configure file > > were done manually and here it has to be done through a script. The changes > that I did manually were; >> >> in epics-base/configure/CONFIG_SITE >> set >> CROSS_COMPILER_TARGET_ARCHS= > >What I entered: >CROSS_COMPILER_TARGET_ARCHS= RTEMS-pc386-qemu >> >> e.g. RTEMS-pc386 >> or RTEMS-xilinx_zynq_a9_qemu >> >> in epics-base/configure/os there must be a file for the target used, >> e.g. >> CONFIG.Common.RTEMS-xilinx_zynq_a9_qemu >> or >> CONFIG.Common.RTEMS-pc386 > > Checked. CONFIG.Common.RTEMS-pc386 was there >> >> >> Then you have to set in configure/os/CONFIG_SITE.Common.RTEMS >> where to find RTEMS: >> >> # Where to find RTEMS >> # >> # APS: >> #RTEMS_VERSION = 4.10.2 >> #RTEMS_BASE = /usr/local/vw/rtems/rtems-$(RTEMS_VERSION) > > > In my system, I entered this: > #FHI > RTEMS_VERSION = 5 > RTEMS_BASE = /home/mritunjay/development/rtems/$(RTEMS_VERSION) > > I have a doubt on how to implement the above changes in the > `source-builder/config/epics-7-1.cfg` to make it work. > > Do we have to write a patch? And what will be the best way to do it? > This is a good question. These configuration changes need to be populated somehow based on the target being built. If this is only doable by writing files directly, then we'll probably need a way to apply patches for each different target. This seems unwieldy, so further thought should be considered on how to configure EPICS based on the RTEMS BSP build. You can start with a manually-created patch file, but eventually we need something that can be used across different BSPs / architectures. > The latest error looks somewhat like this which is because I have to change > the configurations in epics directory. > > The question is how to accomplish it through the script. > > ../../configure/os/CONFIG.Common.RTEMS:36: > /Users/junkes/MVME6100/RTEMS/rtems-5/powerpc-rtems5/beatnik/Makefile.inc: No > such file or directory > > > > Thanks > > Mritunjay > > > > On Tue, Jul 21, 2020 at 4:09 AM Mritunjay Sharma > wrote: >> >> Hello all, >> >> I went through the https://docs.rtems.org/branches/master/user/rsb/index.html >> and started writing a recipe for building EPICS 7. >> >> The code is based on a very raw idea just now and >> so was expected to give errors. >> >> The code can be found here: >> https://github.com/mritunjaysharma394/rtems-source-builder/blob/epics-support/source-builder/config/epics-7-1.cfg >> >> After this, just to check, what errors it might gave, >> I ran the following command: >> >> ../source-builder/sb-builder --prefix=/home/mritunjay/development >> --log=log_epics epics-7-1 --trace >> >> This gave me the following error: >> >> `+ cd epics-3afec267ab08568ea454789e562450b00feea5c0 >> /home/mritunjay/development/rtems/src/rsb_GSoC/rtems/b
[PATCH] Removed Soft float from MIPS
This Patch removes Soft Float code from MIPS. Instead It adds the soft float code from RISCV Signed-off-by: Eshan dhawan --- .../machine/mips/machine/fenv-softfloat.h | 55 +++ newlib/libm/machine/mips/fenv.c | 10 2 files changed, 21 insertions(+), 44 deletions(-) diff --git a/newlib/libc/machine/mips/machine/fenv-softfloat.h b/newlib/libc/machine/mips/machine/fenv-softfloat.h index cf13e73fc..7c8bc3a89 100644 --- a/newlib/libc/machine/mips/machine/fenv-softfloat.h +++ b/newlib/libc/machine/mips/machine/fenv-softfloat.h @@ -50,16 +50,11 @@ * doesn't matter how you define them. */ #include -int __softfloat_float_exception_flags; -int __softfloat_float_exception_mask; -int __softfloat_float_rounding_mode; - __fenv_static inline int feclearexcept(int excepts) { - __softfloat_float_exception_flags &= ~excepts; return (0); } @@ -67,16 +62,14 @@ __fenv_static inline int fegetexceptflag(fexcept_t *flagp, int excepts) { - *flagp = __softfloat_float_exception_flags & excepts; return (0); + } __fenv_static inline int fesetexceptflag(const fexcept_t *flagp, int excepts) { - __softfloat_float_exception_flags &= ~excepts; - __softfloat_float_exception_flags |= *flagp & excepts; return (0); } @@ -84,7 +77,7 @@ __fenv_static inline int feraiseexcept(int excepts) { -return(excepts ? -ENOTSUP : 0 ); + return( excepts != 0 ); } @@ -92,21 +85,25 @@ __fenv_static inline int fetestexcept(int excepts) { - return (__softfloat_float_exception_flags & excepts); + return (0); } __fenv_static inline int fegetround(void) { - return (__softfloat_float_rounding_mode); +#ifdef FE_TONEAREST + return FE_TONEAREST; +#else + return 0; +#endif + } __fenv_static inline int fesetround(int rounding_mode) { - __softfloat_float_rounding_mode = rounding_mode; return (0); } @@ -114,19 +111,13 @@ __fenv_static inline int fegetenv(fenv_t *envp) { - __set_env(*envp, __softfloat_float_exception_flags, - __softfloat_float_exception_mask, __softfloat_float_rounding_mode); return (0); } __fenv_static inline int feholdexcept(fenv_t *envp) { - fenv_t __env; - - fegetenv(envp); - __softfloat_float_exception_flags = 0; - __softfloat_float_exception_mask = 0; + return (0); } @@ -134,19 +125,19 @@ __fenv_static inline int fesetenv(const fenv_t *envp) { - __softfloat_float_exception_flags = __env_flags(*envp); - __softfloat_float_exception_mask = __env_mask(*envp); - __softfloat_float_rounding_mode = __env_round(*envp); + return (0); } __fenv_static inline int feupdateenv(const fenv_t *envp) { - int __oflags = __softfloat_float_exception_flags; - fesetenv(envp); - feraiseexcept(__oflags); +#if defined FE_NOMASK_ENV && FE_ALL_EXCEPT != 0 + if (envp == FE_NOMASK_ENV) + return 1; +#endif + return (0); } @@ -157,26 +148,22 @@ feupdateenv(const fenv_t *envp) __fenv_static inline int feenableexcept(int __mask) { - int __omask = __softfloat_float_exception_mask; - - __softfloat_float_exception_mask |= __mask; - return (__omask); + + return (0); } __fenv_static inline int fedisableexcept(int __mask) { - int __omask = __softfloat_float_exception_mask; - - __softfloat_float_exception_mask &= ~__mask; - return (__omask); + + return (0); } __fenv_static inline int fegetexcept(void) { - return (__softfloat_float_exception_mask); + return (0); } #endif /* __BSD_VISIBLE */ diff --git a/newlib/libm/machine/mips/fenv.c b/newlib/libm/machine/mips/fenv.c index 6e4bb8f33..e2179eb20 100644 --- a/newlib/libm/machine/mips/fenv.c +++ b/newlib/libm/machine/mips/fenv.c @@ -44,20 +44,10 @@ * this as a default environment. */ - #ifdef __mips_soft_float -#define __set_env(env, flags, mask, rnd) env = ((flags) \ -| (mask)<<_FPUSW_SHIFT \ -| (rnd) << 24) -#define __env_flags(env)((env) & FE_ALL_EXCEPT) -#define __env_mask(env) (((env) >> _FPUSW_SHIFT)\ -& FE_ALL_EXCEPT) -#define __env_round(env)(((env) >> 24) & _ROUND_MASK) #include #endif - - extern inline int feclearexcept(int excepts); extern inline int fegetexceptflag(fexcept_t *flagp, int excepts); extern inline int fesetexceptflag(const fexcept_t *flagp, int excepts); -- 2.17.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [GSoC 2020]: Weekly thread: Preparing RSB recipies for EPICS
I cancelled the earlier message because the log file size was very big and could not be posted in the devel list. [UPDATE]: Applying PATCH for RTEMS-pc386 support to EPICS and making other changes in code worked and EPICS7 was successfully built and installed using the RSB recipe. Tha changes that made it work: - diff --git a/rtems/config/epics/epics-7-1.cfg b/rtems/config/epics/epics-7-1.cfg new file mode 100644 index ..ed1f768b --- /dev/null +++ b/rtems/config/epics/epics-7-1.cfg @@ -0,0 +1,28 @@ +# +# EPICS 3afec267ab08568ea454789e562450b00feea5c0 +# + +%if %{release} == %{nil} + %define release 1 +%endif + +#%include %{_configdir}/rtems-bsp.cfg + +# +# EPICS Version +# +%define epics_version 3afec267ab08568ea454789e562450b00feea5c0 + +#%hash sha512 epics-%{ntp_version}.tar.gz 8d76fc7e92b2ea6dd5031e6030a7aba4ff6fb3e19d3bc0153852509861be5d0960e70604814163caedb81f8315a451d78371f99634a50b55cfe1cbd2c69e3046 + +# +# Patch for RTEMS support. +# +%patch add epics -p1 file:///home/mritunjay/development/rtems/src/rsb_GSoC/rtems/patches/0001-Added-Support-for-RTEMS-pc386.patch + +#%hash sha512 rtems-ntp-4.2.6p5.diff 257223d207d0b77cde2b9d7add22e3b9d657b58998411d2e20d0b1adf36910be21f1277386c54c34f5d9616fccd29f721d007295708047ea7ae0270a00be25a0 + +# +# EPICS Build configuration +# +%include %{_configdir}/epics-7-1.cfg diff --git a/rtems/config/epics/epics-base.bset b/rtems/config/epics/epics-base.bset new file mode 100644 index ..550daad0 --- /dev/null +++ b/rtems/config/epics/epics-base.bset @@ -0,0 +1,26 @@ +# +# Build set for EPICS +# + +%define release 1 + +# +# RTEMS Version +# +%define rtems_version 5 + +# +# The RTEMS URL paths. +# +%include rtems-urls.bset + +# +# The RTEMS Package defines +# +%include rtems-package.bset + + +# +# Build EPICS. +# +epics/epics-7-1.cfg \ No newline at end of file diff --git a/source-builder/config/epics-7-1.cfg b/source-builder/config/epics-7-1.cfg index ea25f284..b18f62bd 100644 --- a/source-builder/config/epics-7-1.cfg +++ b/source-builder/config/epics-7-1.cfg @@ -31,6 +31,7 @@ URL: https://epics.mpg.de/ source_dir_epics="epicsBaseOwnPlayground-%{epics_version}" %source setup epics -q -n epicsBaseOwnPlayground-%{epics_version} + %patch setup epics -p1 cd ${build_top} @@ -43,10 +44,7 @@ URL: https://epics.mpg.de/ %{__make} PREFIX=%{_prefix} - ./configure \ ---prefix=%{_prefix} - - %{__make} %{?_smp_mflags} + #%{__make} %{?_smp_mflags} cd ${build_top} -- The changes can also be looked here: https://github.com/RTEMS/rtems-source-builder/compare/master...mritunjaysharma394:epics-support?expand=1 On Tue, Jul 21, 2020 at 10:23 PM Gedare Bloom wrote: > On Tue, Jul 21, 2020 at 10:42 AM Mritunjay Sharma > wrote: > > > > [UPDATE]: The error was actually a mismatch of names which was fixed > with the following > > changes: > > --- > > > > diff --git a/source-builder/config/epics-7-1.cfg > b/source-builder/config/epics-7-1.cfg > > index fe1fb458..ea25f284 100644 > > --- a/source-builder/config/epics-7-1.cfg > > +++ b/source-builder/config/epics-7-1.cfg > > @@ -10,7 +10,7 @@ > > > > %define epics_version 3afec267ab08568ea454789e562450b00feea5c0 > > > > -Name: epics-%{epics_version}-%{_host}-%{release} > > +Name: epicsBaseOwnPlayground-%{epics_version}-%{_host}-%{release} > > Summary: EPICS v%{epics_version} for target %{_target} on host > %{_host} > > Version: %{epics_version} > > Release: %{release} > > @@ -19,7 +19,8 @@ URL: https://epics.mpg.de/ > > # > > # Source > > # > > -%source set epics --rsb-file=epics-%{epics_version}.zip > https://github.com/hjunkes/epicsBaseOwnPlayground/archive/%{epics_version}.zip > > +%source set epics > --rsb-file=epicsBaseOwnPlayground-%{epics_version}.tar.gz > https://github.com/hjunkes/epicsBaseOwnPlayground/archive/%{epics_version}.tar.gz > > + > > > > # > > # Prepare the source code. > > @@ -27,25 +28,20 @@ URL: https://epics.mpg.de/ > > %prep > >build_top=$(pwd) > > > > - source_dir_epics="epics-%{epics_version}" > > + source_dir_epics="epicsBaseOwnPlayground-%{epics_version}" > > > > - %source setup epics -q -n epics-%{epics_version} > > + %source setup epics -q -n epicsBaseOwnPlayground-%{epics_version} > > > > We will eventually want this to work from the upstream EPICS. > Yes, I think we need to discuss it with Heinz when he is available. > > > >cd ${build_top} > > > > %build > >build_top=$(pwd) > > > > - > > - > > - %{build_directory} > > - > > - mkdir -p ${build_dir} > > - cd ${build_dir} > > + cd ${source_dir_epics} > > > > - %{host_build_flags} > > + %{build_build_flags} > > > > - #cd ${source_dir_epics} > > + %{__make} PREFIX=%{_prefix} > > > >./configure \ > > --prefix=%{_prefix} > > > > > > -- > > > > After this, I ran the comman
Re: [GSoC 2020]: Weekly thread: Preparing RSB recipies for EPICS
On Tue, Jul 21, 2020 at 2:16 PM Mritunjay Sharma wrote: > > I cancelled the earlier message because the log file size was very big > and could not be posted in the devel list. > > [UPDATE]: Applying PATCH for RTEMS-pc386 support to EPICS and > making other changes in code worked and EPICS7 was successfully built > and installed using the RSB recipe. > > Tha changes that made it work: > > - > diff --git a/rtems/config/epics/epics-7-1.cfg > b/rtems/config/epics/epics-7-1.cfg > new file mode 100644 > index ..ed1f768b > --- /dev/null > +++ b/rtems/config/epics/epics-7-1.cfg > @@ -0,0 +1,28 @@ > +# > +# EPICS 3afec267ab08568ea454789e562450b00feea5c0 > +# > + > +%if %{release} == %{nil} > + %define release 1 > +%endif > + > +#%include %{_configdir}/rtems-bsp.cfg > + > +# > +# EPICS Version > +# > +%define epics_version 3afec267ab08568ea454789e562450b00feea5c0 > + > +#%hash sha512 epics-%{ntp_version}.tar.gz > 8d76fc7e92b2ea6dd5031e6030a7aba4ff6fb3e19d3bc0153852509861be5d0960e70604814163caedb81f8315a451d78371f99634a50b55cfe1cbd2c69e3046 > + > +# > +# Patch for RTEMS support. > +# > +%patch add epics -p1 > file:///home/mritunjay/development/rtems/src/rsb_GSoC/rtems/patches/0001-Added-Support-for-RTEMS-pc386.patch > + > +#%hash sha512 rtems-ntp-4.2.6p5.diff > 257223d207d0b77cde2b9d7add22e3b9d657b58998411d2e20d0b1adf36910be21f1277386c54c34f5d9616fccd29f721d007295708047ea7ae0270a00be25a0 > + > +# > +# EPICS Build configuration > +# > +%include %{_configdir}/epics-7-1.cfg > diff --git a/rtems/config/epics/epics-base.bset > b/rtems/config/epics/epics-base.bset > new file mode 100644 > index ..550daad0 > --- /dev/null > +++ b/rtems/config/epics/epics-base.bset > @@ -0,0 +1,26 @@ > +# > +# Build set for EPICS > +# > + > +%define release 1 > + > +# > +# RTEMS Version > +# > +%define rtems_version 5 > + > +# > +# The RTEMS URL paths. > +# > +%include rtems-urls.bset > + > +# > +# The RTEMS Package defines > +# > +%include rtems-package.bset > + > + > +# > +# Build EPICS. > +# > +epics/epics-7-1.cfg > \ No newline at end of file > diff --git a/source-builder/config/epics-7-1.cfg > b/source-builder/config/epics-7-1.cfg > index ea25f284..b18f62bd 100644 > --- a/source-builder/config/epics-7-1.cfg > +++ b/source-builder/config/epics-7-1.cfg > @@ -31,6 +31,7 @@ URL: https://epics.mpg.de/ >source_dir_epics="epicsBaseOwnPlayground-%{epics_version}" > >%source setup epics -q -n epicsBaseOwnPlayground-%{epics_version} > + %patch setup epics -p1 > >cd ${build_top} > > @@ -43,10 +44,7 @@ URL: https://epics.mpg.de/ > >%{__make} PREFIX=%{_prefix} > > - ./configure \ > ---prefix=%{_prefix} > - > - %{__make} %{?_smp_mflags} > + #%{__make} %{?_smp_mflags} > >cd ${build_top} > -- > > The changes can also be looked here: > https://github.com/RTEMS/rtems-source-builder/compare/master...mritunjaysharma394:epics-support?expand=1 > > > > > > On Tue, Jul 21, 2020 at 10:23 PM Gedare Bloom wrote: >> >> On Tue, Jul 21, 2020 at 10:42 AM Mritunjay Sharma >> wrote: >> > >> > [UPDATE]: The error was actually a mismatch of names which was fixed with >> > the following >> > changes: >> > --- >> > >> > diff --git a/source-builder/config/epics-7-1.cfg >> > b/source-builder/config/epics-7-1.cfg >> > index fe1fb458..ea25f284 100644 >> > --- a/source-builder/config/epics-7-1.cfg >> > +++ b/source-builder/config/epics-7-1.cfg >> > @@ -10,7 +10,7 @@ >> > >> > %define epics_version 3afec267ab08568ea454789e562450b00feea5c0 >> > >> > -Name: epics-%{epics_version}-%{_host}-%{release} >> > +Name: epicsBaseOwnPlayground-%{epics_version}-%{_host}-%{release} >> > Summary: EPICS v%{epics_version} for target %{_target} on host %{_host} >> > Version: %{epics_version} >> > Release: %{release} >> > @@ -19,7 +19,8 @@ URL: https://epics.mpg.de/ >> > # >> > # Source >> > # >> > -%source set epics --rsb-file=epics-%{epics_version}.zip >> > https://github.com/hjunkes/epicsBaseOwnPlayground/archive/%{epics_version}.zip >> > +%source set epics >> > --rsb-file=epicsBaseOwnPlayground-%{epics_version}.tar.gz >> > https://github.com/hjunkes/epicsBaseOwnPlayground/archive/%{epics_version}.tar.gz >> > + >> > >> > # >> > # Prepare the source code. >> > @@ -27,25 +28,20 @@ URL: https://epics.mpg.de/ >> > %prep >> >build_top=$(pwd) >> > >> > - source_dir_epics="epics-%{epics_version}" >> > + source_dir_epics="epicsBaseOwnPlayground-%{epics_version}" >> > >> > - %source setup epics -q -n epics-%{epics_version} >> > + %source setup epics -q -n epicsBaseOwnPlayground-%{epics_version} >> > >> >> We will eventually want this to work from the upstream EPICS. > > > Yes, I think we need to discuss it with Heinz when he is available. > >> >> >> >> >cd ${build_top} >> > >> > %build >> >build_top=$(pwd) >> > >> > - >> > - >> > - %{build_
Re: [PATCH rtems v2 3/3] bsps/fdt: Make sure data is cache aligned.
Hello Gedare, I'll re-check to make absolutely sure and push it afterwards. Best regards Christian On 20/07/2020 22:01, Gedare Bloom wrote: > looks good if it works, thanks Christian! > > On Sun, Jul 19, 2020 at 11:47 PM Christian Mauderer > wrote: >> >> The cache of the fdt blob is flushed after copy. Therefore it should be >> aligned. >> --- >> bsps/shared/start/bsp-fdt.c | 8 +--- >> 1 file changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/bsps/shared/start/bsp-fdt.c b/bsps/shared/start/bsp-fdt.c >> index 7e8d8922a8..50a485eb16 100644 >> --- a/bsps/shared/start/bsp-fdt.c >> +++ b/bsps/shared/start/bsp-fdt.c >> @@ -29,10 +29,11 @@ >> >> #ifdef BSP_FDT_BLOB_READ_ONLY >> static const uint32_t >> -bsp_fdt_blob[BSP_FDT_BLOB_SIZE_MAX / sizeof(uint32_t)] = { 0xdeadbeef }; >> +bsp_fdt_blob[BSP_FDT_BLOB_SIZE_MAX / sizeof(uint32_t)] >> CPU_STRUCTURE_ALIGNMENT = >> + { 0xdeadbeef }; >> #else >> static uint32_t >> -bsp_fdt_blob[BSP_FDT_BLOB_SIZE_MAX / sizeof(uint32_t)]; >> +bsp_fdt_blob[BSP_FDT_BLOB_SIZE_MAX / sizeof(uint32_t)] >> CPU_STRUCTURE_ALIGNMENT; >> #endif >> >> void bsp_fdt_copy(const void *src) >> @@ -48,6 +49,7 @@ void bsp_fdt_copy(const void *src) >> >>if (s != d) { >> size_t m = MIN(sizeof(bsp_fdt_blob), fdt_totalsize(src)); >> +size_t aligned_size = roundup2(m, CPU_CACHE_LINE_BYTES); >> size_t n = (m + sizeof(*d) - 1) / sizeof(*d); >> size_t i; >> >> @@ -55,7 +57,7 @@ void bsp_fdt_copy(const void *src) >>d[i] = s[i]; >> } >> >> -rtems_cache_flush_multiple_data_lines(d, m); >> +rtems_cache_flush_multiple_data_lines(d, aligned_size); >>} >> } >> >> -- >> 2.26.2 >> -- embedded brains GmbH Herr Christian Mauderer Dornierstr. 4 D-82178 Puchheim Germany email: christian.maude...@embedded-brains.de Phone: +49-89-18 94 741 - 18 Fax: +49-89-18 94 741 - 08 PGP: Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 01/33] libtest: to
On 22/7/20 1:04 am, Sebastian Huber wrote: > Rename this header file to later move to . Should we have ? Using a test directory makes the naming easier, for example . Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 00/33] Test framework improvements
On 22/7/20 1:04 am, Sebastian Huber wrote: > This patch set adds a couple of improvements to the test framework: > > * The header file changes from to . > > * Support for a stack of test fixtures. This helps to write test > building blocks. > > * The test check messages are now optional. > > * The support for interrupt tests and change all the interrupt critical > tests to use this new test support. This should address the sporadic > failures and timeouts. > > For the documentation please have a look at: > > https://ftp.rtems.org/pub/rtems/people/sebh/eng2.pdf > I assume you asking us to look only at section 8? The doco looks good. The following are some review comment: 8.1 a) Supported languages? 8.1.1 a) The wording ".. outcome all right, ..." seems non-specific for someting I would assume needs to be specific. What about " ... is not the required outcome for the test, ..."? b) As previously discussed there are a few more states a test result can be other than pass and fail and I thikn the wording here may need tightening. I am not sure what is needed. Also how do resource leaks effect the result? 8.1.2 a) It test case naming to be specified or can be use anything we like, ie lower case with `_`, Camelcase, ...? b) Change "static constructors" to "static C constructors". 8.1.3 a) Change "test case as well as to give thescope for log messags." to " test case as well as the scope for log messages." b) Change "function. It can be set within the scope of one .." to "function and can be set within the scope of one .." c) Does the framework provide a standard way to export a dynamic test environment so the test and the results can be reviewed as a complete set of data? 8.1.4 a) Should "Each non-quiet test check fetches.." be "A non-quiet test check fetches.."? 8.1.5 a) Change "..if various resources are leaked .." to ".. if various resources have leaked ..". 8.1.7 a) Change "You can add test case destructors with T_add_destructor(). They are.." to "A test case destructor can be added with T_add_destructor(). The destructors are..". b) Maybe add it is best to use statically allocated memory only? 8.1.8 a) "Meet its expecation" ... I am not sure what this means, who expecation and what does expecation mean? Do you mean " .. test check meets the check's exepected outcome."? b) I am not sure what "The actual value ..." is referring to. The value the test expects to be the input from the test to the check? Ah coming back to here, I see this is in the next bit. Would adding a little bit in the text before using the special words like actual and expected be helpful? c) I think the T_assert_ etc variants of the test checks should be explained somewhere. I think it is important to know tests can continue even after a fail or they can be made to stop. I had noted I had not seen this documented and I have now found it buried in here. d) I think the word `available` can be removed from the initial sentence on all sub-sectons? 8.1.8.10 a) I think type variant piece of test should be moved to the top and add to the initial sentence so you have " are available where the type variant `xyz` must be ...". 8.1.8.12 a) What about 0 or EINTR as OK? :) 8.1.6 a) Are the printf variants check for type correctness by the compiler? If so I suggest this is mentioned. 8.1.11 a) Can "You can .." be removed so it is not person specific? For example "You can convert time into ticks with the" ciuld be "The time can be converted into ticks with the"? This comment covers all the "You can"s. :) 8.1.13 a) What is the picture drawn in? I will comment on the patches as well. Chris > Sebastian Huber (33): > libtest: to > libtest: Move to > libtest: Add T_busy() > libtest: Add T_get_one_clock_tick_busy() > libtest: Add T_make_runner() > libtest: Support custom scope messages via fixture > libtest: Add push/pop fixture support > libtest: Add T_get_scope() > libtest: Split POSIX Keys support > libtest: Add T_stop() > libtest: Add T_CHECK_FMT > libtest: Make check message optional > libtest: Add T_unreachable() > libtest: Add quiet assert NULL pointer checks > libtest: Add rtems_test_run() > libtest: Add T_interrupt_test() > psxintrcritical01: Use T_interrupt_test() > spintrcritical01/2/3/4/5: Use T_interrupt_test() > spintrcritical06/spintrcritical07: Remove tests > spintrcritical08: Use T_interrupt_test() > spintrcritical09: Use T_interrupt_test() > spintrcritical10: Use T_interrupt_test() > spintrcritical11/12: Use T_interrupt_test() > spintrcritical13/14: Use T_interrupt_test() > spintrcritical15: Use T_interrupt_test() > spintrcritical16: Use T_interrupt_test() > spintrcritical18: Use T_interrupt_test() > spintrcritical20: Use T_interrupt_test() > spintrcritical21: Use T_interrupt_test() > spintrcritical22: Use T_interrupt_test() > spintrcritical23: Use T_interrupt_test() > spintrcritical24: Use T_interrupt_test() > spintrc
Re: [PATCH 05/33] libtest: Add T_make_runner()
On 22/7/20 1:04 am, Sebastian Huber wrote: > Update #3199. > --- > cpukit/include/rtems/test.h | 2 ++ > cpukit/libtest/t-test.c | 10 -- > 2 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h > index b68f303e16..a1a976d7ff 100644 > --- a/cpukit/include/rtems/test.h > +++ b/cpukit/include/rtems/test.h > @@ -2209,6 +2209,8 @@ void T_putchar_default(int, void *); > > int T_main(const T_config *); > > +void T_make_runner(void); > + > bool T_is_runner(void); > > void T_run_initialize(const T_config *); > diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c > index 16018335c9..a0336fa461 100644 > --- a/cpukit/libtest/t-test.c > +++ b/cpukit/libtest/t-test.c > @@ -330,7 +330,7 @@ T_scope(char *buf) > } > > static void > -T_set_runner(T_context *ctx) > +T_do_make_runner(T_context *ctx) > { > #ifdef __rtems__ > ISR_Level level; Indenting 4 or 2 spaces? > @@ -353,6 +353,12 @@ T_set_runner(T_context *ctx) > #endif > } > > +void > +T_make_runner(void) > +{ > + T_do_make_runner(&T_instance); > +} > + > int > T_printf(char const *fmt, ...) > { > @@ -719,7 +725,7 @@ T_do_run_initialize(const T_config *config) > ctx->overall_steps = 0; > ctx->overall_failures = 0; > > - T_set_runner(ctx); > + T_do_make_runner(ctx); > T_actions_forward(config, T_EVENT_RUN_INITIALIZE_EARLY, config->name); > T_do_log(ctx, T_QUIET, "A:%s\n", config->name); > T_system(ctx); Same here? This comment is also for all the remaining files in touched by the patches. I see a mix. Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 05/33] libtest: Add T_make_runner()
On 22/07/2020 07:04, Chris Johns wrote: On 22/7/20 1:04 am, Sebastian Huber wrote: Update #3199. --- cpukit/include/rtems/test.h | 2 ++ cpukit/libtest/t-test.c | 10 -- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index b68f303e16..a1a976d7ff 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -2209,6 +2209,8 @@ void T_putchar_default(int, void *); int T_main(const T_config *); +void T_make_runner(void); + bool T_is_runner(void); void T_run_initialize(const T_config *); diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c index 16018335c9..a0336fa461 100644 --- a/cpukit/libtest/t-test.c +++ b/cpukit/libtest/t-test.c @@ -330,7 +330,7 @@ T_scope(char *buf) } static void -T_set_runner(T_context *ctx) +T_do_make_runner(T_context *ctx) { #ifdef __rtems__ ISR_Level level; Indenting 4 or 2 spaces? @@ -353,6 +353,12 @@ T_set_runner(T_context *ctx) #endif } +void +T_make_runner(void) +{ + T_do_make_runner(&T_instance); +} + int T_printf(char const *fmt, ...) { @@ -719,7 +725,7 @@ T_do_run_initialize(const T_config *config) ctx->overall_steps = 0; ctx->overall_failures = 0; - T_set_runner(ctx); + T_do_make_runner(ctx); T_actions_forward(config, T_EVENT_RUN_INITIALIZE_EARLY, config->name); T_do_log(ctx, T_QUIET, "A:%s\n", config->name); T_system(ctx); Same here? This comment is also for all the remaining files in touched by the patches. I see a mix. The test framework uses the BSD coding style. The core implementation is done in C11 and is portable to FreeBSD, MSYS2, and Linux. The indentation level is one tab. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 01/33] libtest: to
On 22/07/2020 07:05, Chris Johns wrote: On 22/7/20 1:04 am, Sebastian Huber wrote: Rename this header file to later move to . Should we have ? Using a test directory makes the naming easier, for example . That would be fine for me, but I don't like a . ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 05/33] libtest: Add T_make_runner()
On 22/7/20 3:10 pm, Sebastian Huber wrote: > On 22/07/2020 07:04, Chris Johns wrote: > >> On 22/7/20 1:04 am, Sebastian Huber wrote: >>> Update #3199. >>> --- >>> cpukit/include/rtems/test.h | 2 ++ >>> cpukit/libtest/t-test.c | 10 -- >>> 2 files changed, 10 insertions(+), 2 deletions(-) >>> >>> diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h >>> index b68f303e16..a1a976d7ff 100644 >>> --- a/cpukit/include/rtems/test.h >>> +++ b/cpukit/include/rtems/test.h >>> @@ -2209,6 +2209,8 @@ void T_putchar_default(int, void *); >>> int T_main(const T_config *); >>> +void T_make_runner(void); >>> + >>> bool T_is_runner(void); >>> void T_run_initialize(const T_config *); >>> diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c >>> index 16018335c9..a0336fa461 100644 >>> --- a/cpukit/libtest/t-test.c >>> +++ b/cpukit/libtest/t-test.c >>> @@ -330,7 +330,7 @@ T_scope(char *buf) >>> } >>> static void >>> -T_set_runner(T_context *ctx) >>> +T_do_make_runner(T_context *ctx) >>> { >>> #ifdef __rtems__ >>> ISR_Level level; >> Indenting 4 or 2 spaces? >> >>> @@ -353,6 +353,12 @@ T_set_runner(T_context *ctx) >>> #endif >>> } >>> +void >>> +T_make_runner(void) >>> +{ >>> + T_do_make_runner(&T_instance); >>> +} >>> + >>> int >>> T_printf(char const *fmt, ...) >>> { >>> @@ -719,7 +725,7 @@ T_do_run_initialize(const T_config *config) >>> ctx->overall_steps = 0; >>> ctx->overall_failures = 0; >>> - T_set_runner(ctx); >>> + T_do_make_runner(ctx); >>> T_actions_forward(config, T_EVENT_RUN_INITIALIZE_EARLY, config->name); >>> T_do_log(ctx, T_QUIET, "A:%s\n", config->name); >>> T_system(ctx); >> Same here? >> >> This comment is also for all the remaining files in touched by the patches. I >> see a mix. > The test framework uses the BSD coding style. The core implementation is done > in > C11 and is portable to FreeBSD, MSYS2, and Linux. The indentation level is > one tab. As in a real tab character? Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel