From ac16e3b9611297697ffd8f6d80166c2c05f745e5 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 9 Nov 2023 11:22:07 +0100 Subject: libtest: Add hash to gcov info dump This helps to validate that the data was transferred correctly. --- cpukit/libtest/testgcovdumpinfo.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/cpukit/libtest/testgcovdumpinfo.c b/cpukit/libtest/testgcovdumpinfo.c index c1d07275e7..71cf4d6d37 100644 --- a/cpukit/libtest/testgcovdumpinfo.c +++ b/cpukit/libtest/testgcovdumpinfo.c @@ -10,7 +10,7 @@ */ /* - * Copyright (C) 2021, 2022 embedded brains GmbH & Co. KG + * 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 @@ -42,12 +42,24 @@ #include #include +#include #include 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; @@ -55,11 +67,24 @@ void rtems_test_gcov_dump_info( void ) _ISR_lock_ISR_disable_and_acquire( &gcov_dump_lock, &lock_context ); if ( !gcov_dump_done ) { + Hash_Control result; + uint8_t byte; + gcov_dump_done = true; _IO_Printf( rtems_put_char, NULL, "\n*** BEGIN OF GCOV INFO BASE64 ***\n" ); - _Gcov_Dump_info_base64( rtems_put_char, NULL ); + _Hash_Initialize( &gcov_hash ); + _Gcov_Dump_info_base64( gcov_put_char, NULL ); _IO_Printf( rtems_put_char, NULL, "\n*** END OF GCOV INFO BASE64 ***\n" ); + byte = '\n'; + _Hash_Add_data( &gcov_hash, &byte, sizeof( byte ) ); + _Hash_Finalize( &gcov_hash, &result ); + _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 ); -- cgit v1.2.3