Skip to content
Snippets Groups Projects
Commit eb17799f authored by Łukasz Plewa's avatar Łukasz Plewa Committed by Grzegorz Brzeziński
Browse files

test: fix failing pmemdetect on windows

After pmem/pmdk#3099 pmemdetect on windows was silently failing due to
missing access to libpmem which was moved to a different directory.
To fix this issue we have to append lib directory to the PATH variable.

This change moves pmemdetect related code to a separate
thread (separate shell), as we should not modify PATH
variable in the user shell.
parent 1245116a
No related branches found
No related tags found
No related merge requests found
...@@ -365,32 +365,49 @@ if ($Env:NON_PMEM_FS_DIR -And (-Not (isDir($Env:NON_PMEM_FS_DIR)))) { ...@@ -365,32 +365,49 @@ if ($Env:NON_PMEM_FS_DIR -And (-Not (isDir($Env:NON_PMEM_FS_DIR)))) {
throw "error: NON_PMEM_FS_DIR=$Env:NON_PMEM_FS_DIR doesn't exist" throw "error: NON_PMEM_FS_DIR=$Env:NON_PMEM_FS_DIR doesn't exist"
} }
$PMEMDETECT="..\x64\Debug\tests\pmemdetect.exe" # run this code in the separate thread to not pollute PATH variable in user shell.
Start-Job -Name $name -Args $PSScriptRoot -ScriptBlock {
param ([string]$dir)
cd $dir
# in script block there is no access to other functions
function isDir {
if (-Not $args[0]) {
return $false
}
return Test-Path $args[0] -PathType Container
}
if (-Not (Test-Path $PMEMDETECT)) { $PMEMDETECT="..\x64\Debug\tests\pmemdetect.exe"
$PMEMDETECT="..\x64\Release\tests\pmemdetect.exe"
}
if (isDir($Env:PMEM_FS_DIR)) { if (-Not (Test-Path $PMEMDETECT)) {
if ($Env:PMEM_FS_DIR_FORCE_PMEM -eq "1") { $PMEMDETECT="..\x64\Release\tests\pmemdetect.exe"
# "0" means there is PMEM $Env:Path = "..\x64\Release\libs;" + $Env:Path
$Local:PMEM_IS_PMEM = "0"
} else { } else {
&$PMEMDETECT $Env:PMEM_FS_DIR $Env:Path = "..\x64\Debug\libs;" + $Env:Path
$Local:PMEM_IS_PMEM = $Global:LASTEXITCODE
} }
if ($Local:PMEM_IS_PMEM -ne "0") {
throw "error: PMEM_FS_DIR=$Env:PMEM_FS_DIR does not point to a PMEM device"
}
}
if (isDir($Env:NON_PMEM_FS_DIR)) { if (isDir($Env:PMEM_FS_DIR)) {
&$PMEMDETECT $Env:NON_PMEM_FS_DIR if ($Env:PMEM_FS_DIR_FORCE_PMEM -eq "1") {
$Local:NON_PMEM_IS_PMEM = $Global:LASTEXITCODE # "0" means there is PMEM
$Local:PMEM_IS_PMEM = "0"
} else {
&$PMEMDETECT $Env:PMEM_FS_DIR
$Local:PMEM_IS_PMEM = $Global:LASTEXITCODE
}
if ($Local:NON_PMEM_IS_PMEM -eq "0") { if ($Local:PMEM_IS_PMEM -ne "0") {
throw "error: NON_PMEM_FS_DIR=$Env:NON_PMEM_FS_DIR does not point to a non-PMEM device" throw "error: PMEM_FS_DIR=$Env:PMEM_FS_DIR does not point to a PMEM device"
}
} }
}
if (isDir($Env:NON_PMEM_FS_DIR)) {
&$PMEMDETECT $Env:NON_PMEM_FS_DIR
$Local:NON_PMEM_IS_PMEM = $Global:LASTEXITCODE
if ($Local:NON_PMEM_IS_PMEM -eq "0") {
throw "error: NON_PMEM_FS_DIR=$Env:NON_PMEM_FS_DIR does not point to a non-PMEM device"
}
}
} | Receive-Job -Wait -AutoRemoveJob
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment