test@test-pc:~/workspace/share/testcase/test_tee$ tree .
.
├── resource
│   ├── googlekey
│   │   ├── default_googlekey.bin
│   │   └── kmsetkey_ca
│   └── vts_testcase
│       ├── VtsHalBiometricsFaceV1_0TargetTest
│       │   ├── arm
│       │   │   └── VtsHalBiometricsFaceV1_0TargetTest
│       │   ├── arm64
│       │   │   └── VtsHalBiometricsFaceV1_0TargetTest
│       │   └── VtsHalBiometricsFaceV1_0TargetTest.config
│       ├── VtsHalBiometricsFingerprintV2_1TargetTest
│       │   ├── arm
│       │   │   └── VtsHalBiometricsFingerprintV2_1TargetTest
│       │   ├── arm64
│       │   │   └── VtsHalBiometricsFingerprintV2_1TargetTest
│       │   └── VtsHalBiometricsFingerprintV2_1TargetTest.config
│       ├── VtsHalBiometricsFingerprintV2_2TargetTest
│       │   ├── arm
│       │   │   └── VtsHalBiometricsFingerprintV2_2TargetTest
│       │   ├── arm64
│       │   │   └── VtsHalBiometricsFingerprintV2_2TargetTest
│       │   └── VtsHalBiometricsFingerprintV2_2TargetTest.config
│       ├── VtsHalGatekeeperV1_0TargetTest
│       │   ├── arm
│       │   │   └── VtsHalGatekeeperV1_0TargetTest
│       │   ├── arm64
│       │   │   └── VtsHalGatekeeperV1_0TargetTest
│       │   └── VtsHalGatekeeperV1_0TargetTest.config
│       ├── VtsHalKeymasterV3_0TargetTest
│       │   ├── arm
│       │   │   └── VtsHalKeymasterV3_0TargetTest
│       │   ├── arm64
│       │   │   └── VtsHalKeymasterV3_0TargetTest
│       │   └── VtsHalKeymasterV3_0TargetTest.config
│       ├── VtsHalKeymasterV4_0TargetTest
│       │   ├── arm
│       │   │   └── VtsHalKeymasterV4_0TargetTest
│       │   ├── arm64
│       │   │   └── VtsHalKeymasterV4_0TargetTest
│       │   └── VtsHalKeymasterV4_0TargetTest.config
│       └── VtsHalKeymasterV4_1TargetTest
│           ├── arm
│           │   └── VtsHalKeymasterV4_1TargetTest
│           ├── arm64
│           │   └── VtsHalKeymasterV4_1TargetTest
│           └── VtsHalKeymasterV4_1TargetTest.config
├── tee.json
└── tee_test.py24 directories, 25 files
# coding=utf8#  python tran_projects/common/tee/tools/tee_info.pyimport sys
import os
import shutil
import time
import random
import subprocess
import getoptimport jsondebug = 0g_verify = 0
g_enroll = 0test_vts_gatekeeper = False
test_vts_keymaster = False
test_press_locksetting = False
test_press_keymaster = False
test_press_count = 1report_list = ["gatekeeper","keymaster3.0-arm","keymaster3.0-arm64","keymaster4.0-arm","keymaster4.0-arm64","keymaster4.1-arm","keymaster4.1-arm64"]
report_result = {}locksetting = {"every_enroll":{"correct_verify": 10,"incorrect_verify": 5}
}def print_report():print("\n===============================================")print("result report:")for line in report_list:if line not in report_result:continueprint("\t[result][vts] test %s %s" % (line,report_result[line]))print("===============================================")def getRandomSet(bits):num_set = [chr(i) for i in range(48,58)]char_set = [chr(i) for i in range(97,123)]total_set = num_set + char_setvalue_set = "".join(random.sample(total_set, bits))return value_setdef generated_numbers(type):if type == "pin":return random.randint(1000,99999999)elif type == "password":return getRandomSet(8)elif type == "pattern":return "12369"else:return "0000"
def generated_cipher(type):while True:res = generated_numbers(type)if res != "1478":return resdef get_args(argv):global test_vts_gatekeeperglobal test_vts_keymasterglobal test_press_locksettingglobal test_press_keymasterglobal test_press_counttry:opts, args = getopt.getopt(argv,"hv:p:n:",["--help=","--vts=","--press="])except getopt.GetoptError:print('test.py -v keymaster/gatekeeper/all')sys.exit(2)for opt, arg in opts:if opt == ("-h", "--help"):print('test.py -v <vts_testcase>,  vts_testcase:gatekeeper,keymaster,all')if opt in ("-v", "--vts"):if arg == "gatekeeper" or arg == "all":test_vts_gatekeeper = Trueif arg == "keymaster" or arg == "all":test_vts_keymaster = Trueif opt in ("-p", "--press"):if arg == "locksetting" or arg == "all":test_press_locksetting = Trueif arg == "keymaster" or arg == "all":test_press_keymaster = Trueif opt in ("-n"):test_press_count = argdef test_locksetting_pattern(testcount):for num in range(0,testcount):#new_pd = random.randint(1236,99999999)old_pd = 12369new_pd = 1236os.system("adb shell locksettings set-pattern --old %s %s" % (old_pd, new_pd))old_pd = 1236new_pd = 12369os.system("adb shell locksettings set-pattern --old %s %s" % (old_pd, new_pd))def test_locksetting_pin(type,testcount):global g_verifyif debug == 1:new_pd = "2222"type = "pin"else:new_pd = generated_cipher(type)os.system("adb shell locksettings set-%s %s" % (type, new_pd))for num in range(0,testcount):old_pd = new_pdif debug == 1:if new_pd == "2222":new_pd = "1111"else:new_pd = "2222"else:new_pd =  generated_cipher(type)output = subprocess.getstatusoutput("adb shell locksettings set-%s --old %s %s" % (type, old_pd, new_pd))for verify_count in range(0,locksetting["every_enroll"]["correct_verify"]):output = subprocess.getstatusoutput("adb shell cmd lock_settings verify --old %s" % (new_pd))if 0 == output[0] and "Lock credential verified successfully" == output[1]:g_verify = g_verify + 1print("Use the correct %s : Lock credential verified successfully. ---(pass_count=%s)pass" % (type,g_verify))else:print("%s error not as expected!!!! exit!!!" % (type))sys.exit(2)for verify_count in range(0,locksetting["every_enroll"]["incorrect_verify"]):temp_pd = "1478"output = subprocess.getstatusoutput("adb shell cmd lock_settings verify --old %s" % (temp_pd))print(output)if "Old password '1478' didn't match" in output:g_verify = g_verify + 1print("Use the incorrect %s : Old password '1478' didn't match. ---(pass_count=%s)pass" % (type,g_verify))elif "Request throttled" in output:g_verify = g_verify + 1print("Wrong %s exceeds and need wait for 30s : Request throttled. ---(pass_count=%s)pass" % (type,g_verify))time.sleep(30)else:print("%s correct not as expected!!!! exit!!!" % (type))sys.exit(2)os.system("adb shell locksettings clear --old %s" % (new_pd))def test_keymaster_use_vts(testcount):output = subprocess.getstatusoutput("adb root")output = subprocess.getstatusoutput("adb push resource/googlekey/default_googlekey.bin /data")output = subprocess.getstatusoutput("adb push resource/googlekey/kmsetkey_ca /data")output = subprocess.getstatusoutput("adb shell \"chmod 777 data/kmsetkey_ca\"")output = subprocess.getstatusoutput("adb shell ./data/kmsetkey_ca -i ./data/default_googlekey.bin")# for keymaster 4.0 - arm64print("Start to test keymaster4.0-arm64. It will take a few minutes. Please wait patiently.")output = subprocess.getstatusoutput("adb push resource/vts_testcase/VtsHalKeymasterV4_0TargetTest/arm64/VtsHalKeymasterV4_0TargetTest /data")output = subprocess.getstatusoutput("adb shell \"chmod 777 /data/VtsHalKeymasterV4_0TargetTest\"")output = subprocess.getstatusoutput("adb shell ./data/VtsHalKeymasterV4_0TargetTest --gtest_break_on_failure")for line in output:print(line)print("\n\n")if "[  PASSED  ]" in str(output[1]):print("test_keymaster 4.0 - arm64  --pass")report_result["keymaster4.0-arm64"] = "Pass"else:print("test_keymaster 4.0 - arm64  --failed")report_result["keymaster4.0-arm64"] = "fail"# for keymaster 4.0 - armprint("Start to test keymaster4.0-arm. It will take a few minutes. Please wait patiently.")output = subprocess.getstatusoutput("adb push resource/vts_testcase/VtsHalKeymasterV4_0TargetTest/arm/VtsHalKeymasterV4_0TargetTest /data")output = subprocess.getstatusoutput("adb shell \"chmod 777 /data/VtsHalKeymasterV4_0TargetTest\"")output = subprocess.getstatusoutput("adb shell ./data/VtsHalKeymasterV4_0TargetTest --gtest_break_on_failure")for line in output:print(line)print("\n\n")if "[  PASSED  ]" in str(output[1]):print("test_keymaster 4.0 - arm  --pass")report_result["keymaster4.0-arm"] = "Pass"else:print("test_keymaster 4.0 - arm  --failed")report_result["keymaster4.0-arm"] = "fail"# for keymaster 4.1 - arm64print("Start to test keymaster4.1-arm64. It will take a few minutes. Please wait patiently.")output = subprocess.getstatusoutput("adb push resource/vts_testcase/VtsHalKeymasterV4_1TargetTest/arm64/VtsHalKeymasterV4_1TargetTest /data")output = subprocess.getstatusoutput("adb shell \"chmod 777 /data/VtsHalKeymasterV4_1TargetTest\"")output = subprocess.getstatusoutput("adb shell ./data/VtsHalKeymasterV4_1TargetTest --gtest_break_on_failure")for line in output:print(line)print("\n\n")if "[  PASSED  ]" in str(output[1]):print("test_keymaster 4.1 - arm64  --pass")report_result["keymaster4.1-arm64"] = "Pass"else:print("test_keymaster 4.1 - arm64  --failed")report_result["keymaster4.1-arm64"] = "fail"# for keymaster 4.1 - armprint("Start to test keymaster4.1-arm. It will take a few minutes. Please wait patiently.")output = subprocess.getstatusoutput("adb push resource/vts_testcase/VtsHalKeymasterV4_1TargetTest/arm/VtsHalKeymasterV4_1TargetTest /data")output = subprocess.getstatusoutput("adb shell \"chmod 777 /data/VtsHalKeymasterV4_1TargetTest\"")output = subprocess.getstatusoutput("adb shell ./data/VtsHalKeymasterV4_1TargetTest --gtest_break_on_failure")for line in output:print(line)print("\n\n")if "[  PASSED  ]" in str(output[1]):print("test_keymaster 4.1 - arm  --pass")report_result["keymaster4.1-arm"] = "Pass"else:print("test_keymaster 4.1 - arm  --failed")report_result["keymaster4.1-arm"] = "fail"# for keymaster 3.0 - arm64print("Start to test keymaster3.0-arm64. It will take a few minutes. Please wait patiently.")output = subprocess.getstatusoutput("adb push resource/vts_testcase/VtsHalKeymasterV3_0TargetTest/arm64/VtsHalKeymasterV3_0TargetTest /data")output = subprocess.getstatusoutput("adb shell \"chmod 777 /data/VtsHalKeymasterV3_0TargetTest\"")output = subprocess.getstatusoutput("adb shell ./data/VtsHalKeymasterV3_0TargetTest --gtest_break_on_failure")for line in output:print(line)print("\n\n")if "[  PASSED  ]" in str(output[1]):print("test_keymaster 3.0 - arm64  --pass")report_result["keymaster3.0-arm64"] = "Pass"else:print("test_keymaster 3.0 - arm64  --failed")report_result["keymaster3.0-arm64"] = "fail"# for keymaster 3.0 - armprint("Start to test keymaster3.0-arm. It will take a few minutes. Please wait patiently.")output = subprocess.getstatusoutput("adb push resource/vts_testcase/VtsHalKeymasterV3_0TargetTest/arm/VtsHalKeymasterV3_0TargetTest /data")output = subprocess.getstatusoutput("adb shell \"chmod 777 /data/VtsHalKeymasterV3_0TargetTest\"")output = subprocess.getstatusoutput("adb shell ./data/VtsHalKeymasterV3_0TargetTest --gtest_break_on_failure")for line in output:print(line)print("\n\n")if "[  PASSED  ]" in str(output[1]):print("test_keymaster 3.0 - arm  --pass")report_result["keymaster3.0-arm"] = "Pass"else:print("test_keymaster 3.0 - arm  --failed")report_result["keymaster3.0-arm"] = "fail"def test_gatekeeper_use_vts(testcount):print("Start to test gatekeeper. It will take a few minutes. Please wait patiently.")output = subprocess.getstatusoutput("adb root")output = subprocess.getstatusoutput("adb push resource/vts_testcase/VtsHalGatekeeperV1_0TargetTest/arm64/VtsHalGatekeeperV1_0TargetTest /data")output = subprocess.getstatusoutput("adb shell \"chmod 777 /data/VtsHalGatekeeperV1_0TargetTest\"")output = subprocess.getstatusoutput("adb shell ./data/VtsHalGatekeeperV1_0TargetTest")for line in output:print(line)print("\n\n")if "[  PASSED  ]" in str(output[1]):print("test_gatekeeper_use_vts--pass")report_result["gatekeeper"] = "Pass"else:print("test_gatekeeper_use_vts--failed")report_result["gatekeeper"] = "Fail"if __name__ == '__main__':print(str(sys.argv[0]) + " enter")get_args(sys.argv[1:])if test_press_locksetting == True:test_locksetting_pin("pattern", test_press_count)test_locksetting_pin("password", test_press_count)test_locksetting_pin("pin", test_press_count)print("Total testcase : %s pass" % (g_verify))if test_vts_gatekeeper == True or test_press_locksetting == True:test_gatekeeper_use_vts(test_press_count)if test_vts_keymaster == True or test_press_keymaster == True:test_keymaster_use_vts(test_press_count)if test_press_locksetting == False and test_press_keymaster == False and test_vts_gatekeeper == False and test_vts_keymaster == False:test_keymaster_use_vts(test_press_count)test_gatekeeper_use_vts(test_press_count)print_report()time.sleep(30)else:print_report()

