Closed github-my closed 2 years ago
test old testcase result:
[ RUN ] TestStubContainter::TestStubContainer::testShouldAlwaysReturnAStubBeforeItIsCompleted [ OK ] (9 us) [ RUN ] TestStubContainter::TestStubContainer::testShouldAlwaysReturnLastStubIfAllStubsHaveBeenReturnedEvenIfItHasBeenCompleted [ OK ] (9 us) [ RUN ] TestStubContainter::TestStubContainer::testShouldReturnNullIfNoStubWasAdded [ OK ] (3 us) [ RUN ] TestVirtualTable::TestVirtualTable::shouldBeAbleToConvertToPointerToInterfaceType [ OK ] (91 us) [ RUN ] TestVirtualTable::TestVirtualTable::shouldThrowExceptionIfTheNumberOfVptrExceedsTheMaxSettingOfConfiguration [ OK ] (60 us) [ RUN ] TestVirtualTable::TestVirtualTable::shouldBeAbleToSetMethod [ OK ] (67 us) [ RUN ] TestVirtualTable::TestVirtualTable::shouldThrowExceptionIfAMethodIsNotSet [ OK ] (87 us) [ RUN ] TestVirtualTable::TestVirtualTable::shouldThrowExceptionIfIndexOfVtblExceedsTheLimitationOfConfiguration [ OK ] (65 us) [ RUN ] TestVirtualTable::TestVirtualTable::shouldThrowExceptionIfIndexOfVtblExceedsTheNumberOfVptr [ OK ] (52 us) [ RUN ] TestVirtualTable::TestVirtualTable::shouldBeAbleToGetPreviouslySetIndexInvokableGetterByReturnedPointerToInterface [ OK ] (53 us) [ RUN ] TestVirtualTable::TestVirtualTable::shouldThrowExceptionIfItExpectedToBeDeletedButActuallyNotWhenItIsVerified [ OK ] (52 us) [ RUN ] TestVirtualTable::TestVirtualTable::shouldPassVerifyIfThePointerIsDeletedAsExpected [ OK ] (44 us) [ RUN ] TestVirtualTable::TestVirtualTable::shouldPassVerifyIfThePointerIsNotDeletedAsExpected [ OK ] (43 us) [ RUN ] TestVirtualTable::TestVirtualTable::shouldFailThrowExceptionWhileTryingToDeleteThePointerWhichWasExpectedNotTo [ OK ] (48 us) [ RUN ] TestVirtualTable::TestVirtualTable::shouldThrowExceptionIfAnObjectIsExpectedBothKeepAliveAndBeingDelete [ OK ] (58 us) [ RUN ] TestVirtualTable::TestVirtualTable::shouldThrowExceptionIfAnObjectIsExpectedBothKeepAliveAndBeingDelete2 [ OK ] (47 us) [ RUN ] TestVirtualTable::TestVirtualTable::shouldThrowExceptionWhenTryingToExpectsADeletedObjectKeepAlive [ OK ] (55 us) [ RUN ] TestVirtualTable::TestVirtualTable::shouldThrowAnExceptionWhenTryingToAccessMethodsOfADeleteObject [ OK ] (54 us)
===========================RESULT=========================== [ OK ] 274 cases from 32 suites ran successfully.
(0s 32116us) [root@8d528f027148 /sc/01.src/mockcpp]$
OK, thanks, merged.
sample test code: `#include
include
include <sys/syscall.h>
include
include "gtest/gtest.h"
include "mockcpp/mokc.h"
int int_ret_func(int a, int b) { printf("call orginal function %s\n", FUNCTION); return a + b; }
int stub_int_ret_func(int a, int b) { int tid = (int)syscall(__NR_gettid); printf("call stub function %s, tid: %d\n", FUNCTION, tid); return a * b; }
void void_ret_func(int a, int b, int c) { printf("call orginal function %s\n", FUNCTION); }
void stub_void_ret_func(int a, int b, int c) { int tid = (int)syscall(__NR_gettid); printf("call stub function %s, tid: %d\n", FUNCTION, tid); }
void threadFunc(void arg) { while (1) { int ret = int_ret_func(2, 3); EXPECT_EQ(ret, 6); void_ret_func(2, 3, 4); usleep(1000); }
}
TEST(TestSuite, Factorial_Stub) { MOCKER(int_ret_func).stubs().will(invoke(stub_int_ret_func)); MOCKER(void_ret_func).stubs().will(invoke(stub_void_ret_func));
}` running result:
because of data using after free, need to fix