Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

104 Zeilen
2.9 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. Name = 'test_plsr_profile'
  60. Sources = @(
  61. "$workspacePath\PLSR\Src\plsr_profile.c"
  62. "$workspacePath\PLSR\Test\test_plsr_profile.c"
  63. )
  64. }
  65. )
  66. foreach ($test in $tests)
  67. {
  68. $outputPath = Join-Path $outputDirectory "$($test.Name).exe"
  69. $arguments = @(
  70. '-std=c11'
  71. '-Wall'
  72. '-Wextra'
  73. '-Werror'
  74. '-DPLSR_HOST_TEST'
  75. "-I$workspacePath\PLSR\Inc"
  76. ) + $test.Sources + @('-o', $outputPath, '-lm')
  77. try
  78. {
  79. & $compiler.Source @arguments
  80. if ($LASTEXITCODE -ne 0)
  81. {
  82. throw "$($test.Name) compilation failed with exit code $LASTEXITCODE."
  83. }
  84. & $outputPath
  85. if ($LASTEXITCODE -ne 0)
  86. {
  87. throw "$($test.Name) failed with exit code $LASTEXITCODE."
  88. }
  89. }
  90. finally
  91. {
  92. if (Test-Path -LiteralPath $outputPath)
  93. {
  94. Remove-Item -LiteralPath $outputPath -Force
  95. }
  96. }
  97. }