run_samples.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/usr/bin/python
  2. # Script for automatically run tests on samples
  3. # author: sana
  4. # contributors: tct, alexm
  5. import subprocess
  6. import sys
  7. # list of data structures
  8. tests = ["algorithms",
  9. "avl_tree",
  10. "b_tree",
  11. "binary_search_tree",
  12. "binary_tree",
  13. "doubly_linked_list",
  14. "hash_map",
  15. "hash_set",
  16. "heap",
  17. "interval_tree",
  18. "linked_list",
  19. "matrix",
  20. "graph",
  21. "graph_matrix",
  22. "pair",
  23. "queue",
  24. "red_black_tree",
  25. "scapegoat_tree",
  26. "skip_list",
  27. "sort",
  28. "splay_tree",
  29. "stack",
  30. "treap_tree",
  31. "tree_algorithms",
  32. "tree",
  33. "trie_tree",
  34. "vector"]
  35. EXEC = "./temelia_samples "
  36. CROSS_COMPILE = ""
  37. subprocess.call("make clean", shell=True)
  38. for arg in sys.argv:
  39. if (arg == 'dll'):
  40. subprocess.call("cp /usr/lib/temelia.dll .", shell=True)
  41. EXEC = "./temelia_samples.exe "
  42. CROSS_COMPILE = " CROSS_COMPILE=i586-mingw32msvc-"
  43. subprocess.call("make" + CROSS_COMPILE, shell=True)
  44. LOG_FILE = "samples_log.txt"
  45. flog = open(LOG_FILE, 'w')
  46. # no. of failed and passed tests
  47. failed = 0
  48. passed = 0
  49. print "* Testing samples..."
  50. for test in tests:
  51. # log each test's output
  52. flog.write('* Test ' + test + ' begins...\n' )
  53. flog.write('* Test ' + test + ' ended.\t')
  54. if (subprocess.call(EXEC + test + " >> " + LOG_FILE, shell=True) != 0):
  55. print 'FAILED Test [' + test + ']'
  56. flog.write('[failed]\n')
  57. failed += 1
  58. else:
  59. print 'PASSED Test [' + test + ']'
  60. flog.write(' [passed]\n')
  61. passed += 1
  62. print 'Done.'
  63. print 'Statistics: ' + str(failed) + ' failed tests' + ' | ' + \
  64. str(passed) + ' passed tests.'
  65. print 'See log file ' + LOG_FILE