runtest_Windows.bat 3.6 KB
Newer Older
M
maweiye 已提交
1 2
@echo off

M
maweiye 已提交
3 4 5 6
@REM 本地OpenHarmony源码目录,请根据实际环境修改!!
set LOCAL=\\wsl$\ubuntu-20.04\home\OHOS\
@REM 本地编译out目录
set OUTDIR=out\hi3516dv300
M
maweiye 已提交
7

M
maweiye 已提交
8 9 10
@REM 本地用例生成目录
set TESTDIR=%LOCAL%\%OUTDIR%\tests\unittest\libc-test\src
@REM 动态链接库生成目录
M
maweiye 已提交
11
set DYNLIB=%LOCAL%\%OUTDIR%\musl\libc-test-lib
M
maweiye 已提交
12 13 14
@REM 远程传输目标目录
set REMOTE=/data/tests/libc-test/src
@REM runtest脚本所在目录
M
maweiye 已提交
15 16 17 18 19 20
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%
M
maweiye 已提交
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41

@REM 检查设备是否连接
echo HDC device checking...
for /F "usebackq delims==" %%c in (`hdc list targets`) DO (
    echo Device list:
    echo %%c | findstr "[Empty]" && goto noDevice || echo %%c && goto hdcStart
)

@REM 在单板创建目录,原先并不存在相应目录,也无法在传输时创建,因此需要预先创建好才能传输到相应位置。
:hdcStart
echo.
echo now mkdir...
hdc shell mkdir /data/tests
hdc shell mkdir /data/tests/libc-test
hdc shell mkdir %REMOTE%
hdc shell mkdir %REMOTE%/api
hdc shell mkdir %REMOTE%/common
hdc shell mkdir %REMOTE%/functional
hdc shell mkdir %REMOTE%/math
hdc shell mkdir %REMOTE%/musl
hdc shell mkdir %REMOTE%/regression
42

M
maweiye 已提交
43
@REM 创建临时文件夹,用于存放用例生成的临时文件
44 45
hdc shell mkdir /tmp
hdc shell mkdir /dev/shm
M
maweiye 已提交
46
echo Mkdir done.
M
maweiye 已提交
47 48 49 50
goto hdcSend

@REM 传输文件,单板上执行runtest.sh,将结果REPORT返回到.bat所在目录
:hdcSend
M
maweiye 已提交
51
for /F %%i in ('dir %TESTDIR% /S /B') do (
M
maweiye 已提交
52 53 54
    for %%b in ("%%i\..") do (
        echo Sending %%~nb/%%~nxi
        hdc file send -sync %%i %REMOTE%/%%~nb/%%~nxi
55
        hdc shell chmod a+x %REMOTE%/%%~nb/%%~nxi
M
maweiye 已提交
56 57
    )
)
58
@REM 动态库传输
M
maweiye 已提交
59 60 61 62
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
63 64 65

@REM 修改动态库权限
hdc shell chmod a+x	%REMOTE%/functional/libdlopen_dso.so
M
maweiye 已提交
66 67
hdc shell chmod a+x	%REMOTE%/functional/libtls_align_dso.so
hdc shell chmod a+x	%REMOTE%/functional/libtls_init_dso.so
68
hdc shell chmod a+x %REMOTE%/regression/libtls_get_new-dtv_dso.so
M
maweiye 已提交
69
echo Test cases sending finished.
M
maweiye 已提交
70
echo.
M
maweiye 已提交
71 72 73 74 75 76 77
goto sendSH


@REM 发送脚本并执行用例
:sendSH
echo Sending runtest.sh
hdc file send %SHDIR%\runtest.sh %REMOTE%/runtest.sh
78
hdc shell chmod a+x %REMOTE%/runtest.sh
M
maweiye 已提交
79
echo runtest.sh has been transported.
M
maweiye 已提交
80 81 82 83
echo.
echo hdc shell .%REMOTE%/runtest.sh
hdc shell .%REMOTE%/runtest.sh
echo.
M
maweiye 已提交
84 85 86 87 88 89 90
echo ================================
echo The test cases have been executed.

@REM 删除临时文件夹
hdc shell rm /tmp -rf
hdc shell rm /dev/shm -rf
echo.
M
maweiye 已提交
91 92 93 94
echo hdc file recv %REMOTE%/REPORT %~dp0REPORT
hdc file recv %REMOTE%/REPORT %~dp0REPORT
goto end

M
maweiye 已提交
95
@REM 提示检查设备连接。
M
maweiye 已提交
96 97 98 99
:noDevice
echo Device not found,please check your device.
goto end

M
maweiye 已提交
100
@REM 完成所用时间
M
maweiye 已提交
101 102 103 104 105 106
:end
echo.
set /a endS=%time:~6,2%
set /a endM=%time:~3,2%
set /a diffS_=%endS%-%startS%
set /a diffM_=%endM%-%startM%
107 108 109 110 111 112 113 114 115 116

@REM REPORT文件比较 
start python %LOCAL%\third_party\musl\scripts\compare.py
if exist "%LOCAL%\third_party\musl\scripts\\result.html" (
  echo Test failed,please checking result.html!
) else (
  echo Test successful!
)  
echo file compareing finished

M
maweiye 已提交
117 118
echo All items finished.
echo Time cost:%diffM_%m%diffS_%s .
M
maweiye 已提交
119 120 121
echo.
pause
exit