ascii.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/sh
  2. # test conv=ascii
  3. # Copyright (C) 2014-2018 Free Software Foundation, Inc.
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
  15. print_ver_ dd printf
  16. {
  17. # Two lines, EBCDIC " A A" and " A ", followed by all the bytes in order.
  18. env printf '\100\301\100\301\100\301\100\100' &&
  19. env printf $(env printf '\\%03o' $(seq 0 255));
  20. } >in || framework_failure_
  21. {
  22. # The converted lines, with trailing spaces removed.
  23. env printf \
  24. ' A A\n A\n'\
  25. '\000\001\002\003\n\234\011\206\177\n'\
  26. '\227\215\216\013\n\014\015\016\017\n'\
  27. '\020\021\022\023\n\235\205\010\207\n'\
  28. '\030\031\222\217\n\034\035\036\037\n'\
  29. '\200\201\202\203\n\204\012\027\033\n'\
  30. '\210\211\212\213\n\214\005\006\007\n'\
  31. '\220\221\026\223\n\224\225\226\004\n'\
  32. '\230\231\232\233\n\024\025\236\032\n'\
  33. '\040\240\241\242\n\243\244\245\246\n'\
  34. '\247\250\325\056\n\074\050\053\174\n'\
  35. '\046\251\252\253\n\254\255\256\257\n'\
  36. '\260\261\041\044\n\052\051\073\176\n'\
  37. '\055\057\262\263\n\264\265\266\267\n'\
  38. '\270\271\313\054\n\045\137\076\077\n'\
  39. '\272\273\274\275\n\276\277\300\301\n'\
  40. '\302\140\072\043\n\100\047\075\042\n'\
  41. '\303\141\142\143\n\144\145\146\147\n'\
  42. '\150\151\304\305\n\306\307\310\311\n'\
  43. '\312\152\153\154\n\155\156\157\160\n'\
  44. '\161\162\136\314\n\315\316\317\320\n'\
  45. '\321\345\163\164\n\165\166\167\170\n'\
  46. '\171\172\322\323\n\324\133\326\327\n'\
  47. '\330\331\332\333\n\334\335\336\337\n'\
  48. '\340\341\342\343\n\344\135\346\347\n'\
  49. '\173\101\102\103\n\104\105\106\107\n'\
  50. '\110\111\350\351\n\352\353\354\355\n'\
  51. '\175\112\113\114\n\115\116\117\120\n'\
  52. '\121\122\356\357\n\360\361\362\363\n'\
  53. '\134\237\123\124\n\125\126\127\130\n'\
  54. '\131\132\364\365\n\366\367\370\371\n'\
  55. '\060\061\062\063\n\064\065\066\067\n'\
  56. '\070\071\372\373\n\374\375\376\377\n';
  57. } >exp || framework_failure_
  58. dd if=in of=out conv=ascii cbs=4 || fail=1
  59. compare exp out \
  60. || { od -v -to1 exp > exp2 || framework_failure_;
  61. od -v -to1 out > out2 || framework_failure_;
  62. compare exp2 out2;
  63. fail=1; }
  64. Exit $fail