Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

71 строка
1.8 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. $outputDirectory = Join-Path $workspacePath 'tmp'
  9. if (-not (Test-Path -LiteralPath $outputDirectory))
  10. {
  11. New-Item -ItemType Directory -Path $outputDirectory | Out-Null
  12. }
  13. $tests = @(
  14. @{
  15. Name = 'test_plc_device'
  16. Sources = @(
  17. "$workspacePath\PLSR\Src\plc_device.c"
  18. "$workspacePath\PLSR\Src\plsr_persistence.c"
  19. "$workspacePath\PLSR\Test\test_plc_device.c"
  20. )
  21. },
  22. @{
  23. Name = 'test_plsr_core'
  24. Sources = @(
  25. "$workspacePath\PLSR\Src\plc_device.c"
  26. "$workspacePath\PLSR\Src\plsr_persistence.c"
  27. "$workspacePath\PLSR\Src\plsr_resource.c"
  28. "$workspacePath\PLSR\Src\plsr_core.c"
  29. "$workspacePath\PLSR\Test\test_plsr_core.c"
  30. )
  31. }
  32. )
  33. foreach ($test in $tests)
  34. {
  35. $outputPath = Join-Path $outputDirectory "$($test.Name).exe"
  36. $arguments = @(
  37. '-std=c11'
  38. '-Wall'
  39. '-Wextra'
  40. '-Werror'
  41. '-DPLSR_HOST_TEST'
  42. "-I$workspacePath\PLSR\Inc"
  43. ) + $test.Sources + @('-o', $outputPath)
  44. try
  45. {
  46. & $compiler.Source @arguments
  47. if ($LASTEXITCODE -ne 0)
  48. {
  49. throw "$($test.Name) compilation failed with exit code $LASTEXITCODE."
  50. }
  51. & $outputPath
  52. if ($LASTEXITCODE -ne 0)
  53. {
  54. throw "$($test.Name) failed with exit code $LASTEXITCODE."
  55. }
  56. }
  57. finally
  58. {
  59. if (Test-Path -LiteralPath $outputPath)
  60. {
  61. Remove-Item -LiteralPath $outputPath -Force
  62. }
  63. }
  64. }