Re: Bug in EXPECT family of macros in test framework

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 27, 2015 at 12:35:35PM +0100, Xavier Hernandez wrote:
> Hi,
> 
> I've just discovered that EXPECT, EXPECT_WITHIN and others have a bug that
> can hide some failures.
> 
> The problem is that the test is made using a regular expression comparison.
> For example, EXPECT checks this:
> 
>     if ! [[ "$a" =~ $e ]]; then
> 
> There are some tests that use a regular expression as the first argument to
> EXPECT, however there are many other tests that simply use a number or a
> text.
> 
> This can cause problems. For example if the test is:
> 
>     EXPECT "0" <test>
> 
> And the test returns 10, the regular expression "0" *will* match with "10",
> so the test will be considered successful when it shouldn't.
> 
> It will also report success for test cases that check for an empty result:
> 
>     EXPECT "" <test>
> 
> This will always succeed, even if the test returns something.
> 
> What would be the best approach to solve this ?

Oh, yuck!

I think we should test like this, untested: [[ "$a" =~ "^$e\$" ]]

It might break some regular expressions, the expressions are now forced
to be very strict and should match the whole line.

Thoughts?
Niels

Attachment: pgpPlYUjtqS8D.pgp
Description: PGP signature

_______________________________________________
Gluster-devel mailing list
Gluster-devel@xxxxxxxxxxx
http://www.gluster.org/mailman/listinfo/gluster-devel

[Index of Archives]     [Gluster Users]     [Ceph Users]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux