valgrind_tester 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env ruby
  2. require 'fileutils'
  3. print("Regression tester 0.0.1\n")
  4. def path_local(from)
  5. return from #from.gsub('/','//')
  6. from.gsub('/','\\\\')
  7. end
  8. TESTS_DIR="./tests"
  9. def perform_test(exepath,filepath,outname,args)
  10. output_path=path_local(TESTS_DIR+"/outputs/"+outname)
  11. error_path=path_local(TESTS_DIR+"/errors/"+outname)
  12. exepath=path_local(exepath)
  13. output_path=path_local(output_path)
  14. filepath=path_local(filepath)
  15. joined_args = args.join(' ')
  16. printf("calling:" + "#{exepath} #{joined_args} -o#{output_path}.a1 #{filepath}\n")
  17. valgrind_mode="valgrind --track-origins=yes "
  18. #valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes
  19. result = `#{valgrind_mode} #{exepath} #{joined_args} -a1 -o#{output_path}.b #{filepath} 2>#{error_path}.val`
  20. result = `#{valgrind_mode} #{exepath} #{joined_args} -a2 -o#{output_path}.b #{filepath} 2>>#{error_path}.val`
  21. result = `#{valgrind_mode} #{exepath} #{joined_args} -o#{output_path}.b #{filepath} 2>>#{error_path}.val`
  22. puts result
  23. p $?
  24. end
  25. `rm -rf #{TESTS_DIR}/outputs/*.*`
  26. #exit(1)
  27. if(ARGV.size()==0)
  28. puts("valgrind_tester DCC_EXECUTABLE")
  29. exit(0)
  30. end
  31. Dir.open(TESTS_DIR+"/inputs").each() {|f|
  32. next if f=="." or f==".."
  33. perform_test(".//"+ARGV[0],TESTS_DIR+"/inputs/"+f,f,ARGV[1..-1])
  34. }
  35. Dir.open(TESTS_DIR+"/inputs").each() {|f|
  36. next if f=="." or f==".."
  37. FileUtils.mv(TESTS_DIR+"/inputs/"+f,TESTS_DIR+"/outputs/"+f) if f.end_with?(".b")
  38. }
  39. "diff -rqbwB"