| 1 | // |
| 2 | // SPDX-FileCopyrightText: Copyright 2025-2026 Arm Limited and/or its affiliates <open-source-office@arm.com> |
| 3 | // |
| 4 | // SPDX-License-Identifier: Apache-2.0 |
| 5 | // |
| 6 | |
| 7 | #include "test/common/seed.hpp" |
| 8 | |
| 9 | #include <gtest/gtest.h> |
| 10 | |
| 11 | #include <algorithm> |
| 12 | |
| 13 | namespace kai::test { |
| 14 | |
| 15 | std::uint32_t global_test_seed() { |
| 16 | const auto* unit_test = testing::UnitTest::GetInstance(); |
| 17 | |
| 18 | if (!unit_test) { |
| 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | int seed = unit_test->random_seed(); |
| 23 | if (seed == 0) { |
| 24 | seed = GTEST_FLAG_GET(random_seed); |
| 25 | } |
| 26 | return static_cast<std::uint32_t>(std::max(0, seed)); |
| 27 | } |
| 28 | |
| 29 | std::string current_test_key() { |
| 30 | const auto* info = testing::UnitTest::GetInstance()->current_test_info(); |
| 31 | |
| 32 | if (!info) { |
| 33 | return "UnknownTest"; |
| 34 | } |
| 35 | |
| 36 | return std::string(info->test_suite_name()) + "::" + info->name(); |
| 37 | } |
| 38 | |
| 39 | } // namespace kai::test |