SystemC 单元测试是否需要分叉?

Does SystemC unit testing need forking?

我开始使用 SystemC,并研究中提到的示例 Using existing unit test frameworks with SystemC

我真的不明白为什么需要分叉,尤其是当一个分叉只等待另一个时。内核中是否有某些东西需要这样的多线程(尤其是事件处理)? (换句话说:我是否仅在需要并发测试或更简单的情况下才需要这种处理方式)

另一个问题,在链接的答案中我在开头看到了徽标

 SystemC 2.2.0 --- Feb 24 2011 15:01:50
        Copyright (c) 1996-2006 by all Contributors
                    ALL RIGHTS RESERVED
Running main() from gtest_main.cc

而在我的例子中,徽标位于输出的末尾

Running main() from gtest_main.cc
[==========] Running 0 tests from 0 test cases.
[==========] 0 tests from 0 test cases ran. (0 ms total)
[  PASSED  ] 0 tests.
Hello World.

        SystemC 2.3.1-Accellera --- Mar 28 2017 21:08:36
        Copyright (c) 1996-2014 by all Contributors,
        ALL RIGHTS RESERVED

只是因为版本不同,还是预期的及时行为?

SystemC 内核以其当前形式设计的方式不完全支持模拟模块的动态 creation/removal,一旦您使用 sc_start() 启动 SystemC 模拟并使用 [= 停止模拟11=]你需要彻底破坏SystemC模拟上下文。

请查看更新后的答案以获得更好的解决方案here
注意:建议为不同的模拟上下文设置单独的可执行文件,因为模拟器不能保证在这种环境下的模拟结果,请参考SystemC LRM了解更多详情.

至于 SystemC 徽标的差异,这是由于您的系统中 stdoutstderr 的不同缓冲造成的。每次执行二进制文件时,您都会看到不同的结果。 (如果一致,那么可能 google 测试框架正在内部处理 stdoutstderr 流。)

我会使用注册表设计模式。我已经在 Using existing unit test frameworks with SystemC

中发布了如何使用 SystemC 和 GoogleTest 做到这一点