From 671efd39f6d3304f377a7d7b56a45b3c1823b545 Mon Sep 17 00:00:00 2001 From: liaou3 Date: Mon, 1 Apr 2024 13:35:04 +0800 Subject: [PATCH] Remove wrong file --- providers/base/tests/watchdog_config_test.py | 118 ------------------- 1 file changed, 118 deletions(-) delete mode 100755 providers/base/tests/watchdog_config_test.py diff --git a/providers/base/tests/watchdog_config_test.py b/providers/base/tests/watchdog_config_test.py deleted file mode 100755 index a8fa0bed6f..0000000000 --- a/providers/base/tests/watchdog_config_test.py +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2021 Canonical Ltd. -# All rights reserved. -# -# Written by: -# Vic Liu -# -# Checkbox is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 3, -# as published by the Free Software Foundation. -# -# Checkbox is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Checkbox. If not, see . - -''' -Watchdog implementation on both classic and core image no longer rely -on watchdogd service since 20.04, with this change watchdog/systemd-config -tests only systemd configuration on 20.04 and later series while keeping -the original test for prior releases -''' - -import subprocess -import argparse -import sys - -from checkbox_support.snap_utils.system import on_ubuntucore -from checkbox_support.snap_utils.system import get_series - - -def watchdog_argparse(): - parser = argparse.ArgumentParser() - parser.add_argument('-t', '--check_time', action='store_true') - parser.add_argument('-s', '--check_service', action='store_true') - - return parser.parse_args() - - -def get_systemd_wdt_usec(): - """ - Return value of systemd-watchdog RuntimeWatchdogUSec - """ - cmd = ['systemctl', 'show', '-p', 'RuntimeWatchdogUSec'] - try: - result = subprocess.check_output(cmd, universal_newlines=True) - except Exception as err: - raise SystemExit("Error: {}".format(err)) - - if result: - runtime_watchdog_usec = result.split("=")[1].strip() - return runtime_watchdog_usec - else: - raise SystemExit( - "Unexpected failure occurred when executing: {}".format(cmd)) - - -def watchdog_service_check(): - """ - Check if the watchdog service is configured correctly - """ - cmd = ['systemctl', 'is-active', 'watchdog.service', '--quiet'] - try: - return not subprocess.run(cmd).returncode - except Exception as err: - raise SystemExit("Error: {}".format(err)) - - -def main(): - args = watchdog_argparse() - - ubuntu_version = int(get_series().split(".")[0]) - watchdog_config_ready = True - - if args.check_time: - runtime_watchdog_usec = get_systemd_wdt_usec() - is_systemd_wdt_configured = (runtime_watchdog_usec != "0") - - if ubuntu_version >= 20 or on_ubuntucore(): - if not is_systemd_wdt_configured: - print("systemd watchdog should be enabled but reset timeout: " - "{}".format(runtime_watchdog_usec)) - watchdog_config_ready = False - if watchdog_config_ready: - print("systemd watchdog enabled, reset timeout: {}".format( - runtime_watchdog_usec)) - else: - if is_systemd_wdt_configured: - print("systemd watchdog should not be enabled but reset" - " timeout: {}".format(runtime_watchdog_usec)) - watchdog_config_ready = False - if watchdog_config_ready: - print("systemd watchdog disabled") - - if args.check_service: - is_wdt_service_configured = watchdog_service_check() - - if ubuntu_version >= 20 or on_ubuntucore(): - if is_wdt_service_configured: - print("found unexpected active watchdog.service unit") - watchdog_config_ready = False - if watchdog_config_ready: - print("watchdog.service is not active") - else: - if not is_wdt_service_configured: - print("watchdog.service unit does not report as active") - watchdog_config_ready = False - if watchdog_config_ready: - print("watchdog.service is active") - - return not watchdog_config_ready - - -if __name__ == "__main__": - sys.exit(main())