From 20a8fbe559b8088c736ef99a584f65f34e124fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Tue, 14 Sep 2021 22:06:21 +0200 Subject: [PATCH 1/7] call global postgetstorage plugins (like spec) before non-global ones (like type) Fixes #4043 --- src/libs/elektra/kdb.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/src/libs/elektra/kdb.c b/src/libs/elektra/kdb.c index c06d448f808..34bef3c0fc0 100644 --- a/src/libs/elektra/kdb.c +++ b/src/libs/elektra/kdb.c @@ -1394,6 +1394,19 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey) ksClear (ks); splitMergeBackends (split, ks); + if (elektraGlobalGet (handle, ks, parentKey, POSTGETSTORAGE, INIT) == ELEKTRA_PLUGIN_STATUS_ERROR) + { + goto error; + } + if (elektraGlobalGet (handle, ks, parentKey, POSTGETSTORAGE, MAXONCE) == ELEKTRA_PLUGIN_STATUS_ERROR) + { + goto error; + } + if (elektraGlobalGet (handle, ks, parentKey, POSTGETSTORAGE, DEINIT) == ELEKTRA_PLUGIN_STATUS_ERROR) + { + goto error; + } + clearError (parentKey); if (elektraGetDoUpdateWithGlobalHooks (handle, split, ks, parentKey, initialParent, LAST) == -1) { @@ -1429,23 +1442,25 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey) ksClear (ks); splitMergeBackends (split, ks); - } - keySetName (parentKey, keyName (initialParent)); + keySetName (parentKey, keyName (initialParent)); - if (elektraGlobalGet (handle, ks, parentKey, POSTGETSTORAGE, INIT) == ELEKTRA_PLUGIN_STATUS_ERROR) - { - goto error; - } - if (elektraGlobalGet (handle, ks, parentKey, POSTGETSTORAGE, MAXONCE) == ELEKTRA_PLUGIN_STATUS_ERROR) - { - goto error; - } - if (elektraGlobalGet (handle, ks, parentKey, POSTGETSTORAGE, DEINIT) == ELEKTRA_PLUGIN_STATUS_ERROR) - { - goto error; + if (elektraGlobalGet (handle, ks, parentKey, POSTGETSTORAGE, INIT) == ELEKTRA_PLUGIN_STATUS_ERROR) + { + goto error; + } + if (elektraGlobalGet (handle, ks, parentKey, POSTGETSTORAGE, MAXONCE) == ELEKTRA_PLUGIN_STATUS_ERROR) + { + goto error; + } + if (elektraGlobalGet (handle, ks, parentKey, POSTGETSTORAGE, DEINIT) == ELEKTRA_PLUGIN_STATUS_ERROR) + { + goto error; + } } + keySetName (parentKey, keyName (initialParent)); + if (handle->globalPlugins[POSTGETCACHE][MAXONCE]) { splitCacheStoreState (handle, split, handle->global, cacheParent, initialParent); From 09aff92d175801953bc4d96f35ff59038ceabc4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Tue, 14 Sep 2021 22:17:03 +0200 Subject: [PATCH 2/7] allow empty string with type=string --- src/plugins/type/README.md | 2 +- src/plugins/type/types.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/type/README.md b/src/plugins/type/README.md index 793b842cd28..6f91009907a 100644 --- a/src/plugins/type/README.md +++ b/src/plugins/type/README.md @@ -20,7 +20,7 @@ The type checker plugin supports these types: `any`, `enum`, `string`, `wstring` and `octet`. - Checking `any` will always be successful, regardless of the content. -- `string` matches any non-empty key value. +- `string` matches any string key value. - `octet` and `char` are equivalent to each other. - `enum` will do enum checking as described below. - `boolean` only allows the values `1` and `0`. See also [Normalization](#normalization). diff --git a/src/plugins/type/types.c b/src/plugins/type/types.c index f253a38f804..82e7961a2cc 100644 --- a/src/plugins/type/types.c +++ b/src/plugins/type/types.c @@ -58,7 +58,7 @@ bool elektraTypeCheckWChar (const Key * key) bool elektraTypeCheckString (const Key * key) { - return strlen (keyString (key)) != 0; + return keyIsString (key) == 1; } bool elektraTypeCheckWString (const Key * key) From ec02242b3e9183f31533073fbd6bac578c8e1abd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Tue, 14 Sep 2021 22:18:28 +0200 Subject: [PATCH 3/7] report more errors from global plugins Fixes #4044 --- src/libs/elektra/kdb.c | 20 ++++++++++++++++---- tests/shell/gen/highlevel/struct.data.ini | 5 +++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/libs/elektra/kdb.c b/src/libs/elektra/kdb.c index 34bef3c0fc0..2de0e0b7669 100644 --- a/src/libs/elektra/kdb.c +++ b/src/libs/elektra/kdb.c @@ -794,13 +794,25 @@ static int elektraGetDoUpdateWithGlobalHooks (KDB * handle, Split * split, KeySe { case FIRST: keySetName (parentKey, keyName (initialParent)); - elektraGlobalGet (handle, ks, parentKey, GETSTORAGE, INIT); - elektraGlobalGet (handle, ks, parentKey, GETSTORAGE, MAXONCE); + if (elektraGlobalGet (handle, ks, parentKey, GETSTORAGE, INIT) == ELEKTRA_PLUGIN_ERROR) + { + return -1; + } + if (elektraGlobalGet (handle, ks, parentKey, GETSTORAGE, MAXONCE) == ELEKTRA_PLUGIN_ERROR) + { + return -1; + } break; case LAST: keySetName (parentKey, keyName (initialParent)); - elektraGlobalGet (handle, ks, parentKey, PROCGETSTORAGE, INIT); - elektraGlobalGet (handle, ks, parentKey, PROCGETSTORAGE, MAXONCE); + if (elektraGlobalGet (handle, ks, parentKey, PROCGETSTORAGE, INIT) == ELEKTRA_PLUGIN_ERROR) + { + return -1; + } + if (elektraGlobalGet (handle, ks, parentKey, PROCGETSTORAGE, MAXONCE) == ELEKTRA_PLUGIN_ERROR) + { + return -1; + } elektraGlobalError (handle, ks, parentKey, PROCGETSTORAGE, DEINIT); break; default: diff --git a/tests/shell/gen/highlevel/struct.data.ini b/tests/shell/gen/highlevel/struct.data.ini index 4acb5c41b98..f927692a61c 100644 --- a/tests/shell/gen/highlevel/struct.data.ini +++ b/tests/shell/gen/highlevel/struct.data.ini @@ -3,6 +3,7 @@ mountpoint=tests_gen_elektra_struct.ini [mystruct] type=struct +check/type=any default="" [mystruct/a] @@ -15,6 +16,7 @@ default=8 [myotherstruct] type=struct +check/type=any default="" gen/struct/depth=2 @@ -28,6 +30,7 @@ default=6 [person/_] type=struct +check/type=any default="" gen/struct/type=Person gen/struct/alloc=1 @@ -47,6 +50,7 @@ default=1.80 [person/_/children/#] type=struct_ref +check/type=any default="" [person/_/children] @@ -56,6 +60,7 @@ check/reference/restrict=../../../person/_ [people/#] type=struct_ref +check/type=any default="" [people] From 6525b71fe535f54d136f9b63fab101d619bd4b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Tue, 14 Sep 2021 23:45:01 +0200 Subject: [PATCH 4/7] fix tests --- src/libs/elektra/kdb.c | 10 ++- src/plugins/type/testmod_type.c | 2 +- tests/shell/gen/highlevel/commands.check.sh | 71 ++++++++++++++----- tests/shell/gen/highlevel/commands.data.ini | 6 ++ tests/shell/gen/highlevel/commands.expected.c | 3 +- tests/shell/gen/highlevel/commands.expected.h | 41 +++++++++++ tests/shell/gen/highlevel/empty.check.sh | 6 +- tests/shell/gen/highlevel/enum.check.sh | 6 +- .../shell/gen/highlevel/externalspec.check.sh | 6 +- .../highlevel/externalwithdefaults.check.sh | 6 +- tests/shell/gen/highlevel/nosetter.check.sh | 6 +- tests/shell/gen/highlevel/simple.check.sh | 6 +- tests/shell/gen/highlevel/struct.check.sh | 6 +- tests/shell/gen/highlevel/struct.expected.c | 10 +-- 14 files changed, 137 insertions(+), 48 deletions(-) diff --git a/src/libs/elektra/kdb.c b/src/libs/elektra/kdb.c index 2de0e0b7669..8ab8b623792 100644 --- a/src/libs/elektra/kdb.c +++ b/src/libs/elektra/kdb.c @@ -1274,11 +1274,16 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey) elektraCacheLoad (handle, cache, parentKey, initialParent, cacheParent); // parentkey different from initialParent } + int hasProcGetStorage = handle->globalPlugins[PROCGETSTORAGE][INIT] || handle->globalPlugins[PROCGETSTORAGE][MAXONCE] || + handle->globalPlugins[PROCGETSTORAGE][DEINIT]; + // Check if a update is needed at all switch (elektraGetCheckUpdateNeeded (split, parentKey)) { case -2: // We have a cache hit - if (elektraCacheLoadSplit (handle, split, ks, &cache, &cacheParent, parentKey, initialParent, debugGlobalPositions) != 0) + // TODO: cache breaks procgetstorage + if (hasProcGetStorage || + elektraCacheLoadSplit (handle, split, ks, &cache, &cacheParent, parentKey, initialParent, debugGlobalPositions) != 0) { goto cachemiss; } @@ -1383,8 +1388,7 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey) } if (handle->globalPlugins[POSTGETSTORAGE][FOREACH] || handle->globalPlugins[POSTGETCLEANUP][FOREACH] || - handle->globalPlugins[PROCGETSTORAGE][FOREACH] || handle->globalPlugins[PROCGETSTORAGE][INIT] || - handle->globalPlugins[PROCGETSTORAGE][MAXONCE] || handle->globalPlugins[PROCGETSTORAGE][DEINIT]) + handle->globalPlugins[PROCGETSTORAGE][FOREACH] || hasProcGetStorage) { clearError (parentKey); if (elektraGetDoUpdateWithGlobalHooks (handle, split, ks, parentKey, initialParent, FIRST) == -1) diff --git a/src/plugins/type/testmod_type.c b/src/plugins/type/testmod_type.c index 22d7e6a3344..5bb0fef56c8 100644 --- a/src/plugins/type/testmod_type.c +++ b/src/plugins/type/testmod_type.c @@ -269,7 +269,7 @@ void test_string (void) { Key * k = keyNew ("user:/anything", KEY_VALUE, "a", KEY_META, "check/type", "string", KEY_END); keySetString (k, ""); - succeed_if (!checkType (k), "empty string should not check successfully as string"); + succeed_if (checkType (k), "empty string should check successfully as string"); keySetString (k, "ab"); succeed_if (checkType (k), "\"ab\" should check successfully as string"); diff --git a/tests/shell/gen/highlevel/commands.check.sh b/tests/shell/gen/highlevel/commands.check.sh index 800d9f2cd96..5fd54c603c0 100644 --- a/tests/shell/gen/highlevel/commands.check.sh +++ b/tests/shell/gen/highlevel/commands.check.sh @@ -41,9 +41,10 @@ int commandKdb (Elektra * elektra, kdb_boolean_t terminal, void * userData) int commandKdbGet (Elektra * elektra, kdb_boolean_t terminal, void * userData) { kdb_boolean_t verbose = elektraGet (elektra, ELEKTRA_TAG_GET_VERBOSE); + kdb_long_t maxLength = elektraGet (elektra, ELEKTRA_TAG_GET_MAXLENGTH); const char * keyname = elektraGet (elektra, ELEKTRA_TAG_GET_KEYNAME); - printf ("commandKdbGet called %s, verbose: %d, keyname: %s\n", terminal ? "last" : "in the middle", verbose ? 1 : 0, keyname); + printf ("commandKdbGet called %s, verbose: %d, maxLength: " ELEKTRA_LONG_F ", keyname: %s\n", terminal ? "last" : "in the middle", verbose ? 1 : 0, maxLength, keyname); return 0; } @@ -130,21 +131,51 @@ if [ "$res" = "0" ]; then res=$? echo "dummy exited with: $res" - if command -v valgrind; then - valgrind --error-exitcode=2 --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy + if [ "$res" = "0" ] && command -v valgrind; then + valgrind --error-exitcode=2 --show-leak-kinds=all --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes -- ./dummy echo "valgrind dummy exited with: $res" fi + + res=$(("$res" != 0)) fi -if [ "$res" = "0" ]; then +if [ "$res" = 0 ]; then ./dummy -v get -v ab cd res=$? echo "dummy -v get -v ab cd exited with: $res" - if command -v valgrind; then - valgrind --error-exitcode=2 --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy - echo "valgrind dummy -v get -v ab cd exited with: $res" + if [ "$res" = "0" ] && command -v valgrind; then + valgrind --error-exitcode=2 --show-leak-kinds=all --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes -- ./dummy -v get -v ab cd + echo "valgrind dummy -v get -v ab cd exited with: $?" + fi + + res=$(("$res" != 0)) +fi + +if [ "$res" = "0" ]; then + ./dummy -v get --max-length=10 ab cd + res=$? + echo "dummy -v get --max-length=10 ab cd exited with: $res" + + if [ "$res" = "0" ] && command -v valgrind; then + valgrind --error-exitcode=2 --show-leak-kinds=all --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes -- ./dummy -v get --max-length=10 ab cd + echo "valgrind dummy -v get -v ab cd exited with: $?" + fi + + res=$(("$res" != 0)) +fi + +if [ "$res" = "0" ]; then + ./dummy -v get --max-length=notanint ab cd + res=$? + echo "dummy -v get --max-length=notanint ab cd exited with: $res" + + if [ "$res" = "0" ] && command -v valgrind; then + valgrind --error-exitcode=2 --show-leak-kinds=all --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes -- ./dummy -v get --max-length=notanint ab cd + echo "valgrind dummy -v get -v ab cd exited with: $?" fi + + res=$(("$res" == 0)) fi if [ "$res" = "0" ]; then @@ -152,21 +183,25 @@ if [ "$res" = "0" ]; then res=$? echo "dummy get meta -v a b exited with: $res" - if command -v valgrind; then - valgrind --error-exitcode=2 --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy - echo "valgrind dummy get meta -v a b exited with: $res" + if [ "$res" = "0" ] && command -v valgrind; then + valgrind --error-exitcode=2 --show-leak-kinds=all --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes -- ./dummy get meta -v a b + echo "valgrind dummy get meta -v a b exited with: $?" fi + + res=$(("$res" != 0)) fi if [ "$res" = "0" ]; then - ./dummy set def -2 + ./dummy set -- def -2 res=$? echo "dummy set def -2 exited with: $res" - if command -v valgrind; then - valgrind --error-exitcode=2 --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy - echo "valgrind dummy set def -2 exited with: $res" + if [ "$res" = "0" ] && command -v valgrind; then + valgrind --error-exitcode=2 --show-leak-kinds=all --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes -- ./dummy set def -2 + echo "valgrind dummy set def -2 exited with: $?" fi + + res=$(("$res" != 0)) fi if [ "$res" = "0" ]; then @@ -174,10 +209,12 @@ if [ "$res" = "0" ]; then res=$? echo "dummy abc -v def exited with: $res" - if command -v valgrind; then - valgrind --error-exitcode=2 --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy - echo "valgrind dummy abc -v def exited with: $res" + if [ "$res" = "0" ] && command -v valgrind; then + valgrind --error-exitcode=2 --show-leak-kinds=all --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes -- ./dummy abc -v def + echo "valgrind dummy abc -v def exited with: $?" fi + + res=$(("$res" != 0)) fi cd .. diff --git a/tests/shell/gen/highlevel/commands.data.ini b/tests/shell/gen/highlevel/commands.data.ini index 6cfed923d6e..3c7b43e4351 100644 --- a/tests/shell/gen/highlevel/commands.data.ini +++ b/tests/shell/gen/highlevel/commands.data.ini @@ -25,6 +25,12 @@ opt = v opt/long = verbose opt/arg = none +[get/maxlength] +type = long +default = -1 +opt/long = max-length +opt/arg = required + [get/keyname] type = string default = "" diff --git a/tests/shell/gen/highlevel/commands.expected.c b/tests/shell/gen/highlevel/commands.expected.c index 9037e38c43f..142c33066b9 100644 --- a/tests/shell/gen/highlevel/commands.expected.c +++ b/tests/shell/gen/highlevel/commands.expected.c @@ -41,11 +41,12 @@ static KeySet * embeddedSpec (void) { - return ksNew (13, + return ksNew (14, keyNew ("/", KEY_META, "command", "", KEY_META, "default", "", KEY_META, "gen/command/function", "commandKdb", KEY_META, "mountpoint", "tests_gen_elektra_commands.ini", KEY_META, "type", "string", KEY_END), keyNew ("/dynamic/#", KEY_META, "args", "remaining", KEY_META, "default", "", KEY_META, "type", "string", KEY_END), keyNew ("/get", KEY_META, "command", "get", KEY_META, "default", "", KEY_META, "gen/command/function", "commandKdbGet", KEY_META, "type", "string", KEY_END), keyNew ("/get/keyname", KEY_META, "args", "indexed", KEY_META, "args/index", "0", KEY_META, "default", "", KEY_META, "type", "string", KEY_END), + keyNew ("/get/maxlength", KEY_META, "default", "-1", KEY_META, "opt/arg", "required", KEY_META, "opt/long", "max-length", KEY_META, "type", "long", KEY_END), keyNew ("/get/meta", KEY_META, "command", "meta", KEY_META, "default", "", KEY_META, "gen/command/function", "commandKdbGetMeta", KEY_META, "type", "string", KEY_END), keyNew ("/get/meta/keyname", KEY_META, "args", "indexed", KEY_META, "args/index", "0", KEY_META, "default", "", KEY_META, "type", "string", KEY_END), keyNew ("/get/meta/metaname", KEY_META, "args", "indexed", KEY_META, "args/index", "1", KEY_META, "default", "", KEY_META, "type", "string", KEY_END), diff --git a/tests/shell/gen/highlevel/commands.expected.h b/tests/shell/gen/highlevel/commands.expected.h index 322320add3c..b9ba5b123e4 100644 --- a/tests/shell/gen/highlevel/commands.expected.h +++ b/tests/shell/gen/highlevel/commands.expected.h @@ -116,6 +116,12 @@ extern "C" { */// #define ELEKTRA_TAG_GET_KEYNAME GetKeyname +/** +* Tag name for 'get/maxlength' +* +*/// +#define ELEKTRA_TAG_GET_MAXLENGTH GetMaxlength + /** * Tag name for 'get/meta' * @@ -331,6 +337,41 @@ static inline void ELEKTRA_SET (ELEKTRA_TAG_GET_KEYNAME) (Elektra * elektra, +/** + * Get the value of key 'get/maxlength' (tag #ELEKTRA_TAG_GET_MAXLENGTH). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + + * + * @return the value of 'get/maxlength'. + + */// +static inline kdb_long_t ELEKTRA_GET (ELEKTRA_TAG_GET_MAXLENGTH) (Elektra * elektra ) +{ + + return ELEKTRA_GET (Long) (elektra, "get/maxlength"); +} + + +/** + * Set the value of key 'get/maxlength' (tag #ELEKTRA_TAG_GET_MAXLENGTH). + * + * @param elektra Instance of Elektra. Create with loadConfiguration(). + * @param value The value of 'get/maxlength'. + + * @param error Pass a reference to an ElektraError pointer. + * Will only be set in case of an error. + */// +static inline void ELEKTRA_SET (ELEKTRA_TAG_GET_MAXLENGTH) (Elektra * elektra, + kdb_long_t value, ElektraError ** error) +{ + + ELEKTRA_SET (Long) (elektra, "get/maxlength", value, error); +} + + + + /** * Get the value of key 'get/meta' (tag #ELEKTRA_TAG_GET_META). * diff --git a/tests/shell/gen/highlevel/empty.check.sh b/tests/shell/gen/highlevel/empty.check.sh index 83bc43fec5a..a918a6a0b1d 100644 --- a/tests/shell/gen/highlevel/empty.check.sh +++ b/tests/shell/gen/highlevel/empty.check.sh @@ -91,9 +91,9 @@ if [ "$res" = "0" ]; then res=$? echo "dummy exited with: $res" - if command -v valgrind; then - valgrind --error-exitcode=2 --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy - echo "valgrind dummy exited with: $res" + if [ "$res" = "0" ] && command -v valgrind; then + valgrind --error-exitcode=2 --show-leak-kinds=all --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy + echo "valgrind dummy exited with: $?" fi fi diff --git a/tests/shell/gen/highlevel/enum.check.sh b/tests/shell/gen/highlevel/enum.check.sh index b982e35cd8f..d3624d62e99 100644 --- a/tests/shell/gen/highlevel/enum.check.sh +++ b/tests/shell/gen/highlevel/enum.check.sh @@ -122,9 +122,9 @@ if [ "$res" = "0" ]; then res=$? echo "dummy exited with: $res" - if command -v valgrind; then - valgrind --error-exitcode=2 --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy - echo "valgrind dummy exited with: $res" + if [ "$res" = "0" ] && command -v valgrind; then + valgrind --error-exitcode=2 --show-leak-kinds=all --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy + echo "valgrind dummy exited with: $?" fi fi diff --git a/tests/shell/gen/highlevel/externalspec.check.sh b/tests/shell/gen/highlevel/externalspec.check.sh index 8f9f3a2c434..c497d3fc83e 100644 --- a/tests/shell/gen/highlevel/externalspec.check.sh +++ b/tests/shell/gen/highlevel/externalspec.check.sh @@ -117,9 +117,9 @@ if [ "$res" = "0" ]; then "$KDB" export "spec:$MOUNTPOINT" ni > ~/export.spec.ini "$KDB" export "user:$MOUNTPOINT" ni > ~/export.user.ini - if command -v valgrind; then - valgrind --error-exitcode=2 --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy - echo "valgrind dummy exited with: $res" + if [ "$res" = "0" ] && command -v valgrind; then + valgrind --error-exitcode=2 --show-leak-kinds=all --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy + echo "valgrind dummy exited with: $?" fi fi diff --git a/tests/shell/gen/highlevel/externalwithdefaults.check.sh b/tests/shell/gen/highlevel/externalwithdefaults.check.sh index 6603f48c97b..4442ca11755 100644 --- a/tests/shell/gen/highlevel/externalwithdefaults.check.sh +++ b/tests/shell/gen/highlevel/externalwithdefaults.check.sh @@ -117,9 +117,9 @@ if [ "$res" = "0" ]; then "$KDB" export "spec:$MOUNTPOINT" ni > ~/export.spec.ini "$KDB" export "user:$MOUNTPOINT" ni > ~/export.user.ini - if command -v valgrind; then - valgrind --error-exitcode=2 --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy - echo "valgrind dummy exited with: $res" + if [ "$res" = "0" ] && command -v valgrind; then + valgrind --error-exitcode=2 --show-leak-kinds=all --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy + echo "valgrind dummy exited with: $?" fi fi diff --git a/tests/shell/gen/highlevel/nosetter.check.sh b/tests/shell/gen/highlevel/nosetter.check.sh index 29358bd841d..4a2860a630e 100644 --- a/tests/shell/gen/highlevel/nosetter.check.sh +++ b/tests/shell/gen/highlevel/nosetter.check.sh @@ -104,9 +104,9 @@ if [ "$res" = "0" ]; then "$KDB" export "spec:$MOUNTPOINT" ni > ~/export.spec.ini "$KDB" export "user:$MOUNTPOINT" ni > ~/export.user.ini - if command -v valgrind; then - valgrind --error-exitcode=2 --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy - echo "valgrind dummy exited with: $res" + if [ "$res" = "0" ] && command -v valgrind; then + valgrind --error-exitcode=2 --show-leak-kinds=all --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy + echo "valgrind dummy exited with: $?" fi fi diff --git a/tests/shell/gen/highlevel/simple.check.sh b/tests/shell/gen/highlevel/simple.check.sh index e5815940c0a..5617e18705c 100644 --- a/tests/shell/gen/highlevel/simple.check.sh +++ b/tests/shell/gen/highlevel/simple.check.sh @@ -119,9 +119,9 @@ if [ "$res" = "0" ]; then "$KDB" export "spec:$MOUNTPOINT" ni > ~/export.spec.ini "$KDB" export "user:$MOUNTPOINT" ni > ~/export.user.ini - if command -v valgrind; then - valgrind --error-exitcode=2 --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy - echo "valgrind dummy exited with: $res" + if [ "$res" = "0" ] && command -v valgrind; then + valgrind --error-exitcode=2 --show-leak-kinds=all --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy + echo "valgrind dummy exited with: $?" fi fi diff --git a/tests/shell/gen/highlevel/struct.check.sh b/tests/shell/gen/highlevel/struct.check.sh index 8aab1a2f6b7..11adb65e07e 100644 --- a/tests/shell/gen/highlevel/struct.check.sh +++ b/tests/shell/gen/highlevel/struct.check.sh @@ -103,9 +103,9 @@ if [ "$res" = "0" ]; then res=$? echo "dummy exited with: $res" - if command -v valgrind; then - valgrind --error-exitcode=2 --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy - echo "valgrind dummy exited with: $res" + if [ "$res" = "0" ] && command -v valgrind; then + valgrind --error-exitcode=2 --show-leak-kinds=all --leak-check=full --leak-resolution=high --track-origins=yes --vgdb=no --trace-children=yes ./dummy + echo "valgrind dummy exited with: $?" fi fi diff --git a/tests/shell/gen/highlevel/struct.expected.c b/tests/shell/gen/highlevel/struct.expected.c index 1e6735d0303..6e299912a51 100644 --- a/tests/shell/gen/highlevel/struct.expected.c +++ b/tests/shell/gen/highlevel/struct.expected.c @@ -43,18 +43,18 @@ static KeySet * embeddedSpec (void) { return ksNew (15, keyNew ("/", KEY_META, "mountpoint", "tests_gen_elektra_struct.ini", KEY_END), - keyNew ("/myotherstruct", KEY_META, "default", "", KEY_META, "gen/struct/depth", "2", KEY_META, "type", "struct", KEY_END), + keyNew ("/myotherstruct", KEY_META, "check/type", "any", KEY_META, "default", "", KEY_META, "gen/struct/depth", "2", KEY_META, "type", "struct", KEY_END), keyNew ("/myotherstruct/x", KEY_META, "default", "4", KEY_META, "type", "long", KEY_END), keyNew ("/myotherstruct/x/y", KEY_META, "default", "6", KEY_META, "type", "long", KEY_END), - keyNew ("/mystruct", KEY_META, "default", "", KEY_META, "type", "struct", KEY_END), + keyNew ("/mystruct", KEY_META, "check/type", "any", KEY_META, "default", "", KEY_META, "type", "struct", KEY_END), keyNew ("/mystruct/a", KEY_META, "default", "", KEY_META, "type", "string", KEY_END), keyNew ("/mystruct/b", KEY_META, "default", "8", KEY_META, "type", "long", KEY_END), keyNew ("/people", KEY_META, "check/reference", "single", KEY_META, "check/reference/restrict", "../person/_", KEY_META, "default", "", KEY_END), - keyNew ("/people/#", KEY_META, "default", "", KEY_META, "type", "struct_ref", KEY_END), - keyNew ("/person/_", KEY_META, "default", "", KEY_META, "gen/struct/alloc", "1", KEY_META, "gen/struct/type", "Person", KEY_META, "type", "struct", KEY_END), + keyNew ("/people/#", KEY_META, "check/type", "any", KEY_META, "default", "", KEY_META, "type", "struct_ref", KEY_END), + keyNew ("/person/_", KEY_META, "check/type", "any", KEY_META, "default", "", KEY_META, "gen/struct/alloc", "1", KEY_META, "gen/struct/type", "Person", KEY_META, "type", "struct", KEY_END), keyNew ("/person/_/age", KEY_META, "default", "30", KEY_META, "type", "short", KEY_END), keyNew ("/person/_/children", KEY_META, "check/reference", "recursive", KEY_META, "check/reference/restrict", "../../../person/_", KEY_META, "default", "", KEY_END), - keyNew ("/person/_/children/#", KEY_META, "default", "", KEY_META, "type", "struct_ref", KEY_END), + keyNew ("/person/_/children/#", KEY_META, "check/type", "any", KEY_META, "default", "", KEY_META, "type", "struct_ref", KEY_END), keyNew ("/person/_/height", KEY_META, "default", "1.80", KEY_META, "type", "float", KEY_END), keyNew ("/person/_/name", KEY_META, "default", "Max", KEY_META, "gen/struct/field", "fullName", KEY_META, "type", "string", KEY_END), KS_END); From 4eec1ca3464c7ce62b7bbc9206b4651a83727054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Tue, 14 Sep 2021 23:47:23 +0200 Subject: [PATCH 5/7] add release notes --- doc/news/_preparation_next_release.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/news/_preparation_next_release.md b/doc/news/_preparation_next_release.md index d3847491165..24f0621fae7 100644 --- a/doc/news/_preparation_next_release.md +++ b/doc/news/_preparation_next_release.md @@ -51,12 +51,12 @@ The following section lists news about the [plugins](https://www.libelektra.org/ ### gopts - The `gopts` plugin now includes deeply nested options and arguments in the generated help message. _(Tobias Schubert @qwepoizt)_ +- Errors from `gopts` are now correctly reported. _(Klemens Böswirth)_ -### <> +### spec -- <> -- <> -- <> +- The `spec` plugin now runs before other `postgetstorage` plugins, so that validation can happen during `kdbGet` as well. + This is especially relevant in combination with `gopts`. _(Klemens Böswirth)_ ### <> From 1e267b71fff0f2bc9ab8d67f2147758fcb23c1d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Wed, 15 Sep 2021 13:13:08 +0200 Subject: [PATCH 6/7] make shell script POSIX compatible --- tests/shell/gen/highlevel/commands.check.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/shell/gen/highlevel/commands.check.sh b/tests/shell/gen/highlevel/commands.check.sh index 5fd54c603c0..a1b1004fb91 100644 --- a/tests/shell/gen/highlevel/commands.check.sh +++ b/tests/shell/gen/highlevel/commands.check.sh @@ -136,7 +136,7 @@ if [ "$res" = "0" ]; then echo "valgrind dummy exited with: $res" fi - res=$(("$res" != 0)) + res=$((res != 0)) fi if [ "$res" = 0 ]; then @@ -149,7 +149,7 @@ if [ "$res" = 0 ]; then echo "valgrind dummy -v get -v ab cd exited with: $?" fi - res=$(("$res" != 0)) + res=$((res != 0)) fi if [ "$res" = "0" ]; then @@ -162,7 +162,7 @@ if [ "$res" = "0" ]; then echo "valgrind dummy -v get -v ab cd exited with: $?" fi - res=$(("$res" != 0)) + res=$((res != 0)) fi if [ "$res" = "0" ]; then @@ -175,7 +175,7 @@ if [ "$res" = "0" ]; then echo "valgrind dummy -v get -v ab cd exited with: $?" fi - res=$(("$res" == 0)) + res=$((res == 0)) fi if [ "$res" = "0" ]; then @@ -188,7 +188,7 @@ if [ "$res" = "0" ]; then echo "valgrind dummy get meta -v a b exited with: $?" fi - res=$(("$res" != 0)) + res=$((res != 0)) fi if [ "$res" = "0" ]; then @@ -201,7 +201,7 @@ if [ "$res" = "0" ]; then echo "valgrind dummy set def -2 exited with: $?" fi - res=$(("$res" != 0)) + res=$((res != 0)) fi if [ "$res" = "0" ]; then @@ -214,7 +214,7 @@ if [ "$res" = "0" ]; then echo "valgrind dummy abc -v def exited with: $?" fi - res=$(("$res" != 0)) + res=$((res != 0)) fi cd .. From e7f62f204cbe53b293404ed165ec78a32ea16b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klemens=20B=C3=B6swirth?= Date: Wed, 15 Sep 2021 15:31:26 +0200 Subject: [PATCH 7/7] fix external tests --- examples/codegen/econf/spec.ini | 1 + examples/codegen/tree/spec.ini | 3 +++ 2 files changed, 4 insertions(+) diff --git a/examples/codegen/econf/spec.ini b/examples/codegen/econf/spec.ini index aa36db235c2..d02ab8b81d5 100644 --- a/examples/codegen/econf/spec.ini +++ b/examples/codegen/econf/spec.ini @@ -7,6 +7,7 @@ default = 0 [format/#] type = struct +check/type = any default = "" gen/struct/type = FormatConf gen/struct/depth = 2 diff --git a/examples/codegen/tree/spec.ini b/examples/codegen/tree/spec.ini index 10ca9c3ea23..f5ae6b31d14 100644 --- a/examples/codegen/tree/spec.ini +++ b/examples/codegen/tree/spec.ini @@ -3,18 +3,21 @@ mountpoint = codegen_tree_example.conf [root] type = struct_ref +check/type = any default = "" check/reference = recursive check/reference/restrict = ../tree/_ [tree/_] type = struct +check/type = any default = "" gen/struct/type = Tree gen/struct/alloc = 1 [tree/_/children/#] type = struct_ref +check/type = any default = "" gen/struct/array/sizefield = childCount