15 if Common.has_numpy():
17 from numpy
import linalg
22 run_test = xboa.test.TestTools.run_test
23 run_test_group = xboa.test.TestTools.run_test_group
24 __float_tol = xboa.test.TestTools.__float_tol
25 parse_tests = xboa.test.TestTools.parse_tests
36 mem_usage = float(os.popen(
'ps -p %d -o %s | tail -1' % (pid,
"rss")).read())
37 print "Memory usage for process", os.getpid(), mem_usage
51 print "Allocating memory"
53 bunch_list.append(
Bunch())
54 for i
in range(10000):
55 bunch_list[-1].append(
Hit())
56 bunch_list[-1][0].get(
'x')
57 bunch_list[-1][0].set(
'x', 1.)
58 bunch_list[-1][0].set(
'global_weight', 0.5)
59 bunch_list[-1][0].get(
'global_weight')
60 bunch_list[-1].moment([
'x'])
61 Hit.clear_global_weights()
63 print "Cleaning memory"
68 bunch_list.remove(bunch_list[0])
70 Hit.clear_global_weights()
74 print "Memory usage after cleanup in Mb (target 0 Mb):",mem_usage,
'(absolute)',mem_usage-mem_usage_b4,
'(difference)'
75 if mem_usage-mem_usage_b4 > 1000.:
return "warn"
79 data = os.path.join(
'/', sys.prefix,
'share' ,
'xboa',
'data')
80 temp = tempfile.mkstemp()[1]
81 print 'Writing test xboa9f data to ', temp
82 proc = subprocess.Popen([
'XBOA9f',
83 '-i='+data+
'/for009.dat',
84 '-c='+data+
'/ecalc9f.inp',
87 if proc.returncode == 0:
94 os.chdir(os.path.expandvars(
'$HOME'))
95 proc = subprocess.Popen([
'python',
'-m',
'xboa.examples.'+example_name],
96 stdin=subprocess.PIPE)
98 proc.communicate(input=
'\n')
101 if proc.returncode != 0:
108 run_test(test_results, system_mem_test, () )
109 run_test(test_results, system_xboa9f_test_1, ())
110 run_test(test_results, test_example, (
'Example_1',) )
111 run_test(test_results, test_example, (
'Example_2',) )
112 run_test(test_results, test_example, (
'Example_3',) )
113 run_test(test_results, test_example, (
'Example_4',) )
115 print '\n==============\n|| SYSTEM ||\n=============='
116 print 'Passed ',passes,
' tests\nFailed ',fails,
' tests\n',warns,
' warnings\n\n\n'
117 return (passes,fails,warns)
123 if __name__ ==
'__main__':