Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

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