diff --git a/app/demolink/BUILD.gn b/app/demolink/BUILD.gn index f46075f9430bda14b11444b96866edf67b0470b7..48ce7caf74844e188ec008c1c6d5561eaf685aa8 100644 --- a/app/demolink/BUILD.gn +++ b/app/demolink/BUILD.gn @@ -12,10 +12,11 @@ # limitations under the License. static_library("example_demolink") { - sources = [ "helloworld.c" ] - - include_dirs = [ - "//utils/native/lite/include", - "//domains/iot/link/libbuild", + sources = [ + "demosdk.c", + "demosdk_adapter.c", + "helloworld.c", ] + + include_dirs = [ "//utils/native/lite/include" ] } diff --git a/app/demolink/demosdk.c b/app/demolink/demosdk.c new file mode 100644 index 0000000000000000000000000000000000000000..beb196f68fd0f7845cad2678df21ceddb80ffff8 --- /dev/null +++ b/app/demolink/demosdk.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 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. + */ +#include "demosdk.h" + +#include + +#include "demosdk_adapter.h" + +#define TASK_STACK_SIZE 1000 +#define TASK_PRIO 20 +#define SECOND_CNT 1000 + +void *DemoSdkBiz(const char *arg) +{ + (void)arg; + while (1) { + printf("it is demo biz: hello world.\n"); + DemoSdkSleepMs(SECOND_CNT); + } + return NULL; +} + +int DemoSdkEntry(void) +{ + printf("it is demosdk entry.\n"); + struct TaskPara para = {0}; + para.name = "demotask"; + para.func = (void *)DemoSdkBiz; + para.prio = TASK_PRIO; + para.size = TASK_STACK_SIZE; + unsigned int handle; + int ret = DemoSdkCreateTask(&handle, ¶); + if (ret != 0) { + printf("create task fail.\n"); + return -1; + } + return 0; +} diff --git a/app/demolink/demosdk.h b/app/demolink/demosdk.h new file mode 100644 index 0000000000000000000000000000000000000000..cecd86bf70fd4c0a0f25c0e61514a6c27fc48519 --- /dev/null +++ b/app/demolink/demosdk.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 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. + */ + +#ifndef DEMOSDK_H +#define DEMOSDK_H + +int DemoSdkEntry(void); + +#endif // DEMOSDK_H diff --git a/app/demolink/demosdk_adapter.c b/app/demolink/demosdk_adapter.c new file mode 100644 index 0000000000000000000000000000000000000000..aecd2a7558a392b0d1041cae4cb8ed998ec9794c --- /dev/null +++ b/app/demolink/demosdk_adapter.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2020 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. + */ + +#include "demosdk_adapter.h" +#include + +#include "cmsis_os2.h" + +#define MS_CNT 1000 + +int DemoSdkCreateTask(unsigned int *handle, const struct TaskPara *para) +{ + osThreadAttr_t attr = {0}; + osThreadId_t threadId; + if (handle == 0 || para == 0) { + return DEMOSDK_ERR; + } + + if (para->func == 0) { + return DEMOSDK_ERR; + } + + if (para->name == 0) { + return DEMOSDK_ERR; + } + + attr.name = para->name; + attr.priority = para->prio; + attr.stack_size = para->size; + threadId = osThreadNew((osThreadFunc_t)para->func, para->arg, &attr); + if (threadId == 0) { + printf("osThreadNew fail\n"); + return DEMOSDK_ERR; + } + + *(unsigned int *)handle = (unsigned int)threadId; + return DEMOSDK_OK; +} + +void DemoSdkSleepMs(int ms) +{ + usleep(MS_CNT * ms); +} + diff --git a/app/demolink/demosdk_adapter.h b/app/demolink/demosdk_adapter.h new file mode 100644 index 0000000000000000000000000000000000000000..5c836099a77c08c83dcd839867a7a5d0e056bb9e --- /dev/null +++ b/app/demolink/demosdk_adapter.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2020 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. + */ + +#ifndef DEMOSDK_ADAPTER_H +#define DEMOSDK_ADAPTER_H + +#define DEMOSDK_ERR (-1) +#define DEMOSDK_OK 0 + +struct TaskPara { + char *name; + void *(*func)(char* arg); + void *arg; + unsigned char prio; + unsigned int size; +}; + +int DemoSdkCreateTask(unsigned int *handle, const struct TaskPara *para); +void DemoSdkSleepMs(int ms); + +#endif // DEMOSDK_ADAPTER_H diff --git a/screenshot/audiotest/audio_renderer_unit_test b/screenshot/audiotest/audio_renderer_unit_test index 1d2809162e5d7ea884fc56f550c90d7193009e69..7d28912bb91459a59bcd5dfba80d525320946f3e 100644 Binary files a/screenshot/audiotest/audio_renderer_unit_test and b/screenshot/audiotest/audio_renderer_unit_test differ diff --git a/screenshot/resource/app_capture_screen_test_config.json b/screenshot/resource/app_capture_screen_test_config.json index 02086ef307756a2838dcbb8d0c8c336b91c2c5c7..1e9a86aefff2d60942313ef5d592308f2a86a73a 100644 --- a/screenshot/resource/app_capture_screen_test_config.json +++ b/screenshot/resource/app_capture_screen_test_config.json @@ -66,7 +66,7 @@ "entry": "", "remount":["mount -o rw,remount /"], "chmodfile1":["chmod 777 /data/audio_renderer_unit_test"], - "audio_render_test":["cd /data && ./audio_renderer_unit_test && rm *.xml", "[ PASSED ] 1 test"], + "audio_render_test":["cd /data && ./audio_renderer_unit_test --gtest_filter=AudioRendererUnitTest.Audio_Renderer_Playback_001 && rm *.xml", "[ PASSED ] 1 test"], "compress_log":["cd /data/log/hilog && tar -cf audio_render_log.tar *"], "all_actions": [ [1, "remount"], [1, "send_file_to_dev", "audiotest/audio_renderer_unit_test", "/data/"], [1, "send_file_to_dev", "audiotest/test_44100_2.wav", "/data/"], [2, "chmodfile1"], @@ -101,8 +101,8 @@ "entry": "aa start -a com.ohos.photos.MainAbility -b com.ohos.photos", "compress_log":["cd /data/log/hilog && tar -cf photos_log.tar *"], "all_actions": [ - [2, "shot_cmd", "photo_check_1"], [2, "permisson_ok-x-y"], [2, "shot_cmd", "photo_check_2"], [2, "permisson_ok-x-y"], [2, "shot_cmd", "photo_check_3"], [2, "permisson_ok-x-y"], [2, "shot_cmd"], [2, "recent-x-y"], [2, "shot_cmd", "photo_check_4"], [2, "recent_del-x-y"], - [2, "shot_cmd", "photo_check_5"], [2, "recent-x-y"], [2, "recent_del-x-y"], [1, "stop_hilog"], [1, "compress_log"], [1, "get_file_from_dev", "/data/log/hilog/photos_log.tar"] + [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"], [1, "cmp_cmd-level"], + [2, "recent-x-y"], [2, "recent_del-x-y"], [1, "stop_hilog"], [1, "compress_log"], [1, "get_file_from_dev", "/data/log/hilog/photos_log.tar"] ] }, { diff --git a/screenshot/resource/capturescreentest.py b/screenshot/resource/capturescreentest.py index fe30b18d1af8e60fc804762f0e35fcc9c53ae419..330b1bc36bced1fb74a18c112cfe9faaf0434103 100644 --- a/screenshot/resource/capturescreentest.py +++ b/screenshot/resource/capturescreentest.py @@ -147,7 +147,7 @@ if __name__ == "__main__": cmp_status = 0 global_pos = all_app[0] - + #rmlock rebootcnt = 2 while rebootcnt: @@ -249,10 +249,10 @@ if __name__ == "__main__": 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 + testcnt = 3 while testcnt: testok = 0 - if testcnt != 5: + if testcnt != 3: 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") @@ -272,9 +272,9 @@ if __name__ == "__main__": else: pic_name = "{}{}".format(single_app['app_name'], ".png") raw_pic_name = single_app['app_name'] + ".pngraw" - EnterShellCmd("rm /data/screen_test/{}_{}*".format(6 - testcnt, 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) + EnterShellCmd("rm /data/screen_test/{}_{}*".format(4 - testcnt, pic_name), 1) + EnterShellCmd(capture_screen_cmd.format(4 - testcnt, pic_name), 1) + GetFileFromDev("/data/screen_test/{}_{}".format(4 - testcnt, pic_name), args.save_path) 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': @@ -282,7 +282,7 @@ if __name__ == "__main__": sys.stdout.flush() EnterShellCmd("rm /data/train_set/{}".format(raw_pic_name), 1) 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) + new_cmp_cmd = cmp_cmd.format(4 - testcnt, raw_pic_name, raw_pic_name) if len(single_action) == 3: tolerance = single_action[2] else: @@ -301,8 +301,8 @@ if __name__ == "__main__": PrintToLog("{} screenshot check is abnarmal!\n\n".format(raw_pic_name)) sys.stdout.flush() if testok == 1 or testcnt == 1 or smoke_first_failed != '': - 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) + old_name = os.path.normpath(os.path.join(args.save_path, "{}_{}".format(4 - testcnt, pic_name))) + GetFileFromDev("/data/screen_test/{}_{}".format(4 - 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 = '' @@ -323,10 +323,10 @@ if __name__ == "__main__": ConnectToWifi(args.tools_path) elif type(single_action[1]) == str and single_action[1] == 'log_packaging': next_cmd = "" - EnterShellCmd("cd /data/log/hilog && tar -cf photos_log_{}.tar *".format(5 - testcnt)) + EnterShellCmd("cd /data/log/hilog && tar -cf photos_log_{}.tar *".format(4 - testcnt)) elif type(single_action[1]) == str and single_action[1] == 'get_photos_log_from_dev': next_cmd = "" - EnterCmd("hdc_std -t {} file recv \"/data/log/hilog/photos_log_{}.tar\" \"{}\"".format(args.device_num, 5 - testcnt, os.path.normpath(args.save_path))) + EnterCmd("hdc_std -t {} file recv \"/data/log/hilog/photos_log_{}.tar\" \"{}\"".format(args.device_num, 4 - testcnt, os.path.normpath(args.save_path))) #process_crash_check elif type(single_action[1]) == str and single_action[1] == 'process_crash_check': next_cmd = "" @@ -336,13 +336,13 @@ if __name__ == "__main__": findsome = result.find(single_action[2], 0, len(result)) if findsome != -1: testok = -1 - PrintToLog("\"{}\" ERROR:find crux crash \"{}\"!\n".format(single_action[1], single_action[2])) + PrintToLog("\"{}\" ERROR:find fatal crash \"{}\"!\n".format(single_action[1], single_action[2])) PrintToLog("SmokeTest find some fatal problems!") PrintToLog("End of check, test failed!") SysExit() else: testok = 1 - PrintToLog("\"{}\" check execut result is ok, not find crux crash \"{}\"!\n".format(single_action[1], single_action[2])) + PrintToLog("\"{}\" check execut result is ok, not find fatal crash \"{}\"!\n".format(single_action[1], single_action[2])) sys.stdout.flush() #other cmd handle elif type(single_action[1]) == str: @@ -431,24 +431,44 @@ if __name__ == "__main__": EnterShellCmd("cd /data/log/faultlog/temp && tar -cf after_test_crash_log_{}.tar cppcrash*".format(args.device_num)) GetFileFromDev("/data/log/faultlog/temp/after_test_crash_log_{}.tar".format(args.device_num), os.path.normpath(args.save_path)) - crash_cnt = EnterShellCmd("cd /data/log/faultlog/temp && find . -name cppcrash*", 2) - result = "".join(crash_cnt) - findsome = result.find("cppcrash", 0, len(result)) - if findsome != -1: - PrintToLog("ERROR:find cppcrash !\n") - PrintToLog("SmokeTest find some fatal problems!") - PrintToLog("End of check, test failed!") - SysExit() + EnterShellCmd("cd /data/log/faultlog/temp && find . -name cppcrash*", 2) + EnterShellCmd("cd /data/log/faultlog/temp && grep \"Process name\" -rnw ./", 2) + + fail_str_list = [str(x) for x in fail_idx_list] + reboot_test_num = " ".join(fail_str_list) + print(fail_str_list) if len(fail_idx_list) != 0: - 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("SmokeTest find some fatal problems!") + with open(os.path.normpath(os.path.join(args.tools_path, "reboot.txt")), mode='a+') as f: + f.seek(0) + reboot_result = f.read() + f.close() + if len(reboot_result) < 1: + os.system("mkdir {}\\reboot".format(args.save_path)) + with open(os.path.normpath(os.path.join(args.tools_path, "reboot.txt")), mode='w') as f: + f.write("reboot") + f.close() + PrintToLog("ERROR: name {}, index {}, these testcase is failed, reboot and try!!".format(fail_name_list, fail_idx_list)) + EnterShellCmd("rm -rf /data/*;reboot") + reboot_result_list = EnterCmd("hdc_std list targets", 2) + number = 0 + while "7001005458323933328a" not in reboot_result_list and number < 15: + reboot_result_list = EnterCmd("hdc_std list targets", 2) + number += 1 + EnterShellCmd("rm /data/log/hilog/*;hilog -r;hilog -w start -l 400000000 -m none", 1) + py_cmd = os.system("python {}\\resource\\capturescreentest.py --config {}\\resource\\app_capture_screen_test_config.json --anwser_path {} --save_path {}\\reboot --tools_path {} --test_num \"{}\"".format(args.tools_path, args.tools_path, args.anwser_path, args.save_path, args.tools_path, reboot_test_num)) + if py_cmd == 0: + sys.exit(0) + elif py_cmd == 98: + sys.exit(98) + else: + sys.exit(99) + else: + PrintToLog("ERROR: name {}, index {}, these testcase is failed".format(fail_name_list, fail_idx_list)) + PrintToLog("SmokeTest find some key problems!") PrintToLog("End of check, test failed!") - SysExit() - PrintToLog("SmokeTest find some key problems!") - PrintToLog("End of check, test failed!") - sys.exit(98) + sys.exit(98) else: PrintToLog("All testcase is ok") PrintToLog("End of check, test succeeded!") - sys.exit(0) \ No newline at end of file + sys.exit(0) + diff --git a/screenshot/resource/process.txt b/screenshot/resource/process.txt index 3732e227e60cde01f6f3c703f9036a28ff447b81..c2fa51c6a93cdcc0bdd5c6f18acffce88ac1cbdf 100644 --- a/screenshot/resource/process.txt +++ b/screenshot/resource/process.txt @@ -26,7 +26,6 @@ audio_policy deviceauth_service softbus_server wifi_hal_service -deviceinfoservi faultloggerd accountmgr time_service @@ -51,7 +50,6 @@ usb_service camera_service thermal foundation -accesstoken_ser hdcd disp_gralloc_host light_dal_host