diff --git a/testsuites/unittest/process/rwlock/BUILD.gn b/testsuites/unittest/process/rwlock/BUILD.gn index aedc928f25c66a9182d57fff66eb6fdbc250cab3..4ed9394f86a4407a02179bfd1cff961aca0ebe08 100644 --- a/testsuites/unittest/process/rwlock/BUILD.gn +++ b/testsuites/unittest/process/rwlock/BUILD.gn @@ -43,10 +43,10 @@ sources_entry = [ sources_smoke = [ "smoke/pthread_rwlock_test_001.cpp", - "smoke/pthread_rwlock_test_002.cpp", ] sources_full = [ + "full/pthread_rwlock_test_002.cpp", ] if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) { diff --git a/testsuites/unittest/process/rwlock/smoke/pthread_rwlock_test_002.cpp b/testsuites/unittest/process/rwlock/full/pthread_rwlock_test_002.cpp similarity index 99% rename from testsuites/unittest/process/rwlock/smoke/pthread_rwlock_test_002.cpp rename to testsuites/unittest/process/rwlock/full/pthread_rwlock_test_002.cpp index 544748e57a1f68b95a20296182d25c8e10205c50..075c2aa8f131e5e6f47a483a6503d0f00faea281 100644 --- a/testsuites/unittest/process/rwlock/smoke/pthread_rwlock_test_002.cpp +++ b/testsuites/unittest/process/rwlock/full/pthread_rwlock_test_002.cpp @@ -100,6 +100,7 @@ static void *ThreadReadFunc(void *a) ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); while (loop > 0) { + SLEEP_AND_YIELD(1); ret = pthread_rwlock_rdlock(&g_rwlockLock); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); g_isReading[threadCount] = 1; @@ -139,6 +140,7 @@ static void *ThreadWriteFunc1(void *a) ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); while (CheckReadThreadExit()) { + SLEEP_AND_YIELD(1); ret = pthread_rwlock_wrlock(&g_rwlockLock); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); @@ -180,6 +182,7 @@ static void *ThreadWriteFunc(void *a) int threadCount = *((int *)a); while (CheckReadThreadExit() || CheckWriteThreadExit()) { + SLEEP_AND_YIELD(1); ret = pthread_rwlock_wrlock(&g_rwlockLock); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); @@ -247,20 +250,20 @@ static int PthreadRwlockTest(void) count = 1; while (count < WRITE_THREAD_COUNT) { g_writePar[count] = count; - ret = pthread_create(&newPthread, &a, ThreadWriteFunc1, &g_writePar[count]); - ICUNIT_ASSERT_EQUAL(ret, 0, ret); g_isWriting[count] = 0; g_isWriteExit[count] = 0; + ret = pthread_create(&newPthread, &a, ThreadWriteFunc1, &g_writePar[count]); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); count++; } count = 0; while (count < READ_THREAD_COUNT) { g_readPar[count] = count; - ret = pthread_create(&newPthread, &a, ThreadReadFunc, &g_readPar[count]); - ICUNIT_ASSERT_EQUAL(ret, 0, ret); g_isReading[count] = 0; g_isReadExit[count] = 0; + ret = pthread_create(&newPthread, &a, ThreadReadFunc, &g_readPar[count]); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); count++; } diff --git a/testsuites/unittest/process/rwlock/process_rwlock_test.cpp b/testsuites/unittest/process/rwlock/process_rwlock_test.cpp index b4a6753d7310e598ed7261a20bed729eb8b2868e..2a0f5f7de35d0d9801535937dad942b0fb967223 100644 --- a/testsuites/unittest/process/rwlock/process_rwlock_test.cpp +++ b/testsuites/unittest/process/rwlock/process_rwlock_test.cpp @@ -52,7 +52,9 @@ HWTEST_F(ProcessRwlockTest, ItTestPthreadRwlock001, TestSize.Level0) { ItTestPthreadRwlock001(); } +#endif +#if defined(LOSCFG_USER_TEST_FULL) /* * * @tc.name: it_test_pthread_rwlock_002 * @tc.desc: function for ProcessRwlockTest