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);
}