summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/compliance_1666/test220/test220.cpp
diff options
context:
space:
mode:
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;
+}