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.

65 lignes
1.4KB

  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.EventPath == "" {
  42. t.Fatalf("event path default not applied")
  43. }
  44. }
  45. func TestProfileDefaultsPresent(t *testing.T) {
  46. cfg := Default()
  47. if len(cfg.Profiles) < 2 {
  48. t.Fatalf("expected built-in profiles")
  49. }
  50. found := false
  51. for _, p := range cfg.Profiles {
  52. if p.Name == "wideband-balanced" {
  53. found = true
  54. break
  55. }
  56. }
  57. if !found {
  58. t.Fatalf("missing wideband-balanced profile")
  59. }
  60. }