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.
 
 
 
 
 
 

138 Zeilen
4.3 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_plsr_position'
  16. Sources = @(
  17. "$workspacePath\PLSR\Src\plsr_position.c"
  18. "$workspacePath\PLSR\Test\test_plsr_position.c"
  19. )
  20. },
  21. @{
  22. Name = 'test_plc_device'
  23. Sources = @(
  24. "$workspacePath\PLSR\Src\plsr_position.c"
  25. "$workspacePath\PLSR\Src\plc_device.c"
  26. "$workspacePath\PLSR\Src\plsr_persistence.c"
  27. "$workspacePath\PLSR\Test\test_plc_device.c"
  28. )
  29. },
  30. @{
  31. Name = 'test_plsr_core'
  32. Sources = @(
  33. "$workspacePath\PLSR\Src\plsr_position.c"
  34. "$workspacePath\PLSR\Src\plc_device.c"
  35. "$workspacePath\PLSR\Src\plsr_persistence.c"
  36. "$workspacePath\PLSR\Src\plsr_resource.c"
  37. "$workspacePath\PLSR\Src\plsr_job.c"
  38. "$workspacePath\PLSR\Src\plsr_path.c"
  39. "$workspacePath\PLSR\Src\plsr_profile.c"
  40. "$workspacePath\PLSR\Src\plsr_hal_f407.c"
  41. "$workspacePath\PLSR\Src\plsr_core.c"
  42. "$workspacePath\PLSR\Test\test_plsr_core.c"
  43. )
  44. },
  45. @{
  46. Name = 'test_plsr_job'
  47. Sources = @(
  48. "$workspacePath\PLSR\Src\plsr_position.c"
  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_profile.c"
  55. "$workspacePath\PLSR\Src\plsr_hal_f407.c"
  56. "$workspacePath\PLSR\Src\plsr_core.c"
  57. "$workspacePath\PLSR\Test\test_plsr_job.c"
  58. )
  59. },
  60. @{
  61. Name = 'test_plsr_path'
  62. Sources = @(
  63. "$workspacePath\PLSR\Src\plsr_position.c"
  64. "$workspacePath\PLSR\Src\plc_device.c"
  65. "$workspacePath\PLSR\Src\plsr_persistence.c"
  66. "$workspacePath\PLSR\Src\plsr_resource.c"
  67. "$workspacePath\PLSR\Src\plsr_job.c"
  68. "$workspacePath\PLSR\Src\plsr_path.c"
  69. "$workspacePath\PLSR\Src\plsr_profile.c"
  70. "$workspacePath\PLSR\Src\plsr_hal_f407.c"
  71. "$workspacePath\PLSR\Src\plsr_core.c"
  72. "$workspacePath\PLSR\Test\test_plsr_path.c"
  73. )
  74. },
  75. @{
  76. Name = 'test_plsr_profile'
  77. Sources = @(
  78. "$workspacePath\PLSR\Src\plsr_position.c"
  79. "$workspacePath\PLSR\Src\plsr_profile.c"
  80. "$workspacePath\PLSR\Test\test_plsr_profile.c"
  81. )
  82. },
  83. @{
  84. Name = 'test_plsr_hal'
  85. Sources = @(
  86. "$workspacePath\PLSR\Src\plsr_position.c"
  87. "$workspacePath\PLSR\Src\plc_device.c"
  88. "$workspacePath\PLSR\Src\plsr_persistence.c"
  89. "$workspacePath\PLSR\Src\plsr_resource.c"
  90. "$workspacePath\PLSR\Src\plsr_job.c"
  91. "$workspacePath\PLSR\Src\plsr_path.c"
  92. "$workspacePath\PLSR\Src\plsr_profile.c"
  93. "$workspacePath\PLSR\Src\plsr_hal_f407.c"
  94. "$workspacePath\PLSR\Src\plsr_core.c"
  95. "$workspacePath\PLSR\Src\plsr_self_test.c"
  96. "$workspacePath\PLSR\Test\test_plsr_hal.c"
  97. )
  98. }
  99. )
  100. foreach ($test in $tests)
  101. {
  102. $outputPath = Join-Path $outputDirectory "$($test.Name).exe"
  103. $arguments = @(
  104. '-std=c11'
  105. '-Wall'
  106. '-Wextra'
  107. '-Werror'
  108. '-DPLSR_HOST_TEST'
  109. "-I$workspacePath\PLSR\Inc"
  110. ) + $test.Sources + @('-o', $outputPath, '-lm')
  111. try
  112. {
  113. & $compiler.Source @arguments
  114. if ($LASTEXITCODE -ne 0)
  115. {
  116. throw "$($test.Name) compilation failed with exit code $LASTEXITCODE."
  117. }
  118. & $outputPath
  119. if ($LASTEXITCODE -ne 0)
  120. {
  121. throw "$($test.Name) failed with exit code $LASTEXITCODE."
  122. }
  123. }
  124. finally
  125. {
  126. if (Test-Path -LiteralPath $outputPath)
  127. {
  128. Remove-Item -LiteralPath $outputPath -Force
  129. }
  130. }
  131. }