[OpenWrt-Devel] [PATCH 1/2] tests: add test cases for -P and -p options.
Yousong Zhou
yszhou4tech at gmail.com
Tue Mar 31 12:20:17 EDT 2015
---
test/references/options.delta.result | 5 +++++
test/tests.d/090_cli_options | 38 ++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
create mode 100644 test/references/options.delta.result
create mode 100644 test/tests.d/090_cli_options
diff --git a/test/references/options.delta.result b/test/references/options.delta.result
new file mode 100644
index 0000000..3119b6f
--- /dev/null
+++ b/test/references/options.delta.result
@@ -0,0 +1,5 @@
+
+config sectype 'sec0'
+ list li0 '1'
+ list li0 '0'
+
diff --git a/test/tests.d/090_cli_options b/test/tests.d/090_cli_options
new file mode 100644
index 0000000..52052a3
--- /dev/null
+++ b/test/tests.d/090_cli_options
@@ -0,0 +1,38 @@
+test_add_delta() {
+ local new_savedir="$TMP_DIR/new_savedir"
+ local config_delta="$CONFIG_DIR/delta"
+
+ # add normal changes
+ touch "$config_delta"
+ $UCI set delta.sec0=sectype
+ $UCI add_list delta.sec0.li0=0
+
+ # save new changes in "$new_savedir"
+ mkdir -p "$new_savedir"
+ touch "$new_savedir/delta"
+ $UCI -P "$new_savedir" set delta.sec0=sectype
+ $UCI -P "$new_savedir" add_list delta.sec0.li0=1
+
+ assertEquals "delta.sec0='sectype'
+delta.sec0.li0+='0'" "$($UCI changes)"
+
+ # check combined changes. order matters here.
+ assertEquals "delta.sec0='sectype'
+delta.sec0.li0+='1'
+delta.sec0='sectype'
+delta.sec0.li0+='0'" "$($UCI -P "$new_savedir" changes)"
+
+ # check CLI_FLAG_NOCOMMIT with -P option.
+ $UCI -P "$new_savedir" commit
+ assertTrue "$?"
+ assertEquals "" "$(cat $config_delta)"
+
+ # check normal commit.
+ $UCI -p "$new_savedir" commit
+ assertTrue "$?"
+ assertSameFile "$REF_DIR/options.delta.result" "$config_delta"
+
+ rm -rf "$new_savedir"
+ rm -f "$config_delta"
+}
+
--
1.7.10.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list