Skip to content

Commit 7b07225

Browse files
committed
Fixed a bug that prevented the automatic test mode to resume the test if the crash happened on core 0. Fixes #89
1 parent 3c318e3 commit 7b07225

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

helpers/automode-startup-script.ps1

+14-9
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,23 @@ class AutoModeResumeFailedException: System.Exception {
152152

153153
# The main functionality
154154
try {
155+
$startDate = Get-Date
156+
$formatDate = Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
157+
$curTimeStamp = Get-Date -UFormat %s -Millisecond 0
158+
159+
# Limit the maximum time between when the test was started and when the resume script was started
160+
$limitTimestamp = $curTimeStamp - $maxTimeLimit
161+
162+
155163
Write-Text('')
156164
Write-Text('┌────────────────────────────────────────────┐')
157165
Write-Text('│ CoreCycler Auto Mode Recovery Script │')
158166
Write-Text('└────────────────────────────────────────────┘')
159167
Write-Text('')
168+
Write-Text($formatDate)
160169
Write-Text('Recovering from an unexpected exit (crash/reboot)')
161170
Write-Text('')
162171

163-
$startDate = Get-Date
164-
$curTimeStamp = Get-Date -UFormat %s -Millisecond 0
165-
166-
# Limit the maximum time between when the test was started and when the resume script was started
167-
$limitTimestamp = $curTimeStamp - $maxTimeLimit
168-
169-
170172

171173
# We need to be admin to use the Auto Test Mode
172174
$weAreAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
@@ -180,7 +182,7 @@ try {
180182
if (!(Test-Path $autoModeFile -PathType Leaf)) {
181183
Write-Text('The .automode file does not exist!')
182184
Write-Text('The file is needed to be able to continue the testing process, aborting.')
183-
Write-Text('(' + $autoModeFile + ')')
185+
Write-Text('(Looking for: ' + $autoModeFile + ')')
184186
Write-Text('')
185187

186188
Remove-StartupTask
@@ -248,7 +250,10 @@ try {
248250

249251

250252
# Start the script now
251-
Start-Process -FilePath 'cmd.exe' -ArgumentList @('/C', ('"' + $scriptRoot + '\Run CoreCycler.bat"'), $coreTested)
253+
Write-Text('Command:')
254+
Write-Text('Start-Process -PassThru -FilePath ''cmd.exe'' -ArgumentList @(''/C'', (''"' + $scriptRoot + '\Run CoreCycler.bat"''), ' + $coreTested + ')')
255+
256+
$process = Start-Process -PassThru -FilePath 'cmd.exe' -ArgumentList @('/C', ('"' + $scriptRoot + '\Run CoreCycler.bat"'), $coreTested)
252257
}
253258

254259
# Don't throw an error

script-corecycler.ps1

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.AUTHOR
33
sp00n
44
.VERSION
5-
0.10.0.0alpha4
5+
0.10.0.0alpha5
66
.DESCRIPTION
77
Sets the affinity of the selected stress test program process to only one
88
core and cycles through all the cores which allows to test the stability of
@@ -23,7 +23,7 @@ param(
2323

2424

2525
# Our current version
26-
$version = '0.10.0.0alpha4'
26+
$version = '0.10.0.0alpha5'
2727

2828

2929
# This defines the strict mode
@@ -4644,7 +4644,7 @@ function Initialize-AutomaticTestMode {
46444644

46454645
# This flag indicates that the .automode file existed and the startup scheduled task was run
46464646
# So we had a crash while the script was running
4647-
if ($CoreFromAutoMode -and $CoreFromAutoMode -gt -1) {
4647+
if (-not [String]::IsNullOrWhiteSpace($CoreFromAutoMode) -and [Int]$CoreFromAutoMode -gt -1) {
46484648
Write-Debug('The CoreFromAutoMode variable was passed from the command line: ' + $CoreFromAutoMode)
46494649

46504650
# The setting for the automatic resume must also be activated
@@ -9238,7 +9238,7 @@ function Test-AutomaticTestModeIncrease {
92389238
}
92399239
}
92409240

9241-
Write-ColorText('Increasing the ' + $autoModeDescription + ' value' + $forCore + ' from ' + $oldValueStr + ' to ' + $newValueStr) Yellow
9241+
Write-ColorText('Modifying the ' + $autoModeDescription + ' value' + $forCore + ' from ' + $oldValueStr + ' to ' + $newValueStr) Yellow
92429242

92439243
if ($newValue -eq $maxValue) {
92449244
Write-ColorText('This is the maximum set ' + $autoModeDescription + ' value, there will be no further increases') Yellow
@@ -11747,7 +11747,7 @@ try {
1174711747

1174811748

1174911749
# Add the previously tested core from before the reboot if we're in Automatic Test Mode with resume
11750-
if ($useAutomaticTestModeWithResume -and $CoreFromAutoMode -gt 0) {
11750+
if ($useAutomaticTestModeWithResume -and $CoreFromAutoMode -gt -1) {
1175111751
Write-Text('')
1175211752
Write-ColorText('Apparently the computer crashed in the last run while testing core ' + $CoreFromAutoMode) Red
1175311753
Write-ColorText('Trying to resume the test process') Red
@@ -11842,7 +11842,7 @@ try {
1184211842
$coreTestOrderArray = [System.Collections.ArrayList]::new()
1184311843

1184411844
# If we had added a core from CoreFromAutoMode, we will need to push it to the front here again
11845-
if ($useAutomaticTestModeWithResume -and $CoreFromAutoMode -gt 0) {
11845+
if ($useAutomaticTestModeWithResume -and $CoreFromAutoMode -gt -1) {
1184611846
[Void] $coreTestOrderArray.Add($CoreFromAutoMode)
1184711847
}
1184811848

@@ -11875,7 +11875,7 @@ try {
1187511875
[System.Collections.ArrayList] $coreTestOrderArray = @(@($coreTestOrderArray) | Sort-Object { Get-Random })
1187611876

1187711877
# If we had added a core from CoreFromAutoMode, we will need to push it to the front here again
11878-
if ($useAutomaticTestModeWithResume -and $CoreFromAutoMode -gt 0) {
11878+
if ($useAutomaticTestModeWithResume -and $CoreFromAutoMode -gt -1) {
1187911879
[Void] $coreTestOrderArray.Insert(0, $CoreFromAutoMode)
1188011880
}
1188111881
}

0 commit comments

Comments
 (0)