diff options
Diffstat (limited to 'cpp/src')
| -rw-r--r-- | cpp/src/tests/background.ps1 | 21 | ||||
| -rw-r--r-- | cpp/src/tests/start_broker.ps1 | 21 | ||||
| -rw-r--r-- | cpp/src/tests/stop_broker.ps1 | 17 |
3 files changed, 53 insertions, 6 deletions
diff --git a/cpp/src/tests/background.ps1 b/cpp/src/tests/background.ps1 index 934078602b..36e9e4e6e9 100644 --- a/cpp/src/tests/background.ps1 +++ b/cpp/src/tests/background.ps1 @@ -30,11 +30,26 @@ trap { break } $encodedScript = [convert]::ToBase64String(
[Text.Encoding]::Unicode.GetBytes([string] $script))
-$p = new-object System.Diagnostics.Process
+#$p = new-object System.Diagnostics.Process
$si = new-object System.Diagnostics.ProcessStartInfo
$si.WorkingDirectory = $pwd
-$si.UseShellExecute = $true
$si.FileName = (get-command powershell.exe).Definition
$si.Arguments = "-encodedCommand $encodedScript"
-[diagnostics.process]::Start($si)
+###### debugging setup
+#$si.CreateNoWindow = $true
+# UseShellExecute false required for RedirectStandard(Error, Output)
+#$si.UseShellExecute = $false
+#$si.RedirectStandardError = $true
+#$si.RedirectStandardOutput = $true
+######
+$si.UseShellExecute = $true
+
+##### Debugging, instead of the plain Start() above.
+#$output = [io.File]::AppendText("start.out")
+#$error = [io.File]::AppendText("start.err")
+$p = [System.Diagnostics.Process]::Start($si)
+#$output.WriteLine($p.StandardOutput.ReadToEnd())
+#$error.WriteLine($p.StandardError.ReadToEnd())
+#$p.WaitForExit()
+#$output.Close()
diff --git a/cpp/src/tests/start_broker.ps1 b/cpp/src/tests/start_broker.ps1 index f2aa20439a..9263262b9f 100644 --- a/cpp/src/tests/start_broker.ps1 +++ b/cpp/src/tests/start_broker.ps1 @@ -28,9 +28,26 @@ function Get-ScriptPath if (Test-Path qpidd.port) { Remove-Item qpidd.port } + +# Test runs from the tests directory but the broker executable is one level +# up, and most likely in a subdirectory from there based on what build type. +# Look around for it before trying to start it. +$subs = "Debug","Release","MinSizeRel","RelWithDebInfo" +foreach ($sub in $subs) { + $prog = "..\$sub\qpidd.exe" + if (Test-Path $prog) { + break + } +} +if (!(Test-Path $prog)) { + "Cannot locate qpidd.exe" + exit 1 +} +$cmdline = "$prog --auth=no --no-module-dir --port=0 --log-to-file qpidd.log $args | foreach { set-content qpidd.port `$_ }" +$cmdblock = $executioncontext.invokecommand.NewScriptBlock($cmdline) $srcdir = Get-ScriptPath -. $srcdir\background.ps1 { - ..\Debug\qpidd --auth=no --no-module-dir --port=0 --log-to-file qpidd.log $args | foreach { set-content qpidd.port $_ } } +. $srcdir\background.ps1 $cmdblock + $wait_time = 0 while (!(Test-Path qpidd.port) -and ($wait_time -lt 10)) { Start-Sleep 2 diff --git a/cpp/src/tests/stop_broker.ps1 b/cpp/src/tests/stop_broker.ps1 index 165c7a63b0..4fdeb26e2b 100644 --- a/cpp/src/tests/stop_broker.ps1 +++ b/cpp/src/tests/stop_broker.ps1 @@ -21,8 +21,23 @@ Get-Content -path qpidd.port -totalCount 1 | Set-Variable -name qpid_port Remove-Item qpidd.port +# Test runs from the tests directory but the broker executable is one level +# up, and most likely in a subdirectory from there based on what build type. +# Look around for it before trying to start it. +$subs = "Debug","Release","MinSizeRel","RelWithDebInfo" +foreach ($sub in $subs) { + $prog = "..\$sub\qpidd.exe" + if (Test-Path $prog) { + break + } +} +if (!(Test-Path $prog)) { + "Cannot locate qpidd.exe" + exit 1 +} + # Piping the output makes the script wait for qpidd to finish. -..\Debug\qpidd --quit --port $qpid_port | Write-Output +Invoke-Expression "$prog --quit --port $qpid_port" | Write-Output $stopped = $? # Check qpidd.log. |
