Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix is_not_rw_storage #2595

Merged
merged 28 commits into from Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
48689f3
tests: fix is_not_rw_storage
llukask Mar 18, 2019
b5200e4
tests: make check_export accept quotes around value
llukask Mar 18, 2019
0301368
tests: include_common.sh.in shoud have 1000 lines
llukask Mar 18, 2019
a141b41
tests: use 4 argument command version in import
llukask Apr 7, 2019
8aaa983
tests: include_common.sh.in shoud have 1000 lines
llukask Mar 18, 2019
cac3372
tests: disable generate_data.sh
llukask Apr 7, 2019
5f88177
tests: check_import and check_export should run for at least one plugin
llukask Apr 7, 2019
65a74c2
test: exclude yamlcpp from is_not_rw_storage
llukask Apr 8, 2019
10af10d
test: add test-files for xerces
llukask Apr 8, 2019
4880a63
test: regenerate test-files for yajl
llukask Apr 8, 2019
73fe334
test: don't do naming tests for ini
llukask Apr 8, 2019
1882771
test: don't check if directory-value is set for yajl
llukask Apr 8, 2019
f1eaed4
test: run reformatting script
llukask Apr 8, 2019
cc8833d
tests: include_common.sh.in shoud have 1000 lines
llukask Mar 18, 2019
5eeb975
tests: use 4 argument command version in import
llukask Apr 7, 2019
f6ca6a4
tests: include_common.sh.in shoud have 1000 lines
llukask Mar 18, 2019
3728afb
tests: disable generate_data.sh
llukask Apr 7, 2019
d8a4d7a
test: fix is_not_rw_storage add release notes
llukask Apr 7, 2019
c1afc01
test: run reformatting script
llukask Apr 8, 2019
ccadfd3
test: add yanlr to list of excluded plugins
llukask Aug 7, 2019
38b9cce
test: regenerate test files
llukask Aug 7, 2019
fc782a2
test: add yawn to list of excluded plugins
llukask Aug 7, 2019
c1a9ff4
test: do cleanup before running check_import
llukask Aug 8, 2019
560c4f3
test: run formatting script
llukask Aug 8, 2019
0fc0bac
tests: exclude dini
Aug 8, 2019
58bb002
tests: reformat shell
Aug 8, 2019
488ba93
tests: regenerate shell test data
kodebach Sep 29, 2020
4e76908
tests: disable storage tests for toml and kconfig
kodebach Sep 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/news/_preparation_next_release.md
Expand Up @@ -152,6 +152,8 @@ you up to date with the multi-language support provided by Elektra.

## Tests

- Fixed the `is_not_rw_storage` function. _(Lukas Kilian)_
- We now ensure that the `check_import` and `check_export` tests run for at least one plugin. _(Lukas Kilian)_
- <<TODO>>
- <<TODO>>
- <<TODO>>
Expand Down
9 changes: 8 additions & 1 deletion tests/shell/check_export.sh
Expand Up @@ -10,6 +10,8 @@ ROOT=$USER_ROOT
FILE="$(mktempfile_elektra)"
PLUGIN=$PLUGIN

RAN_ONCE=0

cleanup() {
rm -f $FILE
}
Expand All @@ -26,6 +28,8 @@ for PLUGIN in $PLUGINS; do
continue
fi

RAN_ONCE=1

echo -------- $PLUGIN -----------

"$KDB" set $ROOT "root" > /dev/null
Expand All @@ -40,7 +44,7 @@ for PLUGIN in $PLUGINS; do
diff "$DATADIR"/one_value.$PLUGIN $FILE
succeed_if "Export file one_value.$PLUGIN was not equal"

test "$("$KDB" set $ROOT/key "value")" = "Create a new key $ROOT/key with string value"
test "$("$KDB" set $ROOT/key "value")" = "Create a new key $ROOT/key with string \"value\""
succeed_if "Could not set $ROOT/key"

"$KDB" export $ROOT $PLUGIN > $FILE
Expand Down Expand Up @@ -72,4 +76,7 @@ for PLUGIN in $PLUGINS; do

done

test $RAN_ONCE != 0
succeed_if "check_export should run for at least one plugin"

end_script
68 changes: 41 additions & 27 deletions tests/shell/check_import.sh
Expand Up @@ -10,6 +10,8 @@ ROOT=$USER_ROOT
FILE="$(mktempfile_elektra)"
SIDE=$ROOT/../side_val

RAN_ONCE=0

