Blame 0007-tests-Fix-test_swapon_pagesize-on-systems-with-64k-p.patch

Vojtech Trefny 95db11
From 2c59bc22d30ebfc16d5d06b1f31c4d7bbede68e9 Mon Sep 17 00:00:00 2001
Vojtech Trefny 95db11
From: Vojtech Trefny <vtrefny@redhat.com>
Vojtech Trefny 95db11
Date: Mon, 31 Oct 2022 12:43:17 +0100
Vojtech Trefny 95db11
Subject: [PATCH] tests: Fix test_swapon_pagesize on systems with 64k pages
Vojtech Trefny 95db11
Vojtech Trefny 95db11
---
Vojtech Trefny 95db11
 tests/swap_test.py | 12 ++++++++++--
Vojtech Trefny 95db11
 1 file changed, 10 insertions(+), 2 deletions(-)
Vojtech Trefny 95db11
Vojtech Trefny 95db11
diff --git a/tests/swap_test.py b/tests/swap_test.py
Vojtech Trefny 95db11
index 0a0f333d..e350f8e8 100644
Vojtech Trefny 95db11
--- a/tests/swap_test.py
Vojtech Trefny 95db11
+++ b/tests/swap_test.py
Vojtech Trefny 95db11
@@ -1,5 +1,6 @@
Vojtech Trefny 95db11
 import unittest
Vojtech Trefny 95db11
 import os
Vojtech Trefny 95db11
+import resource
Vojtech Trefny 95db11
 import overrides_hack
Vojtech Trefny 95db11
 
Vojtech Trefny 95db11
 from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, run_command, run, TestTags, tag_test
Vojtech Trefny 95db11
@@ -102,8 +103,15 @@ class SwapTestCase(SwapTest):
Vojtech Trefny 95db11
     def test_swapon_pagesize(self):
Vojtech Trefny 95db11
         """Verify that activating swap with different pagesize fails"""
Vojtech Trefny 95db11
 
Vojtech Trefny 95db11
-        # create swap with 64k pagesize
Vojtech Trefny 95db11
-        ret, out, err = run_command("mkswap --pagesize 65536 %s" % self.loop_dev)
Vojtech Trefny 95db11
+        # pick some wrong page size: 8k on 64k and 64k everywhere else
Vojtech Trefny 95db11
+        pagesize = resource.getpagesize()
Vojtech Trefny 95db11
+        if pagesize == 65536:
Vojtech Trefny 95db11
+            wrong_pagesize = 8192
Vojtech Trefny 95db11
+        else:
Vojtech Trefny 95db11
+            wrong_pagesize = 65536
Vojtech Trefny 95db11
+
Vojtech Trefny 95db11
+        # create swap with "wrong" pagesize
Vojtech Trefny 95db11
+        ret, out, err = run_command("mkswap --pagesize %s %s" % (wrong_pagesize, self.loop_dev))
Vojtech Trefny 95db11
         if ret != 0:
Vojtech Trefny 95db11
             self.fail("Failed to prepare swap for pagesize test: %s %s" % (out, err))
Vojtech Trefny 95db11
 
Vojtech Trefny 95db11
-- 
Vojtech Trefny 95db11
2.39.2
Vojtech Trefny 95db11