From 589f0134da921dc6b237d9f23cc8b124d65debbb Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Fri, 3 Mar 2023 22:24:24 +0100 Subject: [PATCH] Fix #2012 --- api/include/opentelemetry/version.h | 4 ++++ api/test/core/BUILD | 15 +++++++++++++++ api/test/core/CMakeLists.txt | 8 ++++++++ api/test/core/version_test.cc | 16 ++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 api/test/core/version_test.cc diff --git a/api/include/opentelemetry/version.h b/api/include/opentelemetry/version.h index 0672a7546f..82bfa8811c 100644 --- a/api/include/opentelemetry/version.h +++ b/api/include/opentelemetry/version.h @@ -8,6 +8,10 @@ #define OPENTELEMETRY_ABI_VERSION_NO 1 #define OPENTELEMETRY_VERSION "1.8.2" +#define OPENTELEMETRY_VERSION_MAJOR 1 +#define OPENTELEMETRY_VERSION_MINOR 8 +#define OPENTELEMETRY_VERSION_PATCH 2 + #define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO) // clang-format off diff --git a/api/test/core/BUILD b/api/test/core/BUILD index 2736bbc474..38c65e6d31 100644 --- a/api/test/core/BUILD +++ b/api/test/core/BUILD @@ -15,3 +15,18 @@ cc_test( "@com_google_googletest//:gtest_main", ], ) + +cc_test( + name = "version_test", + srcs = [ + "version_test.cc", + ], + tags = [ + "api", + "test", + ], + deps = [ + "//api", + "@com_google_googletest//:gtest_main", + ], +) diff --git a/api/test/core/CMakeLists.txt b/api/test/core/CMakeLists.txt index ebb9c1625b..7123f9a708 100644 --- a/api/test/core/CMakeLists.txt +++ b/api/test/core/CMakeLists.txt @@ -10,3 +10,11 @@ gtest_add_tests( TARGET timestamp_test TEST_PREFIX trace. TEST_LIST timestamp_test) + +add_executable(version_test version_test.cc) +target_link_libraries(version_test ${GTEST_BOTH_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} opentelemetry_api) +gtest_add_tests( + TARGET version_test + TEST_PREFIX version. + TEST_LIST version_test) diff --git a/api/test/core/version_test.cc b/api/test/core/version_test.cc new file mode 100644 index 0000000000..74b4b56900 --- /dev/null +++ b/api/test/core/version_test.cc @@ -0,0 +1,16 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +#include "opentelemetry/version.h" + +#include + +TEST(VersionTest, Consistency) +{ + char expected[10]; + sprintf(expected, "%d.%d.%d", OPENTELEMETRY_VERSION_MAJOR, OPENTELEMETRY_VERSION_MINOR, + OPENTELEMETRY_VERSION_PATCH); + + std::string actual = OPENTELEMETRY_VERSION; + EXPECT_EQ(actual, expected); +}