cleanup() {
rm -f $FILE
}
Expand All @@ -20,12 +22,17 @@ exit_if_fail "For export/import /dev must be mounted"
[ -e /dev/stdout ]
exit_if_fail "For export/import /dev must be mounted"

"$KDB" rm -r $ROOT
"$KDB" rm $SIDE

for PLUGIN in $PLUGINS; do
if is_not_rw_storage; then
echo "-- $PLUGIN not a read-write storage"
continue
fi

RAN_ONCE=1

echo -------- $PLUGIN -----------

echo "Import with existing root"
Expand All @@ -41,14 +48,16 @@ for PLUGIN in $PLUGINS; do
test "x$("$KDB" ls $ROOT)" = "x$ROOT"
succeed_if "Root key not found"

"$KDB" import $ROOT $PLUGIN < "$DATADIR"/one_value.$PLUGIN
"$KDB" import $ROOT $PLUGIN "$DATADIR"/one_value.$PLUGIN
succeed_if "Could not run kdb import"

test "x$("$KDB" ls $ROOT)" = "xuser/tests/script"
succeed_if "key name not correct one_value"

test "$("$KDB" get $ROOT)" = root
succeed_if "root value not correct"
if [ "x$PLUGIN" != "xyajl" ]; then
test "$("$KDB" get $ROOT)" = root
succeed_if "root value not correct"
fi

"$KDB" export $ROOT $PLUGIN > $FILE
succeed_if "Could not run kdb export"
Expand All @@ -61,7 +70,7 @@ for PLUGIN in $PLUGINS; do

echo "Import with empty root"

"$KDB" import $ROOT $PLUGIN < "$DATADIR"/one_value.$PLUGIN
"$KDB" import $ROOT $PLUGIN "$DATADIR"/one_value.$PLUGIN
succeed_if "Could not run kdb import"

test "x$("$KDB" ls $ROOT)" = "xuser/tests/script"
Expand All @@ -83,29 +92,31 @@ for PLUGIN in $PLUGINS; do
"$KDB" rm -r $ROOT
succeed_if "Could not remove root"

echo "Import as stream (using cat)"
if [ "x$PLUGIN" != "xdini" ]; then
echo "Import as stream (using cat)"

cat "$DATADIR"/one_value.$PLUGIN | "$KDB" import $ROOT $PLUGIN
succeed_if "Could not run kdb import"
cat "$DATADIR"/one_value.$PLUGIN | "$KDB" import $ROOT $PLUGIN
succeed_if "Could not run kdb import"

test "x$("$KDB" ls $ROOT)" = "xuser/tests/script"
succeed_if "key name not correct one_value empty root"
test "x$("$KDB" ls $ROOT)" = "xuser/tests/script"
succeed_if "key name not correct one_value empty root"

if [ "x$PLUGIN" != "xyajl" ]; then
#TODO: yajl currently cannot hold values within
#directories, do not hardcode that
test "$("$KDB" get $ROOT)" = root
succeed_if "root value not correct"
fi
if [ "x$PLUGIN" != "xyajl" ]; then
#TODO: yajl currently cannot hold values within
#directories, do not hardcode that
test "$("$KDB" get $ROOT)" = root
succeed_if "root value not correct"
fi

"$KDB" export $ROOT $PLUGIN > $FILE
succeed_if "Could not run kdb export"
"$KDB" export $ROOT $PLUGIN > $FILE
succeed_if "Could not run kdb export"

diff "$DATADIR"/one_value.$PLUGIN $FILE
succeed_if "Export file one_value.$PLUGIN was not equal"
diff "$DATADIR"/one_value.$PLUGIN $FILE
succeed_if "Export file one_value.$PLUGIN was not equal"

"$KDB" rm -r $ROOT
succeed_if "Could not remove root"
"$KDB" rm -r $ROOT
succeed_if "Could not remove root"
fi

echo "Import with wrong root (overwrite)"

Expand All @@ -115,7 +126,7 @@ for PLUGIN in $PLUGINS; do
"$KDB" set $ROOT "wrong_root" > /dev/null
exit_if_fail "could not set wrong_root"

"$KDB" import -s "import" $ROOT $PLUGIN < "$DATADIR"/one_value.$PLUGIN
"$KDB" import -s "import" $ROOT $PLUGIN "$DATADIR"/one_value.$PLUGIN
succeed_if "Could not run kdb import"

