Skip to content

Commit

Permalink
✨ (system tests): Add duration, percentage args
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Feb 14, 2024
1 parent 65c40b7 commit f36f47b
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tools/run_system_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
parser.add_argument('--no-flash-erase', action='store_false',
help='disable flash erase')

parser.add_argument('-d', '--duration', metavar='DURATION',
default=180,
help='duration in seconds to wait for the system to sleep')

parser.add_argument('-s', '--deep-sleep-percentage', metavar='DEEP_SLEEP_PERCENTAGE',
default=95,
help='deep sleep percentage')

args = parser.parse_args()


Expand Down Expand Up @@ -181,10 +189,10 @@ def wait_for_system_to_sleep(duration=180):
sleep(1)

print()
data = list(filter(lambda string: 'watchdog' in string, data))
data = list(filter(lambda string: 'watchdog' in string, data))[-10:]
print("\n".join(data))
print_end_success(f"Waiting for LekaOS to run for {duration} seconds")
return data[-10:]
return data


def calculate_sleep_deep_statistics(lines):
Expand Down Expand Up @@ -224,6 +232,8 @@ def parse_line(line):


FLASH_ERASE_FLAG = args.no_flash_erase
SLEEP_DURATION = int(args.duration)
DEEP_SLEEP_PERCENTAGE = int(args.deep_sleep_percentage)


def main():
Expand All @@ -236,7 +246,7 @@ def main():

reset_buffer()

data = wait_for_system_to_sleep(180)
data = wait_for_system_to_sleep(SLEEP_DURATION)

sleep, deep_sleep = calculate_sleep_deep_statistics(data)

Expand All @@ -245,11 +255,11 @@ def main():
print(Fore.CYAN + f"Average sleep: {sleep}%" + Style.RESET_ALL)
print(Fore.CYAN + f"Average deep sleep: {deep_sleep}%" + Style.RESET_ALL)

if deep_sleep > 95:
print(Fore.GREEN + "Deep sleep is higher than 95%, this is good! ✅" + Style.RESET_ALL)
if deep_sleep >= DEEP_SLEEP_PERCENTAGE:
print(Fore.GREEN + f"Deep sleep is higher than {DEEP_SLEEP_PERCENTAGE}%, this is good! ✅" + Style.RESET_ALL)
return 0
else:
print(Fore.RED + "Deep sleep is lower than 95%, this is bad! ❌" + Style.RESET_ALL)
print(Fore.RED + f"Deep sleep is lower than {DEEP_SLEEP_PERCENTAGE}%, this is bad! ❌" + Style.RESET_ALL)
return 1


Expand Down

0 comments on commit f36f47b

Please sign in to comment.