summaryrefslogtreecommitdiff
path: root/test cases/keyval
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-02-07 01:55:27 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2020-05-08 20:56:14 +0300
commit7e1529501883ce8741d8689c150f589ab68a814f (patch)
tree407e0c6b075a1b8872f7f9896948d79cbe5846ed /test cases/keyval
parenta535ef6719816b23085da492dbcdcc4b7bfa8d2b (diff)
downloadmeson-7e1529501883ce8741d8689c150f589ab68a814f.tar.gz
rename unstable-kconfig to unstable-keyval
Discussions in #6524 have shown that there are various possible uses of the kconfig module and even disagreements in the exact file format between Python-based kconfiglib and the tools in Linux. Instead of trying to reconcile them, just rename the module to something less suggestive and leave any policy to meson.build files. In the future it may be possible to add some kind of parsing through keyword arguments such as bool_true, quoted_strings, etc. and possibly creation of key-value lists too. For now, configuration_data objects provide an easy way to access quoted strings. Note that Kconfig stores false as "absent" so it was already necessary to write "x.has_key('abc')" rather than the more compact "x['abc']". Therefore, having to use configuration_data does not make things much more verbose.
Diffstat (limited to 'test cases/keyval')
-rw-r--r--test cases/keyval/1 basic/.config3
-rw-r--r--test cases/keyval/1 basic/meson.build16
-rw-r--r--test cases/keyval/2 subdir/.config2
-rw-r--r--test cases/keyval/2 subdir/dir/meson.build13
-rw-r--r--test cases/keyval/2 subdir/meson.build4
-rw-r--r--test cases/keyval/3 load_config files/dir/config2
-rw-r--r--test cases/keyval/3 load_config files/dir/meson.build13
-rw-r--r--test cases/keyval/3 load_config files/meson.build4
-rw-r--r--test cases/keyval/4 load_config builddir/config2
-rw-r--r--test cases/keyval/4 load_config builddir/meson.build14
10 files changed, 73 insertions, 0 deletions
diff --git a/test cases/keyval/1 basic/.config b/test cases/keyval/1 basic/.config
new file mode 100644
index 000000000..071d1854d
--- /dev/null
+++ b/test cases/keyval/1 basic/.config
@@ -0,0 +1,3 @@
+CONFIG_VAL1=y
+# CONFIG_VAL2 is not set
+CONFIG_VAL_VAL=4
diff --git a/test cases/keyval/1 basic/meson.build b/test cases/keyval/1 basic/meson.build
new file mode 100644
index 000000000..fc7ddb3fd
--- /dev/null
+++ b/test cases/keyval/1 basic/meson.build
@@ -0,0 +1,16 @@
+project('keyval basic test')
+
+k = import('unstable-keyval')
+conf = k.load('.config')
+
+if not conf.has_key('CONFIG_VAL1')
+ error('Expected CONFIG_VAL1 to be set, but it wasn\'t')
+endif
+
+if conf.has_key('CONFIG_VAL2')
+ error('Expected CONFIG_VAL2 not be set, but it was')
+endif
+
+if conf.get('CONFIG_VAL_VAL').to_int() != 4
+ error('Expected CONFIG_VAL_VAL to be 4')
+endif
diff --git a/test cases/keyval/2 subdir/.config b/test cases/keyval/2 subdir/.config
new file mode 100644
index 000000000..0599d4616
--- /dev/null
+++ b/test cases/keyval/2 subdir/.config
@@ -0,0 +1,2 @@
+CONFIG_IS_SET=y
+# CONFIG_NOT_IS_SET is not set
diff --git a/test cases/keyval/2 subdir/dir/meson.build b/test cases/keyval/2 subdir/dir/meson.build
new file mode 100644
index 000000000..dc1b478b3
--- /dev/null
+++ b/test cases/keyval/2 subdir/dir/meson.build
@@ -0,0 +1,13 @@
+
+k = import('unstable-keyval')
+
+conf = k.load(meson.source_root() / '.config')
+
+if not conf.has_key('CONFIG_IS_SET')
+ error('Expected CONFIG_IS_SET to be set, but it wasn\'t')
+endif
+
+if conf.has_key('CONFIG_NOT_IS_SET')
+ error('Expected CONFIG_NOT_IS_SET not be set, but it was')
+endif
+
diff --git a/test cases/keyval/2 subdir/meson.build b/test cases/keyval/2 subdir/meson.build
new file mode 100644
index 000000000..0651acf34
--- /dev/null
+++ b/test cases/keyval/2 subdir/meson.build
@@ -0,0 +1,4 @@
+project('keyval subdir test')
+
+# Test into sub directory
+subdir('dir')
diff --git a/test cases/keyval/3 load_config files/dir/config b/test cases/keyval/3 load_config files/dir/config
new file mode 100644
index 000000000..0599d4616
--- /dev/null
+++ b/test cases/keyval/3 load_config files/dir/config
@@ -0,0 +1,2 @@
+CONFIG_IS_SET=y
+# CONFIG_NOT_IS_SET is not set
diff --git a/test cases/keyval/3 load_config files/dir/meson.build b/test cases/keyval/3 load_config files/dir/meson.build
new file mode 100644
index 000000000..43fba13a8
--- /dev/null
+++ b/test cases/keyval/3 load_config files/dir/meson.build
@@ -0,0 +1,13 @@
+
+k = import('unstable-keyval')
+
+conf = k.load(files('config'))
+
+if not conf.has_key('CONFIG_IS_SET')
+ error('Expected CONFIG_IS_SET to be set, but it wasn\'t')
+endif
+
+if conf.has_key('CONFIG_NOT_IS_SET')
+ error('Expected CONFIG_NOT_IS_SET not be set, but it was')
+endif
+
diff --git a/test cases/keyval/3 load_config files/meson.build b/test cases/keyval/3 load_config files/meson.build
new file mode 100644
index 000000000..0651acf34
--- /dev/null
+++ b/test cases/keyval/3 load_config files/meson.build
@@ -0,0 +1,4 @@
+project('keyval subdir test')
+
+# Test into sub directory
+subdir('dir')
diff --git a/test cases/keyval/4 load_config builddir/config b/test cases/keyval/4 load_config builddir/config
new file mode 100644
index 000000000..0599d4616
--- /dev/null
+++ b/test cases/keyval/4 load_config builddir/config
@@ -0,0 +1,2 @@
+CONFIG_IS_SET=y
+# CONFIG_NOT_IS_SET is not set
diff --git a/test cases/keyval/4 load_config builddir/meson.build b/test cases/keyval/4 load_config builddir/meson.build
new file mode 100644
index 000000000..1bb028564
--- /dev/null
+++ b/test cases/keyval/4 load_config builddir/meson.build
@@ -0,0 +1,14 @@
+project('keyval builddir test')
+
+k = import('unstable-keyval')
+
+out_conf = configure_file(input: 'config', output: 'out-config', copy: true)
+conf = k.load(out_conf)
+
+if not conf.has_key('CONFIG_IS_SET')
+ error('Expected CONFIG_IS_SET to be set, but it wasn\'t')
+endif
+
+if conf.has_key('CONFIG_NOT_IS_SET')
+ error('Expected CONFIG_NOT_IS_SET not be set, but it was')
+endif