I am developing an application handling CTRL-C. I am producing a signal handler to shut-down gracefully threads and other resources.
I want to test CTRL-C in different scenarios where my application might be. I know how to setup those for the process under test, but I need a way (in the code of the running test suite) to check whether that condition is reached or not to call exactly CTRL-C.
I work in Linux and I want to run my tests automatically with the help of CPPUNIT
. In each of my CTRL-C tests I start the process and then I send CTRL-C using kill
function having the PID of the process.
I am using shared memory; once the tested application reaches a condition of my interest or a point when I would like to send CTRL-C, I write a tag or a state into the shared memory. Aat the same time the test suite code running in a different process is continuosly polling the shared memory and once it reads the desired state it send CTRL-C/kill.
您认为这是一个好方法还是通常以更好/有效的方式完成?
亲切的问候
AFG
首先测试接收到某些外部信号时的行为看起来不像单元测试,而是像功能测试。
此外,您执行此操作的方式听起来也太复杂,并且可能会强制执行某种同步并隐藏某些行为。
另一方面,对于此类测试,我确实没有更好的建议,这通常是由外部工具以一种不太受控制的方式完成的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)