test "x$("$KDB" ls $ROOT)" = "xuser/tests/script"
Expand Down Expand Up @@ -152,11 +163,11 @@ for PLUGIN in $PLUGINS; do
"$KDB" import $ROOT $PLUGIN < "$DATADIR"/two_value.$PLUGIN
succeed_if "Could not run kdb import"

test "x$("$KDB" ls $ROOT)" = "xuser/tests/script
if [ "x$PLUGIN" != "xyajl" ]; then
test "x$("$KDB" ls $ROOT)" = "xuser/tests/script
user/tests/script/key"
succeed_if "key name not correct"
succeed_if "key name not correct"

if [ "x$PLUGIN" != "xyajl" ]; then
#TODO: yajl currently cannot hold values within
#directories, do not hardcode that
test "$("$KDB" get $ROOT)" = root
Expand All @@ -177,7 +188,7 @@ user/tests/script/key"
"$KDB" set $SIDE val
succeed_if "Could not set $SIDE"

"$KDB" import -s "cut" $ROOT $PLUGIN < "$DATADIR"/one_value.$PLUGIN
"$KDB" import -s "cut" $ROOT $PLUGIN "$DATADIR"/one_value.$PLUGIN
succeed_if "Could not run kdb import"

test "x$("$KDB" ls $ROOT)" = "xuser/tests/script"
Expand Down Expand Up @@ -213,7 +224,7 @@ user/tests/script/key"
"$KDB" set $SIDE val
succeed_if "Could not set $SIDE"

"$KDB" import -s "cut" $ROOT $PLUGIN < "$DATADIR"/one_value.$PLUGIN
"$KDB" import -s "cut" $ROOT $PLUGIN "$DATADIR"/one_value.$PLUGIN
succeed_if "Could not run kdb import"

test "x$("$KDB" ls $ROOT)" = "xuser/tests/script"
Expand Down Expand Up @@ -247,4 +258,7 @@ user/tests/script/key"

done

test $RAN_ONCE != 0
succeed_if "check_import should run for at least one plugin"

end_script
2 changes: 1 addition & 1 deletion tests/shell/check_kdb_internal_suite.sh
Expand Up @@ -22,7 +22,7 @@ for PLUGIN in $PLUGINS; do
;;
"ini")
MOUNT_PLUGIN="$PLUGIN"
TESTS="basic string umlauts naming"
TESTS="basic string umlauts"
;;
"line")
TESTS="basic"
Expand Down
4 changes: 2 additions & 2 deletions tests/shell/generate_data.sh
Expand Up @@ -22,13 +22,13 @@ for PLUGIN in $PLUGINS; do
"$KDB" set $ROOT "root" > /dev/null
exit_if_fail "could not set root"

test $("$KDB" ls $ROOT) = $ROOT
test "$("$KDB" ls $ROOT)" = "$ROOT"
succeed_if "Root key not found"

"$KDB" export $ROOT $PLUGIN > "$DATADIR"/one_value.$PLUGIN
succeed_if "Could not run kdb export"

test "$("$KDB" set $ROOT/key "value")" = "create a new key $ROOT/key with string value"
test "$("$KDB" set $ROOT/key "value")" = "Create a new key $ROOT/key with string \"value\""
succeed_if "Could not set $ROOT/key"

