From c1a1f2c8da4993b03f0a8fadac8f0521df48abec Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 10 Sep 2019 09:21:11 +0200 Subject: Add rtems_version_control_key_is_valid() --- cpukit/include/rtems/version.h | 19 +++++++++++++++++-- testsuites/sptests/spversion01/init.c | 8 +++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/cpukit/include/rtems/version.h b/cpukit/include/rtems/version.h index 30dd70cc21..a8aff732f3 100644 --- a/cpukit/include/rtems/version.h +++ b/cpukit/include/rtems/version.h @@ -16,6 +16,8 @@ #ifndef _RTEMS_VERSION_H #define _RTEMS_VERSION_H +#include + #ifdef __cplusplus extern "C" { #endif @@ -65,11 +67,24 @@ int rtems_version_revision( void ); * The key is specific to the version control system being used and allows the * built version to be identified. * - * @return The version control key or the empty string if no version control - * key is available. + * Use rtems_version_control_key_is_valid() to check if the version control key + * is valid. + * + * @return The version control key. */ const char *rtems_version_control_key( void ); +/** + * @brief Returns true, if the version control key is valid, otherwise false. + * + * @retval true The version control key is valid. + * @retval false Otherwise. + */ +static inline bool rtems_version_control_key_is_valid( const char *key ) +{ + return key[ 0 ] != '\0'; +} + /** * @brief Returns the board support package name. * diff --git a/testsuites/sptests/spversion01/init.c b/testsuites/sptests/spversion01/init.c index fc38577691..9db3143d39 100644 --- a/testsuites/sptests/spversion01/init.c +++ b/testsuites/sptests/spversion01/init.c @@ -22,13 +22,19 @@ static rtems_task Init( rtems_task_argument argument ) { + const char *key; + const char *valid; + TEST_BEGIN(); + key = rtems_version_control_key(); + valid = rtems_version_control_key_is_valid(key) ? "valid" : "invalid"; + printf("Release : %s\n", rtems_version()); printf("Major : %d\n", rtems_version_major()); printf("Minor : %d\n", rtems_version_minor()); printf("Revision : %d\n", rtems_version_revision()); - printf("VC Key : %s\n", rtems_version_control_key()); + printf("VC Key : %s (%s)\n", key, valid); printf("BSP : %s\n", rtems_board_support_package()); TEST_END(); -- cgit v1.2.3