History

fix low memory crash issue

huili2 committed 9 years ago

Commit d1c0a931 parent 48c2fe116 files · +401 −386Browse files

Showing the changes to test/common/WelsThreadPoolTest.cpp (1 of 16 files). Show all

Unified · Split

test/common/WelsThreadPoolTest.cpp+15−11
@@ -39,7 +39,9 @@ uint32_t CSimpleTask::id = 0; · 38 unmodified lines
3939 void* OneCallingFunc() {
4040 CThreadPoolTest cThreadPoolTest;
4141 CSimpleTask* aTasks[TEST_TASK_NUM];
42− CWelsThreadPool* pThreadPool = & (CWelsThreadPool::AddReference());
42+ CWelsThreadPool* pThreadPool = (CWelsThreadPool::AddReference());
43+ if (pThreadPool == NULL)
44+ return 0;
4345
4446 int32_t i;
4547 for (i = 0; i < TEST_TASK_NUM; i++) {
@@ -70,8 +72,10 @@ TEST (CThreadPoolTest, CThreadPoolTest) { · 24 unmodified lines
7072 EXPECT_EQ (0, iRet);
7173 EXPECT_FALSE (CWelsThreadPool::IsReferenced());
7274
73− CWelsThreadPool* pThreadPool = & (CWelsThreadPool::AddReference ());
74− EXPECT_TRUE(pThreadPool->IsReferenced());
75+ CWelsThreadPool* pThreadPool = (CWelsThreadPool::AddReference());
76+ ASSERT_TRUE (pThreadPool != NULL);
77+
78+ EXPECT_TRUE (pThreadPool->IsReferenced());
7579
7680 EXPECT_EQ (8, pThreadPool->GetThreadNum());
7781
@@ -84,7 +88,7 @@ TEST (CThreadPoolTest, CThreadPoolTest) { · 6 unmodified lines
8488 iRet = CWelsThreadPool::SetThreadNum (4);
8589 EXPECT_EQ (0, iRet);
8690
87− pThreadPool = & (CWelsThreadPool::AddReference ());
91+ pThreadPool = (CWelsThreadPool::AddReference());
8892 EXPECT_TRUE (pThreadPool->IsReferenced());
8993 EXPECT_EQ (4, pThreadPool->GetThreadNum());
9094 pThreadPool->RemoveInstance();
@@ -97,24 +101,24 @@ TEST (CThreadPoolTest, CThreadPoolTestMulti) { · 6 unmodified lines
97101 int iCallingNum = 10;
98102 WELS_THREAD_HANDLE mThreadID[30];
99103 int i = 0;
100−
104+ WELS_THREAD_ERROR_CODE rc;
101105 for (i = 0; i < iCallingNum; i++) {
102− WelsThreadCreate (& (mThreadID[i]), (LPWELS_THREAD_ROUTINE)OneCallingFunc, NULL, 0);
106+ rc = WelsThreadCreate (& (mThreadID[i]), (LPWELS_THREAD_ROUTINE)OneCallingFunc, NULL, 0);
107+ ASSERT_TRUE (rc == WELS_THREAD_ERROR_OK);
103108 WelsSleep (1);
104109 }
105−
106110 for (i = iCallingNum; i < iCallingNum * 2; i++) {
107− WelsThreadCreate (& (mThreadID[i]), (LPWELS_THREAD_ROUTINE)OneCallingFunc, NULL, 0);
111+ rc = WelsThreadCreate (& (mThreadID[i]), (LPWELS_THREAD_ROUTINE)OneCallingFunc, NULL, 0);
112+ ASSERT_TRUE (rc == WELS_THREAD_ERROR_OK);
108113 WelsSleep (1);
109114 WelsThreadJoin (mThreadID[i]);
110115 }
111−
112116 for (i = 0; i < iCallingNum; i++) {
113117 WelsThreadJoin (mThreadID[i]);
114118 }
115−
116119 for (i = iCallingNum * 2; i < iCallingNum * 3; i++) {
117− WelsThreadCreate (& (mThreadID[i]), (LPWELS_THREAD_ROUTINE)OneCallingFunc, NULL, 0);
120+ rc = WelsThreadCreate (& (mThreadID[i]), (LPWELS_THREAD_ROUTINE)OneCallingFunc, NULL, 0);
121+ ASSERT_TRUE (rc == WELS_THREAD_ERROR_OK);
118122 WelsSleep (1);
119123 WelsThreadJoin (mThreadID[i]);
120124 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t