Skip to content

Commit 5f11245

Browse files
committed
Add pre-flight checks for e2e binary dependencies
1 parent c66f857 commit 5f11245

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

cmd/chain.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"fmt"
5+
"os/exec"
56
"strconv"
67
"strings"
78
"time"
@@ -173,6 +174,26 @@ func runChain(cmd *cobra.Command, args []string) error {
173174
configs = append(configs, cfg)
174175
}
175176

177+
// Pre-flight: check required binaries for e2e steps
178+
for _, cfg := range configs {
179+
switch cfg.name {
180+
case "e2e/dnstt", "doh/e2e":
181+
if _, err := exec.LookPath("dnstt-client"); err != nil {
182+
return fmt.Errorf("step %q requires dnstt-client in PATH (not found)", cfg.name)
183+
}
184+
if _, err := exec.LookPath("curl"); err != nil {
185+
return fmt.Errorf("step %q requires curl in PATH (not found)", cfg.name)
186+
}
187+
case "e2e/slipstream":
188+
if _, err := exec.LookPath("slipstream-client"); err != nil {
189+
return fmt.Errorf("step %q requires slipstream-client in PATH (not found)", cfg.name)
190+
}
191+
if _, err := exec.LookPath("curl"); err != nil {
192+
return fmt.Errorf("step %q requires curl in PATH (not found)", cfg.name)
193+
}
194+
}
195+
}
196+
176197
// Shared port pool for e2e steps
177198
ports := scanner.PortPool(portBase, workers)
178199

cmd/scan.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55
"os"
6+
"os/exec"
67
"sort"
78
"strings"
89
"time"
@@ -70,6 +71,23 @@ func runScan(cmd *cobra.Command, args []string) error {
7071
return err
7172
}
7273

74+
// Pre-flight: verify required binaries before wasting time scanning
75+
if pubkey != "" {
76+
if _, err := exec.LookPath("dnstt-client"); err != nil {
77+
return fmt.Errorf("--pubkey requires dnstt-client in PATH (not found)")
78+
}
79+
}
80+
if certPath != "" {
81+
if _, err := exec.LookPath("slipstream-client"); err != nil {
82+
return fmt.Errorf("--cert requires slipstream-client in PATH (not found)")
83+
}
84+
}
85+
if (pubkey != "" || certPath != "") {
86+
if _, err := exec.LookPath("curl"); err != nil {
87+
return fmt.Errorf("e2e tests require curl in PATH (not found)")
88+
}
89+
}
90+
7391
dur := time.Duration(timeout) * time.Second
7492
needE2E := pubkey != "" || certPath != ""
7593
var ports chan int

0 commit comments

Comments
 (0)