summaryrefslogtreecommitdiff
path: root/meta-google/recipes-google/networking/network-sh/test.sh
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2021-05-10 13:07:14 +0300
committerWilliam A. Kennington III <wak@google.com>2021-05-11 23:33:02 +0300
commit80776788b1946fbbe0748a54b18cb1b28c03a8ad (patch)
treed2367a4195e1aae8d1e4464bce427ecca205e5b7 /meta-google/recipes-google/networking/network-sh/test.sh
parent1819d8176a3380fd13b958275c678ec24c462aaf (diff)
downloadopenbmc-80776788b1946fbbe0748a54b18cb1b28c03a8ad.tar.xz
meta-google: network-sh: Add ip_bytes_to_str
This makes it possible to get a human readable address back from a byte array. Change-Id: Ifcc98bcc95b8d75fe7d1aae1c264cbddf3fc5bd0 Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'meta-google/recipes-google/networking/network-sh/test.sh')
-rwxr-xr-xmeta-google/recipes-google/networking/network-sh/test.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/meta-google/recipes-google/networking/network-sh/test.sh b/meta-google/recipes-google/networking/network-sh/test.sh
index 2361cfe3e..33cab86aa 100755
--- a/meta-google/recipes-google/networking/network-sh/test.sh
+++ b/meta-google/recipes-google/networking/network-sh/test.sh
@@ -114,6 +114,36 @@ test_ip6_to_bytes() {
out=()
}
+test_ip4_bytes_str() {
+ in=(10 0 255 1)
+ str="$(ip_bytes_to_str in)" || fail
+ expect_streq "$str" '10.0.255.1'
+}
+
+test_ip6_bytes_str() {
+ in=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
+ str="$(ip_bytes_to_str in)" || fail
+ expect_streq "$str" '::'
+ in=(0xfd 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
+ str="$(ip_bytes_to_str in)" || fail
+ expect_streq "$str" 'fd00::'
+ in=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0xfd)
+ str="$(ip_bytes_to_str in)" || fail
+ expect_streq "$str" '::fd'
+ in=(0xfd 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1)
+ str="$(ip_bytes_to_str in)" || fail
+ expect_streq "$str" 'fd01::1'
+ in=(0xfd 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1)
+ str="$(ip_bytes_to_str in)" || fail
+ expect_streq "$str" 'fd01::1:0:0:1'
+ in=(0xfd 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1)
+ str="$(ip_bytes_to_str in)" || fail
+ expect_streq "$str" 'fd01:0:0:1:1::1'
+ in=(0 1 0 1 0xdd 0xdd 0 1 0 1 0 1 0 1 0 1)
+ str="$(ip_bytes_to_str in)" || fail
+ expect_streq "$str" '1:1:dddd:1:1:1:1:1'
+}
+
test_ipv6_pfx_concat() {
# Invalid inputs
expect_err 1 ipv6_pfx_concat 'fd/64' '1234:5678:90af'