diff options
author | Gabe Black <gabeblack@google.com> | 2018-05-24 01:37:55 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-08-08 10:09:54 +0000 |
commit | 16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f (patch) | |
tree | 7b6faaacb4574a555e561534aa4a8508c0624c32 /src/systemc/tests/systemc/kernel/process_control/throw_it | |
parent | 7235d3b5211d0ba8f528d930a4c1e7ad62eec51a (diff) | |
download | gem5-16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f.tar.xz |
systemc: Import tests from the Accellera systemc distribution.
Change-Id: Iad76b398949a55d768a34d027a2d8e3739953da6
Reviewed-on: https://gem5-review.googlesource.com/10845
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/tests/systemc/kernel/process_control/throw_it')
-rw-r--r-- | src/systemc/tests/systemc/kernel/process_control/throw_it/test1/golden/test1.log | 5 | ||||
-rw-r--r-- | src/systemc/tests/systemc/kernel/process_control/throw_it/test1/test1.cpp | 57 |
2 files changed, 62 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/golden/test1.log b/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/golden/test1.log new file mode 100644 index 000000000..18c914736 --- /dev/null +++ b/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/golden/test1.log @@ -0,0 +1,5 @@ +SystemC Simulation +0 s: starting victim thread +10 ns: in perpetrator throwing exception in victim +10 ns: in victim thread, caught exception from pepetrator, exiting +10 ns: in perpetrator after throwing exception in victim diff --git a/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/test1.cpp b/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/test1.cpp new file mode 100644 index 000000000..1a3ceb192 --- /dev/null +++ b/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/test1.cpp @@ -0,0 +1,57 @@ +//---------------------------------------------------------------------- +// Copyright 2009 Cadence Design Systems, Inc. +// All Rights Reserved Worldwide +//---------------------------------------------------------------------- + +#include <systemc.h> + +class my_exception { +public: + my_exception(const char* s) : s_(s) { } + const char* message() { return s_.c_str(); } +protected: + std::string s_; +}; + +SC_MODULE(top) { +public: + SC_CTOR(top) { + SC_THREAD(victim); + h = sc_get_current_process_handle(); + SC_THREAD(perpetrator); + } + + void victim() { + try { + cerr << sc_time_stamp() << ": starting victim thread" << endl; + ::sc_core::wait(100, SC_NS); + } + catch (my_exception& x) { + cerr << sc_time_stamp() << ": in victim thread, caught exception " + << x.message() << ", exiting" << endl; + return; + } + } + + void perpetrator() { + wait(10, SC_NS); + cerr << sc_time_stamp() + << ": in perpetrator throwing exception in victim " + << endl; + h.throw_it(my_exception("from pepetrator")); + cerr << sc_time_stamp() + << ": in perpetrator after throwing exception in victim " + << endl; + } + +protected: + sc_process_handle h; +}; + +int sc_main (int argc, char *argv[]) +{ + top t("top"); + sc_start(); + return 0; +} + |