From 007c942109bb2198165eafa7f4651152b4943984 Mon Sep 17 00:00:00 2001 From: maweiye Date: Thu, 2 Dec 2021 17:05:00 +0800 Subject: [PATCH] Update scripts and README_toRunStart.md Signed-off-by: maweiye --- BUILD.gn | 5 ++ libc-test/README-HowtoRun.md | 55 ++++++++++++++ ohos.build | 12 --- scripts/runtest.sh | 44 +++++++---- scripts/{runtest.bat => runtest_Windows.bat} | 79 +++++++++++--------- 5 files changed, 131 insertions(+), 64 deletions(-) create mode 100644 libc-test/README-HowtoRun.md delete mode 100644 ohos.build rename scripts/{runtest.bat => runtest_Windows.bat} (57%) diff --git a/BUILD.gn b/BUILD.gn index 4a0385a6..30113e05 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -257,3 +257,8 @@ copy("musl_copy_inc_root") { outputs = [ "${target_out_dir}/${musl_inc_out_dir}/{{source_file_part}}" ] deps = [ ":create_porting_src" ] } + +group("libctest") { + testonly = true + deps = [ "libc-test:musl_libc_test" ] +} diff --git a/libc-test/README-HowtoRun.md b/libc-test/README-HowtoRun.md new file mode 100644 index 00000000..a501000a --- /dev/null +++ b/libc-test/README-HowtoRun.md @@ -0,0 +1,55 @@ +## 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、执行步骤一(生成用例)中的编译命令,即可生成对应可执行文件。 + diff --git a/ohos.build b/ohos.build deleted file mode 100644 index d7ea85f0..00000000 --- a/ohos.build +++ /dev/null @@ -1,12 +0,0 @@ -{ - "subsystem": "musl", - "parts": { - "libc-test": { - "module_list":[ - ], - "test_list": [ - "//third_party/musl/libc-test:musl_libc_test" - ] - } - } -} diff --git a/scripts/runtest.sh b/scripts/runtest.sh index 41e4de63..c02e58a1 100755 --- a/scripts/runtest.sh +++ b/scripts/runtest.sh @@ -1,17 +1,29 @@ -cd /data/tests/libc-test/src -rm REPORT -touch REPORT -for filelist in $(ls) -do - cd /data/tests/libc-test/src/$filelist - for file in $(ls) - do - if [ "$file" = "runtest" ] || [ "$file" = "libdlopen_dso.so" ] || [ "$file" = "libtls_get_new-dtv_dso.so" ] || [ "$file" = "src" ]; then - continue - else - /data/tests/libc-test/src/common/runtest -w '' $file >>../REPORT - echo $filelist/$file - fi - done - cd .. + +cd /data/tests/libc-test +rm src/REPORT +touch src/REPORT + +for filelist in src/* +do + if [ -d $filelist ]; then + for file in `ls $filelist` + do + if [ "$file" = "runtest" ] \ + || [ "$file" = "libdlopen_dso.so" ] \ + || [ "$file" = "libtls_init_dso.so" ] \ + || [ "$file" = "libtls_align_dso.so" ] \ + || [ "$file" = "libtls_get_new-dtv_dso.so" ] + 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 diff --git a/scripts/runtest.bat b/scripts/runtest_Windows.bat similarity index 57% rename from scripts/runtest.bat rename to scripts/runtest_Windows.bat index 9086eb20..05409e1f 100644 --- a/scripts/runtest.bat +++ b/scripts/runtest_Windows.bat @@ -1,17 +1,23 @@ @echo off -@REM 开始时间 -set /a startS=%time:~6,2% -set /a startM=%time:~3,2% +@REM 本地OpenHarmony源码目录,请根据实际环境修改!! +set LOCAL=\\wsl$\ubuntu-20.04\home\OHOS\ +@REM 本地编译out目录 +set OUTDIR=out\hi3516dv300 -@REM 本地文件所在目录 -set LOCAL=\\wsl$\ubuntu-20.04\home\OHOS\out\ohos-arm-release\tests\unittest\libc-test\src +@REM 本地用例生成目录 +set TESTDIR=%LOCAL%\%OUTDIR%\tests\unittest\libc-test\src +@REM 动态链接库生成目录 +set DYNLIB=%LOCAL%\%OUTDIR%\musl\libc-test\lib @REM 远程传输目标目录 set REMOTE=/data/tests/libc-test/src @REM runtest脚本所在目录 -set SHDIR=\\wsl$\Ubuntu-20.04\home\OHOS\third_party\musl\scripts -@REM 动态链接库所在目录 -set DYNLIB=\\wsl$\Ubuntu-18.04\root\openhramony2\out\ohos-arm-release\musl\libc-test\lib +set SHDIR=%LOCAL%\third_party\musl\scripts + +@REM Do not modify the following code unless necessary +@REM 开始时间 +set /a startS=%time:~6,2% +set /a startM=%time:~3,2% @REM 检查设备是否连接 echo HDC device checking... @@ -34,71 +40,72 @@ hdc shell mkdir %REMOTE%/math hdc shell mkdir %REMOTE%/musl hdc shell mkdir %REMOTE%/regression -@REM 创建临时文件夹 +@REM 创建临时文件夹,用于存放用例生成的临时文件 hdc shell mkdir /tmp hdc shell mkdir /dev/shm - -@REM 创建存放动态库文件夹 -hdc shell mkdir %REMOTE%/functional/src -hdc shell mkdir %REMOTE%/functional/src/functional -echo Done. +echo Mkdir done. goto hdcSend @REM 传输文件,单板上执行runtest.sh,将结果REPORT返回到.bat所在目录 :hdcSend -for /F %%i in ('dir %LOCAL% /S /B') do ( +for /F %%i in ('dir %TESTDIR% /S /B') do ( for %%b in ("%%i\..") do ( echo Sending %%~nb/%%~nxi hdc file send -sync %%i %REMOTE%/%%~nb/%%~nxi hdc shell chmod a+x %REMOTE%/%%~nb/%%~nxi ) ) - @REM 动态库传输 -hdc file send %DYNLIB%\libdlopen_dso.so %REMOTE%/functional -hdc file send %DYNLIB%\libtls_get_new-dtv_dso.so %REMOTE%/regression -hdc file send %DYNLIB%\libtls_align_dso.so %REMOTE%/functional/src/functional -hdc file send %DYNLIB%\libtls_init_dso.so %REMOTE%/functional/src/functional +hdc file send %DYNLIB%\libdlopen_dso.so %REMOTE%/functional/libdlopen_dso.so +hdc file send %DYNLIB%\libtls_align_dso.so %REMOTE%/functional/libtls_align_dso.so +hdc file send %DYNLIB%\libtls_init_dso.so %REMOTE%/functional/libtls_init_dso.so +hdc file send %DYNLIB%\libtls_get_new-dtv_dso.so %REMOTE%/regression/libtls_get_new-dtv_dso.so @REM 修改动态库权限 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%/functional/src/functional/libtls_align_dso.so -hdc shell chmod a+x %REMOTE%/functional/src/functional/libtls_init_dso.so -echo Done. +echo Test cases sending finished. echo. -echo Sending run.sh -hdc file send %SHDIR%\run.sh %REMOTE%/runtest.sh +goto sendSH + + +@REM 发送脚本并执行用例 +:sendSH +echo Sending runtest.sh +hdc file send %SHDIR%\runtest.sh %REMOTE%/runtest.sh hdc shell chmod a+x %REMOTE%/runtest.sh -echo. -echo ============================ -echo ALL files send finished. +echo runtest.sh has been transported. echo. echo hdc shell .%REMOTE%/runtest.sh hdc shell .%REMOTE%/runtest.sh 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 hdc file recv %REMOTE%/REPORT %~dp0REPORT goto end -@REM 若检查无设备连接,提示检查设备。 +@REM 提示检查设备连接。 :noDevice echo Device not found,please check your device. goto end +@REM 完成所用时间 :end echo. set /a endS=%time:~6,2% set /a endM=%time:~3,2% set /a diffS_=%endS%-%startS% set /a diffM_=%endM%-%startM% -echo All Done. Time cost:%diffM_%m%diffS_%s - -@REM 删除临时文件夹 -hdc shell rm /tmp -rf -hdc shell rm /dev/shm -rf - -@REM 完成所用时间 +echo All items finished. +echo Time cost:%diffM_%m%diffS_%s . echo. pause exit -- GitLab