diff options
author | Emmanuel Dreyfus <manu@netbsd.org> | 2014-11-26 09:59:25 +0100 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2014-11-26 04:18:47 -0800 |
commit | 51eaed7fb243a989fdf96461ba2d9acfc07977f8 (patch) | |
tree | e371a00cbfe45b74d236472b9896a8adc4f5bb57 /tests/bugs | |
parent | c147c36a70505ff239cef48030422840abd3fbcd (diff) |
Regression test portability: batch of bugs (volume 2)
Fix various regression test portability in tests/bugs.
bug-861542.t
- Avoid syntax specific to GNU sed.
bug-860663.t
- Command argument length is system dependent, and specifying 1000 file
path may overflow it. Use a C program to do the job in a portable and
efficient way.
- Add a test that we created the specified amount of files.
bug-858242.c, bug-808400-fcntl.c, bug-808400-flock.c
- fstat64() is Linux-specific. Define it as fstat for other systems.
bug-823081.t
- Use portable tail -n instead of tail --lines
In many tests:
- Do not assume python interpreter name. Use $PYTHON as defined
in env.rc by configure.
utils/libcxattr.py
- If python version is 2.6 or higher, use a portable mechanism to
recover errno. The original version is retained for python version
2.5 and earlier but it only works on Linux.
BUG: 1129939
Change-Id: If2fea1ffec5cc6ab2de426fb200e884450afe61b
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/9097
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'tests/bugs')
-rw-r--r-- | tests/bugs/bug-1111490.t | 6 | ||||
-rw-r--r-- | tests/bugs/bug-808400-fcntl.c | 4 | ||||
-rw-r--r-- | tests/bugs/bug-808400-flock.c | 4 | ||||
-rwxr-xr-x | tests/bugs/bug-823081.t | 8 | ||||
-rwxr-xr-x | tests/bugs/bug-853258.t | 2 | ||||
-rwxr-xr-x | tests/bugs/bug-857330/normal.t | 3 | ||||
-rwxr-xr-x | tests/bugs/bug-857330/xml.t | 3 | ||||
-rw-r--r-- | tests/bugs/bug-858242.c | 4 | ||||
-rw-r--r-- | tests/bugs/bug-860663.c | 42 | ||||
-rw-r--r-- | tests/bugs/bug-860663.t | 8 | ||||
-rwxr-xr-x | tests/bugs/bug-861542.t | 3 | ||||
-rwxr-xr-x | tests/bugs/bug-902610.t | 2 |
12 files changed, 75 insertions, 14 deletions
diff --git a/tests/bugs/bug-1111490.t b/tests/bugs/bug-1111490.t index 289ac70b4a1..6760bbe952b 100644 --- a/tests/bugs/bug-1111490.t +++ b/tests/bugs/bug-1111490.t @@ -16,7 +16,8 @@ TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0 --aux-gfid-mount # create file with specific gfid uuid=`uuidgen` -EXPECT "File creation OK" gfid-access.py $M0 ROOT file0 $uuid file +EXPECT "File creation OK" $PYTHON $(dirname $0)/../utils/gfid-access.py \ + $M0 ROOT file0 $uuid file # check gfid EXPECT "$uuid" getfattr --only-values -n glusterfs.gfid.string $M0/file0 @@ -27,6 +28,7 @@ TEST umount $M0 TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0 --aux-gfid-mount # touch the file again (gfid-access.py handles errno) -EXPECT "File creation OK" gfid-access.py $M0 ROOT file0 $uuid file +EXPECT "File creation OK" $PYTHON $(dirname $0)/../utils/gfid-access.py \ + $M0 ROOT file0 $uuid file cleanup; diff --git a/tests/bugs/bug-808400-fcntl.c b/tests/bugs/bug-808400-fcntl.c index 4deef34a532..87a83f317b8 100644 --- a/tests/bugs/bug-808400-fcntl.c +++ b/tests/bugs/bug-808400-fcntl.c @@ -7,6 +7,10 @@ #include <fcntl.h> #include <sys/wait.h> +#ifndef linux +#define fstat64(fd, st) fstat(fd, st) +#endif + int run_child (char *filename) { diff --git a/tests/bugs/bug-808400-flock.c b/tests/bugs/bug-808400-flock.c index 4770c81dc69..bd2ce8cfb01 100644 --- a/tests/bugs/bug-808400-flock.c +++ b/tests/bugs/bug-808400-flock.c @@ -7,6 +7,10 @@ #include <fcntl.h> #include <sys/wait.h> +#ifndef linux +#define fstat64(fd, st) fstat(fd, st) +#endif + int run_child (char *filename) { diff --git a/tests/bugs/bug-823081.t b/tests/bugs/bug-823081.t index 15b38517945..e8630521b64 100755 --- a/tests/bugs/bug-823081.t +++ b/tests/bugs/bug-823081.t @@ -22,20 +22,20 @@ function set_tail () set_tail $V0; TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}; -tail=`tail --lines=1 $logdir/$cmd_log_history | cut -d " " -f 5-` +tail=`tail -n 1 $logdir/$cmd_log_history | cut -d " " -f 5-` TEST [[ \"$tail\" == \"$tail_success\" ]] TEST ! $CLI volume create $V0 $H0:$B0/${V0}{1,2}; -tail=`tail --lines=1 $logdir/$cmd_log_history | cut -d " " -f 5-` +tail=`tail -n 1 $logdir/$cmd_log_history | cut -d " " -f 5-` TEST [[ \"$tail\" == \"$tail_failure\" ]] set_tail $V1; TEST gluster volume create $V1 $H0:$B0/${V1}{1,2} force; -tail=`tail --lines=1 $logdir/$cmd_log_history | cut -d " " -f 5-` +tail=`tail -n 1 $logdir/$cmd_log_history | cut -d " " -f 5-` TEST [[ \"$tail\" == \"$tail_success_force\" ]] TEST ! gluster volume create $V1 $H0:$B0/${V1}{1,2} force; -tail=`tail --lines=1 $logdir/$cmd_log_history | cut -d " " -f 5-` +tail=`tail -n 1 $logdir/$cmd_log_history | cut -d " " -f 5-` TEST [[ \"$tail\" == \"$tail_failure_force\" ]] cleanup; diff --git a/tests/bugs/bug-853258.t b/tests/bugs/bug-853258.t index 3d4cfba00a2..21e48bd1a8f 100755 --- a/tests/bugs/bug-853258.t +++ b/tests/bugs/bug-853258.t @@ -38,7 +38,7 @@ for i in $(seq 0 3); do xattrs="$xattrs $(dht_get_layout $B0/${V0}$i)" done -overlap=$(python2 $(dirname $0)/overlap.py $xattrs) +overlap=$( $PYTHON $(dirname $0)/overlap.py $xattrs) # 2863311531 = 0xaaaaaaab = 2/3 overlap TEST [ "$overlap" -ge 2863311531 ] diff --git a/tests/bugs/bug-857330/normal.t b/tests/bugs/bug-857330/normal.t index b7409078775..9e348c53449 100755 --- a/tests/bugs/bug-857330/normal.t +++ b/tests/bugs/bug-857330/normal.t @@ -14,7 +14,8 @@ TEST $CLI volume start $V0; TEST glusterfs -s $H0 --volfile-id=$V0 $M0; -TEST create-files.py --multi -b 10 -d 10 -n 10 $M0; +TEST $PYTHON $(dirname $0)/../../utils/create-files.py \ + --multi -b 10 -d 10 -n 10 $M0; EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 diff --git a/tests/bugs/bug-857330/xml.t b/tests/bugs/bug-857330/xml.t index bacca453dbe..475c35b8faa 100755 --- a/tests/bugs/bug-857330/xml.t +++ b/tests/bugs/bug-857330/xml.t @@ -15,7 +15,8 @@ TEST $CLI volume start $V0; TEST glusterfs -s $H0 --volfile-id=$V0 $M0; -TEST create-files.py --multi -b 10 -d 10 -n 10 $M0; +TEST $PYTHON $(dirname $0)/../../utils/create-files.py \ + --multi -b 10 -d 10 -n 10 $M0; EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 diff --git a/tests/bugs/bug-858242.c b/tests/bugs/bug-858242.c index 00a3a2d5f7d..ecdda2a5d23 100644 --- a/tests/bugs/bug-858242.c +++ b/tests/bugs/bug-858242.c @@ -7,6 +7,10 @@ #include <stdlib.h> #include <unistd.h> +#ifndef linux +#define fstat64(fd, st) fstat(fd, st) +#endif + int main (int argc, char *argv[]) { diff --git a/tests/bugs/bug-860663.c b/tests/bugs/bug-860663.c new file mode 100644 index 00000000000..6f6d0696e64 --- /dev/null +++ b/tests/bugs/bug-860663.c @@ -0,0 +1,42 @@ +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <fcntl.h> +#include <string.h> +#include <err.h> +#include <sys/param.h> + +int +main(argc, argv) + int argc; + char **argv; +{ + char *basepath; + char path[MAXPATHLEN + 1]; + unsigned int count; + int i, fd; + + if (argc != 3) + errx(1, "usage: %s path count", argv[0]); + + basepath = argv[1]; + count = atoi(argv[2]); + + if (count > 999999) + errx(1, "count too big"); + + if (strlen(basepath) > MAXPATHLEN - 6) + errx(1, "path too long"); + + for (i = 0; i < count; i++) { + (void)sprintf(path, "%s%06d", basepath, i); + + if ((fd = open(path, O_CREAT|O_RDWR, 0644)) == -1) + err(1, "create %s failed", path); + + if (close(fd) != 0) + warn("close %s failed", path); + } + + return 0; +} diff --git a/tests/bugs/bug-860663.t b/tests/bugs/bug-860663.t index a4b3d71fb78..555a63436ba 100644 --- a/tests/bugs/bug-860663.t +++ b/tests/bugs/bug-860663.t @@ -17,6 +17,8 @@ function file_count() BRICK_COUNT=3 +build_tester $(dirname $0)/bug-860663.c + TEST glusterd TEST pidof glusterd @@ -26,9 +28,10 @@ TEST $CLI volume start $V0 ## Mount FUSE TEST glusterfs -s $H0 --volfile-id $V0 $M0; -TEST touch $M0/files{1..10000}; +TEST $(dirname $0)/bug-860663 $M0/files 10000 ORIG_FILE_COUNT=`ls -l $M0 | wc -l`; +TEST [ $ORIG_FILE_COUNT -ge 10000 ] # Kill a brick process kill -9 `cat $GLUSTERD_WORKDIR/vols/$V0/run/$H0-d-backends-${V0}1.pid`; @@ -37,7 +40,7 @@ TEST $CLI volume rebalance $V0 fix-layout start sleep 30; -TEST ! touch $M0/files{1..10000}; +TEST ! $(dirname $0)/bug-860663 $M0/files 10000 TEST $CLI volume start $V0 force @@ -47,4 +50,5 @@ NEW_FILE_COUNT=`ls -l $M0 | wc -l`; EXPECT "0" file_count $ORIG_FILE_COUNT $NEW_FILE_COUNT +rm -f $(dirname $0)/bug-860663 cleanup; diff --git a/tests/bugs/bug-861542.t b/tests/bugs/bug-861542.t index f4fd4e52a58..70fd12239e2 100755 --- a/tests/bugs/bug-861542.t +++ b/tests/bugs/bug-861542.t @@ -30,8 +30,7 @@ function xml_port_field() local opt=$2; $CLI --xml volume status $vol $opt | tr -d '\n' |\ #Find the first occurrence of the string between <port> and </port> - sed -r 's/<port>/&\n/;s/<\/port>/\n&/;s/^.*\n(.*)\n.*$/\1/'| \ - grep -v xml | tr -d '\n'; + sed -rn 's/<port>/&###/;s/<\/port>/###&/;s/^.*###(.*)###.*$/\1/p' } TEST $CLI volume status $V0; diff --git a/tests/bugs/bug-902610.t b/tests/bugs/bug-902610.t index 9b824b1b558..8b1e91fb9cb 100755 --- a/tests/bugs/bug-902610.t +++ b/tests/bugs/bug-902610.t @@ -27,7 +27,7 @@ function get_layout() fi # Figure out where the join point is. - target=$(python -c "print '%08x' % (0x$layout1_e + 1)") + target=$( $PYTHON -c "print '%08x' % (0x$layout1_e + 1)") #echo "target for layout2 = $target" > /dev/tty # The second layout should cover everything that the first doesn't. |