-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding exception catcher around system::run
- Loading branch information
1 parent
4644bf4
commit 5aeecd3
Showing
4 changed files
with
92 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/****************************************************************************** | ||
* * | ||
* Copyright (C) 2023 MachineWare GmbH * | ||
* All Rights Reserved * | ||
* * | ||
* This is work is licensed under the terms described in the LICENSE file * | ||
* found in the root directory of this source tree. * | ||
* * | ||
******************************************************************************/ | ||
|
||
#include "testing.h" | ||
|
||
class harness : public vcml::system | ||
{ | ||
public: | ||
mwr::publishers::terminal term; | ||
mock_publisher pub; | ||
|
||
harness(const sc_module_name& nm): vcml::system(nm), term(), pub() { | ||
SC_HAS_PROCESS(harness); | ||
SC_METHOD(test_method); | ||
pub.expect(LOG_INFO, "starting infinite simulation"); | ||
} | ||
|
||
virtual ~harness() = default; | ||
|
||
void test_method() { | ||
pub.expect(LOG_ERROR, "wait() is only allowed in SC_THREADs"); | ||
wait(SC_ZERO_TIME); | ||
} | ||
}; | ||
|
||
TEST(system, exceptions) { | ||
// restore default handler, otherwise reports will count as a failure | ||
auto handler = ::sc_core::sc_report_handler::default_handler; | ||
::sc_core::sc_report_handler::set_handler(handler); | ||
|
||
harness test("harness"); | ||
EXPECT_EQ(test.run(), EXIT_FAILURE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters