From 61f83856fb1365e8c9df525dbcc5b74708ddbfe4 Mon Sep 17 00:00:00 2001 From: Leonard Crestez Date: Mon, 1 Feb 2010 21:28:17 +0200 Subject: [PATCH] (testsuite) Fix chown test "crash" if root user/group is N/A (Alioth: 312306). --- test/lib/completions/chown.exp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/lib/completions/chown.exp b/test/lib/completions/chown.exp index cc56149b..480f6743 100644 --- a/test/lib/completions/chown.exp +++ b/test/lib/completions/chown.exp @@ -24,10 +24,14 @@ set partgroup "roo" # Skip tests if root:root not available or if roo:roo matches multiple # users/groups -if {[exec bash -c "compgen -A user $partuser" | wc -l] > 1 || - [exec bash -c "compgen -A user $fulluser" | wc -l] != 1 || - [exec bash -c "compgen -A group $partgroup" | wc -l] > 1 || - [exec bash -c "compgen -A group $fullgroup" | wc -l] != 1} { +# +# 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"