mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-18 03:49:41 +00:00
Merge commit 'e6e7dc29101bcd8a5d30ae99adf71a09fa544b09' into develop
This commit is contained in:
46
experimental/builder/test/unit_error.cpp
Normal file
46
experimental/builder/test/unit_error.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "ck_tile/builder/testing/error.hpp"
|
||||
#include "ck_tile/builder/testing/tensor_buffer.hpp"
|
||||
#include "testing_utils.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
#include <gmock/gmock.h>
|
||||
|
||||
namespace ckt = ck_tile::builder::test;
|
||||
|
||||
using ::testing::AllOf;
|
||||
using ::testing::HasSubstr;
|
||||
using ::testing::Throws;
|
||||
using ::testing::ThrowsMessage;
|
||||
|
||||
[[noreturn]] void throw_error() { throw ckt::HipError("test error", hipErrorInvalidValue); }
|
||||
|
||||
TEST(HipError, SourceInfo)
|
||||
{
|
||||
EXPECT_THAT(throw_error,
|
||||
ThrowsMessage<ckt::HipError>(AllOf(
|
||||
// The error message should include...
|
||||
// ...the user message
|
||||
HasSubstr("test error"),
|
||||
// ...the HIP message
|
||||
HasSubstr("invalid argument"),
|
||||
// ...the HIP status code,
|
||||
HasSubstr("(1)"),
|
||||
// ...the filename
|
||||
HasSubstr("experimental/builder/test/unit_error.cpp"),
|
||||
// ...the function name
|
||||
HasSubstr("throw_error"),
|
||||
// Note: Don't include the row/column so that we can move
|
||||
// stuff around in this file.
|
||||
)));
|
||||
}
|
||||
|
||||
TEST(CheckHip, BasicUsage)
|
||||
{
|
||||
EXPECT_THAT([] { ckt::check_hip(hipSuccess); }, Not(Throws<ckt::HipError>()));
|
||||
EXPECT_THAT([] { ckt::check_hip(hipErrorNotMapped); }, Throws<ckt::HipError>());
|
||||
EXPECT_THAT([] { ckt::check_hip(hipErrorOutOfMemory); }, Throws<ckt::OutOfDeviceMemoryError>());
|
||||
EXPECT_THAT([] { ckt::check_hip("test message", hipErrorAlreadyMapped); },
|
||||
ThrowsMessage<ckt::HipError>(HasSubstr("test message")));
|
||||
}
|
||||
Reference in New Issue
Block a user