Re: [LTP] fix mail_tests for systems without mail installed

Geert Uytterhoeven
2009-08-27T12:39:53Z

On Thu, 13 Aug 2009, Mike Frysinger wrote:
> On Wednesday 12 August 2009 17:14:09 Paul Larson wrote:
> > +`which mail`
> > +if [ $? != 0 ]; then
>
> this results in pretty ugly output, and the return value/output of `which` is
> not portable. use the type builtin instead.
>
> > + MAIL_NOT_INSTALLED=1
>
> you should make sure this is always set/unset at the top of the script so
> parent environment poisoning wont screw things up.
>
> > +if [ -z $MAIL_NOT_INSTALLED ]; then
>
> tests must always be quoted:
> [ -z "$foo" ]

Worse, as $MAIL_NOT_INSTALLED is always "0" or "1", -z always return false...

From 8035091c4232e8d6c7b3a75d612bc82c1ad84365 Mon Sep 17 00:00:00 2001
From: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Date: Thu, 27 Aug 2009 14:11:58 +0200
Subject: [PATCH] Fix mail_tests for systems with mail installed

`-z' tests for a string length of zero, not for a zero value, causing the
test always to return false.
Initialize $MAIL_NOT_INSTALLED to an empty string instead of a numerical
zero to fix this.

Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
---
testcases/commands/mail/mail_tests.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/testcases/commands/mail/mail_tests.sh b/testcases/commands/mail/mail_tests.sh
index 0959a0c..45bac93 100755
--- a/testcases/commands/mail/mail_tests.sh
+++ b/testcases/commands/mail/mail_tests.sh
@@ -59,7 +59,7 @@ RC=0
export TCID=SETUP
export TST_COUNT=1

-MAIL_NOT_INSTALLED=0
+MAIL_NOT_INSTALLED=
`type mail &> /dev/null`
if [ $? != 0 ]; then
MAIL_NOT_INSTALLED=1
--
1.6.2.4

With kind regards,

Geert Uytterhoeven
Software Architect
Techsoft Centre

Technology and Software Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone: +32 (0)2 700 8453
Fax: +32 (0)2 700 8622
E-mail: Geert.Uytterhoeven@sonycom.com
Internet: http://www.sony-europe.com/

A division of Sony Europe (Belgium) N.V.
VAT BE 0413.825.160 · RPR Brussels
Fortis · BIC GEBABEBB · IBAN BE41293037680010