Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

83 wiersze
2.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. $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_job.c"
  29. "$workspacePath\PLSR\Src\plsr_core.c"
  30. "$workspacePath\PLSR\Test\test_plsr_core.c"
  31. )
  32. },
  33. @{
  34. Name = 'test_plsr_job'
  35. Sources = @(
  36. "$workspacePath\PLSR\Src\plc_device.c"
  37. "$workspacePath\PLSR\Src\plsr_persistence.c"
  38. "$workspacePath\PLSR\Src\plsr_resource.c"
  39. "$workspacePath\PLSR\Src\plsr_job.c"
  40. "$workspacePath\PLSR\Src\plsr_core.c"
  41. "$workspacePath\PLSR\Test\test_plsr_job.c"
  42. )
  43. }
  44. )
  45. foreach ($test in $tests)
  46. {
  47. $outputPath = Join-Path $outputDirectory "$($test.Name).exe"
  48. $arguments = @(
  49. '-std=c11'
  50. '-Wall'
  51. '-Wextra'
  52. '-Werror'
  53. '-DPLSR_HOST_TEST'
  54. "-I$workspacePath\PLSR\Inc"
  55. ) + $test.Sources + @('-o', $outputPath)
  56. try
  57. {
  58. & $compiler.Source @arguments
  59. if ($LASTEXITCODE -ne 0)
  60. {
  61. throw "$($test.Name) compilation failed with exit code $LASTEXITCODE."
  62. }
  63. & $outputPath
  64. if ($LASTEXITCODE -ne 0)
  65. {
  66. throw "$($test.Name) failed with exit code $LASTEXITCODE."
  67. }
  68. }
  69. finally
  70. {
  71. if (Test-Path -LiteralPath $outputPath)
  72. {
  73. Remove-Item -LiteralPath $outputPath -Force
  74. }
  75. }
  76. }