bctest 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/bin/sh
  2. # This script is used by test/Makefile.ssl to check whether a sane 'bc'
  3. # is installed.
  4. # ('make test_bn' should not try to run 'bc' if it does not exist or if
  5. # it is a broken 'bc' version that is known to cause trouble.)
  6. #
  7. # If 'bc' works, we also test if it knows the 'print' command.
  8. #
  9. # In any case, output an appropriate command line for running (or not
  10. # running) bc.
  11. IFS=:
  12. try_without_dir=true
  13. # First we try "bc", then "$dir/bc" for each item in $PATH.
  14. for dir in dummy:$PATH; do
  15. if [ "$try_without_dir" = true ]; then
  16. # first iteration
  17. bc=bc
  18. try_without_dir=false
  19. else
  20. # second and later iterations
  21. bc="$dir/bc"
  22. if [ ! -f "$bc" ]; then # '-x' is not available on Ultrix
  23. bc=''
  24. fi
  25. fi
  26. if [ ! "$bc" = '' ]; then
  27. failure=none
  28. # Test for SunOS 5.[78] bc bug
  29. "$bc" >tmp.bctest <<\EOF
  30. obase=16
  31. ibase=16
  32. a=AD88C418F31B3FC712D0425001D522B3AE9134FF3A98C13C1FCC1682211195406C1A6C66C6A\
  33. CEEC1A0EC16950233F77F1C2F2363D56DD71A36C57E0B2511FC4BA8F22D261FE2E9356D99AF57\
  34. 10F3817C0E05BF79C423C3F66FDF321BE8D3F18F625D91B670931C1EF25F28E489BDA1C5422D1\
  35. C3F6F7A1AD21585746ECC4F10A14A778AF56F08898E965E9909E965E0CB6F85B514150C644759\
  36. 3BE731877B16EA07B552088FF2EA728AC5E0FF3A23EB939304519AB8B60F2C33D6BA0945B66F0\
  37. 4FC3CADF855448B24A9D7640BCF473E
  38. b=DCE91E7D120B983EA9A104B5A96D634DD644C37657B1C7860B45E6838999B3DCE5A555583C6\
  39. 9209E41F413422954175A06E67FFEF6746DD652F0F48AEFECC3D8CAC13523BDAAD3F5AF4212BD\
  40. 8B3CD64126E1A82E190228020C05B91C8B141F1110086FC2A4C6ED631EBA129D04BB9A19FC53D\
  41. 3ED0E2017D60A68775B75481449
  42. (a/b)*b + (a%b) - a
  43. EOF
  44. if [ 0 != "`cat tmp.bctest`" ]; then
  45. failure=SunOStest
  46. fi
  47. if [ "$failure" = none ]; then
  48. # Test for SCO bc bug.
  49. "$bc" >tmp.bctest <<\EOF
  50. obase=16
  51. ibase=16
  52. -FFDD63BA1A4648F0D804F8A1C66C53F0D2110590E8A3907EC73B4AEC6F15AC177F176F2274D2\
  53. 9DC8022EA0D7DD3ABE9746D2D46DD3EA5B5F6F69DF12877E0AC5E7F5ADFACEE54573F5D256A06\
  54. 11B5D2BC24947724E22AE4EC3FB0C39D9B4694A01AFE5E43B4D99FB9812A0E4A5773D8B254117\
  55. 1239157EC6E3D8D50199 * -FFDD63BA1A4648F0D804F8A1C66C53F0D2110590E8A3907EC73B4\
  56. AEC6F15AC177F176F2274D29DC8022EA0D7DD3ABE9746D2D46DD3EA5B5F6F69DF12877E0AC5E7\
  57. F5ADFACEE54573F5D256A0611B5D2BC24947724E22AE4EC3FB0C39D9B4694A01AFE5E43B4D99F\
  58. B9812A0E4A5773D8B2541171239157EC6E3D8D50199 - FFBACC221682DA464B6D7F123482522\
  59. 02EDAEDCA38C3B69E9B7BBCD6165A9CD8716C4903417F23C09A85B851961F92C217258CEEB866\
  60. 85EFCC5DD131853A02C07A873B8E2AF2E40C6D5ED598CD0E8F35AD49F3C3A17FDB7653E4E2DC4\
  61. A8D23CC34686EE4AD01F7407A7CD74429AC6D36DBF0CB6A3E302D0E5BDFCD048A3B90C1BE5AA8\
  62. E16C3D5884F9136B43FF7BB443764153D4AEC176C681B078F4CC53D6EB6AB76285537DDEE7C18\
  63. 8C72441B52EDBDDBC77E02D34E513F2AABF92F44109CAFE8242BD0ECBAC5604A94B02EA44D43C\
  64. 04E9476E6FBC48043916BFA1485C6093603600273C9C33F13114D78064AE42F3DC466C7DA543D\
  65. 89C8D71
  66. AD534AFBED2FA39EE9F40E20FCF9E2C861024DB98DDCBA1CD118C49CA55EEBC20D6BA51B2271C\
  67. 928B693D6A73F67FEB1B4571448588B46194617D25D910C6A9A130CC963155CF34079CB218A44\
  68. 8A1F57E276D92A33386DDCA3D241DB78C8974ABD71DD05B0FA555709C9910D745185E6FE108E3\
  69. 37F1907D0C56F8BFBF52B9704 % -E557905B56B13441574CAFCE2BD257A750B1A8B2C88D0E36\
  70. E18EF7C38DAC80D3948E17ED63AFF3B3467866E3B89D09A81B3D16B52F6A3C7134D3C6F5123E9\
  71. F617E3145BBFBE9AFD0D6E437EA4FF6F04BC67C4F1458B4F0F47B64 - 1C2BBBB19B74E86FD32\
  72. 9E8DB6A8C3B1B9986D57ED5419C2E855F7D5469E35E76334BB42F4C43E3F3A31B9697C171DAC4\
  73. D97935A7E1A14AD209D6CF811F55C6DB83AA9E6DFECFCD6669DED7171EE22A40C6181615CAF3F\
  74. 5296964
  75. EOF
  76. if [ "0
  77. 0" != "`cat tmp.bctest`" ]; then
  78. failure=SCOtest
  79. fi
  80. fi
  81. if [ "$failure" = none ]; then
  82. # bc works; now check if it knows the 'print' command.
  83. if [ "OK" = "`echo 'print \"OK\"' | $bc 2>/dev/null`" ]
  84. then
  85. echo "$bc"
  86. else
  87. echo "sed 's/print.*//' | $bc"
  88. fi
  89. exit 0
  90. fi
  91. echo "$bc does not work properly ('$failure' failed). Looking for another bc ..." >&2
  92. fi
  93. done
  94. echo "No working bc found. Consider installing GNU bc." >&2
  95. if [ "$1" = ignore ]; then
  96. echo "cat >/dev/null"
  97. exit 0
  98. fi
  99. exit 1