random_config.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #!/bin/bash
  2. dir="$1"
  3. mkdir "$dir"
  4. if [ $? -ne 0 ]
  5. then
  6. exit 1
  7. fi
  8. cd "$dir"
  9. if [ $? -ne 0 ]
  10. then
  11. exit 1
  12. fi
  13. configure_path="$2"
  14. config="random_config.txt"
  15. case `seq 3 | shuf -n1` in
  16. 1)
  17. approx=--enable-float-approx
  18. math=-ffast-math
  19. ;;
  20. 2)
  21. approx=--enable-float-approx
  22. ;;
  23. *)
  24. approx=
  25. math=
  26. ;;
  27. esac
  28. CFLAGS='-g'
  29. opt=`echo -e "-O1\n-O2\n-O3" | shuf -n1`
  30. #arch=-march=`echo -e "core2\nsandybridge\nbroadwell\nskylake" | shuf -n1`
  31. arch=`echo -e "\n-march=core2\n-march=sandybridge\n-march=broadwell\n-march=skylake\n-march=native" | shuf -n1`
  32. footprint=`echo -e "\n-DSMALL_FOOTPRINT" | shuf -n1`
  33. std=`echo -e "\n-std=c90\n-std=c99\n-std=c11\n-std=c17" | shuf -n1`
  34. sanitize=`echo -e "\n-fsanitize=address -fno-sanitize-recover=all\n-fsanitize=undefined -fno-sanitize-recover=all -fsanitize-recover=signed-integer-overflow" | shuf -n1`
  35. CFLAGS="$CFLAGS $std $opt $arch $footprint $math $sanitize"
  36. echo "CFLAGS=$CFLAGS" > "$config"
  37. lib=`echo -e "\n--disable-static\n--disable-shared" | shuf -n1`
  38. arithmetic=`echo -e "\n--enable-fixed-point\n--enable-fixed-point --enable-fixed-point-debug\n--enable-fixed-point --disable-float-api\n--enable-fixed-point --enable-fixed-point-debug --disable-float-api" | shuf -n1`
  39. custom=`echo -e "\n--enable-custom-modes" | shuf -n1`
  40. asm=`echo -e "\n--disable-asm\n--disable-rtcd\n--disable-intrinsics" | shuf -n1`
  41. #asm=`echo -e "\n--disable-asm\n--disable-intrinsics" | shuf -n1`
  42. assert=`echo -e "\n--enable-assertions" | shuf -n1`
  43. harden=`echo -e "\n--enable-hardening" | shuf -n1`
  44. fuzz=`echo -e "\n--enable-fuzzing" | shuf -n1`
  45. checkasm=`echo -e "\n--enable-check-asm" | shuf -n1`
  46. rfc8251=`echo -e "\n--disable-rfc8251" | shuf -n1`
  47. if [ "$rfc8251" = --disable-rfc8251 ]
  48. then
  49. vectors="$3"
  50. else
  51. vectors="$4"
  52. fi
  53. echo using testvectors at "$vectors" >> "$config"
  54. config_opt="$lib $arithmetic $custom $asm $assert $harden $fuzz $checkasm $rfc8251 $approx"
  55. echo configure $config_opt >> "$config"
  56. export CFLAGS
  57. "$configure_path/configure" $config_opt > configure_output.txt 2>&1
  58. if [ $? -ne 0 ]
  59. then
  60. echo configure FAIL >> "$config"
  61. exit 1
  62. fi
  63. make > make_output.txt 2>&1
  64. if [ $? -ne 0 ]
  65. then
  66. echo make FAIL >> "$config"
  67. exit 1
  68. fi
  69. #Run valgrind 5% of the time (minus the asan cases)
  70. if [ "`seq 20 | shuf -n1`" -ne 1 -o "$sanitize" = "-fsanitize=address -fno-sanitize-recover=all" ]
  71. then
  72. make check > makecheck_output.txt 2>&1
  73. else
  74. echo valgrind enabled >> "$config"
  75. valgrind --trace-children=yes --error-exitcode=128 make check > makecheck_output.txt 2>&1
  76. fi
  77. if [ $? -ne 0 ]
  78. then
  79. echo check FAIL >> "$config"
  80. exit 1
  81. fi
  82. rate=`echo -e "8000\n12000\n16000\n24000\n48000" | shuf -n1`
  83. echo testvectors for "$rate" Hz > testvectors_output.txt
  84. ../../../run_vectors.sh . "$vectors" "$rate" >> testvectors_output.txt 2>&1
  85. if [ $? -ne 0 ]
  86. then
  87. echo testvectors FAIL >> "$config"
  88. exit 1
  89. fi
  90. echo all tests PASS >> "$config"
  91. #When everything's good, do some cleaning up to save space
  92. make distclean > /dev/null 2>&1
  93. rm -f tmp.out
  94. gzip make_output.txt