[PATCH] test: qemuxml2argv: Mock virMemoryMaxValue to remove 32/64 bit difference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Always return LLONG_MAX even on 32 bit systems. The limitation
originates from our use of "unsigned long" in several APIs. The internal
data type is unsigned long long. Make the test suite deterministic by
removing the architecture difference.

Flaw was introduced in 645881139b3d2c86acf9d644c3a1471520bc9e57 where
I've added a test that uses too large numbers.
---
I've tested this by changing the mock value to the number returned on 32-bit
systems and got the same error. I didn't test it on an actual 32 bit system
though.

 src/util/virutil.c       |  2 ++
 tests/qemuxml2argvmock.c | 10 ++++++++++
 2 files changed, 12 insertions(+)

diff --git a/src/util/virutil.c b/src/util/virutil.c
index fe65faf..9d56d66 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -2639,6 +2639,8 @@ virMemoryLimitIsSet(unsigned long long value)
  * @capped: whether the value must fit into unsigned long
  *   (long long is assumed otherwise)
  *
+ * Note: This function is mocked in tests/qemuxml2argvmock.c for test stability
+ *
  * Returns the maximum possible memory value in bytes.
  */
 unsigned long long
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index e58b8ce..8426108 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -74,3 +74,13 @@ virTPMCreateCancelPath(const char *devpath)

     return path;
 }
+
+/**
+ * Large values for memory would fail on 32 bit systems, despite having
+ * variables that support it.
+ */
+unsigned long long
+virMemoryMaxValue(bool capped ATTRIBUTE_UNUSED)
+{
+    return LLONG_MAX;
+}
-- 
2.6.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]