Bug #55225 Cluster unit test uses bashism in shell script
Submitted: 13 Jul 2010 17:10 Modified: 12 Aug 2010 6:52
Reporter: Joerg Bruehe Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S1 (Critical)
Version:mysql-5.1-telco-7.1 OS:Any
Assigned to: Jonas Oreland CPU Architecture:Any
Tags: 7.1.5, bash, shell

[13 Jul 2010 17:10] Joerg Bruehe
Description:
In the build of Cluster-7.1.5, we have total failures on some platforms,
I do not have a complete list yet.

On Solaris 10, x86_64, the relevant log lines are:

=====
2010-07-12 13:24:16  START run the unittest
cd unittest && /usr/local/bin/make-3.78.1 test
perl unit.pl run mytap mysys  ../storage/archive ../storage/blackhole ../storage/csv ../storage/federated ../storage/heap ../storage/innobase ../storage/myisammrg ../storage/myisam ../storage/ndb
Running tests: mytap mysys ../storage/archive ../storage/blackhole ../storage/csv ../storage/federated ../storage/heap ../storage/innobase ../storage/myisammrg ../storage/myisam ../storage/ndb
mytap/t/basic-t..................................................ok
        2/5 skipped: Sensa fragoli
mysys/bitmap-t...................................................ok
mysys/base64-t...................................................ok
mysys/my_atomic-t................................................ok
../storage/ndb/src/ndbjtie/jtie/test/jtie_unit_tests-t............./storage/ndb/src/ndbjtie/jtie/test/jtie_unit_tests-t: syntax error at line 34: `test_counter=$' unexpected
dubious
    Test returned status 2 (wstat 512, 0x200)
DIED. FAILED tests 1-3
    Failed 3/3 tests, 0.00% okay
../storage/ndb/src/ndbjtie/test/ndbjtie_unit_tests-t.............../storage/ndb/src/ndbjtie/test/ndbjtie_unit_tests-t: syntax error at line 34: `test_counter=$' unexpected
dubious
    Test returned status 2 (wstat 512, 0x200)
DIED. FAILED tests 1-6
    Failed 6/6 tests, 0.00% okay
../storage/ndb/src/ndbjtie/mysql/test/mysql_utils_unit_tests-t...ok
        1/1 skipped: test_mysql_utils test file missing
../storage/ndb/src/common/portlib/NdbDir-t.......................failed at line 409
FAILED--Further testing stopped: Signal 6 thrown
make-3.78.1: *** [test] Error 29
=====

Looking into the failing test file, I see:

  1 #!/bin/sh
  2 #
 .. ...
 31 run_test()
 32 {
 33     test_name=$1;
 34     test_counter=$(expr $test_counter + 1)
 35     script_name="test_$test_name.sh"
 36

Checking the shell binaries, it is obvious that "/bin/sh" is no bash:
> ls -ldi /usr/bin/bash /sbin/sh /bin/sh
        45 lrwxrwxrwx   1 root     root          13 Oct 18  2008 /bin/sh -> ../../sbin/sh
      1793 -r-xr-xr-x   1 root     root       82468 Oct 18  2006 /sbin/sh
     45327 -r-xr-xr-x   1 root     bin       611132 May  2  2007 /usr/bin/bash

So the bashism in line 34 must be expected to fail.

How to repeat:
Run the unittest on a machine whose shell is not bash.

Suggested fix:
Do not write bashisms in shell script.

In this case, replace
 34     test_counter=$(expr $test_counter + 1)
by
 34     test_counter=`expr $test_counter + 1`
[11 Aug 2010 9:09] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/115460

3731 Jonas Oreland	2010-08-11
      ndb - bug#55225 - fix bash-ism
[11 Aug 2010 9:09] Jonas Oreland
pushed into 7.1.6
[12 Aug 2010 6:52] Jon Stephens
Change in test code only. Nothing to document. Closed.