fork download
  1. import os
  2. from time import time
  3.  
  4. SOURCE_CODE_DIR = '/media/tarun/New Volume/Source codes'
  5. TEST_DIR = '/home/tarun/Desktop/param'
  6. SOURCE_FILE = 'aaaa.cpp'
  7. EXE_FILE = 'aaaa.exe'
  8. OUTPUT_FILE = '/home/tarun/Desktop/output.txt'
  9.  
  10. os.chdir(TEST_DIR)
  11. files = os.listdir()
  12. input_files = [file for file in files if '.in' in file]
  13. output_files = [file.replace('.in', '.out') for file in input_files]
  14.  
  15. assert len(input_files) == len(output_files)
  16.  
  17. os.chdir(SOURCE_CODE_DIR)
  18. if os.system('g++ -o ' + EXE_FILE + ' --std=c++11 -D CP ' + SOURCE_FILE):
  19. print("Compilation failed")
  20. exit(0)
  21.  
  22. for i in range(len(input_files)):
  23. infile = TEST_DIR + '/' + input_files[i]
  24. outfile = TEST_DIR + '/' + output_files[i]
  25. infile = infile.replace(' ', '\\ ')
  26. outfile = outfile.replace(' ', '\\ ')
  27. print('Testing on', input_files[i])
  28. tic = time()
  29. os.system('./' + EXE_FILE + ' < ' + infile + ' > ' + OUTPUT_FILE)
  30. print('Time (in ms): %.3f' %(1000*(time()-tic)))
  31. os.system('diff ' + outfile + ' ' + OUTPUT_FILE)
  32. print('')
Runtime error #stdin #stdout #stderr 0.01s 27728KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 10, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/home/tarun/Desktop/param'