xref: /aosp_15_r20/external/executorch/runtime/kernel/test/kernel_double_registration_test.cpp (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 #include <executorch/runtime/core/exec_aten/exec_aten.h>
10 #include <executorch/runtime/kernel/operator_registry.h>
11 #include <executorch/runtime/platform/runtime.h>
12 #include <executorch/test/utils/DeathTest.h>
13 #include <gtest/gtest.h>
14 #include <string>
15 
16 using namespace ::testing;
17 
18 using executorch::runtime::ArrayRef;
19 using executorch::runtime::Error;
20 using executorch::runtime::EValue;
21 using executorch::runtime::Kernel;
22 using executorch::runtime::KernelRuntimeContext;
23 using executorch::runtime::register_kernels;
24 
25 class KernelDoubleRegistrationTest : public ::testing::Test {
26  public:
SetUp()27   void SetUp() override {
28     executorch::runtime::runtime_init();
29   }
30 };
31 
TEST_F(KernelDoubleRegistrationTest,Basic)32 TEST_F(KernelDoubleRegistrationTest, Basic) {
33   Kernel kernels[] = {Kernel(
34       "aten::add.out",
35       "v1/7;0,1,2,3|7;0,1,2,3|7;0,1,2,3",
36       [](KernelRuntimeContext&, EValue**) {})};
37   Error err = Error::InvalidArgument;
38 
39   ET_EXPECT_DEATH(
40       { (void)register_kernels({kernels}); },
41       std::to_string(static_cast<uint32_t>(err)));
42 }
43