summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/compliance_1666/test220/test220.cpp
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-05-24 01:37:55 -0700
committerGabe Black <gabeblack@google.com>2018-08-08 10:09:54 +0000
commit16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f (patch)
tree7b6faaacb4574a555e561534aa4a8508c0624c32 /src/systemc/tests/systemc/compliance_1666/test220/test220.cpp
parent7235d3b5211d0ba8f528d930a4c1e7ad62eec51a (diff)
downloadgem5-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/compliance_1666/test220/test220.cpp')
-rw-r--r--src/systemc/tests/systemc/compliance_1666/test220/test220.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/compliance_1666/test220/test220.cpp b/src/systemc/tests/systemc/compliance_1666/test220/test220.cpp
new file mode 100644
index 000000000..0d25509b6
--- /dev/null
+++ b/src/systemc/tests/systemc/compliance_1666/test220/test220.cpp
@@ -0,0 +1,68 @@
+#include <systemc>
+using namespace sc_core;
+using namespace sc_dt;
+using std::cout;
+using std::endl;
+
+// 20) sc_report_handler::stop_after(SC_FATAL,-1) should NOT call sc_stop on 1st fatal error
+
+static bool global_flag_1 = false;
+static bool global_flag_2 = false;
+static bool global_flag_3 = false;
+
+SC_MODULE(M)
+{
+ SC_CTOR(M)
+ {
+ SC_THREAD(T);
+ }
+ void T()
+ {
+ SC_REPORT_FATAL("/JA", "A bad thing has happened");
+ wait(1, SC_NS);
+ sc_assert(sc_report_handler::get_count(SC_FATAL) == 1);
+ global_flag_1 = true;
+
+ sc_report_handler::stop_after(SC_FATAL, 0);
+ SC_REPORT_FATAL("/JA", "A bad thing has happened");
+ wait(1, SC_NS);
+ sc_assert(sc_report_handler::get_count(SC_FATAL) == 2);
+ global_flag_2 = true;
+
+ sc_report_handler::stop_after(SC_FATAL, -1);
+ SC_REPORT_FATAL("/JA", "A bad thing has happened");
+ wait(1, SC_NS);
+ sc_assert(sc_report_handler::get_count(SC_FATAL) == 3);
+ global_flag_3 = true;
+ }
+};
+
+struct Top: sc_module
+{
+ M *m;
+ Top(sc_module_name)
+ {
+ m = new M("m");
+ }
+};
+
+int sc_main(int argc, char* argv[])
+{
+ cout << "Should be silent except for 3 fatal errors..." << endl;
+
+ sc_report_handler::set_actions(SC_FATAL, SC_DISPLAY);
+
+ Top top("top");
+ sc_start();
+
+ sc_assert(global_flag_1);
+ sc_assert(global_flag_2);
+ sc_assert(global_flag_3);
+ sc_assert(sc_report_handler::get_count(SC_INFO) == 0);
+ sc_assert(sc_report_handler::get_count(SC_WARNING) == 0);
+ sc_assert(sc_report_handler::get_count(SC_ERROR) == 0);
+ sc_assert(sc_report_handler::get_count(SC_FATAL) == 3);
+
+ cout << endl << "Success" << endl;
+ return 0;
+}