提交 c77854cf 编写于 作者: L lnlan

分支区分,有目录形式改为分支区分

Signed-off-by: Nlnlan <lanleinan3@huawei.com>
上级 2c6b8898
[
{
"return-x-y":[199, 1262],
"recent-x-y":[500, 1262],
"home-x-y":[350, 1262],
"recent_del-x-y":[350, 1140],
"permisson_ok-x-y":[495, 690],
"permisson_no-x-y":[241, 690],
"shot_cmd":[""],
"remount":["hdc_std shell mount -o rw,remount /"],
"cmp_cmd-level":["", 443200]
},
{
"app_name": "crash_check",
"entry": "",
"compress_file_recv":["hdc_std shell \"cd /data/log/faultlog/temp && tar -cf crash_log.tar cppcrash*\""],
"crash_check":["hdc_std shell \"ls /data/log/faultlog/temp/ -al | wc -l\"", ""],
"all_actions": [
[2, "remount"], [2, "crash_check"], [2, "compress_file_recv"], [2, "recv_log-file", "/data/log/faultlog/temp/crash_log.tar"]
]
},
{
"app_name": "wifi_connect",
"entry": "",
"check_ping_baidu":["hdc_std shell ping www.baidu.com", "64 bytes from"],
"all_actions": [[2, "connect_wifi"], [2, "check_ping_baidu"]]
},
{
"app_name": "launcher",
"entry": "",
"rm_lock_cmd":["hdc_std shell uinput -T -m 350 900 350 300"],
"powermode_cmd":["hdc_std shell \"power-shell setmode 602\""],
"all_actions": [
[2, "rm_lock_cmd"], [2, "powermode_cmd"], [2, "rm_lock_cmd"], [2, "powermode_cmd"],
[2, "rm_lock_cmd"], [2, "rm_lock_cmd"], [2, "shot_cmd"], [2, "cmp_cmd-level"]
]
},
{
"app_name": "audio_render",
"entry": "",
"remount":["hdc_std shell mount -o rw,remount /"],
"sendfile1":["hdc_std file send D:\\DeviceTestTools\\screenshot\\audiotest\\hdf_audio_hdi_server_function_test /data/"],
"sendfile2":["hdc_std file send D:\\DeviceTestTools\\screenshot\\audiotest\\audiorendertest.wav /bin/"],
"chmodfile1":["hdc_std shell chmod 777 /data/hdf_audio_hdi_server_function_test"],
"executefile1":["hdc_std shell ./data/hdf_audio_hdi_server_function_test"],
"audio_render_test":["hdc_std shell \"cd /data && ./hdf_audio_hdi_server_function_test --gtest_filter=AudioServerFunctionTest.SUB_Audio_Function_Render_Test_* && rm *.xml\"", "[ PASSED ] 12 tests."],
"audio_capture_test":["hdc_std shell \"cd /data && ./hdf_audio_hdi_server_function_test --gtest_filter=AudioServerFunctionTest.SUB_Audio_Function_Capture_Test_* && rm *.xml\"", "[ PASSED ] 10 test."],
"all_actions": [
[2, "remount"], [2, "sendfile1"], [2, "sendfile2"], [2, "chmodfile1"],
[5, "audio_render_test"]
]
},
{
"app_name": "camera",
"entry": "",
"start_hilog":["hdc_std shell \"hilog -r && hilog -w start -f camera_log -l 400000000 -m none\""],
"start_camera":["hdc_std shell aa start -a com.ohos.camera.MainAbility -b com.ohos.camera"],
"stop_hilog":["hdc_std shell hilog -w stop"],
"check_result":["hdc_std shell \"cd /data/log/hilog && grep -nr PreviewOutputCallback\"", ""],
"compress_log":["hdc_std shell \"cd /data/log/hilog && tar -cf camera_log.tar camera_*\""],
"clear_log":["hdc_std shell rm /data/log/hilog/*"],
"all_actions": [
[2, "clear_log"], [1, "start_hilog"], [4, "start_camera"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [4, "permisson_ok-x-y"], [2, "stop_hilog"], [3, "check_result"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "compress_log"], [2, "recv_log-file", "/data/log/hilog/camera_log.tar"], [2, "clear_log"]
]
},
{
"app_name": "settings_keyboard",
"entry": "aa start -a com.ohos.settings.MainAbility -b com.ohos.settings",
"all_actions": [
[3, "shot_cmd", "settings"], [3, "cmp_cmd-level"], [3, 400, 120], [3, 400, 120], [20, 400, 80], [3, 400, 80],
[3, "shot_cmd", "keyboard"], [3, "recent-x-y"], [3, "recent_del-x-y"], [3, "recent-x-y"], [3, "recent_del-x-y"], [3, "cmp_cmd-level", 200000]
]
},
{
"app_name": "photos",
"entry": "aa start -a com.ohos.photos.MainAbility -b com.ohos.photos",
"all_actions": [[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level"], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "distributedcalc",
"entry": "aa start -a com.example.distributedcalc.default -b com.example.distributedcalc",
"all_actions": [[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level", 3686400], [2, "recent-x-y"], [2, "recent_del-x-y"]]
},
{
"app_name": "note",
"entry": "aa start -a com.ohos.note.MainAbility -b com.ohos.note",
"all_actions": [[2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "permisson_ok-x-y"], [2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "cmp_cmd-level"]]
}
]
# -*- coding: utf-8 -*-
# Copyright (c) 2022 Huawei Device 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.
from ast import parse
import json
import sys
import os
import time
import argparse
import re
import subprocess
def MyPrint(str):
print(str)
with open(os.path.join(args.save_path, 'shot_test.log'), mode='a', encoding='utf-8') as log_file:
console = sys.stdout
sys.stdout = log_file
print(str)
sys.stdout = console
log_file.close()
def EnterCmd(mycmd, waittime = 0, printresult = 1):
if mycmd == "":
return
with open(os.path.join(args.save_path, 'shot_test.bat'), mode='a', encoding='utf-8') as cmd_file:
cmd_file.write(mycmd + '\n')
cmd_file.close()
with os.popen(mycmd) as p:
result = ''.join(p.readlines())
if printresult == 1:
MyPrint(mycmd)
MyPrint(result)
sys.stdout.flush()
if waittime != 0:
time.sleep(waittime)
with open(os.path.join(args.save_path, 'shot_test.bat'), mode='a', encoding='utf-8') as cmd_file:
cmd_file.write("ping -n {} 127.0.0.1>null\n".format(waittime))
cmd_file.close()
return result
def connect_to_wifi(tools_path):
EnterCmd("hdc_std shell mkdir /data/l2tool", 1)
EnterCmd("hdc_std file send {}\\l2tool\\busybox /data/l2tool".format(tools_path), 1)
EnterCmd("hdc_std file send {}\\l2tool\\dhcpc.sh /data/l2tool".format(tools_path), 1)
EnterCmd("hdc_std file send {}\\l2tool\\entry-debug-rich-signed.hap /data/l2tool".format(tools_path), 1)
EnterCmd("hdc_std file send {}\\l2tool\\hostapd.conf /data/l2tool".format(tools_path), 1)
EnterCmd("hdc_std file send {}\\l2tool\\iperf /data/l2tool".format(tools_path), 1)
EnterCmd("hdc_std file send {}\\l2tool\\p2p_supplicant.conf /data/l2tool".format(tools_path), 1)
EnterCmd("hdc_std file send {}\\l2tool\\p2p_supplicant1.conf /data/l2tool".format(tools_path), 1)
EnterCmd("hdc_std file send {}\\l2tool\\udhcpd.conf /data/l2tool".format(tools_path), 1)
EnterCmd("hdc_std file send {}\\l2tool\\wpa_supplicant.conf /data/l2tool".format(tools_path), 1)
EnterCmd("hdc_std shell wpa_supplicant -B -d -i wlan0 -c /data/l2tool/wpa_supplicant.conf", 1)
EnterCmd("hdc_std shell chmod 777 ./data/l2tool/busybox", 1)
cnt = 2
while cnt:
try:
MyPrint("hdc_std shell ./data/l2tool/busybox udhcpc -i wlan0 -s /data/l2tool/dhcpc.sh")
p = subprocess.check_output("hdc_std shell ./data/l2tool/busybox udhcpc -i wlan0 -s /data/l2tool/dhcpc.sh", timeout=8)
MyPrint(p.decode(encoding="utf-8"))
with open(os.path.join(args.save_path, 'shot_test.bat'), mode='a', encoding='utf-8') as cmd_file:
cmd_file.write('hdc_std shell ./data/l2tool/busybox udhcpc -i wlan0 -s /data/l2tool/dhcpc.sh' + '\n')
cmd_file.close()
ret_code = 0;
except subprocess.TimeoutExpired as time_e:
MyPrint(time_e)
ret_code = 1
if ret_code == 0:
ip = re.findall(r"\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b", p.decode(encoding="utf-8"))
MyPrint(ip)
if len(ip) <= 0:
break
if len(re.findall(r'(?<!\d)\d{1,3}\.\d{1,3}\.\d{1,3}(?=\.\d)', ip[0])) <= 0:
break
gate = str(re.findall(r'(?<!\d)\d{1,3}\.\d{1,3}\.\d{1,3}(?=\.\d)', ip[0])[0]) + ".1"
MyPrint(gate)
ifconfig="hdc_std shell ifconfig wlan0 {}".format(ip[0])
EnterCmd(ifconfig)
routeconfig="hdc_std shell ./data/l2tool/busybox route add default gw {} dev wlan0".format(gate)
EnterCmd(routeconfig)
break
MyPrint("try {}".format(cnt))
cnt -= 1
time.sleep(5)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='manual to this script')
parser.add_argument('--config', type=str, default = './app_capture_screen_test_config.json')
parser.add_argument('--test_num', type=int, nargs='+', default = [])
parser.add_argument('--tools_path', type=str, default = 'D:\\DeviceTestTools')
parser.add_argument('--anwser_path', type=str, default = 'screenshot\\RK\\')
parser.add_argument('--save_path', type=str, default = './report/screenshot_1/')
args = parser.parse_args()
with open(args.config) as f:
all_app = json.load(f)
with open(os.path.join(args.save_path, 'shot_test.bat'), mode='w', encoding='utf-8') as cmd_file:
cmd_file.close()
with open(os.path.join(args.save_path, 'shot_test.log'), mode='w', encoding='utf-8') as log_file:
log_file.close()
cmp_status = 0
global_pos = all_app[0]
return_cmd = "hdc_std shell uinput -M -m {} {} -c 0".format(global_pos['return-x-y'][0], global_pos['return-x-y'][1])
recent_cmd = "hdc_std shell uinput -M -m {} {} -c 0".format(global_pos['recent-x-y'][0], global_pos['recent-x-y'][1])
home_cmd = "hdc_std shell uinput -M -m {} {} -c 0".format(global_pos['home-x-y'][0], global_pos['home-x-y'][1])
recent_del_cmd = "hdc_std shell uinput -M -m {} {} -c 0".format(global_pos['recent_del-x-y'][0], global_pos['recent_del-x-y'][1])
os.system("hdc_std start")
EnterCmd("hdc_std list targets", 1)
EnterCmd("hdc_std list targets", 1)
EnterCmd("hdc_std list targets", 1)
EnterCmd("hdc_std shell rm -rf /data/screen_test/train_set")
EnterCmd("hdc_std shell mkdir -p /data/screen_test/train_set")
EnterCmd("hdc_std file send {} {}".format(os.path.join(os.path.dirname(args.config), "printscreen"), "/data/screen_test/"))
EnterCmd("hdc_std shell chmod 777 /data/screen_test/printscreen")
if len(args.test_num) == 0:
idx_list = list(range(1, len(all_app)))
else:
idx_list = args.test_num
fail_idx_list = []
for idx in idx_list:
single_app = all_app[idx]
sys.stdout.flush()
call_app_cmd = "hdc_std shell " + single_app['entry']
send_file_cmd = "hdc_std file send {} {}"
capture_screen_cmd = "hdc_std shell /data/screen_test/printscreen -f /data/screen_test/{}"
recv_file_cmd = "hdc_std file recv /data/screen_test/{} {}"
cmp_cmd = "hdc_std shell \"cmp -l /data/screen_test/{} /data/screen_test/train_set/{} | wc -l\""
MyPrint("\n\n########## case {} : {} test start ##############".format(idx, single_app['app_name']))
with open(os.path.join(args.save_path, 'shot_test.bat'), mode='a', encoding='utf-8') as cmd_file:
cmd_file.write("\n\n::::::case {} --- {} test start \n".format(idx, single_app['app_name']))
cmd_file.close()
if single_app['entry'] != "":
EnterCmd(call_app_cmd, 5)
MyPrint(single_app['all_actions'])
testcnt = 2
while testcnt:
testok = 0
if testcnt == 1:
MyPrint(">>>>>>>>>>>>>>>>>>>>>>>Try again:\n")
for single_action in single_app['all_actions']:
#shot_cmd is stable, different to other cmd,so handle it specialy
if type(single_action[1]) == str and single_action[1] == 'shot_cmd':
if len(single_action) == 3:
pic_name = single_action[2] + ".png"
raw_pic_name = single_action[2] + ".pngraw"
else:
pic_name = single_app['app_name'] + ".png"
raw_pic_name = single_app['app_name'] + ".pngraw"
EnterCmd(capture_screen_cmd.format(pic_name), 1)
EnterCmd(recv_file_cmd.format(pic_name, args.save_path), 1)
EnterCmd(recv_file_cmd.format(raw_pic_name, args.save_path), 1)
next_cmd = ""
#cmp_cmd-level is stable, different to other cmd,so handle it specialy
elif type(single_action[1]) == str and single_action[1] == 'cmp_cmd-level':
next_cmd = ""
MyPrint(send_file_cmd.format(os.path.join(args.anwser_path, raw_pic_name), "/data/screen_test/train_set"))
sys.stdout.flush()
EnterCmd(send_file_cmd.format(os.path.join(args.anwser_path, raw_pic_name), "/data/screen_test/train_set"))
new_cmp_cmd = cmp_cmd.format(raw_pic_name, raw_pic_name)
if len(single_action) == 3:
tolerance = single_action[2]
else:
tolerance = global_pos['cmp_cmd-level'][1]
p = EnterCmd(new_cmp_cmd, single_action[0])
num = re.findall(r'[-+]?\d+', p)
MyPrint(num)
if type(num) == list and len(num) > 0 and int(num[0]) < tolerance:
testok = 1
MyPrint("{} screenshot check is ok!\n\n".format(raw_pic_name))
else:
testok = -1
MyPrint("{} screenshot check is abnarmal!\n\n".format(raw_pic_name))
sys.stdout.flush()
elif type(single_action[1]) == str and single_action[1] == 'recv_log-file':
next_cmd = ""
if len(single_action) == 3:
logfilepath = single_action[2]
next_cmd = "hdc_std file recv {} {}".format(logfilepath, args.save_path)
elif type(single_action[1]) == str and single_action[1] == 'connect_wifi':
next_cmd = ""
connect_to_wifi(args.tools_path)
#other cmd handle
elif type(single_action[1]) == str:
if single_action[1] not in single_app.keys():
target_ = global_pos[single_action[1]]
else:
target_ = single_app[single_action[1]]
#this cmd is real cmd,and have a except answer
if type(target_[0]) == str:
next_cmd = ""
p = EnterCmd(target_[0], single_action[0])
result = "".join(p)
if len(target_) > 1:
findsome = result.find(target_[1], 0, len(result))
if findsome != -1:
testok = 1
MyPrint("\"{}\" check execut result is ok, find \"{}\"!\n".format(target_[0], target_[1]))
else:
testok = -1
MyPrint("\"{}\" check execut result is not ok, not find \"{}\"!\n".format(target_[0], target_[1]))
sys.stdout.flush()
#this cmd only is a name of x,y postion, to get x,y an click it
else:
next_cmd = "hdc_std shell uinput -M -m {} {} -c 0".format(target_[0], target_[1])
#uinput x,y postion, to click it
else:
next_cmd = "hdc_std shell uinput -M -m {} {} -c 0".format(single_action[1], single_action[2])
EnterCmd(next_cmd, single_action[0])
if fail_idx_list.count(idx):
fail_idx_list.remove(idx)
if testok == 1:
MyPrint("testcase {}, {} is ok!\n\n".format(idx, single_app['app_name']))
testcnt = 0
elif testok == -1:
MyPrint("ERROR:testcase {}, {} is failed!\n\n".format(idx, single_app['app_name']))
fail_idx_list.append(idx)
testcnt -= 1
else:
testcnt = 0
if len(fail_idx_list) != 0:
MyPrint("ERROR: {}, these testcase is failed".format(fail_idx_list))
MyPrint("End of check, test failed!")
else:
MyPrint("All testcase is ok")
MyPrint("End of check, test succeeded!")
sys.stdout.flush()
sys.exit(len(fail_idx_list))
\ No newline at end of file
此差异已折叠。
hdf_devmgr
param_watcher
storage_manager
appspawn
hilogd
samgr
storage_daemon
udevd
uinput_inject
multimodalinput
token_sync_serv
huks_service
memmgrservice
bluetooth_servi
pulseaudio
accessibility
resource_schedu
faceauth
work_scheduler_
bgtaskmgr_servi
audio_policy
deviceauth_service
softbus_server
wifi_hal_service
deviceinfoservi
faultloggerd
accountmgr
time_service
distributeddata
useriam
updater_sa
inputmethod_ser
ui_service
fms_service
distributedfile
distributedfile
netmanager
battery_stats
dslm_service
sensors
media_service
wifi_manager_se
distributedsche
installs
hiview
telephony
usb_service
camera_service
render_service
thermal
foundation
accesstoken_ser
hdcd
disp_gralloc_host
light_dal_host
vibrator_dal_host
sensor_dal_host
input_user_host
camera_host
audio_hdi_server_host
wifi_host
usbfnMaster_host
usb_host
blue_host
wifi_hal_service
com.ohos.systemui
device_usage_st
com.ohos.launcher
power_host
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册