blob: 794ef5562a07e76711ece564ca382aae51b2f9aa [file] [log] [blame]
William A. Kennington III7d6fa422021-02-08 17:04:02 -08001#!/bin/bash
Brandon Kimdab96f12021-02-18 11:21:37 -08002# Copyright 2021 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
William A. Kennington III7d6fa422021-02-08 17:04:02 -080016TEST_DIR="$(dirname "${BASH_SOURCE[0]}")"
17source "$TEST_DIR"/test_lib.sh
18
Patrick Williams59486672022-12-08 06:23:47 -060019function TestNormalizeMACInvalidArgs() {
20 ! "$NORMALIZE_MAC"
21 ! "$NORMALIZE_MAC" '0:0:0:0:0:0' 'extra'
William A. Kennington III7d6fa422021-02-08 17:04:02 -080022}
23
Patrick Williams59486672022-12-08 06:23:47 -060024function TestNormalizeMACBadMAC() {
25 ! "$NORMALIZE_MAC" '0:0'
26 ! "$NORMALIZE_MAC" '0:0:0:0:0:0:0'
27 ! "$NORMALIZE_MAC" '1ff:0:0:0:0'
William A. Kennington III7d6fa422021-02-08 17:04:02 -080028}
29
Patrick Williams59486672022-12-08 06:23:47 -060030function TestNormalizeMACSuccess() {
31 StrEq "$("$NORMALIZE_MAC" '0:0:0:0:0:0')" '00:00:00:00:00:00'
32 StrEq "$("$NORMALIZE_MAC" 'ff:0f:0:0:11:1')" 'ff:0f:00:00:11:01'
33 StrEq "$("$NORMALIZE_MAC" '0:0:0:0:0:ff')" "$("$NORMALIZE_MAC" '0:0:0:0:0:FF')"
William A. Kennington III7d6fa422021-02-08 17:04:02 -080034}
35
36TESTS+=(
Patrick Williams59486672022-12-08 06:23:47 -060037 TestNormalizeMACInvalidArgs
38 TestNormalizeMACBadMAC
39 TestNormalizeMACSuccess
William A. Kennington III7d6fa422021-02-08 17:04:02 -080040)
41
42return 0 2>/dev/null
43TestAnythingMain