diff --git a/OAT.xml b/OAT.xml
index 67c0c7e1a985412630f7e16c33d575d5d6d20307..75658c32ecac16a62b367d59e9007ec3b6705fd8 100644
--- a/OAT.xml
+++ b/OAT.xml
@@ -30,15 +30,15 @@
-
+
-
+
-
+
diff --git a/screenshot/l2tool/busybox b/screenshot/l2tool/busybox
new file mode 100755
index 0000000000000000000000000000000000000000..bb8c6c2a7f66274277dad579038b44a355c505d4
Binary files /dev/null and b/screenshot/l2tool/busybox differ
diff --git a/screenshot/l2tool/dhcpc.sh b/screenshot/l2tool/dhcpc.sh
new file mode 100755
index 0000000000000000000000000000000000000000..b94b73965638945289d1a31eb8bdd6449b3d5f95
--- /dev/null
+++ b/screenshot/l2tool/dhcpc.sh
@@ -0,0 +1,39 @@
+#!/system/bin/sh
+# udhcpc script edited by Tim Riker
+
+[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
+
+RESOLV_CONF="/etc/resolv.conf"
+[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
+[ -n "$subnet" ] && NETMASK="netmask $subnet"
+
+case "$1" in
+ deconfig)
+ /system/bin/ifconfig $interface 0.0.0.0
+ ;;
+
+ renew|bound)
+ /system/bin/ifconfig $interface $ip $BROADCAST $NETMASK
+
+ if [ -n "$router" ] ; then
+ echo "deleting routers"
+ while ./busybox route del default gw 0.0.0.0 dev $interface ; do
+ :
+ done
+
+ for i in $router ; do
+ ./busybox route add default gw $i dev $interface
+ done
+ fi
+
+ echo -n > $RESOLV_CONF
+ [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
+ for i in $dns ; do
+ echo adding dns $i
+ echo nameserver $i >> $RESOLV_CONF
+ done
+ ;;
+esac
+
+exit 0
+
diff --git a/screenshot/l2tool/wpa_supplicant.conf b/screenshot/l2tool/wpa_supplicant.conf
new file mode 100755
index 0000000000000000000000000000000000000000..81ffc27a5435f2d6edd8da554b7103fd3f3a35e8
--- /dev/null
+++ b/screenshot/l2tool/wpa_supplicant.conf
@@ -0,0 +1,8 @@
+country=GB
+#update_config=1
+#ap_scan=1
+
+network={
+ ssid="testapold"
+ psk="passw0rd1!"
+}
\ No newline at end of file
diff --git a/screenshot/resource/app_capture_screen_test_config.json b/screenshot/resource/app_capture_screen_test_config.json
index beee9aa55d865928998e0660238bc90d9d4d37d6..7f78b1792c9b988c288e24c76122a66df796ee4c 100644
--- a/screenshot/resource/app_capture_screen_test_config.json
+++ b/screenshot/resource/app_capture_screen_test_config.json
@@ -1,5 +1,7 @@
[
{
+ "DEVICE_1":[1, 2, 3, 4, 5],
+ "DEVICE_2":[6, 7, 8, 9, 10, 11],
"return-x-y":[199, 1262],
"recent-x-y":[500, 1262],
"home-x-y":[350, 1262],
@@ -7,105 +9,99 @@
"permisson_ok-x-y":[495, 690],
"permisson_no-x-y":[241, 690],
"shot_cmd":[""],
- "remount":["hdc_std shell mount -o rw,remount /"],
- "stop_hilog":["hdc_std shell hilog -w stop"],
- "cmp_cmd-level":["", 443200]
+ "remount":["mount -o rw,remount"],
+ "stop_hilog":["hilog -w stop"],
+ "cmp_cmd-level":["", 443200],
+ "get_file_from_dev":[""],
+ "send_file_to_dev":["", ""]
},
{
"app_name": "launcher",
"entry": "",
- "rm_lock_cmd":["hdc_std shell \"uinput -T -m 425 1000 425 400;sleep 2;uinput -T -m 425 400 425 1000\""],
- "powermode_cmd":["hdc_std shell \"power-shell wakeup && 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, "rm_lock_cmd"], [2, "shot_cmd"], [2, "cmp_cmd-level"]
+ [2, "shot_cmd"], [2, "cmp_cmd-level"]
]
},
{
"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\"", ""],
+ "compress_file_recv":["cd /data/log/faultlog/temp && tar -cf crash_log.tar cppcrash*"],
+ "crash_check":["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"]
+ [2, "remount"], [2, "crash_check"], [2, "compress_file_recv"], [2, "get_file_from_dev", "/data/log/faultlog/temp/crash_log.tar"]
]
},
{
"app_name": "notification_bar",
"entry": "",
- "pull_down_cmd":["hdc_std shell uinput -T -m 500 0 550 40"],
- "swipe_up_cmd":["hdc_std shell uinput -T -m 500 500 550 300"],
- "compress_log":["hdc_std shell \"cd /data/log/hilog && tar -cf notification_bar.tar *\""],
+ "pull_down_cmd":["uinput -T -m 500 0 550 40"],
+ "swipe_up_cmd":["uinput -T -m 500 500 550 300"],
+ "compress_log":["cd /data/log/hilog && tar -cf notification_bar.tar *"],
"all_actions": [
[2, "pull_down_cmd"], [2, "pull_down_cmd"], [2, "pull_down_cmd"], [2, "pull_down_cmd"],
- [2, "shot_cmd"], [2, "cmp_cmd-level"], [1, "swipe_up_cmd"], [1, "swipe_up_cmd"], [2, "stop_hilog"], [2, "compress_log"], [2, "recv_log-file", "/data/log/hilog/notification_bar.tar"]
+ [2, "shot_cmd"], [2, "cmp_cmd-level"], [1, "swipe_up_cmd"], [1, "swipe_up_cmd"], [2, "stop_hilog"], [2, "compress_log"], [2, "get_file_from_dev", "/data/log/hilog/notification_bar.tar"]
]
},
{
"app_name": "wifi_connect",
"entry": "",
- "check_ping_baidu":["hdc_std shell ping www.baidu.com", "64 bytes from"],
- "compress_log":["hdc_std shell \"cd /data/log/hilog && tar -cf wifi_connect_log.tar *\""],
- "all_actions": [[2, "connect_wifi"], [2, "check_ping_baidu"], [2, "stop_hilog"], [2, "compress_log"], [2, "recv_log-file", "/data/log/hilog/wifi_connect_log.tar"]]
+ "check_ping_baidu":["ping www.baidu.com", "64 bytes from"],
+ "compress_log":["cd /data/log/hilog && tar -cf wifi_connect_log.tar *"],
+ "all_actions": [[2, "connect_wifi"], [2, "check_ping_baidu"], [2, "stop_hilog"], [2, "compress_log"], [2, "get_file_from_dev", "/data/log/hilog/wifi_connect_log.tar"]]
},
{
"app_name": "video_test",
"entry": "",
- "install_video_test":["hdc_std install D:\\DeviceTestTools\\screenshot\\vediotest\\ActsVideoPlayerJsTest.hap"],
- "mk_test_dir":["hdc_std shell mkdir -p /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile"],
- "send_video":["hdc_std file send D:\\DeviceTestTools\\screenshot\\vediotest\\H264_AAC.mp4 /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/"],
- "close_auto_log":["hdc_std shell \"hilog -w stop;rm /data/log/hilog/*\""],
- "start_video_log":["hdc_std shell \"hilog -r;hilog -w start -l 400000000 -m none;hilog -G 512M\""],
- "start_test":["hdc_std shell aa start -a ohos.acts.multimedia.video.videoplayer.MainAbility -b ohos.acts.multimedia.video.videoplayer"],
- "recover_log":["hdc_std shell \"cd data/log/hilog/;hilog -x > video_log.txt\""],
- "stop_hilog":["hdc_std shell hilog -w stop"],
- "check_result":["hdc_std shell \"cd /data/log/hilog && grep 'total cases' video_log.txt\"", ""],
- "compress_log":["hdc_std shell \"cd /data/log/hilog && tar -cf video_log.tar video_*\""],
- "clear_log":["hdc_std shell rm /data/log/hilog/*"],
+ "mk_test_dir":["mkdir -p /data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile"],
+ "close_auto_log":["hilog -w stop;rm /data/log/hilog/*"],
+ "start_video_log":["hilog -r;hilog -w start -l 400000000 -m none;hilog -G 512M"],
+ "start_test":["aa start -a ohos.acts.multimedia.video.videoplayer.MainAbility -b ohos.acts.multimedia.video.videoplayer"],
+ "recover_log":["cd data/log/hilog/;hilog -x > video_log.txt"],
+ "check_result":["cd /data/log/hilog && grep -nr 'total cases'", ""],
+ "compress_log":["cd /data/log/hilog && tar -cf video_log.tar video_*"],
+ "clear_log":["rm /data/log/hilog/*"],
"all_actions": [
- [2, "install_video_test"], [2, "mk_test_dir"], [2, "remount"], [2, "send_video"], [2, "close_auto_log"],
- [0, "start_video_log"], [15, "start_test"],[2, "recover_log"], [2, "stop_hilog"], [2, "check_result"], [2, "compress_log"],
- [2, "recv_log-file", "/data/log/hilog/video_log.tar"], [2, "clear_log"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"]
+ [2, "install_hap", "vediotest/ActsVideoPlayerJsTest.hap"], [2, "mk_test_dir"], [2, "remount"],
+ [2, "send_file_to_dev", "vediotest/H264_AAC.mp4", "/data/app/el1/bundle/public/ohos.acts.multimedia.video.videoplayer/ohos.acts.multimedia.video.videoplayer/assets/entry/resources/rawfile/"],
+ [15, "start_test"], [2, "stop_hilog"], [2, "check_result"], [2, "compress_log"],
+ [2, "get_file_from_dev", "/data/log/hilog/video_log.tar"], [2, "clear_log"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "recent-x-y"], [2, "recent_del-x-y"]
]
},
{
"app_name": "audio_render",
"entry": "",
- "remount":["hdc_std shell mount -o rw,remount /"],
- "sendfile1":["hdc_std file send D:\\DeviceTestTools\\screenshot\\audiotest\\audio_renderer_unit_test /data/"],
- "sendfile2":["hdc_std file send D:\\DeviceTestTools\\screenshot\\audiotest\\test_44100_2.wav /data/"],
- "chmodfile":["hdc_std shell chmod 777 /data/audio_renderer_unit_test"],
- "audio_render_test":["hdc_std shell ./data/audio_renderer_unit_test",""],
- "stop_hilog":["hdc_std shell hilog -w stop"],
- "compress_log":["hdc_std shell \"cd /data/log/hilog && tar -cf audio_render_log.tar *\""],
+ "remount":["mount -o rw,remount /"],
+ "chmodfile1":["chmod 777 /data/audio_renderer_unit_test"],
+ "audio_render_test":["cd /data && ./audio_renderer_unit_test && rm *.xml", ""],
+ "compress_log":["cd /data/log/hilog && tar -cf audio_render_log.tar *"],
"all_actions": [
- [2, "remount"], [2, "sendfile1"], [2, "sendfile2"], [2, "chmodfile"],
- [5, "audio_render_test"], [2, "stop_hilog"], [2, "compress_log"], [2, "recv_log-file", "/data/log/hilog/audio_render_log.tar"]
+ [2, "remount"], [2, "send_file_to_dev", "audiotest/audio_renderer_unit_test", "/data/"], [2, "send_file_to_dev", "audiotest/test_44100_2.wav", "/data/"], [2, "chmodfile1"],
+ [5, "audio_render_test"], [2, "stop_hilog"], [2, "compress_log"], [2, "get_file_from_dev", "/data/log/hilog/audio_render_log.tar"]
]
},
{
"app_name": "camera",
"entry": "",
- "check_result":["hdc_std shell \"cd /data/log/hilog && grep -nr PreviewOutputCallback\"", "OnFrameStarted"],
- "compress_log":["hdc_std shell \"cd /data/log/hilog && tar -cf camera_log.tar *\""],
- "close_auto_log":["hdc_std shell \"hilog -w stop;rm /data/log/hilog/*;hilog -G 512M\""],
- "open_camera_log":["hdc_std shell \"hilog -b X;hilog -b D -T CAMERA;hilog -r\""],
- "start_camera":["hdc_std shell aa start -a MainAbility -b com.ohos.camera"],
- "recover_log":["hdc_std shell \"cd data/log/hilog/;hilog -x > camera_log.txt;hilog -b D"],
+ "check_result":["cd /data/log/hilog && grep -nr PreviewOutputCallback", ""],
+ "compress_log":["cd /data/log/hilog && tar -cf camera_log.tar *"],
+ "close_auto_log":["hilog -w stop;rm /data/log/hilog/*"],
+ "open_camera_log":["hilog -b X;hilog -b D -T CAMERA;hilog -r"],
+ "start_camera":["aa start -a MainAbility -b com.ohos.camera"],
+ "recover_log":["cd data/log/hilog/;hilog -x > camera_log.txt;hilog -b D"],
"take_photo-x-y":[360, 1050], "picture-x-y":[245, 1060], "to_photo-x-y":[225, 25],
"first_pic-x-y":[100, 250], "pic_del1-x-y":[500, 1165], "pic_del2-x-y":[445, 1150],
"all_actions": [
[1, "close_auto_log"], [1, "open_camera_log"], [5, "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"], [2, "permisson_ok-x-y"], [2, "recover_log"], [3, "check_result"],
- [2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "compress_log"], [2, "recv_log-file", "/data/log/hilog/camera_log.tar"]
+ [2, "shot_cmd"], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "compress_log"], [2, "get_file_from_dev", "/data/log/hilog/camera_log.tar"]
]
},
{
"app_name": "settings_keyboard",
"entry": "aa start -a com.ohos.settings.MainAbility -b com.ohos.settings",
- "compress_log":["hdc_std shell \"cd /data/log/hilog && tar -cf settings_keyboard_log.tar *\""],
+ "compress_log":["cd /data/log/hilog && tar -cf settings_keyboard_log.tar *"],
"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], [2, "stop_hilog"], [2, "compress_log"], [2, "recv_log-file", "/data/log/hilog/settings_keyboard_log.tar"]
+ [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], [2, "stop_hilog"], [2, "compress_log"], [2, "get_file_from_dev", "/data/log/hilog/settings_keyboard_log.tar"]
]
},
{
@@ -116,13 +112,13 @@
{
"app_name": "distributedcalc",
"entry": "aa start -a com.example.distributedcalc.default -b com.example.distributedcalc",
- "compress_log":["hdc_std shell \"cd /data/log/hilog && tar -cf calc_log.tar *\""],
- "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", 200000], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "stop_hilog"], [2, "compress_log"], [2, "recv_log-file", "/data/log/hilog/calc_log.tar"]]
+ "compress_log":["cd /data/log/hilog && tar -cf calc_log.tar *"],
+ "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", 200000], [2, "recent-x-y"], [2, "recent_del-x-y"], [2, "stop_hilog"], [2, "compress_log"], [2, "get_file_from_dev", "/data/log/hilog/calc_log.tar"]]
},
{
"app_name": "note",
"entry": "aa start -a MainAbility -b com.ohos.note",
- "compress_log":["hdc_std shell \"cd /data/log/hilog && tar -cf note_log.tar *\""],
- "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"], [2, "stop_hilog"], [2, "compress_log"], [2, "recv_log-file", "/data/log/hilog/note_log.tar"]]
+ "compress_log":["cd /data/log/hilog && tar -cf note_log.tar *"],
+ "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"], [2, "stop_hilog"], [2, "compress_log"], [2, "get_file_from_dev", "/data/log/hilog/note_log.tar"]]
}
]
diff --git a/screenshot/resource/capturescreentest.py b/screenshot/resource/capturescreentest.py
index fd68383b09885ff2f7cec9a9e6bc6788a0719bb5..08010ec517faa2a2831b45d36985ec865439eb4d 100644
--- a/screenshot/resource/capturescreentest.py
+++ b/screenshot/resource/capturescreentest.py
@@ -11,6 +11,7 @@
# 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
@@ -19,10 +20,11 @@ import time
import argparse
import re
import subprocess
+import shlex
-def MyPrint(str):
+def PrintToLog(str):
print(str)
- with open(os.path.join(args.save_path, 'shot_test.log'), mode='a', encoding='utf-8') as log_file:
+ with open(os.path.join(args.save_path, 'shot_test_{}.log'.format(args.device_num)), mode='a', encoding='utf-8') as log_file:
console = sys.stdout
sys.stdout = log_file
print(str)
@@ -32,180 +34,257 @@ def MyPrint(str):
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:
- bf = p._stream.buffer.read()
- try:
- result=bf.decode().strip()
- except UnicodeDecodeError:
- result=bf.decode('gbk', errors='ignore').strip()
-
+ global CmdRetryCnt
+ CmdRetryCnt = 1
+ EnterCmdRetry = 2
+ while EnterCmdRetry:
+ EnterCmdRetry -= 1
+ try:
+ p = subprocess.Popen(mycmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ result, unused_err = p.communicate(timeout=15)
+ try:
+ result=result.decode(encoding="utf-8")
+ except UnicodeDecodeError:
+ result=result.decode('gbk', errors='ignore')
+ break
+ except Exception as e:
+ result = 'retry failed again'
+ PrintToLog(e)
+ PrintToLog("cmd_retry_trace_{}.png".format(CmdRetryCnt))
+ os.system("hdc_std -t {} shell \" snapshot_display -f /data/cmd_retry_trace_{}.png\"".format(args.device_num, CmdRetryCnt))
+ GetFileFromDev("/data/cmd_retry_trace_{}.png".format(CmdRetryCnt), args.save_path)
+ CmdRetryCnt += 1
+ p.kill()
if printresult == 1:
- MyPrint(mycmd)
- MyPrint(result)
+ with open(os.path.join(args.save_path, 'shot_test_{}.bat'.format(args.device_num)), mode='a', encoding='utf-8') as cmd_file:
+ cmd_file.write(mycmd + '\n')
+ cmd_file.close()
+ PrintToLog(mycmd)
+ PrintToLog(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()
+ if printresult == 1:
+ with open(os.path.join(args.save_path, 'shot_test_{}.bat'.format(args.device_num)), 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 EnterShellCmd(shellcmd, waittime = 0, printresult = 1):
+ if shellcmd == "":
+ return
+ cmd = "hdc_std -t {} shell \"{}\"".format(args.device_num, shellcmd)
+ return EnterCmd(cmd, waittime, printresult)
+
+def SendFileToDev(src, dst):
+ cmd = "hdc_std -t {} file send \"{}\" \"{}\"".format(args.device_num, src, dst)
+ return EnterCmd(cmd, 1, 1)
+
+def GetFileFromDev(src, dst):
+ cmd = "hdc_std -t {} file recv \"{}\" \"{}\"".format(args.device_num, src, dst)
+ return EnterCmd(cmd, 1, 1)
+
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)
+ EnterShellCmd("mkdir /data/l2tool", 1)
+ SendFileToDev(os.path.normpath(os.path.join(tools_path, "l2tool/busybox")), "/data/l2tool/")
+ SendFileToDev(os.path.normpath(os.path.join(tools_path, "l2tool/dhcpc.sh")), "/data/l2tool/")
+ SendFileToDev(os.path.normpath(os.path.join(tools_path, "l2tool/wpa_supplicant.conf")), "/data/l2tool/")
+ EnterShellCmd("wpa_supplicant -B -d -i wlan0 -c /data/l2tool/wpa_supplicant.conf", 1)
+ EnterShellCmd("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:
+ PrintToLog("hdc_std shell ./data/l2tool/busybox udhcpc -i wlan0 -s /data/l2tool/dhcpc.sh")
+ p = subprocess.check_output(shlex.split("hdc_std -t {} shell ./data/l2tool/busybox udhcpc -i wlan0 -s /data/l2tool/dhcpc.sh".format(args.device_num)), timeout=8)
+ PrintToLog(p.decode(encoding="utf-8"))
+ with open(os.path.join(args.save_path, 'shot_test_{}.bat'.format(args.device_num)), 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)
+ PrintToLog(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)
+ PrintToLog(ip)
if len(ip) <= 0:
break
if len(re.findall(r'(? 0 and int(num[0]) < 1000000:
+ PrintToLog("remove lock is ok!\n\n")
+ break
+ elif rebootcnt >= 1:
+ PrintToLog("remove lock failed, reboot and try!!!\n\n")
+ os.system("hdc_std -t {} shell reboot".format(args.device_num))
+ for i in range(5):
+ EnterCmd("hdc_std list targets", 10)
+
+ else:
+ PrintToLog("remove lock failed\n\n")
+ break
+ try:
+ args.test_num.index('/')
+ idx_total = args.test_num.split('/')
+ if len(idx_total) != 2:
+ PrintToLog("test_num is invaild !!!")
+ PrintToLog("End of check, test failed!")
+ sys.exit(1)
+ elif idx_total[1] == '1':
+ idx_list = list(range(1, len(all_app)))
+ else:
+ idx_list = global_pos['DEVICE_{}'.format(idx_total[0])]
+ except ValueError as e:
+ PrintToLog(e)
+ idx_list = list(map(eval, args.test_num.split()))
+
+ PrintToLog(idx_list)
fail_idx_list = []
fail_name_list = []
+ smoke_first_failed = ''
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:
+ call_app_cmd = single_app['entry']
+ capture_screen_cmd = "/data/screen_test/printscreen -f /data/screen_test/{}_{}"
+ cmp_cmd = "cmp -l /data/screen_test/{}_{} /data/screen_test/train_set/{} | wc -l"
+ PrintToLog("\n\n########## case {} : {} test start ##############".format(idx, single_app['app_name']))
+ with open(os.path.join(args.save_path, 'shot_test_{}.bat'.format(args.device_num)), 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()
testcnt = 5
while testcnt:
testok = 0
if testcnt != 5:
- MyPrint(">>>>>>>>>>>>>>>>>>>>>>>Try again:\n")
- with open(os.path.join(args.save_path, 'shot_test.bat'), mode='a', encoding='utf-8') as cmd_file:
+ PrintToLog(">>>>>>>>>>>>>>>>>>>>>>>Try again:\n")
+ with open(os.path.join(args.save_path, 'shot_test_{}.bat'.format(args.device_num)), mode='a', encoding='utf-8') as cmd_file:
cmd_file.write("\n::::::Last failed, Try again \n")
cmd_file.close()
- EnterCmd("hdc_std shell \"rm /data/log/hilog/*;hilog -r;hilog -w start -l 400000000 -m none\"", 1)
+ EnterShellCmd("rm /data/log/hilog/*;hilog -r;hilog -w start -l 400000000 -m none", 1)
if single_app['entry'] != "":
- EnterCmd(call_app_cmd, 5)
- MyPrint(single_app['all_actions'])
+ EnterShellCmd(call_app_cmd, 5)
+ PrintToLog(single_app['all_actions'])
+ raw_pic_name = ''
+ pic_name = ''
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"
+ pic_name = "{}{}".format(single_action[2], ".png")
raw_pic_name = single_action[2] + ".pngraw"
else:
- pic_name = single_app['app_name'] + ".png"
+ pic_name = "{}{}".format(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)
- p = EnterCmd("hdc_std shell ls -al /data/screen_test/{}".format(raw_pic_name), 1)
+ EnterShellCmd(capture_screen_cmd.format(6 - testcnt, pic_name), 1)
+ GetFileFromDev("/data/screen_test/{}_{}".format(6 - testcnt, pic_name), args.save_path)
+ p = EnterShellCmd("ls -al /data/screen_test/{}_{}".format(6 - testcnt, raw_pic_name), 1)
no_such = re.findall(r'No such file or directory', p)
- print(no_such)
+ PrintToLog(no_such)
if type(no_such) == list and len(no_such) > 0 and no_such[0] == 'No such file or directory':
- MyPrint("ERROR: {} screenshot failed!\n\n".format(raw_pic_name))
- MyPrint("End of check, test failed!")
+ PrintToLog("ERROR: {} screenshot failed!\n\n".format(raw_pic_name))
+ PrintToLog("End of check, test failed!")
sys.exit(255)
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)
+ SendFileToDev(os.path.normpath(os.path.join(args.anwser_path, raw_pic_name)), "/data/screen_test/train_set")
+ new_cmp_cmd = cmp_cmd.format(6 - testcnt, 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])
+ p = EnterShellCmd(new_cmp_cmd, single_action[0])
num = re.findall(r'[-+]?\d+', p)
- MyPrint(num)
+ PrintToLog(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))
+ PrintToLog("{} screenshot check is ok!\n\n".format(raw_pic_name))
else:
testok = -1
- MyPrint("{} screenshot check is abnarmal!\n\n".format(raw_pic_name))
+ PrintToLog("{} 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':
+ if testok == 1 or testcnt == 1:
+ old_name = os.path.normpath(os.path.join(args.save_path, "{}_{}".format(6 - testcnt, pic_name)))
+ GetFileFromDev("/data/screen_test/{}_{}".format(6 - testcnt, raw_pic_name), args.save_path)
+ os.system("rename {} {}".format(old_name, pic_name))
+ os.system("rename {}raw {}raw".format(old_name, pic_name))
+ raw_pic_name = ''
+ elif type(single_action[1]) == str and single_action[1] == 'install_hap':
+ next_cmd = ""
+ if len(single_action) == 3:
+ EnterCmd("hdc_std -t {} install \"{}\"".format(args.device_num, os.path.normpath(os.path.join(args.tools_path, single_action[2]))))
+ elif type(single_action[1]) == str and single_action[1] == 'get_file_from_dev':
next_cmd = ""
if len(single_action) == 3:
- logfilepath = single_action[2]
- next_cmd = "hdc_std file recv {} {}".format(logfilepath, args.save_path)
+ EnterCmd("hdc_std -t {} file recv \"{}\" \"{}\"".format(args.device_num, single_action[2], os.path.normpath(args.save_path)))
+ elif type(single_action[1]) == str and single_action[1] == 'send_file_to_dev':
+ next_cmd = ""
+ if len(single_action) == 4:
+ EnterCmd("hdc_std -t {} file send \"{}\" \"{}\"".format(args.device_num, os.path.normpath(os.path.join(args.tools_path, single_action[2])), single_action[3]))
elif type(single_action[1]) == str and single_action[1] == 'connect_wifi':
next_cmd = ""
connect_to_wifi(args.tools_path)
@@ -218,50 +297,56 @@ if __name__ == "__main__":
#this cmd is real cmd,and have a except answer
if type(target_[0]) == str:
next_cmd = ""
- p = EnterCmd(target_[0], single_action[0])
+ p = EnterShellCmd(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]))
+ PrintToLog("\"{}\" 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]))
+ PrintToLog("\"{}\" 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])
+ next_cmd = "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 fail_name_list.count(single_app['app_name']):
- fail_name_list.remove(single_app['app_name'])
+ next_cmd = "uinput -M -m {} {} -c 0".format(single_action[1], single_action[2])
+ EnterShellCmd(next_cmd, single_action[0])
+
if testok == 1:
- MyPrint("testcase {}, {} is ok!\n\n".format(idx, single_app['app_name']))
+ PrintToLog("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']))
+ elif testok == -1 and smoke_first_failed == '':
+ #PrintToLog("ERROR:testcase {}, {} is failed!\n\n".format(idx, single_app['app_name']))
+ if testcnt == 1:
+ fail_idx_list.append(idx)
+ fail_name_list.append(single_app['app_name'])
+ smoke_first_failed = single_app['app_name']
+ PrintToLog("ERROR:testcase {}, {} is failed!\n\n".format(idx, single_app['app_name']))
+ testcnt -= 1
+ elif testok == -1 and smoke_first_failed != '':
fail_idx_list.append(idx)
fail_name_list.append(single_app['app_name'])
- if testcnt == 1 and single_app['app_name'] == 'launcher':
- MyPrint("ERROR: name {}, index {}, these testcase is failed".format(fail_name_list, fail_idx_list))
- MyPrint("End of check, test failed!")
- sys.stdout.flush()
- sys.exit(len(fail_idx_list))
- testcnt -= 1
+ PrintToLog("ERROR:testcase {}, {} is failed!\n\n".format(idx, single_app['app_name']))
+ testcnt = 0
else:
testcnt = 0
- EnterCmd("hdc_std shell hilog -w stop", 1)
+ EnterShellCmd("hilog -w stop", 1)
+ if smoke_first_failed == 'launcher':
+ break
+ EnterShellCmd("cd /data/log/faultlog/temp && tar -cf after_test_crash_log.tar cppcrash*")
+ EnterCmd("hdc_std -t {} file recv /data/log/faultlog/temp/after_test_crash_log.tar {}".format(args.device_num, os.path.normpath(args.save_path)))
if len(fail_idx_list) != 0:
- MyPrint("ERROR: {}, these testcase is failed".format(fail_idx_list))
- MyPrint("End of check, test failed!")
+ PrintToLog("ERROR: name {}, index {}, these testcase is failed".format(fail_name_list, fail_idx_list))
+ if fail_name_list.count('launcher') or fail_name_list.count('settings_keyboard'):
+ PrintToLog("End of check, Some Key APPs(launcher or setting) failed!")
+ PrintToLog("End of check, test failed!")
else:
- MyPrint("All testcase is ok")
- MyPrint("End of check, test succeeded!")
+ PrintToLog("All testcase is ok")
+ PrintToLog("End of check, test succeeded!")
sys.stdout.flush()
sys.exit(len(fail_idx_list))
\ No newline at end of file