Compare commits
No commits in common. "master" and "OpenHarmony-4.0-Beta2" have entirely different histories.
master
...
OpenHarmon
7
BUILD.gn
7
BUILD.gn
|
|
@ -44,10 +44,6 @@ if (defined(LOSCFG_COMPILER_ICCARM)) {
|
|||
}
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
liteos_build_asm = true
|
||||
}
|
||||
|
||||
config("arch_config") {
|
||||
cflags = arch_config_cflags
|
||||
asmflags = arch_config_asmflags
|
||||
|
|
@ -219,7 +215,4 @@ build_ext_component("build_kernel_image") {
|
|||
exec_path = rebase_path(root_out_dir)
|
||||
|
||||
command = toochain_config_command
|
||||
if (liteos_build_asm) {
|
||||
command += toochain_asm_command
|
||||
}
|
||||
}
|
||||
|
|
|
|||
170
Kconfig
170
Kconfig
|
|
@ -39,9 +39,19 @@ choice
|
|||
config COMPILER_GCC
|
||||
bool "GCC"
|
||||
|
||||
config CROSS_COMPILE
|
||||
string "GCC cross-compile toolchain prefix"
|
||||
depends on COMPILER_GCC
|
||||
default "arm-none-eabi-" if ARCH_ARM_AARCH32
|
||||
|
||||
config COMPILER_CLANG_LLVM
|
||||
bool "Clang"
|
||||
|
||||
config LLVM_TARGET
|
||||
string "Clang LLVM target"
|
||||
depends on COMPILER_CLANG_LLVM
|
||||
default "arm-liteos-ohos" if ARCH_ARM_AARCH32
|
||||
|
||||
config COMPILER_ICCARM
|
||||
bool "ICCARM"
|
||||
|
||||
|
|
@ -86,6 +96,15 @@ config PLATFORM
|
|||
string
|
||||
default "virt" if PLATFORM_QEMU_ARM_VIRT_CM7 || PLATFORM_QEMU_ARM_VIRT_CM4 || PLATFORM_QEMU_ARM_VIRT_CM55 || PRODUCT_QEMU_RISCV32_VIRT || PLATFORM_QEMU_CSKY_SMARTL || PLATFORM_QEMU_XTENSA_ESP32
|
||||
|
||||
config PRODUCT_NAME
|
||||
string
|
||||
default "arm_virt" if PRODUCT_QEMU_ARM
|
||||
default "arm_mps2_an386" if PRODUCT_QEMU_ARM_MPS2_AN386
|
||||
default "arm_mps3_an547" if PRODUCT_QEMU_ARM_MPS3_AN547
|
||||
default "riscv32_virt" if PRODUCT_QEMU_RISCV32_VIRT
|
||||
default "csky_smartl_e802" if PRODUCT_QEMU_CSKY_SMARTL_E802
|
||||
default "xtensa_esp32" if PRODUCT_QEMU_XTENSA_ESP32
|
||||
|
||||
config DEVICE_COMPANY
|
||||
string
|
||||
default "qemu" if PLATFORM_QEMU_ARM_VIRT_CM7 || PLATFORM_QEMU_ARM_VIRT_CM4 || PLATFORM_QEMU_ARM_VIRT_CM55 || PRODUCT_QEMU_RISCV32_VIRT || PLATFORM_QEMU_CSKY_SMARTL || PLATFORM_QEMU_XTENSA_ESP32
|
||||
|
|
@ -144,9 +163,24 @@ choice
|
|||
help
|
||||
Select your target board.
|
||||
|
||||
config PRODUCT_QEMU_ARM
|
||||
bool "arm_virt" if PLATFORM_QEMU_ARM_VIRT_CM7
|
||||
|
||||
config PRODUCT_QEMU_ARM_MPS2_AN386
|
||||
bool "arm_mps2_an386" if PLATFORM_QEMU_ARM_VIRT_CM4
|
||||
|
||||
config PRODUCT_QEMU_ARM_MPS3_AN547
|
||||
bool "arm_mps3_an547" if PLATFORM_QEMU_ARM_VIRT_CM55
|
||||
|
||||
config PRODUCT_QEMU_RISCV32_VIRT
|
||||
bool "riscv32_virt" if PLATFORM_QEMU_RISCV32_VIRT
|
||||
|
||||
config PRODUCT_QEMU_CSKY_SMARTL_E802
|
||||
bool "csky_smartl_e802" if PLATFORM_QEMU_CSKY_SMARTL
|
||||
|
||||
config PRODUCT_QEMU_XTENSA_ESP32
|
||||
bool "xtensa_esp32" if PLATFORM_QEMU_XTENSA_ESP32
|
||||
|
||||
endchoice
|
||||
|
||||
|
||||
|
|
@ -185,6 +219,12 @@ endchoice
|
|||
|
||||
orsource "../../device/soc/*/Kconfig.liteos_m.soc"
|
||||
|
||||
config QUICK_START
|
||||
bool "Enable QUICK_START"
|
||||
default n
|
||||
depends on DRIVERS && FS_VFS
|
||||
help
|
||||
Answer Y to enable LiteOS support quick start.
|
||||
endmenu
|
||||
|
||||
######################### config options of kernel #####################
|
||||
|
|
@ -303,6 +343,21 @@ config KERNEL_PM_IDLE
|
|||
Configuration item for low power frame tailoring.
|
||||
If you wish to build LiteOS with support for power management idle.
|
||||
|
||||
config KERNEL_PM_TASK_PTIORITY
|
||||
int "Power Management Task Priority"
|
||||
default 1
|
||||
range 1 31
|
||||
depends on KERNEL_PM
|
||||
help
|
||||
Configuration item for priority of low-power task.
|
||||
|
||||
config KERNEL_PM_TASK_STACKSIZE
|
||||
int "Power Management Task Stack Size"
|
||||
default 1024
|
||||
depends on KERNEL_PM
|
||||
help
|
||||
Configuration item for stack size of low-power task.
|
||||
|
||||
config KERNEL_PM_DEBUG
|
||||
bool "Power Management Debug"
|
||||
default n
|
||||
|
|
@ -338,6 +393,17 @@ source "components/lms/Kconfig"
|
|||
|
||||
endmenu
|
||||
|
||||
######################### config options of lib ########################
|
||||
menu "Lib"
|
||||
config LIB_LIBC
|
||||
bool "Enable Libc"
|
||||
default y
|
||||
help
|
||||
Answer Y to enable libc for full code.
|
||||
|
||||
endmenu
|
||||
|
||||
|
||||
######################### config options of compatibility ##############
|
||||
menu "Compat"
|
||||
|
||||
|
|
@ -370,6 +436,43 @@ endmenu
|
|||
|
||||
######################## config options of debug ########################
|
||||
menu "Debug"
|
||||
config GDB
|
||||
bool "Enable gdb functions"
|
||||
default n
|
||||
help
|
||||
Answer Y to enable gdb functions.
|
||||
|
||||
config PLATFORM_ADAPT
|
||||
bool "Enable Os_adapt"
|
||||
default y
|
||||
help
|
||||
Answer Y to add os_adapt.c to LiteOS.
|
||||
|
||||
config ENABLE_OOM_LOOP_TASK
|
||||
bool "Enable Oom loop task"
|
||||
default n
|
||||
depends on KERNEL_VM
|
||||
help
|
||||
Answer Y to enable oom loop kthread to check system out of memory.
|
||||
|
||||
config DO_ALIGN
|
||||
bool "Enable do align for hi3518e"
|
||||
default y
|
||||
depends on PLATFORM_HI3518EV200
|
||||
help
|
||||
Answer Y to enable do align for hi3518e.
|
||||
|
||||
|
||||
config ENABLE_MAGICKEY
|
||||
bool "Enable MAGIC KEY"
|
||||
default y
|
||||
help
|
||||
Answer Y to enable LiteOS Magic key.
|
||||
ctrl + r : Magic key check switch;
|
||||
ctrl + z : Show all magic op key;
|
||||
ctrl + t : Show task information;
|
||||
ctrl + p : System panic;
|
||||
ctrl + e : Check system memory pool.
|
||||
|
||||
config THUMB
|
||||
bool "Enable Thumb"
|
||||
|
|
@ -378,6 +481,20 @@ config THUMB
|
|||
help
|
||||
Answer Y to build thumb version. This will make LiteOS smaller.
|
||||
|
||||
config PLATFORM_DVFS
|
||||
bool "Enable Dvfs"
|
||||
default n
|
||||
depends on COMPAT_LINUXKPI
|
||||
help
|
||||
Answer Y to enable LiteOS support dynamic voltage and frequency scaling feature for
|
||||
low power consumption.
|
||||
|
||||
config SAVE_EXCINFO
|
||||
bool "Enable Saving Exception Information"
|
||||
default n
|
||||
help
|
||||
Answer Y to enable LiteOS support saving exception information to storage medium.
|
||||
|
||||
config DEBUG_VERSION
|
||||
bool "Enable a Debug Version"
|
||||
default y
|
||||
|
|
@ -397,6 +514,13 @@ config DEBUG_KERNEL
|
|||
It also means you want to get queue, mutex, semaphore, memory debug information.
|
||||
That means you want a opposite behaviour compared to release version.
|
||||
|
||||
config DEBUG_QUEUE
|
||||
bool "Enable Queue Debugging"
|
||||
default n
|
||||
depends on DEBUG_KERNEL
|
||||
help
|
||||
Answer Y to enable debug queue.
|
||||
|
||||
config MUTEX_CREATE_TRACE
|
||||
bool "Enable Mutex Trace Debugging"
|
||||
default n
|
||||
|
|
@ -405,6 +529,20 @@ config MUTEX_CREATE_TRACE
|
|||
help
|
||||
Answer Y to enable debug mutex trace.
|
||||
|
||||
config DEBUG_DEADLOCK
|
||||
bool "Enable Mutex Deadlock Debugging"
|
||||
default n
|
||||
depends on DEBUG_KERNEL
|
||||
help
|
||||
Answer Y to enable debug mutex deadlock.
|
||||
|
||||
config DEBUG_SEMAPHORE
|
||||
bool "Enable Semaphore Debugging"
|
||||
default n
|
||||
depends on DEBUG_KERNEL
|
||||
help
|
||||
Answer Y to enable debug semaphore.
|
||||
|
||||
config NET_LWIP_SACK_TFTP
|
||||
bool "Enable Tftp"
|
||||
default y
|
||||
|
|
@ -419,6 +557,18 @@ config DEBUG_HOOK
|
|||
help
|
||||
Enable the kernel hook framework to support customized trace information capture.
|
||||
|
||||
config SCHED_DEBUG
|
||||
bool "Enable sched debug Feature"
|
||||
default n
|
||||
depends on DEBUG_VERSION
|
||||
help
|
||||
If you wish to build LiteOS with support for sched debug.
|
||||
|
||||
config USER_INIT_DEBUG
|
||||
bool "Enable user init Debug"
|
||||
default n
|
||||
depends on DEBUG_VERSION
|
||||
|
||||
config SHELL_CMD_DEBUG
|
||||
bool "Enable shell cmd Debug"
|
||||
default n
|
||||
|
|
@ -431,6 +581,13 @@ config DEBUG_TOOLS
|
|||
help
|
||||
Answer Y to enable LiteOS debug tools, include stackdump, hwidump, tasktrack.
|
||||
|
||||
config USB_DEBUG
|
||||
bool "Enable USB Debug"
|
||||
default n
|
||||
depends on SHELL && DRIVERS_USB && DEBUG_VERSION
|
||||
help
|
||||
Answer Y to enable LiteOS support usb debug.
|
||||
use shell command to open the specified debug level print.
|
||||
config MEM_DEBUG
|
||||
bool "Enable MEM Debug"
|
||||
default n
|
||||
|
|
@ -454,6 +611,13 @@ config MEM_WATERLINE
|
|||
default n
|
||||
depends on DEBUG_VERSION && MEM_DEBUG
|
||||
|
||||
config VM_OVERLAP_CHECK
|
||||
bool "Enable VM overlap check or not"
|
||||
default n
|
||||
depends on DEBUG_VERSION && MEM_DEBUG
|
||||
help
|
||||
Answer Y to enable vm overlap check.
|
||||
|
||||
config TASK_MEM_USED
|
||||
bool "Enable show task mem used or not"
|
||||
default n
|
||||
|
|
@ -479,6 +643,12 @@ config SECURE_HEAP_SIZE
|
|||
int "TrustZone Heap Size (bytes)"
|
||||
default 2048
|
||||
depends on SECURE_TRUSTZONE
|
||||
config SECURE_STACK_DEFAULT_SIZE
|
||||
int "TrustZone Stack Size (bytes)"
|
||||
default 512
|
||||
depends on SECURE_TRUSTZONE
|
||||
help
|
||||
The secure stack must be allocated before the task calls non-secure functions.
|
||||
config SECURE
|
||||
bool "Enable Security"
|
||||
default n
|
||||
|
|
|
|||
4
OAT.xml
4
OAT.xml
|
|
@ -23,7 +23,6 @@
|
|||
<policylist>
|
||||
<policy name="projectPolicy" desc="">
|
||||
<policyitem type="copyright" name="Huawei Technologies Co., Ltd. All rights reserved." path=".*" desc="original liteos copyright"/>
|
||||
<policyitem type="copyright" name="Hunan OpenValley Digital Industry Development Co., Ltd." path=".*" desc="Developed By OpenValley Digital Co., Ltd."/>
|
||||
<policyitem type="license" name="BSD-3-Clause" path=".*" desc="Liteos kernel use bsd3 license"/>
|
||||
<policyitem type="license" name="BSD-3-Clause" path=".*" desc="Liteos kernel use bsd3 license"/>
|
||||
</policy>
|
||||
|
|
@ -67,9 +66,6 @@
|
|||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
|
||||
<filteritem type="filepath"
|
||||
name="figures/architecture-of-openharmony-the-liteos-cortex-m-kernel.png" desc="architecture-of-openharmony-the-liteos-cortex-m-kernel"/>
|
||||
<filteritem type="filepath" name="figures/OpenHarmony-LiteOS-M核内核架构图.png" desc="内核驱动架构"/>
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ The directory structure is as follows. For more details, see [arch_spec.md](arch
|
|||
│ ├── include # APIs exposed externally
|
||||
│ ├── risc-v # Code of the risc-v architecture
|
||||
│ │ ├── nuclei # Code of the nuclei system technology risc-v architecture
|
||||
│ │ └── riscv32 # Code of the risc-v official common architecture
|
||||
│ │ └── riscv32 # Code of the risc-v architecture
|
||||
│ └── xtensa # Code of the xtensa architecture
|
||||
│ └── lx6 # Code of the lx6 xtensa architecture
|
||||
├── components # Optional components
|
||||
|
|
|
|||
21
arch/Kconfig
21
arch/Kconfig
|
|
@ -24,6 +24,27 @@ config ARCH_FPU_DISABLE
|
|||
help
|
||||
This option will bypass floating procedure in system.
|
||||
|
||||
config ARCH_SECURE_MONITOR_MODE
|
||||
bool "Run On Secure Monitor Mode"
|
||||
default n
|
||||
depends on ARCH_ARM_AARCH64
|
||||
help
|
||||
This option will make the system run on EL3.
|
||||
|
||||
config ARCH_INTERRUPT_PREEMPTION
|
||||
bool "Enable Interrupt Preemption"
|
||||
default n
|
||||
depends on ARCH_ARM_AARCH64
|
||||
help
|
||||
This option will support high priority interrupt preemption.
|
||||
|
||||
config IRQ_USE_STANDALONE_STACK
|
||||
bool "Use Interrupt Stack"
|
||||
default y
|
||||
depends on ARCH_ARM_AARCH64 || ARCH_ARM_AARCH32
|
||||
help
|
||||
This option will support using standalone interrupt stack.
|
||||
|
||||
config ARCH_UNALIGNED_EXC
|
||||
bool "Enable Unaligned Exception"
|
||||
default y
|
||||
|
|
|
|||
|
|
@ -105,6 +105,10 @@ BOOL OsHwiIsCreated(UINT32 index)
|
|||
#endif
|
||||
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
typedef struct {
|
||||
HWI_PROC_FUNC pfnHandler;
|
||||
VOID *pParm;
|
||||
} HWI_HANDLER_FUNC;
|
||||
|
||||
/* *
|
||||
* @ingroup los_hwi
|
||||
|
|
|
|||
|
|
@ -63,11 +63,6 @@ extern UINT32 g_intCount;
|
|||
#endif
|
||||
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
typedef struct {
|
||||
HWI_PROC_FUNC pfnHandler;
|
||||
VOID *pParm;
|
||||
} HWI_HANDLER_FUNC;
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* Set interrupt vector table.
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
|||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
|
||||
return nextResponseTime;
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
|||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
|||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
|||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
|||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
|||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
|||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
|||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
|||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
|||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
|||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
|||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2024 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_m/liteos.gni")
|
||||
|
||||
module_name = "arch"
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"los_context.c",
|
||||
"los_dispatch.S",
|
||||
"los_exc.S",
|
||||
"los_interrupt.c",
|
||||
"los_mpu.c",
|
||||
"los_timer.c",
|
||||
]
|
||||
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "." ]
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
|||
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
|
||||
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
|
||||
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
|
||||
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
|
||||
NVIC_ClearPendingIRQ(SysTick_IRQn);
|
||||
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
|
||||
return nextResponseTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,6 +155,10 @@ UINT32 ArchIntCurIrqNum(VOID)
|
|||
}
|
||||
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
typedef struct {
|
||||
HWI_PROC_FUNC pfnHandler;
|
||||
VOID *pParm;
|
||||
} HWI_HANDLER_FUNC;
|
||||
|
||||
/* *
|
||||
* @ingroup los_hwi
|
||||
|
|
|
|||
|
|
@ -63,11 +63,6 @@ extern volatile UINT32 g_intCount;
|
|||
#endif
|
||||
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
typedef struct {
|
||||
HWI_PROC_FUNC pfnHandler;
|
||||
VOID *pParm;
|
||||
} HWI_HANDLER_FUNC;
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* Set interrupt vector table.
|
||||
|
|
|
|||
|
|
@ -110,12 +110,6 @@ typedef struct {
|
|||
*/
|
||||
#define OS_RISCV_VECTOR_CNT (OS_RISCV_SYS_VECTOR_CNT + OS_RISCV_CUSTOM_IRQ_VECTOR_CNT)
|
||||
|
||||
/**
|
||||
* @ingroup los_arch_interrupt
|
||||
* Count of risc-v system interrupt vector.
|
||||
*/
|
||||
#define OS_SYS_VECTOR_CNT 0
|
||||
|
||||
/**
|
||||
* Maximum number of supported hardware devices that generate hardware interrupts.
|
||||
* The maximum number of hardware devices that generate hardware interrupts supported by hi3518ev200 is 32.
|
||||
|
|
|
|||
|
|
@ -137,6 +137,10 @@ UINT32 ArchIntCurIrqNum(VOID)
|
|||
}
|
||||
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
typedef struct {
|
||||
HWI_PROC_FUNC pfnHandler;
|
||||
VOID *pParm;
|
||||
} HWI_HANDLER_FUNC;
|
||||
|
||||
/* *
|
||||
* @ingroup los_hwi
|
||||
|
|
|
|||
|
|
@ -63,11 +63,6 @@ extern UINT32 g_intCount;
|
|||
#endif
|
||||
|
||||
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
|
||||
typedef struct {
|
||||
HWI_PROC_FUNC pfnHandler;
|
||||
VOID *pParm;
|
||||
} HWI_HANDLER_FUNC;
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* Set interrupt vector table.
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@
|
|||
"component": {
|
||||
"name": "liteos_m",
|
||||
"subsystem": "kernel",
|
||||
"syscap": [
|
||||
"SystemCapability.Kernel.Liteos-M"
|
||||
],
|
||||
"features": [],
|
||||
"adapted_system_type": [
|
||||
"mini"
|
||||
|
|
|
|||
|
|
@ -616,11 +616,11 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_CpupUsageMonitor(CPUP_TYPE_E type, CPUP_MODE_E
|
|||
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqStart(UINT32 intNum)
|
||||
{
|
||||
if ((g_irqCpupInitFlg == 0) || (intNum < OS_SYS_VECTOR_CNT)) {
|
||||
if (g_irqCpupInitFlg == 0) {
|
||||
return;
|
||||
}
|
||||
UINT32 cpupIntNum = intNum - OS_SYS_VECTOR_CNT;
|
||||
g_irqCpup[cpupIntNum].startTime = CpupTimeUsGet();
|
||||
|
||||
g_irqCpup[intNum].startTime = CpupTimeUsGet();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -629,34 +629,33 @@ LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqEnd(UINT32 intNum)
|
|||
UINT64 cpuTime;
|
||||
UINT64 usedTime;
|
||||
|
||||
if ((g_irqCpupInitFlg == 0) || (intNum < OS_SYS_VECTOR_CNT)) {
|
||||
if (g_irqCpupInitFlg == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
UINT32 cpupIntNum = intNum - OS_SYS_VECTOR_CNT;
|
||||
if (g_irqCpup[cpupIntNum].startTime == 0) {
|
||||
if (g_irqCpup[intNum].startTime == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
cpuTime = CpupTimeUsGet();
|
||||
if (cpuTime < g_irqCpup[cpupIntNum].startTime) {
|
||||
if (cpuTime < g_irqCpup[intNum].startTime) {
|
||||
cpuTime += OS_US_PER_TICK;
|
||||
}
|
||||
|
||||
g_irqCpup[cpupIntNum].cpupID = intNum;
|
||||
g_irqCpup[cpupIntNum].status = OS_CPUP_USED;
|
||||
usedTime = cpuTime - g_irqCpup[cpupIntNum].startTime;
|
||||
g_irqCpup[intNum].cpupID = intNum;
|
||||
g_irqCpup[intNum].status = OS_CPUP_USED;
|
||||
usedTime = cpuTime - g_irqCpup[intNum].startTime;
|
||||
|
||||
if (g_irqCpup[cpupIntNum].count <= 1000) { /* 1000, Take 1000 samples */
|
||||
g_irqCpup[cpupIntNum].allTime += usedTime;
|
||||
g_irqCpup[cpupIntNum].count++;
|
||||
if (g_irqCpup[intNum].count <= 1000) { /* 1000, Take 1000 samples */
|
||||
g_irqCpup[intNum].allTime += usedTime;
|
||||
g_irqCpup[intNum].count++;
|
||||
} else {
|
||||
g_irqCpup[cpupIntNum].allTime = 0;
|
||||
g_irqCpup[cpupIntNum].count = 0;
|
||||
g_irqCpup[intNum].allTime = 0;
|
||||
g_irqCpup[intNum].count = 0;
|
||||
}
|
||||
g_irqCpup[cpupIntNum].startTime = 0;
|
||||
if (usedTime > g_irqCpup[cpupIntNum].timeMax) {
|
||||
g_irqCpup[cpupIntNum].timeMax = usedTime;
|
||||
g_irqCpup[intNum].startTime = 0;
|
||||
if (usedTime > g_irqCpup[intNum].timeMax) {
|
||||
g_irqCpup[intNum].timeMax = usedTime;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,4 +31,11 @@ config LMS_CHECK_STRICT
|
|||
default n
|
||||
depends on KERNEL_LMS
|
||||
help
|
||||
Select y to enable byte-by-byte check in Lms
|
||||
Select y to enable byte-by-byte check in lms
|
||||
|
||||
config LMS_LIBC_FULL_CHECK
|
||||
bool "Enable libc all function do lms check"
|
||||
default n
|
||||
depends on KERNEL_LMS
|
||||
help
|
||||
Select y to enable libc full check
|
||||
|
|
|
|||
|
|
@ -162,8 +162,7 @@ UINT32 LOS_LmsCheckPoolAdd(const VOID *pool, UINT32 size)
|
|||
lmsPoolNode->shadowStart = (UINTPTR)poolAddr + realSize;
|
||||
lmsPoolNode->shadowSize = poolAddr + size - lmsPoolNode->shadowStart;
|
||||
/* init shadow value */
|
||||
(VOID)memset_s((VOID *)lmsPoolNode->shadowStart, lmsPoolNode->shadowSize, LMS_SHADOW_AFTERFREE_U8,
|
||||
lmsPoolNode->shadowSize);
|
||||
(VOID)memset_s((VOID *)lmsPoolNode->shadowStart, lmsPoolNode->shadowSize, LMS_SHADOW_AFTERFREE_U8, lmsPoolNode->shadowSize);
|
||||
|
||||
LOS_ListAdd(&g_lmsCheckPoolList, &(lmsPoolNode->node));
|
||||
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
|
|||
realSleepTime = expireTime - currTime;
|
||||
sleepCycle = OS_SYS_CYCLE_TO_NS(realSleepTime, g_sysClock);
|
||||
sleepCycle = OS_SYS_NS_TO_CYCLE(sleepCycle, tickTimer->freq);
|
||||
|
||||
if (sleepCycle == 0) {
|
||||
pm->sysMode = LOS_SYS_NORMAL_SLEEP;
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -24,4 +24,18 @@ config SHELL_STACK_SIZE
|
|||
default 4096
|
||||
depends on SHELL
|
||||
|
||||
config SHELL_LK
|
||||
bool "Enable Shell lk"
|
||||
default y
|
||||
depends on DEBUG_VERSION && SHELL
|
||||
help
|
||||
Answer Y to enable LiteOS support shell lk.
|
||||
|
||||
config SHELL_DMESG
|
||||
bool "Enable Shell dmesg"
|
||||
default n
|
||||
depends on DEBUG_VERSION && SHELL && SHELL_CMD_DEBUG
|
||||
help
|
||||
Answer Y to enable LiteOS support shell dmesg.
|
||||
|
||||
endmenu
|
||||
|
|
|
|||
|
|
@ -72,4 +72,7 @@ config TRACE_CONTROL_VIA_SHELL
|
|||
config TRACE_CONTROL_AGENT
|
||||
bool "Via Trace Agent Task"
|
||||
|
||||
config TRACE_NO_CONTROL
|
||||
bool "No Control"
|
||||
|
||||
endchoice
|
||||
|
|
@ -206,6 +206,5 @@ toochain_config_objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
|
|||
toochain_config_command =
|
||||
"$toochain_config_objcopy -O binary $liteos_name $liteos_name.bin"
|
||||
toochain_config_command += " && sh -c '$toochain_config_objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
|
||||
|
||||
toochain_asm_command =
|
||||
toochain_config_command +=
|
||||
" && sh -c '$toochain_config_objdump -d $liteos_name >$liteos_name.asm'"
|
||||
|
|
|
|||
|
|
@ -149,5 +149,4 @@ toochain_config_objdump = "${compile_prefix}ielfdumparm$toolchain_cmd_suffix"
|
|||
|
||||
toochain_config_command =
|
||||
"$toochain_config_objcopy --bin --verbose $liteos_name $liteos_name.bin"
|
||||
|
||||
toochain_asm_command = " && sh -c '$toochain_config_objdump --source --all $liteos_name -o $liteos_name.asm'"
|
||||
toochain_config_command += " && sh -c '$toochain_config_objdump --source --all $liteos_name -o $liteos_name.asm'"
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@
|
|||
|
||||
#include "los_list.h"
|
||||
#include "los_config.h"
|
||||
#include "los_task.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
@ -488,50 +487,6 @@ extern UINT32 LOS_QueueReadCopy(UINT32 queueID,
|
|||
UINT32 *bufferSize,
|
||||
UINT32 timeOut);
|
||||
|
||||
/**
|
||||
* @ingroup los_queue
|
||||
* @brief Read a queue in interrupt service routine.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to read data in a specified queue, and store the obtained data to the address specified
|
||||
* by bufferAddr. The address and the size of the data to be read are defined by users.
|
||||
* It is safe to use this API from within an interrupt service routine.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The specific queue should be created firstly.</li>
|
||||
* <li>Queue reading adopts the fist in first out (FIFO) mode. The data that is first stored in the queue is read
|
||||
* first.</li>
|
||||
* <li>This API read a queue in unblocking modes.</li>
|
||||
* <li>bufferAddr stores the obtained data.</li>
|
||||
* <li>This API cannot be called before the kernel is initialized.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param queueID [IN] Queue ID created by LOS_QueueCreate. The value range is
|
||||
* [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
|
||||
* @param bufferAddr [OUT] Starting address that stores the obtained data. The starting address must not be
|
||||
* null.
|
||||
* @param bufferSize [IN/OUT] Where to maintain the buffer expected-size before read, and the real-size after read.
|
||||
*
|
||||
* @retval #LOS_OK The queue is successfully read.
|
||||
* @retval #LOS_ERRNO_QUEUE_INVALID The handle of the queue that is being read is invalid.
|
||||
* @retval #LOS_ERRNO_QUEUE_READ_PTR_NULL The pointer passed in during queue reading is null.
|
||||
* @retval #LOS_ERRNO_QUEUE_READSIZE_ISZERO The buffer size passed in during queue reading is 0.
|
||||
* @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue to be read is not created.
|
||||
* @retval #LOS_ERRNO_QUEUE_ISEMPTY No resource is in the queue that is being read when the time for
|
||||
* waiting to processing the queue expires.
|
||||
* @retval #LOS_ERRNO_QUEUE_READ_SIZE_TOO_SMALL The buffer size passed in during queue reading is less than
|
||||
* the queue size.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_QueueWriteCopy | LOS_QueueCreate
|
||||
*/
|
||||
STATIC INLINE UINT32 LOS_QueueReadCopyIsr(UINT32 queueID,
|
||||
VOID *bufferAddr,
|
||||
UINT32 *bufferSize)
|
||||
{
|
||||
return LOS_QueueReadCopy(queueID, bufferAddr, bufferSize, LOS_NO_WAIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_queue
|
||||
* @brief Write data into a queue.
|
||||
|
|
@ -578,47 +533,6 @@ extern UINT32 LOS_QueueWriteCopy(UINT32 queueID,
|
|||
UINT32 bufferSize,
|
||||
UINT32 timeOut);
|
||||
|
||||
/**
|
||||
* @ingroup los_queue
|
||||
* @brief Write data into a queue in interrupt service routine.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to write the data of the size specified by bufferSize and stored at the address specified by
|
||||
* bufferAddr into a queue.It is safe to use this API from within an interrupt service routine.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The specific queue should be created firstly.</li>
|
||||
* <li>This API write data into a queue in unblocking modes.</li>
|
||||
* <li>This API cannot be called before the kernel is initialized.</li>
|
||||
* <li>The data to be written is of the size specified by bufferSize and is stored at the address specified by
|
||||
* BufferAddr.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param queueID [IN] Queue ID created by LOS_QueueCreate. The value range is
|
||||
* [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
|
||||
* @param bufferAddr [IN] Starting address that stores the data to be written.The starting address must
|
||||
* not be null.
|
||||
* @param bufferSize [IN] Passed-in buffer size. The value range is [1,USHRT_MAX - sizeof(UINT32)].
|
||||
*
|
||||
* @retval #LOS_OK The data is successfully written into the queue.
|
||||
* @retval #LOS_ERRNO_QUEUE_INVALID The queue handle passed in during queue writing is invalid.
|
||||
* @retval #LOS_ERRNO_QUEUE_WRITE_PTR_NULL The pointer passed in during queue writing is null.
|
||||
* @retval #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO The buffer size passed in during queue writing is 0.
|
||||
* @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue into which the data is written is not created.
|
||||
* @retval #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG The buffer size passed in during queue writing is bigger than
|
||||
* the queue size.
|
||||
* @retval #LOS_ERRNO_QUEUE_ISFULL No free node is available during queue writing.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_QueueReadCopy | LOS_QueueCreate
|
||||
*/
|
||||
STATIC INLINE UINT32 LOS_QueueWriteCopyIsr(UINT32 queueID,
|
||||
VOID *bufferAddr,
|
||||
UINT32 bufferSize)
|
||||
{
|
||||
return LOS_QueueWriteCopy(queueID, bufferAddr, bufferSize, LOS_NO_WAIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_queue
|
||||
* @brief Read a queue.
|
||||
|
|
@ -668,50 +582,6 @@ extern UINT32 LOS_QueueRead(UINT32 queueID,
|
|||
UINT32 bufferSize,
|
||||
UINT32 timeOut);
|
||||
|
||||
/**
|
||||
* @ingroup los_queue
|
||||
* @brief Read a queue in interrupt service routine.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to read the address of data in a specified queue, and store it to the address specified by
|
||||
* bufferAddr.It is safe to use this API from within an interrupt service routine.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The specific queue should be created firstly.</li>
|
||||
* <li>Queue reading adopts the fist in first out (FIFO) mode. The data that is first stored in the queue is
|
||||
* read first.</li>
|
||||
* <li>This API read a queue in unblocking modes.</li>
|
||||
* <li>bufferAddr stores the obtained data address.</li>
|
||||
* <li>This API cannot be called before the kernel is initialized.</li>
|
||||
* <li>The bufferSize is not really used in LOS_QueueRead, because the interface is only used to
|
||||
* obtain the address of data.</li>
|
||||
* <li>The buffer which the bufferAddr pointing to must be greater than or equal to 4 bytes.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param queueID [IN] Queue ID created by LOS_QueueCreate. The value range is
|
||||
* [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
|
||||
* @param bufferAddr [OUT] Starting address that stores the obtained data. The starting address must
|
||||
* not be null.
|
||||
* @param bufferSize [IN] Passed-in buffer size, which must not be 0. The value range is [1,0xffffffff].
|
||||
*
|
||||
* @retval #LOS_OK The queue is successfully read.
|
||||
* @retval #LOS_ERRNO_QUEUE_INVALID The handle of the queue that is being read is invalid.
|
||||
* @retval #LOS_ERRNO_QUEUE_READ_PTR_NULL The pointer passed in during queue reading is null.
|
||||
* @retval #LOS_ERRNO_QUEUE_READSIZE_ISZERO The buffer size passed in during queue reading is 0.
|
||||
* @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue to be read is not created.
|
||||
* @retval #LOS_ERRNO_QUEUE_ISEMPTY No resource is in the queue that is being read when the time for
|
||||
* waiting to processing the queue expires.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_QueueWrite | LOS_QueueCreate
|
||||
*/
|
||||
STATIC INLINE UINT32 LOS_QueueReadIsr(UINT32 queueID,
|
||||
VOID *bufferAddr,
|
||||
UINT32 bufferSize)
|
||||
{
|
||||
return LOS_QueueRead(queueID, bufferAddr, bufferSize, LOS_NO_WAIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_queue
|
||||
* @brief Write data into a queue.
|
||||
|
|
@ -759,49 +629,6 @@ extern UINT32 LOS_QueueWrite(UINT32 queueID,
|
|||
UINT32 bufferSize,
|
||||
UINT32 timeOut);
|
||||
|
||||
/**
|
||||
* @ingroup los_queue
|
||||
* @brief Write data into a queue in interrupt service routine.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to write the address of data specified by bufferAddr into a queue.
|
||||
* It is safe to use this API from within an interrupt service routine.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The specific queue should be created firstly.</li>
|
||||
* <li>This API write data into a queue in unblocking modes.</li>
|
||||
* <li>This API cannot be called before the kernel is initialized.</li>
|
||||
* <li>The address of the data of the size specified by bufferSize and stored at the address specified by
|
||||
* BufferAddr is to be written.</li>
|
||||
* <li>The bufferSize is not really used in LOS_QueueWriteIsr, because the interface is only used to write the address
|
||||
* of data specified by bufferAddr into a queue.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param queueID [IN] Queue ID created by LOS_QueueCreate. The value range is
|
||||
* [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
|
||||
* @param bufferAddr [IN] Starting address that stores the data to be written. The starting address
|
||||
* must not be null.
|
||||
* @param bufferSize [IN] Passed-in buffer size, which must not be 0. The value range is [1,0xffffffff].
|
||||
*
|
||||
* @retval #LOS_OK The data is successfully written into the queue.
|
||||
* @retval #LOS_ERRNO_QUEUE_INVALID The queue handle passed in during queue writing is invalid.
|
||||
* @retval #LOS_ERRNO_QUEUE_WRITE_PTR_NULL The pointer passed in during queue writing is null.
|
||||
* @retval #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO The buffer size passed in during queue writing is 0.
|
||||
* @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue into which the data is written is not created.
|
||||
* @retval #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG The buffer size passed in during queue writing is bigger than
|
||||
* the queue size.
|
||||
* @retval #LOS_ERRNO_QUEUE_ISFULL No free node is available during queue writing.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_QueueRead | LOS_QueueCreate
|
||||
*/
|
||||
STATIC INLINE UINT32 LOS_QueueWriteIsr(UINT32 queueID,
|
||||
VOID *bufferAddr,
|
||||
UINT32 bufferSize)
|
||||
{
|
||||
return LOS_QueueWrite(queueID, bufferAddr, bufferSize, LOS_NO_WAIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_queue
|
||||
* @brief Write data into a queue header.
|
||||
|
|
@ -849,48 +676,6 @@ extern UINT32 LOS_QueueWriteHead(UINT32 queueID,
|
|||
UINT32 bufferSize,
|
||||
UINT32 timeOut);
|
||||
|
||||
/**
|
||||
* @ingroup los_queue
|
||||
* @brief Write data into a queue header in interrupt service routine.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to write the data of the size specified by bufferSize and stored at the address specified by
|
||||
* bufferAddr into a queue header.It is safe to use this API from within an interrupt service routine.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>This API cannot be called before the kernel is initialized.</li>
|
||||
* <li>This API write data into a queue header in unblocking modes.</li>
|
||||
* <li>The address of the data of the size specified by bufferSize and stored at the address specified by
|
||||
* BufferAddr is to be written.</li>
|
||||
* <li>LOS_QueueRead and LOS_QueueWriteHeadIsr are a set of interfaces, and the two groups of interfaces need to be used.
|
||||
* <li>
|
||||
* </ul>
|
||||
*
|
||||
* @param queueID [IN] Queue ID created by LOS_QueueCreate. The value range is
|
||||
* [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
|
||||
* @param bufferAddr [OUT] Starting address that stores the data to be written. The starting address
|
||||
* must not be null.
|
||||
* @param bufferSize [IN] Passed-in buffer size, which must not be 0. The value range is [1,0xffffffff].
|
||||
*
|
||||
* @retval #LOS_OK The data is successfully written into the queue.
|
||||
* @retval #LOS_ERRNO_QUEUE_INVALID The queue handle passed in during queue writing is invalid.
|
||||
* @retval #LOS_ERRNO_QUEUE_WRITE_PTR_NULL The pointer passed in during queue writing is null.
|
||||
* @retval #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO The buffer size passed in during queue writing is 0.
|
||||
* @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue into which the data is written is not created.
|
||||
* @retval #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG The buffer size passed in during queue writing is bigger than
|
||||
* the queue size.
|
||||
* @retval #LOS_ERRNO_QUEUE_ISFULL No free node is available during queue writing.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_QueueRead | LOS_QueueCreate
|
||||
*/
|
||||
STATIC INLINE UINT32 LOS_QueueWriteHeadIsr(UINT32 queueID,
|
||||
VOID *bufferAddr,
|
||||
UINT32 bufferSize)
|
||||
{
|
||||
return LOS_QueueWriteHead(queueID, bufferAddr, bufferSize, LOS_NO_WAIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_queue
|
||||
* @brief Write data into a queue header.
|
||||
|
|
@ -938,48 +723,6 @@ extern UINT32 LOS_QueueWriteHeadCopy(UINT32 queueID,
|
|||
UINT32 bufferSize,
|
||||
UINT32 timeOut);
|
||||
|
||||
/**
|
||||
* @ingroup los_queue
|
||||
* @brief Write data into a queue header in interrupt service routine.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to write the data of the size specified by bufferSize and stored at the address specified by
|
||||
* bufferAddr into a queue header.It is safe to use this API from within an interrupt service routine.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>This API cannot be called before the kernel is initialized.</li>
|
||||
* <li>This API write data into a queue header in unblocking modes.</li>
|
||||
* <li>The address of the data of the size specified by bufferSize and stored at the address specified by
|
||||
* BufferAddr is to be written.</li>
|
||||
* <li>LOS_QueueReadCopy and LOS_QueueWriteHeadCopyIsr are a set of interfaces, and the two groups of interfaces need to be
|
||||
* used.<li>
|
||||
* </ul>
|
||||
*
|
||||
* @param queueID [IN] Queue ID created by LOS_QueueCreate. The value range is
|
||||
* [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
|
||||
* @param bufferAddr [OUT] Starting address that stores the data to be written.
|
||||
* The starting address must not be null.
|
||||
* @param bufferSize [IN] Passed-in buffer size, which must not be 0. The value range is [1,0xffffffff].
|
||||
*
|
||||
* @retval #LOS_OK The data is successfully written into the queue.
|
||||
* @retval #LOS_ERRNO_QUEUE_INVALID The queue handle passed in during queue writing is invalid.
|
||||
* @retval #LOS_ERRNO_QUEUE_WRITE_PTR_NULL The pointer passed in during queue writing is null.
|
||||
* @retval #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO The buffer size passed in during queue writing is 0.
|
||||
* @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue into which the data is written is not created.
|
||||
* @retval #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG The buffer size passed in during queue writing is bigger than
|
||||
* the queue size.
|
||||
* @retval #LOS_ERRNO_QUEUE_ISFULL No free node is available during queue writing.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_QueueWrite | LOS_QueueWriteHeadIsr
|
||||
*/
|
||||
STATIC INLINE UINT32 LOS_QueueWriteHeadCopyIsr(UINT32 queueID,
|
||||
VOID *bufferAddr,
|
||||
UINT32 bufferSize)
|
||||
{
|
||||
return LOS_QueueWriteHeadCopy(queueID, bufferAddr, bufferSize, LOS_NO_WAIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_queue
|
||||
* @brief Delete a queue.
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include "los_interrupt.h"
|
||||
#include "los_membox.h"
|
||||
#include "los_memory.h"
|
||||
#include "los_task.h"
|
||||
#include "los_sched.h"
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -164,22 +164,6 @@ static_library("test_queue") {
|
|||
"It_los_queue_head_040.c",
|
||||
"It_los_queue_head_041.c",
|
||||
"It_los_queue_head_042.c",
|
||||
"It_los_queue_isr_001.c",
|
||||
"It_los_queue_isr_002.c",
|
||||
"It_los_queue_isr_003.c",
|
||||
"It_los_queue_isr_004.c",
|
||||
"It_los_queue_isr_005.c",
|
||||
"It_los_queue_isr_006.c",
|
||||
"It_los_queue_isr_007.c",
|
||||
"It_los_queue_isr_008.c",
|
||||
"It_los_queue_isr_009.c",
|
||||
"It_los_queue_isr_010.c",
|
||||
"It_los_queue_isr_011.c",
|
||||
"It_los_queue_isr_012.c",
|
||||
"It_los_queue_isr_013.c",
|
||||
"It_los_queue_isr_014.c",
|
||||
"It_los_queue_isr_015.c",
|
||||
"It_los_queue_isr_016.c",
|
||||
"It_los_queue_static_001.c",
|
||||
"It_los_queue_static_002.c",
|
||||
"It_los_queue_static_003.c",
|
||||
|
|
|
|||
|
|
@ -151,22 +151,7 @@ VOID ItSuiteLosQueue(VOID)
|
|||
ItLosQueueHead040();
|
||||
ItLosQueueHead041();
|
||||
ItLosQueueHead042();
|
||||
ItLosQueueIsr001();
|
||||
ItLosQueueIsr002();
|
||||
ItLosQueueIsr003();
|
||||
ItLosQueueIsr004();
|
||||
ItLosQueueIsr005();
|
||||
ItLosQueueIsr006();
|
||||
ItLosQueueIsr007();
|
||||
ItLosQueueIsr008();
|
||||
ItLosQueueIsr009();
|
||||
ItLosQueueIsr010();
|
||||
ItLosQueueIsr011();
|
||||
ItLosQueueIsr012();
|
||||
ItLosQueueIsr013();
|
||||
ItLosQueueIsr014();
|
||||
ItLosQueueIsr015();
|
||||
ItLosQueueIsr016();
|
||||
|
||||
#if (LOS_KERNEL_TEST_FULL == 1)
|
||||
#if (LOS_KERNEL_HWI_TEST == 1)
|
||||
ItLosQueue044();
|
||||
|
|
|
|||
|
|
@ -183,22 +183,7 @@ extern VOID ItLosQueueHead039(VOID);
|
|||
extern VOID ItLosQueueHead040(VOID);
|
||||
extern VOID ItLosQueueHead041(VOID);
|
||||
extern VOID ItLosQueueHead042(VOID);
|
||||
extern VOID ItLosQueueIsr001(VOID);
|
||||
extern VOID ItLosQueueIsr002(VOID);
|
||||
extern VOID ItLosQueueIsr003(VOID);
|
||||
extern VOID ItLosQueueIsr004(VOID);
|
||||
extern VOID ItLosQueueIsr005(VOID);
|
||||
extern VOID ItLosQueueIsr006(VOID);
|
||||
extern VOID ItLosQueueIsr007(VOID);
|
||||
extern VOID ItLosQueueIsr008(VOID);
|
||||
extern VOID ItLosQueueIsr009(VOID);
|
||||
extern VOID ItLosQueueIsr010(VOID);
|
||||
extern VOID ItLosQueueIsr011(VOID);
|
||||
extern VOID ItLosQueueIsr012(VOID);
|
||||
extern VOID ItLosQueueIsr013(VOID);
|
||||
extern VOID ItLosQueueIsr014(VOID);
|
||||
extern VOID ItLosQueueIsr015(VOID);
|
||||
extern VOID ItLosQueueIsr016(VOID);
|
||||
|
||||
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||
extern VOID ItLosQueueStatic001(VOID);
|
||||
extern VOID ItLosQueueStatic002(VOID);
|
||||
|
|
|
|||
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
|
||||
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
CHAR *buff2 = NULL;
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosQueueIsr001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr001", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
|
||||
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret);
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
CHAR *buff2 = NULL;
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_PARA_ISZERO, ret, EXIT);
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosQueueIsr002(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr002", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
|
||||
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, 0);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG, ret);
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
CHAR *buff2 = NULL;
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, 1);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff2, 1, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosQueueIsr003(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr003", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, 0);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
CHAR *buff2 = NULL;
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, 4);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff2, 1, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosQueueIsr004(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr004", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
|
||||
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
CHAR *buff2 = NULL;
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosQueueIsr005(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr005", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
CHAR buff1[QUEUE_BASE_MSGSIZE] = "UniDSP";
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
CHAR *buff2 = NULL;
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
|
||||
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff2 + index), buff1[index],
|
||||
*((CHAR *)(intptr_t)buff2 + index), EXIT);
|
||||
}
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
VOID ItLosQueueIsr006(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr006", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
|
||||
ret = LOS_QueueWriteIsr((UINT32)-1, &buff1, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_INVALID, ret);
|
||||
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
CHAR *buff2 = NULL;
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosQueueIsr007(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr007", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
|
||||
ret = LOS_QueueWriteIsr(OS_ALL_IPC_QUEUE_LIMIT + 1, &buff1, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_INVALID, ret);
|
||||
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
CHAR *buff2 = NULL;
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosQueueIsr008(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr008", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR *buff2 = NULL;
|
||||
|
||||
ret = LOS_QueueReadIsr(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_QueueWrite(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosQueueIsr009(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr009", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR *buff2 = NULL;
|
||||
|
||||
ret = LOS_QueueReadIsr(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret);
|
||||
}
|
||||
|
||||
static VOID HwiF02(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR *buff2 = NULL;
|
||||
|
||||
ret = LOS_QueueReadIsr(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST0, hwiPrio, mode, (HWI_PROC_FUNC)HwiF02, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
ret = LOS_QueueWrite(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST0);
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
TestHwiDelete(HWI_NUM_TEST0);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosQueueIsr010(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr010", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
static CHAR g_buff[QUEUE_BASE_MSGSIZE] = "UniDSP";
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR *buff2 = NULL;
|
||||
|
||||
ret = LOS_QueueReadIsr(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
|
||||
ICUNIT_ASSERT_EQUAL_VOID(*((CHAR *)(intptr_t)buff2 + index), g_buff[index],
|
||||
*((CHAR *)(intptr_t)buff2 + index));
|
||||
}
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_QueueWrite(g_testQueueID01, &g_buff, QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosQueueIsr011(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr011", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
|
||||
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
}
|
||||
|
||||
static VOID TaskF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR *buff2 = NULL;
|
||||
|
||||
g_testCount++;
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE,LOS_WAIT_FOREVER);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
g_testCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk001A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 1;
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount);
|
||||
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosQueueIsr012(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr012", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
|
||||
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
}
|
||||
|
||||
static VOID TaskF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR *buff2 = NULL;
|
||||
|
||||
g_testCount++;
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE,LOS_WAIT_FOREVER);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
g_testCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk001A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST + 1;
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
LOS_TaskDelay(1);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
|
||||
LOS_TaskDelay(1);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount);
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosQueueIsr013(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr013", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
|
||||
ret = LOS_QueueWriteCopyIsr(g_testQueueID01, buff1, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
}
|
||||
|
||||
static VOID TaskF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 msgSize = (UINT32)QUEUE_BASE_MSGSIZE;
|
||||
CHAR buff[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
CHAR buff2[QUEUE_SHORT_BUFFER_LENGTH] = " ";
|
||||
|
||||
ret = LOS_QueueReadCopy(g_testQueueID01, buff2, &msgSize, LOS_WAIT_FOREVER);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
|
||||
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff2 + index), buff[index],
|
||||
*((CHAR *)(intptr_t)buff2 + index), EXIT);
|
||||
}
|
||||
|
||||
EXIT:
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk001A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 1;
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosQueueIsr014(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr014", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
static CHAR g_buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
static CHAR g_buff2[QUEUE_SHORT_BUFFER_LENGTH] = "DOPRA";
|
||||
static CHAR g_buff3[QUEUE_SHORT_BUFFER_LENGTH] = "TEST";
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
ret = LOS_QueueWriteHeadIsr(g_testQueueID01, &g_buff1, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_QueueWriteHeadIsr(g_testQueueID01, &g_buff2, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_QueueWriteHeadIsr(g_testQueueID01, &g_buff3, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
}
|
||||
|
||||
static VOID TaskF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR buffA[QUEUE_SHORT_BUFFER_LENGTH] = "TEST";
|
||||
CHAR buffB[QUEUE_SHORT_BUFFER_LENGTH] = "DOPRA";
|
||||
CHAR buffC[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
CHAR *buff = NULL;
|
||||
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff, QUEUE_BASE_MSGSIZE, LOS_WAIT_FOREVER);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
|
||||
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff + index), buffA[index],
|
||||
*((CHAR *)(intptr_t)buff + index), EXIT);
|
||||
}
|
||||
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff, QUEUE_BASE_MSGSIZE, LOS_WAIT_FOREVER);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
|
||||
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff + index), buffB[index],
|
||||
*((CHAR *)(intptr_t)buff + index), EXIT);
|
||||
}
|
||||
|
||||
ret = LOS_QueueRead(g_testQueueID01, &buff, QUEUE_BASE_MSGSIZE, LOS_WAIT_FOREVER);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
|
||||
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff + index), buffC[index],
|
||||
*((CHAR *)(intptr_t)buff + index), EXIT);
|
||||
}
|
||||
|
||||
EXIT:
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk001A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 1;
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosQueueIsr015(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr015", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
/*
|
||||
* 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_queue.h"
|
||||
|
||||
|
||||
static VOID HwiF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
CHAR buff2[QUEUE_SHORT_BUFFER_LENGTH] = "DOPRA";
|
||||
CHAR buff3[QUEUE_SHORT_BUFFER_LENGTH] = "TEST";
|
||||
|
||||
ret = LOS_QueueWriteHeadCopyIsr(g_testQueueID01, buff1, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_QueueWriteHeadCopyIsr(g_testQueueID01, buff2, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_QueueWriteHeadCopyIsr(g_testQueueID01, buff3, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
}
|
||||
|
||||
static VOID TaskF01(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 msgSize = (UINT32)QUEUE_BASE_MSGSIZE;
|
||||
CHAR buffA[QUEUE_SHORT_BUFFER_LENGTH] = "TEST";
|
||||
CHAR buffB[QUEUE_SHORT_BUFFER_LENGTH] = "DOPRA";
|
||||
CHAR buffC[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
CHAR buff[QUEUE_SHORT_BUFFER_LENGTH] = " ";
|
||||
|
||||
ret = LOS_QueueReadCopy(g_testQueueID01, buff, &msgSize, LOS_WAIT_FOREVER);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
|
||||
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff + index), buffA[index],
|
||||
*((CHAR *)(intptr_t)buff + index), EXIT);
|
||||
}
|
||||
|
||||
ret = LOS_QueueReadCopy(g_testQueueID01, buff, &msgSize, LOS_WAIT_FOREVER);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
|
||||
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff + index), buffB[index],
|
||||
*((CHAR *)(intptr_t)buff + index), EXIT);
|
||||
}
|
||||
|
||||
ret = LOS_QueueReadCopy(g_testQueueID01, buff, &msgSize, LOS_WAIT_FOREVER);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
|
||||
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff + index), buffC[index],
|
||||
*((CHAR *)(intptr_t)buff + index), EXIT);
|
||||
}
|
||||
|
||||
EXIT:
|
||||
return;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
HWI_PRIOR_T hwiPrio = 3;
|
||||
HWI_MODE_T mode = 0;
|
||||
HwiIrqParam irqParam;
|
||||
|
||||
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
|
||||
irqParam.pDevId = 0;
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
|
||||
task1.uwStackSize = TASK_STACK_SIZE_TEST;
|
||||
task1.pcName = "Tsk001A";
|
||||
task1.usTaskPrio = TASK_PRIO_TEST - 1;
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
g_testCount = 0;
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
TestHwiTrigger(HWI_NUM_TEST);
|
||||
|
||||
EXIT:
|
||||
TestHwiDelete(HWI_NUM_TEST);
|
||||
ret = LOS_QueueDelete(g_testQueueID01);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID ItLosQueueIsr016(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItLosQueueIsr016", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
|
||||
}
|
||||
|
||||
|
|
@ -85,7 +85,7 @@
|
|||
#define ICUNIT_GOTO_WITHIN_EQUAL(param, value1, value2, retcode, label) \
|
||||
do { \
|
||||
if ((param) < (value1) || (param) > (value2)) { \
|
||||
ICunitSaveErr(__LINE__, (iiUINT32)(retcode)); \
|
||||
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
|
||||
goto label; \
|
||||
} \
|
||||
} while (0)
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ static VOID *PthreadF01(VOID *argument)
|
|||
|
||||
g_testCount = 2; // 2, Init test count value.
|
||||
|
||||
EXIT1:
|
||||
EXIT1:
|
||||
return NULL;
|
||||
EXIT2:
|
||||
g_testCount = 0;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ static UINT32 Testcase(VOID)
|
|||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = mq_close(mqdes);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
|
|
|||
|
|
@ -135,8 +135,8 @@ static char *TmToStr(const struct tm *timePtr, char *timeStr, unsigned len)
|
|||
if (timePtr == NULL || timeStr == NULL) {
|
||||
return "";
|
||||
}
|
||||
(VOID)sprintf_s(timeStr, len, "%ld/%d/%d %02d:%02d:%02d WEEK(%d)", timePtr->tm_year + TM_BASE_YEAR,
|
||||
timePtr->tm_mon + 1, timePtr->tm_mday, timePtr->tm_hour, timePtr->tm_min, timePtr->tm_sec, timePtr->tm_wday);
|
||||
sprintf_s(timeStr, len, "%ld/%d/%d %02d:%02d:%02d WEEK(%d)", timePtr->tm_year + TM_BASE_YEAR, timePtr->tm_mon + 1,
|
||||
timePtr->tm_mday, timePtr->tm_hour, timePtr->tm_min, timePtr->tm_sec, timePtr->tm_wday);
|
||||
return timeStr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,16 +31,9 @@ import("//kernel/liteos_m/liteos.gni")
|
|||
static_library("xts_test") {
|
||||
sources = [ "xts_test.c" ]
|
||||
deps = [
|
||||
"cmsis:cmsis_test",
|
||||
"io:io_test",
|
||||
"ipc:ipc_test",
|
||||
"math:math_test",
|
||||
"mem:mem_test",
|
||||
"net:net_test",
|
||||
"process:pthread_test",
|
||||
"sched:sched_test",
|
||||
"sys:system_test",
|
||||
"time:time_test",
|
||||
]
|
||||
configs += [ "$LITEOSTOPDIR/testsuites:include" ]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,48 +0,0 @@
|
|||
# Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_m/liteos.gni")
|
||||
|
||||
static_library("cmsis_test") {
|
||||
sources = [
|
||||
"cmsis_event_func_test.c",
|
||||
"cmsis_msg_func_test.c",
|
||||
"cmsis_mutex_func_test.c",
|
||||
"cmsis_sem_func_test.c",
|
||||
"cmsis_task_func_test.c",
|
||||
"cmsis_task_pri_func_test.c",
|
||||
"cmsis_timer_func_test.c",
|
||||
"xts_cmsis.c",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
".",
|
||||
"$LITEOSTOPDIR/testsuites/include",
|
||||
"$LITEOSTOPDIR/testsuites/unittest/xts",
|
||||
]
|
||||
}
|
||||
|
|
@ -1,364 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "xts_cmsis.h"
|
||||
|
||||
osEventFlagsId_t g_eventId;
|
||||
UINT16 g_cmsisTestEventCount;
|
||||
|
||||
LITE_TEST_SUIT(Cmsis, Cmsisevent, CmsisEventFuncTestSuite);
|
||||
|
||||
static BOOL CmsisEventFuncTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL CmsisEventFuncTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void CmsisEventFlagsWaitFunc001(void const *argument)
|
||||
{
|
||||
(void)argument;
|
||||
g_cmsisTestEventCount++;
|
||||
UINT32 ret = osEventFlagsWait(g_eventId, EVENT_MASK_HEX_11, (osFlagsWaitAll | osFlagsNoClear), osWaitForever);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, EVENT_MASK_HEX_11, ret);
|
||||
g_cmsisTestEventCount++;
|
||||
osThreadExit();
|
||||
}
|
||||
|
||||
static void CmsisEventFlagsSetFunc002(void const *argument)
|
||||
{
|
||||
(void)argument;
|
||||
UINT32 ret;
|
||||
g_cmsisTestEventCount++;
|
||||
ret = osEventFlagsWait(g_eventId, EVENT_MASK_HEX_11, (osFlagsWaitAll | osFlagsNoClear), TIMEOUT_NUM_3);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, osErrorTimeout, ret);
|
||||
g_cmsisTestEventCount++;
|
||||
|
||||
ret = osEventFlagsWait(g_eventId, EVENT_MASK_HEX_4, (osFlagsWaitAll | osFlagsNoClear), osWaitForever);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, TESTCOUNT_NUM_4, ret);
|
||||
g_cmsisTestEventCount++;
|
||||
osThreadExit();
|
||||
}
|
||||
|
||||
static void CmsisEventFlagsClearFunc001(void const *argument)
|
||||
{
|
||||
(void)argument;
|
||||
g_cmsisTestEventCount++;
|
||||
UINT32 ret = osEventFlagsWait(g_eventId, EVENT_MASK_HEX_1, osFlagsWaitAll, osWaitForever);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, EVENT_MASK_HEX_1, ret);
|
||||
g_cmsisTestEventCount++;
|
||||
osThreadExit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0100
|
||||
* @tc.name : event operation for creat
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsNew001, Function | MediumTest | Level1)
|
||||
{
|
||||
g_eventId = osEventFlagsNew(NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_eventId, NULL, g_eventId);
|
||||
(void)osEventFlagsDelete(g_eventId);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0200
|
||||
* @tc.name : event operation for delete
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsDelete001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 ret;
|
||||
g_eventId = osEventFlagsNew(NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_eventId, NULL, g_eventId);
|
||||
ret = osEventFlagsDelete(g_eventId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0300
|
||||
* @tc.name : event delete operation with EventFlagsId = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsDelete002, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 ret = osEventFlagsDelete(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0400
|
||||
* @tc.name : event operation for flags set
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsSet001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 ret;
|
||||
g_eventId = osEventFlagsNew(NULL);
|
||||
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_10);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EVENT_MASK_HEX_10, ret);
|
||||
ret = osEventFlagsDelete(g_eventId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0500
|
||||
* @tc.name : event reliability test for flags set
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsSet002, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 ret;
|
||||
osThreadId_t id;
|
||||
osStatus_t status;
|
||||
osThreadAttr_t attr;
|
||||
attr.name = "test";
|
||||
attr.attr_bits = 0U;
|
||||
attr.cb_mem = NULL;
|
||||
attr.cb_size = 0U;
|
||||
attr.stack_mem = NULL;
|
||||
attr.stack_size = TEST_TASK_STACK_SIZE;
|
||||
attr.priority = osPriorityAboveNormal;
|
||||
|
||||
g_cmsisTestEventCount = 0;
|
||||
g_eventId = osEventFlagsNew(NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_eventId, NULL, g_eventId);
|
||||
id = osThreadNew((osThreadFunc_t)CmsisEventFlagsSetFunc002, NULL, &attr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, EVENT_MASK_HEX_1, g_cmsisTestEventCount);
|
||||
g_cmsisTestEventCount++;
|
||||
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_2);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, TESTCOUNT_NUM_3, g_cmsisTestEventCount);
|
||||
|
||||
g_cmsisTestEventCount++;
|
||||
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_11);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, TESTCOUNT_NUM_4, g_cmsisTestEventCount);
|
||||
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_4);
|
||||
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, TESTCOUNT_NUM_5, g_cmsisTestEventCount);
|
||||
ret = osEventFlagsDelete(g_eventId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0600
|
||||
* @tc.name : event flags set operation with EventFlagsId = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsSet003, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 ret = osEventFlagsSet(NULL, EVENT_MASK_HEX_10);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osFlagsErrorParameter, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0700
|
||||
* @tc.name : event operation for wait
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsWait001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 ret;
|
||||
osThreadId_t id;
|
||||
osThreadAttr_t attr;
|
||||
attr.name = "test";
|
||||
attr.attr_bits = 0U;
|
||||
attr.cb_mem = NULL;
|
||||
attr.cb_size = 0U;
|
||||
attr.stack_mem = NULL;
|
||||
attr.stack_size = TEST_TASK_STACK_SIZE;
|
||||
attr.priority = osPriorityAboveNormal;
|
||||
|
||||
g_cmsisTestEventCount = 0;
|
||||
g_eventId = osEventFlagsNew(NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_eventId, NULL, g_eventId);
|
||||
id = osThreadNew((osThreadFunc_t)CmsisEventFlagsWaitFunc001, NULL, &attr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_10);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EVENT_MASK_HEX_10, ret);
|
||||
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, EVENT_MASK_HEX_1, g_cmsisTestEventCount);
|
||||
|
||||
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EVENT_MASK_HEX_11, ret);
|
||||
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, TESTCOUNT_NUM_2, g_cmsisTestEventCount);
|
||||
|
||||
ret = osEventFlagsDelete(g_eventId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0800
|
||||
* @tc.name : event operation for invalid option
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsWait002, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 ret;
|
||||
g_eventId = osEventFlagsNew(NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_eventId, NULL, g_eventId);
|
||||
|
||||
ret = osEventFlagsWait(g_eventId, EVENT_MASK_HEX_11, INVALID_FLAG_OPTION, osWaitForever);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osFlagsErrorParameter, ret);
|
||||
|
||||
ret = osEventFlagsDelete(g_eventId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_0900
|
||||
* @tc.name : event wait operation with EventFlagsId = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsWait003, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 ret = osEventFlagsWait(NULL, EVENT_MASK_HEX_11, (osFlagsWaitAll | osFlagsNoClear), osWaitForever);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osFlagsErrorParameter, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_1000
|
||||
* @tc.name : event operation for flags get
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsGet001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 ret;
|
||||
g_eventId = osEventFlagsNew(NULL);
|
||||
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_10);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EVENT_MASK_HEX_10, ret);
|
||||
ret = osEventFlagsGet(g_eventId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EVENT_MASK_HEX_10, ret);
|
||||
|
||||
ret = osEventFlagsDelete(g_eventId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_1100
|
||||
* @tc.name : event flags get operation with EventFlagsId = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsGet002, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 ret = osEventFlagsGet(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_1200
|
||||
* @tc.name : event operation for flags clear
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsClear001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 ret;
|
||||
osThreadId_t id;
|
||||
|
||||
osThreadAttr_t attr;
|
||||
attr.name = "test";
|
||||
attr.attr_bits = 0U;
|
||||
attr.cb_mem = NULL;
|
||||
attr.cb_size = 0U;
|
||||
attr.stack_mem = NULL;
|
||||
attr.stack_size = TEST_TASK_STACK_SIZE;
|
||||
attr.priority = osPriorityAboveNormal;
|
||||
|
||||
g_cmsisTestEventCount = 0;
|
||||
g_eventId = osEventFlagsNew(NULL);
|
||||
id = osThreadNew((osThreadFunc_t)CmsisEventFlagsClearFunc001, NULL, &attr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_10);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EVENT_MASK_HEX_10, ret);
|
||||
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, EVENT_MASK_HEX_1, g_cmsisTestEventCount);
|
||||
|
||||
ret = osEventFlagsClear(g_eventId, 0xffff);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EVENT_MASK_HEX_10, ret);
|
||||
ret = osEventFlagsGet(g_eventId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = osEventFlagsSet(g_eventId, EVENT_MASK_HEX_1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(g_cmsisTestEventCount, TESTCOUNT_NUM_2, g_cmsisTestEventCount);
|
||||
ret = osEventFlagsDelete(g_eventId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_EVENT_OPERATION_1300
|
||||
* @tc.name : event flags clear operation with EventFlagsId = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisEventFuncTestSuite, testOsEventFlagsClear002, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 ret = osEventFlagsClear(NULL, 0xffff);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osFlagsErrorParameter, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
RUN_TEST_SUITE(CmsisEventFuncTestSuite);
|
||||
|
||||
void CmsisEventFuncTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testOsEventFlagsNew001);
|
||||
RUN_ONE_TESTCASE(testOsEventFlagsDelete001);
|
||||
RUN_ONE_TESTCASE(testOsEventFlagsDelete002);
|
||||
RUN_ONE_TESTCASE(testOsEventFlagsSet001);
|
||||
RUN_ONE_TESTCASE(testOsEventFlagsSet002);
|
||||
RUN_ONE_TESTCASE(testOsEventFlagsSet003);
|
||||
RUN_ONE_TESTCASE(testOsEventFlagsWait001);
|
||||
RUN_ONE_TESTCASE(testOsEventFlagsWait002);
|
||||
RUN_ONE_TESTCASE(testOsEventFlagsWait003);
|
||||
RUN_ONE_TESTCASE(testOsEventFlagsGet001);
|
||||
RUN_ONE_TESTCASE(testOsEventFlagsGet002);
|
||||
RUN_ONE_TESTCASE(testOsEventFlagsClear001);
|
||||
RUN_ONE_TESTCASE(testOsEventFlagsClear002);
|
||||
}
|
||||
|
|
@ -1,419 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "xts_cmsis.h"
|
||||
|
||||
osMessageQueueId_t g_cmsisMqId;
|
||||
static char *g_cmsisMessageInfo[] = {"msg1", "msg2", "msg3", "msg4", "msg5", "msg6", "msg7", "msg8"};
|
||||
|
||||
LITE_TEST_SUIT(Cmsis, Cmsismsg, CmsisMsgFuncTestSuite);
|
||||
|
||||
static BOOL CmsisMsgFuncTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL CmsisMsgFuncTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void CmsisMessageQueueGetFunc001(void const *argument)
|
||||
{
|
||||
(void)argument;
|
||||
osStatus_t uwRet;
|
||||
UINT8 msgPrio = 0;
|
||||
CHAR ucTemp[MSGINFO_LEN] = "";
|
||||
UINT32 uwCmp;
|
||||
uwRet = osMessageQueueGet(g_cmsisMqId, ucTemp, &msgPrio, TIMEOUT_COUNT);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
uwCmp = memcmp(ucTemp, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_0], MSGINFO_LEN);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwCmp);
|
||||
|
||||
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
osThreadExit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0100
|
||||
* @tc.name : message queue operation for creat
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueNew001, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t status;
|
||||
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||
(void)osMessageQueueDelete(g_cmsisMqId);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0200
|
||||
* @tc.name : message queue operation for creat when msg_count = 0
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueNew002, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t status;
|
||||
g_cmsisMqId = osMessageQueueNew(0, MSG_SIZE, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0300
|
||||
* @tc.name : message queue operation for creat when msg_size = 0
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueNew003, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t status;
|
||||
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, 0, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0400
|
||||
* @tc.name : message queue operation for delete
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueDelete001, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t uwRet;
|
||||
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0500
|
||||
* @tc.name : message queue delete operation with mq_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueDelete002, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t uwRet = osMessageQueueDelete(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0600
|
||||
* @tc.name : message queue operation for put
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueuePut001, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t uwRet;
|
||||
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||
|
||||
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_0], 0, 0);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
|
||||
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0700
|
||||
* @tc.name : message queue put operation with mq_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueuePut002, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t uwRet = osMessageQueuePut(NULL, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_0], 0, 0);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0800
|
||||
* @tc.name : message queue operation for put when msg_ptr = 0
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueuePut003, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t uwRet;
|
||||
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||
|
||||
uwRet = osMessageQueuePut(g_cmsisMqId, NULL, 0, 0);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
|
||||
|
||||
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_0900
|
||||
* @tc.name : message queue operation for get
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGet001, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t uwRet;
|
||||
UINT32 uId;
|
||||
osThreadId_t id;
|
||||
osThreadAttr_t attr;
|
||||
attr.name = "test";
|
||||
attr.attr_bits = 0U;
|
||||
attr.cb_mem = NULL;
|
||||
attr.cb_size = 0U;
|
||||
attr.stack_mem = NULL;
|
||||
attr.stack_size = TEST_TASK_STACK_SIZE;
|
||||
attr.priority = osPriorityAboveNormal;
|
||||
uId = osKernelLock();
|
||||
ICUNIT_ASSERT_EQUAL(uId, 0, uId); /* 1, common data for test, no special meaning */
|
||||
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||
|
||||
id = osThreadNew((osThreadFunc_t)CmsisMessageQueueGetFunc001, NULL, &attr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_0], 0, 0);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
uId = osKernelUnlock();
|
||||
ICUNIT_ASSERT_EQUAL(uId, 1, uId); /* 1, common data for test, no special meaning */
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1000
|
||||
* @tc.name : message queue get operation with mq_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGet002, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t uwRet;
|
||||
UINT8 msgPrio = 0;
|
||||
CHAR ucTemp[MSGINFO_LEN] = "";
|
||||
uwRet = osMessageQueueGet(NULL, ucTemp, &msgPrio, TIMEOUT_COUNT);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1100
|
||||
* @tc.name : message queue operation for get when msg_ptr = 0
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGet003, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t uwRet;
|
||||
UINT8 msgPrio = 0;
|
||||
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||
|
||||
uwRet = osMessageQueueGet(g_cmsisMqId, NULL, &msgPrio, TIMEOUT_COUNT);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osErrorParameter, uwRet);
|
||||
|
||||
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1200
|
||||
* @tc.name : message queue operation for get msg size
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetMsgSize001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||
|
||||
uwRet = osMessageQueueGetMsgSize(g_cmsisMqId);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, MSG_SIZE, uwRet);
|
||||
|
||||
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1300
|
||||
* @tc.name : message queue get msg size with mq_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetMsgSize002, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet = osMessageQueueGetMsgSize(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1400
|
||||
* @tc.name : message queue operation for get capacity
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetCapacity001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||
uwRet = osMessageQueueGetCapacity(g_cmsisMqId);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, MSGQUEUE_COUNT, uwRet);
|
||||
|
||||
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1500
|
||||
* @tc.name : message queue get capacity with mq_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetCapacity002, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet = osMessageQueueGetCapacity(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1600
|
||||
* @tc.name : message queue operation for get count
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetCount001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||
|
||||
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_0], 0, 0);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
|
||||
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_1], 0, 0);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
|
||||
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_2], 0, 0);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
|
||||
uwRet = osMessageQueueGetCount(g_cmsisMqId);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, MSGQUEUE_PUT_COUNT, uwRet);
|
||||
|
||||
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1700
|
||||
* @tc.name : message queue get count with mq_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetCount002, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet = osMessageQueueGetCount(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1800
|
||||
* @tc.name : message queue operation for get space
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetSpace001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
g_cmsisMqId = osMessageQueueNew(MSGQUEUE_COUNT, MSG_SIZE, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisMqId, NULL, g_cmsisMqId);
|
||||
|
||||
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_0], 0, 0);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
|
||||
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_1], 0, 0);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
|
||||
uwRet = osMessageQueuePut(g_cmsisMqId, g_cmsisMessageInfo[MSGQUEUE_COUNT_INDEX_2], 0, 0);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
|
||||
uwRet = osMessageQueueGetSpace(g_cmsisMqId);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, MSGQUEUE_SPACE_COUNT, uwRet);
|
||||
|
||||
uwRet = osMessageQueueDelete(g_cmsisMqId);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MSG_OPERATION_1900
|
||||
* @tc.name : message queue get space with mq_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMsgFuncTestSuite, testOsMessageQueueGetSpace002, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet = osMessageQueueGetSpace(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
RUN_TEST_SUITE(CmsisMsgFuncTestSuite);
|
||||
|
||||
void CmsisMsgFuncTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueNew001);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueNew002);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueNew003);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueDelete001);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueDelete002);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueuePut001);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueuePut002);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueuePut003);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueGet001);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueGet002);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueGet003);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueGetMsgSize001);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueGetMsgSize002);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueGetCapacity001);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueGetCapacity002);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueGetCount001);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueGetCount002);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueGetSpace001);
|
||||
RUN_ONE_TESTCASE(testOsMessageQueueGetSpace002);
|
||||
}
|
||||
|
|
@ -1,296 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "xts_cmsis.h"
|
||||
|
||||
UINT16 g_cmsisTestMutexCount;
|
||||
osMutexId_t g_cmsisOsMutexId;
|
||||
osMutexAttr_t g_cmsisMutexAttr;
|
||||
|
||||
LITE_TEST_SUIT(Cmsis, Cmsismutex, CmsisMutexFuncTestSuite);
|
||||
|
||||
static BOOL CmsisMutexFuncTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL CmsisMutexFuncTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void CmsisMutexGetOwnerFunc001(void const *argument)
|
||||
{
|
||||
(void)argument;
|
||||
osStatus_t ret;
|
||||
osThreadId_t id1;
|
||||
osThreadId_t id2;
|
||||
osThreadAttr_t attr;
|
||||
g_cmsisOsMutexId = osMutexNew(&g_cmsisMutexAttr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||
|
||||
ret = osMutexAcquire(g_cmsisOsMutexId, LOS_WAIT_FOREVER);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
id1 = osMutexGetOwner(g_cmsisOsMutexId);
|
||||
id2 = osThreadGetId();
|
||||
ICUNIT_ASSERT_STRING_EQUAL(id1, id2, id1);
|
||||
|
||||
attr.name = osThreadGetName(id1);
|
||||
ICUNIT_ASSERT_STRING_EQUAL("testMutexGetOwner001", attr.name, attr.name);
|
||||
|
||||
ret = osMutexRelease(g_cmsisOsMutexId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
osThreadExit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0100
|
||||
* @tc.name : mutex operation for creat with NULL para
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexNew001, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t status;
|
||||
g_cmsisOsMutexId = osMutexNew(NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||
(void)osMutexDelete(g_cmsisOsMutexId);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0200
|
||||
* @tc.name : mutex operation for creat
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexNew002, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t status;
|
||||
g_cmsisOsMutexId = osMutexNew(&g_cmsisMutexAttr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||
(void)osMutexDelete(g_cmsisOsMutexId);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0300
|
||||
* @tc.name : mutex operation for delete after creat mutex with NULL parameter
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexDelete001, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret;
|
||||
g_cmsisOsMutexId = osMutexNew(NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0400
|
||||
* @tc.name : mutex operation for delete
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexDelete002, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret;
|
||||
g_cmsisOsMutexId = osMutexNew(&g_cmsisMutexAttr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0500
|
||||
* @tc.name : mutex operation for delete after mutex acquire and release
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexDelete003, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret;
|
||||
g_cmsisOsMutexId = osMutexNew(NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||
|
||||
osMutexAcquire(g_cmsisOsMutexId, LOS_WAIT_FOREVER);
|
||||
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
|
||||
|
||||
(void)osMutexRelease(g_cmsisOsMutexId);
|
||||
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0600
|
||||
* @tc.name : mutex delete operation with mutex_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexDelete004, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret = osMutexDelete(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0700
|
||||
* @tc.name : mutex acquire operation with mutex_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexAcquire001, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret = osMutexAcquire(NULL, LOS_WAIT_FOREVER);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0800
|
||||
* @tc.name : mutex operation for acquire
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexAcquire002, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret;
|
||||
g_cmsisOsMutexId = osMutexNew(&g_cmsisMutexAttr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||
|
||||
ret = osMutexAcquire(g_cmsisOsMutexId, LOS_WAIT_FOREVER);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
(void)osMutexRelease(g_cmsisOsMutexId);
|
||||
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_0900
|
||||
* @tc.name : mutex operation for release
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexRelease001, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret;
|
||||
g_cmsisOsMutexId = osMutexNew(&g_cmsisMutexAttr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisOsMutexId, NULL, g_cmsisOsMutexId);
|
||||
|
||||
ret = osMutexAcquire(g_cmsisOsMutexId, LOS_WAIT_FOREVER);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
|
||||
|
||||
ret = osMutexRelease(g_cmsisOsMutexId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
ret = osMutexDelete(g_cmsisOsMutexId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_1000
|
||||
* @tc.name : mutex release operation with mutex_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexRelease002, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret = osMutexRelease(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_1100
|
||||
* @tc.name : mutex operation for get owner
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexGetOwner001, Function | MediumTest | Level1)
|
||||
{
|
||||
osThreadId_t id;
|
||||
osThreadAttr_t osAttr;
|
||||
osAttr.name = "testMutexGetOwner001";
|
||||
osAttr.attr_bits = 0U;
|
||||
osAttr.cb_mem = NULL;
|
||||
osAttr.cb_size = 0U;
|
||||
osAttr.stack_mem = NULL;
|
||||
osAttr.stack_size = TEST_TASK_STACK_SIZE;
|
||||
osAttr.priority = osPriorityAboveNormal;
|
||||
id = osThreadNew((osThreadFunc_t)CmsisMutexGetOwnerFunc001, NULL, &osAttr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_MUTEX_OPERATION_1200
|
||||
* @tc.name : mutex get owner operation with mutex_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisMutexFuncTestSuite, testOsMutexGetOwner002, Function | MediumTest | Level1)
|
||||
{
|
||||
osThreadId_t id = osMutexGetOwner(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(id, NULL, id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
RUN_TEST_SUITE(CmsisMutexFuncTestSuite);
|
||||
|
||||
void CmsisMutexFuncTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testOsMutexNew001);
|
||||
RUN_ONE_TESTCASE(testOsMutexNew002);
|
||||
RUN_ONE_TESTCASE(testOsMutexDelete001);
|
||||
RUN_ONE_TESTCASE(testOsMutexDelete002);
|
||||
RUN_ONE_TESTCASE(testOsMutexDelete003);
|
||||
RUN_ONE_TESTCASE(testOsMutexDelete004);
|
||||
RUN_ONE_TESTCASE(testOsMutexAcquire001);
|
||||
RUN_ONE_TESTCASE(testOsMutexAcquire002);
|
||||
RUN_ONE_TESTCASE(testOsMutexRelease001);
|
||||
RUN_ONE_TESTCASE(testOsMutexRelease002);
|
||||
RUN_ONE_TESTCASE(testOsMutexGetOwner001);
|
||||
RUN_ONE_TESTCASE(testOsMutexGetOwner002);
|
||||
}
|
||||
|
|
@ -1,466 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "xts_cmsis.h"
|
||||
|
||||
osSemaphoreId_t g_cmsisSemSemaph;
|
||||
|
||||
LITE_TEST_SUIT(Cmsis, CmsisSem, CmsisSemFuncTestSuite);
|
||||
|
||||
static BOOL CmsisSemFuncTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL CmsisSemFuncTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0100
|
||||
* @tc.name : semaphore operation for creat when Semaphhore count = 1 and 0
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew001, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t status;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT0, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0200
|
||||
* @tc.name : semaphore operation for creat when Semaphhore count = 10 and 1
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew002, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t status;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT10, SEMAPHHORE_COUNT_INT1, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0300
|
||||
* @tc.name : semaphore operation for creat when Semaphhore count = 0 and 10
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew003, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t status;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT0, SEMAPHHORE_COUNT_INT10, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0400
|
||||
* @tc.name : semaphore operation for creat when Semaphhore count = 0 and 0
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew004, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t status;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT0, SEMAPHHORE_COUNT_INT0, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0500
|
||||
* @tc.name : semaphore operation for creat when Semaphhore count = 1 and 1
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew005, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t status;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT1, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0600
|
||||
* @tc.name : semaphore operation for creat when Semaphhore count = 10 and 10
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew006, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t status;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT10, SEMAPHHORE_COUNT_INT10, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0700
|
||||
* @tc.name : semaphore operation for creat when Semaphhore count = 0xFE and 0
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew007, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t status;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_HEX_MAX, SEMAPHHORE_COUNT_INT0, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0800
|
||||
* @tc.name : semaphore operation for creat when Semaphhore count = 0 and 0xFE
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreNew008, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t status;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT0, SEMAPHHORE_COUNT_HEX_MAX, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
(void)osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_0900
|
||||
* @tc.name : semaphore operation for delete
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreDelete001, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT10, SEMAPHHORE_COUNT_INT0, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1000
|
||||
* @tc.name : semaphore delete operation twice
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreDelete002, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT10, SEMAPHHORE_COUNT_INT0, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
|
||||
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1100
|
||||
* @tc.name : semaphore delete operation with semaphore_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreDelete003, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret = osSemaphoreDelete(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1200
|
||||
* @tc.name : semaphore operation for acquire when Semaphhore count = 1 and 1
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreAcquire001, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT1, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
ret = osSemaphoreAcquire(g_cmsisSemSemaph, 0);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1300
|
||||
* @tc.name : semaphore operation for acquire when Semaphhore count = 1 and 0
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreAcquire002, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT0, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
ret = osSemaphoreAcquire(g_cmsisSemSemaph, 0);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
|
||||
|
||||
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1400
|
||||
* @tc.name : semaphore operation for acquire when Semaphhore count = 0 and 1
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreAcquire003, Function | MediumTest | Level1)
|
||||
{
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT0, SEMAPHHORE_COUNT_INT1, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1500
|
||||
* @tc.name : semaphore acquire operation with semaphore_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreAcquire004, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret = osSemaphoreAcquire(NULL, 0);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1600
|
||||
* @tc.name : semaphore operation for release
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreRelease001, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT0, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
|
||||
ret = osSemaphoreAcquire(g_cmsisSemSemaph, 0);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
|
||||
|
||||
ret = osSemaphoreRelease(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1700
|
||||
* @tc.name : semaphore release operation twice
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreRelease002, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT0, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
|
||||
ret = osSemaphoreRelease(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
ret = osSemaphoreRelease(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
|
||||
|
||||
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1800
|
||||
* @tc.name : semaphore operation for release after semaphore acquire
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreRelease003, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT1, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
|
||||
ret = osSemaphoreRelease(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
|
||||
|
||||
ret = osSemaphoreAcquire(g_cmsisSemSemaph, 0);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
ret = osSemaphoreRelease(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
ret = osSemaphoreRelease(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorResource, ret);
|
||||
|
||||
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_1900
|
||||
* @tc.name : semaphore release operation with semaphore_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreRelease004, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret = osSemaphoreRelease(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osErrorParameter, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_2000
|
||||
* @tc.name : semaphore operation for get count when Semaphhore count = 1 or 0xFE
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreGetCount001, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT1, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
ret = osSemaphoreGetCount(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 1, ret); /* 1, common data for test, no special meaning */
|
||||
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_HEX_MAX, SEMAPHHORE_COUNT_HEX_MAX, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
ret = osSemaphoreGetCount(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, SEMAPHHORE_COUNT_HEX_MAX, ret);
|
||||
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_2100
|
||||
* @tc.name : semaphore operation for get count when Semaphhore count = 1 or 0
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreGetCount002, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT1, SEMAPHHORE_COUNT_INT0, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
ret = osSemaphoreGetCount(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_INT0, SEMAPHHORE_COUNT_INT1, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_2200
|
||||
* @tc.name : semaphore operation for get count
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreGetCount003, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret;
|
||||
g_cmsisSemSemaph = osSemaphoreNew(SEMAPHHORE_COUNT_HEX_MAX, SEMAPHHORE_COUNT_HEX_MAX, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_cmsisSemSemaph, NULL, g_cmsisSemSemaph);
|
||||
ret = osSemaphoreAcquire(g_cmsisSemSemaph, osWaitForever);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
ret = osSemaphoreGetCount(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, SEMAPHHORE_COUNT_HEX_MAX - 1, ret); /* 1, common data for test, no special meaning */
|
||||
ret = osSemaphoreDelete(g_cmsisSemSemaph);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_SEM_OPERATION_2300
|
||||
* @tc.name : semaphore get count operation with semaphore_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisSemFuncTestSuite, testOsSemaphoreGetCount004, Function | MediumTest | Level1)
|
||||
{
|
||||
osStatus_t ret = osSemaphoreGetCount(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
return 0;
|
||||
};
|
||||
|
||||
RUN_TEST_SUITE(CmsisSemFuncTestSuite);
|
||||
|
||||
void CmsisSemFuncTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreNew001);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreNew002);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreNew003);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreNew004);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreNew005);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreNew006);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreNew007);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreNew008);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreDelete001);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreDelete002);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreDelete003);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreAcquire001);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreAcquire002);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreAcquire003);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreAcquire004);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreRelease001);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreRelease002);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreRelease003);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreRelease004);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreGetCount001);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreGetCount002);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreGetCount003);
|
||||
RUN_ONE_TESTCASE(testOsSemaphoreGetCount004);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -1,768 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "xts_cmsis.h"
|
||||
|
||||
UINT16 g_cmsisTestTimeCount;
|
||||
|
||||
/**
|
||||
* @tc.desc : register a test suite, this suite is used to test basic flow and interface dependency
|
||||
* @param : subsystem name is utils
|
||||
* @param : module name is utilsFile
|
||||
* @param : test suit name is CmsisTaskFuncTestSuite
|
||||
*/
|
||||
LITE_TEST_SUIT(Cmsis, Cmsistimer, CmsisTimerFuncTestSuite);
|
||||
|
||||
/**
|
||||
* @tc.setup : setup for all testcases
|
||||
* @return : setup result, TRUE is success, FALSE is fail
|
||||
*/
|
||||
static BOOL CmsisTimerFuncTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.teardown : teardown for all testcases
|
||||
* @return : teardown result, TRUE is success, FALSE is fail
|
||||
*/
|
||||
static BOOL CmsisTimerFuncTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void CmsisTimerFunc001(void const *argument)
|
||||
{
|
||||
(void)argument;
|
||||
return;
|
||||
}
|
||||
|
||||
static void CmsisTimerFunc002(void const *argument)
|
||||
{
|
||||
(void)argument;
|
||||
g_cmsisTestTimeCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0100
|
||||
* @tc.name : timer operation for creat with parameter osTimerOnce
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerNew001, Function | MediumTest | Level1)
|
||||
{
|
||||
osTimerId_t id;
|
||||
osStatus_t status;
|
||||
UINT32 value = 0xffff;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
(void)osTimerDelete(id);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0200
|
||||
* @tc.name : timer operation for creat with parameter osTimerPeriodic
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerNew002, Function | MediumTest | Level1)
|
||||
{
|
||||
osTimerId_t id;
|
||||
osStatus_t status;
|
||||
UINT32 value = 0xffff;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
(void)osTimerDelete(id);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0300
|
||||
* @tc.name : timer creat operation with NULL func and parameter osTimerOnce
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerNew003, Function | MediumTest | Level1)
|
||||
{
|
||||
osTimerId_t id;
|
||||
osStatus_t status;
|
||||
UINT32 value = 0xffff;
|
||||
id = osTimerNew(NULL, osTimerOnce, &value, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(id, NULL, id);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0400
|
||||
* @tc.name : timer creat operation with NULL func and parameter osTimerPeriodic
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerNew004, Function | MediumTest | Level1)
|
||||
{
|
||||
osTimerId_t id;
|
||||
osStatus_t status;
|
||||
UINT32 value = 0xffff;
|
||||
id = osTimerNew(NULL, osTimerPeriodic, &value, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(id, NULL, id);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0500
|
||||
* @tc.name : timer operation for invalid timer type
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerNew005, Function | MediumTest | Level1)
|
||||
{
|
||||
osTimerId_t id;
|
||||
osStatus_t status;
|
||||
UINT32 value = 0xffff;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, INVALID_TIMER_TYPE, &value, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(id, NULL, id);
|
||||
status = osDelay(DELAY_TICKS_5);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0600
|
||||
* @tc.name : timer operation for start with parameter osTimerOnce
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStart001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
UINT32 value = 0xffff;
|
||||
UINT32 millisec = MILLISEC_NUM_INT4;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
uwRet = osTimerStart(id, millisec);
|
||||
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0700
|
||||
* @tc.name : timer operation for start with parameter osTimerPeriodic
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStart002, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
UINT32 value = 0xffff;
|
||||
UINT32 millisec = MILLISEC_NUM_INT4;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
uwRet = osTimerStart(id, millisec);
|
||||
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0800
|
||||
* @tc.name : timer operation for start with callback func and parameter osTimerOnce
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStart003, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
osStatus_t status;
|
||||
UINT32 value = 0xffff;
|
||||
UINT32 millisec = MILLISEC_NUM_INT4;
|
||||
g_cmsisTestTimeCount = 0;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc002, osTimerOnce, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
uwRet = osTimerStart(id, millisec);
|
||||
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||
|
||||
status = osDelay(DELAY_TICKS_10);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
ICUNIT_ASSERT_EQUAL(1, g_cmsisTestTimeCount, g_cmsisTestTimeCount); /* 1, common data for test, no special meaning */
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_0900
|
||||
* @tc.name : timer operation for start with callback func and parameter osTimerPeriodic
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStart004, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
osStatus_t status;
|
||||
UINT32 value = 0xffff;
|
||||
UINT32 millisec = MILLISEC_NUM_INT4;
|
||||
g_cmsisTestTimeCount = 0;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc002, osTimerPeriodic, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
uwRet = osTimerStart(id, millisec);
|
||||
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||
|
||||
status = osDelay(DELAY_TICKS_10);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
ICUNIT_ASSERT_EQUAL(TIMER_PERIODIC_COUNT, g_cmsisTestTimeCount, g_cmsisTestTimeCount);
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1000
|
||||
* @tc.name : timer start operation with ticks = 0 and parameter osTimerOnce
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStart005, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
UINT32 value = 0xffff;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
uwRet = osTimerStart(id, 0);
|
||||
ICUNIT_ASSERT_EQUAL(osErrorParameter, uwRet, uwRet);
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1100
|
||||
* @tc.name : timer start operation with ticks = 0 and parameter osTimerPeriodic
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStart006, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
UINT32 value = 0xffff;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
uwRet = osTimerStart(id, 0);
|
||||
ICUNIT_ASSERT_EQUAL(osErrorParameter, uwRet, uwRet);
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1200
|
||||
* @tc.name : timer start operation with timer_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStart007, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 millisec = MILLISEC_NUM_INT4;
|
||||
UINT32 uwRet = osTimerStart(NULL, millisec);
|
||||
ICUNIT_ASSERT_EQUAL(osErrorParameter, uwRet, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1300
|
||||
* @tc.name : timer operation for delete with parameter osTimerOnce
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerDelete001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
osStatus_t status;
|
||||
UINT32 value = 0xffff;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
uwRet = osTimerDelete(id);
|
||||
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1400
|
||||
* @tc.name : timer operation for delete with parameter osTimerPeriodic
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerDelete002, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
osStatus_t status;
|
||||
UINT32 value = 0xffff;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
uwRet = osTimerDelete(id);
|
||||
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1500
|
||||
* @tc.name : timer operation for delete after osTimerStart with parameter osTimerOnce
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerDelete003, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
osStatus_t status;
|
||||
UINT32 value = 0xffff;
|
||||
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
osTimerStart(id, millisec);
|
||||
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
uwRet = osTimerDelete(id);
|
||||
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1600
|
||||
* @tc.name : timer operation for delete after osTimerStart with parameter osTimerPeriodic
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerDelete004, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
osStatus_t status;
|
||||
UINT32 value = 0xffff;
|
||||
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
uwRet = osTimerStart(id, millisec);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
uwRet = osTimerDelete(id);
|
||||
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1700
|
||||
* @tc.name : timer delete operation with timer_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerDelete005, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet = osTimerDelete(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(osErrorParameter, uwRet, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1800
|
||||
* @tc.name : timer operation for stop after osTimerStart with parameter osTimerOnce
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStop001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
osStatus_t status;
|
||||
UINT32 value = 0xffff;
|
||||
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
uwRet = osTimerStart(id, millisec);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
uwRet = osTimerStop(id);
|
||||
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_1900
|
||||
* @tc.name : timer operation for stop after osTimerStart with parameter osTimerPeriodic
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStop002, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
osStatus_t status;
|
||||
UINT32 value = 0xffff;
|
||||
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
uwRet = osTimerStart(id, millisec);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
uwRet = osTimerStop(id);
|
||||
ICUNIT_ASSERT_EQUAL(osOK, uwRet, uwRet);
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2000
|
||||
* @tc.name : timer operation for stop with parameter osTimerOnce
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStop003, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
osStatus_t status;
|
||||
UINT32 value = 0xffff;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
uwRet = osTimerStop(id);
|
||||
ICUNIT_ASSERT_EQUAL(osErrorResource, uwRet, uwRet);
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2100
|
||||
* @tc.name : timer operation for stop with parameter osTimerPeriodic
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStop004, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
osStatus_t status;
|
||||
UINT32 value = 0xffff;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
status = osDelay(1); /* 1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
uwRet = osTimerStop(id);
|
||||
ICUNIT_ASSERT_EQUAL(osErrorResource, uwRet, uwRet);
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2200
|
||||
* @tc.name : timer stop operation with timer_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerStop005, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet = osTimerStop(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(osErrorParameter, uwRet, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2300
|
||||
* @tc.name : timer operation for running
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
UINT32 value = 0xffff;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
uwRet = osTimerIsRunning(id);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2400
|
||||
* @tc.name : timer operation for running after osTimerStart
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning002, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
UINT32 value = 0xffff;
|
||||
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
uwRet = osTimerStart(id, millisec);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
uwRet = osTimerIsRunning(id);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 1, uwRet); /* 1, common data for test, no special meaning */
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2500
|
||||
* @tc.name : timer operation for running after osTimerStart and osTimerStop
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning003, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
UINT32 value = 0xffff;
|
||||
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
uwRet = osTimerStart(id, millisec);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
uwRet = osTimerStop(id);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
|
||||
uwRet = osTimerIsRunning(id);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2600
|
||||
* @tc.name : timer operation for running after osTimerStart and osTimerDelete
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning004, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
UINT32 value = 0xffff;
|
||||
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerOnce, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
uwRet = osTimerStart(id, millisec);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
uwRet = osTimerDelete(id);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
uwRet = osTimerIsRunning(id);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2700
|
||||
* @tc.name : timer operation for running with parameter osTimerPeriodic
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning005, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
UINT32 value = 0xffff;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
uwRet = osTimerIsRunning(id);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2800
|
||||
* @tc.name : timer operation for running after osTimerStart with parameter osTimerPeriodic
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning006, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
UINT32 value = 0xffff;
|
||||
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
uwRet = osTimerStart(id, millisec);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, osOK, uwRet);
|
||||
uwRet = osTimerIsRunning(id);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 1, uwRet); /* 1, common data for test, no special meaning */
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_2900
|
||||
* @tc.name : timer operation for running after osTimerStart and osTimerStop with parameter osTimerPeriodic
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning007, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
UINT32 value = 0xffff;
|
||||
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
uwRet = osTimerStart(id, millisec);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||
uwRet = osTimerStop(id);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||
uwRet = osTimerIsRunning(id);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||
(void)osTimerDelete(id);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_3000
|
||||
* @tc.name : timer operation for running after osTimerStart and osTimerDelete with parameter osTimerPeriodic
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning008, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet;
|
||||
osTimerId_t id;
|
||||
UINT32 value = 0xffff;
|
||||
UINT32 millisec = MILLISEC_NUM_INT10;
|
||||
id = osTimerNew((osTimerFunc_t)CmsisTimerFunc001, osTimerPeriodic, &value, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(id, NULL, id);
|
||||
|
||||
uwRet = osTimerStart(id, millisec);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||
uwRet = osTimerDelete(id);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||
uwRet = osTimerIsRunning(id);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_3100
|
||||
* @tc.name : timer running inquiry with timer_id = NULL
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsTimerIsRunning009, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet = osTimerIsRunning(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, 0, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_3200
|
||||
* @tc.name : os operation for get tick freq
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsKernelGetTickFreq001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet = osKernelGetTickFreq();
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, LOSCFG_BASE_CORE_TICK_PER_SECOND, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_3300
|
||||
* @tc.name : os operation for get sys time freq
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsKernelGetSysTimerFreq001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet = osKernelGetSysTimerFreq();
|
||||
ICUNIT_ASSERT_EQUAL(uwRet, OS_SYS_CLOCK, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_CMSIS_TIMER_OPERATION_3400
|
||||
* @tc.name : os operation for get sys time count
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisTimerFuncTestSuite, testOsKernelGetSysTimerCount001, Function | MediumTest | Level1)
|
||||
{
|
||||
UINT32 uwRet = osKernelGetSysTimerCount();
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL(uwRet, 0, UINT_MAX, uwRet);
|
||||
return 0;
|
||||
};
|
||||
|
||||
RUN_TEST_SUITE(CmsisTimerFuncTestSuite);
|
||||
|
||||
void CmsisTimerFuncTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testOsTimerNew001);
|
||||
RUN_ONE_TESTCASE(testOsTimerNew002);
|
||||
RUN_ONE_TESTCASE(testOsTimerNew003);
|
||||
RUN_ONE_TESTCASE(testOsTimerNew004);
|
||||
RUN_ONE_TESTCASE(testOsTimerNew005);
|
||||
RUN_ONE_TESTCASE(testOsTimerStart001);
|
||||
RUN_ONE_TESTCASE(testOsTimerStart002);
|
||||
RUN_ONE_TESTCASE(testOsTimerStart003);
|
||||
RUN_ONE_TESTCASE(testOsTimerStart004);
|
||||
RUN_ONE_TESTCASE(testOsTimerStart005);
|
||||
RUN_ONE_TESTCASE(testOsTimerStart006);
|
||||
RUN_ONE_TESTCASE(testOsTimerStart007);
|
||||
RUN_ONE_TESTCASE(testOsTimerDelete001);
|
||||
RUN_ONE_TESTCASE(testOsTimerDelete002);
|
||||
RUN_ONE_TESTCASE(testOsTimerDelete003);
|
||||
RUN_ONE_TESTCASE(testOsTimerDelete004);
|
||||
RUN_ONE_TESTCASE(testOsTimerDelete005);
|
||||
RUN_ONE_TESTCASE(testOsTimerStop001);
|
||||
RUN_ONE_TESTCASE(testOsTimerStop002);
|
||||
RUN_ONE_TESTCASE(testOsTimerStop003);
|
||||
RUN_ONE_TESTCASE(testOsTimerStop004);
|
||||
RUN_ONE_TESTCASE(testOsTimerStop005);
|
||||
RUN_ONE_TESTCASE(testOsTimerIsRunning001);
|
||||
RUN_ONE_TESTCASE(testOsTimerIsRunning002);
|
||||
RUN_ONE_TESTCASE(testOsTimerIsRunning003);
|
||||
RUN_ONE_TESTCASE(testOsTimerIsRunning004);
|
||||
RUN_ONE_TESTCASE(testOsTimerIsRunning005);
|
||||
RUN_ONE_TESTCASE(testOsTimerIsRunning006);
|
||||
RUN_ONE_TESTCASE(testOsTimerIsRunning007);
|
||||
RUN_ONE_TESTCASE(testOsTimerIsRunning008);
|
||||
RUN_ONE_TESTCASE(testOsTimerIsRunning009);
|
||||
RUN_ONE_TESTCASE(testOsKernelGetTickFreq001);
|
||||
RUN_ONE_TESTCASE(testOsKernelGetSysTimerFreq001);
|
||||
RUN_ONE_TESTCASE(testOsKernelGetSysTimerCount001);
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "xts_test.h"
|
||||
|
||||
void CmsisFuncTest(void)
|
||||
{
|
||||
CmsisEventFuncTest();
|
||||
CmsisMsgFuncTest();
|
||||
CmsisMutexFuncTest();
|
||||
CmsisSemFuncTest();
|
||||
CmsisTaskFuncTest();
|
||||
CmsisTaskPriFuncTest();
|
||||
CmsisTimerFuncTest();
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef XTS_CMSID_H
|
||||
#define XTS_CMSID_H
|
||||
|
||||
#include "xts_test.h"
|
||||
#include <securec.h>
|
||||
#include <limits.h>
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
#define LOS_WAIT_FOREVER 0xFFFFFFFF
|
||||
|
||||
#define TESTCOUNT_NUM_1 1
|
||||
#define TESTCOUNT_NUM_2 2
|
||||
#define TESTCOUNT_NUM_3 3
|
||||
#define TESTCOUNT_NUM_4 4
|
||||
#define TESTCOUNT_NUM_5 5
|
||||
|
||||
#define MSGQUEUE_COUNT 16
|
||||
#define MSGQUEUE_SPACE_COUNT 13
|
||||
#define MSGQUEUE_PUT_COUNT 3
|
||||
#define MSG_SIZE 4
|
||||
#define MSGINFO_LEN 4
|
||||
#define TIMEOUT_COUNT 1000
|
||||
#define BUF_LEN 32
|
||||
#define MSGQUEUE_COUNT_INDEX_0 0
|
||||
#define MSGQUEUE_COUNT_INDEX_1 1
|
||||
#define MSGQUEUE_COUNT_INDEX_2 2
|
||||
|
||||
#define SEMAPHHORE_COUNT_HEX_MAX 0xFE
|
||||
#define SEMAPHHORE_COUNT_INT0 0
|
||||
#define SEMAPHHORE_COUNT_INT1 1
|
||||
#define SEMAPHHORE_COUNT_INT10 10
|
||||
|
||||
#define EVENT_MASK_HEX_1 0x01
|
||||
#define EVENT_MASK_HEX_2 0x02
|
||||
#define EVENT_MASK_HEX_4 0x04
|
||||
#define EVENT_MASK_HEX_10 0x10
|
||||
#define EVENT_MASK_HEX_11 0x11
|
||||
#define TIMEOUT_NUM_3 3
|
||||
#define TIMEOUT_NUM_10 10
|
||||
#define INVALID_FLAG_OPTION 0x00000004U
|
||||
|
||||
#define MILLISEC_NUM_INT10 10U
|
||||
#define MILLISEC_NUM_INT4 4U
|
||||
#define INVALID_TIMER_TYPE 10
|
||||
#define TIMER_PERIODIC_COUNT 2
|
||||
|
||||
#define DELAY_TICKS_1 1
|
||||
#define DELAY_TICKS_5 5
|
||||
#define DELAY_TICKS_10 10
|
||||
|
||||
#define PRIORITY_COUNT_NOT_MIN 3
|
||||
#define PRIORITY_COUNT_MIN_1 4
|
||||
#define PRIORITY_COUNT_MIN_2 5
|
||||
#define PRIORITY_COUNT_MIN_3 6
|
||||
#define PRIORITY_COUNT_MIN_4 7
|
||||
#define MAX_UINT32 0xFFFFFFFF
|
||||
#define ALIVE_INFO_DIS 10000
|
||||
|
||||
#endif
|
||||
|
|
@ -647,200 +647,6 @@ LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqSetAttrEBADFEINVAL, Function |
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.number SUB_KERNEL_IPC_MQ_OPEN_0100
|
||||
* @tc.name mq_open function errno for EEXIST test
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqOpenEEXIST, Function | MediumTest | Level2)
|
||||
{
|
||||
int ret;
|
||||
char qName[MQ_NAME_LEN];
|
||||
mqd_t queue, queueOther;
|
||||
|
||||
ret = sprintf_s(qName, sizeof(qName), "testMqOpenEEXIST_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* 1, common data for test, no special meaning */
|
||||
|
||||
queueOther = mq_open(qName, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(queueOther, (mqd_t)-1, queueOther); /* 1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(errno, EEXIST, errno);
|
||||
ret = mq_close(queue);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = mq_unlink(qName);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.number SUB_KERNEL_IPC_MQ_OPEN_0200
|
||||
* @tc.name mq_open function errno for EINVAL test
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqOpenEINVAL, Function | MediumTest | Level2)
|
||||
{
|
||||
int i, ret;
|
||||
mqd_t queue;
|
||||
struct mq_attr attr = { 0 };
|
||||
char qName[MQ_NAME_LEN];
|
||||
const int max = 65535; /* 65535, common data for test, no special meaning */
|
||||
|
||||
ret = sprintf_s(qName, sizeof(qName), "testMqOpenEINVAL_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
attr.mq_msgsize = -1; /* -1, common data for test, no special meaning */
|
||||
attr.mq_maxmsg = max;
|
||||
break;
|
||||
case 1:
|
||||
attr.mq_msgsize = max;
|
||||
attr.mq_maxmsg = max;
|
||||
break;
|
||||
case 2:
|
||||
attr.mq_msgsize = 10; /* 10, common data for test, no special meaning */
|
||||
attr.mq_maxmsg = -1; /* -1, common data for test, no special meaning */
|
||||
break;
|
||||
case 3:
|
||||
attr.mq_msgsize = 10; /* 10, common data for test, no special meaning */
|
||||
attr.mq_maxmsg = max + 1;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
attr.mq_msgsize = 0; /* 0, common data for test, no special meaning */
|
||||
attr.mq_maxmsg = 16; /* 16, common data for test, no special meaning */
|
||||
break;
|
||||
|
||||
case 5:
|
||||
attr.mq_msgsize = 64; /* 64, common data for test, no special meaning */
|
||||
attr.mq_maxmsg = 0; /* 0, common data for test, no special meaning */
|
||||
break;
|
||||
}
|
||||
|
||||
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_ASSERT_EQUAL(queue, (mqd_t)-1, queue); /* 1, common data for test, no special meaning */
|
||||
|
||||
if (queue != (mqd_t)-1) { /* 1, common data for test, no special meaning */
|
||||
ret = mq_close(queue);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = mq_unlink(qName);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
}
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||
}
|
||||
|
||||
for (i = 0; i < MQ_NAME_LEN; i++) {
|
||||
qName[i] = 0;
|
||||
}
|
||||
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_ASSERT_EQUAL(queue, (mqd_t)-1, queue); /* 1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.number SUB_KERNEL_IPC_MQ_OPEN_0300
|
||||
* @tc.name mq_open function errno for ENAMETOOLONG test
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqOpenENAMETOOLONG, Function | MediumTest | Level2)
|
||||
{
|
||||
char qName[MAX_MQ_NAME_LEN + 10]; /* 10, common data for test, no special meaning */
|
||||
mqd_t queue;
|
||||
int i, ret;
|
||||
|
||||
for (i = 0; i < MAX_MQ_NAME_LEN + 5; i++) { /* 5, common data for test, no special meaning */
|
||||
qName[i] = '8';
|
||||
}
|
||||
qName[i] = '\0';
|
||||
|
||||
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||
|
||||
if (queue != (mqd_t)-1) { /* -1, common data for test, no special meaning */
|
||||
ret = mq_close(queue);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = mq_unlink(qName);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
}
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(errno, ENAMETOOLONG, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.number SUB_KERNEL_IPC_MQ_OPEN_0400
|
||||
* @tc.name mq_open function errno for ENOENT test
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqOpenENOENT, Function | MediumTest | Level3)
|
||||
{
|
||||
int ret;
|
||||
mqd_t queue;
|
||||
char qName[MQ_NAME_LEN];
|
||||
|
||||
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqOpenENOENT_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||
queue = mq_open(qName, O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||
|
||||
if (queue != (mqd_t)-1) { /* -1, common data for test, no special meaning */
|
||||
ret = mq_close(queue);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = mq_unlink(qName);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.number SUB_KERNEL_IPC_MQ_OPEN_0600
|
||||
* @tc.name mq_open function errno for ENOSPC test
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqOpenENOSPC, Function | MediumTest | Level3)
|
||||
{
|
||||
int ret;
|
||||
mqd_t queue;
|
||||
struct mq_attr setAttr = { 0 };
|
||||
char qName[MQ_NAME_LEN];
|
||||
|
||||
ret = sprintf_s(qName, MQ_NAME_LEN, "testMqOpenENOSPC_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret);
|
||||
setAttr.mq_msgsize = MAX_MQ_MSG_SIZE + 1; /* 1, common data for test, no special meaning */
|
||||
setAttr.mq_maxmsg = MAX_MQ_NAME_LEN;
|
||||
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr);
|
||||
ICUNIT_ASSERT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */
|
||||
|
||||
if (queue != (mqd_t)-1) { /* -1, common data for test, no special meaning */
|
||||
ret = mq_close(queue);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = mq_unlink(qName);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(errno, ENOSPC, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* *
|
||||
* @tc.number SUB_KERNEL_IPC_MQ_CLOSE_0100
|
||||
* @tc.name mq_close function errno for EBADF test
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqCloseEBADF, Function | MediumTest | Level2)
|
||||
{
|
||||
int ret = mq_close(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
RUN_TEST_SUITE(IpcMqExceptionApiTestSuite);
|
||||
|
||||
void IpcMqExceptionFuncTest(void)
|
||||
|
|
@ -861,10 +667,4 @@ void IpcMqExceptionFuncTest(void)
|
|||
RUN_ONE_TESTCASE(testMqUnlinkEINVAL);
|
||||
RUN_ONE_TESTCASE(testMqGetAttrEBADFEINVAL);
|
||||
RUN_ONE_TESTCASE(testMqSetAttrEBADFEINVAL);
|
||||
RUN_ONE_TESTCASE(testMqOpenEEXIST);
|
||||
RUN_ONE_TESTCASE(testMqOpenEINVAL);
|
||||
RUN_ONE_TESTCASE(testMqOpenENAMETOOLONG);
|
||||
RUN_ONE_TESTCASE(testMqOpenENOENT);
|
||||
RUN_ONE_TESTCASE(testMqOpenENOSPC);
|
||||
RUN_ONE_TESTCASE(testMqCloseEBADF);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
# Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_m/liteos.gni")
|
||||
|
||||
static_library("mem_test") {
|
||||
sources = [
|
||||
"acts_mem_api_test.c",
|
||||
"mem_api_test.c",
|
||||
"xts_mem.c",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
".",
|
||||
"$LITEOSTOPDIR/testsuites/include",
|
||||
"$LITEOSTOPDIR/testsuites/unittest/xts",
|
||||
]
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "xts_mem.h"
|
||||
|
||||
LITE_TEST_SUIT(MEM, ActsMemApi, ActsMemApiTestSuite);
|
||||
|
||||
static BOOL ActsMemApiTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL ActsMemApiTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_NDKAPI_MEM_MEMCHR_0100
|
||||
* @tc.name test memchr api
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ActsMemApiTestSuite, testMemchr_0100, Function | MediumTest | Level1) {
|
||||
char srcStr[] = "this is str a;";
|
||||
char *pos = (char *)memchr(srcStr, 'a', 14); /* 14, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_STRING_EQUAL(pos, (char *)"a;", pos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_NDKAPI_MEM_MEMCHR_1000
|
||||
* @tc.name test memchr api para len not enough
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ActsMemApiTestSuite, testMemchr_1000, Function | MediumTest | Level1) {
|
||||
char srcStr[] = "this is str a;";
|
||||
char *pos = (char *)memchr(srcStr, 'a', 4); /* 4, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(pos, 0, pos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_NDKAPI_MEM_MEMCHR_1100
|
||||
* @tc.name test memchr api para c not found
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ActsMemApiTestSuite, testMemchr_1100, Function | MediumTest | Level1) {
|
||||
char srcStr[] = "this is str a;";
|
||||
char *pos = (char *)memchr(srcStr, 'b', 14); /* 14, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(pos, 0, pos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
RUN_TEST_SUITE(ActsMemApiTestSuite);
|
||||
|
||||
void ActsMemApiTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testMemchr_0100);
|
||||
RUN_ONE_TESTCASE(testMemchr_1000);
|
||||
RUN_ONE_TESTCASE(testMemchr_1100);
|
||||
}
|
||||
|
||||
|
|
@ -1,201 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "xts_mem.h"
|
||||
|
||||
LITE_TEST_SUIT(MEM, MemApi, MemApiTestSuite);
|
||||
|
||||
static BOOL MemApiTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL MemApiTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_MEM_MEMSET_0100
|
||||
* @tc.name memset function set buffer value test
|
||||
* @tc.desc [C-L*-311]
|
||||
*/
|
||||
LITE_TEST_CASE(MemApiTestSuite, testMemset, Function | MediumTest | Level1)
|
||||
{
|
||||
char chr = 'A';
|
||||
int i, len, failure;
|
||||
len = GetRandom(1024); /* 1024, common data for test, no special meaning */
|
||||
errno_t err = EOK;
|
||||
|
||||
char buf[1024]; /* 1024, common data for test, no special meaning */
|
||||
err = memset_s(buf, sizeof(buf), chr, len);
|
||||
ICUNIT_ASSERT_EQUAL(err, 0, err);
|
||||
failure = 0;
|
||||
for (i = 0; i < len; i++) {
|
||||
if (buf[i] != chr) {
|
||||
failure = 1; /* 1, common data for test, no special meaning */
|
||||
break;
|
||||
}
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(failure, 0, failure);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_MEM_MEMCPY_0100
|
||||
* @tc.name memcpy function copy buffer test
|
||||
* @tc.desc [C-L*-311]
|
||||
*/
|
||||
LITE_TEST_CASE(MemApiTestSuite, testMemcpy, Function | MediumTest | Level2)
|
||||
{
|
||||
char chr = 'A';
|
||||
int i, len, failure;
|
||||
char src[1024]; /* 1024, common data for test, no special meaning */
|
||||
char dst[1024]; /* 1024, common data for test, no special meaning */
|
||||
|
||||
len = GetRandom(1024); /* 1024, common data for test, no special meaning */
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
src[i] = chr + i % 26; /* 26, common data for test, no special meaning */
|
||||
}
|
||||
|
||||
errno_t err = memcpy_s(dst, sizeof(dst) / sizeof(dst[0]), src, len);
|
||||
ICUNIT_ASSERT_EQUAL(err, 0, err);
|
||||
failure = 0;
|
||||
for (i = 0; i < len; i++) {
|
||||
if (dst[i] != src[i]) {
|
||||
failure = 1; /* 1, common data for test, no special meaning */
|
||||
break;
|
||||
}
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(failure, 0, failure);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_MEM_MEMMOVE_0100
|
||||
* @tc.name memmove function move buffer test
|
||||
* @tc.desc [C-L*-311]
|
||||
*/
|
||||
LITE_TEST_CASE(MemApiTestSuite, testMemmove, Function | MediumTest | Level2)
|
||||
{
|
||||
char chr = 'A';
|
||||
char buf[1024]; /* 1024, common data for test, no special meaning */
|
||||
int i, len, failure;
|
||||
|
||||
len = sizeof(buf);
|
||||
for (i = 0; i < len; i++) {
|
||||
buf[i] = chr + GetRandom(26); /* 26, common data for test, no special meaning */
|
||||
}
|
||||
errno_t err = memmove_s(&buf[0], sizeof(buf) / sizeof(buf[0]), &buf[len / 2], len / 2); /* 2, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(err, 0, err);
|
||||
|
||||
failure = 0;
|
||||
for (i = 0; i < len / 2; i++) { /* 2, common data for test, no special meaning */
|
||||
if (buf[i] != buf[len / 2 + i]) { /* 2, common data for test, no special meaning */
|
||||
failure = 1; /* 1, common data for test, no special meaning */
|
||||
break;
|
||||
}
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(failure, 0, failure);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_MEM_MEMMOVE_0200
|
||||
* @tc.name memmove function overlay move buffer test
|
||||
* @tc.desc [C-L*-311]
|
||||
*/
|
||||
LITE_TEST_CASE(MemApiTestSuite, testMemmoveOverlay, Function | MediumTest | Level3)
|
||||
{
|
||||
char chr = 'A';
|
||||
char buf[1024]; /* 1024, common data for test, no special meaning */
|
||||
char backup[1024]; /* 1024, common data for test, no special meaning */
|
||||
int i, len, failure;
|
||||
|
||||
len = sizeof(buf);
|
||||
for (i = 0; i < len; i++) {
|
||||
buf[i] = chr + GetRandom(26); /* 26, common data for test, no special meaning */
|
||||
backup[i] = buf[i];
|
||||
}
|
||||
errno_t err = memmove_s(&buf[16], sizeof(buf) / sizeof(buf[0]) - 16, &buf[0], len / 2); /* 16, 2, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(err, 0, err);
|
||||
|
||||
failure = 0;
|
||||
for (i = 0; i < len / 2; i++) { /* 2, common data for test, no special meaning */
|
||||
if (buf[i + 16] != backup[i]) { /* 16, common data for test, no special meaning */
|
||||
failure = 1; /* 1, common data for test, no special meaning */
|
||||
break;
|
||||
}
|
||||
}
|
||||
ICUNIT_ASSERT_EQUAL(failure, 0, failure);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_MEM_MEMCMP_0100
|
||||
* @tc.name memmove function move buffer test
|
||||
* @tc.desc [C-L*-311]
|
||||
*/
|
||||
LITE_TEST_CASE(MemApiTestSuite, testMemcmp, Function | MediumTest | Level2)
|
||||
{
|
||||
char orign[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}; /* 8, common data for test, no special meaning */
|
||||
char lt[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x77}; /* 8, common data for test, no special meaning */
|
||||
char eq[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}; /* 8, common data for test, no special meaning */
|
||||
char gt[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x99}; /* 8, common data for test, no special meaning */
|
||||
|
||||
int ret;
|
||||
int len = sizeof(orign);
|
||||
|
||||
ret = memcmp(lt, orign, len);
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL(ret, INT_MIN, 0, ret);
|
||||
|
||||
ret = memcmp(eq, orign, len);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = memcmp(gt, orign, len);
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL(ret, 0, INT_MAX, ret);
|
||||
|
||||
ret = memcmp(gt, orign, 0);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
RUN_TEST_SUITE(MemApiTestSuite);
|
||||
|
||||
void MemApiTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testMemset);
|
||||
RUN_ONE_TESTCASE(testMemcpy);
|
||||
RUN_ONE_TESTCASE(testMemmove);
|
||||
RUN_ONE_TESTCASE(testMemmoveOverlay);
|
||||
RUN_ONE_TESTCASE(testMemcmp);
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "xts_test.h"
|
||||
|
||||
void MemFuncTest(void)
|
||||
{
|
||||
ActsMemApiTest();
|
||||
MemApiTest();
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef XTS_MEM_H
|
||||
#define XTS_MEM_H
|
||||
|
||||
#include "xts_test.h"
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <securec.h>
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <limits.h>
|
||||
|
||||
#endif
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
# Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_m/liteos.gni")
|
||||
|
||||
static_library("net_test") {
|
||||
sources = [ "acts_net_test.c" ]
|
||||
|
||||
include_dirs = [
|
||||
".",
|
||||
"$LITEOSTOPDIR/testsuites/include",
|
||||
"$LITEOSTOPDIR/testsuites/unittest/xts",
|
||||
"$THIRDPARTY_MUSL_DIR/include/net",
|
||||
]
|
||||
}
|
||||
|
|
@ -1,419 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "xts_net.h"
|
||||
|
||||
LITE_TEST_SUIT(NET, ActsNet, ActsNetTestSuite);
|
||||
|
||||
static BOOL ActsNetTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL ActsNetTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_NET_0730
|
||||
* @tc.name : test ioctl get and set IFHWADDR
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ActsNetTestSuite, testIoctlIfhwAddr, Function | MediumTest | Level2)
|
||||
{
|
||||
int udpFd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(udpFd, -1, udpFd); /* -1, common data for test, no special meaning */
|
||||
|
||||
struct ifreq ifre[5]; /* 5, common data for test, no special meaning */
|
||||
struct ifconf ifcf = {0};
|
||||
(void)memset_s(&ifcf, sizeof(struct ifconf), 0, sizeof(struct ifconf));
|
||||
ifcf.ifc_len = 5 * sizeof(struct ifreq); /* 5, common data for test, no special meaning */
|
||||
ifcf.ifc_buf = (char *)ifre;
|
||||
int ret = ioctl(udpFd, SIOCGIFCONF, (char *)&ifcf);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
char rst1[18]; /* 18, common data for test, no special meaning */
|
||||
char *macPtr = NULL;
|
||||
struct ifreq ifrTmp = {0};
|
||||
struct sockaddr_in *addr = NULL;
|
||||
int ifrCount = ifcf.ifc_len / sizeof(struct ifreq);
|
||||
ICUNIT_GOTO_EQUAL(ifrCount, 2, ifrCount, EXIT); /* 2, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL(ifrCount, 2, INT_MAX, ifrCount); /* 2, common data for test, no special meaning */
|
||||
EXIT:
|
||||
for (int i = 0; i < ifrCount; i++) {
|
||||
addr = (struct sockaddr_in *)&ifre[i].ifr_addr;
|
||||
if (strcmp("lo", ifre[i].ifr_name) != 0) {
|
||||
(void)memset_s(&ifrTmp, sizeof(struct ifreq), 0, sizeof(struct ifreq));
|
||||
ret = strcpy_s(ifrTmp.ifr_name, sizeof(ifrTmp.ifr_name), ifre[i].ifr_name);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = ioctl(udpFd, SIOCGIFHWADDR, &ifrTmp);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
macPtr = ifrTmp.ifr_hwaddr.sa_data;
|
||||
ret = sprintf_s(rst1, sizeof(rst1), "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", *macPtr, *(macPtr + 1),
|
||||
*(macPtr + 2), *(macPtr + 3), *(macPtr + 4), *(macPtr + 5)); /* 1, 2, 3, 4, 5, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL((unsigned int)ret, strlen(rst1), (unsigned int)ret);
|
||||
}
|
||||
}
|
||||
ret = close(udpFd);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_NET_1000
|
||||
* @tc.name : test socket operation
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ActsNetTestSuite, testSocketOpt, Function | MediumTest | Level2)
|
||||
{
|
||||
socklen_t len;
|
||||
struct timeval timeout = {0};
|
||||
int fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(fd, -1, fd); /* -1, common data for test, no special meaning */
|
||||
|
||||
int error = -1; /* -1, common data for test, no special meaning */
|
||||
len = sizeof(error);
|
||||
int ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(error, 0, error);
|
||||
|
||||
len = sizeof(timeout);
|
||||
ret = getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, &len);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
timeout.tv_sec = 1000; /* 1000, common data for test, no special meaning */
|
||||
len = sizeof(timeout);
|
||||
ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, len);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
(void)memset_s(&timeout, len, 0, len);
|
||||
ret = getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, &len);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(timeout.tv_sec, 1000, timeout.tv_sec); /* 1000, common data for test, no special meaning */
|
||||
|
||||
int flag = 1; /* 1, common data for test, no special meaning */
|
||||
ret = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag));
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
flag = 0;
|
||||
len = sizeof(flag);
|
||||
ret = getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, &len);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(flag, 1, flag); /* 1, common data for test, no special meaning */
|
||||
|
||||
error = -1; /* -1, common data for test, no special meaning */
|
||||
len = sizeof(error);
|
||||
ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(error, 0, error);
|
||||
|
||||
ret = close(fd);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_NET_1100
|
||||
* @tc.name : test getsockname and getpeername invalid input
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ActsNetTestSuite, testGetSocketNameInvalidInput, Function | MediumTest | Level3)
|
||||
{
|
||||
struct sockaddr addr = {0};
|
||||
socklen_t addrLen = sizeof(addr);
|
||||
int ret = getsockname(-1, &addr, &addrLen); /* -1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
ret = getpeername(-1, &addr, &addrLen); /* -1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
ret = getsockname(0, &addr, &addrLen);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
ret = getpeername(0, &addr, &addrLen);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
ret = getsockname(1, &addr, &addrLen); /* 1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
ret = getpeername(1, &addr, &addrLen); /* 1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
ret = getsockname(130, &addr, &addrLen); /* 130, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
ret = getpeername(130, &addr, &addrLen); /* 130, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
ret = getsockname(10, NULL, &addrLen); /* 10, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
ret = getpeername(10, NULL, &addrLen); /* 10, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
ret = getsockname(10, &addr, NULL); /* 10, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
ret = getpeername(10, &addr, NULL); /* 10, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_NET_2400
|
||||
* @tc.name : test convert value from host to network byte order
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ActsNetTestSuite, testHostToNetwork, Function | MediumTest | Level2)
|
||||
{
|
||||
uint32_t intInput1 = 0;
|
||||
uint32_t intRst01 = htonl(intInput1);
|
||||
uint32_t intInput2 = 65536; /* 65536, common data for test, no special meaning */
|
||||
uint32_t intRst02 = htonl(intInput2);
|
||||
uint16_t shortInput1 = 0;
|
||||
uint16_t shortRst01 = htons(shortInput1);
|
||||
uint16_t shortInput2 = 255; /* 255, common data for test, no special meaning */
|
||||
uint16_t shortRst02 = htons(shortInput2);
|
||||
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
uint32_t expectZero = 0;
|
||||
uint32_t expectForIinput2 = 256; /* 255, common data for test, no special meaning */
|
||||
uint32_t expectForSinput2 = 65280; /* 65536, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(intRst01, expectZero, intRst01);
|
||||
ICUNIT_ASSERT_EQUAL(intRst02, expectForIinput2, intRst02);
|
||||
ICUNIT_ASSERT_EQUAL(shortRst01, expectZero, shortRst01);
|
||||
ICUNIT_ASSERT_EQUAL(shortRst02, expectForSinput2, shortRst02);
|
||||
#else
|
||||
ICUNIT_ASSERT_EQUAL(intRst01, intInput1, intRst01);
|
||||
ICUNIT_ASSERT_EQUAL(intRst02, intInput2, intRst02);
|
||||
ICUNIT_ASSERT_EQUAL(shortRst01, shortInput1, shortRst01);
|
||||
ICUNIT_ASSERT_EQUAL(shortRst02, shortInput2, shortRst02);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_NET_2500
|
||||
* @tc.name : test convert value from network to host byte order
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ActsNetTestSuite, testNetworkToHost, Function | MediumTest | Level2)
|
||||
{
|
||||
uint32_t intInput1 = 0;
|
||||
uint32_t intRst1 = ntohl(intInput1);
|
||||
uint32_t intInput2 = 65536; /* 65536, common data for test, no special meaning */
|
||||
uint32_t intRst02 = ntohl(intInput2);
|
||||
uint16_t shortInput1 = 0;
|
||||
uint16_t shortRst01 = ntohs(shortInput1);
|
||||
uint16_t shortInput2 = 255; /* 255, common data for test, no special meaning */
|
||||
uint16_t shortRst02 = ntohs(shortInput2);
|
||||
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
uint32_t expectZero = 0;
|
||||
uint32_t expectForIinput2 = 256; /* 255, common data for test, no special meaning */
|
||||
uint32_t expectForSinput2 = 65280; /* 65536, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(intRst1, expectZero, intRst1);
|
||||
ICUNIT_ASSERT_EQUAL(intRst02, expectForIinput2, intRst02);
|
||||
ICUNIT_ASSERT_EQUAL(shortRst01, expectZero, shortRst01);
|
||||
ICUNIT_ASSERT_EQUAL(shortRst02, expectForSinput2, shortRst02);
|
||||
#else
|
||||
ICUNIT_ASSERT_EQUAL(intRst1, intInput1, intRst1);
|
||||
ICUNIT_ASSERT_EQUAL(intRst02, intInput2, intRst02);
|
||||
ICUNIT_ASSERT_EQUAL(shortRst01, shortInput1, shortRst01);
|
||||
ICUNIT_ASSERT_EQUAL(shortRst02, shortInput2, shortRst02);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_NET_2600
|
||||
* @tc.name : test inet_pton IPv4 normal
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ActsNetTestSuite, testInetPtonIpv4Normal, Function | MediumTest | Level2)
|
||||
{
|
||||
int ret;
|
||||
struct in_addr rst = {0};
|
||||
char cpAddrs[4][16] = {"10.58.212.100", "0.0.0.0", "255.0.0.0", "255.255.255.255"}; /* 4, 16, common data for test, no special meaning */
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
unsigned int expLittle[4] = {1691630090, 0, 255, 4294967295}; /* 4, common data for test, no special meaning */
|
||||
#else
|
||||
unsigned int expBig[4] = {171627620, 0, 4278190080, 4294967295}; /* 4, common data for test, no special meaning */
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < 4; i++) { /* 4, common data for test, no special meaning */
|
||||
ret = inet_pton(AF_INET, cpAddrs[i], &rst);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 1, ret);
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
ICUNIT_ASSERT_EQUAL(rst.s_addr, expLittle[i], rst.s_addr);
|
||||
#else
|
||||
ICUNIT_ASSERT_EQUAL(rst.s_addr, expBig[i], rst.s_addr);
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_NET_2800
|
||||
* @tc.name : test inet_pton IPv6 normal
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ActsNetTestSuite, testInetPtonIpv6Normal, Function | MediumTest | Level2)
|
||||
{
|
||||
int ret;
|
||||
struct in6_addr rst = {0};
|
||||
char cpAddrs[6][40] = {"0101:0101:0101:0101:1010:1010:1010:1010", "0:0:0:0:0:0:0:0", /* 6, 40, common data for test, no special meaning */
|
||||
"FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF", "::", "1::", "0011:0011:0011:0011:11:11:11:11"};
|
||||
for (int i = 0; i < 6; i++) { /* 6, common data for test, no special meaning */
|
||||
ret = inet_pton(AF_INET6, cpAddrs[i], &rst);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 1, ret); /* 1, common data for test, no special meaning */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_NET_2900
|
||||
* @tc.name : test inet_pton IPv6 abnormal
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ActsNetTestSuite, testInetPtonIpv6Abnormal, Function | MediumTest | Level2)
|
||||
{
|
||||
int ret;
|
||||
struct in6_addr rst = {0};
|
||||
char cpAddrs[7][40] = {"127.0.0.1", "f", ":", "0:0", "1:::", ":::::::", /* 7, 40, common data for test, no special meaning */
|
||||
"1111:1111:1111:1111:1111:1111:1111:111G"};
|
||||
for (int i = 0; i < 7; i++) { /* 7, common data for test, no special meaning */
|
||||
ret = inet_pton(AF_INET6, cpAddrs[i], &rst);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_NET_3000
|
||||
* @tc.name : test inet_pton with invalid family
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ActsNetTestSuite, testInetPtonInvalidFamily, Function | MediumTest | Level2)
|
||||
{
|
||||
struct in_addr rst = {0};
|
||||
int ret = inet_pton(AF_IPX, "127.0.0.1", &rst);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
ret = inet_pton(-1, "127.0.0.1", &rst);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_NET_3100
|
||||
* @tc.name : test inet_ntop IPv4 normal
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ActsNetTestSuite, testInetNtopIpv4Normal, Function | MediumTest | Level2)
|
||||
{
|
||||
const char *ret = NULL;
|
||||
struct in_addr inputAddr = {0};
|
||||
char rstBuff[INET_ADDRSTRLEN];
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
unsigned int inpLittle[4] = {0x64d43a0a, 0, 255, 4294967295}; /* 4, common data for test, no special meaning */
|
||||
#else
|
||||
unsigned int inpBig[4] = {171627620, 0, 4278190080, 4294967295}; /* 4, common data for test, no special meaning */
|
||||
#endif
|
||||
|
||||
char expAddrs[4][16] = {"10.58.212.100", "0.0.0.0", "255.0.0.0", "255.255.255.255"}; /* 4, 16, common data for test, no special meaning */
|
||||
for (int i = 0; i < 4; i++) { /* 4, common data for test, no special meaning */
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
inputAddr.s_addr = inpLittle[i];
|
||||
#else
|
||||
inputAddr.s_addr = inpBig[i];
|
||||
#endif
|
||||
ret = inet_ntop(AF_INET, &inputAddr, rstBuff, sizeof(rstBuff));
|
||||
if (ret == NULL) {
|
||||
ICUNIT_ASSERT_NOT_EQUAL(ret, NULL, ret);
|
||||
} else {
|
||||
ICUNIT_ASSERT_STRING_EQUAL(ret, expAddrs[i], ret);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(rstBuff, expAddrs[i], rstBuff);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_NET_3200
|
||||
* @tc.name : test inet_ntop IPv4 boundary input
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ActsNetTestSuite, testInetNtopIpv4Abnormal, Function | MediumTest | Level2)
|
||||
{
|
||||
const char *ret = NULL;
|
||||
struct in_addr inputAddr = {0};
|
||||
char rstBuff[INET_ADDRSTRLEN];
|
||||
char expStr[2][16] = {"255.255.255.255", "0.0.0.0"}; /* 2, 16, common data for test, no special meaning */
|
||||
for (int i = 0; i < 2; i++) { /* 2, common data for test, no special meaning */
|
||||
inputAddr.s_addr = (i == 0 ? -1 : 4294967296); /* -1, 4294967296, common data for test, no special meaning */
|
||||
ret = inet_ntop(AF_INET, &inputAddr, rstBuff, sizeof(rstBuff));
|
||||
ICUNIT_ASSERT_NOT_EQUAL(ret, NULL, ret);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(ret, expStr[i], ret);
|
||||
ICUNIT_ASSERT_STRING_EQUAL(rstBuff, expStr[i], rstBuff);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_NET_3500
|
||||
* @tc.name : test inet_ntop with invalid family
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ActsNetTestSuite, testInetNtopInvalidFamily, Function | MediumTest | Level2)
|
||||
{
|
||||
int iret;
|
||||
const char *ret = NULL;
|
||||
struct in6_addr inputAddr = {0};
|
||||
char rstBuff[INET6_ADDRSTRLEN];
|
||||
|
||||
iret = inet_pton(AF_INET6, "1::", &inputAddr);
|
||||
ICUNIT_ASSERT_EQUAL(iret, 1, iret); /* 1, common data for test, no special meaning */
|
||||
ret = inet_ntop(AF_IPX, &inputAddr, rstBuff, sizeof(rstBuff));
|
||||
ICUNIT_ASSERT_EQUAL(ret, NULL, ret);
|
||||
ret = inet_ntop(-1, &inputAddr, rstBuff, sizeof(rstBuff)); /* -1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(ret, NULL, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
RUN_TEST_SUITE(ActsNetTestSuite);
|
||||
|
||||
void ActsNetTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testIoctlIfhwAddr);
|
||||
RUN_ONE_TESTCASE(testSocketOpt);
|
||||
RUN_ONE_TESTCASE(testGetSocketNameInvalidInput);
|
||||
RUN_ONE_TESTCASE(testHostToNetwork);
|
||||
RUN_ONE_TESTCASE(testNetworkToHost);
|
||||
RUN_ONE_TESTCASE(testInetPtonIpv4Normal);
|
||||
RUN_ONE_TESTCASE(testInetPtonInvalidFamily);
|
||||
RUN_ONE_TESTCASE(testInetNtopIpv4Normal);
|
||||
RUN_ONE_TESTCASE(testInetNtopIpv4Abnormal);
|
||||
#if (LWIP_IPV6 == 1)
|
||||
RUN_ONE_TESTCASE(testInetPtonIpv6Normal);
|
||||
RUN_ONE_TESTCASE(testInetPtonIpv6Abnormal);
|
||||
RUN_ONE_TESTCASE(testInetNtopInvalidFamily);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef XTS_NET_H
|
||||
#define XTS_NET_H
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "if.h"
|
||||
#include "xts_test.h"
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <securec.h>
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <limits.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <poll.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ether.h>
|
||||
#include <net/if.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include "lwip/sockets.h"
|
||||
#include <sys/socket.h>
|
||||
|
||||
#endif
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
# Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_m/liteos.gni")
|
||||
|
||||
static_library("pthread_test") {
|
||||
sources = [
|
||||
"acts_process_api_test.c",
|
||||
"pthread_attr_test.c",
|
||||
"pthread_basic_api_test.c",
|
||||
"pthread_test.c",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
".",
|
||||
"$LITEOSTOPDIR/testsuites/include",
|
||||
"$LITEOSTOPDIR/testsuites/unittest/xts",
|
||||
]
|
||||
}
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "pthread_test.h"
|
||||
|
||||
LITE_TEST_SUIT(PROCESS, ProcessApi, ProcessApiTestSuite);
|
||||
|
||||
static BOOL ProcessApiTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL ProcessApiTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void *ThreadFunc(void* arg)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_NDKAPI_PROCESS_PTHREAD_SETNAME_NP_1000
|
||||
* @tc.name test pthread_setname_np api para stringlong
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ProcessApiTestSuite, testPthreadSetnameNp1000, Function | MediumTest | Level1) {
|
||||
pthread_t thisThread;
|
||||
int returnVal = pthread_create(&thisThread, NULL, ThreadFunc, NULL);
|
||||
returnVal = pthread_setname_np(thisThread, "funcThreadNamelongName");
|
||||
ICUNIT_ASSERT_NOT_EQUAL(returnVal, 0, returnVal);
|
||||
ICUNIT_ASSERT_EQUAL(returnVal, ERANGE, returnVal);
|
||||
return 0;
|
||||
}
|
||||
|
||||
RUN_TEST_SUITE(ProcessApiTestSuite);
|
||||
|
||||
void ActsProcessApiTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testPthreadSetnameNp1000);
|
||||
}
|
||||
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "pthread_test.h"
|
||||
|
||||
LITE_TEST_SUIT(PROCESS, PthreadAttr, PthreadAttrTestSuite);
|
||||
|
||||
static BOOL PthreadAttrTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL PthreadAttrTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_PTHREAD_ATTR_SETDETACHSTATE_0100
|
||||
* @tc.name basic test about pthread_attr_setdetachstate
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadAttrTestSuite, testPthreadAttrSetdetachstate, Function | MediumTest | Level3)
|
||||
{
|
||||
int ret;
|
||||
pthread_t tid;
|
||||
pthread_attr_t attr;
|
||||
int param;
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_attr_getdetachstate(&attr, ¶m);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(param, PTHREAD_CREATE_DETACHED, param);
|
||||
ret = pthread_create(&tid, &attr, ThreadPublic, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_attr_destroy(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_join(tid, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_attr_getdetachstate(&attr, ¶m);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(param, PTHREAD_CREATE_JOINABLE, param);
|
||||
ret = pthread_create(&tid, &attr, ThreadPublic, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_attr_destroy(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_join(tid, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_PTHREAD_ATTR_SETSTACKSIZE_0200
|
||||
* @tc.name test pthread_attr_setstacksize EINVAL
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadAttrTestSuite, testPthreadAttrSetstacksizeEINVAL, Function | MediumTest | Level3)
|
||||
{
|
||||
int ret;
|
||||
pthread_attr_t attr;
|
||||
size_t stackSize;
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_attr_getstacksize(&attr, &stackSize);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
stackSize = PTHREAD_STACK_MIN - 1; /* 1, common data for test, no special meaning */
|
||||
ret = pthread_attr_setstacksize(&attr, stackSize);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
ret = pthread_attr_destroy(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
RUN_TEST_SUITE(PthreadAttrTestSuite);
|
||||
|
||||
void PthreadAttrTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testPthreadAttrSetdetachstate);
|
||||
RUN_ONE_TESTCASE(testPthreadAttrSetstacksizeEINVAL);
|
||||
}
|
||||
|
||||
|
|
@ -1,222 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "pthread_test.h"
|
||||
|
||||
LITE_TEST_SUIT(PROCESS, PthreadBasicApi, PthreadBasicApiTestSuite);
|
||||
|
||||
static BOOL PthreadBasicApiTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL PthreadBasicApiTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void *ThreadPthreadCreateBasic(void *arg)
|
||||
{
|
||||
char *s = (char*)arg;
|
||||
ICUNIT_ASSERT_STRING_EQUAL(s, "1234567890 !@#$%^&*()_= ZXCVBNM [];'./>?:\" +-*/qwertyuiopasdfghjklzxcvbnm", s);
|
||||
return arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_PTHREAD_CREATE_0100
|
||||
* @tc.name pthread_create create a thread
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadBasicApiTestSuite, testPthreadCreateBasic, Function | MediumTest | Level2)
|
||||
{
|
||||
int ret;
|
||||
pthread_t tid;
|
||||
char str[] = "1234567890 !@#$%^&*()_= ZXCVBNM [];'./>?:\" +-*/qwertyuiopasdfghjklzxcvbnm";
|
||||
ret = pthread_create(&tid, NULL, ThreadPthreadCreateBasic, (void*)str);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_join(tid, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_PTHREAD_JOIN_0200
|
||||
* @tc.name Test the function of pthread_join to get the return value
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadBasicApiTestSuite, testJoinReturn, Function | MediumTest | Level3)
|
||||
{
|
||||
int ret;
|
||||
pthread_t tid;
|
||||
int num = 4; /* 4, common data for test, no special meaning */
|
||||
void *joinRe = NULL;
|
||||
ret = pthread_create(&tid, NULL, ThreadPublic, (void*)&num);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_join(tid, &joinRe);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
int *p = (int*)joinRe;
|
||||
ICUNIT_ASSERT_EQUAL(&num, p, &num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_PTHREAD_JOIN_0300
|
||||
* @tc.name Test the function about pthread_join, but child thread Exited
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadBasicApiTestSuite, testJoinExited, Function | MediumTest | Level3)
|
||||
{
|
||||
int ret;
|
||||
pthread_t tid;
|
||||
ret = pthread_create(&tid, NULL, ThreadPublic, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
usleep(50); /* 50, common data for test, no special meaning */
|
||||
ret = pthread_join(tid, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *ThreadPthreadExitThread(void *arg)
|
||||
{
|
||||
pthread_exit(arg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_PTHREAD_EXIT_0100
|
||||
* @tc.name Test the return function of pthread_exit in the child thread
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadBasicApiTestSuite, testPthreadExitThread, Function | MediumTest | Level3)
|
||||
{
|
||||
int ret;
|
||||
pthread_t tid;
|
||||
int num = 4; /* 4, common data for test, no special meaning */
|
||||
void *joinRe = NULL;
|
||||
ret = pthread_create(&tid, NULL, ThreadPthreadExitThread, (void*)&num);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_join(tid, &joinRe);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
int *p = (int*)joinRe;
|
||||
ICUNIT_ASSERT_EQUAL(&num, p, &num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FunPthreadExit(void *arg)
|
||||
{
|
||||
pthread_exit(arg);
|
||||
}
|
||||
|
||||
void *ThreadPthreadExitFunction(void *arg)
|
||||
{
|
||||
FunPthreadExit(arg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_PTHREAD_EXIT_0200
|
||||
* @tc.name Test the return function of pthread_exit in the child thread function
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadBasicApiTestSuite, testPthreadExitFunction, Function | MediumTest | Level3)
|
||||
{
|
||||
int ret;
|
||||
pthread_t tid;
|
||||
int num = 4; /* 4, common data for test, no special meaning */
|
||||
void *joinRe = NULL;
|
||||
ret = pthread_create(&tid, NULL, ThreadPthreadExitFunction, (void*)&num);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_join(tid, &joinRe);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
int *p = (int*)joinRe;
|
||||
ICUNIT_ASSERT_EQUAL(&num, p, &num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_PTHREAD_DETACH_0100
|
||||
* @tc.name Use pthread_detach to detach child threads
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadBasicApiTestSuite, testPthreadDetach, Function | MediumTest | Level3)
|
||||
{
|
||||
int ret;
|
||||
pthread_t tid;
|
||||
ret = pthread_create(&tid, NULL, ThreadPublic, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_detach(tid);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_join(tid, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *ThreadPthreadEqual(void *arg)
|
||||
{
|
||||
int ret;
|
||||
pthread_t *tid = (pthread_t*)arg;
|
||||
ret = pthread_equal(*tid, pthread_self());
|
||||
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
|
||||
usleep(10); /* 10, common data for test, no special meaning */
|
||||
return arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_PTHREAD_EQUAL_0100
|
||||
* @tc.name Use pthread_equal checks process equality
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadBasicApiTestSuite, testPthreadEqual, Function | MediumTest | Level3)
|
||||
{
|
||||
int ret;
|
||||
pthread_t tid;
|
||||
ret = pthread_create(&tid, NULL, ThreadPthreadEqual, (void*)&tid);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_equal(tid, pthread_self());
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ret = pthread_join(tid, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
RUN_TEST_SUITE(PthreadBasicApiTestSuite);
|
||||
|
||||
void PthreadBasicApiTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testPthreadCreateBasic);
|
||||
RUN_ONE_TESTCASE(testJoinReturn);
|
||||
RUN_ONE_TESTCASE(testJoinExited);
|
||||
RUN_ONE_TESTCASE(testPthreadExitThread);
|
||||
RUN_ONE_TESTCASE(testPthreadExitFunction);
|
||||
RUN_ONE_TESTCASE(testPthreadDetach);
|
||||
RUN_ONE_TESTCASE(testPthreadEqual);
|
||||
}
|
||||
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "xts_test.h"
|
||||
|
||||
void *ThreadPublic(void *arg)
|
||||
{
|
||||
usleep(10); /* 10, common data for test, no special meaning */
|
||||
return arg;
|
||||
}
|
||||
|
||||
void PthreadFuncTest(void)
|
||||
{
|
||||
ActsProcessApiTest();
|
||||
PthreadAttrTest();
|
||||
PthreadBasicApiTest();
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef XTS_PROCESS_H
|
||||
#define XTS_PROCESS_H
|
||||
|
||||
#include "xts_test.h"
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
#include <securec.h>
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <limits.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
extern void *ThreadPublic(void *arg);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
# Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_m/liteos.gni")
|
||||
|
||||
static_library("sched_test") {
|
||||
sources = [
|
||||
"process_sched_api_test.c",
|
||||
"pthread_sched_api_test.c",
|
||||
"sched_api_test.c",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
".",
|
||||
"$LITEOSTOPDIR/testsuites/include",
|
||||
"$LITEOSTOPDIR/testsuites/unittest/xts",
|
||||
]
|
||||
}
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "sched_api_test.h"
|
||||
|
||||
LITE_TEST_SUIT(SCHED, ProcessSchedApi, ProcessSchedApiTestSuite);
|
||||
|
||||
static BOOL ProcessSchedApiTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL ProcessSchedApiTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_SCHED_API_GET_PRIORITY_MAX_0200
|
||||
* @tc.name sched_get_priority_max api error test with unsupport policy.
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ProcessSchedApiTestSuite, testSchedGetPriorityMaxError0200, Function | MediumTest | Level3)
|
||||
{
|
||||
int invalidPolicy[] = {SCHED_FIFO, SCHED_OTHER, SCHED_BATCH, SCHED_IDLE, SCHED_DEADLINE, SCHED_RESET_ON_FORK};
|
||||
int testLoop = sizeof(invalidPolicy) / sizeof(int);
|
||||
for (int i = 0; i < testLoop; i++) {
|
||||
errno = 0;
|
||||
int prio = sched_get_priority_max(invalidPolicy[i]);
|
||||
ICUNIT_ASSERT_EQUAL(prio, -1, prio); /* -1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_SCHED_API_GET_PRIORITY_MAX_0300
|
||||
* @tc.name sched_get_priority_max api error test with invalid policy.
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ProcessSchedApiTestSuite, testSchedGetPriorityMaxError0300, Function | MediumTest | Level3)
|
||||
{
|
||||
int invalidPolicyVal;
|
||||
int prio;
|
||||
|
||||
invalidPolicyVal = -GetRandom(10000); /* 10000, common data for test, no special meaning */
|
||||
errno = 0;
|
||||
prio = sched_get_priority_max(invalidPolicyVal);
|
||||
ICUNIT_ASSERT_EQUAL(prio, -1, prio); /* -1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||
|
||||
invalidPolicyVal = GetRandom(10000) + SCHED_DEADLINE; /* 10000, common data for test, no special meaning */
|
||||
errno = 0;
|
||||
prio = sched_get_priority_max(invalidPolicyVal);
|
||||
ICUNIT_ASSERT_EQUAL(prio, -1, prio); /* -1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_SCHED_API_GET_PRIORITY_MIN_0200
|
||||
* @tc.name sched_get_priority_min api error test with unsupport policy.
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ProcessSchedApiTestSuite, testSchedGetPriorityMinError0200, Function | MediumTest | Level3)
|
||||
{
|
||||
int invalidPolicy[] = {SCHED_FIFO, SCHED_OTHER, SCHED_BATCH, SCHED_IDLE, SCHED_DEADLINE, SCHED_RESET_ON_FORK};
|
||||
int testLoop = sizeof(invalidPolicy) / sizeof(int);
|
||||
for (int i = 0; i < testLoop; i++) {
|
||||
errno = 0;
|
||||
int prio = sched_get_priority_min(invalidPolicy[i]);
|
||||
ICUNIT_ASSERT_EQUAL(prio, -1, prio); /* -1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_SCHED_API_GET_PRIORITY_MIN_0300
|
||||
* @tc.name sched_get_priority_min api error test with invalid policy.
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(ProcessSchedApiTestSuite, testSchedGetPriorityMinError0300, Function | MediumTest | Level3)
|
||||
{
|
||||
int invalidPolicyVal;
|
||||
int prio;
|
||||
invalidPolicyVal = -GetRandom(10000); /* 10000, common data for test, no special meaning */
|
||||
errno = 0;
|
||||
prio = sched_get_priority_min(invalidPolicyVal);
|
||||
ICUNIT_ASSERT_EQUAL(prio, -1, prio); /* -1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||
|
||||
invalidPolicyVal = GetRandom(10000) + SCHED_DEADLINE; /* 10000, common data for test, no special meaning */
|
||||
errno = 0;
|
||||
prio = sched_get_priority_min(invalidPolicyVal);
|
||||
ICUNIT_ASSERT_EQUAL(prio, -1, prio); /* -1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
RUN_TEST_SUITE(ProcessSchedApiTestSuite);
|
||||
|
||||
void ProcessSchedApiTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testSchedGetPriorityMaxError0200);
|
||||
RUN_ONE_TESTCASE(testSchedGetPriorityMaxError0300);
|
||||
RUN_ONE_TESTCASE(testSchedGetPriorityMinError0200);
|
||||
RUN_ONE_TESTCASE(testSchedGetPriorityMinError0300);
|
||||
}
|
||||
|
|
@ -1,243 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "sched_api_test.h"
|
||||
|
||||
LITE_TEST_SUIT(SCHED, PthreadSchedApi, PthreadSchedApiTestSuite);
|
||||
|
||||
static int g_policy = 0;
|
||||
static int g_prioriy = 0;
|
||||
|
||||
static BOOL PthreadSchedApiTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL PthreadSchedApiTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_SCHED_API_PATTR_INHERIT_0100
|
||||
* @tc.name test the default value of inheritsched.
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrGetInheritsched, Function | MediumTest | Level1)
|
||||
{
|
||||
int ret;
|
||||
pthread_attr_t attr;
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
int inheritsched = -1; /* -1, common data for test, no special meaning */
|
||||
int rt = pthread_attr_getinheritsched(&attr, &inheritsched);
|
||||
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
|
||||
ICUNIT_ASSERT_EQUAL(inheritsched, PTHREAD_INHERIT_SCHED, inheritsched);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_SCHED_API_PATTR_INHERIT_0200
|
||||
* @tc.name test set and get inheritsched.
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrSetInheritsched, Function | MediumTest | Level1)
|
||||
{
|
||||
int ret;
|
||||
pthread_attr_t attr;
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
int rt = pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
|
||||
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
|
||||
int inheritsched = -1; /* -1, common data for test, no special meaning */
|
||||
rt = pthread_attr_getinheritsched(&attr, &inheritsched);
|
||||
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
|
||||
ICUNIT_ASSERT_EQUAL(inheritsched, PTHREAD_INHERIT_SCHED, inheritsched);
|
||||
|
||||
rt = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
|
||||
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
|
||||
inheritsched = -1; /* -1, common data for test, no special meaning */
|
||||
rt = pthread_attr_getinheritsched(&attr, &inheritsched);
|
||||
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
|
||||
ICUNIT_ASSERT_EQUAL(inheritsched, PTHREAD_EXPLICIT_SCHED, inheritsched);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_SCHED_API_PATTR_INHERIT_0300
|
||||
* @tc.name pthread_attr_setinheritsched error test.
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrSetInheritschedError, Function | MediumTest | Level1)
|
||||
{
|
||||
int ret;
|
||||
pthread_attr_t attr;
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
int n = -GetRandom(100); /* 100, common data for test, no special meaning */
|
||||
int rt = pthread_attr_setinheritsched(&attr, n);
|
||||
ICUNIT_ASSERT_EQUAL(rt, EINVAL, rt);
|
||||
n = 2 + GetRandom(100); /* 2, 100, common data for test, no special meaning */
|
||||
rt = pthread_attr_setinheritsched(&attr, n);
|
||||
ICUNIT_ASSERT_EQUAL(rt, EINVAL, rt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_SCHED_API_PATTR_SCHEDPARAM_0200
|
||||
* @tc.name test set and get sched param.
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrSetSchedParam, Function | MediumTest | Level1)
|
||||
{
|
||||
int ret;
|
||||
pthread_attr_t attr;
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
struct sched_param param = {0};
|
||||
int rt = pthread_attr_getschedparam(&attr, ¶m);
|
||||
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
|
||||
|
||||
param.sched_priority = 22; /* 22, common data for test, no special meaning */
|
||||
rt = pthread_attr_setschedparam(&attr, ¶m);
|
||||
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
|
||||
|
||||
rt = pthread_attr_getschedparam(&attr, ¶m);
|
||||
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
|
||||
ICUNIT_ASSERT_EQUAL(param.sched_priority, 22, param.sched_priority); /* 22, common data for test, no special meaning */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_SCHED_API_PATTR_SCHEDPOLICY_0100
|
||||
* @tc.name test the default value of sched policy.
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrGetSchedPolicy, Function | MediumTest | Level1)
|
||||
{
|
||||
int ret;
|
||||
pthread_attr_t attr;
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
int policy = -1; /* -1, common data for test, no special meaning */
|
||||
int rt = pthread_attr_getschedpolicy(&attr, &policy);
|
||||
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
|
||||
ICUNIT_ASSERT_EQUAL(policy, SCHED_RR, policy);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_SCHED_API_PATTR_SCHEDPOLICY_0300
|
||||
* @tc.name pthread_attr_setschedpolicy error test.
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrSetSchedPolicyError, Function | MediumTest | Level1)
|
||||
{
|
||||
int ret;
|
||||
pthread_attr_t attr;
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
int rt;
|
||||
|
||||
int invalidPolicy[7] = {SCHED_OTHER, SCHED_BATCH, SCHED_IDLE, SCHED_DEADLINE, SCHED_RESET_ON_FORK}; /* 7, common data for test, no special meaning */
|
||||
invalidPolicy[5] = -GetRandom(10000); /* 5, 10000, common data for test, no special meaning */
|
||||
invalidPolicy[6] = GetRandom(10000) + 6; /* 6, 10000, common data for test, no special meaning */
|
||||
for (int i = 0; i < 7; i++) { /* 7, common data for test, no special meaning */
|
||||
rt = pthread_attr_setschedpolicy(&attr, invalidPolicy[i]);
|
||||
ICUNIT_ASSERT_EQUAL(rt, EINVAL, rt);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_SCHED_API_PATTR_SCOPE_0100
|
||||
* @tc.name test the default value of sched scope.
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrGetScope, Function | MediumTest | Level1)
|
||||
{
|
||||
int ret;
|
||||
pthread_attr_t attr;
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
int scope = -1; /* -1, common data for test, no special meaning */
|
||||
int rt = pthread_attr_getscope(&attr, &scope);
|
||||
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
|
||||
ICUNIT_ASSERT_EQUAL(scope, PTHREAD_SCOPE_SYSTEM, scope);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_SCHED_API_PATTR_SCOPE_0200
|
||||
* @tc.name test set and get scope.
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(PthreadSchedApiTestSuite, testAttrSetScope, Function | MediumTest | Level1)
|
||||
{
|
||||
int ret;
|
||||
pthread_attr_t attr;
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
int rt = pthread_attr_setscope(&attr, PTHREAD_SCOPE_PROCESS);
|
||||
ICUNIT_ASSERT_EQUAL(rt, ENOTSUP, rt);
|
||||
|
||||
rt = pthread_attr_setscope(&attr, -GetRandom(10000)); /* 10000, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(rt, EINVAL, rt);
|
||||
|
||||
rt = pthread_attr_setscope(&attr, GetRandom(10000) + 2); /* 2, 10000, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(rt, EINVAL, rt);
|
||||
|
||||
int scope = -1; /* -1, common data for test, no special meaning */
|
||||
rt = pthread_attr_getscope(&attr, &scope);
|
||||
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
|
||||
ICUNIT_ASSERT_EQUAL(scope, PTHREAD_SCOPE_SYSTEM, scope);
|
||||
return 0;
|
||||
}
|
||||
|
||||
RUN_TEST_SUITE(PthreadSchedApiTestSuite);
|
||||
|
||||
void PthreadSchedApiTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testAttrGetInheritsched);
|
||||
RUN_ONE_TESTCASE(testAttrSetInheritsched);
|
||||
RUN_ONE_TESTCASE(testAttrSetInheritschedError);
|
||||
RUN_ONE_TESTCASE(testAttrSetSchedParam);
|
||||
RUN_ONE_TESTCASE(testAttrGetSchedPolicy);
|
||||
RUN_ONE_TESTCASE(testAttrSetSchedPolicyError);
|
||||
RUN_ONE_TESTCASE(testAttrGetScope);
|
||||
RUN_ONE_TESTCASE(testAttrSetScope);
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "xts_test.h"
|
||||
|
||||
void SchedApiFuncTest(void)
|
||||
{
|
||||
ProcessSchedApiTest();
|
||||
PthreadSchedApiTest();
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef XTS_SCHED_H
|
||||
#define XTS_SCHED_H
|
||||
|
||||
#include "xts_test.h"
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/resource.h>
|
||||
#include <fcntl.h>
|
||||
#include <semaphore.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#endif
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
# Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_m/liteos.gni")
|
||||
|
||||
static_library("system_test") {
|
||||
sources = [ "sys_api_test.c" ]
|
||||
|
||||
include_dirs = [
|
||||
".",
|
||||
"$LITEOSTOPDIR/testsuites/include",
|
||||
"$LITEOSTOPDIR/testsuites/unittest/xts",
|
||||
]
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef XTS_SYS_API_H
|
||||
#define XTS_SYS_API_H
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
#include <search.h>
|
||||
#include <err.h>
|
||||
#include <regex.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#endif
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "sys_api.h"
|
||||
#include "xts_test.h"
|
||||
|
||||
LITE_TEST_SUIT(SYSTEM, SysApiTest, SysApiTestSuite);
|
||||
|
||||
static BOOL SysApiTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL SysApiTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_SYS_STRERROR_0100
|
||||
* @tc.name test strerror
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(SysApiTestSuite, testStrerror, Function | MediumTest | Level1)
|
||||
{
|
||||
ICUNIT_ASSERT_STRING_EQUAL(strerror(-1), "No error information", strerror(-1)); /* -1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_STRING_EQUAL(strerror(0), "No error information", strerror(0));
|
||||
ICUNIT_ASSERT_STRING_EQUAL(strerror(2), "No such file or directory", strerror(2)); /* 2, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_STRING_EQUAL(strerror(10), "No child process", strerror(10)); /* 10, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_STRING_EQUAL(strerror(65536), "No error information", strerror(65536)); /* 65536, common data for test, no special meaning */
|
||||
}
|
||||
|
||||
RUN_TEST_SUITE(SysApiTestSuite);
|
||||
|
||||
void SysApiFuncTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testStrerror);
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
# Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_m/liteos.gni")
|
||||
|
||||
static_library("time_test") {
|
||||
sources = [
|
||||
"alarm_test.c",
|
||||
"clock_time_test.c",
|
||||
"sleep_test.c",
|
||||
"time_utils_test.c",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
".",
|
||||
"$LITEOSTOPDIR/testsuites/include",
|
||||
"$LITEOSTOPDIR/testsuites/unittest/xts",
|
||||
]
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "xts_test.h"
|
||||
#include "alarm_test.h"
|
||||
|
||||
LITE_TEST_SUIT(TIME, TimeAlarmTest, TimeAlarmTestSuite);
|
||||
|
||||
static BOOL TimeAlarmTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL TimeAlarmTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_TIME_API_TIMER_CREATE_0500
|
||||
* @tc.name timer_create function errno for EINVAL test
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(TimeAlarmTestSuite, testTimerCreateEINVAL, Function | MediumTest | Level4)
|
||||
{
|
||||
int ret;
|
||||
timer_t tid = NULL;
|
||||
clockid_t clockid = GetRandom(2048); /* 2048, common data for test, no special meaning */
|
||||
ret = timer_create(clockid, NULL, &tid);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
RUN_TEST_SUITE(TimeAlarmTestSuite);
|
||||
|
||||
void AlarmTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testTimerCreateEINVAL);
|
||||
}
|
||||
|
||||
void TimeFuncTest(void)
|
||||
{
|
||||
AlarmTest();
|
||||
ClockTimeTest();
|
||||
SleepTest();
|
||||
TimeUtilsTest();
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef TIME_ALARM_TEST_H
|
||||
#define TIME_ALARM_TEST_H
|
||||
#define _GNU_SOURCE
|
||||
#include "xts_test.h"
|
||||
#include <signal.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/timeb.h>
|
||||
#include <sys/times.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define SECS_PER_MIN 60
|
||||
#define INIT_TM(tmSt, year, mon, day, hour, min, sec, wday) do { \
|
||||
(tmSt).tm_sec = (sec); \
|
||||
(tmSt).tm_min = (min); \
|
||||
(tmSt).tm_hour = (hour); \
|
||||
(tmSt).tm_mday = (day); \
|
||||
(tmSt).tm_mon = (mon); \
|
||||
(tmSt).tm_year = (year) - 1900; \
|
||||
(tmSt).tm_wday = wday; \
|
||||
(tmSt).__tm_gmtoff = 0; \
|
||||
(tmSt).__tm_zone = ""; \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
|
@ -1,148 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "alarm_test.h"
|
||||
|
||||
LITE_TEST_SUIT(TIME, TimeClockTimeTest, TimeClockTimeTestSuite);
|
||||
|
||||
static BOOL TimeClockTimeTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL TimeClockTimeTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_TIME_API_CLOCK_GETTIME_0100
|
||||
* @tc.name test all supported clockid of clock_gettime
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(TimeClockTimeTestSuite, testClockGettimeAll, Function | MediumTest | Level1)
|
||||
{
|
||||
clockid_t cid = CLOCK_REALTIME;
|
||||
struct timespec time1 = {0, 0};
|
||||
int rt = clock_gettime(cid, &time1);
|
||||
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_TIME_API_CLOCK_SETTIME_0100
|
||||
* @tc.name test clock_settime basic
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(TimeClockTimeTestSuite, testClockSettime, Function | MediumTest | Level1)
|
||||
{
|
||||
struct timespec time1 = {0, 0};
|
||||
sleep(1); /* 1, common data for test, no special meaning */
|
||||
int rt = clock_gettime(CLOCK_REALTIME, &time1);
|
||||
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
|
||||
time_t sec = time1.tv_sec;
|
||||
time1.tv_sec -= 1; /* 1, common data for test, no special meaning */
|
||||
time1.tv_nsec = 1; /* 1, common data for test, no special meaning */
|
||||
rt = clock_settime(CLOCK_REALTIME, &time1);
|
||||
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
|
||||
sleep(1); /* 1, common data for test, no special meaning */
|
||||
rt = clock_gettime(CLOCK_REALTIME, &time1);
|
||||
ICUNIT_ASSERT_EQUAL(rt, 0, rt);
|
||||
ICUNIT_ASSERT_EQUAL(time1.tv_sec, sec, time1.tv_sec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_TIME_API_GETTIMEOFDAY_0100
|
||||
* @tc.name test gettimeofday api
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(TimeClockTimeTestSuite, testGettimeofday, Function | MediumTest | Level1)
|
||||
{
|
||||
int ret;
|
||||
int sleepSec = 1; /* 1, common data for test, no special meaning */
|
||||
struct timeval tValStart = {0};
|
||||
struct timeval tValEnd = {0};
|
||||
struct timezone tZone;
|
||||
|
||||
int ret1 = gettimeofday(&tValStart, &tZone);
|
||||
sleep(sleepSec);
|
||||
int ret2 = gettimeofday(&tValEnd, &tZone);
|
||||
ICUNIT_ASSERT_EQUAL(ret1, 0, ret1);
|
||||
ICUNIT_ASSERT_EQUAL(ret2, 0, ret2);
|
||||
|
||||
ret = (int)(tValEnd.tv_sec - tValStart.tv_sec);
|
||||
ICUNIT_ASSERT_EQUAL(ret, sleepSec, ret);
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL(ret, sleepSec, INT_MAX, ret);
|
||||
ret = (int)(tValEnd.tv_sec - tValStart.tv_sec);
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL(ret, INT_MIN, sleepSec + 1, ret); /* 1, common data for test, no special meaning */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_TIME_API_SETTIMEOFDAY_0100
|
||||
* @tc.name test settimeofday api
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(TimeClockTimeTestSuite, testSettimeofday, Function | MediumTest | Level1)
|
||||
{
|
||||
int ret;
|
||||
int setSec = 100; /* 100, common data for test, no special meaning */
|
||||
int sleepSec = 2; /* 2, common data for test, no special meaning */
|
||||
struct timeval tValStart = {0};
|
||||
struct timeval tValEnd = {0};
|
||||
struct timeval set = {.tv_sec = setSec, .tv_usec = 0};
|
||||
|
||||
int ret1 = settimeofday(&set, NULL);
|
||||
int ret2 = gettimeofday(&tValStart, NULL);
|
||||
sleep(sleepSec);
|
||||
int ret3 = gettimeofday(&tValEnd, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret1, 0, ret1);
|
||||
ICUNIT_ASSERT_EQUAL(ret2, 0, ret2);
|
||||
ICUNIT_ASSERT_EQUAL(ret3, 0, ret3);
|
||||
ICUNIT_ASSERT_EQUAL(tValStart.tv_sec, setSec, tValStart.tv_sec);
|
||||
|
||||
ret = (int)(tValEnd.tv_sec - tValStart.tv_sec);
|
||||
ICUNIT_ASSERT_EQUAL(ret, sleepSec, ret);
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL(ret, sleepSec, INT_MAX, ret);
|
||||
ret = (int)(tValEnd.tv_sec - tValStart.tv_sec);
|
||||
ICUNIT_ASSERT_WITHIN_EQUAL(ret, INT_MIN, sleepSec + 1, ret); /* 1, common data for test, no special meaning */
|
||||
return 0;
|
||||
}
|
||||
|
||||
RUN_TEST_SUITE(TimeClockTimeTestSuite);
|
||||
|
||||
void ClockTimeTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testClockGettimeAll);
|
||||
RUN_ONE_TESTCASE(testClockSettime);
|
||||
RUN_ONE_TESTCASE(testGettimeofday);
|
||||
RUN_ONE_TESTCASE(testSettimeofday);
|
||||
}
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "alarm_test.h"
|
||||
|
||||
static const char *ALL_CLOCKS_NAME[CLOCK_TAI + 1] = {
|
||||
"CLOCK_REALTIME",
|
||||
"CLOCK_MONOTONIC",
|
||||
"CLOCK_PROCESS_CPUTIME_ID",
|
||||
"CLOCK_THREAD_CPUTIME_ID",
|
||||
"CLOCK_MONOTONIC_RAW",
|
||||
"CLOCK_REALTIME_COARSE",
|
||||
"CLOCK_MONOTONIC_COARSE",
|
||||
"CLOCK_BOOTTIME",
|
||||
"CLOCK_REALTIME_ALARM",
|
||||
"CLOCK_BOOTTIME_ALARM",
|
||||
"CLOCK_SGI_CYCLE",
|
||||
"CLOCK_TAI",
|
||||
};
|
||||
|
||||
LITE_TEST_SUIT(TIME, TimeSleepTest, TimeSleepTestSuite);
|
||||
|
||||
static BOOL TimeSleepTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL TimeSleepTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_TIME_API_CLOCK_NANOSLEEP_0200
|
||||
* @tc.name clock_nanosleep fail test - non-support clock_id
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(TimeSleepTestSuite, testClockNanosleepInvalidID, Reliability | SmallTest | Level2)
|
||||
{
|
||||
clockid_t cid = 1; /* 1, common data for test, no special meaning */
|
||||
const char *cname = ALL_CLOCKS_NAME[cid];
|
||||
struct timespec req = {0, 100}; /* 100, common data for test, no special meaning */
|
||||
struct timespec rem = {0};
|
||||
int rt = clock_nanosleep(cid, 0, &req, &rem);
|
||||
if (cid == CLOCK_SGI_CYCLE) {
|
||||
ICUNIT_ASSERT_EQUAL(rt, EINVAL, rt);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_TIME_API_CLOCK_NANOSLEEP_0300
|
||||
* @tc.name clock_nanosleep fail test - invalid parameter
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(TimeSleepTestSuite, testClockNanosleepInvalidPara, Reliability | SmallTest | Level2)
|
||||
{
|
||||
struct timespec req = {0, 100}; /* 100, common data for test, no special meaning */
|
||||
struct timespec rem = {0};
|
||||
int rt;
|
||||
|
||||
int id = GetRandom(1000) + 12; /* 1000, 12, common data for test, no special meaning */
|
||||
rt = clock_nanosleep(id, 0, &req, &rem);
|
||||
ICUNIT_ASSERT_EQUAL(rt, EINVAL, rt);
|
||||
|
||||
id = -GetRandom(1000) - 12; /* 1000, 12, common data for test, no special meaning */
|
||||
rt = clock_nanosleep(id, 0, &req, &rem);
|
||||
ICUNIT_ASSERT_EQUAL(rt, EINVAL, rt);
|
||||
|
||||
int flag = TIMER_ABSTIME;
|
||||
rt = clock_nanosleep(CLOCK_REALTIME, flag, &req, &rem);
|
||||
ICUNIT_ASSERT_EQUAL(rt, ENOTSUP, rt);
|
||||
flag = GetRandom(100) + 1; /* 100, 1, common data for test, no special meaning */
|
||||
rt = clock_nanosleep(CLOCK_REALTIME, flag, &req, &rem);
|
||||
ICUNIT_ASSERT_EQUAL(rt, EINVAL, rt);
|
||||
flag = -GetRandom(100) - 1; /* 100, 1, common data for test, no special meaning */
|
||||
rt = clock_nanosleep(CLOCK_REALTIME, flag, &req, &rem);
|
||||
ICUNIT_ASSERT_EQUAL(rt, EINVAL, rt);
|
||||
|
||||
req.tv_sec = -1; /* -1, common data for test, no special meaning */
|
||||
req.tv_nsec = 1; /* 1, common data for test, no special meaning */
|
||||
rt = clock_nanosleep(CLOCK_REALTIME, 0, &req, &rem);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||
req.tv_sec = 1; /* 1, common data for test, no special meaning */
|
||||
req.tv_nsec = -1; /* -1, common data for test, no special meaning */
|
||||
rt = clock_nanosleep(CLOCK_REALTIME, 0, &req, &rem);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||
req.tv_sec = 1; /* 1, common data for test, no special meaning */
|
||||
req.tv_nsec = 1000 * 1000 * 1000 + 1; /* 1000, 1, common data for test, no special meaning */
|
||||
rt = clock_nanosleep(CLOCK_REALTIME, 0, &req, &rem);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
RUN_TEST_SUITE(TimeSleepTestSuite);
|
||||
|
||||
void SleepTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testClockNanosleepInvalidID);
|
||||
RUN_ONE_TESTCASE(testClockNanosleepInvalidPara);
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "alarm_test.h"
|
||||
|
||||
time_t g_time = 18880; /* 18880, common data for test, no special meaning */
|
||||
size_t g_zero = 0;
|
||||
|
||||
LITE_TEST_SUIT(TIME, TimeUtilsTest, TimeUtilsTestSuite);
|
||||
|
||||
static BOOL TimeUtilsTestSuiteSetUp(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL TimeUtilsTestSuiteTearDown(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number SUB_KERNEL_TIME_API_MKTIME_0100
|
||||
* @tc.name test mktime api
|
||||
* @tc.desc [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(TimeUtilsTestSuite, testMktime, Function | MediumTest | Level2)
|
||||
{
|
||||
struct tm *localTime = NULL;
|
||||
struct tm timeptr = {0};
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
|
||||
int ret = gettimeofday(&tv, &tz);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
long sysTimezone = (long)(-tz.tz_minuteswest) * SECS_PER_MIN;
|
||||
|
||||
INIT_TM(timeptr, 2000, 6, 9, 10, 10, 0, 7); /* 2000, 6, 9, 10, 7, common data for test, no special meaning */
|
||||
time_t timeRet = mktime(&timeptr);
|
||||
ICUNIT_ASSERT_EQUAL(sysTimezone, timeptr.__tm_gmtoff, sysTimezone);
|
||||
ICUNIT_ASSERT_EQUAL(timeRet, 963137400 - timeptr.__tm_gmtoff, timeRet); /* 963137400, common data for test, no special meaning */
|
||||
localTime = localtime(&g_time);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(localTime, NULL, localTime);
|
||||
time_t timep = mktime(localTime);
|
||||
ICUNIT_ASSERT_EQUAL(timep, 18880, timep); /* 18880, common data for test, no special meaning */
|
||||
return 0;
|
||||
}
|
||||
|
||||
RUN_TEST_SUITE(TimeUtilsTestSuite);
|
||||
|
||||
void TimeUtilsTest(void)
|
||||
{
|
||||
RUN_ONE_TESTCASE(testMktime);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue