From ed31d0f1912354dd9afed1471c515d8d70275fc7 Mon Sep 17 00:00:00 2001 From: yangl777 Date: Mon, 6 Jun 2022 14:25:27 +0800 Subject: [PATCH] enable make check --- ...port-use-pytest-to-run-the-unittests.patch | 116 ++++++++++++++++++ kdump-anaconda-addon.spec | 14 ++- 2 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 backport-use-pytest-to-run-the-unittests.patch diff --git a/backport-use-pytest-to-run-the-unittests.patch b/backport-use-pytest-to-run-the-unittests.patch new file mode 100644 index 0000000..1fb49f7 --- /dev/null +++ b/backport-use-pytest-to-run-the-unittests.patch @@ -0,0 +1,116 @@ +From fe60eaf2d6e32ed7009f6d9cfecc1f761ec77560 Mon Sep 17 00:00:00 2001 +From: Vendula Poncova +Date: Thu, 23 Sep 2021 14:43:26 +0200 +Subject: [PATCH] Use pytest to run the unit tests + +The nose library is no longer maintained and it doesn't work with Python 3.9. + +Conflict:Change the case name based on the current version +Reference:https://github.com/daveyoung/kdump-anaconda-addon/commit/fe60eaf2d6e32ed7009f6d9cfecc1f761ec77560 + +--- + Makefile | 4 ++-- + test/unittests/test_common.py | 6 +++--- + test/unittests/test_kickstart.py | 16 ++++++++-------- + 3 files changed, 13 insertions(+), 13 deletions(-) + +diff --git a/Makefile b/Makefile +index c9b581d..122d090 100644 +--- a/Makefile ++++ b/Makefile +@@ -77,14 +77,14 @@ test: + @find . -name '*.py' -print|xargs -n1 --max-procs=$(NUM_PROCS) pylint -E 2> /dev/null + @echo "[ OK ]" + @echo "***Running unittests checks***" +- @PYTHONPATH=. python3 -m nose --processes=-1 -vw test/unittests ++ @PYTHONPATH=. pytest -vv test/unittests + + runpylint: + @find . -name '*.py' -print|xargs -n1 --max-procs=$(NUM_PROCS) pylint -E 2> /dev/null + @echo "[ OK ]" + + unittest: +- PYTHONPATH=. python3 -m nose --processes=-1 -vw test/unittests ++ PYTHONPATH=. pytest -vv test/unittests + + version.sh: + @echo "KDUMP_ADDON_VERSION=$(VERSION)" > version.sh +diff --git a/test/unittests/test_common.py b/test/unittests/test_common.py +index 7f221be..e7a2ff3 100644 +--- a/test/unittests/test_common.py ++++ b/test/unittests/test_common.py +@@ -43,15 +43,15 @@ class MockFileRead(MagicMock): + class KdumpCommonTestCase(KdumpTestCase): + @patch("builtins.open", MockFileRead(X86_INFO_FIXTURE)) + @patch("blivet.arch.get_arch", return_value="x86_64") +- def memory_bound_test_x86(self, _mock_read): ++ def test_memory_bound_x86(self, _mock_read): + self.assertEqual((128, 4 * 1024 - 256, 1), common.getMemoryBounds()) + + @patch("builtins.open", MockFileRead(AARCH64_INFO_FIXTURE)) + @patch("blivet.arch.get_arch", return_value="aarch64") +- def memory_bound_test_aarch64(self, _mock_read): ++ def test_memory_bound_aarch64(self, _mock_read): + self.assertEqual((128, 64 * 1024 - 256, 1), common.getMemoryBounds()) + + @patch("builtins.open", MockFileRead(PPC64_INFO_FIXTURE)) + @patch("blivet.arch.get_arch", return_value="ppc64") +- def memory_bound_test_ppc64(self, _mock_read): ++ def test_memory_bound_ppc64(self, _mock_read): + self.assertEqual((256, 64 * 1024 - 1024, 1), common.getMemoryBounds()) +diff --git a/test/unittests/test_kickstart.py b/test/unittests/test_kickstart.py +index 4fb63a9..dc0d357 100644 +--- a/test/unittests/test_kickstart.py ++++ b/test/unittests/test_kickstart.py +@@ -25,40 +25,40 @@ def kdump_check_ks(test, addon_data, required_arguments): + + + class KdumpKickstartTestCase(KdumpTestCase): +- def new_ks_addon_data_test(self): ++ def test_new_ks_addon_data(self): + ks_addon_data = new_ks_addon_data() + self.assertIsNotNone(ks_addon_data) + +- def ks_default_to_str_test(self): ++ def test_ks_default_to_str(self): + ks_addon_data = new_ks_addon_data() + kdump_check_ks(self, ks_addon_data, ["--disable"]) + +- def ks_enable_to_str_test(self): ++ def test_ks_enable_to_str(self): + ks_addon_data = new_ks_addon_data() + ks_addon_data.enabled = True + kdump_check_ks(self, ks_addon_data, ["--enable"]) + +- def ks_disable_to_str_test(self): ++ def test_ks_disable_to_str(self): + ks_addon_data = new_ks_addon_data() + ks_addon_data.enabled = False + kdump_check_ks(self, ks_addon_data, ["--disable"]) + +- def ks_parse_enable_to_str_test(self): ++ def test_ks_parse_enable_to_str(self): + ks_addon_data = new_ks_addon_data() + ks_addon_data.handle_header(0, ["--enable"]) + kdump_check_ks(self, ks_addon_data, ["--enable"]) + +- def ks_parse_reserve_to_str_test(self): ++ def test_ks_parse_reserve_to_str(self): + ks_addon_data = new_ks_addon_data() + ks_addon_data.handle_header(0, ["--enable", "--reserve-mb=256"]) + kdump_check_ks(self, ks_addon_data, ["--enable", "--reserve-mb[=|\ ](\"256\"|'256'|256)[Mm]?"]) + +- def ks_parse_fadump_to_str_test(self): ++ def test_ks_parse_fadump_to_str(self): + ks_addon_data = new_ks_addon_data() + ks_addon_data.handle_header(0, ['--enablefadump']) + kdump_check_ks(self, ks_addon_data, ["--enablefadump"]) + +- def ks_parse_invalid_reserve_size_test(self): ++ def test_ks_parse_invalid_reserve_size(self): + with self.assertRaises(KickstartParseError) as error: + ks_addon_data = new_ks_addon_data() + ks_addon_data.handle_header(0, ['--reserve-mb=']) +-- +2.33.0 + diff --git a/kdump-anaconda-addon.spec b/kdump-anaconda-addon.spec index 88fe91b..3091d77 100644 --- a/kdump-anaconda-addon.spec +++ b/kdump-anaconda-addon.spec @@ -1,7 +1,7 @@ Name: kdump-anaconda-addon Version: 005 -Release: 6 +Release: 11 Summary: Anaconda addon for configuring kdump. License: GPLv2 URL: https://github.com/daveyoung/kdump-anaconda-addon @@ -34,8 +34,9 @@ Patch6023: fix-an-unittest-error.patch Patch6024: replace-getSysroot.patch Patch6025: use-kernel-arguments-instead-of-cmdline.patch Patch6026: dont-use-the-local-storage-object.patch +Patch6027: backport-use-pytest-to-run-the-unittests.patch -BuildRequires: intltool gettext +BuildRequires: intltool gettext python3-pytest python3-blivet anaconda >= 29.24 Requires: anaconda >= 29.24 hicolor-icon-theme Obsoletes: kexec-tools-anaconda-addon < 2.0.17-9 @@ -58,6 +59,7 @@ installation media. %find_lang kdump-anaconda-addon %check +make unittest %pre @@ -74,8 +76,14 @@ installation media. %{_datadir}/icons/hicolor/scalable/apps/kdump.svg %changelog +* Mon Jun 06 2022 yanglu - 005-11 +- DESC: enable make check + +* Thu Apr 28 2021 yanglu - 005-10 +- DESC: rebuild package + * Mon Aug 09 2021 chenyanpanHW - 005-6 -- DESC: delete -Sgit from %autosetup, and delete BuildRequires git +- DESC: delete -Sgit from autosetup, and delete BuildRequires git * Sat Aug 7 2021 yangzhuangzhuang - 005-5 - revert "update version to 006"