/[eiffelstudio]/trunk/eweasel/tests/exec184/test_mt.e
ViewVC logotype

Contents of /trunk/eweasel/tests/exec184/test_mt.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 88265 - (show annotations)
Fri Feb 3 01:43:35 2012 UTC (7 years, 7 months ago) by manus
File size: 1935 byte(s)
Adapted tests to breaking changed in class THREAD where the later requires `make' to be called as part of the creation of a THREAD object.

1 class TEST_MT
2
3 inherit
4
5 TEST
6 rename
7 make as execute,
8 report_test_result as old_report_test_result
9 end
10
11 TEST
12 rename
13 make as execute
14 redefine
15 report_test_result
16 select
17 report_test_result
18 end
19
20 THREAD
21 rename
22 make as thread_make
23 end
24
25 $THREAD_CONTROL
26
27 create
28
29 make,
30 start
31
32 feature {NONE} -- Creation
33
34 make is
35 -- Run test cases in multiple threads and report results.
36 local
37 t: TEST
38 i: INTEGER
39 do
40 thread_make
41 -- Create common structures
42 create mutex.make
43 create succeeded_tests.make_empty
44 -- Start threads
45 from
46 i := thread_count
47 until
48 i <= 0
49 loop
50 create {TEST_MT} t.start (mutex, succeeded_tests)
51 i := i - 1
52 end
53 -- Wait for thread completion
54 join_all
55 -- Report test results
56 from
57 i := 1
58 until
59 i > succeeded_tests.count
60 loop
61 old_report_test_result (i, succeeded_tests.item (i) = thread_count)
62 i := i + 1
63 end
64 end
65
66 start (m: like mutex; t: like succeeded_tests) is
67 -- Launch test cases in a new thread and register results in `t'.
68 require
69 m /= Void
70 t /= Void
71 do
72 thread_make
73 mutex := m
74 succeeded_tests := t
75 launch
76 end
77
78 feature {NONE} -- Initialization
79
80 thread_count: INTEGER is 5
81 -- Number of threads to be launched
82
83 feature {NONE} -- Statistics
84
85 succeeded_tests: ARRAY [INTEGER]
86 -- Storage to keep the number of succeded tests
87
88 report_test_result (test_number: INTEGER; succeeded: BOOLEAN) is
89 do
90 mutex.lock
91 if succeeded_tests.count < test_number then
92 succeeded_tests.force (0, test_number)
93 end
94 if succeeded then
95 succeeded_tests.put (succeeded_tests.item (test_number) + 1, test_number)
96 end
97 mutex.unlock
98 end
99
100 feature {NONE} -- Synchronization
101
102 mutex: MUTEX
103 -- Mutex to serialize access to `succeeded_tests'
104 -- from different threads
105
106 invariant
107
108 non_void_mutex: mutex /= Void
109 non_void_succeeded_tests: succeeded_tests /= Void
110
111 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23