diff options
author | Andy Getzendanner <durandal@google.com> | 2023-05-23 15:46:35 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-05-23 15:47:23 -0700 |
commit | 52747821480e6cadd8b27a0947af5d7933f9dfb4 (patch) | |
tree | cc42f6dc30fa8eca19047efd799c769ead59b6c4 /absl/random/internal | |
parent | 79ca5d7aad63973c83a4962a66ab07cd623131ea (diff) |
Migrate most RAW_LOGs and RAW_CHECKs in tests to regular LOG and CHECK.
The non-RAW_ versions provide better output but weren't available when most of these tests were written.
There are just a couple spots where RAW_ is actually needed, e.g. signal handlers and malloc hooks.
Also fix a couple warnings in layout_test.cc newly surfaced because the optimizer understands CHECK_XX differently than INTERNAL_CHECK.
PiperOrigin-RevId: 534584435
Change-Id: I8d36fa809ffdaae5a3813064bd602cb8611c1613
Diffstat (limited to 'absl/random/internal')
-rw-r--r-- | absl/random/internal/BUILD.bazel | 8 | ||||
-rw-r--r-- | absl/random/internal/nanobenchmark_test.cc | 20 | ||||
-rw-r--r-- | absl/random/internal/randen_engine_test.cc | 7 | ||||
-rw-r--r-- | absl/random/internal/randen_hwaes_test.cc | 26 |
4 files changed, 32 insertions, 29 deletions
diff --git a/absl/random/internal/BUILD.bazel b/absl/random/internal/BUILD.bazel index a51c9375..37f4d6e2 100644 --- a/absl/random/internal/BUILD.bazel +++ b/absl/random/internal/BUILD.bazel @@ -601,7 +601,7 @@ cc_test( deps = [ ":explicit_seed_seq", ":randen_engine", - "//absl/base:raw_logging_internal", + "//absl/log", "//absl/strings", "//absl/time", "@com_google_googletest//:gtest_main", @@ -646,7 +646,7 @@ cc_test( ":platform", ":randen_hwaes", ":randen_hwaes_impl", # build_cleaner: keep - "//absl/base:raw_logging_internal", + "//absl/log", "//absl/strings:str_format", "@com_google_googletest//:gtest", ], @@ -707,8 +707,10 @@ cc_test( ], deps = [ ":nanobenchmark", - "//absl/base:raw_logging_internal", + "//absl/log", + "//absl/log:check", "//absl/strings", + "//absl/strings:str_format", ], ) diff --git a/absl/random/internal/nanobenchmark_test.cc b/absl/random/internal/nanobenchmark_test.cc index f1571e26..d4f1028d 100644 --- a/absl/random/internal/nanobenchmark_test.cc +++ b/absl/random/internal/nanobenchmark_test.cc @@ -14,8 +14,10 @@ #include "absl/random/internal/nanobenchmark.h" -#include "absl/base/internal/raw_logging.h" +#include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/numbers.h" +#include "absl/strings/str_format.h" namespace absl { ABSL_NAMESPACE_BEGIN @@ -36,16 +38,16 @@ void MeasureDiv(const FuncInput (&inputs)[N]) { params.max_evals = 6; // avoid test timeout const size_t num_results = Measure(&Div, nullptr, inputs, N, results, params); if (num_results == 0) { - ABSL_RAW_LOG( - WARNING, - "WARNING: Measurement failed, should not happen when using " - "PinThreadToCPU unless the region to measure takes > 1 second.\n"); + LOG(WARNING) + << "WARNING: Measurement failed, should not happen when using " + "PinThreadToCPU unless the region to measure takes > 1 second."; return; } for (size_t i = 0; i < num_results; ++i) { - ABSL_RAW_LOG(INFO, "%5zu: %6.2f ticks; MAD=%4.2f%%\n", results[i].input, - results[i].ticks, results[i].variability * 100.0); - ABSL_RAW_CHECK(results[i].ticks != 0.0f, "Zero duration"); + LOG(INFO) << absl::StreamFormat("%5u: %6.2f ticks; MAD=%4.2f%%\n", + results[i].input, results[i].ticks, + results[i].variability * 100.0); + CHECK_NE(results[i].ticks, 0.0f) << "Zero duration"; } } @@ -54,7 +56,7 @@ void RunAll(const int argc, char* argv[]) { int cpu = -1; if (argc == 2) { if (!absl::SimpleAtoi(argv[1], &cpu)) { - ABSL_RAW_LOG(FATAL, "The optional argument must be a CPU number >= 0.\n"); + LOG(FATAL) << "The optional argument must be a CPU number >= 0."; } } PinThreadToCPU(cpu); diff --git a/absl/random/internal/randen_engine_test.cc b/absl/random/internal/randen_engine_test.cc index c8e7685b..a94f4916 100644 --- a/absl/random/internal/randen_engine_test.cc +++ b/absl/random/internal/randen_engine_test.cc @@ -21,7 +21,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "absl/base/internal/raw_logging.h" +#include "absl/log/log.h" #include "absl/random/internal/explicit_seed_seq.h" #include "absl/strings/str_cat.h" #include "absl/time/clock.h" @@ -645,9 +645,8 @@ TEST(RandenTest, IsFastOrSlow) { } auto duration = absl::GetCurrentTimeNanos() - start; - ABSL_INTERNAL_LOG(INFO, absl::StrCat(static_cast<double>(duration) / - static_cast<double>(kCount), - "ns")); + LOG(INFO) << static_cast<double>(duration) / static_cast<double>(kCount) + << "ns"; EXPECT_GT(sum, 0); EXPECT_GE(duration, kCount); // Should be slower than 1ns per call. diff --git a/absl/random/internal/randen_hwaes_test.cc b/absl/random/internal/randen_hwaes_test.cc index 2348b55c..00d96efd 100644 --- a/absl/random/internal/randen_hwaes_test.cc +++ b/absl/random/internal/randen_hwaes_test.cc @@ -16,7 +16,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "absl/base/internal/raw_logging.h" +#include "absl/log/log.h" #include "absl/random/internal/platform.h" #include "absl/random/internal/randen_detect.h" #include "absl/random/internal/randen_traits.h" @@ -67,32 +67,32 @@ TEST(RandenHwAesTest, Default) { int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); - ABSL_RAW_LOG(INFO, "ABSL_HAVE_ACCELERATED_AES=%d", ABSL_HAVE_ACCELERATED_AES); - ABSL_RAW_LOG(INFO, "ABSL_RANDOM_INTERNAL_AES_DISPATCH=%d", - ABSL_RANDOM_INTERNAL_AES_DISPATCH); + LOG(INFO) << "ABSL_HAVE_ACCELERATED_AES=" << ABSL_HAVE_ACCELERATED_AES; + LOG(INFO) << "ABSL_RANDOM_INTERNAL_AES_DISPATCH=" + << ABSL_RANDOM_INTERNAL_AES_DISPATCH; #if defined(ABSL_ARCH_X86_64) - ABSL_RAW_LOG(INFO, "ABSL_ARCH_X86_64"); + LOG(INFO) << "ABSL_ARCH_X86_64"; #elif defined(ABSL_ARCH_X86_32) - ABSL_RAW_LOG(INFO, "ABSL_ARCH_X86_32"); + LOG(INFO) << "ABSL_ARCH_X86_32"; #elif defined(ABSL_ARCH_AARCH64) - ABSL_RAW_LOG(INFO, "ABSL_ARCH_AARCH64"); + LOG(INFO) << "ABSL_ARCH_AARCH64"; #elif defined(ABSL_ARCH_ARM) - ABSL_RAW_LOG(INFO, "ABSL_ARCH_ARM"); + LOG(INFO) << "ABSL_ARCH_ARM"; #elif defined(ABSL_ARCH_PPC) - ABSL_RAW_LOG(INFO, "ABSL_ARCH_PPC"); + LOG(INFO) << "ABSL_ARCH_PPC"; #else - ABSL_RAW_LOG(INFO, "ARCH Unknown"); + LOG(INFO) << "ARCH Unknown"; #endif int x = absl::random_internal::HasRandenHwAesImplementation(); - ABSL_RAW_LOG(INFO, "HasRandenHwAesImplementation = %d", x); + LOG(INFO) << "HasRandenHwAesImplementation = " << x; int y = absl::random_internal::CPUSupportsRandenHwAes(); - ABSL_RAW_LOG(INFO, "CPUSupportsRandenHwAes = %d", x); + LOG(INFO) << "CPUSupportsRandenHwAes = " << x; if (!x || !y) { - ABSL_RAW_LOG(INFO, "Skipping Randen HWAES tests."); + LOG(INFO) << "Skipping Randen HWAES tests."; return 0; } return RUN_ALL_TESTS(); |