-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathtest-phase5-e2e.lua
More file actions
321 lines (256 loc) · 10.1 KB
/
test-phase5-e2e.lua
File metadata and controls
321 lines (256 loc) · 10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
--[[
E2E Test Script for Phase 5: TAS-Style Debugging
This script tests the complete Phase 5 feature set:
- 5.1: Lua Scripting Integration
- 5.2: Variable History Recording
- 5.4: Watchpoint Scripting
- 5.5: Force Replay
Prerequisites:
- SAP system accessible
- SAP credentials configured (environment variables)
- ZTEST program exists with breakpointable code
Usage:
./vsp lua examples/scripts/test-phase5-e2e.lua
--]]
print("=" .. string.rep("=", 70))
print("vsp Phase 5: TAS-Style Debugging - E2E Test Suite")
print("=" .. string.rep("=", 70))
print("")
local tests_passed = 0
local tests_failed = 0
local tests_skipped = 0
-- Helper function to run a test
local function test(name, fn)
io.write("TEST: " .. name .. " ... ")
local ok, err = pcall(fn)
if ok then
print("PASS")
tests_passed = tests_passed + 1
return true
else
if string.find(tostring(err), "SKIP") then
print("SKIP: " .. string.gsub(tostring(err), ".*SKIP: ", ""))
tests_skipped = tests_skipped + 1
else
print("FAIL: " .. tostring(err))
tests_failed = tests_failed + 1
end
return false
end
end
-- Helper to skip a test
local function skip(reason)
error("SKIP: " .. reason)
end
-- ============================================================================
-- Phase 5.1: Lua Scripting Integration
-- ============================================================================
print("\n--- Phase 5.1: Lua Scripting Integration ---\n")
test("print() function works", function()
-- We're already using print, so this is a sanity check
assert(type(print) == "function", "print is not a function")
end)
test("sleep() function exists", function()
assert(type(sleep) == "function", "sleep is not a function")
end)
test("json.encode() works", function()
local data = {name = "test", value = 42}
local encoded = json.encode(data)
assert(encoded ~= nil, "json.encode returned nil")
assert(string.find(encoded, "name"), "encoded JSON missing 'name'")
assert(string.find(encoded, "test"), "encoded JSON missing 'test'")
end)
test("json.decode() works", function()
local jsonStr = '{"name": "hello", "count": 10}'
local data = json.decode(jsonStr)
assert(data ~= nil, "json.decode returned nil")
assert(data.name == "hello", "data.name mismatch")
assert(data.count == 10, "data.count mismatch")
end)
test("json round-trip preserves data", function()
local original = {
string_val = "hello world",
number_val = 42,
bool_val = true,
nested = {a = 1, b = 2}
}
local encoded = json.encode(original)
local decoded = json.decode(encoded)
assert(decoded.string_val == original.string_val, "string mismatch")
assert(decoded.number_val == original.number_val, "number mismatch")
assert(decoded.bool_val == original.bool_val, "bool mismatch")
assert(decoded.nested.a == 1, "nested.a mismatch")
end)
-- ============================================================================
-- Phase 5.2: Variable History Recording (Unit Tests)
-- ============================================================================
print("\n--- Phase 5.2: Variable History Recording ---\n")
test("startRecording() function exists", function()
assert(type(startRecording) == "function", "startRecording not found")
end)
test("stopRecording() function exists", function()
assert(type(stopRecording) == "function", "stopRecording not found")
end)
test("getRecording() function exists", function()
assert(type(getRecording) == "function", "getRecording not found")
end)
test("startRecording() creates a recording", function()
startRecording("e2e-test-session", "ZTEST_E2E")
local info = getRecording()
assert(info ~= nil, "getRecording returned nil after start")
end)
test("stopRecording() returns statistics", function()
-- Start fresh
startRecording("e2e-stats-test", "ZTEST_E2E")
local stats = stopRecording()
assert(stats ~= nil, "stopRecording returned nil")
end)
test("getStateAtStep() function exists", function()
assert(type(getStateAtStep) == "function", "getStateAtStep not found")
end)
test("findWhenChanged() function exists", function()
assert(type(findWhenChanged) == "function", "findWhenChanged not found")
end)
test("findChanges() function exists", function()
assert(type(findChanges) == "function", "findChanges not found")
end)
-- ============================================================================
-- Phase 5.4: Watchpoint Scripting (Function Existence)
-- ============================================================================
print("\n--- Phase 5.4: Watchpoint Scripting ---\n")
test("setBreakpoint() exists", function()
assert(type(setBreakpoint) == "function", "setBreakpoint not found")
end)
test("setStatementBP() exists", function()
assert(type(setStatementBP) == "function", "setStatementBP not found")
end)
test("setExceptionBP() exists", function()
assert(type(setExceptionBP) == "function", "setExceptionBP not found")
end)
test("setMessageBP() exists", function()
assert(type(setMessageBP) == "function", "setMessageBP not found")
end)
test("setBadiBP() exists", function()
assert(type(setBadiBP) == "function", "setBadiBP not found")
end)
test("setEnhancementBP() exists", function()
assert(type(setEnhancementBP) == "function", "setEnhancementBP not found")
end)
test("setWatchpoint() exists", function()
assert(type(setWatchpoint) == "function", "setWatchpoint not found")
end)
test("setMethodBP() exists", function()
assert(type(setMethodBP) == "function", "setMethodBP not found")
end)
test("getBreakpoints() exists", function()
assert(type(getBreakpoints) == "function", "getBreakpoints not found")
end)
test("deleteBreakpoint() exists", function()
assert(type(deleteBreakpoint) == "function", "deleteBreakpoint not found")
end)
-- ============================================================================
-- Phase 5.5: Force Replay
-- ============================================================================
print("\n--- Phase 5.5: Force Replay ---\n")
test("saveCheckpoint() exists", function()
assert(type(saveCheckpoint) == "function", "saveCheckpoint not found")
end)
test("getCheckpoint() exists", function()
assert(type(getCheckpoint) == "function", "getCheckpoint not found")
end)
test("listCheckpoints() exists", function()
assert(type(listCheckpoints) == "function", "listCheckpoints not found")
end)
test("injectCheckpoint() exists", function()
assert(type(injectCheckpoint) == "function", "injectCheckpoint not found")
end)
test("forceReplay() exists", function()
assert(type(forceReplay) == "function", "forceReplay not found")
end)
test("replayFromStep() exists", function()
assert(type(replayFromStep) == "function", "replayFromStep not found")
end)
test("setVariable() exists", function()
assert(type(setVariable) == "function", "setVariable not found")
end)
-- ============================================================================
-- Checkpoint Workflow Test (No ADT Required)
-- ============================================================================
print("\n--- Checkpoint Workflow (Local) ---\n")
test("saveCheckpoint() saves data locally", function()
-- This works without ADT because checkpoints are in-memory
-- but saveCheckpoint needs variables from getVariables which requires ADT
-- Skip for now
skip("requires active debug session")
end)
test("listCheckpoints() returns array", function()
local list = listCheckpoints()
assert(type(list) == "table", "listCheckpoints should return table")
end)
-- ============================================================================
-- ADT Integration Tests (Require SAP System)
-- ============================================================================
print("\n--- ADT Integration (Requires SAP) ---\n")
-- Check if we can search (indicates ADT connection)
local function check_adt_connection()
local ok, result = pcall(function()
return searchObject("ZTEST*", 1)
end)
return ok and result ~= nil
end
local adt_available = check_adt_connection()
if not adt_available then
print("NOTICE: SAP system not available, skipping ADT integration tests")
print("")
end
test("searchObject() can find ZTEST programs", function()
if not adt_available then skip("SAP not available") end
local results = searchObject("ZTEST*", 5)
assert(results ~= nil, "searchObject returned nil")
-- Don't require specific results, just that it works
end)
test("getBreakpoints() can list breakpoints", function()
if not adt_available then skip("SAP not available") end
local bps = getBreakpoints()
assert(bps ~= nil, "getBreakpoints returned nil")
end)
-- ============================================================================
-- Recording Integration Test (With Debug Session)
-- ============================================================================
print("\n--- Recording Integration (Requires Debug Session) ---\n")
test("Full recording workflow", function()
if not adt_available then skip("SAP not available") end
skip("requires manual debug session setup")
-- This would be the full test:
-- 1. Set breakpoint
-- 2. Start recording
-- 3. Trigger debuggee
-- 4. Step through
-- 5. Stop recording
-- 6. Query history
end)
test("Force Replay workflow", function()
if not adt_available then skip("SAP not available") end
skip("requires manual debug session setup")
-- This would test:
-- 1. Load a saved recording
-- 2. forceReplay to inject state
-- 3. Verify variables were set
end)
-- ============================================================================
-- Summary
-- ============================================================================
print("")
print("=" .. string.rep("=", 70))
print("Test Summary")
print("=" .. string.rep("=", 70))
print(string.format(" PASSED: %d", tests_passed))
print(string.format(" FAILED: %d", tests_failed))
print(string.format(" SKIPPED: %d", tests_skipped))
print("=" .. string.rep("=", 70))
if tests_failed > 0 then
print("\nSome tests FAILED!")
os.exit(1)
else
print("\nAll tests PASSED!")
end