Skip to content

Commit 686c999

Browse files
Merge pull request #24 from accellera-official/revert-22-main
Revert "Splits reporting into frontend and backend implementation"
2 parents f3ddba5 + 5047f18 commit 686c999

File tree

11 files changed

+660
-934
lines changed

11 files changed

+660
-934
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,3 @@
22
/_build/
33
/.cproject
44
/.project
5-
/.venv
6-
/.vscode

examples/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ endmacro()
1010

1111
run_test(smoke)
1212
run_test(smoke_report)
13-
run_test(smoke_logger)

examples/smoke.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ SC_MODULE (test) {
4141
uint64_t myint = mid + mid;
4242
myint += mid;
4343
if (mid == 0x450) {
44-
SCP_INFO("ext test") << "Success";
44+
SC_REPORT_INFO("ext test", "Success");
4545
} else {
46-
SCP_INFO("ext test") << "Failure";
46+
SC_REPORT_INFO("ext test", "Failour");
4747
}
4848
}
4949
};

examples/smoke_logger.cc

Lines changed: 0 additions & 215 deletions
This file was deleted.

examples/smoke_report.cc

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#include <cstdio>
2525
#include <string>
26+
#include <fstream>
27+
#include <streambuf>
2628
#include <unistd.h>
2729

2830
SC_MODULE (test4) {
@@ -142,6 +144,14 @@ int sc_main(int argc, char** argv) {
142144

143145
std::string logfile = "/tmp/scp_smoke_report_test." +
144146
std::to_string(getpid());
147+
scp::init_logging(
148+
scp::LogConfig()
149+
.logLevel(scp::log::DEBUG) // set log level to debug
150+
.msgTypeFieldWidth(20)
151+
.fileInfoFrom(5)
152+
.logAsync(false)
153+
.printSimTime(false)
154+
.logFileName(logfile)); // make the msg type column a bit tighter
145155
SCP_INFO() << "Constructing design";
146156
test toptest("top");
147157
test1 t1("t1");
@@ -150,5 +160,56 @@ int sc_main(int argc, char** argv) {
150160
sc_core::sc_start();
151161
SCP_WARN() << "Ending simulation";
152162

153-
return 0;
163+
#ifdef FMT_SHARED
164+
std::string fmtstr = "FMT String : Cached version default";
165+
#else
166+
std::string fmtstr = "Please add FMT library for FMT support.";
167+
#endif
168+
169+
std::string expected =
170+
R"([ info] [ 0 s ]SystemC : Constructing design
171+
[ info] [ 0 s ]out.class : constructor
172+
[ warning] [ 0 s ]out.class : constructor
173+
[ debug] [ 0 s ]top : First part
174+
[ info] [ 0 s ]top : top
175+
[ info] [ 0 s ]top : top->top->top
176+
[ debug] [ 0 s ]top : Second part
177+
[ info] [ 0 s ]ext test : Success
178+
[ info] [ 0 s ]SystemC : Uncached version empty
179+
[ info] [ 0 s ]top : )" +
180+
fmtstr + R"(
181+
[ info] [ 0 s ]top : UnCached version feature using SCMOD macro
182+
[ info] [ 0 s ]top : Cached version using (m_my_logger)
183+
[ info] [ 0 s ]top : Cached version with D
184+
[ info] [ 0 s ]t1.t2.t3_1 : . T3 D Logger "other" "feature.one"
185+
[ warning] [ 0 s ]t1.t2.t3_1 : . T3 D Logger "other" "feature.one"
186+
[ info] [ 0 s ]t1.t2.t3_1 : . T3 Logger ()
187+
[ warning] [ 0 s ]t1.t2.t3_1 : . T3 Logger ()
188+
[ info] [ 0 s ]t1.t2.t3_2 : . T3 D Logger "other" "feature.one"
189+
[ warning] [ 0 s ]t1.t2.t3_2 : . T3 D Logger "other" "feature.one"
190+
[ warning] [ 0 s ]t1.t2.t3_2 : . T3 Logger ()
191+
[ info] [ 0 s ]t1.t2.t4 : . T4 Logger() 1
192+
[ warning] [ 0 s ]t1.t2.t4 : . T4 Logger() 1
193+
[ info] [ 0 s ]t1.t2.t4 : . T4 Logger() 2
194+
[ warning] [ 0 s ]t1.t2.t4 : . T4 Logger() 2
195+
[ warning] [ 0 s ]t1.t2 : T2 Logger()
196+
[ warning] [ 0 s ]My.Name : T1 My.Name typed log
197+
[ warning] [ 0 s ]t1 : T1 Logger()
198+
[ info] [ 0 s ]t1 : Thing1?
199+
[ warning] [ 0 s ]t1 : Thing1?
200+
[ warning] [ 0 s ]t1 : Thing2?
201+
[ info] [ 0 s ]SystemC : Starting simulation
202+
[ warning] [ 0 s ]SystemC : Ending simulation
203+
)";
204+
205+
std::ifstream lf(logfile);
206+
std::string out((std::istreambuf_iterator<char>(lf)),
207+
std::istreambuf_iterator<char>());
208+
209+
std::cout << "out file\n" << out << "\n";
210+
std::cout << "expected\n" << expected << "\n";
211+
std::cout << "Number of difference: " << out.compare(expected) << "\n";
212+
213+
std::remove(logfile.c_str());
214+
return out.compare(expected);
154215
}

0 commit comments

Comments
 (0)