diff options
Diffstat (limited to '')
32 files changed, 694 insertions, 70 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 59a5fd7d56..5d6ec25bda 100644 --- a/cpukit/libtest/t-test-checks-psx.c +++ b/cpukit/libtest/t-test-checks-psx.c @@ -3,11 +3,14 @@ /** * @file * - * @brief + * @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 (http://www.embedded-brains.de) + * 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 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 85b9b6ff69..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 diff --git a/cpukit/libtest/t-test-rtems-context.c b/cpukit/libtest/t-test-rtems-context.c index cadafcdf94..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 + * + * @ingroup RTEMSTestFrameworkImpl * - * Copyright (C) 2019 embedded brains GmbH + * @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 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 e21b092a81..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 + * + * @ingroup RTEMSTestFrameworkImpl * - * Copyright (C) 2018, 2021 embedded brains GmbH + * @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 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 index 3f4a59c674..d9df0cc97b 100644 --- a/cpukit/libtest/t-test-scheduler.c +++ b/cpukit/libtest/t-test-scheduler.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * 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 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 12d020446a..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> @@ -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 6ff52d67c4..eca8712b35 100644 --- a/cpukit/libtest/testbeginend.c +++ b/cpukit/libtest/testbeginend.c @@ -1,7 +1,16 @@ /* SPDX-License-Identifier: BSD-2-Clause */ +/** + * @file + * + * @ingroup RTEMSTestFrameworkImpl + * + * @brief This source file contains the implementation of + * rtems_test_begin() and rtems_test_end(). + */ + /* - * Copyright (c) 2014, 2018 embedded brains GmbH. All rights reserved. + * Copyright (C) 2014, 2018 embedded brains GmbH & Co. KG * * Copyright (c) 2017 Chris Johns <chrisj@rtems.org>. All rights reserved. * @@ -32,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 69fb34cb32..71cb237691 100644 --- a/cpukit/libtest/testbusy.c +++ b/cpukit/libtest/testbusy.c @@ -1,7 +1,7 @@ /* 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 * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/cpukit/libtest/testextension.c b/cpukit/libtest/testextension.c index 6bfe61eb0c..483c13ca85 100644 --- a/cpukit/libtest/testextension.c +++ b/cpukit/libtest/testextension.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (c) 2014 embedded brains GmbH. All rights reserved. + * Copyright (c) 2014 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,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 d7a7068a35..1406ddee10 100644 --- a/cpukit/libtest/testparallel.c +++ b/cpukit/libtest/testparallel.c @@ -1,7 +1,7 @@ /* 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 * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions 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 3c6e8fccc3..2316208f7c 100644 --- a/cpukit/libtest/testwrappers.c +++ b/cpukit/libtest/testwrappers.c @@ -29,7 +29,7 @@ #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); |