介绍了UT测试框架及动态打桩技术,并配有相关源代码工程,方便开发人员进行代码自测试。
2021-12-19 23:20:34 12.64MB UT与动态打桩
1
C语言UT单元测试中需要实现动态,本代码实现了该功能,原理和网络上的描述一样,通过修改机器指令实现。 平台是Linux
2021-11-16 13:27:34 2KB C UT 动态打桩 stub
1
在单元测试中经常需要动态的替换被测函数调用的其他函数,这个替换叫做打桩,现在很少有动态打桩的函数,研究了许久,写了这个功能,做成了lib库,在cygwin下生成的。 给出了一个Demo,使用makefile试一试吧! ps:我目前只在windowsxp下应用,其他平台未知!欢迎发邮件给我。 #include "stdio.h" #include "d_stub.h" void testfunc(int arg, int a, int b, int c) { printf("\tI am testFunc %d\n", arg); } void testfunc1(int arg, int a, int b, int c) { printf("\t******************\n\tI am stub function\n"); printf("\tArguments: %d %d %d %d\n\t******************\n", arg, a, b, c); } void testfunc2(int arg, int a, int b, int c) { printf("\tHello world\n"); } main() { stubInfo si, ss; printf("call original func:\n"); testfunc(1, 2, 3, 4); setStub(testfunc, testfunc1, &si); setStub(testfunc1, testfunc2, &ss); printf("after set stub for func1 and func2:\n"); testfunc(1, 2, 3, 4); cleanStub(&ss); /*recover testfunc1*/ printf("after clear stub for func2:\n"); testfunc(1, 2, 3, 4); cleanStub(&si); /*recover testfunc*/ printf("after clear stub for func1::\n"); testfunc(1, 2, 3, 4); }
2021-06-06 21:21:42 2KB 动态打桩 单元测试 UT 打桩
1