]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pytests: test normalise_int32 against out-of-range numbers
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 26 Jun 2025 04:30:48 +0000 (16:30 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Thu, 7 Aug 2025 23:28:33 +0000 (23:28 +0000)
For example, we don't want to "normalise" 0x9876543210 to
0x9776543210, or 0x200000000 to 0x100000000. That is just causing
random damage to 64 bit values without achieving the sign switch.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
python/samba/tests/common.py
selftest/knownfail.d/python-common [new file with mode: 0644]

index a181fb700568e7790093ea0e5574a53acfa54349..c767d2522f7c1992e463b253c7e7b8562d0891c4 100644 (file)
@@ -29,3 +29,6 @@ class CommonTests(samba.tests.TestCase):
         self.assertEqual('17', normalise_int32('17'))
         self.assertEqual('-123', normalise_int32('-123'))
         self.assertEqual('-1294967296', normalise_int32('3000000000'))
+        self.assertRaises(ValueError, normalise_int32, 1 << 32)
+        self.assertRaises(ValueError, normalise_int32, 12345678901234567890)
+        self.assertRaises(ValueError, normalise_int32, -1000000000000)
diff --git a/selftest/knownfail.d/python-common b/selftest/knownfail.d/python-common
new file mode 100644 (file)
index 0000000..3d73084
--- /dev/null
@@ -0,0 +1 @@
+samba.tests.common.samba.tests.common.CommonTests.test_normalise_int32