On Mon, Nov 03, 2014 at 05:52:47PM -0500, Mike Frysinger wrote: > the test requires `cc` to be installed and fully functional. that means > binutils also have to be installed (`as` and `ld`). i'm not aware of any > distro that splits `readelf` out from the others.
Ok, it's reasonable to assume readelf is installed then. The patch below adds two different checks for endiannes: first a simple check of the ASCII character "I" in octal, then the readelf test. If neither test works it logs an error. ================================================== file_test: fix testcase for ppc64le The file_test.sh test assumes all PPC systems are big-endian (MSB), but this assumption is incorrect on the new ppc64le little-endian (LSB) systems and file06 and file10 report false failures: file06 0 TINFO : TEST #6: file command recognizes ELF executables file06 6 TFAIL : ltpapicmd.c:156: file: Failed to Recognize ELF binary executable. Reason: /tmp//cprog: ELF 64-bit LSB executable, version 1 (SYSV), dynamically linked (uses shared libs), ... ... file10 0 TINFO : TEST #10: file command recognizes vmlinu file file10 10 TFAIL : ltpapicmd.c:156: file: Failed to Recognize vmlinu correctly. Reason: /boot/vmlinuz: ELF 64-bit LSB shared object, version 1 (SYSV), statically linked, ... This patch adds more robust testing for the endianness of a CPU. Signed-off-by: Jeffrey Bastian <jbast...@redhat.com> --- testcases/commands/ade/file/file_test.sh | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/testcases/commands/ade/file/file_test.sh b/testcases/commands/ade/file/file_test.sh index 101a8cca8bc9..b94ad2313a31 100755 --- a/testcases/commands/ade/file/file_test.sh +++ b/testcases/commands/ade/file/file_test.sh @@ -332,16 +332,7 @@ fi # TEST #6 -# Test if file command can recognize ELF binay executables - -# Check ppc architecture - TEST_ARCH=LSB # Assume the architecture is Intel - - if uname -m | - grep -qe '\(m68k\)\|\(sparc\)\|\(mips\b\)\|\(mipseb\)\|\(sh.eb\)' \ - -e '\(powerpc\)\|\(ppc\)\|\(s390\)\|\(parisc\)'; then - TEST_ARCH=MSB - fi +# Test if file command can recognize ELF binary executables export TCID=file06 export TST_COUNT=6 @@ -349,6 +340,27 @@ export TST_COUNT=6 $LTPBIN/tst_resm TINFO \ "TEST #6: file command recognizes ELF executables" +# check for CPU endianness +TEST_ARCH=NULL +ENDIAN=$(echo -n I | od -to2 2>/dev/null | + awk '{print substr($2,6,1); exit}' 2>/dev/null) +if [ "$ENDIAN" = "0" ]; then + TEST_ARCH=MSB +elif [ "$ENDIAN" = "1" ]; then + TEST_ARCH=LSB +else + READELF=$(which readelf 2>/dev/null) + ENDIAN=$($READELF -h $READELF 2>/dev/null | grep endian) + if echo $ENDIAN | grep -q 'Data:.*big endian' ; then + TEST_ARCH=MSB + elif echo $ENDIAN | grep -q 'Data:.*little endian' ; then + TEST_ARCH=LSB + fi +fi + +if [ "$TEST_ARCH" = "NULL" ]; then + $LTPBIN/tst_resm TFAIL "file: Could not determine CPU endianness" +fi cat > $LTPTMP/cprog.c <<EOF #include <stdio.h>
pgpA_SJg1Zpmb.pgp
Description: PGP signature
------------------------------------------------------------------------------
_______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list