ncsid: Import from gBMC

This is the initial code drop from gBMC.

Google-Bug-Id: 179618516
Upstream: 1e71af914bc8c54d8b91d0a1cf377e2696713c2f
Change-Id: Ic653e8271dacd205e04f2bc713071ef2ec5936a4
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/ncsid/test/normalize_ip_test.sh b/ncsid/test/normalize_ip_test.sh
new file mode 100755
index 0000000..cb520ef
--- /dev/null
+++ b/ncsid/test/normalize_ip_test.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+TEST_DIR="$(dirname "${BASH_SOURCE[0]}")"
+source "$TEST_DIR"/test_lib.sh
+
+TestNormalizeIPInvalidArgs() {
+  ! "$NORMALIZE_IP"
+  ! "$NORMALIZE_IP" '192.168.10.1' 'extra'
+}
+
+TestNormalizeIPBadIP() {
+  ! "$NORMALIZE_IP" '0f0.100.595.444'
+  ! "$NORMALIZE_IP" 'fx80::1'
+}
+
+TestNormalizeIPv4() {
+  StrEq "$("$NORMALIZE_IP" '192.168.10.1')" '192.168.10.1'
+  StrEq "$("$NORMALIZE_IP" '1.1.1.1')" '1.1.1.1'
+}
+
+TestNormalizeIPv6() {
+  StrEq "$("$NORMALIZE_IP" 'fe80:00B1::0000:1')" 'fe80:b1::1'
+}
+
+TESTS+=(
+  TestNormalizeIPInvalidArgs
+  TestNormalizeIPBadIP
+  TestNormalizeIPv4
+  TestNormalizeIPv6
+)
+
+return 0 2>/dev/null
+TestAnythingMain