Skip to content

Commit

Permalink
Fixed a bug that prevented the automatic test mode to resume the test…
Browse files Browse the repository at this point in the history
… if the crash happened on core 0. Fixes #89
  • Loading branch information
sp00n committed Oct 27, 2024
1 parent 3c318e3 commit 7b07225
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
23 changes: 14 additions & 9 deletions helpers/automode-startup-script.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,23 @@ class AutoModeResumeFailedException: System.Exception {

# The main functionality
try {
$startDate = Get-Date
$formatDate = Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
$curTimeStamp = Get-Date -UFormat %s -Millisecond 0

# Limit the maximum time between when the test was started and when the resume script was started
$limitTimestamp = $curTimeStamp - $maxTimeLimit


Write-Text('')
Write-Text('┌────────────────────────────────────────────┐')
Write-Text('│ CoreCycler Auto Mode Recovery Script │')
Write-Text('└────────────────────────────────────────────┘')
Write-Text('')
Write-Text($formatDate)
Write-Text('Recovering from an unexpected exit (crash/reboot)')
Write-Text('')

$startDate = Get-Date
$curTimeStamp = Get-Date -UFormat %s -Millisecond 0

# Limit the maximum time between when the test was started and when the resume script was started
$limitTimestamp = $curTimeStamp - $maxTimeLimit



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

Remove-StartupTask
Expand Down Expand Up @@ -248,7 +250,10 @@ try {


# Start the script now
Start-Process -FilePath 'cmd.exe' -ArgumentList @('/C', ('"' + $scriptRoot + '\Run CoreCycler.bat"'), $coreTested)
Write-Text('Command:')
Write-Text('Start-Process -PassThru -FilePath ''cmd.exe'' -ArgumentList @(''/C'', (''"' + $scriptRoot + '\Run CoreCycler.bat"''), ' + $coreTested + ')')

$process = Start-Process -PassThru -FilePath 'cmd.exe' -ArgumentList @('/C', ('"' + $scriptRoot + '\Run CoreCycler.bat"'), $coreTested)
}

# Don't throw an error
Expand Down
14 changes: 7 additions & 7 deletions script-corecycler.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.AUTHOR
sp00n
.VERSION
0.10.0.0alpha4
0.10.0.0alpha5
.DESCRIPTION
Sets the affinity of the selected stress test program process to only one
core and cycles through all the cores which allows to test the stability of
Expand All @@ -23,7 +23,7 @@ param(


# Our current version
$version = '0.10.0.0alpha4'
$version = '0.10.0.0alpha5'


# This defines the strict mode
Expand Down Expand Up @@ -4644,7 +4644,7 @@ function Initialize-AutomaticTestMode {

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

# The setting for the automatic resume must also be activated
Expand Down Expand Up @@ -9238,7 +9238,7 @@ function Test-AutomaticTestModeIncrease {
}
}

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

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


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

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

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

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

0 comments on commit 7b07225

Please sign in to comment.