mirror of
https://github.com/nxtrace/NTrace-core.git
synced 2026-11-30 08:28:01 +00:00
- let deploy mode bind the listener before printing the Web UI address and report the actual bound endpoint when :0 is used - switch Unix and Windows regression deploy checks to parse the real base URL from deploy logs instead of preallocating a port in the script - add Unix deploy cleanup traps and make runner scripts temporary/self-cleaning - gate ICMP source-device propagation to Linux and macOS so unsupported Unix targets keep --dev as source-address selection only - add server and trace regression tests for the new listener and source-device behavior
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package trace
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/nxtrace/NTrace-core/trace/internal"
|
|
)
|
|
|
|
func TestApplyICMPSourceDevicePropagatesOnNonWindows(t *testing.T) {
|
|
restoreGOOS := stubCurrentGOOS(t, "darwin")
|
|
defer restoreGOOS()
|
|
|
|
spec := internal.NewICMPSpec(4, 0, 1, nil, nil)
|
|
applyICMPSourceDevice(spec, 1, "en0")
|
|
if spec.SourceDevice != "en0" {
|
|
t.Fatalf("SourceDevice = %q, want en0 for macOS ICMP", spec.SourceDevice)
|
|
}
|
|
|
|
restoreGOOS = stubCurrentGOOS(t, "linux")
|
|
defer restoreGOOS()
|
|
spec = internal.NewICMPSpec(4, 0, 1, nil, nil)
|
|
applyICMPSourceDevice(spec, 3, "eth0")
|
|
if spec.SourceDevice != "eth0" {
|
|
t.Fatalf("SourceDevice = %q, want eth0 for Unix ICMP", spec.SourceDevice)
|
|
}
|
|
}
|
|
|
|
func TestApplyICMPSourceDeviceSkipsWindows(t *testing.T) {
|
|
spec := internal.NewICMPSpec(6, 0, 1, nil, nil)
|
|
applyICMPSourceDevice(spec, 2, "Ethernet0")
|
|
if spec.SourceDevice != "" {
|
|
t.Fatalf("SourceDevice = %q, want empty on Windows", spec.SourceDevice)
|
|
}
|
|
}
|
|
|
|
func TestApplyICMPSourceDeviceSkipsUnsupportedUnix(t *testing.T) {
|
|
restoreGOOS := stubCurrentGOOS(t, "freebsd")
|
|
defer restoreGOOS()
|
|
|
|
spec := internal.NewICMPSpec(4, 0, 1, nil, nil)
|
|
applyICMPSourceDevice(spec, 3, "em0")
|
|
if spec.SourceDevice != "" {
|
|
t.Fatalf("SourceDevice = %q, want empty on unsupported Unix", spec.SourceDevice)
|
|
}
|
|
}
|