Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
alios-things
AliOS-Things
提交
a99f2070
A
AliOS-Things
项目概览
alios-things
/
AliOS-Things
8 个月 前同步成功
通知
61
Star
8
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
AliOS-Things
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a99f2070
编写于
7月 04, 2023
作者:
青
青杠
提交者:
YiluMao
7月 04, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add backlight/button/lcd/uvoice/unzip test cases
上级
beed5e1d
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
662 addition
and
25 deletion
+662
-25
test/testcase/backlight_test/backlight_test.c
test/testcase/backlight_test/backlight_test.c
+56
-0
test/testcase/backlight_test/function/backlight_test_device.c
.../testcase/backlight_test/function/backlight_test_device.c
+60
-0
test/testcase/button_test/button_test.c
test/testcase/button_test/button_test.c
+39
-0
test/testcase/button_test/function/button_test_device.c
test/testcase/button_test/function/button_test_device.c
+40
-0
test/testcase/kv_test/function/kv_test_device.c
test/testcase/kv_test/function/kv_test_device.c
+1
-21
test/testcase/kv_test/kv_test.c
test/testcase/kv_test/kv_test.c
+4
-4
test/testcase/lcd_test/function/lcd_test_device.c
test/testcase/lcd_test/function/lcd_test_device.c
+68
-0
test/testcase/lcd_test/lcd_test.c
test/testcase/lcd_test/lcd_test.c
+58
-0
test/testcase/unzip/aos_unzip_test.c
test/testcase/unzip/aos_unzip_test.c
+104
-0
test/testcase/unzip/unzip_test.c
test/testcase/unzip/unzip_test.c
+35
-0
test/testcase/uvoice_test/function/pcm_test_device.c
test/testcase/uvoice_test/function/pcm_test_device.c
+129
-0
test/testcase/uvoice_test/uvoice_test.c
test/testcase/uvoice_test/uvoice_test.c
+68
-0
未找到文件。
test/testcase/backlight_test/backlight_test.c
0 → 100644
浏览文件 @
a99f2070
/*
* Copyright (C) 2020-2023 Alibaba Group Holding Limited
*/
#include <stdio.h>
#include <sched.h>
#include <pthread.h>
#include <yunit/yunit.h>
extern
void
backlight_test_init
(
void
);
extern
void
backlight_test_onoff
(
void
);
extern
void
backlight_test_silent_reset
(
void
);
extern
void
backlight_test_get_status
(
void
);
static
int
init
(
void
)
{
return
0
;
}
static
int
cleanup
(
void
)
{
return
0
;
}
static
void
setup
(
void
)
{
}
static
void
teardown
(
void
)
{
}
static
void
setup_pri_save
(
void
)
{
}
static
void
teardown_pri_restore
(
void
)
{
}
static
yunit_test_case_t
aos_backlight_testcases
[]
=
{
{
"backlight_test_init"
,
backlight_test_init
},
{
"backlight_test_onoff"
,
backlight_test_onoff
},
{
"backlight_test_silent_reset"
,
backlight_test_silent_reset
},
{
"backlight_test_get_status"
,
backlight_test_get_status
},
YUNIT_TEST_CASE_NULL
};
static
yunit_test_suite_t
suites
[]
=
{
{
"backlight"
,
init
,
cleanup
,
setup
,
teardown
,
aos_backlight_testcases
},
YUNIT_TEST_SUITE_NULL
};
void
aos_backlight_test
(
void
)
{
yunit_add_test_suites
(
suites
);
}
AOS_TESTCASE
(
aos_backlight_test
);
test/testcase/backlight_test/function/backlight_test_device.c
0 → 100644
浏览文件 @
a99f2070
/*
* Copyright (C) 2015-2023 Alibaba Group Holding Limited
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <yunit/yunit.h>
#include "aos/kernel.h"
/* module name used by log print*/
#define MODULE_NAME "backlight_test"
/* test backlight init */
void
backlight_test_init
(
void
)
{
int
ret
;
ret
=
aos_lcd_backlight_on
();
for
(
uint8_t
i
=
0
;
i
<
5
;
i
++
)
{
ret
=
aos_lcd_backlight
(
i
*
20
);
aos_lcd_backlight_valid
();
aos_msleep
(
2000
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
}
}
/* test backlight onoff */
void
backlight_test_onoff
(
void
)
{
int
ret
;
aos_lcd_backlight_off
();
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
aos_msleep
(
2000
);
aos_lcd_backlight_on
();
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
aos_msleep
(
2000
);
aos_lcd_backlight_toggle
();
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
aos_msleep
(
2000
);
}
/* test backlight silent_reset */
void
backlight_test_silent_reset
(
void
)
{
int
ret
;
ret
=
aos_lcd_backlight
(
5
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
aos_lcd_backlight_valid_for_silent_reset
();
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
}
/* test backlight get_status */
void
backlight_test_get_status
(
void
)
{
int
ret
;
uint8_t
onoff
,
level
;
ret
=
aos_lcd_backlight_status
(
&
onoff
,
&
level
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
printf
(
"[%s] backlight status onoff=%d level=%d
\n
"
,
MODULE_NAME
,
onoff
,
level
);
}
test/testcase/button_test/button_test.c
0 → 100644
浏览文件 @
a99f2070
/*
* Copyright (C) 2020-2023 Alibaba Group Holding Limited
*/
#include <stdio.h>
#include <yunit/yunit.h>
extern
void
button_test_init
(
void
);
static
int
init
(
void
)
{
return
0
;
}
static
int
cleanup
(
void
)
{
return
0
;
}
static
void
setup
(
void
)
{
}
static
void
teardown
(
void
)
{
}
static
yunit_test_case_t
aos_button_testcases
[]
=
{
{
"button_test_init"
,
button_test_init
},
YUNIT_TEST_CASE_NULL
};
static
yunit_test_suite_t
suites
[]
=
{
{
"button"
,
init
,
cleanup
,
setup
,
teardown
,
aos_button_testcases
},
YUNIT_TEST_SUITE_NULL
};
void
aos_button_test
(
void
)
{
yunit_add_test_suites
(
suites
);
}
AOS_TESTCASE
(
aos_button_test
);
\ No newline at end of file
test/testcase/button_test/function/button_test_device.c
0 → 100644
浏览文件 @
a99f2070
/*
* Copyright (C) 2015-2023 Alibaba Group Holding Limited
*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "aos/kernel.h"
#include <aos_button.h>
#include <yunit/yunit.h>
/* module name used by log print*/
#define MODULE_NAME "button_test"
/* module parameters */
aos_key_cfg_t
button_cfg
;
static
uint8_t
button_short_press_flag
=
0
;
static
uint8_t
button_long_press_flag
=
0
;
static
void
_short_press_handler
()
{
button_short_press_flag
=
1
;
}
static
void
_long_press_handler
()
{
button_long_press_flag
=
1
;
}
/* test button init */
void
button_test_init
(
void
)
{
int
ret
;
button_cfg
.
short_press_max_ms
=
500
;
button_cfg
.
long_press_min_ms
=
1000
;
button_cfg
.
short_press_handler
=
_short_press_handler
;
button_cfg
.
long_press_handler
=
_long_press_handler
;
ret
=
aos_key_init
(
button_cfg
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
printf
(
"please short press button"
);
aos_msleep
(
2000
);
YUNIT_ASSERT_EQUAL
(
button_short_press_flag
,
1
);
printf
(
"please long press button for 1s"
);
aos_msleep
(
2000
);
YUNIT_ASSERT_EQUAL
(
button_long_press_flag
,
1
);
}
\ No newline at end of file
test/testcase/kv_test/function/kv_test_device.c
浏览文件 @
a99f2070
...
...
@@ -24,30 +24,10 @@ static uint8_t sem_flag = 0;
void
kv_test_init
(
void
)
{
int
ret
;
//
ret=aos_hal_flash_init(HAL_PARTITION_APPLICATION);
ret
=
aos_hal_flash_init
(
HAL_PARTITION_APPLICATION
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
}
#if 0
/* test kv item */
void kv_test_item(void)
{
int ret;
int set_len = strlen(test_val);
int get_len;
char get_value[32] = {0};
ret = kv_item_set(test_key, test_val, set_len, 1); /* set kv item */
YUNIT_ASSERT_EQUAL(ret, 0);
ret = kv_item_get(test_key, get_value, &get_len); /* get kv item */
YUNIT_ASSERT_EQUAL(ret, 0);
YUNIT_ASSERT_EQUAL(get_len, set_len);
ret = strcmp(get_value, test_val);
YUNIT_ASSERT_EQUAL(ret, 0);
ret = kv_item_delete(test_key); /* del kv item */
YUNIT_ASSERT_EQUAL(ret, 0);
}
#endif
/* test kv flash */
void
kv_test_flash
(
void
)
{
...
...
test/testcase/kv_test/kv_test.c
浏览文件 @
a99f2070
...
...
@@ -39,10 +39,10 @@ static void teardown_pri_restore(void)
}
static
yunit_test_case_t
aos_kv_testcases
[]
=
{
//
{ "kv_test_init", kv_test_init},
//
{ "kv_test_flash", kv_test_flash},
//
{ "kv_test_lock", kv_test_lock},
//
{ "kv_test_malloc", kv_test_malloc},
{
"kv_test_init"
,
kv_test_init
},
{
"kv_test_flash"
,
kv_test_flash
},
{
"kv_test_lock"
,
kv_test_lock
},
{
"kv_test_malloc"
,
kv_test_malloc
},
{
"kv_test_task"
,
kv_test_task
},
YUNIT_TEST_CASE_NULL
};
...
...
test/testcase/lcd_test/function/lcd_test_device.c
0 → 100644
浏览文件 @
a99f2070
/*
* Copyright (C) 2015-2023 Alibaba Group Holding Limited
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <aos_lcd.h>
#include <yunit/yunit.h>
#include "aos/kernel.h"
#define YELLOW 0xFFE0
#define BLUE 0x001F
/* module name used by log print*/
#define MODULE_NAME "lcd_test"
/* module parameters */
#define area_image_w 10
#define area_image_h 10
uint16_t
*
area_image
=
NULL
;
/* test lcd init */
void
lcd_test_init
(
void
)
{
int
ret
;
ret
=
aos_hal_lcd_init
(
1
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
}
/* test lcd onoff */
void
lcd_test_onoff
(
void
)
{
int
ret
;
ret
=
aos_hal_lcd_display_on
();
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
ret
=
aos_hal_lcd_display_off
();
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
}
/* test lcd image */
static
void
color_prepare
(
uint16_t
color
)
{
area_image
=
(
uint16_t
*
)
aos_malloc
(
area_image_w
*
area_image_h
*
2
);
for
(
int
i
=
0
;
i
<
(
area_image_w
*
area_image_h
);
i
++
)
{
area_image
[
i
]
=
color
;
}
}
void
lcd_test_image
(
void
)
{
int
ret
;
color_prepare
(
YELLOW
);
ret
=
aos_hal_lcd_image
(
0
,
0
,
area_image_w
,
area_image_h
,
area_image
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
aos_msleep
(
500
);
ret
=
aos_hal_lcd_clear
(
BLUE
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
aos_msleep
(
500
);
aos_free
(
area_image
);
}
/* test lcd finalize */
void
lcd_test_finalize
(
void
)
{
int
ret
;
ret
=
aos_hal_lcd_display_off
();
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
}
\ No newline at end of file
test/testcase/lcd_test/lcd_test.c
0 → 100644
浏览文件 @
a99f2070
/*
* Copyright (C) 2020-2023 Alibaba Group Holding Limited
*/
#include <stdio.h>
#include <sched.h>
#include <pthread.h>
#include <yunit/yunit.h>
extern
void
lcd_test_init
(
void
);
extern
void
lcd_test_onoff
(
void
);
extern
void
lcd_test_image
(
void
);
extern
void
lcd_test_finalize
(
void
);
static
int
init
(
void
)
{
return
0
;
}
static
int
cleanup
(
void
)
{
return
0
;
}
static
void
setup
(
void
)
{
}
static
void
teardown
(
void
)
{
}
static
void
setup_pri_save
(
void
)
{
}
static
void
teardown_pri_restore
(
void
)
{
}
static
yunit_test_case_t
aos_lcd_testcases
[]
=
{
{
"lcd_test_init"
,
lcd_test_init
},
{
"lcd_test_onoff"
,
lcd_test_onoff
},
{
"lcd_test_image"
,
lcd_test_image
},
{
"lcd_test_finalize"
,
lcd_test_finalize
},
YUNIT_TEST_CASE_NULL
};
static
yunit_test_suite_t
suites
[]
=
{
{
"lcd"
,
init
,
cleanup
,
setup
,
teardown
,
aos_lcd_testcases
},
YUNIT_TEST_SUITE_NULL
};
void
aos_lcd_test
(
void
)
{
yunit_add_test_suites
(
suites
);
}
AOS_TESTCASE
(
aos_lcd_test
);
\ No newline at end of file
test/testcase/unzip/aos_unzip_test.c
0 → 100644
浏览文件 @
a99f2070
/*
* Copyright (C) 2020-2023 Alibaba Group Holding Limited
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <ztest.h>
#include "aos/vfs.h"
#include "aos_unzip.h"
#define ZIP_FILE "/jsamp/test.zip"
#define UNZIP_FILE "/jsamp/unzip/test.txt"
#define UNZIP_DIR "/jsamp/unzip"
const
char
test_zip_str
[]
=
{
0x50
,
0x4B
,
0x03
,
0x04
,
0x0A
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x8B
,
0x8C
,
0xDA
,
0x56
,
0x6E
,
0x93
,
0xF4
,
0x30
,
0x10
,
0x00
,
0x00
,
0x00
,
0x10
,
0x00
,
0x00
,
0x00
,
0x08
,
0x00
,
0x1C
,
0x00
,
0x74
,
0x65
,
0x73
,
0x74
,
0x2E
,
0x74
,
0x78
,
0x74
,
0x55
,
0x54
,
0x09
,
0x00
,
0x03
,
0x16
,
0x5C
,
0x99
,
0x64
,
0x17
,
0x5C
,
0x99
,
0x64
,
0x75
,
0x78
,
0x0B
,
0x00
,
0x01
,
0x04
,
0xF6
,
0x01
,
0x00
,
0x00
,
0x04
,
0x14
,
0x00
,
0x00
,
0x00
,
0x74
,
0x68
,
0x69
,
0x73
,
0x20
,
0x69
,
0x73
,
0x20
,
0x61
,
0x20
,
0x74
,
0x65
,
0x73
,
0x74
,
0x2E
,
0x0A
,
0x50
,
0x4B
,
0x01
,
0x02
,
0x1E
,
0x03
,
0x0A
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x8B
,
0x8C
,
0xDA
,
0x56
,
0x6E
,
0x93
,
0xF4
,
0x30
,
0x10
,
0x00
,
0x00
,
0x00
,
0x10
,
0x00
,
0x00
,
0x00
,
0x08
,
0x00
,
0x18
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x00
,
0x00
,
0xA4
,
0x81
,
0x00
,
0x00
,
0x00
,
0x00
,
0x74
,
0x65
,
0x73
,
0x74
,
0x2E
,
0x74
,
0x78
,
0x74
,
0x55
,
0x54
,
0x05
,
0x00
,
0x03
,
0x16
,
0x5C
,
0x99
,
0x64
,
0x75
,
0x78
,
0x0B
,
0x00
,
0x01
,
0x04
,
0xF6
,
0x01
,
0x00
,
0x00
,
0x04
,
0x14
,
0x00
,
0x00
,
0x00
,
0x50
,
0x4B
,
0x05
,
0x06
,
0x00
,
0x00
,
0x00
,
0x00
,
0x01
,
0x00
,
0x01
,
0x00
,
0x4E
,
0x00
,
0x00
,
0x00
,
0x52
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
};
static
int
test_aos_uz
(
void
)
{
int
file
;
int
res
;
size_t
str_len
;
const
char
test_str
[]
=
"this is a test."
;
char
str_buff
[
80
];
// create and write file
file
=
aos_open
(
ZIP_FILE
,
O_CREAT
|
O_RDWR
);
zassert_true
(
file
>=
0
,
"Failed create file [%d], errno [%d]
\n
"
,
file
,
errno
);
if
(
file
<
0
)
{
aos_close
(
file
);
return
TC_FAIL
;
}
res
=
aos_write
(
file
,
(
char
*
)
test_zip_str
,
sizeof
(
test_zip_str
));
zassert_true
(
res
>=
0
,
"Failed writing to file [%d]
\n
"
,
(
int
)
res
);
if
(
res
<
0
)
{
aos_close
(
file
);
return
TC_FAIL
;
}
aos_close
(
file
);
printf
(
"File created and written successfully
\n
"
);
// unzip files
res
=
aos_unzip
(
ZIP_FILE
,
UNZIP_DIR
);
zassert_equal
(
res
,
0
,
"aos_unzip failed
\n
"
);
if
(
res
!=
0
)
{
TC_PRINT
(
"Failed unzip file [%d]
\n
"
,
file
);
return
TC_FAIL
;
}
// check if files existance
file
=
aos_open
(
UNZIP_DIR
"/test.txt"
,
O_RDONLY
);
if
(
file
<
0
)
{
TC_PRINT
(
"Not found - unzip file [%d] not found
\n
"
,
file
);
return
TC_FAIL
;
}
res
=
aos_read
(
file
,
str_buff
,
strlen
(
test_str
));
if
(
res
<
0
)
{
TC_PRINT
(
"Failed reading file [%d]
\n
"
,
(
int
)
res
);
aos_close
(
file
);
return
TC_FAIL
;
}
if
(
strcmp
(
test_str
,
str_buff
))
{
TC_PRINT
(
"Error - Data read does not match data written
\n
"
);
TC_PRINT
(
"Data read:
\"
%s
\"\n\n
"
,
str_buff
);
return
TC_FAIL
;
}
res
=
aos_close
(
file
);
// clear files
aos_remove
(
ZIP_FILE
);
aos_remove
(
UNZIP_FILE
);
aos_rmdir
(
UNZIP_DIR
);
return
TC_PASS
;
}
void
test_aos_unzip
(
void
)
{
YUNIT_ASSERT
(
test_aos_uz
()
==
TC_PASS
)
}
test/testcase/unzip/unzip_test.c
0 → 100644
浏览文件 @
a99f2070
/*
* Copyright (C) 2020-2023 Alibaba Group Holding Limited
*/
#include "yunit/yunit.h"
extern
void
test_aos_unzip
(
void
);
static
int
init
(
void
)
{
return
0
;
}
static
int
cleanup
(
void
)
{
return
0
;
}
static
void
setup
(
void
)
{
}
static
void
teardown
(
void
)
{
}
void
aos_uz_test
(
void
)
{
yunit_test_suite_t
*
suite
;
suite
=
yunit_add_test_suite
(
"uzapi"
,
init
,
cleanup
,
setup
,
teardown
);
yunit_add_test_case
(
suite
,
"aos_unzip"
,
test_aos_unzip
);
}
AOS_TESTCASE
(
aos_uz_test
);
test/testcase/uvoice_test/function/pcm_test_device.c
0 → 100644
浏览文件 @
a99f2070
/*
* Copyright (C) 2015-2023 Alibaba Group Holding Limited
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <uvoice_audio.h>
#include <uvoice_pcm.h>
#include <yunit/yunit.h>
#include "aos/kernel.h"
/* module name used by log print*/
#define MODULE_NAME "pcm_test"
/* configure of export pa */
//#define EXIST_EX_PA
#define PA_ACTIVE_HIGH 1
#define PA_PIN 20
#define PA_DELAY_MS 500
struct
external_pa_info
pa_info
;
/* configure of pcm */
#define EXIST_EX_PA
#define PCM_RATE 48000
#define PCM_CHANNEL 1
#define PCM_PERIOD_SIZE 4
#define PCM_PERIOD_COUNT 5
#define PCM_FORMAT PCM_FORMAT_S16_LE
struct
pcm_device
*
pcm
;
/* configure of snd */
uint8_t
*
sound_data
;
int
sound_len
=
0
;
#define SOUND_LEN_MAX 1000
/* test pcm init */
void
pcm_test_init
(
void
)
{
int
ret
;
#ifdef EXIST_EX_PA
pa_info
.
active_high
=
PA_ACTIVE_HIGH
;
pa_info
.
pin
=
PA_PIN
;
pa_info
.
delay_ms
=
PA_DELAY_MS
;
ret
=
uvoice_extpa_config
(
&
pa_info
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
#endif
ret
=
uvoice_pcm_init
();
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
uvoice_pcm_notify
(
PCM_MSG_WRITE_DONE
);
}
/* test pcm open */
void
pcm_test_open
(
void
)
{
int
ret
;
pcm
->
config
.
rate
=
PCM_RATE
;
pcm
->
config
.
channels
=
PCM_CHANNEL
;
pcm
->
config
.
period_size
=
PCM_PERIOD_SIZE
;
pcm
->
config
.
period_count
=
PCM_PERIOD_COUNT
;
pcm
->
config
.
format
=
PCM_FORMAT
;
ret
=
uvoice_pcm_open
(
pcm
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
}
/* test pcm setpath and read */
void
pcm_test_read
(
void
)
{
int
ret
;
ret
=
uvoice_set_path
(
pcm
,
SND_DEVICE_IN_PRIMARY_MIC
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
sound_data
=
aos_malloc
(
SOUND_LEN_MAX
);
ret
=
uvoice_pcm_read
(
pcm
,
sound_data
,
SOUND_LEN_MAX
);
YUNIT_ASSERT_TRUE
(
ret
>
0
);
sound_len
=
ret
;
}
/* test pcm setpath and write */
void
pcm_test_write
(
void
)
{
int
ret
;
ret
=
uvoice_set_path
(
pcm
,
SND_DEVICE_OUT_SPEAKER
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
ret
=
uvoice_pcm_write
(
pcm
,
sound_data
,
sound_len
);
YUNIT_ASSERT_TRUE
(
ret
>
0
);
aos_free
(
sound_data
);
}
/* test pcm setup */
void
pcm_test_setup
(
void
)
{
int
ret
;
pcm
->
config
.
period_size
=
PCM_PERIOD_SIZE
*
2
;
ret
=
uvoice_pcm_setup
(
pcm
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
}
/* test pcm mute snd */
void
pcm_test_mute
(
void
)
{
int
ret
;
ret
=
uvoice_dev_mute
(
pcm
,
SND_DEVICE_OUT_SPEAKER
,
1
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
}
/* test pcm silence */
void
pcm_test_silence
(
void
)
{
int
ret
;
ret
=
uvoice_pcm_silence
(
pcm
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
}
/* test pcm flush */
void
pcm_test_flush
(
void
)
{
int
ret
;
ret
=
uvoice_pcm_flush
(
pcm
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
}
/* test pcm close */
void
pcm_test_close
(
void
)
{
int
ret
;
ret
=
uvoice_pcm_close
(
pcm
);
YUNIT_ASSERT_EQUAL
(
ret
,
0
);
}
\ No newline at end of file
test/testcase/uvoice_test/uvoice_test.c
0 → 100644
浏览文件 @
a99f2070
/*
* Copyright (C) 2020-2023 Alibaba Group Holding Limited
*/
#include <stdio.h>
#include <sched.h>
#include <pthread.h>
#include <yunit/yunit.h>
extern
void
pcm_test_init
(
void
);
extern
void
pcm_test_open
(
void
);
extern
void
pcm_test_read
(
void
);
extern
void
pcm_test_write
(
void
);
extern
void
pcm_test_setup
(
void
);
extern
void
pcm_test_mute
(
void
);
extern
void
pcm_test_silence
(
void
);
extern
void
pcm_test_flush
(
void
);
extern
void
pcm_test_close
(
void
);
static
int
init
(
void
)
{
return
0
;
}
static
int
cleanup
(
void
)
{
return
0
;
}
static
void
setup
(
void
)
{
}
static
void
teardown
(
void
)
{
}
static
void
setup_pri_save
(
void
)
{
}
static
void
teardown_pri_restore
(
void
)
{
}
static
yunit_test_case_t
aos_uvoice_testcases
[]
=
{
{
"pcm_test_init"
,
pcm_test_init
},
{
"pcm_test_open"
,
pcm_test_open
},
{
"pcm_test_read"
,
pcm_test_read
},
{
"pcm_test_write"
,
pcm_test_write
},
{
"pcm_test_setup"
,
pcm_test_setup
},
{
"pcm_test_mute"
,
pcm_test_mute
},
{
"pcm_test_silence"
,
pcm_test_silence
},
{
"pcm_test_flush"
,
pcm_test_flush
},
{
"pcm_test_close"
,
pcm_test_close
},
YUNIT_TEST_CASE_NULL
};
static
yunit_test_suite_t
suites
[]
=
{
{
"uvoice"
,
init
,
cleanup
,
setup
,
teardown
,
aos_uvoice_testcases
},
YUNIT_TEST_SUITE_NULL
};
void
aos_uvoice_test
(
void
)
{
yunit_add_test_suites
(
suites
);
}
AOS_TESTCASE
(
aos_uvoice_test
);
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录