encoding_errors_warnings.sh 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #parse argument
  2. architecture=$1
  3. matrix_decompressed_file=$2
  4. matrix_comp_file=$3
  5. output_dir=$4
  6. lorem_ipsum_file=$5
  7. permutation_str=""
  8. # useful scripts
  9. # write zero
  10. # dd if=/dev/zero of=binary.dat bs=1c count=1
  11. # append zero
  12. # dd if=/dev/zero oflag=append conv=notrunc of=binary.dat bs=1c count=1
  13. # count zeros
  14. # xxd -b infile | awk 'NF{NF-=1};1' | sed 's/^.*://' | tr -d '\n' | tr -d ' ' | sed 's/1//g' | wc -c
  15. # count last 1024 zeros
  16. # xxd -b running_warning.bin | awk 'NF{NF-=1};1' | sed 's/^.*://' | tr -d '\n' | tr -d ' ' | tail -c 1024 | tr -d '1' | wc -c
  17. # create two files
  18. str="
  19. head -c 256 </dev/urandom >$output_dir/rnd_file.bin
  20. "
  21. echo ""; echo $str; echo ""
  22. eval $str
  23. str="
  24. echo -n $'\xf0' > $output_dir/balanced_file.bin ; \
  25. for i in {1..255} ; do echo -n $'\x0f' >> $output_dir/balanced_file.bin ; done
  26. "
  27. echo ""; echo $str; echo ""
  28. eval $str
  29. # trigger constant warning
  30. # the balanced_file has in the buffer at the end 64 zeroes and 64 ones
  31. # to trigger a warning and not an error we need to add (704-64) ones (or zeros) at the end of the file
  32. str="
  33. cp $output_dir/balanced_file.bin $output_dir/disparity_warning.bin ; \
  34. for i in {1..32} ; do echo -n $'\xff' >> $output_dir/disparity_warning.bin ; done ; \
  35. "
  36. echo ""; echo $str; echo ""
  37. eval $str
  38. str="
  39. xrnlib-cli \
  40. --decoding-conf -compiled-param -no-running-err -disparity-war-th 640 -disparity-err-th 704 -no-password \
  41. --encoding-conf -no-param \
  42. --logging-conf -lib-error-log $output_dir/disparity_warning.err -lib-warning-log $output_dir/disparity_warning.war \
  43. --decode-encode -to-decode $output_dir/disparity_warning.bin -to-encode $output_dir/dummy ; \
  44. rm $output_dir/dummy
  45. "
  46. echo ""; echo $str; echo ""
  47. eval $str
  48. str="
  49. nlwar=$( cat $output_dir/disparity_warning.war | wc -l ) ; \
  50. nlerr=$( cat $output_dir/disparity_warning.err | wc -l ) ; \
  51. if [ \$nlwar != '1' ] || [ \$nlerr != '0' ] ; then echo FAIL ; exit ; fi ; \
  52. "
  53. echo ""; echo $str; echo ""
  54. eval $str
  55. # trigger constant error
  56. # the balanced_file has in the buffer at the end 64 zeroes and 64 ones
  57. # to trigger a warning and not an error we need to add (704-64) ones (or zeros) at the end of the file
  58. str="
  59. xrnlib-cli \
  60. --decoding-conf -compiled-param -no-running-err -disparity-war-th 639 -disparity-err-th 640 -no-password \
  61. --encoding-conf -no-param \
  62. --logging-conf -lib-error-log $output_dir/disparity_error.err -lib-warning-log $output_dir/disparity_error.war \
  63. --decode-encode -to-decode $output_dir/disparity_warning.bin -to-encode $output_dir/dummy ; \
  64. rm $output_dir/dummy
  65. "
  66. echo ""; echo $str; echo ""
  67. eval $str
  68. str="
  69. nlwar=$( cat $output_dir/disparity_error.war | wc -l ) ; \
  70. nlerr=$( cat $output_dir/disparity_error.err | grep -v 'generic error' | wc -l ) ; \
  71. if [ \$nlwar != '0' ] || [ \$nlerr != '1' ] ; then echo FAIL ; exit ; fi ; \
  72. "
  73. echo ""; echo $str; echo ""
  74. eval $str
  75. # do not trigger error or warnings
  76. str="
  77. xrnlib-cli \
  78. --decoding-conf -compiled-param -no-running-err -no-disparity-err -no-password \
  79. --encoding-conf -no-param \
  80. --logging-conf -lib-error-log $output_dir/no_disparity_error.err -lib-warning-log $output_dir/no_disparity_error.war \
  81. --decode-encode -to-decode $output_dir/disparity_warning.bin -to-encode $output_dir/dummy ; \
  82. rm $output_dir/dummy
  83. "
  84. echo ""; echo $str; echo ""
  85. eval $str
  86. str="
  87. nlwar=$( cat $output_dir/no_disparity_error.war | wc -l ) ; \
  88. nlerr=$( cat $output_dir/no_disparity_error.err | grep -v 'generic error' | wc -l ) ; \
  89. if [ \$nlwar != '0' ] || [ \$nlerr != '0' ] ; then echo FAIL ; exit ; fi ; \
  90. "
  91. echo ""; echo $str; echo ""
  92. eval $str
  93. # trigger running warning
  94. # the rnd_file has in the buffer mixed zeros and ones
  95. # to trigger a warning and not an error we need to add (32 consecutives bits) ones
  96. str="
  97. cp $output_dir/rnd_file.bin $output_dir/running_warning.bin ; \
  98. echo -n $'\x0f' >> $output_dir/running_warning.bin ; \
  99. for i in {1..3} ; do echo -n $'\xff' >> $output_dir/running_warning.bin ; done ; \
  100. echo -n $'\xf0' >> $output_dir/running_warning.bin
  101. "
  102. echo ""; echo $str; echo ""
  103. eval $str
  104. str="
  105. xrnlib-cli \
  106. --decoding-conf -compiled-param -running-war-th 32 -running-err-th 36 -no-password \
  107. --encoding-conf -no-param \
  108. --logging-conf -lib-error-log $output_dir/running_warning.err -lib-warning-log $output_dir/running_warning.war \
  109. --decode-encode -to-decode $output_dir/running_warning.bin -to-encode $output_dir/dummy ; \
  110. rm $output_dir/dummy
  111. "
  112. echo ""; echo $str; echo ""
  113. eval $str
  114. str="
  115. nlwar=$( cat $output_dir/running_warning.war | wc -l ) ; \
  116. nlerr=$( cat $output_dir/running_warning.err | wc -l ) ; \
  117. if [ \$nlwar != '1' ] || [ \$nlerr != '0' ] ; then echo FAIL ; exit ; fi ; \
  118. "
  119. echo ""; echo $str; echo ""
  120. eval $str
  121. # trigger running error
  122. # the rnd_file has in the buffer mixed zeros and ones
  123. # to trigger a warning and not an error we need to add (32 consecutives bits) ones
  124. str="
  125. cp $output_dir/rnd_file.bin $output_dir/running_error.bin ; \
  126. echo -n $'\x0f' >> $output_dir/running_error.bin ; \
  127. for i in {1..3} ; do echo -n $'\xff' >> $output_dir/running_error.bin ; done ; \
  128. echo -n $'\xff' >> $output_dir/running_error.bin
  129. "
  130. echo ""; echo $str; echo ""
  131. eval $str
  132. str="
  133. xrnlib-cli \
  134. --decoding-conf -compiled-param -running-war-th 32 -running-err-th 36 -no-password \
  135. --encoding-conf -no-param \
  136. --logging-conf -lib-error-log $output_dir/running_error.err -lib-warning-log $output_dir/running_error.war \
  137. --decode-encode -to-decode $output_dir/running_error.bin -to-encode $output_dir/dummy ; \
  138. rm $output_dir/dummy
  139. "
  140. echo ""; echo $str; echo ""
  141. eval $str
  142. str="
  143. nlwar=$( cat $output_dir/running_error.war | wc -l ) ; \
  144. nlerr=$( cat $output_dir/running_error.err | grep -v 'generic error' | wc -l ) ; \
  145. if [ \$nlwar != '0' ] || [ \$nlerr != '1' ] ; then echo FAIL ; exit ; fi ; \
  146. "
  147. echo ""; echo $str; echo ""
  148. eval $str