|
1 "{ Package: 'jv:libgdbs/tests' }" |
|
2 |
|
3 "{ NameSpace: Smalltalk }" |
|
4 |
|
5 GDBDebuggerTestCase subclass:#GDBDebuggerTestsS |
|
6 instanceVariableNames:'simulator' |
|
7 classVariableNames:'DefaultWaitForTimeout' |
|
8 poolDictionaries:'' |
|
9 category:'GDB-Core-Tests' |
|
10 ! |
|
11 |
|
12 !GDBDebuggerTestsS class methodsFor:'documentation'! |
|
13 |
|
14 documentation |
|
15 " |
|
16 Tests for GDBDebugger (using simulator) |
|
17 |
|
18 [author:] |
|
19 Jan Vrany <jan.vrany@fit.cvut.cz> |
|
20 |
|
21 [instance variables:] |
|
22 |
|
23 [class variables:] |
|
24 |
|
25 [see also:] |
|
26 |
|
27 " |
|
28 ! ! |
|
29 |
|
30 !GDBDebuggerTestsS class methodsFor:'initialization'! |
|
31 |
|
32 initialize |
|
33 "Invoked at system start or when the class is dynamically loaded." |
|
34 |
|
35 "/ please change as required (and remove this comment) |
|
36 |
|
37 DefaultWaitForTimeout := 100. |
|
38 |
|
39 "Modified: / 27-02-2015 / 11:43:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
40 ! ! |
|
41 |
|
42 !GDBDebuggerTestsS methodsFor:'running'! |
|
43 |
|
44 tearDown |
|
45 simulator notNil ifTrue:[ simulator stop ]. |
|
46 debugger notNil ifTrue:[ debugger release ]. |
|
47 |
|
48 "Created: / 06-09-2014 / 02:17:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
49 ! ! |
|
50 |
|
51 !GDBDebuggerTestsS methodsFor:'tests - basic'! |
|
52 |
|
53 test_basic_02 |
|
54 simulator := GDBSimulatorProcess new record: GDBSimulatorResource session_factorial_01. |
|
55 simulator start. |
|
56 debugger := GDBDebugger newWithProcess: simulator. |
|
57 |
|
58 "Created: / 24-06-2014 / 09:09:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
59 "Modified: / 06-09-2014 / 02:18:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
60 ! ! |
|
61 |
|
62 !GDBDebuggerTestsS methodsFor:'tests - threads'! |
|
63 |
|
64 test_inferiors_01a |
|
65 | tgevent tevent blocker | |
|
66 |
|
67 blocker := Semaphore new. |
|
68 simulator := GDBSimulatorProcess new record: GDBSimulatorResource session_factorial_01. |
|
69 simulator start. |
|
70 debugger := GDBDebugger newWithProcess: simulator. |
|
71 debugger announcer when: GDBThreadGroupEvent do:[:ev | |
|
72 tgevent := ev. |
|
73 ]. |
|
74 debugger announcer when: GDBThreadEvent do:[:ev | |
|
75 tevent := ev. |
|
76 ]. |
|
77 debugger send: (GDBMI_file_exec_and_symbols new arguments: {'/home/jv/Private/Projects/SmalltalkX/sources/branches/jv1/build/jv/libgdbs/tests/c/factorial'}). |
|
78 debugger send: (GDBCLICommand new value: 'b factorial'). |
|
79 |
|
80 self assert: debugger inferiors size == 1. |
|
81 self assert: debugger inferiors anElement id = 'i1'. |
|
82 "/ No, following won't work as thread-group-added event is |
|
83 "/ emited before we register the handler above!! |
|
84 "/ self assert: debugger inferiors anElement == event threadGroup. |
|
85 |
|
86 self |
|
87 do:[ debugger send: (GDBCLICommand new value: 'r') ] |
|
88 thenWaitFor: GDBStoppedEvent. |
|
89 |
|
90 self assert: tgevent notNil. |
|
91 self assert: tevent notNil. |
|
92 self assert: debugger inferiors size == 1. |
|
93 self assert: debugger inferiors anElement pid = 7719. |
|
94 self assert: debugger inferiors anElement == tgevent threadGroup. |
|
95 self assert: debugger inferiors anElement threads size == 1. |
|
96 self assert: debugger inferiors anElement threads anElement == tevent thread. |
|
97 self assert: debugger inferiors anElement threads anElement isTerminated not. |
|
98 self assert: debugger inferiors anElement threads anElement isRunning not. |
|
99 self assert: debugger inferiors anElement threads anElement isStopped. |
|
100 self assert: debugger inferiors anElement threads anElement stack size == 2. |
|
101 |
|
102 tgevent := tevent := nil. |
|
103 |
|
104 debugger send: (GDBCLICommand new value: 'del 1'). |
|
105 tgevent := self |
|
106 do:[ debugger send: (GDBCLICommand new value: 'c') ] |
|
107 thenWaitFor: GDBThreadGroupExitedEvent. |
|
108 |
|
109 self assert: tgevent notNil. |
|
110 self assert: debugger inferiors size == 1. |
|
111 self assert: debugger inferiors anElement exitCode = 23. |
|
112 self assert: debugger inferiors anElement == tgevent threadGroup. |
|
113 "/ When thread group exits, all it's threads are dead so |
|
114 "/ inferior threads should return an empty collection. |
|
115 self assert: debugger inferiors anElement threads isEmptyOrNil. |
|
116 |
|
117 "Created: / 07-09-2014 / 13:37:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
118 "Modified: / 27-02-2015 / 12:42:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
119 ! ! |
|
120 |
|
121 !GDBDebuggerTestsS class methodsFor:'documentation'! |
|
122 |
|
123 version_HG |
|
124 |
|
125 ^ '$Changeset: <not expanded> $' |
|
126 ! ! |
|
127 |
|
128 |
|
129 GDBDebuggerTestsS initialize! |