Use find_unique_completion_pair in chown test
This commit is contained in:
parent
2ad9001556
commit
ce624f7983
@ -14,26 +14,21 @@ assert_complete_any "chown "
|
|||||||
sync_after_int
|
sync_after_int
|
||||||
|
|
||||||
|
|
||||||
# All the tests use the root:root user and group. They're assumed to exist.
|
# Find user/group suitable for testing.
|
||||||
set fulluser "root"
|
set failed_find_unique_completion 0
|
||||||
set fullgroup "root"
|
foreach ug {user group} {
|
||||||
|
# compgen -A is used because it's a bash builtin and available everywhere.
|
||||||
|
# The || true part prevents exec from throwing an exception if nothing is
|
||||||
|
# found (very very unlikely).
|
||||||
|
set list [split [exec bash -c "compgen -A $ug || true"] "\n"]
|
||||||
|
if {![find_unique_completion_pair $list part$ug full$ug]} {
|
||||||
|
untested "Not running complex chown tests; no suitable test $ug found."
|
||||||
|
set failed_find_unique_completion 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Partial username is assumed to be unambiguous.
|
# These tests require an unique completion.
|
||||||
set partuser "roo"
|
if {!$failed_find_unique_completion} {
|
||||||
set partgroup "roo"
|
|
||||||
|
|
||||||
# Skip tests if root:root not available or if roo:roo matches multiple
|
|
||||||
# users/groups
|
|
||||||
#
|
|
||||||
# compgen -A is used because it's a bash builtin and available everywhere.
|
|
||||||
# The || true part prevents exec from throwing an exception if nothing is
|
|
||||||
# found.
|
|
||||||
if {[exec bash -c "compgen -A user $partuser || true" | wc -l] > 1 ||
|
|
||||||
[exec bash -c "compgen -A user $fulluser || true" | wc -l] != 1 ||
|
|
||||||
[exec bash -c "compgen -A group $partgroup || true" | wc -l] > 1 ||
|
|
||||||
[exec bash -c "compgen -A group $fullgroup || true" | wc -l] != 1} {
|
|
||||||
untested "Not running complex chown tests."
|
|
||||||
} else {
|
|
||||||
assert_complete $fulluser "chown $partuser"
|
assert_complete $fulluser "chown $partuser"
|
||||||
sync_after_int
|
sync_after_int
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user