From bea4868b388dd927093ad030ecca23b207c14844 Mon Sep 17 00:00:00 2001 From: Kanishk Pachauri Date: Wed, 23 Oct 2024 05:08:43 +0530 Subject: [PATCH] fix: add human-readable error when nc is not installed on the host Signed-off-by: Kanishk Pachauri --- hack/test-port-forwarding.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hack/test-port-forwarding.pl b/hack/test-port-forwarding.pl index 8245cf9396e..3a41ce1e118 100755 --- a/hack/test-port-forwarding.pl +++ b/hack/test-port-forwarding.pl @@ -54,6 +54,17 @@ exit; } +# Check if netcat is available before running tests +my $nc_path = `command -v nc 2>/dev/null`; +chomp $nc_path; +unless ($nc_path) { + die "Error: 'nc' (netcat) is not installed on the host system.\n" . + "Please install netcat to run this test script:\n" . + " - On macOS: brew install netcat\n" . + " - On Ubuntu/Debian: sudo apt-get install netcat\n" . + " - On RHEL/CentOS: sudo yum install nmap-ncat\n"; +} + # Otherwise $instance must be the name of an already running instance that has been # configured with our portForwards settings.