format_checks.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. VERBOSE="" # set VERBOSE="v" for verbose mode
  3. # that @expression@ will be substituted by the 'confgure' script
  4. EXTENSIONS=" BLP BMP DCX DDS DICOM WAD FITS GIF HDR ICNS ICON IFF ILBM IWI JPG JP2 LCMS LIF MDL MNG MP3 PCX PCD PIC PIX PNG PNM PSD PSP PXR RAW ROT SGI SUN TEXTURE TGA TIF TPL UTX VTF WAL WBMP WDP XPM"
  5. # Here are the extensions that should support saving according to docs
  6. #CAN_SAVE=" BMP DDS HDR ICO JPG PCX PNG PPM PSD RAW SGI TGA TIF XPM " RAW and XPM are problematic...
  7. CAN_SAVE="BMP DDS EXR HDR ICO JP2 JPG PCX PNG PPM PSD SGI TGA TIF"
  8. # List of formats that we don't test since they are problematic
  9. PROBLEMATIC="RAW WBMP XPM"
  10. echo "Running saving and loading consistency test..."
  11. FAILED_FORMATS=""
  12. PASSED_FORMATS=""
  13. # if using Wine makes sense, use it...
  14. if [ "x@BUILD_OS@" != "x@HOST_OS@" ]
  15. then
  16. if [ "x" = "xMINGW32" -o "x" = "xCYGWIN" ]
  17. then
  18. test $(which wine 2> /dev/null) && WINE="wine"
  19. echo "Warning: Using wine to test executables (not 100% reliable)"
  20. fi
  21. fi
  22. for EXTENSION in $EXTENSIONS
  23. do
  24. #echo expr match "' $CAN_SAVE '" '.*\s'$EXTENSION'\s.*'
  25. if [ $(expr match "' $CAN_SAVE '" '.*\s'$EXTENSION'\s.*') -eq 0 -o $(expr match "' $PROBLEMATIC '" '.*\s'$EXTENSION'\s.*') -ne 0 ]
  26. then # This extension is not considered as supported...
  27. continue;
  28. fi
  29. test -n "$VERBOSE" && echo $WINE ./testil -e $EXTENSION
  30. # EXEEXT comes in when one compiles on platforms that append extensions to executables (testil.exe)
  31. $WINE ./testil -e$VERBOSE $EXTENSION
  32. # We have to capture whether the test has failed or not
  33. if [ ! $? -eq 0 ]
  34. then # we have an error here...
  35. FAILED_FORMATS="$FAILED_FORMATS $EXTENSION"
  36. FAILED="$?"
  37. else #no error...
  38. PASSED_FORMATS="$PASSED_FORMATS $EXTENSION"
  39. fi
  40. done
  41. #let's tell something to the user as well:
  42. if [ "x$FAILED" = "x" ]
  43. then #everything went fine
  44. echo "All examined formats were OK:$PASSED_FORMATS"
  45. else #something went wrong
  46. echo "Errors were encountered during the test :-("
  47. echo "Formats that were OK:$PASSED_FORMATS"
  48. echo "Failed formats: $FAILED_FORMATS"
  49. FAILED="1"
  50. fi # end of something went wrong
  51. echo "Problematic (untested) formats: $PROBLEMATIC"
  52. echo
  53. # And we have to tell the result to the shell, too...
  54. exit $FAILED