From b43eb174cf64d8362a8f59e8b9d74675eed05ca4 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 15 Oct 2026 12:14:22 +0200 Subject: feat(updates): version order for updatesctl nvtable compares versions for equality, which cannot tell an installed 2.1.278 from an SBo recipe of 2.1.267 that is older than it. vercmp orders numeric chunks as numbers and treats a trailing alphabetic chunk as a pre-release, so a kernel suffix or git hash orders as newer than its base and never reads as behind. Co-Authored-By: Claude Sonnet 5.5 --- desktop/modules/updates/test_updatesctl.py | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 desktop/modules/updates/test_updatesctl.py (limited to 'desktop/modules/updates/test_updatesctl.py') diff --git a/desktop/modules/updates/test_updatesctl.py b/desktop/modules/updates/test_updatesctl.py new file mode 100644 index 0000000..09c3676 --- /dev/null +++ b/desktop/modules/updates/test_updatesctl.py @@ -0,0 +1,42 @@ +#!/usr/bin/python3 +# Copyright (C) 2026 Danilo M. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program 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. +"""Run: /usr/bin/python3 desktop/modules/updates/test_updatesctl.py + +Imports updatesctl for vercmp, then drives it as a CLI against a fixture tree +under a temp dir (UPDATESCTL_ROOT for system paths, HOME for the user's), +never the live system. Plain asserts, no framework. +""" + +import importlib.machinery +import importlib.util +from pathlib import Path + +SCRIPT = Path(__file__).resolve().parent / "updatesctl" + +loader = importlib.machinery.SourceFileLoader("updatesctl", str(SCRIPT)) +spec = importlib.util.spec_from_loader("updatesctl", loader) +u = importlib.util.module_from_spec(spec) +loader.exec_module(u) + +# --- vercmp --- +assert u.vercmp("1.14.10", "1.14.9") > 0 +assert u.vercmp("2.1.278", "2.1.267") > 0 +assert u.vercmp("2026_10_02", "2026_09_12") > 0 +assert u.vercmp("v1.2", "1.2") == 0 +assert u.vercmp("1.0", "1.0") == 0 +# A pre-release is older than the release, a suffix is never behind. +assert u.vercmp("0.12.3_beta.4", "0.12.3") < 0 +assert u.vercmp("9.018.00_6.18.41", "9.018.00") > 0 +assert u.vercmp("3.1-659215d", "3.1") > 0 +assert u.vercmp("1.0.1", "1.0rc1") > 0 + +print("ok") -- cgit v1.2.3