Automatic code testing in c upon execution

发布于 2022-08-18 23:33:30 字数 1084 浏览 20 评论 0

each source file has a function:

unsigned char test(){
    //return true if tests succceed false otherwise
}

Everytime the sourcefile gets recompiled I want the test function of that file to be run on execution of the executable and if the tests return false to halt. However, I want only code whose test code hasnt been run since build.

I was thinking that I could use the makefile system to help with this problem since makefiles will only recompile changed code which is exactly what i want. Therefore, I was thinking of adding something to the command line arguments. I saw an example in which they used echo and date to add a time last modified. The code would write the time last modified to a save file on a successful execution of the test code with which it will compare to the next time.

Is there a better way? One that doesnt rely on make? At the least is there a way without relying on spefic unix commands? Lastly, even if that isnt possible, what would the command line to do the addition to the file look like.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文