From 2be59680f2fb0801b43522cd38cc387c8ff38766 Mon Sep 17 00:00:00 2001 From: zhushengle Date: Tue, 19 Oct 2021 18:57:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E5=86=92=E7=83=9F=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Close #I4EOGA Signed-off-by: zhushengle Change-Id: I0f10f81d41564d4d34fc2f89692da0b3211f5918 --- testsuites/unittest/config.gni | 6 +- testsuites/unittest/process/process/BUILD.gn | 42 ++-- .../{smoke => full}/process_test_007.cpp | 0 .../{smoke => full}/process_test_040.cpp | 0 .../{smoke => full}/process_test_041.cpp | 0 .../{smoke => full}/process_test_049.cpp | 0 .../{smoke => full}/process_test_050.cpp | 0 .../{smoke => full}/process_test_051.cpp | 0 .../{smoke => full}/process_test_052.cpp | 0 .../{smoke => full}/process_test_056.cpp | 0 .../{smoke => full}/process_test_057.cpp | 0 .../{smoke => full}/process_test_058.cpp | 0 .../{smoke => full}/process_test_059.cpp | 0 .../{smoke => full}/process_test_060.cpp | 0 .../{smoke => full}/process_test_063.cpp | 0 .../{smoke => full}/process_test_064.cpp | 0 .../{smoke => full}/process_test_065.cpp | 0 .../{smoke => full}/process_test_066.cpp | 0 .../{smoke => full}/process_test_067.cpp | 0 .../{smoke => full}/process_test_068.cpp | 0 .../{smoke => full}/process_test_069.cpp | 0 .../process/process/process_process_test.cpp | 233 +++--------------- .../{full => smoke}/process_test_054.cpp | 0 .../{full => smoke}/process_test_055.cpp | 0 .../{full => smoke}/process_test_061.cpp | 0 testsuites/unittest/process/pthread/BUILD.gn | 6 +- .../{smoke => full}/pthread_test_004.cpp | 4 + .../{smoke => full}/pthread_test_005.cpp | 0 .../process/pthread/it_pthread_test.h | 4 +- .../process/pthread/process_pthread_test.cpp | 88 ++++--- .../pthread/smoke/pthread_cond_test_003.cpp | 151 ++++++++++++ .../pthread/smoke/pthread_cond_test_004.cpp | 143 +++++++++++ .../pthread/smoke/pthread_test_009.cpp | 4 - 33 files changed, 418 insertions(+), 263 deletions(-) rename testsuites/unittest/process/process/{smoke => full}/process_test_007.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_040.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_041.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_049.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_050.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_051.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_052.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_056.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_057.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_058.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_059.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_060.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_063.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_064.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_065.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_066.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_067.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_068.cpp (100%) rename testsuites/unittest/process/process/{smoke => full}/process_test_069.cpp (100%) rename testsuites/unittest/process/process/{full => smoke}/process_test_054.cpp (100%) rename testsuites/unittest/process/process/{full => smoke}/process_test_055.cpp (100%) rename testsuites/unittest/process/process/{full => smoke}/process_test_061.cpp (100%) rename testsuites/unittest/process/pthread/{smoke => full}/pthread_test_004.cpp (99%) rename testsuites/unittest/process/pthread/{smoke => full}/pthread_test_005.cpp (100%) create mode 100644 testsuites/unittest/process/pthread/smoke/pthread_cond_test_003.cpp create mode 100644 testsuites/unittest/process/pthread/smoke/pthread_cond_test_004.cpp diff --git a/testsuites/unittest/config.gni b/testsuites/unittest/config.gni index f2a2257f..9a5139eb 100644 --- a/testsuites/unittest/config.gni +++ b/testsuites/unittest/config.gni @@ -63,15 +63,15 @@ LOSCFG_USER_TEST_POSIX_MQUEUE = true LOSCFG_USER_TEST_POSIX_MEM = true LOSCFG_USER_TEST_SPINLOCK = true LOSCFG_USER_TEST_RWLOCK = true -LOSCFG_USER_TEST_PTHREAD = false -LOSCFG_USER_TEST_PROCESS = false +LOSCFG_USER_TEST_PTHREAD = true +LOSCFG_USER_TEST_PROCESS = true LOSCFG_USER_TEST_MUTEX = true LOSCFG_USER_TEST_SECURITY_CAPABILITY = true LOSCFG_USER_TEST_SECURITY_VID = true LOSCFG_USER_TEST_SECURITY_REUGID = true LOSCFG_USER_TEST_SIGNAL = true LOSCFG_USER_TEST_SYS = true -LOSCFG_USER_TEST_TIME_CLOCK = true +LOSCFG_USER_TEST_TIME_CLOCK = true LOSCFG_USER_TEST_TIME_TIMER = true LOSCFG_USER_TEST_UTIL = true LOSCFG_USER_TEST_TRACE = false diff --git a/testsuites/unittest/process/process/BUILD.gn b/testsuites/unittest/process/process/BUILD.gn index 8923ca0c..8263c8cb 100644 --- a/testsuites/unittest/process/process/BUILD.gn +++ b/testsuites/unittest/process/process/BUILD.gn @@ -47,7 +47,6 @@ sources_smoke = [ "smoke/process_test_004.cpp", "smoke/process_test_005.cpp", "smoke/process_test_006.cpp", - "smoke/process_test_007.cpp", "smoke/process_test_008.cpp", "smoke/process_test_009.cpp", "smoke/process_test_010.cpp", @@ -79,8 +78,6 @@ sources_smoke = [ "smoke/process_test_037.cpp", "smoke/process_test_038.cpp", "smoke/process_test_039.cpp", - "smoke/process_test_040.cpp", - "smoke/process_test_041.cpp", "smoke/process_test_042.cpp", "smoke/process_test_043.cpp", "smoke/process_test_044.cpp", @@ -88,21 +85,9 @@ sources_smoke = [ "smoke/process_test_046.cpp", "smoke/process_test_047.cpp", "smoke/process_test_048.cpp", - "smoke/process_test_049.cpp", - "smoke/process_test_050.cpp", - "smoke/process_test_051.cpp", - "smoke/process_test_056.cpp", - "smoke/process_test_057.cpp", - "smoke/process_test_058.cpp", - "smoke/process_test_059.cpp", - "smoke/process_test_060.cpp", - "smoke/process_test_063.cpp", - "smoke/process_test_064.cpp", - "smoke/process_test_065.cpp", - "smoke/process_test_066.cpp", - "smoke/process_test_067.cpp", - "smoke/process_test_068.cpp", - "smoke/process_test_069.cpp", + "smoke/process_test_054.cpp", + "smoke/process_test_055.cpp", + "smoke/process_test_061.cpp", "smp/process_test_smp_001.cpp", "smp/process_test_smp_002.cpp", "smp/process_test_smp_003.cpp", @@ -114,10 +99,25 @@ sources_smoke = [ ] sources_full = [ + "full/process_test_007.cpp", + "full/process_test_040.cpp", + "full/process_test_041.cpp", + "full/process_test_049.cpp", + "full/process_test_050.cpp", + "full/process_test_051.cpp", + "full/process_test_056.cpp", + "full/process_test_057.cpp", + "full/process_test_058.cpp", + "full/process_test_059.cpp", + "full/process_test_060.cpp", + "full/process_test_063.cpp", + "full/process_test_064.cpp", + "full/process_test_065.cpp", + "full/process_test_066.cpp", + "full/process_test_067.cpp", + "full/process_test_068.cpp", + "full/process_test_069.cpp", "full/process_test_053.cpp", - "full/process_test_054.cpp", - "full/process_test_055.cpp", - "full/process_test_061.cpp", "full/process_test_062.cpp", ] diff --git a/testsuites/unittest/process/process/smoke/process_test_007.cpp b/testsuites/unittest/process/process/full/process_test_007.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_007.cpp rename to testsuites/unittest/process/process/full/process_test_007.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_040.cpp b/testsuites/unittest/process/process/full/process_test_040.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_040.cpp rename to testsuites/unittest/process/process/full/process_test_040.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_041.cpp b/testsuites/unittest/process/process/full/process_test_041.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_041.cpp rename to testsuites/unittest/process/process/full/process_test_041.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_049.cpp b/testsuites/unittest/process/process/full/process_test_049.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_049.cpp rename to testsuites/unittest/process/process/full/process_test_049.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_050.cpp b/testsuites/unittest/process/process/full/process_test_050.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_050.cpp rename to testsuites/unittest/process/process/full/process_test_050.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_051.cpp b/testsuites/unittest/process/process/full/process_test_051.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_051.cpp rename to testsuites/unittest/process/process/full/process_test_051.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_052.cpp b/testsuites/unittest/process/process/full/process_test_052.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_052.cpp rename to testsuites/unittest/process/process/full/process_test_052.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_056.cpp b/testsuites/unittest/process/process/full/process_test_056.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_056.cpp rename to testsuites/unittest/process/process/full/process_test_056.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_057.cpp b/testsuites/unittest/process/process/full/process_test_057.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_057.cpp rename to testsuites/unittest/process/process/full/process_test_057.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_058.cpp b/testsuites/unittest/process/process/full/process_test_058.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_058.cpp rename to testsuites/unittest/process/process/full/process_test_058.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_059.cpp b/testsuites/unittest/process/process/full/process_test_059.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_059.cpp rename to testsuites/unittest/process/process/full/process_test_059.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_060.cpp b/testsuites/unittest/process/process/full/process_test_060.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_060.cpp rename to testsuites/unittest/process/process/full/process_test_060.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_063.cpp b/testsuites/unittest/process/process/full/process_test_063.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_063.cpp rename to testsuites/unittest/process/process/full/process_test_063.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_064.cpp b/testsuites/unittest/process/process/full/process_test_064.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_064.cpp rename to testsuites/unittest/process/process/full/process_test_064.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_065.cpp b/testsuites/unittest/process/process/full/process_test_065.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_065.cpp rename to testsuites/unittest/process/process/full/process_test_065.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_066.cpp b/testsuites/unittest/process/process/full/process_test_066.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_066.cpp rename to testsuites/unittest/process/process/full/process_test_066.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_067.cpp b/testsuites/unittest/process/process/full/process_test_067.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_067.cpp rename to testsuites/unittest/process/process/full/process_test_067.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_068.cpp b/testsuites/unittest/process/process/full/process_test_068.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_068.cpp rename to testsuites/unittest/process/process/full/process_test_068.cpp diff --git a/testsuites/unittest/process/process/smoke/process_test_069.cpp b/testsuites/unittest/process/process/full/process_test_069.cpp similarity index 100% rename from testsuites/unittest/process/process/smoke/process_test_069.cpp rename to testsuites/unittest/process/process/full/process_test_069.cpp diff --git a/testsuites/unittest/process/process/process_process_test.cpp b/testsuites/unittest/process/process/process_process_test.cpp index 4f602173..73cc347a 100644 --- a/testsuites/unittest/process/process/process_process_test.cpp +++ b/testsuites/unittest/process/process/process_process_test.cpp @@ -126,17 +126,6 @@ HWTEST_F(ProcessProcessTest, ItTestProcess006, TestSize.Level0) ItTestProcess006(); } -/* * - * @tc.name: it_test_process_007 - * @tc.desc: function for ProcessProcessTest - * @tc.type: FUNC - * @tc.require: AR000EEMQ9 - */ -HWTEST_F(ProcessProcessTest, ItTestProcess007, TestSize.Level0) -{ - ItTestProcess007(); -} - /* * * @tc.name: it_test_process_008 * @tc.desc: function for ProcessProcessTest @@ -478,28 +467,6 @@ HWTEST_F(ProcessProcessTest, ItTestProcess039, TestSize.Level0) ItTestProcess039(); } -/* * - * @tc.name: it_test_process_040 - * @tc.desc: function for ProcessProcessTest - * @tc.type: FUNC - * @tc.require: AR000EEMQ9 - */ -HWTEST_F(ProcessProcessTest, ItTestProcess040, TestSize.Level0) -{ - ItTestProcess040(); -} - -/* * - * @tc.name: it_test_process_041 - * @tc.desc: function for ProcessProcessTest - * @tc.type: FUNC - * @tc.require: AR000EEMQ9 - */ -HWTEST_F(ProcessProcessTest, ItTestProcess041, TestSize.Level0) -{ - ItTestProcess041(); -} - /* * * @tc.name: it_test_process_042 * @tc.desc: function for ProcessProcessTest @@ -578,172 +545,36 @@ HWTEST_F(ProcessProcessTest, ItTestProcess048, TestSize.Level0) } /* * - * @tc.name: it_test_process_049 - * @tc.desc: function for ProcessProcessTest - * @tc.type: FUNC - * @tc.require: DTS202101040I5J4KP0H00 - */ -HWTEST_F(ProcessProcessTest, ItTestProcess049, TestSize.Level0) -{ - ItTestProcess049(); -} - -/* * - * @tc.name: it_test_process_050 - * @tc.desc: function for ProcessProcessTest - * @tc.type: FUNC - * @tc.require: DTS202101040I5J4KP0H00 - */ -HWTEST_F(ProcessProcessTest, ItTestProcess050, TestSize.Level0) -{ - ItTestProcess050(); -} - -/* * - * @tc.name: it_test_process_051 - * @tc.desc: function for ProcessProcessTest - * @tc.type: FUNC - * @tc.require: DTS202101040I5J4KP0H00 - */ -HWTEST_F(ProcessProcessTest, ItTestProcess051, TestSize.Level0) -{ - ItTestProcess051(); -} - -/* * - * @tc.name: it_test_process_056 - * @tc.desc: function for posix_spawn:Verifying Basic Functions - * @tc.type: FUNC - * @tc.require: AR000E0QAB - */ -HWTEST_F(ProcessProcessTest, ItTestProcess056, TestSize.Level0) -{ - ItTestProcess056(); -} - -/* * - * @tc.name: it_test_process_057 - * @tc.desc: function for posix_spawnp:Verifying Basic Functions - * @tc.type: FUNC - * @tc.require: AR000E0QAB - */ -HWTEST_F(ProcessProcessTest, ItTestProcess057, TestSize.Level0) -{ - ItTestProcess057(); -} - -/* * - * @tc.name: it_test_process_058 - * @tc.desc: function for posix_spawn: The attr parameter is correctly transferred and the flag is set. - * @tc.type: FUNC - * @tc.require: AR000E0QAB - */ -HWTEST_F(ProcessProcessTest, ItTestProcess058, TestSize.Level0) -{ - ItTestProcess058(); -} - -/* * - * @tc.name: it_test_process_059 - * @tc.desc: function for posix_spawnp: The attr parameter is correctly transferred and the flag is set. - * @tc.type: FUNC - * @tc.require: AR000E0QAB - */ -HWTEST_F(ProcessProcessTest, ItTestProcess059, TestSize.Level0) -{ - ItTestProcess059(); -} - -/* * - * @tc.name: it_test_process_060 - * @tc.desc: function for posix_spawnp: Error code verification for the attr setting function. - * The attr parameter is incorrect and the error code is verified. - * @tc.type: FUNC - * @tc.require: AR000E0QAB - */ -HWTEST_F(ProcessProcessTest, ItTestProcess060, TestSize.Level0) -{ - ItTestProcess060(); -} - -/* * - * @tc.name: it_test_process_063 - * @tc.desc: function for posix_spawn: The file path, argv command, and envp environment variable are invalid. - * Error code verification is performed. - * @tc.type: FUNC - * @tc.require: AR000E0QAB - */ -HWTEST_F(ProcessProcessTest, ItTestProcess063, TestSize.Level0) -{ - ItTestProcess063(); -} - -/* * - * @tc.name: it_test_process_064 - * @tc.desc: function for posix_spawnp: The file path, argv command, and envp environment variable are invalid. - * Error code verification is performed. - * @tc.type: FUNC - * @tc.require: AR000E0QAB - */ -HWTEST_F(ProcessProcessTest, ItTestProcess064, TestSize.Level0) -{ - ItTestProcess064(); -} - -/* * - * @tc.name: it_test_process_065 - * @tc.desc: function for posix_spawn: Error code verification for the attr setting function. - * The attr parameter is incorrect and the error code is verified. - * @tc.type: FUNC - * @tc.require: AR000E0QAB - */ -HWTEST_F(ProcessProcessTest, ItTestProcess065, TestSize.Level0) -{ - ItTestProcess065(); -} - -/* * - * @tc.name: it_test_process_066 - * @tc.desc: function for posix_spawn: Check the effect of subprocess settings when attr is valid. - * @tc.type: FUNC - * @tc.require: AR000E0QAB - */ -HWTEST_F(ProcessProcessTest, ItTestProcess066, TestSize.Level0) -{ - ItTestProcess066(); -} - -/* * - * @tc.name: it_test_process_067 - * @tc.desc: function for posix_spawn: Check the effect of subprocess settings when attr is valid. + * @tc.name: it_test_process_054 + * @tc.desc: function for waitid: The waitid parameter is incorrect and the error code is verified. * @tc.type: FUNC * @tc.require: AR000E0QAB */ -HWTEST_F(ProcessProcessTest, ItTestProcess067, TestSize.Level0) +HWTEST_F(ProcessProcessTest, ItTestProcess054, TestSize.Level0) { - ItTestProcess067(); + ItTestProcess054(); } /* * - * @tc.name: it_test_process_068 - * @tc.desc: function for posix_spawn: Verify the effect of the argv and envp parameters in subprocesses. + * @tc.name: it_test_process_055 + * @tc.desc: function for waitid:To test the function of transferring different parameters of the waitid. * @tc.type: FUNC * @tc.require: AR000E0QAB */ -HWTEST_F(ProcessProcessTest, ItTestProcess068, TestSize.Level0) +HWTEST_F(ProcessProcessTest, ItTestProcess055, TestSize.Level0) { - ItTestProcess068(); + ItTestProcess055(); } /* * - * @tc.name: it_test_process_069 - * @tc.desc: function for posix_spawnp: Verify the effect of the argv and envp parameters in subprocesses. + * @tc.name: it_test_process_061 + * @tc.desc: function for killpg: The killpg parameter is incorrect and the error code is verified. * @tc.type: FUNC * @tc.require: AR000E0QAB */ -HWTEST_F(ProcessProcessTest, ItTestProcess069, TestSize.Level0) +HWTEST_F(ProcessProcessTest, ItTestProcess061, TestSize.Level0) { - ItTestProcess069(); + ItTestProcess061(); } #ifdef LOSCFG_USER_TEST_SMP @@ -839,48 +670,48 @@ HWTEST_F(ProcessProcessTest, ItTestProcessSmp008, TestSize.Level0) #if defined(LOSCFG_USER_TEST_FULL) /* * - * @tc.name: it_test_process_053 - * @tc.desc: function for killpg:Sends a signal to the process group, - * Other processes in the process group can receive the signal. + * @tc.name: it_test_process_007 + * @tc.desc: function for ProcessProcessTest * @tc.type: FUNC - * @tc.require: AR000E0QAB + * @tc.require: AR000EEMQ9 */ -HWTEST_F(ProcessProcessTest, ItTestProcess053, TestSize.Level0) +HWTEST_F(ProcessProcessTest, ItTestProcess007, TestSize.Level0) { - ItTestProcess053(); + ItTestProcess007(); } /* * - * @tc.name: it_test_process_054 - * @tc.desc: function for waitid: The waitid parameter is incorrect and the error code is verified. + * @tc.name: it_test_process_040 + * @tc.desc: function for ProcessProcessTest * @tc.type: FUNC - * @tc.require: AR000E0QAB + * @tc.require: AR000EEMQ9 */ -HWTEST_F(ProcessProcessTest, ItTestProcess054, TestSize.Level0) +HWTEST_F(ProcessProcessTest, ItTestProcess040, TestSize.Level0) { - ItTestProcess054(); + ItTestProcess040(); } /* * - * @tc.name: it_test_process_055 - * @tc.desc: function for waitid:To test the function of transferring different parameters of the waitid. + * @tc.name: it_test_process_041 + * @tc.desc: function for ProcessProcessTest * @tc.type: FUNC - * @tc.require: AR000E0QAB + * @tc.require: AR000EEMQ9 */ -HWTEST_F(ProcessProcessTest, ItTestProcess055, TestSize.Level0) +HWTEST_F(ProcessProcessTest, ItTestProcess041, TestSize.Level0) { - ItTestProcess055(); + ItTestProcess041(); } /* * - * @tc.name: it_test_process_061 - * @tc.desc: function for killpg: The killpg parameter is incorrect and the error code is verified. + * @tc.name: it_test_process_053 + * @tc.desc: function for killpg:Sends a signal to the process group, + * Other processes in the process group can receive the signal. * @tc.type: FUNC * @tc.require: AR000E0QAB */ -HWTEST_F(ProcessProcessTest, ItTestProcess061, TestSize.Level0) +HWTEST_F(ProcessProcessTest, ItTestProcess053, TestSize.Level0) { - ItTestProcess061(); + ItTestProcess053(); } /* * diff --git a/testsuites/unittest/process/process/full/process_test_054.cpp b/testsuites/unittest/process/process/smoke/process_test_054.cpp similarity index 100% rename from testsuites/unittest/process/process/full/process_test_054.cpp rename to testsuites/unittest/process/process/smoke/process_test_054.cpp diff --git a/testsuites/unittest/process/process/full/process_test_055.cpp b/testsuites/unittest/process/process/smoke/process_test_055.cpp similarity index 100% rename from testsuites/unittest/process/process/full/process_test_055.cpp rename to testsuites/unittest/process/process/smoke/process_test_055.cpp diff --git a/testsuites/unittest/process/process/full/process_test_061.cpp b/testsuites/unittest/process/process/smoke/process_test_061.cpp similarity index 100% rename from testsuites/unittest/process/process/full/process_test_061.cpp rename to testsuites/unittest/process/process/smoke/process_test_061.cpp diff --git a/testsuites/unittest/process/pthread/BUILD.gn b/testsuites/unittest/process/pthread/BUILD.gn index d32e2bba..309c51c5 100644 --- a/testsuites/unittest/process/pthread/BUILD.gn +++ b/testsuites/unittest/process/pthread/BUILD.gn @@ -46,12 +46,12 @@ sources_smoke = [ "smoke/pthread_atfork_test_002.cpp", "smoke/pthread_cond_test_001.cpp", "smoke/pthread_cond_test_002.cpp", + "smoke/pthread_cond_test_003.cpp", + "smoke/pthread_cond_test_004.cpp", "smoke/pthread_once_test_001.cpp", "smoke/pthread_test_001.cpp", "smoke/pthread_test_002.cpp", "smoke/pthread_test_003.cpp", - "smoke/pthread_test_004.cpp", - "smoke/pthread_test_005.cpp", "smoke/pthread_test_006.cpp", "smoke/pthread_test_007.cpp", "smoke/pthread_test_008.cpp", @@ -69,6 +69,8 @@ sources_smoke = [ ] sources_full = [ + "full/pthread_test_004.cpp", + "full/pthread_test_005.cpp", ] if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) { diff --git a/testsuites/unittest/process/pthread/smoke/pthread_test_004.cpp b/testsuites/unittest/process/pthread/full/pthread_test_004.cpp similarity index 99% rename from testsuites/unittest/process/pthread/smoke/pthread_test_004.cpp rename to testsuites/unittest/process/pthread/full/pthread_test_004.cpp index b3cce7e4..18bc242e 100644 --- a/testsuites/unittest/process/pthread/smoke/pthread_test_004.cpp +++ b/testsuites/unittest/process/pthread/full/pthread_test_004.cpp @@ -245,6 +245,10 @@ static void *threadFunc(void *arg) ret = pthread_create(&newPthread, &a, threadFunc2, 0); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); +#ifdef LOSCFG_USER_TEST_SMP + sleep(1); +#endif + ret = pthread_spin_lock(&g_spinTestLock); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); ICUNIT_GOTO_EQUAL(g_pthreadTestCount, 4, g_pthreadTestCount, EXIT); // 4, here assert the result. diff --git a/testsuites/unittest/process/pthread/smoke/pthread_test_005.cpp b/testsuites/unittest/process/pthread/full/pthread_test_005.cpp similarity index 100% rename from testsuites/unittest/process/pthread/smoke/pthread_test_005.cpp rename to testsuites/unittest/process/pthread/full/pthread_test_005.cpp diff --git a/testsuites/unittest/process/pthread/it_pthread_test.h b/testsuites/unittest/process/pthread/it_pthread_test.h index 1bd3f098..5a285732 100644 --- a/testsuites/unittest/process/pthread/it_pthread_test.h +++ b/testsuites/unittest/process/pthread/it_pthread_test.h @@ -79,4 +79,6 @@ extern void ItTestPthreadAtfork002(void); extern void ItTestPthreadOnce001(void); extern void ItTestPthreadCond001(void); extern void ItTestPthreadCond002(void); -#endif \ No newline at end of file +extern void ItTestPthreadCond003(void); +extern void ItTestPthreadCond004(void); +#endif diff --git a/testsuites/unittest/process/pthread/process_pthread_test.cpp b/testsuites/unittest/process/pthread/process_pthread_test.cpp index ac6f1076..e29aeb8e 100644 --- a/testsuites/unittest/process/pthread/process_pthread_test.cpp +++ b/testsuites/unittest/process/pthread/process_pthread_test.cpp @@ -87,28 +87,6 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread003, TestSize.Level0) ItTestPthread003(); } -/* * - * @tc.name: it_test_pthread_004 - * @tc.desc: function for ProcessPthreadTest - * @tc.type: FUNC - * @tc.require: AR000EEMQ9 - */ -HWTEST_F(ProcessPthreadTest, ItTestPthread004, TestSize.Level0) -{ - ItTestPthread004(); -} - -/* * - * @tc.name: it_test_pthread_005 - * @tc.desc: function for ProcessPthreadTest - * @tc.type: FUNC - * @tc.require: AR000EEMQ9 - */ -HWTEST_F(ProcessPthreadTest, ItTestPthread005, TestSize.Level0) -{ - ItTestPthread005(); -} - #ifndef LOSCFG_USER_TEST_SMP /* * * @tc.name: it_test_pthread_006 @@ -237,38 +215,39 @@ HWTEST_F(ProcessPthreadTest, ItTestPthread016, TestSize.Level0) } /* * - * @tc.name: it_test_pthread_017 + * @tc.name: it_test_pthread_018 * @tc.desc: function for ProcessPthreadTest * @tc.type: FUNC * @tc.require: AR000EEMQ9 */ -HWTEST_F(ProcessPthreadTest, ItTestPthread017, TestSize.Level0) +HWTEST_F(ProcessPthreadTest, ItTestPthread018, TestSize.Level0) { - ItTestPthread017(); + ItTestPthread018(); } /* * - * @tc.name: it_test_pthread_018 + * @tc.name: it_test_pthread_019 * @tc.desc: function for ProcessPthreadTest * @tc.type: FUNC * @tc.require: AR000EEMQ9 */ -HWTEST_F(ProcessPthreadTest, ItTestPthread018, TestSize.Level0) +HWTEST_F(ProcessPthreadTest, ItTestPthread019, TestSize.Level0) { - ItTestPthread018(); + ItTestPthread019(); } /* * - * @tc.name: it_test_pthread_019 + * @tc.name: it_test_pthread_017 * @tc.desc: function for ProcessPthreadTest * @tc.type: FUNC * @tc.require: AR000EEMQ9 */ -HWTEST_F(ProcessPthreadTest, ItTestPthread019, TestSize.Level0) +HWTEST_F(ProcessPthreadTest, ItTestPthread017, TestSize.Level0) { - ItTestPthread019(); + ItTestPthread017(); } + /* * * @tc.name: it_test_pthread_once_001 * @tc.desc: function for ProcessPthreadTest @@ -323,5 +302,52 @@ HWTEST_F(ProcessPthreadTest, ItTestPthreadCond002, TestSize.Level0) { ItTestPthreadCond002(); } + +/* * + * @tc.name: it_test_pthread_cond_003 + * @tc.desc: function for ProcessPthreadTest + * @tc.type: FUNC + * @tc.require: AR000EEMQ9 + */ +HWTEST_F(ProcessPthreadTest, ItTestPthreadCond003, TestSize.Level0) +{ + ItTestPthreadCond003(); +} + +/* * + * @tc.name: it_test_pthread_cond_004 + * @tc.desc: function for ProcessPthreadTest + * @tc.type: FUNC + * @tc.require: AR000EEMQ9 + */ +HWTEST_F(ProcessPthreadTest, ItTestPthreadCond004, TestSize.Level0) +{ + ItTestPthreadCond004(); +} + +#endif + +#if defined(LOSCFG_USER_TEST_FULL) +/* * + * @tc.name: it_test_pthread_004 + * @tc.desc: function for ProcessPthreadTest + * @tc.type: FUNC + * @tc.require: AR000EEMQ9 + */ +HWTEST_F(ProcessPthreadTest, ItTestPthread004, TestSize.Level0) +{ + ItTestPthread004(); +} + +/* * + * @tc.name: it_test_pthread_005 + * @tc.desc: function for ProcessPthreadTest + * @tc.type: FUNC + * @tc.require: AR000EEMQ9 + */ +HWTEST_F(ProcessPthreadTest, ItTestPthread005, TestSize.Level0) +{ + ItTestPthread005(); +} #endif } // namespace OHOS diff --git a/testsuites/unittest/process/pthread/smoke/pthread_cond_test_003.cpp b/testsuites/unittest/process/pthread/smoke/pthread_cond_test_003.cpp new file mode 100644 index 00000000..736d7d5a --- /dev/null +++ b/testsuites/unittest/process/pthread/smoke/pthread_cond_test_003.cpp @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "it_pthread_test.h" + +static pthread_cond_t g_pthread_cond; +static pthread_mutex_t g_pthread_mutex; +#define TEST_THREAD_COUNT 5 +static void *pthread_cond_func001(void *arg) +{ + int ret; + struct timespec ts; + + g_testCount++; + + ret = pthread_mutex_lock(&g_pthread_mutex); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += 60; /* 60: wait 1 minute */ + + ret = pthread_cond_timedwait(&g_pthread_cond, &g_pthread_mutex, &ts); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + ret = pthread_mutex_unlock(&g_pthread_mutex); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + g_testCount++; +EXIT: + return NULL; +} + +static VOID *pthread_f06(void *argument) +{ + int policy; + int ret; + int i; + pthread_attr_t attr; + struct sched_param schedParam = { 0 }; + pthread_t thread[TEST_THREAD_COUNT]; + + g_testCount = 0; + + ret = pthread_attr_init(&attr); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + ret = pthread_getschedparam(pthread_self(), &policy, &schedParam); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + schedParam.sched_priority -= 1; + ret = pthread_attr_setschedparam(&attr, &schedParam); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + for (i = 0; i < TEST_THREAD_COUNT; i++) { + ret = pthread_create(&thread[i], &attr, pthread_cond_func001, NULL); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + } + + sleep(1); + + ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); /* 5: Five threads */ + + ret = pthread_mutex_lock(&g_pthread_mutex); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + ret = pthread_cond_broadcast(&g_pthread_cond); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + ret = pthread_mutex_unlock(&g_pthread_mutex); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + for (i = 0; i < TEST_THREAD_COUNT; i++) { + ret = pthread_join(thread[i], NULL); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + } + + ICUNIT_GOTO_EQUAL(g_testCount, 10, g_testCount, EXIT); /* 10: Twice per thread */ +EXIT: + return NULL; +} + +static int TestCase(void) +{ + int policy; + pthread_attr_t attr; + pthread_t newTh; + struct sched_param schedParam = { 0 }; + int ret; + + ret = pthread_mutex_init(&g_pthread_mutex, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = pthread_cond_init(&g_pthread_cond, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = pthread_attr_init(&attr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = pthread_getschedparam(pthread_self(), &policy, &schedParam); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + schedParam.sched_priority -= 1; + ret = pthread_attr_setschedparam(&attr, &schedParam); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = pthread_create(&newTh, &attr, pthread_f06, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = pthread_join(newTh, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + return 0; +} + +void ItTestPthreadCond003(void) +{ + TEST_ADD_CASE("IT_POSIX_PTHREAD_COND_003", TestCase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION); +} diff --git a/testsuites/unittest/process/pthread/smoke/pthread_cond_test_004.cpp b/testsuites/unittest/process/pthread/smoke/pthread_cond_test_004.cpp new file mode 100644 index 00000000..65480312 --- /dev/null +++ b/testsuites/unittest/process/pthread/smoke/pthread_cond_test_004.cpp @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors may be used + * to endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "it_pthread_test.h" +static pthread_cond_t g_pthread_cond; +static pthread_mutex_t g_pthread_mutex; +#define TEST_THREAD_COUNT 5 + +static void *pthread_cond_func002(void *arg) +{ + int ret; + struct timespec ts; + + g_testCount++; + + ret = pthread_mutex_lock(&g_pthread_mutex); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += 2; /* 2: wait 2 seconds */ + + ret = pthread_cond_timedwait(&g_pthread_cond, &g_pthread_mutex, &ts); + ICUNIT_GOTO_EQUAL(ret, ETIMEDOUT, ret, EXIT); + + ret = pthread_mutex_unlock(&g_pthread_mutex); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + g_testCount++; +EXIT: + return NULL; +} + +static VOID *pthread_f07(void *argument) +{ + int policy; + int ret; + int i; + pthread_attr_t attr; + struct sched_param schedParam = { 0 }; + pthread_t thread[TEST_THREAD_COUNT]; + + g_testCount = 0; + + ret = pthread_attr_init(&attr); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + ret = pthread_getschedparam(pthread_self(), &policy, &schedParam); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + schedParam.sched_priority -= 1; + ret = pthread_attr_setschedparam(&attr, &schedParam); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + + for (i = 0; i < TEST_THREAD_COUNT; i++) { + ret = pthread_create(&thread[i], &attr, pthread_cond_func002, NULL); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + } + + sleep(1); + + ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); /* 5: Five threads */ + + for (i = 0; i < TEST_THREAD_COUNT; i++) { + ret = pthread_join(thread[i], NULL); + ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT); + } + + ICUNIT_GOTO_EQUAL(g_testCount, 10, g_testCount, EXIT); /* 10: Twice per thread */ + +EXIT: + return NULL; +} + +static int TestCase(void) +{ + int policy; + pthread_attr_t attr; + pthread_t newTh; + struct sched_param schedParam = { 0 }; + int ret; + + ret = pthread_mutex_init(&g_pthread_mutex, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = pthread_cond_init(&g_pthread_cond, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = pthread_attr_init(&attr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = pthread_getschedparam(pthread_self(), &policy, &schedParam); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + schedParam.sched_priority -= 1; + ret = pthread_attr_setschedparam(&attr, &schedParam); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = pthread_create(&newTh, &attr, pthread_f07, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = pthread_join(newTh, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + return 0; +} + +void ItTestPthreadCond004(void) +{ + TEST_ADD_CASE("IT_POSIX_PTHREAD_COND_004", TestCase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION); +} diff --git a/testsuites/unittest/process/pthread/smoke/pthread_test_009.cpp b/testsuites/unittest/process/pthread/smoke/pthread_test_009.cpp index 9fd1436f..bd1968b4 100644 --- a/testsuites/unittest/process/pthread/smoke/pthread_test_009.cpp +++ b/testsuites/unittest/process/pthread/smoke/pthread_test_009.cpp @@ -53,10 +53,6 @@ static UINT32 Testcase(VOID) #ifdef LOSCFG_USER_TEST_SMP sleep(1); #endif - - ret = pthread_join(g_th, NULL); - ICUNIT_ASSERT_EQUAL(ret, 0, ret); - ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, assert the exit code. return 0; } -- GitLab