summaryrefslogtreecommitdiff
path: root/scripts/kconfig/tests/err_num_bounds
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-11-21 17:22:21 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2026-11-21 17:22:21 -0800
commit4843f6873f7c4835e62f2c73ba0fd538e57a2f22 (patch)
treeee620501a1ffbad9a83141e3a70154e1fe641040 /scripts/kconfig/tests/err_num_bounds
downloadlinux-master.tar.gz
linux-master.zip
Merge tag 'sysctl-7.04-fixes-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctlgraftedHEADmaster
Pull sysctl fix from Joel Granados: "Fix sysctl jiffy / milliseconds conversion: - Writing a previously read value "X" shall keep the same "X" value - Remove truncation that was causing incorrect saturation of valid timeouts" * tag 'sysctl-7.04-fixes-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl: sysctl: Do jiffy / ms conversion in ulong space
Diffstat (limited to 'scripts/kconfig/tests/err_num_bounds')
-rw-r--r--scripts/kconfig/tests/err_num_bounds/Kconfig79
-rw-r--r--scripts/kconfig/tests/err_num_bounds/__init__.py12
-rw-r--r--scripts/kconfig/tests/err_num_bounds/expected_stderr10
3 files changed, 101 insertions, 0 deletions
diff --git a/scripts/kconfig/tests/err_num_bounds/Kconfig b/scripts/kconfig/tests/err_num_bounds/Kconfig
new file mode 100644
index 000000000..c439366c0
--- /dev/null
+++ b/scripts/kconfig/tests/err_num_bounds/Kconfig
@@ -0,0 +1,79 @@
+# SPDX-License-Identifier: GPL-2.0
+# Test bounds checks for 'int' and 'hex' constants
+
+config INT_SOURCE
+ int
+
+config HEX_SOURCE
+ hex
+
+config BOOL_SOURCE
+ bool
+
+# Valid values at the limits of the type
+
+config INT_MIN
+ int
+ default -9223372036854775808
+
+config INT_MAX
+ int
+ default 9223372036854775807
+
+config HEX_MIN
+ hex
+ default 0x0
+
+config HEX_MAX
+ hex
+ default 0xffffffffffffffff
+
+config INT_RANGE_LIMITS
+ int
+ range -9223372036854775808 9223372036854775807
+
+config HEX_RANGE_LIMITS
+ hex
+ range 0 0xffffffffffffffff
+
+config INT_FROM_INT
+ int
+ default INT_SOURCE
+
+config HEX_FROM_HEX
+ hex
+ default HEX_SOURCE
+
+# Constants outside the bounds
+
+config INT_DEFAULT_TOO_HIGH
+ int
+ default 10000000000000000000
+
+config INT_DEFAULT_TOO_LOW
+ int
+ default -9223372036854775809
+
+config INT_RANGE_TOO_HIGH
+ int
+ range 0 10000000000000000000
+
+config INT_RANGE_TOO_LOW
+ int
+ range -10000000000000000000 0
+
+config INT_RANGE_BOTH_OUTSIDE
+ int
+ range -9223372036854775809 10000000000000000000
+
+config HEX_DEFAULT_TOO_HIGH
+ hex
+ default 0x10000000000000000
+
+config HEX_RANGE_TOO_HIGH
+ hex
+ range 0 0x10000000000000000
+
+config HEX_RANGE_BOTH_TOO_HIGH
+ hex
+ range 0x10000000000000000 0x20000000000000000
diff --git a/scripts/kconfig/tests/err_num_bounds/__init__.py b/scripts/kconfig/tests/err_num_bounds/__init__.py
new file mode 100644
index 000000000..72ac6aa24
--- /dev/null
+++ b/scripts/kconfig/tests/err_num_bounds/__init__.py
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0
+"""
+Detect constants outside the 'int' and 'hex' bounds.
+
+An int constant must fit in a signed 64-bit integer, and a hex constant must
+fit in an unsigned 64-bit integer.
+"""
+
+
+def test(conf):
+ assert conf.olddefconfig() == 1
+ assert conf.stderr_matches('expected_stderr')
diff --git a/scripts/kconfig/tests/err_num_bounds/expected_stderr b/scripts/kconfig/tests/err_num_bounds/expected_stderr
new file mode 100644
index 000000000..5f89cf4af
--- /dev/null
+++ b/scripts/kconfig/tests/err_num_bounds/expected_stderr
@@ -0,0 +1,10 @@
+Kconfig:51: error: integer constant '10000000000000000000' is outside the 64-bit signed bounds
+Kconfig:55: error: integer constant '-9223372036854775809' is outside the 64-bit signed bounds
+Kconfig:59: error: integer constant '10000000000000000000' is outside the 64-bit signed bounds
+Kconfig:63: error: integer constant '-10000000000000000000' is outside the 64-bit signed bounds
+Kconfig:67: error: integer constant '-9223372036854775809' is outside the 64-bit signed bounds
+Kconfig:67: error: integer constant '10000000000000000000' is outside the 64-bit signed bounds
+Kconfig:71: error: hex constant '0x10000000000000000' is outside the 64-bit unsigned bounds
+Kconfig:75: error: hex constant '0x10000000000000000' is outside the 64-bit unsigned bounds
+Kconfig:79: error: hex constant '0x10000000000000000' is outside the 64-bit unsigned bounds
+Kconfig:79: error: hex constant '0x20000000000000000' is outside the 64-bit unsigned bounds