提交 007c9421 编写于 作者: M maweiye

Update scripts and README_toRunStart.md

Signed-off-by: Nmaweiye <maweiye@huawei.com>
上级 6d299e95
...@@ -257,3 +257,8 @@ copy("musl_copy_inc_root") { ...@@ -257,3 +257,8 @@ copy("musl_copy_inc_root") {
outputs = [ "${target_out_dir}/${musl_inc_out_dir}/{{source_file_part}}" ] outputs = [ "${target_out_dir}/${musl_inc_out_dir}/{{source_file_part}}" ]
deps = [ ":create_porting_src" ] deps = [ ":create_porting_src" ]
} }
group("libctest") {
testonly = true
deps = [ "libc-test:musl_libc_test" ]
}
## libc-test脚本使用说明
### 一、生成用例
编译命令,单独编译出libc-test测试用例
```shell
./build.sh --product-name Hi3516DV300 --build-target third_party/musl:libctest
```
文件生成的目录位于 `out/hi3516dv300/tests/unittest/libc-test`
注:
旧版ohos中,文件生成的目录位于 `out/ohos-arm-release/tests/unittest/libc-test`,请根据实际修改脚本中相关路径!!
请务必根据实际修改脚本中相关路径!
### 二、执行用例
1. 将HDC(Windows版)工具加入到windows环境变量,并将工具改名为hdc.exe。连接上开发板,保证HDC工具可以连接。
2. 进入musl/scripts,并根据实际环境,修改runtest.bat中测试用例生成目录完整路径(必要)
```bat
@REM 本地OpenHarmony源码目录,请根据实际环境修改!!
set LOCAL=\\wsl$\ubuntu-20.04\home\OHOS\
@REM 本地编译out目录
set OUTDIR=out\hi3516dv300
```
3. 将bat脚本复制到windows环境下使用!!windows端双击运行runtest.bat,执行完毕会将结果REPORT返回到当前bat所在目录。
此bat将从WSL映射目录传输文件到单板目录下,由于WSL无法直接访问windows端口,所以在WSL中直接使用可能无法传输用例。
5. 若要单独执行测试用例,需要先将common目录下的`runtest`与用例传输到单板,再通过命令执行,结果将打印出来
```shell
./runtest -w '' {filename}
```
### 三、增加用例
若要在functional、math、regression或增加用例,需要在相应目录的test_src_{dir}.gni中添加文件名。
例如:
1、需要在functional目录中新增一个用例:由`new_test.c`生成可执行文件`new_test`
2、首先把c文件放入functional目录中,打开`test_src_functional.gni`,在`functional_list`中最后一行增加`"new_test",`
3、执行步骤一(生成用例)中的编译命令,即可生成对应可执行文件。
{
"subsystem": "musl",
"parts": {
"libc-test": {
"module_list":[
],
"test_list": [
"//third_party/musl/libc-test:musl_libc_test"
]
}
}
}
cd /data/tests/libc-test/src
rm REPORT cd /data/tests/libc-test
touch REPORT rm src/REPORT
for filelist in $(ls) touch src/REPORT
do
cd /data/tests/libc-test/src/$filelist for filelist in src/*
for file in $(ls) do
do if [ -d $filelist ]; then
if [ "$file" = "runtest" ] || [ "$file" = "libdlopen_dso.so" ] || [ "$file" = "libtls_get_new-dtv_dso.so" ] || [ "$file" = "src" ]; then for file in `ls $filelist`
continue do
else if [ "$file" = "runtest" ] \
/data/tests/libc-test/src/common/runtest -w '' $file >>../REPORT || [ "$file" = "libdlopen_dso.so" ] \
echo $filelist/$file || [ "$file" = "libtls_init_dso.so" ] \
fi || [ "$file" = "libtls_align_dso.so" ] \
done || [ "$file" = "libtls_get_new-dtv_dso.so" ]
cd .. then
continue
else
if [ "$file" = "tls_get_new-dtv" ];then
cd src/regression
/data/tests/libc-test/src/common/runtest -w '' $file >> /data/tests/libc-test/src/REPORT
cd /data/tests/libc-test
else
src/common/runtest -w '' $filelist/$file >> src/REPORT
fi
fi
done
fi
done done
@echo off @echo off
@REM 开始时间 @REM 本地OpenHarmony源码目录,请根据实际环境修改!!
set /a startS=%time:~6,2% set LOCAL=\\wsl$\ubuntu-20.04\home\OHOS\
set /a startM=%time:~3,2% @REM 本地编译out目录
set OUTDIR=out\hi3516dv300
@REM 本地文件所在目录 @REM 本地用例生成目录
set LOCAL=\\wsl$\ubuntu-20.04\home\OHOS\out\ohos-arm-release\tests\unittest\libc-test\src set TESTDIR=%LOCAL%\%OUTDIR%\tests\unittest\libc-test\src
@REM 动态链接库生成目录
set DYNLIB=%LOCAL%\%OUTDIR%\musl\libc-test\lib
@REM 远程传输目标目录 @REM 远程传输目标目录
set REMOTE=/data/tests/libc-test/src set REMOTE=/data/tests/libc-test/src
@REM runtest脚本所在目录 @REM runtest脚本所在目录
set SHDIR=\\wsl$\Ubuntu-20.04\home\OHOS\third_party\musl\scripts set SHDIR=%LOCAL%\third_party\musl\scripts
@REM 动态链接库所在目录
set DYNLIB=\\wsl$\Ubuntu-18.04\root\openhramony2\out\ohos-arm-release\musl\libc-test\lib @REM Do not modify the following code unless necessary
@REM 开始时间
set /a startS=%time:~6,2%
set /a startM=%time:~3,2%
@REM 检查设备是否连接 @REM 检查设备是否连接
echo HDC device checking... echo HDC device checking...
...@@ -34,71 +40,72 @@ hdc shell mkdir %REMOTE%/math ...@@ -34,71 +40,72 @@ hdc shell mkdir %REMOTE%/math
hdc shell mkdir %REMOTE%/musl hdc shell mkdir %REMOTE%/musl
hdc shell mkdir %REMOTE%/regression hdc shell mkdir %REMOTE%/regression
@REM 创建临时文件夹 @REM 创建临时文件夹,用于存放用例生成的临时文件
hdc shell mkdir /tmp hdc shell mkdir /tmp
hdc shell mkdir /dev/shm hdc shell mkdir /dev/shm
echo Mkdir done.
@REM 创建存放动态库文件夹
hdc shell mkdir %REMOTE%/functional/src
hdc shell mkdir %REMOTE%/functional/src/functional
echo Done.
goto hdcSend goto hdcSend
@REM 传输文件,单板上执行runtest.sh,将结果REPORT返回到.bat所在目录 @REM 传输文件,单板上执行runtest.sh,将结果REPORT返回到.bat所在目录
:hdcSend :hdcSend
for /F %%i in ('dir %LOCAL% /S /B') do ( for /F %%i in ('dir %TESTDIR% /S /B') do (
for %%b in ("%%i\..") do ( for %%b in ("%%i\..") do (
echo Sending %%~nb/%%~nxi echo Sending %%~nb/%%~nxi
hdc file send -sync %%i %REMOTE%/%%~nb/%%~nxi hdc file send -sync %%i %REMOTE%/%%~nb/%%~nxi
hdc shell chmod a+x %REMOTE%/%%~nb/%%~nxi hdc shell chmod a+x %REMOTE%/%%~nb/%%~nxi
) )
) )
@REM 动态库传输 @REM 动态库传输
hdc file send %DYNLIB%\libdlopen_dso.so %REMOTE%/functional hdc file send %DYNLIB%\libdlopen_dso.so %REMOTE%/functional/libdlopen_dso.so
hdc file send %DYNLIB%\libtls_get_new-dtv_dso.so %REMOTE%/regression hdc file send %DYNLIB%\libtls_align_dso.so %REMOTE%/functional/libtls_align_dso.so
hdc file send %DYNLIB%\libtls_align_dso.so %REMOTE%/functional/src/functional hdc file send %DYNLIB%\libtls_init_dso.so %REMOTE%/functional/libtls_init_dso.so
hdc file send %DYNLIB%\libtls_init_dso.so %REMOTE%/functional/src/functional hdc file send %DYNLIB%\libtls_get_new-dtv_dso.so %REMOTE%/regression/libtls_get_new-dtv_dso.so
@REM 修改动态库权限 @REM 修改动态库权限
hdc shell chmod a+x %REMOTE%/functional/libdlopen_dso.so hdc shell chmod a+x %REMOTE%/functional/libdlopen_dso.so
hdc shell chmod a+x %REMOTE%/functional/libtls_align_dso.so
hdc shell chmod a+x %REMOTE%/functional/libtls_init_dso.so
hdc shell chmod a+x %REMOTE%/regression/libtls_get_new-dtv_dso.so hdc shell chmod a+x %REMOTE%/regression/libtls_get_new-dtv_dso.so
hdc shell chmod a+x %REMOTE%/functional/src/functional/libtls_align_dso.so echo Test cases sending finished.
hdc shell chmod a+x %REMOTE%/functional/src/functional/libtls_init_dso.so
echo Done.
echo. echo.
echo Sending run.sh goto sendSH
hdc file send %SHDIR%\run.sh %REMOTE%/runtest.sh
@REM 发送脚本并执行用例
:sendSH
echo Sending runtest.sh
hdc file send %SHDIR%\runtest.sh %REMOTE%/runtest.sh
hdc shell chmod a+x %REMOTE%/runtest.sh hdc shell chmod a+x %REMOTE%/runtest.sh
echo. echo runtest.sh has been transported.
echo ============================
echo ALL files send finished.
echo. echo.
echo hdc shell .%REMOTE%/runtest.sh echo hdc shell .%REMOTE%/runtest.sh
hdc shell .%REMOTE%/runtest.sh hdc shell .%REMOTE%/runtest.sh
echo. echo.
echo ================================
echo The test cases have been executed.
@REM 删除临时文件夹
hdc shell rm /tmp -rf
hdc shell rm /dev/shm -rf
echo.
echo hdc file recv %REMOTE%/REPORT %~dp0REPORT echo hdc file recv %REMOTE%/REPORT %~dp0REPORT
hdc file recv %REMOTE%/REPORT %~dp0REPORT hdc file recv %REMOTE%/REPORT %~dp0REPORT
goto end goto end
@REM 若检查无设备连接,提示检查设备 @REM 提示检查设备连接
:noDevice :noDevice
echo Device not found,please check your device. echo Device not found,please check your device.
goto end goto end
@REM 完成所用时间
:end :end
echo. echo.
set /a endS=%time:~6,2% set /a endS=%time:~6,2%
set /a endM=%time:~3,2% set /a endM=%time:~3,2%
set /a diffS_=%endS%-%startS% set /a diffS_=%endS%-%startS%
set /a diffM_=%endM%-%startM% set /a diffM_=%endM%-%startM%
echo All Done. Time cost:%diffM_%m%diffS_%s echo All items finished.
echo Time cost:%diffM_%m%diffS_%s .
@REM 删除临时文件夹
hdc shell rm /tmp -rf
hdc shell rm /dev/shm -rf
@REM 完成所用时间
echo. echo.
pause pause
exit exit
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册