]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: add optlist tests
authorKarel Zak <kzak@redhat.com>
Mon, 22 May 2023 13:40:38 +0000 (15:40 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 22 May 2023 13:40:38 +0000 (15:40 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
31 files changed:
tests/commands.sh
tests/expected/libmount/optlist-append [new file with mode: 0644]
tests/expected/libmount/optlist-append-empty-value [new file with mode: 0644]
tests/expected/libmount/optlist-append-value [new file with mode: 0644]
tests/expected/libmount/optlist-get [new file with mode: 0644]
tests/expected/libmount/optlist-get-flg-linux [new file with mode: 0644]
tests/expected/libmount/optlist-get-flg-user [new file with mode: 0644]
tests/expected/libmount/optlist-get-str [new file with mode: 0644]
tests/expected/libmount/optlist-get-str-linux [new file with mode: 0644]
tests/expected/libmount/optlist-get-str-user [new file with mode: 0644]
tests/expected/libmount/optlist-get-value [new file with mode: 0644]
tests/expected/libmount/optlist-prepend [new file with mode: 0644]
tests/expected/libmount/optlist-prepend-empty-value [new file with mode: 0644]
tests/expected/libmount/optlist-prepend-list [new file with mode: 0644]
tests/expected/libmount/optlist-prepend-value [new file with mode: 0644]
tests/expected/libmount/optlist-remove [new file with mode: 0644]
tests/expected/libmount/optlist-remove-empty-value [new file with mode: 0644]
tests/expected/libmount/optlist-remove-quoted [new file with mode: 0644]
tests/expected/libmount/optlist-remove-value [new file with mode: 0644]
tests/expected/libmount/optlist-set [new file with mode: 0644]
tests/expected/libmount/optlist-set-empty [new file with mode: 0644]
tests/expected/libmount/optlist-set-large [new file with mode: 0644]
tests/expected/libmount/optlist-set-new [new file with mode: 0644]
tests/expected/libmount/optlist-set-new-empty [new file with mode: 0644]
tests/expected/libmount/optlist-set-new-end [new file with mode: 0644]
tests/expected/libmount/optlist-set-new-end-empty [new file with mode: 0644]
tests/expected/libmount/optlist-set-remove [new file with mode: 0644]
tests/expected/libmount/optlist-set-small [new file with mode: 0644]
tests/expected/libmount/optstr-prepend-list [new file with mode: 0644]
tests/ts/libmount/optlist [new file with mode: 0755]
tests/ts/libmount/optstr

index c9a5cd1294b0d61e52b79c755aa531508270867e..38b425405b416c50bcc58c610bac95e49b9e0460 100644 (file)
@@ -15,6 +15,7 @@ TS_HELPER_LIBFDISK_MKPART_FULLSPEC="${ts_helpersdir}sample-fdisk-mkpart-fullspec
 TS_HELPER_LIBFDISK_SCRIPT_FUZZ="${ts_helpersdir}test_fdisk_script_fuzz"
 TS_HELPER_LIBMOUNT_LOCK="${ts_helpersdir}test_mount_lock"
 TS_HELPER_LIBMOUNT_OPTSTR="${ts_helpersdir}test_mount_optstr"
+TS_HELPER_LIBMOUNT_OPTLIST="${ts_helpersdir}test_mount_optlist"
 TS_HELPER_LIBMOUNT_TABDIFF="${ts_helpersdir}test_mount_tab_diff"
 TS_HELPER_LIBMOUNT_TAB="${ts_helpersdir}test_mount_tab"
 TS_HELPER_LIBMOUNT_UPDATE="${ts_helpersdir}test_mount_tab_update"
diff --git a/tests/expected/libmount/optlist-append b/tests/expected/libmount/optlist-append
new file mode 100644 (file)
index 0000000..d6951ed
--- /dev/null
@@ -0,0 +1,5 @@
+#01 [         unknown         ] name:'aaa',    value:'(null)'
+#02 [         unknown         ] name:'bbb',    value:'BBB'
+#03 [         unknown         ] name:'context',        value:'foo,bar,gogo'
+#04 [         unknown         ] name:'ccc',    value:'(null)'
+#05 [         unknown         ] name:'ddd',    value:'(null)'
diff --git a/tests/expected/libmount/optlist-append-empty-value b/tests/expected/libmount/optlist-append-empty-value
new file mode 100644 (file)
index 0000000..1ed1028
--- /dev/null
@@ -0,0 +1,4 @@
+#01 [         unknown         ] name:'aaa',    value:'(null)'
+#02 [         unknown         ] name:'bbb',    value:'BBB'
+#03 [         unknown         ] name:'ccc',    value:'(null)'
+#04 [         unknown         ] name:'ddd',    value:'(null)'
diff --git a/tests/expected/libmount/optlist-append-value b/tests/expected/libmount/optlist-append-value
new file mode 100644 (file)
index 0000000..24f9115
--- /dev/null
@@ -0,0 +1,4 @@
+#01 [         unknown         ] name:'aaa',    value:'(null)'
+#02 [         unknown         ] name:'bbb',    value:'BBB'
+#03 [         unknown         ] name:'ccc',    value:'(null)'
+#04 [         unknown         ] name:'ddd',    value:'DDD'
diff --git a/tests/expected/libmount/optlist-get b/tests/expected/libmount/optlist-get
new file mode 100644 (file)
index 0000000..217a6f7
--- /dev/null
@@ -0,0 +1,4 @@
+Default: rw,aaa,bbb=BBB,ccc
+All:     rw,aaa,bbb=BBB,ccc
+Unknown: aaa,bbb=BBB,ccc
+Helpers: rw,aaa,bbb=BBB,ccc
diff --git a/tests/expected/libmount/optlist-get-flg-linux b/tests/expected/libmount/optlist-get-flg-linux
new file mode 100644 (file)
index 0000000..f57108b
--- /dev/null
@@ -0,0 +1 @@
+0x00000008
diff --git a/tests/expected/libmount/optlist-get-flg-user b/tests/expected/libmount/optlist-get-flg-user
new file mode 100644 (file)
index 0000000..83ab8b2
--- /dev/null
@@ -0,0 +1 @@
+0x0000000c
diff --git a/tests/expected/libmount/optlist-get-str b/tests/expected/libmount/optlist-get-str
new file mode 100644 (file)
index 0000000..f7f3a13
--- /dev/null
@@ -0,0 +1,4 @@
+Default: rw,aaa,bbb=BBB,ccc,defaults
+All:     rw,aaa,bbb=BBB,ccc,defaults
+Unknown: aaa,bbb=BBB,ccc
+Helpers: rw,aaa,bbb=BBB,ccc
diff --git a/tests/expected/libmount/optlist-get-str-linux b/tests/expected/libmount/optlist-get-str-linux
new file mode 100644 (file)
index 0000000..abe63b4
--- /dev/null
@@ -0,0 +1,5 @@
+Default: rw,noexec [0x00000008] (in linux map)
+Default: rw,noexec,noauto,user,defaults
+All:     rw,noexec,noauto,user,defaults
+Unknown: (null)
+Helpers: rw,noexec,user
diff --git a/tests/expected/libmount/optlist-get-str-user b/tests/expected/libmount/optlist-get-str-user
new file mode 100644 (file)
index 0000000..d047003
--- /dev/null
@@ -0,0 +1,5 @@
+Default: noauto,user,defaults [0x0000000c] (in user map)
+Default: rw,noexec,noauto,user,defaults
+All:     rw,noexec,noauto,user,defaults
+Unknown: (null)
+Helpers: rw,noexec,user
diff --git a/tests/expected/libmount/optlist-get-value b/tests/expected/libmount/optlist-get-value
new file mode 100644 (file)
index 0000000..217a6f7
--- /dev/null
@@ -0,0 +1,4 @@
+Default: rw,aaa,bbb=BBB,ccc
+All:     rw,aaa,bbb=BBB,ccc
+Unknown: aaa,bbb=BBB,ccc
+Helpers: rw,aaa,bbb=BBB,ccc
diff --git a/tests/expected/libmount/optlist-prepend b/tests/expected/libmount/optlist-prepend
new file mode 100644 (file)
index 0000000..24c64c6
--- /dev/null
@@ -0,0 +1,4 @@
+#01 [         unknown         ] name:'ddd',    value:'(null)'
+#02 [         unknown         ] name:'aaa',    value:'(null)'
+#03 [         unknown         ] name:'bbb',    value:'BBB'
+#04 [         unknown         ] name:'ccc',    value:'(null)'
diff --git a/tests/expected/libmount/optlist-prepend-empty-value b/tests/expected/libmount/optlist-prepend-empty-value
new file mode 100644 (file)
index 0000000..24c64c6
--- /dev/null
@@ -0,0 +1,4 @@
+#01 [         unknown         ] name:'ddd',    value:'(null)'
+#02 [         unknown         ] name:'aaa',    value:'(null)'
+#03 [         unknown         ] name:'bbb',    value:'BBB'
+#04 [         unknown         ] name:'ccc',    value:'(null)'
diff --git a/tests/expected/libmount/optlist-prepend-list b/tests/expected/libmount/optlist-prepend-list
new file mode 100644 (file)
index 0000000..9e5005f
--- /dev/null
@@ -0,0 +1,6 @@
+#01 [         unknown         ] name:'ddd',    value:'(null)'
+#02 [         unknown         ] name:'eee',    value:'EEE'
+#03 [         unknown         ] name:'fff',    value:'(null)'
+#04 [         unknown         ] name:'aaa',    value:'(null)'
+#05 [         unknown         ] name:'bbb',    value:'BBB'
+#06 [         unknown         ] name:'ccc',    value:'(null)'
diff --git a/tests/expected/libmount/optlist-prepend-value b/tests/expected/libmount/optlist-prepend-value
new file mode 100644 (file)
index 0000000..eed5de5
--- /dev/null
@@ -0,0 +1,4 @@
+#01 [         unknown         ] name:'ddd',    value:'DDD'
+#02 [         unknown         ] name:'aaa',    value:'(null)'
+#03 [         unknown         ] name:'bbb',    value:'BBB'
+#04 [         unknown         ] name:'ccc',    value:'(null)'
diff --git a/tests/expected/libmount/optlist-remove b/tests/expected/libmount/optlist-remove
new file mode 100644 (file)
index 0000000..08f3898
--- /dev/null
@@ -0,0 +1,12 @@
+
+Usage:
+       test_mount_optlist <test> [testoptions]
+Tests:
+       --append-str    <list> <str> [linux|user]  append to the list
+       --prepend-str   <list> <str> [linux|user]  prepend to the list
+       --set-str       <list> <str> [linux|user]  set to the list
+       --append-flg    <list> <flg>  linux|user   append to the list
+       --set-flg       <list> <flg>  linux|user   set to the list
+       --get-str       <list> [linux|user]        all options in string
+       --get-flg       <list>  linux|user         all options by flags
+
diff --git a/tests/expected/libmount/optlist-remove-empty-value b/tests/expected/libmount/optlist-remove-empty-value
new file mode 100644 (file)
index 0000000..08f3898
--- /dev/null
@@ -0,0 +1,12 @@
+
+Usage:
+       test_mount_optlist <test> [testoptions]
+Tests:
+       --append-str    <list> <str> [linux|user]  append to the list
+       --prepend-str   <list> <str> [linux|user]  prepend to the list
+       --set-str       <list> <str> [linux|user]  set to the list
+       --append-flg    <list> <flg>  linux|user   append to the list
+       --set-flg       <list> <flg>  linux|user   set to the list
+       --get-str       <list> [linux|user]        all options in string
+       --get-flg       <list>  linux|user         all options by flags
+
diff --git a/tests/expected/libmount/optlist-remove-quoted b/tests/expected/libmount/optlist-remove-quoted
new file mode 100644 (file)
index 0000000..08f3898
--- /dev/null
@@ -0,0 +1,12 @@
+
+Usage:
+       test_mount_optlist <test> [testoptions]
+Tests:
+       --append-str    <list> <str> [linux|user]  append to the list
+       --prepend-str   <list> <str> [linux|user]  prepend to the list
+       --set-str       <list> <str> [linux|user]  set to the list
+       --append-flg    <list> <flg>  linux|user   append to the list
+       --set-flg       <list> <flg>  linux|user   set to the list
+       --get-str       <list> [linux|user]        all options in string
+       --get-flg       <list>  linux|user         all options by flags
+
diff --git a/tests/expected/libmount/optlist-remove-value b/tests/expected/libmount/optlist-remove-value
new file mode 100644 (file)
index 0000000..08f3898
--- /dev/null
@@ -0,0 +1,12 @@
+
+Usage:
+       test_mount_optlist <test> [testoptions]
+Tests:
+       --append-str    <list> <str> [linux|user]  append to the list
+       --prepend-str   <list> <str> [linux|user]  prepend to the list
+       --set-str       <list> <str> [linux|user]  set to the list
+       --append-flg    <list> <flg>  linux|user   append to the list
+       --set-flg       <list> <flg>  linux|user   set to the list
+       --get-str       <list> [linux|user]        all options in string
+       --get-flg       <list>  linux|user         all options by flags
+
diff --git a/tests/expected/libmount/optlist-set b/tests/expected/libmount/optlist-set
new file mode 100644 (file)
index 0000000..a9f1e66
--- /dev/null
@@ -0,0 +1,4 @@
+#01 [         unknown         ] name:'new',    value:'(null)'
+#02 [         unknown         ] name:'data',   value:'(null)'
+#03 [         unknown         ] name:'for',    value:'(null)'
+#04 [         unknown         ] name:'list',   value:'(null)'
diff --git a/tests/expected/libmount/optlist-set-empty b/tests/expected/libmount/optlist-set-empty
new file mode 100644 (file)
index 0000000..02e1b58
--- /dev/null
@@ -0,0 +1 @@
+#01 [         unknown         ] name:'bbb',    value:'(null)'
diff --git a/tests/expected/libmount/optlist-set-large b/tests/expected/libmount/optlist-set-large
new file mode 100644 (file)
index 0000000..02e1b58
--- /dev/null
@@ -0,0 +1 @@
+#01 [         unknown         ] name:'bbb',    value:'(null)'
diff --git a/tests/expected/libmount/optlist-set-new b/tests/expected/libmount/optlist-set-new
new file mode 100644 (file)
index 0000000..c538cbe
--- /dev/null
@@ -0,0 +1 @@
+#01 [         unknown         ] name:'aaa',    value:'(null)'
diff --git a/tests/expected/libmount/optlist-set-new-empty b/tests/expected/libmount/optlist-set-new-empty
new file mode 100644 (file)
index 0000000..c538cbe
--- /dev/null
@@ -0,0 +1 @@
+#01 [         unknown         ] name:'aaa',    value:'(null)'
diff --git a/tests/expected/libmount/optlist-set-new-end b/tests/expected/libmount/optlist-set-new-end
new file mode 100644 (file)
index 0000000..12d6779
--- /dev/null
@@ -0,0 +1 @@
+#01 [         unknown         ] name:'ccc',    value:'(null)'
diff --git a/tests/expected/libmount/optlist-set-new-end-empty b/tests/expected/libmount/optlist-set-new-end-empty
new file mode 100644 (file)
index 0000000..12d6779
--- /dev/null
@@ -0,0 +1 @@
+#01 [         unknown         ] name:'ccc',    value:'(null)'
diff --git a/tests/expected/libmount/optlist-set-remove b/tests/expected/libmount/optlist-set-remove
new file mode 100644 (file)
index 0000000..02e1b58
--- /dev/null
@@ -0,0 +1 @@
+#01 [         unknown         ] name:'bbb',    value:'(null)'
diff --git a/tests/expected/libmount/optlist-set-small b/tests/expected/libmount/optlist-set-small
new file mode 100644 (file)
index 0000000..02e1b58
--- /dev/null
@@ -0,0 +1 @@
+#01 [         unknown         ] name:'bbb',    value:'(null)'
diff --git a/tests/expected/libmount/optstr-prepend-list b/tests/expected/libmount/optstr-prepend-list
new file mode 100644 (file)
index 0000000..9f289fd
--- /dev/null
@@ -0,0 +1 @@
+result: >ddd,eee=EEE,fff,aaa,bbb=BBB,ccc<
diff --git a/tests/ts/libmount/optlist b/tests/ts/libmount/optlist
new file mode 100755 (executable)
index 0000000..8499496
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+# Copyright (C) 2010 Karel Zak <kzak@redhat.com>
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="options string"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command $TS_HELPER_LIBMOUNT_OPTLIST
+
+TESTPROG="$TS_HELPER_LIBMOUNT_OPTLIST"
+
+ts_init_subtest "append"
+ts_run $TESTPROG --append-str "aaa,bbb=BBB,context=\"foo,bar,gogo\",ccc" "ddd" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "append-value"
+ts_run $TESTPROG --append-str "aaa,bbb=BBB,ccc" "ddd=DDD" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "append-empty-value"
+ts_run $TESTPROG --append-str "aaa,bbb=BBB,ccc" "ddd=" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "prepend"
+ts_run $TESTPROG --prepend-str "aaa,bbb=BBB,ccc" "ddd" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "prepend-list"
+ts_run $TESTPROG --prepend-str "aaa,bbb=BBB,ccc" "ddd,eee=EEE,fff" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "prepend-value"
+ts_run $TESTPROG --prepend-str "aaa,bbb=BBB,ccc" "ddd=DDD" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "prepend-empty-value"
+ts_run $TESTPROG --prepend-str "aaa,bbb=BBB,ccc" "ddd=" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "set"
+ts_run $TESTPROG --set-str "aaa,bbb=BBB,ccc" "new,data,for,list" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "get-str"
+ts_run $TESTPROG --get-str "aaa,bbb=BBB,ccc,defaults" &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "get-str-linux"
+ts_run $TESTPROG --get-str "noexec,noauto,user,defaults" linux &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "get-str-user"
+ts_run $TESTPROG --get-str "noexec,noauto,user,defaults" user &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "get-flg-linux"
+ts_run $TESTPROG --get-flg "noexec,noauto,user,defaults" linux &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "get-flg-user"
+ts_run $TESTPROG --get-flg "noexec,noauto,user,defaults" user &> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_finalize
index 26d9b73f4ab30eaab1df25816b10cfa0806ba6d8..979517e06090eddbadff5713cb1b9bae22a6f01d 100755 (executable)
@@ -8,9 +8,9 @@ TS_DESC="options string"
 . "$TS_TOPDIR"/functions.sh
 ts_init "$*"
 
-TESTPROG="$TS_HELPER_LIBMOUNT_OPTSTR"
+ts_check_test_command $TS_HELPER_LIBMOUNT_OPTSTR
 
-[ -x $TESTPROG ] || ts_skip "test not compiled"
+TESTPROG="$TS_HELPER_LIBMOUNT_OPTSTR"
 
 ts_init_subtest "append"
 ts_run $TESTPROG --append "aaa,bbb=BBB,context=\"foo,bar,gogo\",ccc" "ddd" &> $TS_OUTPUT
@@ -28,6 +28,10 @@ ts_init_subtest "prepend"
 ts_run $TESTPROG --prepend "aaa,bbb=BBB,ccc" "ddd" &> $TS_OUTPUT
 ts_finalize_subtest
 
+ts_init_subtest "prepend-list"
+ts_run $TESTPROG --prepend "aaa,bbb=BBB,ccc" "ddd,eee=EEE,fff" &> $TS_OUTPUT
+ts_finalize_subtest
+
 ts_init_subtest "prepend-value"
 ts_run $TESTPROG --prepend "aaa,bbb=BBB,ccc" "ddd" "DDD" &> $TS_OUTPUT
 ts_finalize_subtest