source: branches/fault_tolerance/softs/test_llsc/scripts/run_simus.py @ 728

Last change on this file since 728 was 724, checked in by cfuguet, 10 years ago

branches/fault_tolerance:

  • Recreating fault_tolerance branch with all new modifications from trunk.
  • Introducing distributed boot rom in the tsar_generic_iob platform
  • Property svn:executable set to *
File size: 3.2 KB
Line 
1#!/usr/bin/python
2
3import subprocess
4import os
5import random
6
7data_dir = 'data'
8gen_dir = 'generated'
9test_gen_tool_dir = 'LLSCTestGenerator'
10
11test_gen_binary = 'generate_test'
12
13log_init_name = 'log_init_'
14log_term_name = 'log_term_'
15
16generated_test = 'test_llsc.c'
17main_task = 'test_llsc_main.c'
18task_no_tty = 'test_llsc_no_tty.c'
19
20res_natif = 'res_natif.txt'
21
22# Parametres des tests
23nb_locks = 20
24nb_max_incr = 2000
25nb_procs = 64
26
27
28os.chdir(os.path.dirname(__file__))
29
30scripts_path = os.path.abspath(".")
31top_path = os.path.abspath("../")
32
33topcell_name = "top.cpp"
34
35
36random.seed()
37
38
39def get_x_y(nb_procs):
40   x = 1
41   y = 1
42   to_x = True
43   while (x * y * 4 < nb_procs):
44      if to_x:
45         x = x * 2
46      else:
47         y = y * 2
48      to_x = not to_x
49   return x, y
50
51
52print "make -C", test_gen_tool_dir
53subprocess.call([ 'make', '-C', test_gen_tool_dir ])
54
55print "cp", os.path.join(test_gen_tool_dir, test_gen_binary), os.path.join(scripts_path, test_gen_binary)
56subprocess.call([ 'cp', os.path.join(test_gen_tool_dir, test_gen_binary), os.path.join(scripts_path, test_gen_binary)])
57
58print "mkdir -p", os.path.join(scripts_path, data_dir)
59subprocess.call([ 'mkdir', '-p', os.path.join(scripts_path, data_dir) ])
60
61while True:
62   x, y = get_x_y(nb_procs)
63   
64   b0 = random.randint(0, 1)
65   b1 = random.randint(0, 1)
66
67   print test_gen_binary, nb_procs, nb_max_incr, nb_locks, b0, b1, generated_test, main_task, task_no_tty
68   tab_size = subprocess.Popen([ os.path.join(scripts_path, test_gen_binary), str(nb_procs), str(nb_max_incr), str(nb_locks), str(b0), str(b1), generated_test, main_task, task_no_tty ], stdout = subprocess.PIPE).communicate()[0]
69   
70   print "make -f Makefile.nat"
71   subprocess.call([ 'make', '-f', 'Makefile.nat' ])
72
73   print "./test_natif >", os.path.join(data_dir, res_natif)
74   output = subprocess.Popen([ './test_natif' ], stdout = subprocess.PIPE).communicate()[0]
75   file = open(os.path.join(data_dir, res_natif), 'w')
76   file.write(output)
77   file.close()
78
79   print "./test_llsc.py", str(x), str(y), tab_size
80   subprocess.call([ './test_llsc.py', str(x), str(y), tab_size ])
81   
82   print "cd", top_path
83   os.chdir(top_path)
84   print "touch", topcell_name
85   subprocess.call([ 'touch', topcell_name ])
86   print "make"
87   subprocess.call([ 'make' ])
88   
89   # Launch simulation
90   print "./simul.x >", os.path.join(scripts_path, data_dir, log_init_name + str(nb_procs))
91   output = subprocess.Popen([ './simul.x' ], stdout = subprocess.PIPE).communicate()[0]
92
93   # Write simulation results to data directory
94   print "cd", scripts_path
95   os.chdir(scripts_path)
96   filename = os.path.join(data_dir, log_init_name + str(nb_procs))
97   file = open(filename, 'w')
98   file.write(output)
99   file.close()
100
101   term_filename = os.path.join(scripts_path, data_dir, log_term_name + str(nb_procs))
102   print "mv", os.path.join(top_path, 'term1'), term_filename
103   subprocess.call([ 'mv', os.path.join(top_path, 'term1'), term_filename ])
104   
105   # Quit if results obtained by simulation are incorrect
106   print "diff", term_filename, os.path.join(data_dir, res_natif)
107   output = subprocess.Popen([ 'diff', term_filename, os.path.join(data_dir, res_natif) ], stdout = subprocess.PIPE).communicate()[0]
108   if output != "":
109      break;
110
111
112## Enf of simulations
113
114
115
116
117
118
119
120
121
Note: See TracBrowser for help on using the repository browser.