[netstack_tools] make the tools shell-commands
The tools will now be available under /bin, and will be dynamically installed
if they're only in the available package set, but not preinstalled.
Test: CQ
Change-Id: I4b1c938757d4b3fa79aa0349e9445bf28e6f3a38
diff --git a/go/src/netstack/BUILD.gn b/go/src/netstack/BUILD.gn
index eb2a1d6..cb23707 100644
--- a/go/src/netstack/BUILD.gn
+++ b/go/src/netstack/BUILD.gn
@@ -32,8 +32,6 @@
}
package("netstack_tools") {
- deprecated_system_image = true
-
deps = [
"filter/netfilter",
"ifconfig",
@@ -44,15 +42,19 @@
binaries = [
{
name = "ifconfig"
+ shell = true
},
{
name = "ifinfo"
+ shell = true
},
{
name = "netstat"
+ shell = true
},
{
name = "netfilter"
+ shell = true
},
]
}
diff --git a/go/src/netstack/ifconfig/ifconfig_test.go b/go/src/netstack/ifconfig/ifconfig_test.go
index 2b71f40..f1eaeb8 100644
--- a/go/src/netstack/ifconfig/ifconfig_test.go
+++ b/go/src/netstack/ifconfig/ifconfig_test.go
@@ -35,9 +35,9 @@
func TestOutput(t *testing.T) {
t.Run("ifconfig route add", func(t *testing.T) {
- before := Run(t, "/system/bin/ifconfig", "route", "show")
- RunExpectingError(t, "/system/bin/ifconfig", "route", "add", "1.2.3.4/14", "gateway", "9.8.7.6", "iface", "NON_EXISTENT_INTERFACE_FORCES_FAILURE")
- after := Run(t, "/system/bin/ifconfig", "route", "show")
+ before := Run(t, "/bin/ifconfig", "route", "show")
+ RunExpectingError(t, "/bin/ifconfig", "route", "add", "1.2.3.4/14", "gateway", "9.8.7.6", "iface", "NON_EXISTENT_INTERFACE_FORCES_FAILURE")
+ after := Run(t, "/bin/ifconfig", "route", "show")
if before != after {
t.Errorf("Expected ifconfig route add failure but the routes changed: '%s' vs '%s'", before, after)
@@ -46,45 +46,45 @@
t.Run("ifconfig route del", func(t *testing.T) {
// Add a route.
- RunQuietly(t, "/system/bin/ifconfig", "route", "add", "1.2.3.4/14", "gateway", "9.8.7.6", "iface", "lo")
+ RunQuietly(t, "/bin/ifconfig", "route", "add", "1.2.3.4/14", "gateway", "9.8.7.6", "iface", "lo")
- out := Run(t, "/system/bin/ifconfig", "route", "show")
+ out := Run(t, "/bin/ifconfig", "route", "show")
expected := "1.2.3.4/14 via 9.8.7.6 lo"
if !strings.Contains(out, expected) {
t.Errorf("ifconfig route add failed, couldn't find '%s' in '%s'", expected, out)
}
// Try to delete it but the gateway mismatches so it should fail.
- RunExpectingError(t, "/system/bin/ifconfig", "route", "del", "1.2.3.4/14", "gateway", "9.9.9.9")
- out = Run(t, "/system/bin/ifconfig", "route", "show")
+ RunExpectingError(t, "/bin/ifconfig", "route", "del", "1.2.3.4/14", "gateway", "9.9.9.9")
+ out = Run(t, "/bin/ifconfig", "route", "show")
if !strings.Contains(out, expected) {
t.Errorf("ifconfig route del removed '%s' from '%s' but it should not have", expected, out)
}
// Try to delete it but the mask length mismatches so it should fail.
- RunExpectingError(t, "/system/bin/ifconfig", "route", "del", "1.2.3.4/15")
- out = Run(t, "/system/bin/ifconfig", "route", "show")
+ RunExpectingError(t, "/bin/ifconfig", "route", "del", "1.2.3.4/15")
+ out = Run(t, "/bin/ifconfig", "route", "show")
if !strings.Contains(out, expected) {
t.Errorf("ifconfig route del removed '%s' from '%s' but it should not have", expected, out)
}
// Now delete it.
- RunQuietly(t, "/system/bin/ifconfig", "route", "del", "1.2.3.4/14", "gateway", "9.8.7.6")
- out = Run(t, "/system/bin/ifconfig", "route", "show")
+ RunQuietly(t, "/bin/ifconfig", "route", "del", "1.2.3.4/14", "gateway", "9.8.7.6")
+ out = Run(t, "/bin/ifconfig", "route", "show")
if strings.Contains(out, expected) {
t.Errorf("ifconfig route del failed, did not expect to find '%s' in '%s'", expected, out)
}
// Try to delete it again, it should fail.
- RunExpectingError(t, "/system/bin/ifconfig", "route", "del", "1.2.3.4/14")
- out = Run(t, "/system/bin/ifconfig", "route", "show")
+ RunExpectingError(t, "/bin/ifconfig", "route", "del", "1.2.3.4/14")
+ out = Run(t, "/bin/ifconfig", "route", "show")
if strings.Contains(out, expected) {
t.Errorf("ifconfig route del failed, did not expect to find '%s' in '%s'", expected, out)
}
})
t.Run("ifconfig route parse error formatting", func(t *testing.T) {
- out, err := exec.Command("/system/bin/ifconfig", "route", "add").CombinedOutput()
+ out, err := exec.Command("/bin/ifconfig", "route", "add").CombinedOutput()
if err == nil {
t.Errorf("ifconfig route add returned success without enough arguments. output: \n%s", out)
}
@@ -93,7 +93,7 @@
t.Errorf("want `ifconfig route add` to print \"%s\", got \"%s\"", expected, out)
}
- out, err = exec.Command("/system/bin/ifconfig", "route", "add", "1.2.3.4/14").CombinedOutput()
+ out, err = exec.Command("/bin/ifconfig", "route", "add", "1.2.3.4/14").CombinedOutput()
if err == nil {
t.Errorf("ifconfig route add returned success with neither gateway or iface specified. output: \n%s", out)
}
@@ -104,7 +104,7 @@
})
t.Run("Interface name exact match: `ifconfig lo` should return 1 interface", func(t *testing.T) {
- out, err := exec.Command("/system/bin/ifconfig", "lo").CombinedOutput()
+ out, err := exec.Command("/bin/ifconfig", "lo").CombinedOutput()
if err != nil {
t.Errorf("want no error but got error:\n%s", out)
}
@@ -120,7 +120,7 @@
})
t.Run("Interface name no match: `ifconfig o` should return 0 interface", func(t *testing.T) {
- out, err := exec.Command("/system/bin/ifconfig", "o").CombinedOutput()
+ out, err := exec.Command("/bin/ifconfig", "o").CombinedOutput()
if err != nil {
t.Errorf("want no error but got error:\n%s", out)
}
@@ -131,7 +131,7 @@
})
t.Run("Interface name partial match: `ifconfig l` should return 1 interface", func(t *testing.T) {
- out, err := exec.Command("/system/bin/ifconfig", "l").CombinedOutput()
+ out, err := exec.Command("/bin/ifconfig", "l").CombinedOutput()
if err != nil {
t.Errorf("want no error from `ifconfig l` but got error:\n%s", out)
}
diff --git a/go/src/netstack/netstat/netstat_test.go b/go/src/netstack/netstat/netstat_test.go
index bed2257..cf551a3 100644
--- a/go/src/netstack/netstat/netstat_test.go
+++ b/go/src/netstack/netstat/netstat_test.go
@@ -26,7 +26,7 @@
}
func TestOutput(t *testing.T) {
- out, err := exec.Command("/system/bin/netstat", "-s").CombinedOutput()
+ out, err := exec.Command("/bin/netstat", "-s").CombinedOutput()
if err != nil {
t.Fatal(err)
}
@@ -98,7 +98,7 @@
// fallthrough, ping doesn't have to successfully resolve the host for sent count to increase
}
- out, err := exec.Command("/system/bin/netstat", "-s").CombinedOutput()
+ out, err := exec.Command("/bin/netstat", "-s").CombinedOutput()
if err != nil {
t.Fatal(err)
}
diff --git a/go/src/netstack/tests/BUILD.gn b/go/src/netstack/tests/BUILD.gn
index 847a1c2..edfe528 100644
--- a/go/src/netstack/tests/BUILD.gn
+++ b/go/src/netstack/tests/BUILD.gn
@@ -47,50 +47,62 @@
binaries = [
{
name = "closetest"
+ shell = true
},
{
name = "getaddrinfo_test"
+ shell = true
},
{
name = "gethostbyname_test"
+ shell = true
},
{
name = "keepalivetest"
+ shell = true
},
{
name = "mctest"
+ shell = true
},
{
name = "nbiotest"
+ shell = true
},
{
name = "passfdtest"
+ shell = true
},
{
name = "polltest"
+ shell = true
},
{
name = "selecttest"
+ shell = true
},
{
name = "sockettest"
+ shell = true
},
{
name = "sockopttest"
+ shell = true
},
{
name = "udptest"
+ shell = true
},
]
}
diff --git a/go/src/netstack/tests/manual/passfdtest.c b/go/src/netstack/tests/manual/passfdtest.c
index 8f49a48..d728d38 100644
--- a/go/src/netstack/tests/manual/passfdtest.c
+++ b/go/src/netstack/tests/manual/passfdtest.c
@@ -32,7 +32,7 @@
}
}
-const char* kProgram = "/system/bin/passfdtest";
+const char* kProgram = "/bin/passfdtest";
static int server(const char* service) {
int16_t port = atoi(service);