"$KDB" export $ROOT $PLUGIN > "$DATADIR"/two_value.$PLUGIN
Expand Down
52 changes: 26 additions & 26 deletions tests/shell/include_common.sh.in
Expand Up @@ -203,8 +203,12 @@ check_set_mv_rm() {
#

is_not_rw_storage() {
test ! "x$("$KDB" plugin-info $PLUGIN provides 2> /dev/null)" = "xstorage" \
-o "x$PLUGIN" = "xhosts" \
echo $("$KDB" plugin-info $PLUGIN provides 2> /dev/null) | fgrep -qw "storage"
if [ $? != 0 ]; then
return 0
fi

test "x$PLUGIN" = "xhosts" \
-o "x$PLUGIN" = "xfstab" \
-o "x$PLUGIN" = "xline" \
-o "x$PLUGIN" = "xuname" \
Expand All @@ -217,7 +221,26 @@ is_not_rw_storage() {
-o "x$PLUGIN" = "xsimplespeclang" \
-o "x$PLUGIN" = "xmozprefs" \
-o "x$PLUGIN" = "xfile" \
-o "x$PLUGIN" = "xruby"
-o "x$PLUGIN" = "xruby" \
-o "x$PLUGIN" = "xdesktop" \
-o "x$PLUGIN" = "xc" \
-o "x$PLUGIN" = "xcpptemplate" \
-o "x$PLUGIN" = "xspecload" \
-o "x$PLUGIN" = "xmmapstorage" \
-o "x$PLUGIN" = "xmmapstorage_crc" \
-o "x$PLUGIN" = "xmultifile" \
-o "x$PLUGIN" = "xcamel" \
-o "x$PLUGIN" = "xsimpleini" \
-o "x$PLUGIN" = "xyambi" \
-o "x$PLUGIN" = "xtcl" \
-o "x$PLUGIN" = "xmini" \
-o "x$PLUGIN" = "xyaypeg" \
-o "x$PLUGIN" = "xyamlcpp" \
-o "x$PLUGIN" = "xyanlr" \
-o "x$PLUGIN" = "xyawn" \
-o "x$PLUGIN" = "xkconfig" \
-o "x$PLUGIN" = "xtoml" \
-o "x$PLUGIN" = "xdini"
}

is_plugin_available() {
Expand Down Expand Up @@ -974,27 +997,4 @@ export_check() {
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
# empty lines up to 1000 so that line numbers in the resulting scripts are more useful
3 changes: 3 additions & 0 deletions tests/shell/shell/again_two_value.dini
@@ -0,0 +1,3 @@
= root
[key]
subkey=another value
2 changes: 1 addition & 1 deletion tests/shell/shell/again_two_value.ini
@@ -1,3 +1,3 @@
= root
[key]
subkey = another value
subkey=another value
4 changes: 4 additions & 0 deletions tests/shell/shell/again_two_value.kconfig
@@ -0,0 +1,4 @@
script=root

[key]
subkey=another value
Binary file modified tests/shell/shell/again_two_value.quickdump
Binary file not shown.
1 change: 1 addition & 0 deletions tests/shell/shell/again_two_value.toml
@@ -0,0 +1 @@
key.subkey = "another value"
8 changes: 8 additions & 0 deletions tests/shell/shell/again_two_value.xerces
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<script>root

<key>
<subkey>another value</subkey>
</key>

</script>
1 change: 1 addition & 0 deletions tests/shell/shell/one_value.dini
@@ -0,0 +1 @@
= root
1 change: 1 addition & 0 deletions tests/shell/shell/one_value.kconfig
@@ -0,0 +1 @@
script=root
Binary file modified tests/shell/shell/one_value.quickdump
Binary file not shown.
Empty file.
2 changes: 2 additions & 0 deletions tests/shell/shell/one_value.xerces
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<script>root</script>
4 changes: 1 addition & 3 deletions tests/shell/shell/one_value.yajl
@@ -1,3 +1 @@
{

}
"root"
3 changes: 3 additions & 0 deletions tests/shell/shell/three_value.dini
@@ -0,0 +1,3 @@
= root
key=value
key/subkey=another value
4 changes: 2 additions & 2 deletions tests/shell/shell/three_value.ini
@@ -1,3 +1,3 @@
= root
key = value
key/subkey = another value
key=value
key/subkey=another value
5 changes: 5 additions & 0 deletions tests/shell/shell/three_value.kconfig
@@ -0,0 +1,5 @@
script=root
key=value

[key]
subkey=another value
Binary file modified tests/shell/shell/three_value.quickdump
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/shell/shell/three_value.toml
@@ -0,0 +1,2 @@
key = "value"
key.subkey = "another value"
8 changes: 8 additions & 0 deletions tests/shell/shell/three_value.xerces
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<script>root

<key>value
<subkey>another value</subkey>
</key>

</script>
2 changes: 2 additions & 0 deletions tests/shell/shell/two_value.dini
@@ -0,0 +1,2 @@
= root
key=value
2 changes: 1 addition & 1 deletion tests/shell/shell/two_value.ini
@@ -1,2 +1,2 @@
= root
key = value
key=value
2 changes: 2 additions & 0 deletions tests/shell/shell/two_value.kconfig
@@ -0,0 +1,2 @@
script=root
key=value
Binary file modified tests/shell/shell/two_value.quickdump
Binary file not shown.
1 change: 1 addition & 0 deletions tests/shell/shell/two_value.toml
@@ -0,0 +1 @@
key = "value"
6 changes: 6 additions & 0 deletions tests/shell/shell/two_value.xerces
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<script>root

<key>value</key>

</script>