From 471552c6e4c9a2b1456a84888a8c9f78e87a3151 Mon Sep 17 00:00:00 2001 From: Jan Vrany Date: Tue, 3 Sep 2024 15:30:18 +0100 Subject: [PATCH] Randomize port number for QEMU's debug stub This commit makes TCP port to use for QEMU's debug stub random, using disjoint ranges on Smalltalk/X and Pharo. This allows one to run tests on both in parallel. --- .../TRCompilationTestShellQEMU.class.st | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Tinyrossa-Tests/TRCompilationTestShellQEMU.class.st b/src/Tinyrossa-Tests/TRCompilationTestShellQEMU.class.st index 5db8750..935db76 100644 --- a/src/Tinyrossa-Tests/TRCompilationTestShellQEMU.class.st +++ b/src/Tinyrossa-Tests/TRCompilationTestShellQEMU.class.st @@ -4,16 +4,34 @@ Class { #instVars : [ 'qemu' ], + #classVars : [ + 'QemuDebugPortRandom' + ], #category : #'Tinyrossa-Tests-Shells' } +{ #category : #initialization } +TRCompilationTestShellQEMU class >> initialize [ + QemuDebugPortRandom := Random new seed: 1234 +] + { #category : #running } TRCompilationTestShellQEMU >> setUp [ - | qemuCmd | + | qemuDebugPort qemuCmd | super setUp. - qemuCmd := target qemu, ' -g 1234 ', binary pathString. + "Randomize port where QEMU's debug stub is listening. + This is to allow running tests simultaneously on both + Smalltalk/X and Pharo (as they take some time to finish)." + + Smalltalk isSmalltalkX ifTrue: [ + qemuDebugPort := 30000 + (QemuDebugPortRandom nextInt: 1000). + ] ifFalse: [ + qemuDebugPort := 31000 + (QemuDebugPortRandom nextInt: 1000). + ]. + + qemuCmd := target qemu, ' -g ', qemuDebugPort printString, ' ', binary pathString. "First, start QEMU... " qemu := OSProcess new command: qemuCmd. @@ -22,7 +40,7 @@ TRCompilationTestShellQEMU >> setUp [ (Delay forSeconds: 1) wait. "...then setup debugger object (using either libgdbs or ULD)" - self setUpDebuggerOnHost: 'localhost' port: 1234. + self setUpDebuggerOnHost: 'localhost' port: qemuDebugPort. ] { #category : #running }