Exemplo n.º 1
0
if apk_file:
    print "Starting monkeyrunner strategy experiment for apk: %s" % apk_file
    res_dir = os.path.split(os.path.abspath(apk_file))[0]
#     if not os.path.exists(res_dir):
#         auxiliary_utils.mkdir(res_dir, mode=0777, overwrite=True)
    print "Putting results in directory: %s" % res_dir
    try:
        bboxcoverage.initAlreadyInstrApkEnv(pathToInstrApk=apk_file, resultsDir=res_dir)
        bboxcoverage.installApkOnDevice()
        
        bboxcoverage.startTesting()
        package_name =  bboxcoverage.getPackageName()
        runMonkeyStrategy(adb=adb, package_name=package_name, 
                          eventsCount=EVENTS_COUNT, seed=SEED, 
                          throttle=THROTTLE)
        
        params={}
        params["strategy"] = "monkey"
        params["package_name"] = package_name
        params["events_count"] = EVENTS_COUNT
        params["seed"] = SEED
        params["throttle"] = THROTTLE
        time.sleep(3)
        bboxcoverage.stopTesting("monkey_events_%d_seed_%d_throttle_%d" % (EVENTS_COUNT, SEED, THROTTLE), paramsToWrite=params)
        time.sleep(3)
        bboxcoverage.uninstallPackage()
        time.sleep(5)
    except Exception as e:
        print "EXCEPTION while execution: " + str(e)
    except:
        print "UNKNOWN EXCEPTION"
Exemplo n.º 2
0
    result_directories = getSubdirs(apk_dir_source)
    for directory in result_directories:
        apk_file = getInstrApkInFolder(directory)
        if apk_file:
            print "Starting experiment for apk: [%s]" % apk_file
            try:
                bboxcoverage.initAlreadyInstrApkEnv(pathToInstrApk=apk_file,
                                                    resultsDir=directory)
            except:
                print "Exception while initialization!"
                continue
            try:
                bboxcoverage.installApkOnDevice()
            except:
                print "Exception while installation apk on device!"
                bboxcoverage.uninstallPackage()
                try:
                    bboxcoverage.installApkOnDevice()
                except:
                    continue

            package_name = bboxcoverage.getPackageName()
            params = {}
            params["strategy"] = "main_intents"
            params["package_name"] = package_name
            params[
                "main_activity"] = bboxcoverage.androidManifest.getMainActivity(
                )

            try:
                bboxcoverage.startTesting()