/* * Copyright (c) Advanced Micro Devices, Inc., or its affiliates. * * SPDX-License-Identifier: MIT */ #include #include /** * @addtogroup printf printf * @{ * @ingroup PrintfTest * `int printf()` - * Method to print the content on output device. */ /** * Test Description * ------------------------ * - Sanity test for `printf(format, ...)` to check all format specifier flags. * * Test source * ------------------------ * - unit/printf/printfFlags.cc * Test requirements * ------------------------ * - HIP_VERSION >= 5.2 */ HIP_TEST_CASE(Unit_Printf_flags_Sanity_Positive) { int pcieAtomic = 0; HIP_CHECK(hipDeviceGetAttribute(&pcieAtomic, hipDeviceAttributeHostNativeAtomicSupported, 0)); if (!pcieAtomic) { HIP_SKIP_TEST(HipTest::SkipReason::kPcieAtomicUnsupported); } std::string reference = std::string(R"here(00000042 -0000042 00000042 0123.456 +0000042 -42 +0000042 )here") + std::string("xyzzy") + std::string(3, ' ') + "\n" + std::string("-42\n 42\n") + std::string("00000042") + std::string(8, ' ') + "\n" + std::string(R"here( 00000042 052 0x2a 0X2A 42.000000 4.200000e+01 4.200000E+01 42.0000 42.0000 0x1.5p+5 0X1.5P+5 )here"); hip::SpawnProc proc("printfFlags_exe", true); REQUIRE(proc.run() == 0); REQUIRE(proc.getOutput() == reference); } /** * End doxygen group PrintfTest. * @} */