From: <ro...@us...> - 2003-11-26 19:30:32
|
Update of /cvsroot/ltp/ltp/testcases/commands/ade/file In directory sc8-pr-cvs1:/tmp/cvs-serv9734 Modified Files: file_test.sh Log Message: Applied patch from Glen Foster: =============================== Problem #1: in "testcases/bin/file_test.sh", line 44: ----------- if [ -z $LTPTMP && -z $TMPBASE ] ... throws line causes the shell to throw the error message: $LTPROOT/testcases/bin/file_test.sh: [: missing ']' ... I don't know if this is a coding error, or if it's a shell portability issue. If the line is changed to" if [ -z $LTPTMP ] && [ -z $TMPBASE ] ... things run fine. Problem #2: in "testcases/bin/file_test.sh", line 261: ----------- cc -o /tmp/cprog /tmp/cprog.c &> /dev/null ... this compiles /tmp/cprog.c, but the code in lines 251-259 create the file "$LTPTMP/cprog.c". If problem #1 is not fixed, this logic fails. If problem #1 (above) is fixed, this does pass but it's not using the environment variable -- coding style. cc -o $LTPTMP/cprog $LTPTMP/cprog.c &> /dev/null ... works (whether problem #1 above is fixed or not) and correctly uses the environment variable constructed Problem #3: in "testcases/bin/file_test.sh", line 267: ----------- grep "ELF 32-bit LSB executable, Intel 80386" $LTPTMP/file.out &> /dev/null ... this test-case is wired for x86 (32-bit intel) -- if you compile the test program on ia64, file(1) sees the file is binary but the comparison still fails because it says ia64 (not ia32). ... changing this to grep "ELF .*-bit LSB executable, .*" $LTPTMP/file.out &> /dev/null ... works on x86 and IA64. Problem #4: in "testcases/bin/file_test.sh", line 286 ----------- export TST_COUN=7 ... simple problem. Should be setting the variable TST_COUNT. Because of this, the test results file reports it ran test-case 6 twice. export TST_COUNT=7 ... makes it work as expected. Problem #5: in "testcases/bin/file_test.sh", line 331 ----------- tar cf $LTPTMP/files $LTPTMP/file1 $LTPTMP/file2 $LTPTMP/file3 \ ... problem is that on line 339, the script runs "gzip $LTPTMP/files.tar" but line 331 doesn't create that filename. tar cf $LTPTMP/files.tar $LTPTMP/file1 $LTPTMP/file2 $LTPTMP/file3 \ ... makes the gzip succeed. Problem #6: in "testcases/bin/file_test.sh", lines 346-347 ----------- file $LTPTMP/files.tar.gz &> $LTPTMP/file.out || RC=$? if [ $RC -eq 0 ] ... it's possible that RC is NOT set, so it's possible therefore that the correct branch may never be taken. Plus, from line 347 to the end of the test-case, the variable RC is never used. If these lines are changed to file $LTPTMP/files.tar.gz &> $LTPTMP/file.out if [ $? -eq 0 ] ... the test-case logically flows as expected. Problem #7: in "testcases/bin/file_test.sh", line 349 ----------- grep "gzip compressed data, deflated, original filename, \'files.tar" \ ... this doesn't match the output of what Red Hat EL 3 file(1) prints. If this line is changed to: grep "gzip compressed data, .*" \ ... this line works as expected Problem #8: in "testcases/bin/file_test.sh", line 436 ----------- rpm -bs $LTPTMP/files.spec &>$LTPTMP/file.out ... this line throws the error message: error: File /usr/src/redhat/SOURCES/cprog.c: No such file or directory ... the basic problem is that Red Hat uses "/usr/src/redhat" while SuSE and others use "/usr/src/packages" for SRPM build-areas. Fixing this one is uglier. I'd recommend checking if /etc/redhat-release exists, and if so, use /usr/src/redhat (else /usr/src/packages). See attached patch -- basically, it's [ -f /etc/redhat-release ] && bDIR=/usr/src/redhat || bDIR=/usr/src/packages + s,/usr/src/packages/,$bDIR,g Problem #9: in "testcases/bin/file_test.sh", line 448 ----------- grep "RPM v3 src i386" $LTPTMP/file.out &>/dev/null ... the problem is that Red Hat EL3 for IA64 does _not_ print the architecture. If the line were changed to: grep "RPM v3 src" $LTPTMP/file.out &>/dev/null ... it should work on all architectures. Problem #10: in "testcases/bin/file_test.sh", line 479 ------------ ... the basic problem is that this test case doesn't work on IA64. The Intel EFI namespace specifications don't allow for a compressed kernel image file to be in /boot (only symlinks). ... also troubling for Red Hat distributions is that the gzip'ed vmlinuz files don't output the string "kernel" in either form, and line 479 greps for "kernel" ala grep -i "kernel" $LTPTMP/file.out &>/dev/null Index: file_test.sh =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/commands/ade/file/file_test.sh,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- file_test.sh 14 Apr 2003 20:56:21 -0000 1.8 +++ file_test.sh 26 Nov 2003 19:30:28 -0000 1.9 @@ -41,7 +41,7 @@ export TST_TOTAL=10 # Number of tests in this testcase -if [ -z $LTPTMP && -z $TMPBASE ] +if [ -z $LTPTMP ] && [ -z $TMPBASE ] then LTPTMP=/tmp/ else @@ -258,13 +258,13 @@ } EOF -cc -o /tmp/cprog /tmp/cprog.c &>/dev/null +cc -o $LTPTMP/cprog $LTPTMP/cprog.c &>/dev/null file $LTPTMP/cprog &>$LTPTMP/file.out || RC=$? if [ $RC -eq 0 ] then - grep "ELF 32-bit LSB executable, Intel 80386" $LTPTMP/file.out &>/dev/null + grep "ELF .*-bit LSB executable, .*" $LTPTMP/file.out &>/dev/null if [ $? -eq 0 ] then $LTPBIN/tst_resm TPASS "file: Recognized ELF binary executable" @@ -328,7 +328,7 @@ $LTPBIN/tst_resm TINFO "TEST #8: file command recognizes tar zip files" -tar cf $LTPTMP/files $LTPTMP/file1 $LTPTMP/file2 $LTPTMP/file3 \ +tar cf $LTPTMP/files.tar $LTPTMP/file1 $LTPTMP/file2 $LTPTMP/file3 \ &>$LTPTMP/file.out if [ $? -ne 0 ] then @@ -346,7 +346,7 @@ file $LTPTMP/files.tar.gz &>$LTPTMP/file.out || RC=$? if [ $RC -eq 0 ] then - grep "gzip compressed data, deflated, original filename, \`files.tar'" \ + grep "gzip compressed data, .*" \ $LTPTMP/file.out &>$LTPTMP/file1.out if [ $? -eq 0 ] then @@ -373,6 +373,8 @@ export TST_COUNT=9 $LTPBIN/tst_resm TINFO "TEST #9: file command recognizes RPM files" +[ -f /etc/redhat-release ] \ + && bDIR=/usr/src/redhat || bDIR=/usr/src/packages cat > $LTPTMP/files.spec <<EOF @@ -407,11 +409,11 @@ EOF -if [ -d /usr/src/packages/SOURCES ] +if [ -d $bDIR/SOURCES ] then echo "directory exists" &>$LTPTMP/file.out else - mkdir -p /usr/src/packages/SOURCES/ &>$LTPTMP/file.out || RC=$? + mkdir -p $bDIR/SOURCES/ &>$LTPTMP/file.out || RC=$? fi if [ $RC -ne 0 ] @@ -419,7 +421,7 @@ $LTPBIN/tst_brk TBROK $LTPTMP/file.out NULL "mkdir: brok. Reason:" fi -cat > /usr/src/packages/SOURCES/cprog.c <<EOF || RC=$? +cat > $bDIR/SOURCES/cprog.c <<EOF || RC=$? #include <stdio.h> main() @@ -439,11 +441,11 @@ $LTPBIN/tst_brk TBROK $LTPTMP/file.out NULL "rpm command brok. Reason:" fi -file /usr/src/packages/SRPMS/cprog-0.0.7-3.src.rpm &>$LTPTMP/file.out || RC=$? +file $bDIR/SRPMS/cprog-0.0.7-3.src.rpm &>$LTPTMP/file.out || RC=$? if [ $RC -eq 0 ] then - grep "RPM v3 src i386" $LTPTMP/file.out &>/dev/null + grep "RPM v3 src" $LTPTMP/file.out &>/dev/null if [ $? -eq 0 ] then $LTPBIN/tst_resm TPASS "file: Recognised RPM file correctly" |