diff --git a/doc/news/_preparation_next_release.md b/doc/news/_preparation_next_release.md index b92717655fa..d5056ff3119 100755 --- a/doc/news/_preparation_next_release.md +++ b/doc/news/_preparation_next_release.md @@ -477,7 +477,7 @@ This section keeps you up-to-date with the multi-language support provided by El ## Tests -- <> +- Add shell test to verify correct behavior for https://github.com/ElektraInitiative/libelektra/issues/4061 _(Tomislav Makar @tmakar)_ - <> - <> - <> diff --git a/tests/shell/external/example_codegen_econf_empty_array_spec.sh b/tests/shell/external/example_codegen_econf_empty_array_spec.sh new file mode 100644 index 00000000000..c8c9424a2f1 --- /dev/null +++ b/tests/shell/external/example_codegen_econf_empty_array_spec.sh @@ -0,0 +1,92 @@ +#!/bin/sh + +@INCLUDE_COMMON@ + +echo +echo ELEKTRA CHECK EXTERNAL CODEGEN ECONF EMPTY ARRAY SPEC +echo + +if command -v realpath; then + if command -v pkg-config; then + if ! pkg-config elektra; then + echo "Elektra not installed, will skip" + exit 0 + fi + else + echo "pkg-config not installed, will skip" + exit 0 + fi +else + echo "realpath is not installed, will skip" + exit 0 +fi + +check_version + +EXTERNAL_FOLDER="@CMAKE_SOURCE_DIR@/examples/codegen/econf" + +check_if_parent_exists() { + if grep -e "spec:\/sw\/example\/econf/\#0\/current\/format\/#$"; then + echo "array parent was found" + else + echo "did not find array parent spec:/sw/example/econf/#0/current/format/#" + exit 1 + fi +} + +do_tests() { + KEY="/sw/example/econf/#0/current" + UKEY="user:$KEY" + SPECKEY="spec:$KEY" + + "$KDB" umount "$SPECKEY" + "$KDB" umount "$KEY" + "$KDB" rm -r "$UKEY" + "$KDB" rm -r "$SPECKEY" + + "$KDB" mount "$(pwd)/spec.ini" "$SPECKEY" ni + "$KDB" import "$SPECKEY" ni < "$EXTERNAL_FOLDER/spec.ini" + "$KDB" spec-mount "$KEY" + + "$KDB" ls "spec:/sw/example/econf/#0" | check_if_parent_exists + + "$KDB" meta-set "$KEY/format" array "#2" + "$KDB" ls "spec:/sw/example/econf/#0" | check_if_parent_exists + + "$KDB" rm -r "$UKEY" + "$KDB" rm -r "$SPECKEY" + "$KDB" umount "$SPECKEY" + "$KDB" umount "$UKEY" + "$KDB" umount "$KEY" +} + +echo "Testing build with cmake" + +cd "$EXTERNAL_FOLDER" || exit +mkdir build +cd build || exit + +# manually set Elektra_DIR and KDB to support non-standard install locations +cmake ../cmake -DElektra_DIR:PATH="$(realpath "$(dirname "$0")"/../../cmake/Elektra)" -DKDB:PATH="$KDB" +succeed_if "could not run cmake" + +cmake --build . +succeed_if "could not build cmake project" + +do_tests + +cd .. +rm -r build + +echo "Testing build with pkgconfig" + +cd "$EXTERNAL_FOLDER/pkgconfig" || exit +# set KDB to support non-standard install locations +KDB="$KDB" make +succeed_if "could not build pkgconfig project" + +do_tests + +make clean + +end_script gen