Wideband autonomous SDR analysis engine forked from sdr-visual-suite
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

79 строки
2.7KB

  1. package pipeline
  2. import (
  3. "testing"
  4. "sdr-wideband-suite/internal/config"
  5. )
  6. func TestApplyNamedProfile(t *testing.T) {
  7. cfg := config.Default()
  8. ApplyNamedProfile(&cfg, "wideband-balanced")
  9. if cfg.Pipeline.Mode != "wideband-balanced" {
  10. t.Fatalf("mode not applied: %s", cfg.Pipeline.Mode)
  11. }
  12. if cfg.Pipeline.Profile != "wideband-balanced" {
  13. t.Fatalf("profile not applied: %s", cfg.Pipeline.Profile)
  14. }
  15. if cfg.Pipeline.Goals.Intent != "wideband-surveillance" {
  16. t.Fatalf("intent not applied: %s", cfg.Pipeline.Goals.Intent)
  17. }
  18. if cfg.Surveillance.AnalysisFFTSize < 4096 {
  19. t.Fatalf("analysis fft too small: %d", cfg.Surveillance.AnalysisFFTSize)
  20. }
  21. if cfg.Surveillance.Strategy != "multi-resolution" {
  22. t.Fatalf("strategy not applied: %s", cfg.Surveillance.Strategy)
  23. }
  24. if !cfg.Refinement.Enabled {
  25. t.Fatalf("refinement should stay enabled")
  26. }
  27. if cfg.Resources.MaxRefinementJobs < 16 {
  28. t.Fatalf("refinement jobs too small: %d", cfg.Resources.MaxRefinementJobs)
  29. }
  30. if cfg.Refinement.DetailFFTSize != cfg.Surveillance.AnalysisFFTSize {
  31. t.Fatalf("detail fft not aligned: %d vs %d", cfg.Refinement.DetailFFTSize, cfg.Surveillance.AnalysisFFTSize)
  32. }
  33. }
  34. func TestPolicyFromConfig(t *testing.T) {
  35. cfg := config.Default()
  36. cfg.Pipeline.Mode = "archive"
  37. cfg.Pipeline.Goals.Intent = "archive-and-triage"
  38. cfg.Pipeline.Goals.MonitorStartHz = 88e6
  39. cfg.Pipeline.Goals.MonitorEndHz = 108e6
  40. cfg.Pipeline.Goals.MonitorSpanHz = 20e6
  41. cfg.Pipeline.Goals.SignalPriorities = []string{"broadcast-fm", "rds"}
  42. cfg.Surveillance.AnalysisFFTSize = 8192
  43. cfg.Surveillance.FrameRate = 9
  44. cfg.Surveillance.DisplayBins = 1200
  45. cfg.Surveillance.DisplayFPS = 6
  46. cfg.Refinement.Enabled = true
  47. cfg.Refinement.DetailFFTSize = 4096
  48. cfg.Resources.MaxRefinementJobs = 5
  49. cfg.Refinement.MinCandidateSNRDb = 2.5
  50. cfg.Resources.PreferGPU = true
  51. cfg.Resources.MaxRecordingStreams = 7
  52. p := PolicyFromConfig(cfg)
  53. if p.Mode != "archive" || p.Intent != "archive-and-triage" || p.SurveillanceFFTSize != 8192 || p.SurveillanceFPS != 9 || p.DisplayBins != 1200 || p.DisplayFPS != 6 {
  54. t.Fatalf("unexpected policy: %+v", p)
  55. }
  56. if p.MonitorSpanHz != 20e6 || len(p.SignalPriorities) != 2 {
  57. t.Fatalf("unexpected policy goals: %+v", p)
  58. }
  59. if p.MonitorCenterHz != cfg.CenterHz {
  60. t.Fatalf("unexpected monitor center: %+v", p.MonitorCenterHz)
  61. }
  62. if !p.RefinementEnabled || p.MaxRefinementJobs != 5 || p.MinCandidateSNRDb != 2.5 || !p.PreferGPU {
  63. t.Fatalf("unexpected policy details: %+v", p)
  64. }
  65. if p.RefinementDetailFFTSize != 4096 {
  66. t.Fatalf("unexpected refinement detail fft: %+v", p.RefinementDetailFFTSize)
  67. }
  68. if p.MaxRecordingStreams != 7 {
  69. t.Fatalf("unexpected record budget: %+v", p.MaxRecordingStreams)
  70. }
  71. if p.RefinementStrategy == "" {
  72. t.Fatalf("expected refinement strategy to be set")
  73. }
  74. }