python自动化测试locksetting/gatekeeper/keymaster/vts等相关推荐

  1. 阿里P8连肝一周整理出这份python自动化测试实战PDF

    由于细节内容实在太多啦,也为了不影响各位大大观看,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!总共整理了有282页的PDF文档,有需要的可以查看我文章最后. 整理了一份pyt ...

  2. selenium + python自动化测试环境搭建

    elenium 是一个web的自动化测试工具,不少学习功能自动化的同学开始首选selenium ,相因为它相比QTP有诸多有点: 免费,也不用再为破解QTP而大伤脑筋 小巧,对于不同的语言它只是一个包 ...

  3. selenium+python自动化测试系列(一):登录

        最近接手商城的项目,针对后台测试,功能比较简单,但是流程比较繁多,涉及到前后台的交叉测试.在对整个项目进行第一轮测试完成之后,考虑以后回归测试任务比较重,为了减轻回归测试的工作量,所以考虑后台 ...

  4. python自动化测试框架pytest.pdf_Python自动化测试框架

    随着技术的进步和自动化技术的出现,市面上出现了一些自动化测试框架.只需要进行一些适用性和效率参数的调整,这些自动化测试框架就能够开箱即用,大大节省了开发时间.而且由于这些框架被广泛使用,他们具有很好的 ...

  5. python自动化测试看什么书-《Python自动化测试实战》终于出版!!!

    一.为什么会写这本书 1.系统梳理.可以加深对测试知识体系的系统梳理 2.名气.增加个人的名气,比如:面试时,可以很自豪的说,我是xxxx书的作者 3.利他.帮助有需要的学习者更系统.完备的学习和进阶 ...

  6. 怎么自学python自动化测试-学习自动化测试,如何学习Python语言?

    一.Python常用领域Python用于简单脚本编程,如编写2048小游戏或12306的自动抢票软件: Python用于系统编程,如开发系统应用: Python用于开发网络爬虫: 有资料奉上,可以看看 ...

  7. selenium + python自动化测试unittest框架学习(五)webdriver的二次封装

    因为webdriver的api方法很长,再加上大多数的定位方式是以xpath方式定位,更加让代码看起来超级长,为了使整体的代码看起来整洁,对webdriver进行封装,学习资料来源于虫师的<se ...

  8. python自动化测试数据驱动_Python 自动化测试(四):数据驱动

    Python 自动化测试(四):数据驱动 本周测试公开课<Pytest 自动化测试最佳实践:实用特性与进阶技巧>! 在实际的测试工作中,通常需要对多组不同的输入数据,进行同样的测试操作步骤 ...

  9. python自动化测试数据驱动_利用Python如何实现数据驱动的接口自动化测试

    大家在接口测试的过程中,很多时候会用到对CSV的读取操作,本文主要说明Python3对CSV的写入和读取.下面话不多说了,来一起看看详细的介绍吧. 1.需求 某API,GET方法,token,mobi ...

