diff --git a/experiment_automatization/monkey_runner.py b/experiment_automatization/monkey_runner.py new file mode 100755 index 0000000000000000000000000000000000000000..054de497b6ea1369a0437719a1e9b71fbabd9fca --- /dev/null +++ b/experiment_automatization/monkey_runner.py @@ -0,0 +1,33 @@ +from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice + +#template file downloaded from this link https://developer.android.com/studio/test/monkeyrunner +#parameters : + # sys.argv[1] the function code to execute during experiements: + # 1 is for the battery drainer app + # sys.argv[from 2 to n] Eventually, argument related to the function to execute + ## for function code 1, ie the battery drainer app + # sys.argv[2] = package name + # sys.argv[3] = activity name + + + +print ("--- Inside the monkey_runner") +# Connects to the current device, returning a MonkeyDevice object +device = MonkeyRunner.waitForConnection() +if sys.argv[1] == 1: # for the battery drainer app + # sets a variable with the package's internal name + package = sys.argv[2] + # sets a variable with the name of an Activity in the package + activity = sys.argv[3] + # sets the name of the component to start + runComponent = package + '/' + activity + print("Monkey runner ready to process: ", runComponent) + + # Presses the Menu button + # device.press('KEYCODE_MENU', MonkeyDevice.DOWN_AND_UP) + +# Takes a screenshot +#result = device.takeSnapshot() + +# Writes the screenshot to a file +#result.writeToFile('myproject/shot1.png','png') diff --git a/experiment_automatization/run_experiments.sh b/experiment_automatization/run_experiments.sh new file mode 100755 index 0000000000000000000000000000000000000000..e00f96742e0d7f169207f568b6a4f9a2bc824219 --- /dev/null +++ b/experiment_automatization/run_experiments.sh @@ -0,0 +1,58 @@ +#!/usr/bin/bash +# scritp to run experiments in +# some configurations +APK_PATH__WINDOWS_SYNTAX="C:\Users\lavoi\opportunist_task_on_android\git_repositories\benchmarking_app_to_test_big_cores\app\debug\app-debug.apk" +DRAINER_APK_PATH__WINDOWS_SYNTAX="C:\Users\lavoi\opportunist_task_on_android\git_repositories\app_to_drain_battery.apk" +drainer_app_package_name="com.opportunistask.scheduling.benchmarking_app_to_test_big_cores" +drainer_app_main_activity="com.opportunistask.scheduling.benchmarking_app_to_test_big_cores.MainActivity" +adb='/mnt/c/Program Files/Android/platform-tools_r33.0.1-windows/platform-tools/adb.exe' +python='/mnt/c/Users/lavoi/AppData/Local/Microsoft/WindowsApps/python.exe' +experiment_battery_level="50" + + +## activating the root +"${adb}" root + + +## first step (for google pixel 4a 5g) : verifying the battery level +echo "### first step (for google pixel 4a 5g) : verifying the battery level" +current_battery_level=$("${adb}" shell "dumpsys battery" | grep level | cut -d ':' -f 2 | sed 's/ //g') +current_battery_level=$(echo $current_battery_level | tr -d '\r') # To remove the DOS carriage return (^M). +echo "current battery level : ${current_battery_level} " + +if [ "$current_battery_level" -eq "$experiment_battery_level" ]; then + echo "Current battery level: OKAY" +elif [ "$current_battery_level" -gt "$experiment_battery_level" ]; then + echo "Current battery is high, so we need to drain battery" + echo "----- Uninstalling drainer app" + "$adb" uninstall drainer_app_package_name + echo "----- Installing drainer app" + "$adb" install "$DRAINER_APK_PATH__WINDOWS_SYNTAX" + + echo "------ Giving rights to drainer app" + "$adb" shell pm grant drainer_app_package_name android.permission.DUMP + "$adb" shell pm grant drainer_app_package_name android.permission.PACKAGE_USAGE_STATS + "$adb" shell pm grant drainer_app_package_name android.permission.WRITE_EXTERNAL_STORAGE + + echo "----- Starting drainer app" + "$adb" shell "sleep 1 + am start -n $drainer_app_package_name/$drainer_app_main_activity" + + sleep 1 + APP_PID=$("$adb" shell "ps -A | grep $drainer_app_package_name" | awk '{ print $2 }') + APP_PID=$(echo $APP_PID | tr -d '\r') # To remove the DOS carriage return (^M). + echo "-----Drainer app started with PID = $APP_PID " + + python monkey_runner.py 1 $drainer_app_package_name $drainer_app_main_activity + + +elif [ "$current_battery_level" -lt "$experiment_battery_level" ]; then + echo "Current battery is low, so we need to wait battery" +fi + + + + + +:<<'END_COMMENT' +END_COMMENT diff --git a/experiment_automatization/test_python_call.py b/experiment_automatization/test_python_call.py new file mode 100755 index 0000000000000000000000000000000000000000..9e33b57858f2fc6c337326bd1742a2cc9a1c8352 --- /dev/null +++ b/experiment_automatization/test_python_call.py @@ -0,0 +1 @@ +print("python call is find") \ No newline at end of file diff --git a/testing_monsoon_api/__pycache__/physalia.cpython-38.pyc b/testing_monsoon_api/__pycache__/physalia.cpython-38.pyc new file mode 100755 index 0000000000000000000000000000000000000000..07bfdb726c897f917c1e909232e51ffd848519e7 Binary files /dev/null and b/testing_monsoon_api/__pycache__/physalia.cpython-38.pyc differ diff --git a/testing_monsoon_api/myscript.py b/testing_monsoon_api/myscript.py new file mode 100755 index 0000000000000000000000000000000000000000..d1e1a0b48ae3b194765a10d2c7b55c1a2bd48942 --- /dev/null +++ b/testing_monsoon_api/myscript.py @@ -0,0 +1,16 @@ +# myscript.py + +import time +from physalia.power_meters import MonsoonPowerMeter +from physalia.energy_profiler import AndroidUseCase + +power_meter = MonsoonPowerMeter(voltage=3.7, serial=29363)#(voltage=3.8, serial=12886) +#power_meter.SetUsbPassthrough(1) + +def run(_): + time.sleep(5) + print(" Android user case ok") +use_case = AndroidUseCase('physalia-simple-tutorial', None, 'na', 'na', run=run) + +measurement = use_case.run(power_meter=power_meter) +print(measurement) diff --git a/testing_monsoon_api/powertool_script.py b/testing_monsoon_api/powertool_script.py new file mode 100755 index 0000000000000000000000000000000000000000..a274b61e66402d054ed40bd201ea93067da4ba82 --- /dev/null +++ b/testing_monsoon_api/powertool_script.py @@ -0,0 +1,5 @@ +import monsoon.LVPM as LVPM +import monsoon.sampleEngine as sampleEngine +import monsoon.Operations as op +Mon = LVPM.Monsoon() +Mon.setup_usb() \ No newline at end of file