You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
1.2 KiB

  1. $ErrorActionPreference = 'Stop'
  2. $workspacePath = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
  3. $compiler = Get-Command gcc.exe -ErrorAction SilentlyContinue
  4. if ($null -eq $compiler)
  5. {
  6. throw 'gcc.exe was not found; PLSR host tests cannot run.'
  7. }
  8. $outputPath = Join-Path $workspacePath 'tmp\test_plc_device.exe'
  9. $outputDirectory = Split-Path -Parent $outputPath
  10. if (-not (Test-Path -LiteralPath $outputDirectory))
  11. {
  12. New-Item -ItemType Directory -Path $outputDirectory | Out-Null
  13. }
  14. $arguments = @(
  15. '-std=c11',
  16. '-Wall',
  17. '-Wextra',
  18. '-Werror',
  19. '-DPLSR_HOST_TEST',
  20. "-I$workspacePath\PLSR\Inc",
  21. "$workspacePath\PLSR\Src\plc_device.c",
  22. "$workspacePath\PLSR\Src\plsr_persistence.c",
  23. "$workspacePath\PLSR\Test\test_plc_device.c",
  24. '-o',
  25. $outputPath
  26. )
  27. try
  28. {
  29. & $compiler.Source @arguments
  30. if ($LASTEXITCODE -ne 0)
  31. {
  32. throw "PLSR host-test compilation failed with exit code $LASTEXITCODE."
  33. }
  34. & $outputPath
  35. if ($LASTEXITCODE -ne 0)
  36. {
  37. throw "PLSR host tests failed with exit code $LASTEXITCODE."
  38. }
  39. }
  40. finally
  41. {
  42. if (Test-Path -LiteralPath $outputPath)
  43. {
  44. Remove-Item -LiteralPath $outputPath -Force
  45. }
  46. }