From 70022950acb181f737820f964392cfb4dc41993f Mon Sep 17 00:00:00 2001 From: chenjiafan Date: Fri, 18 Aug 2023 17:53:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=A2=9E=E5=8A=A0smp=20ipc=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenjiafan Change-Id: If0695aa4a6af947537ea2de0b61fdd5dbcee2fd9 --- testsuites/include/osTest.h | 7 + testsuites/sample/kernel/event/BUILD.gn | 22 +++ testsuites/sample/kernel/event/It_los_event.c | 23 +++ testsuites/sample/kernel/event/It_los_event.h | 21 +++ .../kernel/event/smp/It_smp_los_event_001.c | 71 +++++++++ .../kernel/event/smp/It_smp_los_event_002.c | 75 ++++++++++ .../kernel/event/smp/It_smp_los_event_003.c | 74 ++++++++++ .../kernel/event/smp/It_smp_los_event_004.c | 77 ++++++++++ .../kernel/event/smp/It_smp_los_event_005.c | 92 ++++++++++++ .../kernel/event/smp/It_smp_los_event_006.c | 87 +++++++++++ .../kernel/event/smp/It_smp_los_event_007.c | 97 ++++++++++++ .../kernel/event/smp/It_smp_los_event_008.c | 80 ++++++++++ .../kernel/event/smp/It_smp_los_event_009.c | 106 ++++++++++++++ .../kernel/event/smp/It_smp_los_event_010.c | 94 ++++++++++++ .../kernel/event/smp/It_smp_los_event_011.c | 90 ++++++++++++ .../kernel/event/smp/It_smp_los_event_012.c | 100 +++++++++++++ .../kernel/event/smp/It_smp_los_event_013.c | 100 +++++++++++++ .../kernel/event/smp/It_smp_los_event_014.c | 97 ++++++++++++ .../kernel/event/smp/It_smp_los_event_015.c | 107 ++++++++++++++ .../kernel/event/smp/It_smp_los_event_016.c | 76 ++++++++++ .../kernel/event/smp/It_smp_los_event_017.c | 77 ++++++++++ .../kernel/event/smp/It_smp_los_event_018.c | 78 ++++++++++ .../kernel/event/smp/It_smp_los_event_019.c | 78 ++++++++++ .../kernel/event/smp/It_smp_los_event_020.c | 81 ++++++++++ testsuites/sample/kernel/mux/BUILD.gn | 21 +++ testsuites/sample/kernel/mux/It_los_mux.c | 22 +++ testsuites/sample/kernel/mux/It_los_mux.h | 20 +++ .../kernel/mux/smp/It_smp_los_mux_001.c | 82 +++++++++++ .../kernel/mux/smp/It_smp_los_mux_002.c | 84 +++++++++++ .../kernel/mux/smp/It_smp_los_mux_003.c | 104 +++++++++++++ .../kernel/mux/smp/It_smp_los_mux_004.c | 70 +++++++++ .../kernel/mux/smp/It_smp_los_mux_005.c | 79 ++++++++++ .../kernel/mux/smp/It_smp_los_mux_006.c | 102 +++++++++++++ .../kernel/mux/smp/It_smp_los_mux_007.c | 103 +++++++++++++ .../kernel/mux/smp/It_smp_los_mux_008.c | 70 +++++++++ .../kernel/mux/smp/It_smp_los_mux_009.c | 73 +++++++++ .../kernel/mux/smp/It_smp_los_mux_010.c | 75 ++++++++++ .../kernel/mux/smp/It_smp_los_mux_011.c | 105 +++++++++++++ .../kernel/mux/smp/It_smp_los_mux_012.c | 93 ++++++++++++ .../kernel/mux/smp/It_smp_los_mux_013.c | 106 ++++++++++++++ .../kernel/mux/smp/It_smp_los_mux_014.c | 78 ++++++++++ .../kernel/mux/smp/It_smp_los_mux_015.c | 103 +++++++++++++ .../kernel/mux/smp/It_smp_los_mux_016.c | 84 +++++++++++ .../kernel/mux/smp/It_smp_los_mux_017.c | 109 ++++++++++++++ .../kernel/mux/smp/It_smp_los_mux_018.c | 138 ++++++++++++++++++ .../kernel/mux/smp/It_smp_los_mux_019.c | 105 +++++++++++++ testsuites/sample/kernel/queue/BUILD.gn | 27 ++++ testsuites/sample/kernel/queue/It_los_queue.c | 30 ++++ testsuites/sample/kernel/queue/It_los_queue.h | 28 ++++ .../kernel/queue/smp/It_smp_los_queue_001.c | 74 ++++++++++ .../kernel/queue/smp/It_smp_los_queue_002.c | 77 ++++++++++ .../kernel/queue/smp/It_smp_los_queue_003.c | 79 ++++++++++ .../kernel/queue/smp/It_smp_los_queue_004.c | 81 ++++++++++ .../kernel/queue/smp/It_smp_los_queue_005.c | 96 ++++++++++++ .../kernel/queue/smp/It_smp_los_queue_006.c | 93 ++++++++++++ .../kernel/queue/smp/It_smp_los_queue_007.c | 97 ++++++++++++ .../kernel/queue/smp/It_smp_los_queue_008.c | 82 +++++++++++ .../kernel/queue/smp/It_smp_los_queue_009.c | 109 ++++++++++++++ .../kernel/queue/smp/It_smp_los_queue_010.c | 95 ++++++++++++ .../kernel/queue/smp/It_smp_los_queue_011.c | 98 +++++++++++++ .../kernel/queue/smp/It_smp_los_queue_012.c | 101 +++++++++++++ .../kernel/queue/smp/It_smp_los_queue_013.c | 102 +++++++++++++ .../kernel/queue/smp/It_smp_los_queue_014.c | 102 +++++++++++++ .../kernel/queue/smp/It_smp_los_queue_015.c | 107 ++++++++++++++ .../kernel/queue/smp/It_smp_los_queue_016.c | 77 ++++++++++ .../kernel/queue/smp/It_smp_los_queue_017.c | 78 ++++++++++ .../kernel/queue/smp/It_smp_los_queue_018.c | 80 ++++++++++ .../kernel/queue/smp/It_smp_los_queue_019.c | 79 ++++++++++ .../kernel/queue/smp/It_smp_los_queue_020.c | 82 +++++++++++ .../kernel/queue/smp/It_smp_los_queue_021.c | 84 +++++++++++ .../kernel/queue/smp/It_smp_los_queue_022.c | 100 +++++++++++++ .../kernel/queue/smp/It_smp_los_queue_023.c | 98 +++++++++++++ .../kernel/queue/smp/It_smp_los_queue_024.c | 95 ++++++++++++ .../kernel/queue/smp/It_smp_los_queue_025.c | 100 +++++++++++++ testsuites/sample/kernel/sem/BUILD.gn | 13 ++ testsuites/sample/kernel/sem/It_los_sem.c | 14 ++ testsuites/sample/kernel/sem/It_los_sem.h | 12 ++ .../kernel/sem/smp/It_smp_los_sem_001.c | 78 ++++++++++ .../kernel/sem/smp/It_smp_los_sem_002.c | 96 ++++++++++++ .../kernel/sem/smp/It_smp_los_sem_003.c | 84 +++++++++++ .../kernel/sem/smp/It_smp_los_sem_004.c | 94 ++++++++++++ .../kernel/sem/smp/It_smp_los_sem_005.c | 95 ++++++++++++ .../kernel/sem/smp/It_smp_los_sem_006.c | 98 +++++++++++++ .../kernel/sem/smp/It_smp_los_sem_007.c | 99 +++++++++++++ .../kernel/sem/smp/It_smp_los_sem_008.c | 95 ++++++++++++ .../kernel/sem/smp/It_smp_los_sem_009.c | 104 +++++++++++++ .../kernel/sem/smp/It_smp_los_sem_010.c | 75 ++++++++++ .../kernel/sem/smp/It_smp_los_sem_011.c | 76 ++++++++++ testsuites/sample/kernel/swtmr/BUILD.gn | 27 ++++ testsuites/sample/kernel/swtmr/It_los_swtmr.c | 28 ++++ testsuites/sample/kernel/swtmr/It_los_swtmr.h | 27 ++++ .../kernel/swtmr/smp/It_smp_los_swtmr_001.c | 95 ++++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_002.c | 109 ++++++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_003.c | 90 ++++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_004.c | 95 ++++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_005.c | 90 ++++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_006.c | 92 ++++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_007.c | 86 +++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_008.c | 88 +++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_009.c | 86 +++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_010.c | 88 +++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_011.c | 80 ++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_012.c | 82 +++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_013.c | 80 ++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_014.c | 81 ++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_015.c | 89 +++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_016.c | 91 ++++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_017.c | 89 +++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_018.c | 91 ++++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_019.c | 83 +++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_020.c | 85 +++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_021.c | 83 +++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_022.c | 85 +++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_023.c | 95 ++++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_024.c | 117 +++++++++++++++ .../kernel/swtmr/smp/It_smp_los_swtmr_025.c | 100 +++++++++++++ testsuites/sample/kernel/task/BUILD.gn | 9 ++ testsuites/sample/kernel/task/It_los_task.c | 10 ++ testsuites/sample/kernel/task/It_los_task.h | 5 + .../kernel/task/smp/It_smp_los_task_001.c | 69 +++++++++ .../kernel/task/smp/It_smp_los_task_002.c | 69 +++++++++ .../kernel/task/smp/It_smp_los_task_003.c | 75 ++++++++++ .../kernel/task/smp/It_smp_los_task_004.c | 59 ++++++++ .../kernel/task/smp/It_smp_los_task_005.c | 82 +++++++++++ .../kernel/task/smp/It_smp_los_task_006.c | 84 +++++++++++ .../kernel/task/smp/It_smp_los_task_007.c | 75 ++++++++++ testsuites/src/osTest.c | 66 +++++++-- 127 files changed, 9943 insertions(+), 12 deletions(-) create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_001.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_002.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_003.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_004.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_005.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_006.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_007.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_008.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_009.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_010.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_011.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_012.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_013.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_014.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_015.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_016.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_017.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_018.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_019.c create mode 100644 testsuites/sample/kernel/event/smp/It_smp_los_event_020.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_001.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_002.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_003.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_004.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_005.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_006.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_007.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_008.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_009.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_010.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_011.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_012.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_013.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_014.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_015.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_016.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_017.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_018.c create mode 100644 testsuites/sample/kernel/mux/smp/It_smp_los_mux_019.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_001.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_002.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_003.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_004.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_005.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_006.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_007.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_008.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_009.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_010.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_011.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_012.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_013.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_014.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_015.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_016.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_017.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_018.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_019.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_020.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_021.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_022.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_023.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_024.c create mode 100644 testsuites/sample/kernel/queue/smp/It_smp_los_queue_025.c create mode 100644 testsuites/sample/kernel/sem/smp/It_smp_los_sem_001.c create mode 100644 testsuites/sample/kernel/sem/smp/It_smp_los_sem_002.c create mode 100644 testsuites/sample/kernel/sem/smp/It_smp_los_sem_003.c create mode 100644 testsuites/sample/kernel/sem/smp/It_smp_los_sem_004.c create mode 100644 testsuites/sample/kernel/sem/smp/It_smp_los_sem_005.c create mode 100644 testsuites/sample/kernel/sem/smp/It_smp_los_sem_006.c create mode 100644 testsuites/sample/kernel/sem/smp/It_smp_los_sem_007.c create mode 100644 testsuites/sample/kernel/sem/smp/It_smp_los_sem_008.c create mode 100644 testsuites/sample/kernel/sem/smp/It_smp_los_sem_009.c create mode 100644 testsuites/sample/kernel/sem/smp/It_smp_los_sem_010.c create mode 100644 testsuites/sample/kernel/sem/smp/It_smp_los_sem_011.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_001.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_002.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_003.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_004.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_005.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_006.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_007.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_008.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_009.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_010.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_011.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_012.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_013.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_014.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_015.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_016.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_017.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_018.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_019.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_020.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_021.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_022.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_023.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_024.c create mode 100644 testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_025.c create mode 100644 testsuites/sample/kernel/task/smp/It_smp_los_task_001.c create mode 100644 testsuites/sample/kernel/task/smp/It_smp_los_task_002.c create mode 100644 testsuites/sample/kernel/task/smp/It_smp_los_task_003.c create mode 100644 testsuites/sample/kernel/task/smp/It_smp_los_task_004.c create mode 100644 testsuites/sample/kernel/task/smp/It_smp_los_task_005.c create mode 100644 testsuites/sample/kernel/task/smp/It_smp_los_task_006.c create mode 100644 testsuites/sample/kernel/task/smp/It_smp_los_task_007.c diff --git a/testsuites/include/osTest.h b/testsuites/include/osTest.h index 93199aa0..c6de4d03 100644 --- a/testsuites/include/osTest.h +++ b/testsuites/include/osTest.h @@ -249,6 +249,13 @@ extern UINT32 TaskUsedCountGet(VOID); #define TASK_EXISTED_NUM TaskUsedCountGet() #define QUEUE_EXISTED_NUM QueueUsedCountGet() +extern UINT64 TestTickCountGet(VOID); +extern UINT64 TestTickCountByCurrCpuid(VOID); +extern VOID TestBusyTaskDelay(UINT32 tick); +extern VOID TestAssertBusyTaskDelay(UINT32 timeout, UINT32 flag); + +#define TEST_HwiClear(ID) LOS_HwiClear(ID) + #define HWI_NUM_INT_NEG (-4) #define HWI_NUM_INT0 0 #define HWI_NUM_INT1 1 diff --git a/testsuites/sample/kernel/event/BUILD.gn b/testsuites/sample/kernel/event/BUILD.gn index de7cd494..7f20bca2 100644 --- a/testsuites/sample/kernel/event/BUILD.gn +++ b/testsuites/sample/kernel/event/BUILD.gn @@ -74,7 +74,29 @@ static_library("test_event") { "It_los_event_041.c", "It_los_event_042.c", "It_los_event_043.c", + "smp/It_smp_los_event_001.c", + "smp/It_smp_los_event_002.c", + "smp/It_smp_los_event_003.c", + "smp/It_smp_los_event_004.c", + "smp/It_smp_los_event_005.c", + "smp/It_smp_los_event_006.c", + "smp/It_smp_los_event_007.c", + "smp/It_smp_los_event_008.c", + "smp/It_smp_los_event_009.c", + "smp/It_smp_los_event_010.c", + "smp/It_smp_los_event_011.c", + "smp/It_smp_los_event_012.c", + "smp/It_smp_los_event_013.c", + "smp/It_smp_los_event_014.c", + "smp/It_smp_los_event_015.c", + "smp/It_smp_los_event_016.c", + "smp/It_smp_los_event_017.c", + "smp/It_smp_los_event_018.c", + "smp/It_smp_los_event_019.c", + "smp/It_smp_los_event_020.c", ] + include_dirs = [ "." ] + configs += [ "$LITEOSTOPDIR/testsuites:include" ] } diff --git a/testsuites/sample/kernel/event/It_los_event.c b/testsuites/sample/kernel/event/It_los_event.c index ce315fa5..e21a98a9 100644 --- a/testsuites/sample/kernel/event/It_los_event.c +++ b/testsuites/sample/kernel/event/It_los_event.c @@ -83,4 +83,27 @@ VOID ItSuiteLosEvent() ItLosEvent038(); #endif #endif + +#ifdef LOSCFG_KERNEL_SMP + ItSmpLosEvent001(); + ItSmpLosEvent002(); + ItSmpLosEvent003(); + ItSmpLosEvent004(); + ItSmpLosEvent005(); + ItSmpLosEvent006(); + ItSmpLosEvent007(); + ItSmpLosEvent008(); + ItSmpLosEvent009(); + ItSmpLosEvent010(); + ItSmpLosEvent011(); + ItSmpLosEvent012(); + ItSmpLosEvent013(); + ItSmpLosEvent014(); + ItSmpLosEvent015(); + ItSmpLosEvent016(); + ItSmpLosEvent017(); + ItSmpLosEvent018(); + ItSmpLosEvent019(); + ItSmpLosEvent020(); +#endif } diff --git a/testsuites/sample/kernel/event/It_los_event.h b/testsuites/sample/kernel/event/It_los_event.h index c3cd85b4..ac3f04fa 100644 --- a/testsuites/sample/kernel/event/It_los_event.h +++ b/testsuites/sample/kernel/event/It_los_event.h @@ -110,6 +110,27 @@ extern VOID ItLosEvent041(VOID); extern VOID ItLosEvent042(VOID); extern VOID ItLosEvent043(VOID); +extern VOID ItSmpLosEvent001(VOID); +extern VOID ItSmpLosEvent002(VOID); +extern VOID ItSmpLosEvent003(VOID); +extern VOID ItSmpLosEvent004(VOID); +extern VOID ItSmpLosEvent005(VOID); +extern VOID ItSmpLosEvent006(VOID); +extern VOID ItSmpLosEvent007(VOID); +extern VOID ItSmpLosEvent008(VOID); +extern VOID ItSmpLosEvent009(VOID); +extern VOID ItSmpLosEvent010(VOID); +extern VOID ItSmpLosEvent011(VOID); +extern VOID ItSmpLosEvent012(VOID); +extern VOID ItSmpLosEvent013(VOID); +extern VOID ItSmpLosEvent014(VOID); +extern VOID ItSmpLosEvent015(VOID); +extern VOID ItSmpLosEvent016(VOID); +extern VOID ItSmpLosEvent017(VOID); +extern VOID ItSmpLosEvent018(VOID); +extern VOID ItSmpLosEvent019(VOID); +extern VOID ItSmpLosEvent020(VOID); + #ifdef __cplusplus #if __cplusplus } diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_001.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_001.c new file mode 100644 index 00000000..ccb9500c --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_001.c @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_001_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_EventDestroy(&g_pevent); + return LOS_OK; +} + +VOID ItSmpLosEvent001(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent001", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_002.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_002.c new file mode 100644 index 00000000..c19e1daf --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_002.c @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_002_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_EventDestroy(&g_pevent); + return LOS_OK; +} + +VOID ItSmpLosEvent002(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent002", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_003.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_003.c new file mode 100644 index 00000000..810909d1 --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_003.c @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID HwiF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + TestHwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count + + LOS_HwiDelete(HWI_NUM_TEST, NULL); + LOS_EventDestroy(&g_pevent); + return LOS_OK; +} + +VOID ItSmpLosEvent003(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent003", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ \ No newline at end of file diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_004.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_004.c new file mode 100644 index 00000000..6d03c735 --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_004.c @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_EventRead(&g_pevent, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, g_pevent.uwEventID, ret); + ICUNIT_ASSERT_EQUAL_VOID(g_pevent.uwEventID, 0x11, g_pevent.uwEventID); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_004_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_EVENT_SHOULD_NOT_DESTROYED, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + +EXIT: + ret = LOS_TaskDelete(g_testTaskID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent004(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent004", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ \ No newline at end of file diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_005.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_005.c new file mode 100644 index 00000000..3413be9f --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_005.c @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_EventRead(&g_pevent, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, g_pevent.uwEventID, ret); + ICUNIT_ASSERT_EQUAL_VOID(g_pevent.uwEventID, 0x11, g_pevent.uwEventID); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_EVENT_SHOULD_NOT_DESTROYED, ret); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_005_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_005_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(1); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + +EXIT: + ret = LOS_TaskDelete(g_testTaskID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_TaskDelete(g_testTaskID02); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent005(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent005", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_006.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_006.c new file mode 100644 index 00000000..6c3ed973 --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_006.c @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_EventRead(&g_pevent, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, g_pevent.uwEventID, ret); + ICUNIT_ASSERT_EQUAL_VOID(g_pevent.uwEventID, 0x11, g_pevent.uwEventID); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_006_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + do { + LOS_TaskDelay(10); + } while (g_testCount != 1); + + TestBusyTaskDelay(2); // 2, delay enouge time + + ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus; + ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT); + + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_EVENT_SHOULD_NOT_DESTROYED, ret, EXIT); + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + +EXIT: + ret = LOS_TaskDelete(g_testTaskID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent006(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent006", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_007.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_007.c new file mode 100644 index 00000000..cbb4520f --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_007.c @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_EventRead(&g_pevent, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, g_pevent.uwEventID, ret); + ICUNIT_ASSERT_EQUAL_VOID(g_pevent.uwEventID, 0x11, g_pevent.uwEventID); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_EVENT_SHOULD_NOT_DESTROYED, ret); + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + // 2, Set the priority according to the task purpose,a smaller number means a higher priority. + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_007_task1", TaskF01, TASK_PRIO_TEST - 2, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_007_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(10); // 10, delay enouge time + + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + + ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus; + ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT); + +EXIT: + ret = LOS_TaskDelete(g_testTaskID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_TaskDelete(g_testTaskID02); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent007(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent007", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_008.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_008.c new file mode 100644 index 00000000..a0896c78 --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_008.c @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID HwiF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_EventRead(&g_pevent, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_EVENT_READ_IN_INTERRUPT, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + TestHwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count + + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + +EXIT: + LOS_HwiDelete(HWI_NUM_TEST, NULL); + LOS_EventDestroy(&g_pevent); + return LOS_OK; +} + +VOID ItSmpLosEvent008(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent008", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_009.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_009.c new file mode 100644 index 00000000..f751a305 --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_009.c @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_EventRead(&g_pevent, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, g_pevent.uwEventID, ret); + ICUNIT_ASSERT_EQUAL_VOID(g_pevent.uwEventID, 0x11, g_pevent.uwEventID); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID HwiF01(VOID) +{ + UINT32 ret; + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_EVENT_SHOULD_NOT_DESTROYED, ret); + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_009_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + do { + LOS_TaskDelay(10); + } while (g_testCount != 1); + + TestBusyTaskDelay(2); // 2, delay enouge time + + ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus; + ICUNIT_GOTO_NOT_EQUAL((ret & OS_TASK_STATUS_PEND), 0, ret, EXIT); + + TestHwiTrigger(HWI_NUM_TEST); + + do { + LOS_TaskDelay(10); + } while (g_testCount != 2); // 2, wait until g_testCount is 2 ,or do noting + + ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus; + ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT); + +EXIT: + ret = LOS_TaskDelete(g_testTaskID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + ret = LOS_HwiDelete(HWI_NUM_TEST, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent009(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent009", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_010.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_010.c new file mode 100644 index 00000000..3cb7f64c --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_010.c @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_EventRead(&g_pevent, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, g_pevent.uwEventID, ret); + ICUNIT_ASSERT_EQUAL_VOID(g_pevent.uwEventID, 0x11, g_pevent.uwEventID); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + + ret = LOS_EventWrite(&g_pevent, 0x11); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_010_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_010_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent010(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent010", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_011.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_011.c new file mode 100644 index 00000000..cf9c8890 --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_011.c @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +static VOID TaskF02(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + + ret = LOS_EventWrite(&g_pevent, 0x11); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_EventRead(&g_pevent, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, g_pevent.uwEventID, ret); + ICUNIT_ASSERT_EQUAL_VOID(g_pevent.uwEventID, 0x11, g_pevent.uwEventID); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_011_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_011_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test running count + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3. + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent011(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent011", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_012.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_012.c new file mode 100644 index 00000000..b03b2b54 --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_012.c @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_EventRead(&g_pevent, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, g_pevent.uwEventID, ret); + ICUNIT_ASSERT_EQUAL_VOID(g_pevent.uwEventID, 0x11, g_pevent.uwEventID); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID HwiF01(VOID) +{ + UINT32 ret; + ret = LOS_EventWrite(&g_pevent, 0x11); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_012_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(1); + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + TestHwiTrigger(HWI_NUM_TEST); + + LOS_TaskDelay(1); + + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + ret = LOS_HwiDelete(HWI_NUM_TEST, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent012(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent012", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_013.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_013.c new file mode 100644 index 00000000..eeaaf10b --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_013.c @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + + ret = LOS_EventRead(&g_pevent, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, g_pevent.uwEventID, ret); + ICUNIT_ASSERT_EQUAL_VOID(g_pevent.uwEventID, 0x11, g_pevent.uwEventID); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + + do { + LOS_TaskDelay(10); + } while (g_testCount != 1); + + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_013_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_013_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_EventWrite(&g_pevent, 0x11); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(10); // 10, delay enouge time + + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent013(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent013", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_014.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_014.c new file mode 100644 index 00000000..5226baca --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_014.c @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF02(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + + ret = LOS_EventWrite(&g_pevent, 0x11); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + do { + LOS_TaskDelay(10); + } while (g_testCount != 1); + + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + + return; +} +static VOID TaskF01(VOID) +{ + UINT32 ret; + ret = LOS_EventRead(&g_pevent, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, g_pevent.uwEventID, ret); + ICUNIT_ASSERT_EQUAL_VOID(g_pevent.uwEventID, 0x11, g_pevent.uwEventID); + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_014_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent014(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent014", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_015.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_015.c new file mode 100644 index 00000000..496f1655 --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_015.c @@ -0,0 +1,107 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_EventRead(&g_pevent, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, g_pevent.uwEventID, ret); + ICUNIT_ASSERT_EQUAL_VOID(g_pevent.uwEventID, 0x11, g_pevent.uwEventID); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID HwiF01(VOID) +{ + UINT32 ret; + ret = LOS_EventWrite(&g_pevent, 0x11); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + do { + LOS_TaskDelay(10); + } while (g_testCount != 2); // 2, wait until g_testCount is 2 ,or do noting + + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_015_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(1); + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + TestHwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test running count + + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + ret = LOS_HwiDelete(HWI_NUM_TEST, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent015(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent015", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_016.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_016.c new file mode 100644 index 00000000..7788da93 --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_016.c @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_EventWrite(&g_pevent, 0x11); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_016_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent016(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent016", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_017.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_017.c new file mode 100644 index 00000000..5534296d --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_017.c @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + ret = LOS_EventWrite(&g_pevent, 0x11); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_017_task2", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent017(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent017", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_018.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_018.c new file mode 100644 index 00000000..9257984b --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_018.c @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + ret = LOS_EventWrite(&g_pevent, 0x11); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + LOS_AtomicInc(&g_testCount); + + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_018_task2", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent018(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent018", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_019.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_019.c new file mode 100644 index 00000000..d18badb4 --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_019.c @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID HwiF01(VOID) +{ + UINT32 ret; + ret = LOS_EventWrite(&g_pevent, 0x11); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + TestHwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + ret = LOS_HwiDelete(HWI_NUM_TEST, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent019(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent019", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/event/smp/It_smp_los_event_020.c b/testsuites/sample/kernel/event/smp/It_smp_los_event_020.c new file mode 100644 index 00000000..1b604021 --- /dev/null +++ b/testsuites/sample/kernel/event/smp/It_smp_los_event_020.c @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_event.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + + LOS_AtomicInc(&g_testCount); + + ret = LOS_EventWrite(&g_pevent, 0x11); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + g_pevent.uwEventID = 0; + + ret = LOS_EventInit(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_020_task2", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(1); + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + + ret = LOS_EventRead(&g_pevent, 0x11, LOS_WAITMODE_AND, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL(ret, g_pevent.uwEventID, ret); + + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + ret = LOS_EventDestroy(&g_pevent); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosEvent020(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosEvent020", Testcase, TEST_LOS, TEST_EVENT, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/mux/BUILD.gn b/testsuites/sample/kernel/mux/BUILD.gn index c5e1c402..ccd3407c 100644 --- a/testsuites/sample/kernel/mux/BUILD.gn +++ b/testsuites/sample/kernel/mux/BUILD.gn @@ -64,7 +64,28 @@ static_library("test_mux") { "It_los_mutex_033.c", "It_los_mutex_034.c", "It_los_mux.c", + "smp/It_smp_los_mux_001.c", + "smp/It_smp_los_mux_002.c", + "smp/It_smp_los_mux_003.c", + "smp/It_smp_los_mux_004.c", + "smp/It_smp_los_mux_005.c", + "smp/It_smp_los_mux_006.c", + "smp/It_smp_los_mux_007.c", + "smp/It_smp_los_mux_008.c", + "smp/It_smp_los_mux_009.c", + "smp/It_smp_los_mux_010.c", + "smp/It_smp_los_mux_011.c", + "smp/It_smp_los_mux_012.c", + "smp/It_smp_los_mux_013.c", + "smp/It_smp_los_mux_014.c", + "smp/It_smp_los_mux_015.c", + "smp/It_smp_los_mux_016.c", + "smp/It_smp_los_mux_017.c", + "smp/It_smp_los_mux_018.c", + "smp/It_smp_los_mux_019.c", ] + include_dirs = [ "." ] + configs += [ "$LITEOSTOPDIR/testsuites:include" ] } diff --git a/testsuites/sample/kernel/mux/It_los_mux.c b/testsuites/sample/kernel/mux/It_los_mux.c index aaf49d06..9b11aa16 100644 --- a/testsuites/sample/kernel/mux/It_los_mux.c +++ b/testsuites/sample/kernel/mux/It_los_mux.c @@ -52,6 +52,28 @@ VOID ItSuiteLosMux(void) ItLosMux029(); ItLosMux031(); +#if LOSCFG_KERNEL_SMP + ItSmpLosMux001(); + ItSmpLosMux002(); + ItSmpLosMux003(); + ItSmpLosMux004(); + ItSmpLosMux005(); + ItSmpLosMux006(); + ItSmpLosMux007(); + ItSmpLosMux008(); + ItSmpLosMux009(); + ItSmpLosMux010(); + ItSmpLosMux011(); + ItSmpLosMux012(); + ItSmpLosMux013(); + ItSmpLosMux014(); + ItSmpLosMux015(); + ItSmpLosMux016(); + ItSmpLosMux017(); + ItSmpLosMux018(); + ItSmpLosMux019(); +#endif + #if (LOS_KERNEL_TEST_FULL == 1) ItLosMux007(); ItLosMux010(); diff --git a/testsuites/sample/kernel/mux/It_los_mux.h b/testsuites/sample/kernel/mux/It_los_mux.h index a5760b1d..4b358f98 100644 --- a/testsuites/sample/kernel/mux/It_los_mux.h +++ b/testsuites/sample/kernel/mux/It_los_mux.h @@ -81,6 +81,26 @@ VOID ItSuiteLosMux(void); VOID ItLosMux020(void); #endif +VOID ItSmpLosMux001(VOID); +VOID ItSmpLosMux002(VOID); +VOID ItSmpLosMux003(VOID); +VOID ItSmpLosMux004(VOID); +VOID ItSmpLosMux005(VOID); +VOID ItSmpLosMux006(VOID); +VOID ItSmpLosMux007(VOID); +VOID ItSmpLosMux008(VOID); +VOID ItSmpLosMux009(VOID); +VOID ItSmpLosMux010(VOID); +VOID ItSmpLosMux011(VOID); +VOID ItSmpLosMux012(VOID); +VOID ItSmpLosMux013(VOID); +VOID ItSmpLosMux014(VOID); +VOID ItSmpLosMux015(VOID); +VOID ItSmpLosMux016(VOID); +VOID ItSmpLosMux017(VOID); +VOID ItSmpLosMux018(VOID); +VOID ItSmpLosMux019(VOID); + #ifdef __cplusplus #if __cplusplus } diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_001.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_001.c new file mode 100644 index 00000000..8acdedcc --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_001.c @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static void Task01(VOID) +{ + UINT32 ret; + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + g_testCount++; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + UINT32 currCpuid; + g_testCount = 0; + TSK_INIT_PARAM_S task = { 0 }; + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + task.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01; + task.pcName = "Test Case 1"; + task.uwStackSize = TASK_STACK_SIZE_TEST; + task.usTaskPrio = 5; + task.uwResved = LOS_TASK_STATUS_DETACHED; + task.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid); + + ret = LOS_TaskCreate(&g_testTaskID01, &task); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 1); // 100, delay for Timing control. + ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount); + + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + return LOS_OK; +} + +VOID ItSmpLosMux001(void) +{ + TEST_ADD_CASE("ItSmpLosMux001", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ \ No newline at end of file diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_002.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_002.c new file mode 100644 index 00000000..f31f3395 --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_002.c @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static void Task01(VOID) +{ + UINT32 ret; + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + g_testCount++; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + UINT32 currCpuid; + g_testCount = 0; + TSK_INIT_PARAM_S task = { 0 }; + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + task.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01; + task.pcName = "Test Case 1"; + task.uwStackSize = TASK_STACK_SIZE_TEST; + task.usTaskPrio = 5; + task.uwResved = LOS_TASK_STATUS_DETACHED; + task.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid); + + ret = LOS_TaskCreate(&g_testTaskID01, &task); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 1); // 100, delay for Timing control. + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + return LOS_OK; +} + +VOID ItSmpLosMux002(void) +{ + TEST_ADD_CASE("ItSmpLosMux002", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ \ No newline at end of file diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_003.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_003.c new file mode 100644 index 00000000..b9b948dc --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_003.c @@ -0,0 +1,104 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + + +static void Hwi01(VOID) +{ + UINT32 ret; + + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret); + + TEST_HwiClear(HWI_NUM_TEST); + + g_testCount++; +} + +static void Task01(VOID) +{ + UINT32 ret; + + TestHwiTrigger(HWI_NUM_TEST); + + g_testCount++; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + UINT32 currCpuid; + g_testCount = 0; + TSK_INIT_PARAM_S task = { 0 }; + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 0, 0, (HWI_PROC_FUNC)Hwi01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); + + task.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01; + task.pcName = "Test Case 1"; + task.uwStackSize = TASK_STACK_SIZE_TEST; + task.usTaskPrio = 5; + task.uwResved = LOS_TASK_STATUS_DETACHED; + task.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid); + + ret = LOS_TaskCreate(&g_testTaskID01, &task); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result. + + LOS_HwiDelete(HWI_NUM_TEST, NULL); + + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + return LOS_OK; +EXIT: + LOS_HwiDelete(HWI_NUM_TEST, NULL); + LOS_TaskDelete(g_testTaskID01); + LOS_MuxPost(g_mutexTest1); + LOS_TaskDelete(g_mutexTest1); + return LOS_OK; +} + +VOID ItSmpLosMux003(void) +{ + TEST_ADD_CASE("ItSmpLosMux003", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ \ No newline at end of file diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_004.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_004.c new file mode 100644 index 00000000..ff658209 --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_004.c @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static void Task01(VOID) +{ + UINT32 ret; + + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + g_testCount++; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + UINT32 currCpuid; + g_testCount = 0; + TSK_INIT_PARAM_S task = { 0 }; + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + task.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01; + task.pcName = "Test Case 1"; + task.uwStackSize = TASK_STACK_SIZE_TEST; + task.usTaskPrio = 5; + task.uwResved = LOS_TASK_STATUS_DETACHED; + task.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid); + + ret = LOS_TaskCreate(&g_testTaskID01, &task); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 1); // 100, delay for Timing control. + ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount); + + return LOS_OK; +} + +VOID ItSmpLosMux004(void) +{ + TEST_ADD_CASE("ItSmpLosMux004", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ \ No newline at end of file diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_005.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_005.c new file mode 100644 index 00000000..08614048 --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_005.c @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + + +static void Task01(VOID) +{ + UINT32 ret; + + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PENDED, ret); + g_testCount++; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + UINT32 currCpuid; + g_testCount = 0; + TSK_INIT_PARAM_S task = { 0 }; + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + task.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01; + task.pcName = "Test Case 1"; + task.uwStackSize = TASK_STACK_SIZE_TEST; + task.usTaskPrio = 5; + task.uwResved = LOS_TASK_STATUS_DETACHED; + task.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid); + + ret = LOS_TaskCreate(&g_testTaskID01, &task); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 1); // 100, delay for Timing control. + ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount); + + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + return LOS_OK; +} + +VOID ItSmpLosMux005(void) +{ + TEST_ADD_CASE("ItSmpLosMux005", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ \ No newline at end of file diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_006.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_006.c new file mode 100644 index 00000000..8d5f7fa6 --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_006.c @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static void Task01(VOID) +{ + UINT32 ret; + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + g_testCount++; +} + +static void Task02(VOID) +{ + UINT32 ret; + + ret = LOS_MuxCreate(&g_mutexTest2); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + ret = LOS_MuxPend(g_mutexTest2, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + ret = LOS_MuxPost(g_mutexTest2); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + ret = LOS_MuxDelete(g_mutexTest2); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + g_testCount++; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid, currCpuid2; + g_testCount = 0; + TSK_INIT_PARAM_S task = { 0 }; + TSK_INIT_PARAM_S task2 = { 0 }; + currCpuid = ArchCurrCpuid() % (LOSCFG_KERNEL_CORE_NUM - 1) + 1; + currCpuid2 = currCpuid % (LOSCFG_KERNEL_CORE_NUM - 1) + 1; + + task.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01; + task.pcName = "Test Case 1"; + task.uwStackSize = TASK_STACK_SIZE_TEST; + task.uwResved = LOS_TASK_STATUS_DETACHED; + task.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid); + + ret = LOS_TaskCreate(&g_testTaskID01, &task); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + task2.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02; + task2.pcName = "Test Case 2"; + task2.uwStackSize = TASK_STACK_SIZE_TEST; + task2.uwResved = LOS_TASK_STATUS_DETACHED; + task2.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid2); + + ret = LOS_TaskCreate(&g_testTaskID02, &task2); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control. + ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result. + + return LOS_OK; +} + +VOID ItSmpLosMux006(void) +{ + TEST_ADD_CASE("ItSmpLosMux006", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ \ No newline at end of file diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_007.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_007.c new file mode 100644 index 00000000..82f91d8b --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_007.c @@ -0,0 +1,103 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + + +static void Task01(VOID) +{ + UINT32 ret; + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + TestBusyTaskDelay(5); // 5, delay for Timing control. + + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + g_testCount++; +} + +static void Task02(VOID) +{ + UINT32 ret; + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + TestBusyTaskDelay(5); // 5, delay for Timing control. + + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + g_testCount++; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid, currCpuid2; + g_testCount = 0; + TSK_INIT_PARAM_S task = { 0 }; + TSK_INIT_PARAM_S task2 = { 0 }; + currCpuid = ArchCurrCpuid() % (LOSCFG_KERNEL_CORE_NUM - 1) + 1; + currCpuid2 = currCpuid % (LOSCFG_KERNEL_CORE_NUM - 1) + 1; + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + task.pfnTaskEntry = (TSK_ENTRY_FUNC)Task01; + task.pcName = "Test Case 1"; + task.uwStackSize = TASK_STACK_SIZE_TEST; + task.uwResved = LOS_TASK_STATUS_DETACHED; + task.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid); + + ret = LOS_TaskCreate(&g_testTaskID01, &task); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + task2.pfnTaskEntry = (TSK_ENTRY_FUNC)Task02; + task2.pcName = "Test Case 2"; + task2.uwStackSize = TASK_STACK_SIZE_TEST; + task2.uwResved = LOS_TASK_STATUS_DETACHED; + task2.usCpuAffiMask = CPUID_TO_AFFI_MASK(currCpuid2); + + ret = LOS_TaskCreate(&g_testTaskID02, &task2); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control. + ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2, here assert the result. + + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + return LOS_OK; +} + +VOID ItSmpLosMux007(void) +{ + TEST_ADD_CASE("ItSmpLosMux007", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL0, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ \ No newline at end of file diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_008.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_008.c new file mode 100644 index 00000000..16870746 --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_008.c @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + TSK_INIT_PARAM_S testTask = {0}; + + g_testCount = 0; + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_008_task", TaskF01, 5 - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_MuxDelete(g_mutexTest1); + return LOS_OK; +} + + +VOID ItSmpLosMux008(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosMux008", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_009.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_009.c new file mode 100644 index 00000000..44fa02ed --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_009.c @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask = {0}; + + g_testCount = 0; + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_009_task", TaskF01, 5 - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_MuxDelete(g_mutexTest1); + return LOS_OK; +} + + +VOID ItSmpLosMux009(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosMux009", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_010.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_010.c new file mode 100644 index 00000000..707f908b --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_010.c @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + + +static VOID HwiF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask = {0}; + + g_testCount = 0; + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + LOS_HwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result. + +EXIT: + LOS_HwiDelete(HWI_NUM_TEST, NULL); + LOS_MuxDelete(g_mutexTest1); + return LOS_OK; +} + + +VOID ItSmpLosMux010(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosMux010", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_011.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_011.c new file mode 100644 index 00000000..a3be2072 --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_011.c @@ -0,0 +1,105 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + + TestAssertBusyTaskDelay(100, 3); // 100, 3, delay for Timing control. + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result. + + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +EXIT: + LOS_MuxPost(g_mutexTest1); + LOS_TaskDelete(g_testTaskID01); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + + TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control. + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result. + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PENDED, ret); + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask = {0}; + + g_testCount = 0; + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_011_task2", TaskF02, 5 - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_011_task1", TaskF01, 5 - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 4); // 100, 4, delay for Timing control. + ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + + +VOID ItSmpLosMux011(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosMux011", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_012.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_012.c new file mode 100644 index 00000000..13a92a4b --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_012.c @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + + +static UINT32 volatile g_runFlag = 0; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + + do { + LOS_TaskDelay(10); + } while (g_runFlag); + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask = {0}; + + g_testCount = 0; + g_runFlag = 1; + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_012_task1", TaskF01, 5 - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result. + + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_MUX_PENDED, ret); + + g_runFlag = 0; + TestAssertBusyTaskDelay(100, 3); // 100, 3, delay for Timing control. + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + + +VOID ItSmpLosMux012(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosMux012", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_013.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_013.c new file mode 100644 index 00000000..991ac8b4 --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_013.c @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + + LOS_TaskDelay(2); // 2, delay for Timing control. + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result. + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PENDED, ret); + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask = {0}; + + g_testCount = 0; + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + // 2, set reasonable priority. + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_013_task1", TaskF01, 5 - 2, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_013_task2", TaskF02, 5 - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 4); // 100, 4, delay for Timing control. + ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result. + + LOS_TaskDelay(10); // 10, delay for Timing control. + + ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus; + ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT); + + ret = OS_TCB_FROM_TID(g_testTaskID02)->taskStatus; + ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + + +VOID ItSmpLosMux013(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosMux013", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_014.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_014.c new file mode 100644 index 00000000..f02ea897 --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_014.c @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID HwiF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask = {0}; + + g_testCount = 0; + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + LOS_HwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result. + + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + +EXIT: + LOS_HwiDelete(HWI_NUM_TEST, NULL); + LOS_MuxDelete(g_mutexTest1); + return LOS_OK; +} + +VOID ItSmpLosMux014(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosMux014", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_015.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_015.c new file mode 100644 index 00000000..83210117 --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_015.c @@ -0,0 +1,103 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + + TestAssertBusyTaskDelay(100, 3); // 100, 3, delay for Timing control. + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result. +EXIT: + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID HwiF01(VOID) +{ + UINT32 ret; + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_PENDED, ret); + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask = {0}; + + g_testCount = 0; + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_015_task", TaskF01, 5 - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result. + + LOS_HwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 4); // 100, 4, delay for Timing control. + ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result. + +EXIT: + LOS_TaskDelay(10); // 10, delay for Timing control. + LOS_TaskDelete(g_testTaskID01); + ret = LOS_HwiDelete(HWI_NUM_TEST, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + + +VOID ItSmpLosMux015(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosMux015", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_016.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_016.c new file mode 100644 index 00000000..62ee9d49 --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_016.c @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + LOS_AtomicInc(&g_testCount); +EXIT: + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + TSK_INIT_PARAM_S testTask = {0}; + + g_testCount = 0; + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_016_task1", TaskF01, 5 - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result. + + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_MuxDelete(g_mutexTest1); + return LOS_OK; +} + + +VOID ItSmpLosMux016(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosMux016", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_017.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_017.c new file mode 100644 index 00000000..cb79f91c --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_017.c @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF02(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + LOS_TaskDelay(2); // 2, delay for Timing control. + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result. // task f01 pend + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask = {0}; + + g_testCount = 0; + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_017_task2", TaskF02, 5 - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + do { + LOS_TaskDelay(10); + } while (g_testCount != 1); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_017_task1", TaskF01, 5 + 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(10); // 10, delay for Timing control. // TaskF01 run + + ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, here assert the result. + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + LOS_MuxDelete(g_mutexTest1); + return LOS_OK; +} + + +VOID ItSmpLosMux017(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosMux017", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_018.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_018.c new file mode 100644 index 00000000..205ba414 --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_018.c @@ -0,0 +1,138 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 2, g_testCount); // 2, here assert the result. + LOS_AtomicInc(&g_testCount); + + ret = LOS_MuxPend(g_mutexTest1, 5); // 5, init mutex. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_TIMEOUT, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result. + LOS_AtomicInc(&g_testCount); + return; +EXIT: + LOS_TaskDelete(g_testTaskID01); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + + LOS_TaskDelay(100); // 100, set delay time. + + ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, here assert the result. +EXIT: + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID HwiF01(VOID) +{ + UINT32 ret; + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result. + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_MUX_IN_INTERR, ret); + LOS_AtomicInc(&g_testCount); + return; +EXIT: + LOS_HwiDelete(HWI_NUM_TEST, NULL); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask = {0}; + + g_testCount = 0; + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_018_task1", TaskF02, 5 - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, 2, delay for Timing control. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result. + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_018_task2", TaskF01, 5 + 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(1); // task f01 run + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result. + + LOS_HwiTrigger(HWI_NUM_TEST); + + LOS_TaskDelay(200); // 200, set delay time. + + ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT); // 6, here assert the result. + + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + ret = LOS_HwiDelete(HWI_NUM_TEST, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_MuxDelete(g_mutexTest1); + return LOS_OK; +} + + +VOID ItSmpLosMux018(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosMux018", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/mux/smp/It_smp_los_mux_019.c b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_019.c new file mode 100644 index 00000000..76c17c4a --- /dev/null +++ b/testsuites/sample/kernel/mux/smp/It_smp_los_mux_019.c @@ -0,0 +1,105 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_mux.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + + LOS_AtomicInc(&g_testCount); + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + + do { + LOS_TaskDelay(10); + } while (g_testCount != 3); // 3, wait until g_testCount == 3. + + ret = LOS_MuxDelete(g_mutexTest1); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask = {0}; + + g_testCount = 0; + + ret = LOS_MuxCreate(&g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_MuxPend(g_mutexTest1, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_019_task1", TaskF01, 5 - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_mux_019_task2", TaskF02, 5 - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_MuxPost(g_mutexTest1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 4); // 100, 4, delay for Timing control. + ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + LOS_MuxDelete(g_mutexTest1); + return LOS_OK; +} + +VOID ItSmpLosMux019(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosMux019", Testcase, TEST_LOS, TEST_MUX, TEST_LEVEL2, TEST_FUNCTION); +} +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/queue/BUILD.gn b/testsuites/sample/kernel/queue/BUILD.gn index b3a322dd..75f507a5 100644 --- a/testsuites/sample/kernel/queue/BUILD.gn +++ b/testsuites/sample/kernel/queue/BUILD.gn @@ -188,7 +188,34 @@ static_library("test_queue") { "It_los_queue_static_006.c", "LLt_los_queue_003.c", "Llt_los_queue_001.c", + "smp/It_smp_los_queue_001.c", + "smp/It_smp_los_queue_002.c", + "smp/It_smp_los_queue_003.c", + "smp/It_smp_los_queue_004.c", + "smp/It_smp_los_queue_005.c", + "smp/It_smp_los_queue_006.c", + "smp/It_smp_los_queue_007.c", + "smp/It_smp_los_queue_008.c", + "smp/It_smp_los_queue_009.c", + "smp/It_smp_los_queue_010.c", + "smp/It_smp_los_queue_011.c", + "smp/It_smp_los_queue_012.c", + "smp/It_smp_los_queue_013.c", + "smp/It_smp_los_queue_014.c", + "smp/It_smp_los_queue_015.c", + "smp/It_smp_los_queue_016.c", + "smp/It_smp_los_queue_017.c", + "smp/It_smp_los_queue_018.c", + "smp/It_smp_los_queue_019.c", + "smp/It_smp_los_queue_020.c", + "smp/It_smp_los_queue_021.c", + "smp/It_smp_los_queue_022.c", + "smp/It_smp_los_queue_023.c", + "smp/It_smp_los_queue_024.c", + "smp/It_smp_los_queue_025.c", ] + include_dirs = [ "." ] + configs += [ "$LITEOSTOPDIR/testsuites:include" ] } diff --git a/testsuites/sample/kernel/queue/It_los_queue.c b/testsuites/sample/kernel/queue/It_los_queue.c index 5e693e79..cdbfe768 100644 --- a/testsuites/sample/kernel/queue/It_los_queue.c +++ b/testsuites/sample/kernel/queue/It_los_queue.c @@ -151,6 +151,7 @@ VOID ItSuiteLosQueue(VOID) ItLosQueueHead040(); ItLosQueueHead041(); ItLosQueueHead042(); + ItLosQueueIsr001(); ItLosQueueIsr002(); ItLosQueueIsr003(); @@ -167,6 +168,35 @@ VOID ItSuiteLosQueue(VOID) ItLosQueueIsr014(); ItLosQueueIsr015(); ItLosQueueIsr016(); + +#if LOSCFG_KERNEL_SMP + ItSmpLosQueue001(); + ItSmpLosQueue002(); + ItSmpLosQueue003(); + ItSmpLosQueue004(); + ItSmpLosQueue005(); + ItSmpLosQueue006(); + ItSmpLosQueue007(); + ItSmpLosQueue008(); + ItSmpLosQueue009(); + ItSmpLosQueue010(); + ItSmpLosQueue011(); + ItSmpLosQueue012(); + ItSmpLosQueue013(); + ItSmpLosQueue014(); + ItSmpLosQueue015(); + ItSmpLosQueue016(); + ItSmpLosQueue017(); + ItSmpLosQueue018(); + ItSmpLosQueue019(); + ItSmpLosQueue020(); + ItSmpLosQueue021(); + ItSmpLosQueue022(); + ItSmpLosQueue023(); + ItSmpLosQueue024(); + ItSmpLosQueue025(); +#endif + #if (LOS_KERNEL_TEST_FULL == 1) #if (LOS_KERNEL_HWI_TEST == 1) ItLosQueue044(); diff --git a/testsuites/sample/kernel/queue/It_los_queue.h b/testsuites/sample/kernel/queue/It_los_queue.h index 659d6615..163b5d5c 100644 --- a/testsuites/sample/kernel/queue/It_los_queue.h +++ b/testsuites/sample/kernel/queue/It_los_queue.h @@ -43,6 +43,8 @@ extern "C" { #define QUEUE_BASE_NUM 3 #define QUEUE_BASE_MSGSIZE 8 +#define LOOP 100 + #define PER_ADDED_VALUE 1 extern UINT32 g_testTaskID01; @@ -212,6 +214,32 @@ extern VOID ItLosQueueStatic006(VOID); extern VOID ItLosQueue046(VOID); #endif +extern VOID ItSmpLosQueue001(VOID); +extern VOID ItSmpLosQueue002(VOID); +extern VOID ItSmpLosQueue003(VOID); +extern VOID ItSmpLosQueue004(VOID); +extern VOID ItSmpLosQueue005(VOID); +extern VOID ItSmpLosQueue006(VOID); +extern VOID ItSmpLosQueue007(VOID); +extern VOID ItSmpLosQueue008(VOID); +extern VOID ItSmpLosQueue009(VOID); +extern VOID ItSmpLosQueue010(VOID); +extern VOID ItSmpLosQueue011(VOID); +extern VOID ItSmpLosQueue012(VOID); +extern VOID ItSmpLosQueue013(VOID); +extern VOID ItSmpLosQueue014(VOID); +extern VOID ItSmpLosQueue015(VOID); +extern VOID ItSmpLosQueue016(VOID); +extern VOID ItSmpLosQueue017(VOID); +extern VOID ItSmpLosQueue018(VOID); +extern VOID ItSmpLosQueue019(VOID); +extern VOID ItSmpLosQueue020(VOID); +extern VOID ItSmpLosQueue021(VOID); +extern VOID ItSmpLosQueue022(VOID); +extern VOID ItSmpLosQueue023(VOID); +extern VOID ItSmpLosQueue024(VOID); +extern VOID ItSmpLosQueue025(VOID); + #ifdef __cplusplus #if __cplusplus } diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_001.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_001.c new file mode 100644 index 00000000..5bac3e5e --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_001.c @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; + CHAR buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_001_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue001(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue001", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_002.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_002.c new file mode 100644 index 00000000..98852b84 --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_002.c @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; + CHAR buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_002_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue002(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue002", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_003.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_003.c new file mode 100644 index 00000000..c8df13e9 --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_003.c @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID HwiF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; + CHAR buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + TestHwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count. + + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + +EXIT: + LOS_HwiDelete(HWI_NUM_TEST, NULL); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue003(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue003", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_004.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_004.c new file mode 100644 index 00000000..0117f4fa --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_004.c @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_004_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_IN_TSKUSE, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + +EXIT: + ret = LOS_TaskDelete(g_testTaskID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosQueue004(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue004", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_005.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_005.c new file mode 100644 index 00000000..542a8247 --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_005.c @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_IN_TSKUSE, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_005_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_005_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + +EXIT: + ret = LOS_TaskDelete(g_testTaskID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_TaskDelete(g_testTaskID02); + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosQueue005(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue005", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_006.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_006.c new file mode 100644 index 00000000..4b76a298 --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_006.c @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_006_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + TestBusyTaskDelay(2); // 2, Set the timeout of runtime; + + ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus; + ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT); + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_IN_TSKUSE, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + +EXIT: + ret = LOS_TaskDelete(g_testTaskID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_TaskDelay(10); // 10, set delay time. + ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus; + ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT); + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosQueue006(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue006", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_007.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_007.c new file mode 100644 index 00000000..70196b3a --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_007.c @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_IN_TSKUSE, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + // 2, set new task priority, it is higher than the current task. + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_007_task1", TaskF01, TASK_PRIO_TEST - 2, + CPUID_TO_AFFI_MASK(currCpuid)); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_007_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + +EXIT: + ret = LOS_TaskDelete(g_testTaskID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_TaskDelete(g_testTaskID02); + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosQueue007(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue007", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_008.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_008.c new file mode 100644 index 00000000..1adb04eb --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_008.c @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID HwiF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_READ_IN_INTERRUPT, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + TestHwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + +EXIT: + LOS_HwiDelete(HWI_NUM_TEST, NULL); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue008(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue008", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_009.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_009.c new file mode 100644 index 00000000..fb8ff127 --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_009.c @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID HwiF01(VOID) +{ + UINT32 ret; + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_IN_TSKUSE, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_009_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + LOS_TaskDelay(1); + + ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus; + ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT); + + TestHwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); + +EXIT: + ret = LOS_HwiDelete(HWI_NUM_TEST, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_TaskDelete(g_testTaskID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_TaskDelay(10); // 10, set delay time. + ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus; + ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_UNUSED, 0, ret, EXIT); + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosQueue009(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue009", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_010.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_010.c new file mode 100644 index 00000000..9964fb7e --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_010.c @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, 0); // 8, Write the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + // 2, set new task priority, it is higher than the current task. + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_010_task1", TaskF01, TASK_PRIO_TEST - 2, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_010_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3. + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue010(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue010", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_011.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_011.c new file mode 100644 index 00000000..98f6444e --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_011.c @@ -0,0 +1,98 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF02(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.; + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_011_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_011_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3. + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue011(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue011", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_012.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_012.c new file mode 100644 index 00000000..b7bc7547 --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_012.c @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID HwiF01(VOID) +{ + UINT32 ret; + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_NO_WAIT); // 8, Write the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_012_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + TestHwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3. + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + ret = LOS_HwiDelete(HWI_NUM_TEST, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue012(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue012", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_013.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_013.c new file mode 100644 index 00000000..4c4b3e0f --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_013.c @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + + do { + LOS_TaskDelay(10); + } while (g_testCount != 2); // 2, Here, judgment that g_testCount is not equal to 2. + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_013_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_013_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.; + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue013(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue013", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_014.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_014.c new file mode 100644 index 00000000..598d1a2c --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_014.c @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF02(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.; + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + do { + LOS_TaskDelay(10); + } while (g_testCount != 2); // 2, Here, judgment that g_testCount is not equal to 2. + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} +static VOID TaskF01(VOID) +{ + UINT32 ret; + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + + LOS_AtomicInc(&g_testCount); + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_014_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_014_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue014(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue014", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_015.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_015.c new file mode 100644 index 00000000..37bf68db --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_015.c @@ -0,0 +1,107 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID HwiF01(VOID) +{ + UINT32 ret; + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_NO_WAIT); // 8, Write the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + do { + LOS_TaskDelay(10); + } while (g_testCount != 2); // 2, Here, judgment that g_testCount is not equal to 3. + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_015_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + TestHwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3. + + +EXIT: + LOS_TaskDelete(g_testTaskID01); + ret = LOS_HwiDelete(HWI_NUM_TEST, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue015(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue015", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_016.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_016.c new file mode 100644 index 00000000..39529057 --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_016.c @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.; + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_016_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue016(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue016", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_017.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_017.c new file mode 100644 index 00000000..7530fb1a --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_017.c @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_017_task2", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue017(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue017", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_018.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_018.c new file mode 100644 index 00000000..08632c4d --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_018.c @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.; + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + LOS_AtomicInc(&g_testCount); + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_018_task2", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue018(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue018", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_019.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_019.c new file mode 100644 index 00000000..5efd1d07 --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_019.c @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID HwiF01(VOID) +{ + UINT32 ret; + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_NO_WAIT); // 8, Write the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + TestHwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + ret = LOS_HwiDelete(HWI_NUM_TEST, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue019(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue019", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_020.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_020.c new file mode 100644 index 00000000..1112bf85 --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_020.c @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + + LOS_AtomicInc(&g_testCount); + + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_020_task2", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue020(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue020", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_021.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_021.c new file mode 100644 index 00000000..cdcd3d94 --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_021.c @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_AtomicInc(&g_testCount); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_021_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue021(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue021", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_022.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_022.c new file mode 100644 index 00000000..468d0dc0 --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_022.c @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID HwiF01(VOID) +{ + UINT32 ret; + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_READ_IN_INTERRUPT, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_022_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + TestHwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + ret = LOS_HwiDelete(HWI_NUM_TEST, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue022(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue022", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_023.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_023.c new file mode 100644 index 00000000..a05e4a69 --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_023.c @@ -0,0 +1,98 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_023_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_023_task", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // othercpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue023(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue023", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_024.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_024.c new file mode 100644 index 00000000..5986a142 --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_024.c @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF02(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer.; + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + LOS_AtomicInc(&g_testCount); + return; +} +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_024_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_024_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue024(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue024", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/queue/smp/It_smp_los_queue_025.c b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_025.c new file mode 100644 index 00000000..6985f02f --- /dev/null +++ b/testsuites/sample/kernel/queue/smp/It_smp_los_queue_025.c @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_queue.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP"; +static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = ""; +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + + ret = LOS_QueueWrite(g_testQueueID01, &g_buff1, 8, LOS_WAIT_FOREVER); // 8, Write the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID HwiF01(VOID) +{ + UINT32 ret; + + ret = LOS_QueueRead(g_testQueueID01, &g_buff2, 8, LOS_WAIT_FOREVER); // 8, Read the setting size of queue buffer. + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_READ_IN_INTERRUPT, ret); + + ret = LOS_QueueDelete(g_testQueueID01); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_QueueCreate("Q1", 1, &g_testQueueID01, 0, 8); // 8, Set the maximum data length of the message queue. + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_queue_025_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + TestHwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count. + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2. +EXIT: + LOS_TaskDelete(g_testTaskID01); + ret = LOS_HwiDelete(HWI_NUM_TEST, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_QueueDelete(g_testQueueID01); + return LOS_OK; +} + +VOID ItSmpLosQueue025(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosQueue025", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/sem/BUILD.gn b/testsuites/sample/kernel/sem/BUILD.gn index e8cba38c..79a82c14 100644 --- a/testsuites/sample/kernel/sem/BUILD.gn +++ b/testsuites/sample/kernel/sem/BUILD.gn @@ -75,7 +75,20 @@ static_library("test_sem") { "it_los_sem_041.c", "it_los_sem_042.c", "it_los_sem_043.c", + "smp/It_smp_los_sem_001.c", + "smp/It_smp_los_sem_002.c", + "smp/It_smp_los_sem_003.c", + "smp/It_smp_los_sem_004.c", + "smp/It_smp_los_sem_005.c", + "smp/It_smp_los_sem_006.c", + "smp/It_smp_los_sem_007.c", + "smp/It_smp_los_sem_008.c", + "smp/It_smp_los_sem_009.c", + "smp/It_smp_los_sem_010.c", + "smp/It_smp_los_sem_011.c", ] + include_dirs = [ "." ] + configs += [ "$LITEOSTOPDIR/testsuites:include" ] } diff --git a/testsuites/sample/kernel/sem/It_los_sem.c b/testsuites/sample/kernel/sem/It_los_sem.c index 3d64ec07..e192eff3 100644 --- a/testsuites/sample/kernel/sem/It_los_sem.c +++ b/testsuites/sample/kernel/sem/It_los_sem.c @@ -84,4 +84,18 @@ VOID ItSuiteLosSem(void) ItLosSem037(); ItLosSem039(); #endif + +#if LOSCFG_KERNEL_SMP + ItSmpLosSem001(); + ItSmpLosSem002(); + ItSmpLosSem003(); + ItSmpLosSem004(); + ItSmpLosSem005(); + ItSmpLosSem006(); + ItSmpLosSem007(); + ItSmpLosSem008(); + ItSmpLosSem009(); + ItSmpLosSem010(); + ItSmpLosSem011(); +#endif } diff --git a/testsuites/sample/kernel/sem/It_los_sem.h b/testsuites/sample/kernel/sem/It_los_sem.h index 6f43a605..4be17d1c 100644 --- a/testsuites/sample/kernel/sem/It_los_sem.h +++ b/testsuites/sample/kernel/sem/It_los_sem.h @@ -85,6 +85,18 @@ VOID ItLosSem042(void); VOID ItLosSem043(void); VOID ItLosSem044(void); +VOID ItSmpLosSem001(void); +VOID ItSmpLosSem002(void); +VOID ItSmpLosSem003(void); +VOID ItSmpLosSem004(void); +VOID ItSmpLosSem005(void); +VOID ItSmpLosSem006(void); +VOID ItSmpLosSem007(void); +VOID ItSmpLosSem008(void); +VOID ItSmpLosSem009(void); +VOID ItSmpLosSem010(void); +VOID ItSmpLosSem011(void); + #ifdef __cplusplus #if __cplusplus } diff --git a/testsuites/sample/kernel/sem/smp/It_smp_los_sem_001.c b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_001.c new file mode 100644 index 00000000..9fc9fd13 --- /dev/null +++ b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_001.c @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_sem.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_SemPend(g_usSemID, LOS_WAIT_FOREVER); + + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_SemCreate(0, &g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_001_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_SemDelete(g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_SEM_PENDED, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + +EXIT: + ret = LOS_TaskDelete(g_testTaskID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + ret = LOS_SemDelete(g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosSem001(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosSem001", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/sem/smp/It_smp_los_sem_002.c b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_002.c new file mode 100644 index 00000000..a9d15ade --- /dev/null +++ b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_002.c @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_sem.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_SemPend(g_usSemID, LOS_WAIT_FOREVER); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + ret = LOS_SemDelete(g_usSemID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_SEM_PENDED, ret); + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_SemCreate(0, &g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_002_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_002_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to + + TestBusyTaskDelay(1); + ret = OS_TCB_FROM_TID(g_testTaskID01)->taskStatus; + ICUNIT_GOTO_NOT_EQUAL(ret & OS_TASK_STATUS_PEND, 0, ret, EXIT); + +EXIT: + ret = LOS_TaskDelete(g_testTaskID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_TaskDelete(g_testTaskID02); + ret = LOS_SemDelete(g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosSem002(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosSem002", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/sem/smp/It_smp_los_sem_003.c b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_003.c new file mode 100644 index 00000000..e4531369 --- /dev/null +++ b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_003.c @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_sem.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_SemPend(g_usSemID, LOS_WAIT_FOREVER); + + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_SemCreate(0, &g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_003_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + LOS_TaskDelay(1); + + ret = LOS_SemDelete(g_usSemID); + ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SEM_PENDED, ret, EXIT); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + +EXIT: + ret = LOS_TaskDelete(g_testTaskID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + ret = LOS_SemDelete(g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + return LOS_OK; +} + +VOID ItSmpLosSem003(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosSem003", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/sem/smp/It_smp_los_sem_004.c b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_004.c new file mode 100644 index 00000000..aeded776 --- /dev/null +++ b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_004.c @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_sem.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_SemPend(g_usSemID, LOS_WAIT_FOREVER); + + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + + ret = LOS_SemPost(g_usSemID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_SemCreate(0, &g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_004_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_004_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_SemDelete(g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + LOS_SemDelete(g_usSemID); + return LOS_OK; +} + +VOID ItSmpLosSem004(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosSem004", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/sem/smp/It_smp_los_sem_005.c b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_005.c new file mode 100644 index 00000000..77766617 --- /dev/null +++ b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_005.c @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_sem.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF02(VOID) +{ + UINT32 ret; + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 1, g_testCount); + ret = LOS_SemPost(g_usSemID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_SemPend(g_usSemID, LOS_WAIT_FOREVER); + + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_SemCreate(0, &g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_005_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_005_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test running count + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to + + ret = LOS_SemDelete(g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + LOS_SemDelete(g_usSemID); + return LOS_OK; +} + +VOID ItSmpLosSem005(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosSem005", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/sem/smp/It_smp_los_sem_006.c b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_006.c new file mode 100644 index 00000000..554e82ae --- /dev/null +++ b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_006.c @@ -0,0 +1,98 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_sem.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + ret = LOS_SemPend(g_usSemID, LOS_WAIT_FOREVER); + + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID HwiF01(VOID) +{ + UINT32 ret; + + ret = LOS_SemPost(g_usSemID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_SemCreate(0, &g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_006_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + TestHwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to + + ret = LOS_SemDelete(g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + ret = LOS_HwiDelete(HWI_NUM_TEST, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_SemDelete(g_usSemID); + return LOS_OK; +} + +VOID ItSmpLosSem006(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosSem006", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/sem/smp/It_smp_los_sem_007.c b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_007.c new file mode 100644 index 00000000..fa0a273d --- /dev/null +++ b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_007.c @@ -0,0 +1,99 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_sem.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + + ret = LOS_SemPend(g_usSemID, LOS_WAIT_FOREVER); + + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID TaskF02(VOID) +{ + UINT32 ret; + + do { + LOS_TaskDelay(10); + } while (g_testCount != 1); + + ret = LOS_SemDelete(g_usSemID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_SemCreate(0, &g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_007_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_007_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_SemPost(g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + LOS_SemDelete(g_usSemID); + return LOS_OK; +} + +VOID ItSmpLosSem007(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosSem007", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/sem/smp/It_smp_los_sem_008.c b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_008.c new file mode 100644 index 00000000..ea25e0cb --- /dev/null +++ b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_008.c @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_sem.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF02(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + + ret = LOS_SemPost(g_usSemID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + do { + LOS_TaskDelay(10); + } while (g_testCount != 1); + + ret = LOS_SemDelete(g_usSemID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} +static VOID TaskF01(VOID) +{ + UINT32 ret; + ret = LOS_SemPend(g_usSemID, LOS_WAIT_FOREVER); + + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + LOS_AtomicInc(&g_testCount); + return; +} +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_SemCreate(0, &g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_008_task1", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_event_008_task2", TaskF02, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 2); // 100, Set the timeout of runtime; 2, test running count + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_TaskDelete(g_testTaskID02); + LOS_SemDelete(g_usSemID); + return LOS_OK; +} + +VOID ItSmpLosSem008(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosSem008", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/sem/smp/It_smp_los_sem_009.c b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_009.c new file mode 100644 index 00000000..13fffe43 --- /dev/null +++ b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_009.c @@ -0,0 +1,104 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_sem.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_SemPend(g_usSemID, LOS_WAIT_FOREVER); + + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static VOID HwiF01(VOID) +{ + UINT32 ret; + ret = LOS_SemPost(g_usSemID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + do { + LOS_TaskDelay(10); + } while (g_testCount != 2); // 2, wait flag is, or do nothing + + ret = LOS_SemDelete(g_usSemID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_SemCreate(0, &g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, (HWI_PROC_FUNC)HwiF01, 0); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_HwiSetAffinity(HWI_NUM_TEST, CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_009_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); // current cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + TestHwiTrigger(HWI_NUM_TEST); + + TestAssertBusyTaskDelay(100, 3); // 100, Set the timeout of runtime; 3, test running count + ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to + +EXIT: + LOS_TaskDelete(g_testTaskID01); + ret = LOS_HwiDelete(HWI_NUM_TEST, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + LOS_SemDelete(g_usSemID); + return LOS_OK; +} + +VOID ItSmpLosSem009(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosSem009", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/sem/smp/It_smp_los_sem_010.c b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_010.c new file mode 100644 index 00000000..8e446eef --- /dev/null +++ b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_010.c @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_sem.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + LOS_AtomicInc(&g_testCount); + + ret = LOS_SemPost(g_usSemID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_SemCreate(0, &g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_010_task", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_SemDelete(g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_SemDelete(g_usSemID); + return LOS_OK; +} + +VOID ItSmpLosSem010(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosSem010", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/sem/smp/It_smp_los_sem_011.c b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_011.c new file mode 100644 index 00000000..6789f381 --- /dev/null +++ b/testsuites/sample/kernel/sem/smp/It_smp_los_sem_011.c @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_sem.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID TaskF01(VOID) +{ + UINT32 ret; + + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + ret = LOS_SemPost(g_usSemID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + LOS_AtomicInc(&g_testCount); + return; +} + +static UINT32 Testcase(VOID) +{ + UINT32 ret, currCpuid; + TSK_INIT_PARAM_S testTask; + + g_testCount = 0; + + ret = LOS_SemCreate(0, &g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_sem_011_task2", TaskF01, TASK_PRIO_TEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // other cpu + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + ret = LOS_SemDelete(g_usSemID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + +EXIT: + LOS_TaskDelete(g_testTaskID01); + LOS_SemDelete(g_usSemID); + return LOS_OK; +} + +VOID ItSmpLosSem011(VOID) // IT_Layer_ModuleORFeature_No +{ + TEST_ADD_CASE("ItSmpLosSem011", Testcase, TEST_LOS, TEST_SEM, TEST_LEVEL2, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + diff --git a/testsuites/sample/kernel/swtmr/BUILD.gn b/testsuites/sample/kernel/swtmr/BUILD.gn index e906006f..85be6f4a 100644 --- a/testsuites/sample/kernel/swtmr/BUILD.gn +++ b/testsuites/sample/kernel/swtmr/BUILD.gn @@ -146,7 +146,34 @@ static_library("test_swtmr") { "It_los_swtmr_Delay_003.c", "It_los_swtmr_Delay_004.c", "It_los_swtmr_Delay_005.c", + "smp/It_smp_los_swtmr_001.c", + "smp/It_smp_los_swtmr_002.c", + "smp/It_smp_los_swtmr_003.c", + "smp/It_smp_los_swtmr_004.c", + "smp/It_smp_los_swtmr_005.c", + "smp/It_smp_los_swtmr_006.c", + "smp/It_smp_los_swtmr_007.c", + "smp/It_smp_los_swtmr_008.c", + "smp/It_smp_los_swtmr_009.c", + "smp/It_smp_los_swtmr_010.c", + "smp/It_smp_los_swtmr_011.c", + "smp/It_smp_los_swtmr_012.c", + "smp/It_smp_los_swtmr_013.c", + "smp/It_smp_los_swtmr_014.c", + "smp/It_smp_los_swtmr_015.c", + "smp/It_smp_los_swtmr_016.c", + "smp/It_smp_los_swtmr_017.c", + "smp/It_smp_los_swtmr_018.c", + "smp/It_smp_los_swtmr_019.c", + "smp/It_smp_los_swtmr_020.c", + "smp/It_smp_los_swtmr_021.c", + "smp/It_smp_los_swtmr_022.c", + "smp/It_smp_los_swtmr_023.c", + "smp/It_smp_los_swtmr_024.c", + "smp/It_smp_los_swtmr_025.c", ] + include_dirs = [ "." ] + configs += [ "$LITEOSTOPDIR/testsuites:include" ] } diff --git a/testsuites/sample/kernel/swtmr/It_los_swtmr.c b/testsuites/sample/kernel/swtmr/It_los_swtmr.c index 8514fafe..8c8a7a8d 100644 --- a/testsuites/sample/kernel/swtmr/It_los_swtmr.c +++ b/testsuites/sample/kernel/swtmr/It_los_swtmr.c @@ -78,6 +78,34 @@ VOID ItSuiteLosSwtmr(void) ItLosSwtmrAlign004(); #endif +#if LOSCFG_KERNEL_SMP + ItSmpLosSwtmr001(); + ItSmpLosSwtmr002(); + ItSmpLosSwtmr003(); + ItSmpLosSwtmr004(); + ItSmpLosSwtmr005(); + ItSmpLosSwtmr006(); + ItSmpLosSwtmr007(); + ItSmpLosSwtmr008(); + ItSmpLosSwtmr009(); + ItSmpLosSwtmr010(); + ItSmpLosSwtmr011(); + ItSmpLosSwtmr012(); + ItSmpLosSwtmr013(); + ItSmpLosSwtmr014(); + ItSmpLosSwtmr015(); + ItSmpLosSwtmr016(); + ItSmpLosSwtmr017(); + ItSmpLosSwtmr018(); + ItSmpLosSwtmr019(); + ItSmpLosSwtmr020(); + ItSmpLosSwtmr021(); + ItSmpLosSwtmr022(); + ItSmpLosSwtmr023(); + ItSmpLosSwtmr024(); + ItSmpLosSwtmr025(); +#endif + #if (LOS_KERNEL_TEST_FULL == 1) ItLosSwtmr025(); ItLosSwtmr026(); diff --git a/testsuites/sample/kernel/swtmr/It_los_swtmr.h b/testsuites/sample/kernel/swtmr/It_los_swtmr.h index db83abde..5d7b87eb 100644 --- a/testsuites/sample/kernel/swtmr/It_los_swtmr.h +++ b/testsuites/sample/kernel/swtmr/It_los_swtmr.h @@ -39,6 +39,8 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ +#define LOOP 100 + #define SELF_DELETED 0 #define SYS_EXIST_SWTMR 1 #define TEST_HWI_RUNTIME 0x100000 @@ -188,6 +190,31 @@ extern VOID ItLosSwtmrDelay003(VOID); extern VOID ItLosSwtmrDelay004(VOID); extern VOID ItLosSwtmrDelay005(VOID); +extern VOID ItSmpLosSwtmr001(VOID); +extern VOID ItSmpLosSwtmr002(VOID); +extern VOID ItSmpLosSwtmr003(VOID); +extern VOID ItSmpLosSwtmr004(VOID); +extern VOID ItSmpLosSwtmr005(VOID); +extern VOID ItSmpLosSwtmr006(VOID); +extern VOID ItSmpLosSwtmr007(VOID); +extern VOID ItSmpLosSwtmr008(VOID); +extern VOID ItSmpLosSwtmr009(VOID); +extern VOID ItSmpLosSwtmr010(VOID); +extern VOID ItSmpLosSwtmr011(VOID); +extern VOID ItSmpLosSwtmr012(VOID); +extern VOID ItSmpLosSwtmr013(VOID); +extern VOID ItSmpLosSwtmr014(VOID); +extern VOID ItSmpLosSwtmr015(VOID); +extern VOID ItSmpLosSwtmr016(VOID); +extern VOID ItSmpLosSwtmr017(VOID); +extern VOID ItSmpLosSwtmr018(VOID); +extern VOID ItSmpLosSwtmr019(VOID); +extern VOID ItSmpLosSwtmr020(VOID); +extern VOID ItSmpLosSwtmr021(VOID); +extern VOID ItSmpLosSwtmr022(VOID); +extern VOID ItSmpLosSwtmr023(VOID); +extern VOID ItSmpLosSwtmr024(VOID); +extern VOID ItSmpLosSwtmr025(VOID); #ifdef __cplusplus #if __cplusplus diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_001.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_001.c new file mode 100644 index 00000000..21d6e29b --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_001.c @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static UINT32 g_testTimes; + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret; + UINT32 testSwtmrHandle; + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &testSwtmrHandle, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + ret = LOS_SwtmrStart(testSwtmrHandle); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + LOS_TaskDelay(g_testPeriod * g_testTimes + 5); // g_testPeriod * g_testTimes + 5, set delay time + + ret = LOS_SwtmrStop(testSwtmrHandle); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + ret = LOS_SwtmrDelete(testSwtmrHandle); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + +EXIT: + LOS_SwtmrDelete(testSwtmrHandle); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret, testid; + UINT32 coreIdx = 0; + + /* each core run swtmr for 10 times, period is 10 */ + g_testCount = 0; + g_testPeriod = 10; // period is 10 + g_testTimes = 10; // each core run swtmr for 10 times + + while (coreIdx < LOSCFG_KERNEL_CORE_NUM) { + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_001_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(coreIdx)); + ret = LOS_TaskCreate(&testid, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + coreIdx++; + } + + LOS_TaskDelay(g_testPeriod * g_testTimes + 10); // g_testPeriod * g_testTimes + 10, set delay time + + ICUNIT_ASSERT_EQUAL(g_testCount, g_testTimes * LOSCFG_KERNEL_CORE_NUM, g_testCount); + + return LOS_OK; +} + +VOID ItSmpLosSwtmr001(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr001", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_002.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_002.c new file mode 100644 index 00000000..ec7fed31 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_002.c @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static UINT32 g_testTimes; + +static UINT32 g_swtmrHandle[LOSCFG_KERNEL_CORE_NUM]; + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(UINTPTR swtmrId) +{ + UINT32 ret; + + ret = LOS_SwtmrStart(swtmrId); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + + + return; + +EXIT: + LOS_SwtmrDelete(swtmrId); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret, testid; + UINT32 i; + + /* each core run swtmr for 10 times, period is 10 */ + g_testCount = 0; + g_testPeriod = 10; // period is 10 + g_testTimes = 1; + + for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) { + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_swtmrHandle[i], 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + } + + for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) { + TEST_TASK_PARAM_INIT(testTask, "it_swtmr_002_task", TaskF01, + TASK_PRIO_TEST_SWTMR + 1); // not set cpuaffi + testTask.uwArg = g_swtmrHandle[i]; + testTask.usCpuAffiMask = CPUID_TO_AFFI_MASK(i); + ret = LOS_TaskCreate(&testid, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + } + + UINT64 startTime = LOS_CurrNanosec(); + LOS_TaskDelay(g_testPeriod * g_testTimes + 5); // g_testPeriod * g_testTimes + 5, set delay time + UINT64 usedTime = LOS_CurrNanosec() - startTime; + + ICUNIT_ASSERT_EQUAL(g_testCount, g_testTimes * LOSCFG_KERNEL_CORE_NUM, g_testCount); + + for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) { + ret = LOS_SwtmrStop(g_swtmrHandle[i]); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + ret = LOS_SwtmrDelete(g_swtmrHandle[i]); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + } + return LOS_OK; +EXIT: + for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) { + LOS_SwtmrDelete(g_swtmrHandle[i]); + } + return LOS_OK; +} + +VOID ItSmpLosSwtmr002(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr002", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_003.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_003.c new file mode 100644 index 00000000..f0295d7b --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_003.c @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret, currCpuid; + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + ret = LOS_SwtmrStart(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + return; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_003_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod + 10); // period is 10 + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + /* do stop and delete */ + ret = LOS_SwtmrStop(g_usSwTmrID); + ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT); + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT); + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr003(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr003", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_004.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_004.c new file mode 100644 index 00000000..40e4743b --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_004.c @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret; + LOS_AtomicInc(&g_testCount); + ret = LOS_SwtmrStart(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + return; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + UINT32 currCpuid; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_004_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // cross task + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TestAssertBusyTaskDelay(100, 1); // 100, Set the timeout of runtime; + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + LOS_TaskDelay(g_testPeriod + 1); + + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, The expected value + + /* do stop and delete */ + ret = LOS_SwtmrStop(g_usSwTmrID); + ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT); + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_GOTO_NOT_EQUAL(ret, LOS_OK, ret, EXIT); + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr004(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr004", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_005.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_005.c new file mode 100644 index 00000000..26b3fd52 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_005.c @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret, currCpuid; + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + ret = LOS_SwtmrStart(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + return; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_005_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time + + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, The expected value + + /* do stop and delete */ + ret = LOS_SwtmrStop(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr005(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr005", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_006.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_006.c new file mode 100644 index 00000000..db4b3998 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_006.c @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret; + + ret = LOS_SwtmrStart(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + return; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + UINT32 currCpuid; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_006_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // cross task + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time + + ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, The expected value + + /* do stop and delete */ + ret = LOS_SwtmrStop(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr006(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr006", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_007.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_007.c new file mode 100644 index 00000000..1286fdc1 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_007.c @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret, currCpuid; + + ret = LOS_SwtmrStop(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_STARTED, ret, EXIT); + + return; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_007_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod + 1); + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr007(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr007", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_008.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_008.c new file mode 100644 index 00000000..a60fe705 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_008.c @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret; + + ret = LOS_SwtmrStop(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_STARTED, ret, EXIT); + + return; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + UINT32 currCpuid; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_008_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // cross task + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod + 1); + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr008(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr008", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_009.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_009.c new file mode 100644 index 00000000..7334b156 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_009.c @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret, currCpuid; + + ret = LOS_SwtmrStop(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_STARTED, ret, EXIT); + + return; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_009_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr009(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr009", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_010.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_010.c new file mode 100644 index 00000000..b1f13d1d --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_010.c @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret; + + ret = LOS_SwtmrStop(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_SWTMR_NOT_STARTED, ret, EXIT); + + return; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + UINT32 currCpuid; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_010_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // cross task + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr010(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr010", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_011.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_011.c new file mode 100644 index 00000000..e1686b50 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_011.c @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret, currCpuid; + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_011_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod + 1); + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr011(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr011", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_012.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_012.c new file mode 100644 index 00000000..560823f9 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_012.c @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret; + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + UINT32 currCpuid; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_012_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // cross task + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod + 1); + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr012(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr012", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_013.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_013.c new file mode 100644 index 00000000..155210b6 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_013.c @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret, currCpuid; + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_013_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr013(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr013", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_014.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_014.c new file mode 100644 index 00000000..819cf8a4 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_014.c @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret; + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + UINT32 currCpuid; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_014_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // cross task + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr014(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr014", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_015.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_015.c new file mode 100644 index 00000000..666a83c3 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_015.c @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret; + + ret = LOS_SwtmrStop(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + return; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_SwtmrStart(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_015_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod + 1); + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr015(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr015", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_016.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_016.c new file mode 100644 index 00000000..c19811af --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_016.c @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret; + + ret = LOS_SwtmrStop(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + return; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + UINT32 currCpuid; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_SwtmrStart(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_016_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // cross task + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod + 1); + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr016(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr016", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_017.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_017.c new file mode 100644 index 00000000..8292f568 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_017.c @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret, currCpuid; + + ret = LOS_SwtmrStop(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + return; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_SwtmrStart(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_017_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr017(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr017", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_018.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_018.c new file mode 100644 index 00000000..01168585 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_018.c @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret; + + ret = LOS_SwtmrStop(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + return; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + UINT32 currCpuid; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_SwtmrStart(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_018_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // cross task + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr018(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr018", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_019.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_019.c new file mode 100644 index 00000000..7e47a239 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_019.c @@ -0,0 +1,83 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret, currCpuid; + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_SwtmrStart(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_019_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod + 1); + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr019(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr019", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_020.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_020.c new file mode 100644 index 00000000..ce04b893 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_020.c @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret; + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + UINT32 currCpuid; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_SwtmrStart(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_020_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // cross task + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod + 1); + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr020(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr020", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_021.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_021.c new file mode 100644 index 00000000..30092040 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_021.c @@ -0,0 +1,83 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret, currCpuid; + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_SwtmrStart(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_021_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr021(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr021", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_022.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_022.c new file mode 100644 index 00000000..ddb660e9 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_022.c @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret; + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + UINT32 currCpuid; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_SwtmrStart(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_022_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // cross task + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time + + ICUNIT_GOTO_EQUAL(g_testCount, 0, g_testCount, EXIT); + + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr022(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr022", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_023.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_023.c new file mode 100644 index 00000000..7ac81826 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_023.c @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret; + + ret = LOS_SwtmrStart(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + LOS_TaskDelay(g_testPeriod * 2 + 1); // g_testPeriod*2+1, set delay time + + ret = LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + UINT32 currCpuid; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + currCpuid = (ArchCurrCpuid() + 1) % (LOSCFG_KERNEL_CORE_NUM); + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_023_task", TaskF01, TASK_PRIO_TEST_SWTMR - 1, + CPUID_TO_AFFI_MASK(currCpuid)); // cross task + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod + 1); + + ret = LOS_SwtmrStop(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + LOS_TaskDelay(g_testPeriod + 1); + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr023(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr023", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_024.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_024.c new file mode 100644 index 00000000..fea417c8 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_024.c @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testCount); +} + +static void TaskF01(void) +{ + UINT32 ret; + + ret = LOS_SwtmrStart(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + return; +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return; +} + +static void TaskF02(void) +{ + UINT32 ret; + + do { + LOS_TaskDelay(10); + } while (g_testCount != 1); + + ret = LOS_SwtmrStop(g_usSwTmrID); + ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT); + + return; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + UINT32 currCpuid; + + g_testCount = 0; + g_testPeriod = 10; // period is 10 + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_usSwTmrID, 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_024_task1", TaskF01, + TASK_PRIO_TEST_SWTMR + 1, CPUID_TO_AFFI_MASK(ArchCurrCpuid())); + testTask.uwResved = LOS_TASK_ATTR_JOINABLE; + ret = LOS_TaskCreate(&g_testTaskID01, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_024_task2", TaskF02, + TASK_PRIO_TEST_SWTMR + 1, CPUID_TO_AFFI_MASK((ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM)); + testTask.uwResved = LOS_TASK_ATTR_JOINABLE; + ret = LOS_TaskCreate(&g_testTaskID02, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(g_testPeriod + 1); + + ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT); + + ret = LOS_TaskJoin(g_testTaskID01, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + ret = LOS_TaskJoin(g_testTaskID02, NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_SwtmrDelete(g_usSwTmrID); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + return LOS_OK; + +EXIT: + LOS_SwtmrDelete(g_usSwTmrID); + return LOS_OK; +} + +VOID ItSmpLosSwtmr024(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr024", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_025.c b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_025.c new file mode 100644 index 00000000..0895cae9 --- /dev/null +++ b/testsuites/sample/kernel/swtmr/smp/It_smp_los_swtmr_025.c @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_swtmr.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static UINT32 g_szId[LOSCFG_KERNEL_CORE_NUM] = {0}; +static UINT32 g_testSwtmtCount = 0; +static VOID SwtmrF01(void) +{ + LOS_AtomicInc(&g_testSwtmtCount); +} + +static void TaskF01(UINT32 index) +{ + UINT32 ret; + + ret = LOS_SwtmrCreate(g_testPeriod, LOS_SWTMR_MODE_PERIOD, (SWTMR_PROC_FUNC)SwtmrF01, &g_szId[index], 0 +#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1) + , OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE +#endif + ); + ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret); + return; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + UINT32 currCpuid; + UINT32 i; + UINT32 taskID[LOSCFG_KERNEL_CORE_NUM]; + g_testSwtmtCount = 0; + g_testPeriod = 10; // period is 10 + + for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) { + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_swtmr_025_task1", TaskF01, TASK_PRIO_TEST_SWTMR + 1, CPUID_TO_AFFI_MASK(i)); + testTask.uwArg = i; + testTask.uwResved = LOS_TASK_ATTR_JOINABLE; + ret = LOS_TaskCreate(&taskID[i], &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + } + + for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) { + ret = LOS_TaskJoin(taskID[i], NULL); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + } + + for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) { + ret = LOS_SwtmrStart(g_szId[i]); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + } + + LOS_TaskDelay(g_testPeriod + 5); /* 5 ticks */ + + ICUNIT_GOTO_EQUAL(g_testSwtmtCount, LOSCFG_KERNEL_CORE_NUM, g_testSwtmtCount, EXIT); + + for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) { + ret = LOS_SwtmrDelete(g_szId[i]); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + } + + return LOS_OK; + +EXIT: + for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) { + LOS_SwtmrDelete(g_szId[i]); + } + return LOS_OK; +} + +VOID ItSmpLosSwtmr025(VOID) +{ + TEST_ADD_CASE("ItSmpLosSwtmr025", Testcase, TEST_LOS, TEST_SWTMR, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/task/BUILD.gn b/testsuites/sample/kernel/task/BUILD.gn index 572501ea..97e6d944 100644 --- a/testsuites/sample/kernel/task/BUILD.gn +++ b/testsuites/sample/kernel/task/BUILD.gn @@ -159,7 +159,16 @@ static_library("test_task") { "It_los_task_128.c", "It_los_task_129.c", "It_los_task_130.c", + "smp/It_smp_los_task_001.c", + "smp/It_smp_los_task_002.c", + "smp/It_smp_los_task_003.c", + "smp/It_smp_los_task_004.c", + "smp/It_smp_los_task_005.c", + "smp/It_smp_los_task_006.c", + "smp/It_smp_los_task_007.c", ] + include_dirs = [ "." ] + configs += [ "$LITEOSTOPDIR/testsuites:include" ] } diff --git a/testsuites/sample/kernel/task/It_los_task.c b/testsuites/sample/kernel/task/It_los_task.c index 2ecfb4ac..3f0384a5 100644 --- a/testsuites/sample/kernel/task/It_los_task.c +++ b/testsuites/sample/kernel/task/It_los_task.c @@ -131,6 +131,16 @@ VOID ItSuiteLosTask() ItLosTask129(); ItLosTask130(); +#if LOSCFG_KERNEL_SMP + ItSmpLosTask001(); + ItSmpLosTask002(); + ItSmpLosTask003(); + ItSmpLosTask004(); + ItSmpLosTask005(); + ItSmpLosTask006(); + ItSmpLosTask007(); +#endif + #if (LOS_KERNEL_TEST_FULL == 1) ItLosTask039(); ItLosTask040(); diff --git a/testsuites/sample/kernel/task/It_los_task.h b/testsuites/sample/kernel/task/It_los_task.h index 4d04643e..3352240b 100644 --- a/testsuites/sample/kernel/task/It_los_task.h +++ b/testsuites/sample/kernel/task/It_los_task.h @@ -186,6 +186,11 @@ extern VOID ItLosTask128(VOID); extern VOID ItLosTask129(VOID); extern VOID ItLosTask130(VOID); +extern VOID ItSmpLosTask001(VOID); +extern VOID ItSmpLosTask002(VOID); +extern VOID ItSmpLosTask003(VOID); +extern VOID ItSmpLosTask004(VOID); + #ifdef __cplusplus #if __cplusplus } diff --git a/testsuites/sample/kernel/task/smp/It_smp_los_task_001.c b/testsuites/sample/kernel/task/smp/It_smp_los_task_001.c new file mode 100644 index 00000000..83d7bd3a --- /dev/null +++ b/testsuites/sample/kernel/task/smp/It_smp_los_task_001.c @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_task.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static SPIN_LOCK_INIT(g_TestSpin); + +static void TaskF01(void) +{ + UINT32 puvIntSave; + + LOS_SpinLockSave(&g_TestSpin, &puvIntSave); + g_testCount |= 1 << ArchCurrCpuid(); + LOS_SpinUnlockRestore(&g_TestSpin, puvIntSave); +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret; + UINT32 testid; + UINT32 coreIdx = 0; + + g_testCount = 0; + + while (coreIdx < LOSCFG_KERNEL_CORE_NUM) { + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_task_001", TaskF01, TASK_PRIO_TEST + 1, + CPUID_TO_AFFI_MASK(coreIdx)); + ret = LOS_TaskCreate(&testid, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + coreIdx++; + } + + LOS_TaskDelay(10); // 10, set delay time. + + ICUNIT_ASSERT_EQUAL(g_testCount, LOSCFG_KERNEL_CPU_MASK, g_testCount); + + return LOS_OK; +} + +void ItSmpLosTask001(void) +{ + TEST_ADD_CASE("ItSmpLosTask001", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/task/smp/It_smp_los_task_002.c b/testsuites/sample/kernel/task/smp/It_smp_los_task_002.c new file mode 100644 index 00000000..0c7cd831 --- /dev/null +++ b/testsuites/sample/kernel/task/smp/It_smp_los_task_002.c @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_task.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static void TaskF01(void) +{ + while (1) { + LOS_TaskDelay(10); + }; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret, currCpuid; + UINT32 testid = 0xff; + + /* make sure that created test task is definitely on another core */ + currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM; + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_task_002", TaskF01, OS_TASK_PRIORITY_LOWEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); + + ret = LOS_TaskCreate(&testid, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(2); // 2, set delay time. + ret = LOS_TaskDelete(testid); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + /* delay and check */ + LOS_TaskDelay(10); // 10, set delay time. + + ret = LOS_TaskDelete(testid); + ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_TSK_NOT_CREATED, ret); + + return LOS_OK; +} + +void ItSmpLosTask002(void) +{ + TEST_ADD_CASE("ItSmpLosTask002", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/task/smp/It_smp_los_task_003.c b/testsuites/sample/kernel/task/smp/It_smp_los_task_003.c new file mode 100644 index 00000000..0b84edc0 --- /dev/null +++ b/testsuites/sample/kernel/task/smp/It_smp_los_task_003.c @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_task.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static void TaskF01(void) +{ + while (1) { + LOS_TaskDelay(10); + }; +} + +static UINT32 Testcase(void) +{ + TSK_INIT_PARAM_S testTask; + UINT32 ret, currCpuid; + UINT32 testid = 0xff; + + /* make sure that created test task is definitely on another core */ + currCpuid = (ArchCurrCpuid() + 1) % LOSCFG_KERNEL_CORE_NUM; + + TEST_TASK_PARAM_INIT_AFFI(testTask, "it_smp_task_003", TaskF01, OS_TASK_PRIORITY_LOWEST - 1, + CPUID_TO_AFFI_MASK(currCpuid)); + + ret = LOS_TaskCreate(&testid, &testTask); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + LOS_TaskDelay(2); // 2, set delay time. + ret = LOS_TaskSuspend(testid); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + /* delay and check */ + LOS_TaskDelay(100); // 100, set delay time. + + ret = OS_TCB_FROM_TID(testid)->taskStatus; + ICUNIT_GOTO_EQUAL(ret & OS_TASK_STATUS_SUSPEND, OS_TASK_STATUS_SUSPEND, ret, EXIT); + + LOS_TaskResume(testid); + +EXIT: + LOS_TaskDelay(2); // 2, set delay time. + LOS_TaskDelete(testid); + + return LOS_OK; +} + +void ItSmpLosTask003(void) +{ + TEST_ADD_CASE("ItSmpLosTask003", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/task/smp/It_smp_los_task_004.c b/testsuites/sample/kernel/task/smp/It_smp_los_task_004.c new file mode 100644 index 00000000..ecc804dc --- /dev/null +++ b/testsuites/sample/kernel/task/smp/It_smp_los_task_004.c @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "osTest.h" +#include "It_los_task.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static void TaskF01(void) +{ + UINT32 ret; + ICUNIT_ASSERT_EQUAL_VOID(g_testCount, 0, g_testCount); + g_testCount++; +} + +static UINT32 Testcase(void) +{ + UINT32 ret; + TSK_INIT_PARAM_S task1 = { 0 }; + + g_testCount = 0; + // 2, It is used to calculate a priority relative to TASK_PRIO_TEST. + TEST_TASK_PARAM_INIT_AFFI(task1, "it_smp_task_004", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST - 2, 0); + ret = LOS_TaskCreate(&g_testTaskID01, &task1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + while (g_testCount == 0) { + } + ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount); + + return LOS_OK; +} + +void ItSmpLosTask004(void) +{ + TEST_ADD_CASE("ItSmpLosTask004", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/task/smp/It_smp_los_task_005.c b/testsuites/sample/kernel/task/smp/It_smp_los_task_005.c new file mode 100644 index 00000000..304bd2f9 --- /dev/null +++ b/testsuites/sample/kernel/task/smp/It_smp_los_task_005.c @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_task.h" +#include "los_atomic.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static void TaskF01(void) +{ + g_testCount++; + while (1) { + } +} + +static void TaskF02Preempt(void) +{ + g_testCount++; +} + +static UINT32 Testcase(void) +{ + UINT32 ret; + TSK_INIT_PARAM_S task1 = { 0 }; + UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM]; + g_testCount = 0; + //It is used to calculate a priority relative to TASK_PRIO_TEST. + TEST_TASK_PARAM_INIT(task1, "it_smp_task_005", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST + 2); + int i; + for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) { + /* take control of every cores */ + task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(i); + ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + } + + /* give up this core to task_f01 of this core */ + LOS_TaskDelay(10); // 10, set delay time. + + /* take this core back to control, create an unbinded task */ + ICUNIT_ASSERT_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount); + task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02Preempt; + task1.usTaskPrio = TASK_PRIO_TEST + 1; + task1.usCpuAffiMask = 0; + ret = LOS_TaskCreate(&g_testTaskID01, &task1); + LOS_TaskDelay(10); // 10, set delay time. + /* take this core back to control */ + ICUNIT_ASSERT_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM + 1, g_testCount); + + for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) { + ret = LOS_TaskDelete(testTaskIDSmp[i]); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + } + return LOS_OK; +} + +void ItSmpLosTask005(void) +{ + TEST_ADD_CASE("ItSmpLosTask005", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/task/smp/It_smp_los_task_006.c b/testsuites/sample/kernel/task/smp/It_smp_los_task_006.c new file mode 100644 index 00000000..b3db048b --- /dev/null +++ b/testsuites/sample/kernel/task/smp/It_smp_los_task_006.c @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_task.h" +#include "los_atomic.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static void TaskF01(void) +{ + g_testCount++; + while (1) { + } +} + +static void TaskF02Preempt(void) +{ + g_testCount++; +} + +static UINT32 Testcase(void) +{ + UINT32 ret; + TSK_INIT_PARAM_S task1 = { 0 }; + UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM]; + g_testCount = 0; + //It is used to calculate a priority relative to TASK_PRIO_TEST. + TEST_TASK_PARAM_INIT(task1, "it_smp_task_006", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST + 1); + int i; + for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) { + /* take control of every cores */ + task1.usCpuAffiMask = CPUID_TO_AFFI_MASK(i); + ret = LOS_TaskCreate(&testTaskIDSmp[i], &task1); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + } + + /* give up this core to task_f01 of this core */ + LOS_TaskDelay(10); // 10, set delay time. + + /* take this core back to control, create an unbinded task */ + ICUNIT_ASSERT_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount); + task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02Preempt; + task1.usTaskPrio = TASK_PRIO_TEST + 2; + task1.usCpuAffiMask = 0; + ret = LOS_TaskCreate(&g_testTaskID01, &task1); + + LOS_TaskDelay(10); // 10, set delay time. + + /* take this core back to control */ + ICUNIT_ASSERT_EQUAL(g_testCount, LOSCFG_KERNEL_CORE_NUM, g_testCount); + + for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) { + ret = LOS_TaskDelete(testTaskIDSmp[i]); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + } + return LOS_OK; +} + +void ItSmpLosTask006(void) +{ + TEST_ADD_CASE("ItSmpLosTask006", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/sample/kernel/task/smp/It_smp_los_task_007.c b/testsuites/sample/kernel/task/smp/It_smp_los_task_007.c new file mode 100644 index 00000000..e7e511d4 --- /dev/null +++ b/testsuites/sample/kernel/task/smp/It_smp_los_task_007.c @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "It_los_task.h" +#include "los_atomic.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +static void TaskF01(void) +{ + g_testCount++; +} + +static void TaskF02(void) +{ + g_testCount++; +} + +static UINT32 Testcase(void) +{ + UINT32 ret; + TSK_INIT_PARAM_S task1 = { 0 }; + UINT32 testTaskIDSmp[LOSCFG_KERNEL_CORE_NUM]; + + g_testCount = 0; + //It is used to calculate a priority relative to TASK_PRIO_TEST. + TEST_TASK_PARAM_INIT_AFFI(task1, "it_smp_task_007", (TSK_ENTRY_FUNC)TaskF01, TASK_PRIO_TEST + 1, 0); + ret = LOS_TaskCreate(&g_testTaskID01, &task1); + /* give up this core to task_f01 of this core */ + LOS_TaskDelay(10); // 10, set delay time. + + + ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount); + /* take this core back to control, create an unbinded task */ + task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF02; + task1.usTaskPrio = TASK_PRIO_TEST + 2; + task1.usCpuAffiMask = 0; + ret = LOS_TaskCreate(&g_testTaskID02, &task1); + LOS_TaskDelay(10); // 10, set delay time. + + /* take this core back to control */ + ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); + + ret = LOS_TaskDelete(g_testTaskID01); + ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret); + + return LOS_OK; +} + +void ItSmpLosTask007(void) +{ + TEST_ADD_CASE("ItSmpLosTask007", Testcase, TEST_LOS, TEST_TASK, TEST_LEVEL1, TEST_FUNCTION); +} + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ diff --git a/testsuites/src/osTest.c b/testsuites/src/osTest.c index 0c4e3342..ac52e5f3 100644 --- a/testsuites/src/osTest.c +++ b/testsuites/src/osTest.c @@ -62,8 +62,9 @@ UINT32 g_usSemID2; UINT32 g_cpupTestCount; UINT32 g_cmsisRobinCount1; UINT32 g_cmsisCount; +UINT32 g_testPeriod; -UINT16 g_usSwTmrID; +UINT32 g_usSwTmrID; UINT32 g_testQueueID01; UINT32 g_testQueueID02; @@ -138,22 +139,60 @@ UINT32 QueueUsedCountGet(VOID) return count; } -extern LosTaskCB *g_taskCBArray; -UINT32 TaskUsedCountGet(VOID) +UINT64 TestTickCountGet(VOID) { - UINT32 intSave; - UINT32 count = 0; + /* not use LOS_TickCountGet for now, + cause every timer is not match with others. + use cpu0 timer instead. */ + return LOS_TickCountGet(); +} - intSave = LOS_IntLock(); - for (UINT32 index = 0; index < LOSCFG_BASE_CORE_TSK_LIMIT; index++) { - LosTaskCB *taskCB = ((LosTaskCB *)g_taskCBArray) + index; - if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) { - count++; +UINT64 TestTickCountByCurrCpuid(VOID) +{ + return LOS_TickCountGet(); +} + +/* + * different from calling LOS_TaskDelay, + * this func will not yield this task to another one. + */ +VOID TestBusyTaskDelay(UINT32 tick) +{ + UINT64 runtime; + + runtime = TestTickCountByCurrCpuid() + tick; + while (1) { + if (runtime <= TestTickCountByCurrCpuid()) { + break; } } - LOS_IntRestore(intSave); +} - return (LOSCFG_BASE_CORE_TSK_LIMIT - count); +VOID TestAssertBusyTaskDelay(UINT32 timeout, UINT32 flag) +{ + UINT64 runtime; + + runtime = TestTickCountGet() + timeout; + while (1) { + if ((runtime <= TestTickCountGet()) || (g_testCount == flag)) { + break; + } + } +} + +VOID TestTestHwiDelete(unsigned int irq, VOID *devId) +{ + HwiIrqParam stuwIrqPara; + + if (OS_INT_ACTIVE) { + return; + } + + stuwIrqPara.swIrq = irq; + stuwIrqPara.pDevId = devId; + + (VOID)LOS_HwiDelete(irq, &stuwIrqPara); + return; } void TestKernel(void) @@ -268,6 +307,9 @@ UINT32 los_TestInit(VOID) osTaskInitParam.pcName = "IT_TST_INI"; osTaskInitParam.usTaskPrio = TASK_PRIO_TEST; osTaskInitParam.uwResved = LOS_TASK_ATTR_JOINABLE; +#ifdef LOSCFG_KERNEL_SMP + osTaskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid()); +#endif ret = LOS_TaskCreate(&g_testTskHandle, &osTaskInitParam); if (LOS_OK != ret) { -- Gitee