Wideband autonomous SDR analysis engine forked from sdr-visual-suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 line
2.4KB

  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. }
  31. func TestPolicyFromConfig(t *testing.T) {
  32. cfg := config.Default()
  33. cfg.Pipeline.Mode = "archive"
  34. cfg.Pipeline.Goals.Intent = "archive-and-triage"
  35. cfg.Pipeline.Goals.MonitorStartHz = 88e6
  36. cfg.Pipeline.Goals.MonitorEndHz = 108e6
  37. cfg.Pipeline.Goals.MonitorSpanHz = 20e6
  38. cfg.Pipeline.Goals.SignalPriorities = []string{"broadcast-fm", "rds"}
  39. cfg.Surveillance.AnalysisFFTSize = 8192
  40. cfg.Surveillance.FrameRate = 9
  41. cfg.Surveillance.DisplayBins = 1200
  42. cfg.Surveillance.DisplayFPS = 6
  43. cfg.Refinement.Enabled = true
  44. cfg.Resources.MaxRefinementJobs = 5
  45. cfg.Refinement.MinCandidateSNRDb = 2.5
  46. cfg.Resources.PreferGPU = true
  47. cfg.Resources.MaxRecordingStreams = 7
  48. p := PolicyFromConfig(cfg)
  49. if p.Mode != "archive" || p.Intent != "archive-and-triage" || p.SurveillanceFFTSize != 8192 || p.SurveillanceFPS != 9 || p.DisplayBins != 1200 || p.DisplayFPS != 6 {
  50. t.Fatalf("unexpected policy: %+v", p)
  51. }
  52. if p.MonitorSpanHz != 20e6 || len(p.SignalPriorities) != 2 {
  53. t.Fatalf("unexpected policy goals: %+v", p)
  54. }
  55. if p.MonitorCenterHz != cfg.CenterHz {
  56. t.Fatalf("unexpected monitor center: %+v", p.MonitorCenterHz)
  57. }
  58. if !p.RefinementEnabled || p.MaxRefinementJobs != 5 || p.MinCandidateSNRDb != 2.5 || !p.PreferGPU {
  59. t.Fatalf("unexpected policy details: %+v", p)
  60. }
  61. if p.MaxRecordingStreams != 7 {
  62. t.Fatalf("unexpected record budget: %+v", p.MaxRecordingStreams)
  63. }
  64. if p.RefinementStrategy == "" {
  65. t.Fatalf("expected refinement strategy to be set")
  66. }
  67. }