blob: 6a3f6819fc94877ab1cbd5ae0d7b65ecbf6ba134 [file] [log] [blame]
Matthew Bentham0a59e692023-07-19 15:01:00 +00001/*
Pablo Marquez Tello575c5f12024-04-23 15:02:48 +01002 * Copyright (c) 2023-2024 Arm Limited.
Matthew Bentham0a59e692023-07-19 15:01:00 +00003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "arm_compute/runtime/CPP/CPPScheduler.h"
25
26#include "arm_compute/core/CPP/ICPPKernel.h"
27#include "tests/framework/Asserts.h"
28#include "tests/framework/Macros.h"
29
30#include <stdexcept>
31
32using namespace arm_compute;
33using namespace arm_compute::test;
34
35namespace
36{
37class TestException: public std::exception
38{
39public:
40 const char* what() const noexcept override
41 {
42 return "Expected test exception";
43 }
44};
45
46class TestKernel: public ICPPKernel
47{
48public:
49 TestKernel()
50 {
51 Window window;
52 window.set(0, Window::Dimension(0, 2));
53 configure(window);
54 }
55
56 const char* name() const override
57 {
58 return "TestKernel";
59 }
60
61 void run(const Window &, const ThreadInfo &) override
62 {
63 throw TestException();
64 }
65
66};
67}
68
69TEST_SUITE(UNIT)
70TEST_SUITE(CPPScheduler)
Pablo Marquez Tello575c5f12024-04-23 15:02:48 +010071#if defined(ARM_COMPUTE_CPP_SCHEDULER) && !defined(BARE_METAL)
Matthew Bentham0a59e692023-07-19 15:01:00 +000072TEST_CASE(RethrowException, framework::DatasetMode::ALL)
73{
74 CPPScheduler scheduler;
75 CPPScheduler::Hints hints(0);
76 TestKernel kernel;
77
78 scheduler.set_num_threads(2);
79 try
80 {
81 scheduler.schedule(&kernel, hints);
82 }
83 catch(const TestException&)
84 {
85 return;
86 }
87 ARM_COMPUTE_EXPECT_FAIL("Expected exception not caught", framework::LogLevel::ERRORS);
88}
Pablo Marquez Tello575c5f12024-04-23 15:02:48 +010089#endif // defined(ARM_COMPUTE_CPP_SCHEDULER) && !defined(BARE_METAL)
Matthew Bentham0a59e692023-07-19 15:01:00 +000090TEST_SUITE_END()
91TEST_SUITE_END()