最新文章

  1. 再见了Spring Cloud!这个架构有点厉害,甚至干掉了Dubbo!
  2. python 3.x urllib学习
  3. 史上最纯洁的女孩,看到我实在被雷到了。
  4. 耐寂寞谋定未来-农业大健康·国情讲坛:乡村振兴守公益心
  5. Linux系统学习----前言
  6. JavaMail发送简单邮件
  7. Python对数列进行全排列
  8. struts2自定义拦截器一——模拟登陆权限验证
  9. 函数调用关系图如何画_程序是如何在 CPU 中运行的(二)
  10. CoolFormat 源代码格式化工具使用手册
  11. 如何批量处理Word中的图片大小
  12. magento添加面包屑
  13. vue模板字符串标签动态参数_vue模板字符串
  14. ansys轴对称模型之二维模型
  15. 解决宏碁5750g ubuntu无法调整和保存屏幕亮度的问题
  16. linux环境下,实现公共聊天室功能
  17. linux动态频率调节系统cpufreq,Linux的cpufreq(动态变频)技术
  18. Dynamic Web Module 3.1 requires Java 1.7 or newer. 错误解决方案
  19. 《安富莱嵌入式周报》第285期:电子技术更新换代太快,我要躺平,Linux内核6.1已经并入RUST,一夜161个网站密码遭泄,Matlab精选课件,开源电子书
  20. win10系统重装之u盘装系统,u盘安装win10系统

热门文章

  1. 电气设计 | 图说电气成套柜的布线安装
  2. 新基建之数据中心2020
  3. 数据中心不仅可以好看,还可以变身大型暖气!
  4. 成功解决cv2.error: OpenCV(4.1.2) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: err
  5. DL之DilatedConvolutions:Dilated Convolutions(膨胀卷积/扩张卷积)算法的简介(论文介绍)、架构详解、案例应用等配图集合之详细攻略
  6. RL之Q Learning:利用强化学习之Q Learning实现走迷宫—训练智能体走到迷宫(简单迷宫)的宝藏位置
  7. MAT之GA:GA优化BP神经网络的初始权值、阈值,从而增强BP神经网络的鲁棒性
  8. angular artDialog未及时更新
  9. ES6(三)数组的扩展
  10. [读书笔记]C#学习笔记三: C#类型详解..