diff options
Diffstat (limited to 'cpukit/libtest')
32 files changed, 1523 insertions, 118 deletions
diff --git a/cpukit/libtest/gcovdumpinfo.c b/cpukit/libtest/gcovdumpinfo.c new file mode 100644 index 0000000000..87021ad613 --- /dev/null +++ b/cpukit/libtest/gcovdumpinfo.c @@ -0,0 +1,96 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSImplGcov + * + * @brief This source file contains the implementation of _Gcov_Ddump_info(). + */ + +/* + * Copyright (C) 2021, 2022 embedded brains GmbH & Co. KG + * + * 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 <rtems/test-gcov.h> + +typedef struct { + IO_Put_char put_char; + void *arg; +} Gcov_Context; + +static void _Gcov_Dump( const void *data, unsigned length, void *arg ) +{ + Gcov_Context *ctx; + IO_Put_char put_char; + void *ctx_arg; + const char *in; + const void *end; + + ctx = arg; + in = data; + end = in + length; + put_char = ctx->put_char; + ctx_arg = ctx->arg; + + while ( in != end ) { + ( *put_char )( *in, ctx_arg ); + ++in; + } +} + +static void _Gcov_Filename( const char *filename, void *arg ) +{ + __gcov_filename_to_gcfn( filename, _Gcov_Dump, arg ); +} + +static void *_Gcov_Allocate( unsigned length, void *arg ) +{ + (void) length; + (void) arg; + return NULL; +} + +void _Gcov_Dump_info( IO_Put_char put_char, void *arg ) +{ + Gcov_Context ctx; + const struct gcov_info * const *item; + + ctx.put_char = put_char; + ctx.arg = arg; + + RTEMS_LINKER_SET_FOREACH( gcov_info, item ) { + __gcov_info_to_gcda( + *item, + _Gcov_Filename, + _Gcov_Dump, + _Gcov_Allocate, + &ctx + ); + } +} diff --git a/cpukit/libtest/gcovdumpinfobase64.c b/cpukit/libtest/gcovdumpinfobase64.c new file mode 100644 index 0000000000..62cd89ac7e --- /dev/null +++ b/cpukit/libtest/gcovdumpinfobase64.c @@ -0,0 +1,110 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSImplGcov + * + * @brief This source file contains the implementation of + * _Gcov_Dump_info_base64(). + */ + +/* + * Copyright (C) 2021, 2022 embedded brains GmbH & Co. KG + * + * 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 <rtems/test-gcov.h> + +#include <limits.h> +#include <string.h> + +#include <rtems/base64.h> + +typedef struct { + IO_Put_char put_char; + void *arg; + int out; + size_t index; + char buf[ 57 ]; +} Gcov_Base64_context; + +static void _Gcov_Base64_put_char( int c, void *arg ) +{ + Gcov_Base64_context *ctx; + + ctx = arg; + + ( *ctx->put_char )( c, ctx->arg ); + ++ctx->out; + + if ( ctx->out >= 76 ) { + ctx->out = 0; + ( *ctx->put_char )( '\n', ctx->arg ); + } +} + +static void _Gcov_Base64_encode( int c, void *arg ) +{ + Gcov_Base64_context *ctx; + size_t index; + + ctx = arg; + index = ctx->index; + ctx->buf[ index ] = (char) c; + + if ( index == RTEMS_ARRAY_SIZE( ctx->buf ) - 1 ) { + index = 0; + _Base64_Encode( + _Gcov_Base64_put_char, + ctx, + ctx->buf, + sizeof( ctx->buf ), + NULL, + INT_MAX + ); + } else { + ++index; + } + + ctx->index = index; +} + +void _Gcov_Dump_info_base64( IO_Put_char put_char, void *arg ) +{ + Gcov_Base64_context ctx; + + memset( &ctx, 0, sizeof( ctx ) ); + ctx.put_char = put_char; + ctx.arg = arg; + _Gcov_Dump_info( _Gcov_Base64_encode, &ctx ); + + if ( ctx.index > 0 ) { + _Base64_Encode( put_char, arg, ctx.buf, ctx.index, NULL, INT_MAX ); + ( *put_char )( '\n', arg ); + } +} diff --git a/cpukit/libtest/gcovinfoset.c b/cpukit/libtest/gcovinfoset.c new file mode 100644 index 0000000000..284c993d32 --- /dev/null +++ b/cpukit/libtest/gcovinfoset.c @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSImplGcov + * + * @brief This source file contains the definition of the gcov information + * linker set. + */ + +/* + * Copyright (C) 2021, 2022 embedded brains GmbH & Co. KG + * + * 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 <rtems/test-gcov.h> + +RTEMS_LINKER_ROSET( gcov_info, const struct gcov_info * ); diff --git a/cpukit/libtest/t-test-busy-tick.c b/cpukit/libtest/t-test-busy-tick.c index f83c8360c6..5e45757f24 100644 --- a/cpukit/libtest/t-test-busy-tick.c +++ b/cpukit/libtest/t-test-busy-tick.c @@ -5,11 +5,12 @@ * * @ingroup RTEMSTestFrameworkImpl * - * @brief Implementation of T_get_one_clock_tick_busy(). + * @brief This source file contains the implementation of + * T_get_one_clock_tick_busy(). */ /* - * Copyright (C) 2014, 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2014, 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/libtest/t-test-busy.c b/cpukit/libtest/t-test-busy.c index 3bf149b8bb..e28fa3e5e4 100644 --- a/cpukit/libtest/t-test-busy.c +++ b/cpukit/libtest/t-test-busy.c @@ -5,11 +5,12 @@ * * @ingroup RTEMSTestFrameworkImpl * - * @brief Implementation of T_busy(). + * @brief This source file contains the implementation of + * T_busy(). */ /* - * Copyright (C) 2014, 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2014, 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/libtest/t-test-checks-eno.c b/cpukit/libtest/t-test-checks-eno.c index b80f1d110c..48736915b4 100644 --- a/cpukit/libtest/t-test-checks-eno.c +++ b/cpukit/libtest/t-test-checks-eno.c @@ -1,7 +1,16 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl * - * Copyright (C) 2018 embedded brains GmbH + * @brief This source file contains the implementation of + * T_strerror(), T_check_eno(), and T_check_eno_success(). + */ + +/* + * Copyright (C) 2018 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/libtest/t-test-checks-psx.c b/cpukit/libtest/t-test-checks-psx.c index fe2b375b8f..5d6ec25bda 100644 --- a/cpukit/libtest/t-test-checks-psx.c +++ b/cpukit/libtest/t-test-checks-psx.c @@ -1,3 +1,39 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl + * + * @brief This source file contains the implementation of + * T_check_psx_error() and T_check_psx_success(). + */ + +/* + * Copyright (C) 2019 embedded brains GmbH & Co. KG + * + * 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. + */ + #include <rtems/test.h> #include <errno.h> diff --git a/cpukit/libtest/t-test-checks.c b/cpukit/libtest/t-test-checks.c index c86596521b..b83e83f1f3 100644 --- a/cpukit/libtest/t-test-checks.c +++ b/cpukit/libtest/t-test-checks.c @@ -1,7 +1,16 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl * - * Copyright (C) 2018 embedded brains GmbH + * @brief This source file contains the implementation of various RTEMS Test + * Framework check functions. + */ + +/* + * Copyright (C) 2018 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,27 +39,27 @@ #include <inttypes.h> void -T_check_eq_ptr(const T_check_context_msg *t, const void *a, const void *e) +T_check_eq_ptr(const T_check_context_msg *t, uintptr_t a, uintptr_t e) { T_check(&t->base, a == e, "%s", t->msg); } void -T_check_ne_ptr(const T_check_context_msg *t, const void *a, const void *e) +T_check_ne_ptr(const T_check_context_msg *t, uintptr_t a, uintptr_t e) { T_check(&t->base, a != e, "%s", t->msg); } void -T_check_null(const T_check_context_msg *t, const void *a) +T_check_null(const T_check_context_msg *t, uintptr_t a) { - T_check(&t->base, a == NULL, "%s == NULL", t->msg); + T_check(&t->base, a == 0, "%s == NULL", t->msg); } void -T_check_not_null(const T_check_context_msg *t, const void *a) +T_check_not_null(const T_check_context_msg *t, uintptr_t a) { - T_check(&t->base, a != NULL, "%s != NULL", t->msg); + T_check(&t->base, a != 0, "%s != NULL", t->msg); } void diff --git a/cpukit/libtest/t-test-hash-sha256.c b/cpukit/libtest/t-test-hash-sha256.c index 32e946b4cf..79da4b5dfb 100644 --- a/cpukit/libtest/t-test-hash-sha256.c +++ b/cpukit/libtest/t-test-hash-sha256.c @@ -1,7 +1,16 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file * - * Copyright (C) 2019, 2021 embedded brains GmbH + * @ingroup RTEMSTestFrameworkImpl + * + * @brief This source file contains the implementation of + * T_report_hash_sha256_update() and T_report_hash_sha256(). + */ + +/* + * Copyright (C) 2019, 2021 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,7 +35,6 @@ */ #include <rtems/test.h> -#include <rtems/score/io.h> #include <limits.h> @@ -36,6 +44,8 @@ #include <openssl/sha.h> #endif +#include <rtems/base64.h> + typedef struct { SHA256_CTX sha256; T_putchar putchar; @@ -44,6 +54,15 @@ typedef struct { static T_report_hash_sha256_context T_report_hash_sha256_instance; +void +T_report_hash_sha256_update(char c) +{ + T_report_hash_sha256_context *ctx; + + ctx = &T_report_hash_sha256_instance; + SHA256_Update(&ctx->sha256, &c, sizeof(c)); +} + static void T_report_hash_sha256_putchar(int c, void *arg) { @@ -76,7 +95,7 @@ T_report_hash_sha256_finalize(void) ctx = &T_report_hash_sha256_instance; SHA256_Final(hash, &ctx->sha256); T_printf("Y:ReportHash:SHA256:"); - (void)_IO_Base64url(ctx->putchar, ctx->putchar_arg, hash, + (void)_Base64url_Encode(ctx->putchar, ctx->putchar_arg, hash, sizeof(hash), NULL, INT_MAX); T_printf("\n"); } diff --git a/cpukit/libtest/t-test-interrupt.c b/cpukit/libtest/t-test-interrupt.c index 5d83b7876a..8796dc0b5a 100644 --- a/cpukit/libtest/t-test-interrupt.c +++ b/cpukit/libtest/t-test-interrupt.c @@ -5,11 +5,12 @@ * * @ingroup RTEMSTestFrameworkImpl * - * @brief Implementation of T_interrupt_test(). + * @brief This source file contains the implementation of + * T_interrupt_test(). */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -456,9 +457,16 @@ T_interrupt_test(const T_interrupt_test_config *config, void *arg) lower_bound[sample] = lower - delta; sample = (sample + 1) % T_INTERRUPT_SAMPLE_COUNT; - } else if (state == T_INTERRUPT_TEST_LATE) { + } else if (state == T_INTERRUPT_TEST_LATE || + state == T_INTERRUPT_TEST_ACTION) { uint_fast32_t upper; + /* + * If the state is T_INTERRUPT_TEST_ACTION, then there + * was probably no interrupt during the action, so the + * interrupt would be late. + */ + lower_sum -= lower_bound[sample]; lower_sum += busy; lower_bound[sample] = busy; diff --git a/cpukit/libtest/t-test-rtems-context.c b/cpukit/libtest/t-test-rtems-context.c index 8d33d08866..1405db0c7d 100644 --- a/cpukit/libtest/t-test-rtems-context.c +++ b/cpukit/libtest/t-test-rtems-context.c @@ -1,7 +1,16 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file * - * Copyright (C) 2019 embedded brains GmbH + * @ingroup RTEMSTestFrameworkImpl + * + * @brief This source file contains the implementation of + * T_check_task_context(). + */ + +/* + * Copyright (C) 2019 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -63,6 +72,7 @@ T_do_check_task_context(void) rtems_task_priority prio; rtems_status_code sc; uint32_t v; + rtems_event_set events; #ifdef RTEMS_SMP rtems_id id; #endif @@ -95,6 +105,14 @@ T_do_check_task_context(void) T_check(&T_special, prio == T_runner_priority, "Wrong runner priority, expected %" PRIu32 ", actual %" PRIu32, T_runner_priority, prio); + + sc = rtems_event_receive(RTEMS_ALL_EVENTS, + RTEMS_NO_WAIT | RTEMS_EVENT_ANY, 0, &events); + T_quiet_rsc( sc, RTEMS_UNSATISFIED ); + + sc = rtems_event_system_receive(RTEMS_ALL_EVENTS, + RTEMS_NO_WAIT | RTEMS_EVENT_ANY, 0, &events); + T_quiet_rsc( sc, RTEMS_UNSATISFIED ); } void diff --git a/cpukit/libtest/t-test-rtems-fds.c b/cpukit/libtest/t-test-rtems-fds.c index 8d3ac882e9..2b520972d2 100644 --- a/cpukit/libtest/t-test-rtems-fds.c +++ b/cpukit/libtest/t-test-rtems-fds.c @@ -1,7 +1,16 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl * - * Copyright (C) 2018 embedded brains GmbH + * @brief This source file contains the implementation of + * T_check_file_descriptors(). + */ + +/* + * Copyright (C) 2018 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/libtest/t-test-rtems-heap.c b/cpukit/libtest/t-test-rtems-heap.c index 9b9e8a73ec..2fb069a50e 100644 --- a/cpukit/libtest/t-test-rtems-heap.c +++ b/cpukit/libtest/t-test-rtems-heap.c @@ -1,7 +1,16 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl * - * Copyright (C) 2018 embedded brains GmbH + * @brief This source file contains the implementation of + * T_check_heap(). + */ + +/* + * Copyright (C) 2018 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/libtest/t-test-rtems-measure.c b/cpukit/libtest/t-test-rtems-measure.c index b75aff0d1a..2a2376cd27 100644 --- a/cpukit/libtest/t-test-rtems-measure.c +++ b/cpukit/libtest/t-test-rtems-measure.c @@ -1,7 +1,16 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file * - * Copyright (C) 2018, 2021 embedded brains GmbH + * @ingroup RTEMSTestFrameworkImpl + * + * @brief This source file contains the implementation of + * T_measure_runtime(). + */ + +/* + * Copyright (C) 2018, 2021 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -241,14 +250,14 @@ T_measure_runtime_create(const T_measure_runtime_config *config) ctx->sample_count = config->sample_count; ctx->samples = add_offset(ctx, sizeof(*ctx)); + ctx->samples = align_up(ctx->samples, cache_line_size); ctx->cache_line_size = cache_line_size; ctx->chunk_size = chunk_size; ctx->chunk = add_offset(ctx->samples, sample_size); + ctx->chunk = align_up(ctx->chunk, cache_line_size); ctx->runner = rtems_task_self(); ctx->load_count = load_count; ctx->load_contexts = add_offset(ctx->chunk, chunk_size); - ctx->samples = align_up(ctx->samples, cache_line_size); - ctx->chunk = align_up(ctx->chunk, cache_line_size); for (i = 0; i < load_count; ++i) { rtems_id id; @@ -378,13 +387,12 @@ report_sorted_samples(const T_measure_runtime_context *ctx) sample_count = ctx->sample_count; samples = ctx->samples; - last = 0; - --last; - count = 0; + last = samples[0]; + v = samples[0]; + count = 1; - for (i = 0; i < sample_count; ++i) { + for (i = 1; i < sample_count; ++i) { v = samples[i]; - ++count; if (v != last) { uint32_t sa; @@ -393,24 +401,28 @@ report_sorted_samples(const T_measure_runtime_context *ctx) uint32_t nsb; T_time t; - T_time_to_seconds_and_nanoseconds(T_ticks_to_time(last), - &sa, &nsa); - t = T_ticks_to_time(v); - T_time_to_seconds_and_nanoseconds(t, &sb, &nsb); + t = T_ticks_to_time(last); + T_time_to_seconds_and_nanoseconds(t, &sa, &nsa); + T_time_to_seconds_and_nanoseconds(T_ticks_to_time(v), + &sb, &nsb); if (sa != sb || nsa != nsb) { T_printf("M:S:%zu:%s\n", count, T_time_to_string_ns(t, ts)); - count = 0; + count = 1; + } else { + ++count; } last = v; + } else { + ++count; } } if (count > 0) { T_printf("M:S:%zu:%s\n", count, - T_ticks_to_string_ns(last, ts)); + T_ticks_to_string_ns(v, ts)); } } diff --git a/cpukit/libtest/t-test-rtems-memory.c b/cpukit/libtest/t-test-rtems-memory.c index 92d21a7ccd..ed0908ae10 100644 --- a/cpukit/libtest/t-test-rtems-memory.c +++ b/cpukit/libtest/t-test-rtems-memory.c @@ -1,7 +1,16 @@ /* SPDX-License-Identifier: BSD-2-Clause */ +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl + * + * @brief This source file contains the implementation of + * T_memory_allocate(), T_memory_deallocate(), and T_memory_action(). + */ + /* - * Copyright (C) 2020 embedded brains GmbH + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/libtest/t-test-rtems-objs.c b/cpukit/libtest/t-test-rtems-objs.c index 6548848c49..ce752424b5 100644 --- a/cpukit/libtest/t-test-rtems-objs.c +++ b/cpukit/libtest/t-test-rtems-objs.c @@ -3,13 +3,14 @@ /** * @file * - * @ingroup RTEMSTestFramework + * @ingroup RTEMSTestFrameworkImpl * - * @brief RTEMS Objects Support for Test Framework + * @brief This source file contains the implementation of the RTEMS objects + * test support. */ /* - * Copyright (C) 2018 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2018 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/libtest/t-test-rtems-posix-keys.c b/cpukit/libtest/t-test-rtems-posix-keys.c index 3046fbb6c8..65153d3d33 100644 --- a/cpukit/libtest/t-test-rtems-posix-keys.c +++ b/cpukit/libtest/t-test-rtems-posix-keys.c @@ -3,13 +3,14 @@ /** * @file * - * @ingroup RTEMSTestFramework + * @ingroup RTEMSTestFrameworkImpl * - * @brief RTEMS POSIX Keys Support for Test Framework + * @brief This source file contains the implementation of + * T_check_posix_keys(). */ /* - * Copyright (C) 2018 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2018 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/libtest/t-test-rtems.c b/cpukit/libtest/t-test-rtems.c index 71d8057aaf..d4fc6827af 100644 --- a/cpukit/libtest/t-test-rtems.c +++ b/cpukit/libtest/t-test-rtems.c @@ -1,7 +1,16 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl * - * Copyright (C) 2018 embedded brains GmbH + * @brief This source file contains the implementation of + * T_putchar_default(), T_check_rsc(), and T_check_rsc_success(). + */ + +/* + * Copyright (C) 2018 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/libtest/t-test-rtems.h b/cpukit/libtest/t-test-rtems.h index cc36ba96a1..d429c4f5bd 100644 --- a/cpukit/libtest/t-test-rtems.h +++ b/cpukit/libtest/t-test-rtems.h @@ -3,13 +3,14 @@ /** * @file * - * @ingroup RTEMSTestFrameworkImpl + * @ingroup RTEMSTestFramework * - * @brief RTEMS Support for Test Framework + * @brief This header file provides the RTEMS-specific API of the RTEMS Test + * Framework. */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/libtest/t-test-scheduler.c b/cpukit/libtest/t-test-scheduler.c new file mode 100644 index 0000000000..d9df0cc97b --- /dev/null +++ b/cpukit/libtest/t-test-scheduler.c @@ -0,0 +1,658 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl + * + * @brief This source file contains the implementation of the scheduler test + * support API. + */ + +/* + * Copyright (C) 2021 embedded brains GmbH & Co. KG + * + * 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 <rtems/test-scheduler.h> + +#include <rtems.h> +#include <rtems/score/percpu.h> +#include <rtems/score/schedulerimpl.h> + +typedef struct { + RTEMS_INTERRUPT_LOCK_MEMBER(lock) + T_scheduler_log *active; + T_scheduler_event_handler handler; + void *arg; +} T_scheduler_context; + +static T_scheduler_context T_scheduler_instance = { +#ifdef RTEMS_SMP + .lock = RTEMS_INTERRUPT_LOCK_INITIALIZER("Test Scheduler"), +#endif + .active = NULL +}; + +void +T_scheduler_set_event_handler(T_scheduler_event_handler handler, void *arg) +{ + T_scheduler_context *ctx; + rtems_interrupt_lock_context lock_context; + + ctx = &T_scheduler_instance; + + rtems_interrupt_lock_acquire(&ctx->lock, &lock_context); + ctx->handler = handler; + ctx->arg = arg; + rtems_interrupt_lock_release(&ctx->lock, &lock_context); +} + +static void +T_scheduler_before_operation(T_scheduler_event *event) +{ + T_scheduler_context *ctx; + rtems_interrupt_lock_context lock_context; + T_scheduler_log *log; + T_scheduler_event_handler handler; + void *arg; + Per_CPU_Control *cpu_self; + + ctx = &T_scheduler_instance; + log = ctx->active; + handler = ctx->handler; + + if (log == NULL && handler == NULL) { + return; + } + + rtems_interrupt_lock_interrupt_disable(&lock_context); + cpu_self = _Per_CPU_Get(); + event->cpu = _Per_CPU_Get_index( cpu_self ); + + if (_Per_CPU_Is_ISR_in_progress(cpu_self)) { + event->executing = NULL; + } else { + event->executing = _Per_CPU_Get_executing(cpu_self); + } + + event->instant = T_now(); + + rtems_interrupt_lock_acquire_isr(&ctx->lock, &lock_context); + handler = ctx->handler; + arg = ctx->arg; + rtems_interrupt_lock_release(&ctx->lock, &lock_context); + + if (handler != NULL) { + (*handler)(arg, event, T_SCHEDULER_BEFORE); + } +} + +static void +T_scheduler_record_event(T_scheduler_event *event) +{ + T_scheduler_context *ctx; + rtems_interrupt_lock_context lock_context; + T_scheduler_log *log; + T_scheduler_event_handler handler; + + ctx = &T_scheduler_instance; + log = ctx->active; + handler = ctx->handler; + + if (log == NULL && handler == NULL) { + return; + } + + rtems_interrupt_lock_acquire(&ctx->lock, &lock_context); + +#ifdef RTEMS_SMP + handler = ctx->handler; +#endif + + if (handler != NULL) { + void *arg; + + arg = ctx->arg; + + rtems_interrupt_lock_release(&ctx->lock, &lock_context); + (*handler)(arg, event, T_SCHEDULER_AFTER); + rtems_interrupt_lock_acquire(&ctx->lock, &lock_context); + } + +#ifdef RTEMS_SMP + log = ctx->active; +#endif + + if (log != NULL) { + size_t recorded; + + ++log->header.operations; + recorded = log->header.recorded; + + if (recorded < log->header.capacity) { + log->header.recorded = recorded + 1; + log->events[recorded] = *event; + } + } + + rtems_interrupt_lock_release(&ctx->lock, &lock_context); +} + +T_scheduler_log * +T_scheduler_record(T_scheduler_log *log) +{ + rtems_interrupt_lock_context lock_context; + T_scheduler_log *previous; + T_scheduler_context *ctx; + + if (log != NULL) { + log->header.recorded = 0; + log->header.operations = 0; + } + + ctx = &T_scheduler_instance; + + rtems_interrupt_lock_acquire(&ctx->lock, &lock_context); + previous = ctx->active; + ctx->active = log; + rtems_interrupt_lock_release(&ctx->lock, &lock_context); + + return previous; +} + +T_scheduler_log * +T_scheduler_record_2(T_scheduler_log_2 *log) +{ + log->header.capacity = T_ARRAY_SIZE(log->events); + return T_scheduler_record((T_scheduler_log *)log); +} + +T_scheduler_log * +T_scheduler_record_4(T_scheduler_log_4 *log) +{ + log->header.capacity = T_ARRAY_SIZE(log->events); + return T_scheduler_record((T_scheduler_log *)log); +} + +T_scheduler_log * +T_scheduler_record_10(T_scheduler_log_10 *log) +{ + log->header.capacity = T_ARRAY_SIZE(log->events); + return T_scheduler_record((T_scheduler_log *)log); +} + +T_scheduler_log * +T_scheduler_record_20(T_scheduler_log_20 *log) +{ + log->header.capacity = T_ARRAY_SIZE(log->events); + return T_scheduler_record((T_scheduler_log *)log); +} + +T_scheduler_log * +T_scheduler_record_40(T_scheduler_log_40 *log) +{ + log->header.capacity = T_ARRAY_SIZE(log->events); + return T_scheduler_record((T_scheduler_log *)log); +} + +const T_scheduler_event T_scheduler_event_null; + +const T_scheduler_event * +T_scheduler_next(T_scheduler_header *header, T_scheduler_operation operation, + size_t *index) +{ + T_scheduler_log *log; + size_t i; + + log = (T_scheduler_log *)header; + + if (log == NULL) { + return &T_scheduler_event_null; + } + + i = *index; + + while (i < log->header.recorded) { + if (operation == T_SCHEDULER_ANY || + operation == log->events[i].operation) { + *index = i + 1; + return &log->events[i]; + } + + ++i; + } + + return &T_scheduler_event_null; +} + +const T_scheduler_event * +T_scheduler_next_any(T_scheduler_header *header, size_t *index) +{ + return T_scheduler_next(header, T_SCHEDULER_ANY, index); +} + +void +T_scheduler_initialize(const Scheduler_Control *scheduler) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_INITIALIZE + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + T_scheduler_before_operation(&event); + (*operations->initialize)(scheduler); + T_scheduler_record_event(&event); +} + +void +T_scheduler_schedule(const Scheduler_Control *scheduler, + Thread_Control *thread) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_SCHEDULE, + .thread = thread + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + T_scheduler_before_operation(&event); + (*operations->schedule)(scheduler, thread); + T_scheduler_record_event(&event); +} + +void +T_scheduler_yield(const Scheduler_Control *scheduler, Thread_Control *thread, + Scheduler_Node *node) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_YIELD, + .thread = thread, + .node = node + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + T_scheduler_before_operation(&event); + (*operations->yield)(scheduler, thread, node); + T_scheduler_record_event(&event); +} + +void +T_scheduler_block(const Scheduler_Control *scheduler, Thread_Control *thread, + Scheduler_Node *node) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_BLOCK, + .thread = thread, + .node = node + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + T_scheduler_before_operation(&event); + (*operations->block)(scheduler, thread, node); + T_scheduler_record_event(&event); +} + +void +T_scheduler_unblock(const Scheduler_Control *scheduler, Thread_Control *thread, + Scheduler_Node *node) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_UNBLOCK, + .thread = thread, + .node = node + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + T_scheduler_before_operation(&event); + (*operations->unblock)(scheduler, thread, node); + T_scheduler_record_event(&event); +} + +void +T_scheduler_update_priority(const Scheduler_Control *scheduler, + Thread_Control *thread, Scheduler_Node *node) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_UPDATE_PRIORITY, + .thread = thread, + .node = node + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + T_scheduler_before_operation(&event); + (*operations->update_priority)(scheduler, thread, node); + T_scheduler_record_event(&event); +} + +Priority_Control T_scheduler_map_priority(const Scheduler_Control *scheduler, + Priority_Control priority) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_MAP_PRIORITY + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + event.map_unmap_priority.in = priority; + T_scheduler_before_operation(&event); + event.map_unmap_priority.out = (*operations->map_priority)(scheduler, + priority); + T_scheduler_record_event(&event); + return event.map_unmap_priority.out; +} + +Priority_Control T_scheduler_unmap_priority(const Scheduler_Control *scheduler, + Priority_Control priority) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_UNMAP_PRIORITY + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + event.map_unmap_priority.in = priority; + T_scheduler_before_operation(&event); + event.map_unmap_priority.out = (*operations->unmap_priority)(scheduler, + priority); + T_scheduler_record_event(&event); + return event.map_unmap_priority.out; +} + +void +T_scheduler_node_initialize(const Scheduler_Control *scheduler, + Scheduler_Node *node, Thread_Control *thread, Priority_Control priority) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_NODE_INITIALIZE, + .thread = thread, + .node = node + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + T_scheduler_before_operation(&event); + (*operations->node_initialize)(scheduler, node, thread, priority); + T_scheduler_record_event(&event); +} + +void +T_scheduler_node_destroy(const Scheduler_Control *scheduler, + Scheduler_Node *node) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_NODE_DESTROY, + .node = node + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + T_scheduler_before_operation(&event); + (*operations->node_destroy)(scheduler, node); + T_scheduler_record_event(&event); +} + +void +T_scheduler_release_job(const Scheduler_Control *scheduler, + Thread_Control *thread, Priority_Node *priority, uint64_t deadline, + Thread_queue_Context *queue_context) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_RELEASE_JOB, + .thread = thread + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + event.release_job.priority = priority; + event.release_job.deadline = deadline; + T_scheduler_before_operation(&event); + (*operations->release_job)(scheduler, thread, priority, deadline, queue_context); + T_scheduler_record_event(&event); +} + +void +T_scheduler_cancel_job(const Scheduler_Control *scheduler, + Thread_Control *thread, Priority_Node *priority, + Thread_queue_Context *queue_context) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_CANCEL_JOB, + .thread = thread + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + event.cancel_job.priority = priority; + T_scheduler_before_operation(&event); + (*operations->cancel_job)(scheduler, thread, priority, queue_context); + T_scheduler_record_event(&event); +} + +void +T_scheduler_start_idle(const Scheduler_Control *scheduler, + Thread_Control *thread, Per_CPU_Control *cpu) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_START_IDLE, + .thread = thread + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + T_scheduler_before_operation(&event); + (*operations->start_idle)(scheduler, thread, cpu); + T_scheduler_record_event(&event); +} + +#ifdef RTEMS_SMP +bool +T_scheduler_ask_for_help(const Scheduler_Control *scheduler, + Thread_Control *thread, Scheduler_Node *node) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_ASK_FOR_HELP, + .thread = thread, + .node = node + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + T_scheduler_before_operation(&event); + event.ask_for_help.success = (*operations->ask_for_help)(scheduler, + thread, node); + T_scheduler_record_event(&event); + return event.ask_for_help.success; +} + +void +T_scheduler_reconsider_help_request(const Scheduler_Control *scheduler, + Thread_Control *thread, Scheduler_Node *node) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_RECONSIDER_HELP_REQUEST, + .thread = thread, + .node = node + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + T_scheduler_before_operation(&event); + (*operations->reconsider_help_request)(scheduler, thread, node); + T_scheduler_record_event(&event); +} + +void +T_scheduler_withdraw_node(const Scheduler_Control *scheduler, + Thread_Control *thread, Scheduler_Node *node, + Thread_Scheduler_state next_state) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_WITHDRAW_NODE, + .thread = thread, + .node = node + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + event.withdraw_node.next_state = next_state; + T_scheduler_before_operation(&event); + (*operations->withdraw_node)(scheduler, thread, node, next_state); + T_scheduler_record_event(&event); +} + +void +T_scheduler_make_sticky(const Scheduler_Control *scheduler, Thread_Control *thread, + Scheduler_Node *node) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_MAKE_STICKY, + .thread = thread, + .node = node + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + T_scheduler_before_operation(&event); + (*operations->make_sticky)(scheduler, thread, node); + T_scheduler_record_event(&event); +} + +void +T_scheduler_clean_sticky(const Scheduler_Control *scheduler, Thread_Control *thread, + Scheduler_Node *node) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_CLEAN_STICKY, + .thread = thread, + .node = node + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + T_scheduler_before_operation(&event); + (*operations->clean_sticky)(scheduler, thread, node); + T_scheduler_record_event(&event); +} + +void +T_scheduler_pin(const Scheduler_Control *scheduler, Thread_Control *thread, + Scheduler_Node *node, Per_CPU_Control *cpu) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_PIN, + .thread = thread, + .node = node + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + event.pin_unpin.cpu = cpu; + T_scheduler_before_operation(&event); + (*operations->pin)(scheduler, thread, node, cpu); + T_scheduler_record_event(&event); +} + +void +T_scheduler_unpin(const Scheduler_Control *scheduler, Thread_Control *thread, + Scheduler_Node *node, Per_CPU_Control *cpu) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_UNPIN, + .thread = thread, + .node = node + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + event.pin_unpin.cpu = cpu; + T_scheduler_before_operation(&event); + (*operations->unpin)(scheduler, thread, node, cpu); + T_scheduler_record_event(&event); +} + +void +T_scheduler_add_processor(const Scheduler_Control *scheduler, + Thread_Control *idle) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_ADD_PROCESSOR, + .thread = idle + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + event.add_processor.idle = idle; + T_scheduler_before_operation(&event); + (*operations->add_processor)(scheduler, idle); + T_scheduler_record_event(&event); +} + +Thread_Control * +T_scheduler_remove_processor(const Scheduler_Control *scheduler, + Per_CPU_Control *cpu) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_REMOVE_PROCESSOR + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + event.remove_processor.cpu = cpu; + T_scheduler_before_operation(&event); + event.remove_processor.idle = + (*operations->remove_processor)(scheduler, cpu); + T_scheduler_record_event(&event); + return event.remove_processor.idle; +} + +Status_Control +T_scheduler_set_affinity(const Scheduler_Control *scheduler, + Thread_Control *thread, Scheduler_Node *node, + const Processor_mask *affinity) +{ + T_scheduler_event event = { + .operation = T_SCHEDULER_SET_AFFINITY, + .thread = thread, + .node = node + }; + const Scheduler_Operations *operations; + + operations = &T_scheduler_operations[_Scheduler_Get_index(scheduler)]; + event.set_affinity.affinity = *affinity; + T_scheduler_before_operation(&event); + event.set_affinity.status = (*operations->set_affinity)(scheduler, + thread, node, affinity); + T_scheduler_record_event(&event); + return event.set_affinity.status; +} +#endif diff --git a/cpukit/libtest/t-test-thread-switch.c b/cpukit/libtest/t-test-thread-switch.c index 60179aaa40..99d2d7ee29 100644 --- a/cpukit/libtest/t-test-thread-switch.c +++ b/cpukit/libtest/t-test-thread-switch.c @@ -5,11 +5,12 @@ * * @ingroup RTEMSTestFrameworkImpl * - * @brief Implementation of T_thread_switch_record(). + * @brief This source file contains the implementation of the thread switch + * recorder. */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/libtest/t-test-time.c b/cpukit/libtest/t-test-time.c index c6a43acfc5..2acb75f799 100644 --- a/cpukit/libtest/t-test-time.c +++ b/cpukit/libtest/t-test-time.c @@ -1,7 +1,16 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl * - * Copyright (C) 2018 embedded brains GmbH + * @brief This source file contains the implementation of the time and ticks + * test support. + */ + +/* + * Copyright (C) 2018 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c index 0935a5ceb1..1230505edf 100644 --- a/cpukit/libtest/t-test.c +++ b/cpukit/libtest/t-test.c @@ -1,7 +1,16 @@ -/* - * SPDX-License-Identifier: BSD-2-Clause +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl * - * Copyright (C) 2018, 2020 embedded brains GmbH + * @brief This source file contains the core implementation of RTEMS Test + * Framework. + */ + +/* + * Copyright (C) 2018, 2023 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -37,7 +46,7 @@ #include <stdatomic.h> #ifdef __rtems__ -#include <rtems/score/io.h> +#include <rtems/dev/io.h> #include <rtems/score/percpu.h> #include <rtems/score/smp.h> #include <rtems/score/threadimpl.h> @@ -47,7 +56,7 @@ #include "t-test-printf.h" #endif /* __rtems__ */ -#define T_LINE_SIZE 128 +#define T_LINE_SIZE 256 typedef struct { pthread_spinlock_t lock; @@ -63,6 +72,7 @@ typedef struct { T_fixture_node *fixtures; T_fixture_node case_fixture; LIST_HEAD(, T_destructor) destructors; + T_remark remarks; T_time case_begin_time; atomic_uint planned_steps; atomic_uint steps; @@ -922,6 +932,23 @@ T_call_destructors(const T_context *ctx) #endif } +static void +T_make_remarks(T_context *ctx) +{ + T_remark *remark; + + remark = ctx->remarks.next; + + while (remark != &ctx->remarks) { + T_remark *current; + + current = remark; + remark = current->next; + current->next = NULL; + T_do_log(ctx, T_QUIET, "R:%s\n", current->remark); + } +} + static T_context * T_do_run_initialize(const T_config *config) { @@ -973,6 +1000,7 @@ T_do_case_begin(T_context *ctx, const T_case_context *tc) ctx->current_case = tc; ctx->fixtures = &ctx->case_fixture; LIST_INIT(&ctx->destructors); + ctx->remarks.next = &ctx->remarks; atomic_store_explicit(&ctx->planned_steps, UINT_MAX, memory_order_relaxed); atomic_store_explicit(&ctx->steps, 0, memory_order_relaxed); @@ -1024,6 +1052,7 @@ T_do_case_end(T_context *ctx, const T_case_context *tc) T_call_destructors(ctx); config = ctx->config; T_actions_backward(config, T_EVENT_CASE_END, tc->name); + T_make_remarks(ctx); planned_steps = atomic_fetch_add_explicit(&ctx->planned_steps, 0, memory_order_relaxed); @@ -1284,6 +1313,18 @@ T_pop_fixture(void) T_do_pop_fixture(&T_instance); } +void +T_add_remark(T_remark *remark) +{ + if (remark->next == NULL) { + T_context *ctx; + + ctx = &T_instance; + remark->next = ctx->remarks.next; + ctx->remarks.next = remark; + } +} + size_t T_get_scope(const char * const * const *desc, char *buf, size_t n, const size_t *second_indices) diff --git a/cpukit/libtest/testbeginend.c b/cpukit/libtest/testbeginend.c index 89b2468070..eca8712b35 100644 --- a/cpukit/libtest/testbeginend.c +++ b/cpukit/libtest/testbeginend.c @@ -1,17 +1,39 @@ -/* - * Copyright (c) 2014, 2018 embedded brains GmbH. All rights reserved. +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * @ingroup RTEMSTestFrameworkImpl + * + * @brief This source file contains the implementation of + * rtems_test_begin() and rtems_test_end(). + */ + +/* + * Copyright (C) 2014, 2018 embedded brains GmbH & Co. KG * * Copyright (c) 2017 Chris Johns <chrisj@rtems.org>. All rights reserved. * - * 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. + * 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 @@ -19,6 +41,7 @@ #endif #include <rtems/test-info.h> +#include <rtems/test-printer.h> #include <rtems/bspIo.h> #include <rtems/version.h> diff --git a/cpukit/libtest/testbusy.c b/cpukit/libtest/testbusy.c index 51c6a71810..71cb237691 100644 --- a/cpukit/libtest/testbusy.c +++ b/cpukit/libtest/testbusy.c @@ -1,15 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* - * Copyright (c) 2014, 2018 embedded brains GmbH. All rights reserved. + * Copyright (C) 2014, 2018 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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 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. */ diff --git a/cpukit/libtest/testextension.c b/cpukit/libtest/testextension.c index ee9681a847..483c13ca85 100644 --- a/cpukit/libtest/testextension.c +++ b/cpukit/libtest/testextension.c @@ -1,15 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * Copyright (c) 2014 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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 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 @@ -17,6 +30,7 @@ #endif #include <rtems/test-info.h> +#include <rtems/test-printer.h> #include <rtems/profiling.h> #include <rtems/bspIo.h> diff --git a/cpukit/libtest/testgcovbspreset.c b/cpukit/libtest/testgcovbspreset.c new file mode 100644 index 0000000000..f40102c944 --- /dev/null +++ b/cpukit/libtest/testgcovbspreset.c @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl + * + * @brief This source file contains the implementation of a wrapper for + * bsp_reset() which dumps the gcov information using + * rtems_test_gcov_dump_info() before the real bsp_reset() is called. + */ + +/* + * Copyright (C) 2021, 2022 embedded brains GmbH & Co. KG + * + * 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 <rtems/test-info.h> + +#include <rtems/score/cpu.h> + +void __real_bsp_reset( void ); + +void __wrap_bsp_reset( void ); + +void __wrap_bsp_reset( void ) +{ + rtems_test_gcov_dump_info(); + __real_bsp_reset(); +} diff --git a/cpukit/libtest/testgcovcpufatalhalt.c b/cpukit/libtest/testgcovcpufatalhalt.c new file mode 100644 index 0000000000..9ac242885b --- /dev/null +++ b/cpukit/libtest/testgcovcpufatalhalt.c @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl + * + * @brief This source file contains the implementation of a wrapper for + * _CPU_Fatal_halt() which dumps the gcov information using + * rtems_test_gcov_dump_info() before the real _CPU_Fatal_halt() is called. + */ + +/* + * Copyright (C) 2021, 2022 embedded brains GmbH & Co. KG + * + * 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 <rtems/test-info.h> + +#include <rtems/score/cpu.h> + +void __real__CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr error ); + +void __wrap__CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr error ); + +void __wrap__CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr error ) +{ + rtems_test_gcov_dump_info(); + __real__CPU_Fatal_halt( source, error ); +} diff --git a/cpukit/libtest/testgcovdumpinfo.c b/cpukit/libtest/testgcovdumpinfo.c new file mode 100644 index 0000000000..9687280e21 --- /dev/null +++ b/cpukit/libtest/testgcovdumpinfo.c @@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl + * + * @brief This source file contains the implementation of + * rtems_test_gcov_dump_info(). + */ + +/* + * Copyright (C) 2021, 2023 embedded brains GmbH & Co. KG + * + * 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 <rtems/test-info.h> + +#include <rtems/test-gcov.h> +#include <rtems/score/isrlock.h> +#include <rtems/score/hash.h> +#include <rtems/bspIo.h> + +ISR_LOCK_DEFINE( static, gcov_dump_lock, "gcov dump" ); + +static bool gcov_dump_done; + +static Hash_Context gcov_hash; + +static void gcov_put_char( int c, void *arg ) +{ + uint8_t byte; + + rtems_put_char( c, arg ); + byte = (uint8_t) c; + _Hash_Add_data( &gcov_hash, &byte, sizeof( byte ) ); +} + +void rtems_test_gcov_dump_info( void ) +{ + ISR_lock_Context lock_context; + + _ISR_lock_ISR_disable_and_acquire( &gcov_dump_lock, &lock_context ); + + if ( !gcov_dump_done ) { + Hash_Control result; + + gcov_dump_done = true; + + _IO_Printf( rtems_put_char, NULL, "\n*** BEGIN OF GCOV INFO BASE64 ***\n" ); + _Hash_Initialize( &gcov_hash ); + _Gcov_Dump_info_base64( gcov_put_char, NULL ); + _Hash_Finalize( &gcov_hash, &result ); + _IO_Printf( rtems_put_char, NULL, "*** END OF GCOV INFO BASE64 ***\n" ); + _IO_Printf( + rtems_put_char, + NULL, + "*** GCOV INFO SHA256 %s ***\n", + _Hash_Get_string( &result ) + ); + } + + _ISR_lock_Release_and_ISR_enable( &gcov_dump_lock, &lock_context ); +} diff --git a/cpukit/libtest/testparallel.c b/cpukit/libtest/testparallel.c index f9845e0af1..1406ddee10 100644 --- a/cpukit/libtest/testparallel.c +++ b/cpukit/libtest/testparallel.c @@ -1,15 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* - * Copyright (c) 2013, 2016 embedded brains GmbH. All rights reserved. + * Copyright (C) 2013, 2016 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@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. * - * 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 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. */ diff --git a/cpukit/libtest/testrun.c b/cpukit/libtest/testrun.c index 59418e8c7d..e7be6e91a7 100644 --- a/cpukit/libtest/testrun.c +++ b/cpukit/libtest/testrun.c @@ -3,13 +3,13 @@ /** * @file * - * @ingroup RTEMSAPI + * @ingroup RTEMSTest * - * @brief Implementation of rtems_test_run_default(). + * @brief This source file provides the implementation of rtems_test_run(). */ /* - * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2020, 2023 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -38,6 +38,7 @@ #endif #include <rtems/test-info.h> +#include <rtems/test-printer.h> #include <rtems/test.h> #include <stdlib.h> @@ -65,7 +66,7 @@ static const T_config config = { .buf = buffer, .buf_size = sizeof( buffer ), .putchar = T_putchar_default, - .verbosity = T_VERBOSE, + .verbosity = T_NORMAL, .now = T_now_clock, .allocate = malloc, .deallocate = free, @@ -73,17 +74,33 @@ static const T_config config = { .actions = actions }; +static int printer(void *context, const char *fmt, va_list ap) +{ + (void) context; + return T_vprintf(fmt, ap); +} + void rtems_test_run( rtems_task_argument arg, const RTEMS_TEST_STATE state ) { + rtems_print_printer previous_printer; + int exit_code; + (void) arg; rtems_test_begin( rtems_test_name, state ); T_register(); - if ( T_main( &config ) == 0 ) { + previous_printer = rtems_test_printer.printer; + rtems_test_printer.printer = printer; + + exit_code = T_main( &config ); + + rtems_test_printer.printer = previous_printer; + + if ( exit_code == 0 ) { rtems_test_end( rtems_test_name ); } diff --git a/cpukit/libtest/testwrappers.c b/cpukit/libtest/testwrappers.c index 9679f75b6c..2316208f7c 100644 --- a/cpukit/libtest/testwrappers.c +++ b/cpukit/libtest/testwrappers.c @@ -1,16 +1,35 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* * Copyright (c) 2017 Chris Johns <chrisj@rtems.org>. All rights reserved. * - * 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. + * 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 <rtems/test-info.h> +#include <rtems/test-printer.h> int __wrap_printf(const char* format, ...); int __wrap_puts(const char *str); |