Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Add shell test case for parent array spec bug #4918

Merged
merged 8 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/news/_preparation_next_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ This section keeps you up-to-date with the multi-language support provided by El

## Tests

- <<TODO>>
- Add shell test to verify correct behavior for https://github.com/ElektraInitiative/libelektra/issues/4061 _(Tomislav Makar @tmakar)_
- <<TODO>>
- <<TODO>>
- <<TODO>>
Expand Down
92 changes: 92 additions & 0 deletions tests/shell/external/example_codegen_econf_empty_array_spec.sh
Original file line number Diff line number Diff line change
@@ -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/#"
tmakar marked this conversation as resolved.
Show resolved Hide resolved
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