encoding_errors_warnings.sh 5.8 KB

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