Wideband autonomous SDR analysis engine forked from sdr-visual-suite
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

81 lignes
2.0KB

  1. package config
  2. import (
  3. "os"
  4. "testing"
  5. )
  6. func TestLoadConfig(t *testing.T) {
  7. data := []byte("center_hz: 100.0e6\nfft_size: 1024\n")
  8. f, err := os.CreateTemp(t.TempDir(), "cfg*.yaml")
  9. if err != nil {
  10. t.Fatalf("temp: %v", err)
  11. }
  12. if _, err := f.Write(data); err != nil {
  13. t.Fatalf("write: %v", err)
  14. }
  15. _ = f.Close()
  16. cfg, err := Load(f.Name())
  17. if err != nil {
  18. t.Fatalf("load: %v", err)
  19. }
  20. if cfg.CenterHz != 100.0e6 {
  21. t.Fatalf("center hz: %v", cfg.CenterHz)
  22. }
  23. if cfg.FFTSize != 2048 {
  24. t.Fatalf("fft size: %v", cfg.FFTSize)
  25. }
  26. if cfg.Surveillance.AnalysisFFTSize != 2048 {
  27. t.Fatalf("analysis fft size: %v", cfg.Surveillance.AnalysisFFTSize)
  28. }
  29. if cfg.FrameRate <= 0 {
  30. t.Fatalf("frame rate default not applied")
  31. }
  32. if cfg.Surveillance.AnalysisFFTSize != cfg.FFTSize {
  33. t.Fatalf("analysis fft size not aligned: %d vs %d", cfg.Surveillance.AnalysisFFTSize, cfg.FFTSize)
  34. }
  35. if cfg.Pipeline.Mode == "" {
  36. t.Fatalf("pipeline mode default not applied")
  37. }
  38. if !cfg.Refinement.Enabled {
  39. t.Fatalf("refinement default not applied")
  40. }
  41. if cfg.Refinement.AutoSpan == nil || !*cfg.Refinement.AutoSpan {
  42. t.Fatalf("refinement auto_span default not applied")
  43. }
  44. if cfg.Refinement.DetailFFTSize != cfg.Surveillance.AnalysisFFTSize {
  45. t.Fatalf("refinement detail fft not aligned: %d vs %d", cfg.Refinement.DetailFFTSize, cfg.Surveillance.AnalysisFFTSize)
  46. }
  47. if cfg.EventPath == "" {
  48. t.Fatalf("event path default not applied")
  49. }
  50. }
  51. func TestProfileDefaultsPresent(t *testing.T) {
  52. cfg := Default()
  53. if len(cfg.Profiles) < 2 {
  54. t.Fatalf("expected built-in profiles")
  55. }
  56. found := false
  57. for _, p := range cfg.Profiles {
  58. if p.Name == "wideband-balanced" {
  59. found = true
  60. break
  61. }
  62. }
  63. if !found {
  64. t.Fatalf("missing wideband-balanced profile")
  65. }
  66. }
  67. func TestRefinementSpanDefaults(t *testing.T) {
  68. cfg := Default()
  69. cfg.Refinement.MinSpanHz = 20000
  70. cfg.Refinement.MaxSpanHz = 10000
  71. cfg = applyDefaults(cfg)
  72. if cfg.Refinement.MaxSpanHz != cfg.Refinement.MinSpanHz {
  73. t.Fatalf("expected max span to clamp to min when inverted: %+v", cfg.Refinement)
  74. }
  75. }