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.
 
 
 
 
 
 

150 Zeilen
4.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_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\Src\plsr_modbus_data.c"
  97. "$workspacePath\PLSR\Src\plsr_modbus_control.c"
  98. "$workspacePath\Modbus\Src\modbus_data_store.c"
  99. "$workspacePath\PLSR\Test\test_plsr_hal.c"
  100. )
  101. },
  102. @{
  103. Name = 'test_plsr_modbus_data'
  104. Sources = @(
  105. "$workspacePath\Modbus\Src\modbus_data_store.c"
  106. "$workspacePath\PLSR\Src\plsr_modbus_data.c"
  107. "$workspacePath\PLSR\Test\test_plsr_modbus_data.c"
  108. )
  109. }
  110. )
  111. foreach ($test in $tests)
  112. {
  113. $outputPath = Join-Path $outputDirectory "$($test.Name).exe"
  114. $arguments = @(
  115. '-std=c11'
  116. '-Wall'
  117. '-Wextra'
  118. '-Werror'
  119. '-DPLSR_HOST_TEST'
  120. "-I$workspacePath\PLSR\Inc"
  121. "-I$workspacePath\Modbus\Inc"
  122. ) + $test.Sources + @('-o', $outputPath, '-lm')
  123. try
  124. {
  125. & $compiler.Source @arguments
  126. if ($LASTEXITCODE -ne 0)
  127. {
  128. throw "$($test.Name) compilation failed with exit code $LASTEXITCODE."
  129. }
  130. & $outputPath
  131. if ($LASTEXITCODE -ne 0)
  132. {
  133. throw "$($test.Name) failed with exit code $LASTEXITCODE."
  134. }
  135. }
  136. finally
  137. {
  138. if (Test-Path -LiteralPath $outputPath)
  139. {
  140. Remove-Item -LiteralPath $outputPath -Force
  141. }
  142. }
  143. }