From f06bbd104f90769e3d373c65ccfef50195693e56 Mon Sep 17 00:00:00 2001 From: James Bensley Date: Thu, 6 Apr 2023 16:17:21 +0100 Subject: [PATCH 1/2] Add github workflow for basic unit tests (#1) * Add github workflow for basic unit tests --------- Co-authored-by: James Bensley --- .github/workflows/unit-tests.yml | 36 +++++++++ tests/generate_outputs.sh | 88 +++++++++++++++++++++ tests/reference/as-as112-apnic-notation.txt | 3 + tests/reference/as-as112-ripe-notation.txt | 3 + tests/reference/as112-apnic.txt | 3 + tests/reference/as112-ripe-nonauth.txt | 3 + tests/reference/bird--4.txt | 4 + tests/reference/bird--6.txt | 4 + tests/reference/bird--asp.txt | 3 + tests/reference/eos--4.txt | 4 + tests/reference/eos--6.txt | 4 + tests/reference/formated--4.txt | 1 + tests/reference/formated--6.txt | 1 + tests/reference/huawei--4.txt | 3 + tests/reference/huawei--6.txt | 3 + tests/reference/huawei--asp.txt | 2 + tests/reference/huawei-xpl--4.txt | 5 ++ tests/reference/huawei-xpl--6.txt | 5 ++ tests/reference/huawei-xpl--asp.txt | 3 + tests/reference/ios--4.txt | 3 + tests/reference/ios--6.txt | 3 + tests/reference/ios--asp.txt | 2 + tests/reference/ios-xr--4.txt | 5 ++ tests/reference/ios-xr--6.txt | 5 ++ tests/reference/ios-xr--asp.txt | 3 + tests/reference/json--4.txt | 4 + tests/reference/json--6.txt | 4 + tests/reference/json--asp.txt | 3 + tests/reference/junos--4.txt | 7 ++ tests/reference/junos--6.txt | 7 ++ tests/reference/junos--asp.txt | 6 ++ tests/reference/openbgpd--4.txt | 4 + tests/reference/openbgpd--6.txt | 4 + tests/reference/openbgpd--asp.txt | 1 + tests/reference/routeros6--4.txt | 2 + tests/reference/routeros6--6.txt | 2 + tests/reference/routeros7--4.txt | 2 + tests/reference/routeros7--6.txt | 2 + tests/reference/sros--4.txt | 8 ++ tests/reference/sros--6.txt | 8 ++ tests/reference/sros--asp.txt | 7 ++ tests/reference/sros-mdcli--4.txt | 8 ++ tests/reference/sros-mdcli--6.txt | 8 ++ tests/reference/sros-mdcli--asp.txt | 7 ++ 44 files changed, 293 insertions(+) create mode 100644 .github/workflows/unit-tests.yml create mode 100755 tests/generate_outputs.sh create mode 100644 tests/reference/as-as112-apnic-notation.txt create mode 100644 tests/reference/as-as112-ripe-notation.txt create mode 100644 tests/reference/as112-apnic.txt create mode 100644 tests/reference/as112-ripe-nonauth.txt create mode 100644 tests/reference/bird--4.txt create mode 100644 tests/reference/bird--6.txt create mode 100644 tests/reference/bird--asp.txt create mode 100644 tests/reference/eos--4.txt create mode 100644 tests/reference/eos--6.txt create mode 100644 tests/reference/formated--4.txt create mode 100644 tests/reference/formated--6.txt create mode 100644 tests/reference/huawei--4.txt create mode 100644 tests/reference/huawei--6.txt create mode 100644 tests/reference/huawei--asp.txt create mode 100644 tests/reference/huawei-xpl--4.txt create mode 100644 tests/reference/huawei-xpl--6.txt create mode 100644 tests/reference/huawei-xpl--asp.txt create mode 100644 tests/reference/ios--4.txt create mode 100644 tests/reference/ios--6.txt create mode 100644 tests/reference/ios--asp.txt create mode 100644 tests/reference/ios-xr--4.txt create mode 100644 tests/reference/ios-xr--6.txt create mode 100644 tests/reference/ios-xr--asp.txt create mode 100644 tests/reference/json--4.txt create mode 100644 tests/reference/json--6.txt create mode 100644 tests/reference/json--asp.txt create mode 100644 tests/reference/junos--4.txt create mode 100644 tests/reference/junos--6.txt create mode 100644 tests/reference/junos--asp.txt create mode 100644 tests/reference/openbgpd--4.txt create mode 100644 tests/reference/openbgpd--6.txt create mode 100644 tests/reference/openbgpd--asp.txt create mode 100644 tests/reference/routeros6--4.txt create mode 100644 tests/reference/routeros6--6.txt create mode 100644 tests/reference/routeros7--4.txt create mode 100644 tests/reference/routeros7--6.txt create mode 100644 tests/reference/sros--4.txt create mode 100644 tests/reference/sros--6.txt create mode 100644 tests/reference/sros--asp.txt create mode 100644 tests/reference/sros-mdcli--4.txt create mode 100644 tests/reference/sros-mdcli--6.txt create mode 100644 tests/reference/sros-mdcli--asp.txt diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000..c4bd6fa --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,36 @@ +name: basic unit tests + +on: + pull_request: + types: + - opened + - edited + - reopened + - ready_for_review + - synchronize + +jobs: + output-unit-tests: + name: output unit tests + runs-on: ubuntu-22.04 + steps: + - name: clone repo + uses: actions/checkout@v3 + - name: install pre-reqs + run: | + sudo apt-get update + DEBIAN_FRONTEND=noninteractive sudo apt-get -y --no-install-recommends install autoconf automake libtool make + - name: build bgpq4 + run: | + ./bootstrap + ./configure + make + ./bgpq4 -v + - name: generate output + run: ./tests/generate_outputs.sh ./bgpq4 /tmp + - name: check output + run: > + for file in tests/reference/*.txt; + do + echo "$(sha256sum "${file}" | awk '{print $1}') /tmp/$(basename "${file}")" | sha256sum --check; + done diff --git a/tests/generate_outputs.sh b/tests/generate_outputs.sh new file mode 100755 index 0000000..7c3ef47 --- /dev/null +++ b/tests/generate_outputs.sh @@ -0,0 +1,88 @@ +#!/bin/bash + +set -e + +if [ $# -ne 2 ] +then + echo "Usage: pass the following arguments in order:" + echo "" + echo "path to bgpq4 binary" + echo "output directory path" + echo "" + echo "${0} ./bgpq4 /tmp" + exit 1 +fi + +BGPQ4_PATH="${1}" +TEST_ASN="112" +TEST_AS_SET="AS-AS112" +OUT_DIR="${2}" + +if [ ! -f "${BGPQ4_PATH}" ] +then + echo "File ${BGPQ4_PATH} does't exist" + exit 1 +fi + +if [ ! -e "${OUT_DIR}" ] +then + echo "Output directory ${OUT_DIR} does't exist" + exit 1 +fi + +# Test the IPv4 output formatting for each supported NOS: +"${BGPQ4_PATH}" -4 -b "AS${TEST_ASN}" > "${OUT_DIR}/bird--4.txt" +"${BGPQ4_PATH}" -4 -e "AS${TEST_ASN}" > "${OUT_DIR}/eos--4.txt" +"${BGPQ4_PATH}" -4 -F '%n/%l ' "AS${TEST_ASN}" > "${OUT_DIR}/formated--4.txt" +"${BGPQ4_PATH}" -4 -U "AS${TEST_ASN}" > "${OUT_DIR}/huawei--4.txt" +"${BGPQ4_PATH}" -4 -u "AS${TEST_ASN}" > "${OUT_DIR}/huawei-xpl--4.txt" +"${BGPQ4_PATH}" -4 "AS${TEST_ASN}" > "${OUT_DIR}/ios--4.txt" +"${BGPQ4_PATH}" -4 -X "AS${TEST_ASN}" > "${OUT_DIR}/ios-xr--4.txt" +"${BGPQ4_PATH}" -4 -j "AS${TEST_ASN}" > "${OUT_DIR}/json--4.txt" +"${BGPQ4_PATH}" -4 -J "AS${TEST_ASN}" > "${OUT_DIR}/junos--4.txt" +"${BGPQ4_PATH}" -4 -B "AS${TEST_ASN}" > "${OUT_DIR}/openbgpd--4.txt" +"${BGPQ4_PATH}" -4 -K "AS${TEST_ASN}" > "${OUT_DIR}/routeros6--4.txt" +"${BGPQ4_PATH}" -4 -K7 "AS${TEST_ASN}" > "${OUT_DIR}/routeros7--4.txt" +"${BGPQ4_PATH}" -4 -N "AS${TEST_ASN}" > "${OUT_DIR}/sros--4.txt" +"${BGPQ4_PATH}" -4 -n "AS${TEST_ASN}" > "${OUT_DIR}/sros-mdcli--4.txt" + +# Test the IPv6 prefix-list output formatting for each supported NOS: +"${BGPQ4_PATH}" -6 -b "AS${TEST_ASN}" > "${OUT_DIR}/bird--6.txt" +"${BGPQ4_PATH}" -6 -e "AS${TEST_ASN}" > "${OUT_DIR}/eos--6.txt" +"${BGPQ4_PATH}" -6 -F '%n/%l ' "AS${TEST_ASN}" > "${OUT_DIR}/formated--6.txt" +"${BGPQ4_PATH}" -6 -U "AS${TEST_ASN}" > "${OUT_DIR}/huawei--6.txt" +"${BGPQ4_PATH}" -6 -u "AS${TEST_ASN}" > "${OUT_DIR}/huawei-xpl--6.txt" +"${BGPQ4_PATH}" -6 "AS${TEST_ASN}" > "${OUT_DIR}/ios--6.txt" +"${BGPQ4_PATH}" -6 -X "AS${TEST_ASN}" > "${OUT_DIR}/ios-xr--6.txt" +"${BGPQ4_PATH}" -6 -j "AS${TEST_ASN}" > "${OUT_DIR}/json--6.txt" +"${BGPQ4_PATH}" -6 -J "AS${TEST_ASN}" > "${OUT_DIR}/junos--6.txt" +"${BGPQ4_PATH}" -6 -B "AS${TEST_ASN}" > "${OUT_DIR}/openbgpd--6.txt" +"${BGPQ4_PATH}" -6 -K "AS${TEST_ASN}" > "${OUT_DIR}/routeros6--6.txt" +"${BGPQ4_PATH}" -6 -K7 "AS${TEST_ASN}" > "${OUT_DIR}/routeros7--6.txt" +"${BGPQ4_PATH}" -6 -N "AS${TEST_ASN}" > "${OUT_DIR}/sros--6.txt" +"${BGPQ4_PATH}" -6 -n "AS${TEST_ASN}" > "${OUT_DIR}/sros-mdcli--6.txt" + +# Test the AS path list output formatting for each supported NOS: +"${BGPQ4_PATH}" "${TEST_AS_SET}" -f "${TEST_ASN}" -b > "${OUT_DIR}/bird--asp.txt" +# "${BGPQ4_PATH}" "${TEST_AS_SET}" -f "${TEST_ASN}" -e > "${OUT_DIR}/eos--asp.txt" # Not supported +"${BGPQ4_PATH}" "${TEST_AS_SET}" -f "${TEST_ASN}" -U > "${OUT_DIR}/huawei--asp.txt" +"${BGPQ4_PATH}" "${TEST_AS_SET}" -f "${TEST_ASN}" -u > "${OUT_DIR}/huawei-xpl--asp.txt" +"${BGPQ4_PATH}" "${TEST_AS_SET}" -f "${TEST_ASN}" > "${OUT_DIR}/ios--asp.txt" +"${BGPQ4_PATH}" "${TEST_AS_SET}" -f "${TEST_ASN}" -X > "${OUT_DIR}/ios-xr--asp.txt" +"${BGPQ4_PATH}" "${TEST_AS_SET}" -f "${TEST_ASN}" -j > "${OUT_DIR}/json--asp.txt" +"${BGPQ4_PATH}" "${TEST_AS_SET}" -f "${TEST_ASN}" -J > "${OUT_DIR}/junos--asp.txt" +"${BGPQ4_PATH}" "${TEST_AS_SET}" -f "${TEST_ASN}" -B > "${OUT_DIR}/openbgpd--asp.txt" +# "${BGPQ4_PATH}" "${TEST_AS_SET}" -f "${TEST_ASN}" -K > "${OUT_DIR}/routeros6--asp.txt" # Not supported +# "${BGPQ4_PATH}" "${TEST_AS_SET}" -f "${TEST_ASN}" -K7 > "${OUT_DIR}/routeros7--asp.txt" # Not supported +"${BGPQ4_PATH}" "${TEST_AS_SET}" -f "${TEST_ASN}" -N > "${OUT_DIR}/sros--asp.txt" +"${BGPQ4_PATH}" "${TEST_AS_SET}" -f "${TEST_ASN}" -n > "${OUT_DIR}/sros-mdcli--asp.txt" + +# Test IRR source scopes +# Limit ASN to valid source: +"${BGPQ4_PATH}" "AS${TEST_ASN}" -S RIPE-NONAUTH > "${OUT_DIR}/as112-ripe-nonauth.txt" +# Limit ASN to invalid sources: +"${BGPQ4_PATH}" "AS${TEST_ASN}" -S APNIC,AFRINIC > "${OUT_DIR}/as112-apnic.txt" +# Limit AS-SET using IRR prefix notation to valid source: +"${BGPQ4_PATH}" "RIPE::${TEST_AS_SET}" > "${OUT_DIR}/as-as112-ripe-notation.txt" +# Limit AS-SET using IRR prefix notation to invalid source: +"${BGPQ4_PATH}" "APNIC::${TEST_AS_SET}" > "${OUT_DIR}/as-as112-apnic-notation.txt" diff --git a/tests/reference/as-as112-apnic-notation.txt b/tests/reference/as-as112-apnic-notation.txt new file mode 100644 index 0000000..3cf4682 --- /dev/null +++ b/tests/reference/as-as112-apnic-notation.txt @@ -0,0 +1,3 @@ +no ip prefix-list NN +! generated prefix-list NN is empty +ip prefix-list NN deny 0.0.0.0/0 diff --git a/tests/reference/as-as112-ripe-notation.txt b/tests/reference/as-as112-ripe-notation.txt new file mode 100644 index 0000000..fd3abfe --- /dev/null +++ b/tests/reference/as-as112-ripe-notation.txt @@ -0,0 +1,3 @@ +no ip prefix-list NN +ip prefix-list NN permit 192.31.196.0/24 +ip prefix-list NN permit 192.175.48.0/24 diff --git a/tests/reference/as112-apnic.txt b/tests/reference/as112-apnic.txt new file mode 100644 index 0000000..3cf4682 --- /dev/null +++ b/tests/reference/as112-apnic.txt @@ -0,0 +1,3 @@ +no ip prefix-list NN +! generated prefix-list NN is empty +ip prefix-list NN deny 0.0.0.0/0 diff --git a/tests/reference/as112-ripe-nonauth.txt b/tests/reference/as112-ripe-nonauth.txt new file mode 100644 index 0000000..fd3abfe --- /dev/null +++ b/tests/reference/as112-ripe-nonauth.txt @@ -0,0 +1,3 @@ +no ip prefix-list NN +ip prefix-list NN permit 192.31.196.0/24 +ip prefix-list NN permit 192.175.48.0/24 diff --git a/tests/reference/bird--4.txt b/tests/reference/bird--4.txt new file mode 100644 index 0000000..98db228 --- /dev/null +++ b/tests/reference/bird--4.txt @@ -0,0 +1,4 @@ +NN = [ + 192.31.196.0/24, + 192.175.48.0/24 +]; diff --git a/tests/reference/bird--6.txt b/tests/reference/bird--6.txt new file mode 100644 index 0000000..513c43e --- /dev/null +++ b/tests/reference/bird--6.txt @@ -0,0 +1,4 @@ +NN = [ + 2001:4:112::/48, + 2620:4f:8000::/48 +]; diff --git a/tests/reference/bird--asp.txt b/tests/reference/bird--asp.txt new file mode 100644 index 0000000..8465bfd --- /dev/null +++ b/tests/reference/bird--asp.txt @@ -0,0 +1,3 @@ +NN = [ + 112 +]; diff --git a/tests/reference/eos--4.txt b/tests/reference/eos--4.txt new file mode 100644 index 0000000..06994d4 --- /dev/null +++ b/tests/reference/eos--4.txt @@ -0,0 +1,4 @@ +no ip prefix-list NN +ip prefix-list NN + seq 1 permit 192.31.196.0/24 + seq 2 permit 192.175.48.0/24 diff --git a/tests/reference/eos--6.txt b/tests/reference/eos--6.txt new file mode 100644 index 0000000..2b7b9d0 --- /dev/null +++ b/tests/reference/eos--6.txt @@ -0,0 +1,4 @@ +no ipv6 prefix-list NN +ipv6 prefix-list NN + seq 1 permit 2001:4:112::/48 + seq 2 permit 2620:4f:8000::/48 diff --git a/tests/reference/formated--4.txt b/tests/reference/formated--4.txt new file mode 100644 index 0000000..3d59990 --- /dev/null +++ b/tests/reference/formated--4.txt @@ -0,0 +1 @@ +192.31.196.0/24 192.175.48.0/24 diff --git a/tests/reference/formated--6.txt b/tests/reference/formated--6.txt new file mode 100644 index 0000000..1a76960 --- /dev/null +++ b/tests/reference/formated--6.txt @@ -0,0 +1 @@ +2001:4:112::/48 2620:4f:8000::/48 diff --git a/tests/reference/huawei--4.txt b/tests/reference/huawei--4.txt new file mode 100644 index 0000000..2d9f033 --- /dev/null +++ b/tests/reference/huawei--4.txt @@ -0,0 +1,3 @@ +undo ip ip-prefix NN +ip ip-prefix NN permit 192.31.196.0 24 +ip ip-prefix NN permit 192.175.48.0 24 diff --git a/tests/reference/huawei--6.txt b/tests/reference/huawei--6.txt new file mode 100644 index 0000000..83f454a --- /dev/null +++ b/tests/reference/huawei--6.txt @@ -0,0 +1,3 @@ +undo ip ipv6-prefix NN +ip ipv6-prefix NN permit 2001:4:112:: 48 +ip ipv6-prefix NN permit 2620:4f:8000:: 48 diff --git a/tests/reference/huawei--asp.txt b/tests/reference/huawei--asp.txt new file mode 100644 index 0000000..32facfb --- /dev/null +++ b/tests/reference/huawei--asp.txt @@ -0,0 +1,2 @@ +undo ip as-path-filter NN +ip as-path-filter NN permit ^112(_112)*$ diff --git a/tests/reference/huawei-xpl--4.txt b/tests/reference/huawei-xpl--4.txt new file mode 100644 index 0000000..b090dbc --- /dev/null +++ b/tests/reference/huawei-xpl--4.txt @@ -0,0 +1,5 @@ +no xpl ip-prefix-list NN +xpl ip-prefix-list NN + 192.31.196.0 24, + 192.175.48.0 24 +end-list diff --git a/tests/reference/huawei-xpl--6.txt b/tests/reference/huawei-xpl--6.txt new file mode 100644 index 0000000..258b561 --- /dev/null +++ b/tests/reference/huawei-xpl--6.txt @@ -0,0 +1,5 @@ +no xpl ipv6-prefix-list NN +xpl ipv6-prefix-list NN + 2001:4:112:: 48, + 2620:4f:8000:: 48 +end-list diff --git a/tests/reference/huawei-xpl--asp.txt b/tests/reference/huawei-xpl--asp.txt new file mode 100644 index 0000000..ba9e6cd --- /dev/null +++ b/tests/reference/huawei-xpl--asp.txt @@ -0,0 +1,3 @@ +xpl as-path-list NN + regular ^112(_112)*$ +end-list diff --git a/tests/reference/ios--4.txt b/tests/reference/ios--4.txt new file mode 100644 index 0000000..fd3abfe --- /dev/null +++ b/tests/reference/ios--4.txt @@ -0,0 +1,3 @@ +no ip prefix-list NN +ip prefix-list NN permit 192.31.196.0/24 +ip prefix-list NN permit 192.175.48.0/24 diff --git a/tests/reference/ios--6.txt b/tests/reference/ios--6.txt new file mode 100644 index 0000000..385a1eb --- /dev/null +++ b/tests/reference/ios--6.txt @@ -0,0 +1,3 @@ +no ipv6 prefix-list NN +ipv6 prefix-list NN permit 2001:4:112::/48 +ipv6 prefix-list NN permit 2620:4f:8000::/48 diff --git a/tests/reference/ios--asp.txt b/tests/reference/ios--asp.txt new file mode 100644 index 0000000..a944acd --- /dev/null +++ b/tests/reference/ios--asp.txt @@ -0,0 +1,2 @@ +no ip as-path access-list NN +ip as-path access-list NN permit ^112(_112)*$ diff --git a/tests/reference/ios-xr--4.txt b/tests/reference/ios-xr--4.txt new file mode 100644 index 0000000..a969301 --- /dev/null +++ b/tests/reference/ios-xr--4.txt @@ -0,0 +1,5 @@ +no prefix-set NN +prefix-set NN + 192.31.196.0/24, + 192.175.48.0/24 +end-set diff --git a/tests/reference/ios-xr--6.txt b/tests/reference/ios-xr--6.txt new file mode 100644 index 0000000..7ee22d8 --- /dev/null +++ b/tests/reference/ios-xr--6.txt @@ -0,0 +1,5 @@ +no prefix-set NN +prefix-set NN + 2001:4:112::/48, + 2620:4f:8000::/48 +end-set diff --git a/tests/reference/ios-xr--asp.txt b/tests/reference/ios-xr--asp.txt new file mode 100644 index 0000000..5ff6707 --- /dev/null +++ b/tests/reference/ios-xr--asp.txt @@ -0,0 +1,3 @@ +as-path-set NN + ios-regex '^112(_112)*$' +end-set diff --git a/tests/reference/json--4.txt b/tests/reference/json--4.txt new file mode 100644 index 0000000..5e276e2 --- /dev/null +++ b/tests/reference/json--4.txt @@ -0,0 +1,4 @@ +{ "NN": [ + { "prefix": "192.31.196.0\/24", "exact": true }, + { "prefix": "192.175.48.0\/24", "exact": true } +] } diff --git a/tests/reference/json--6.txt b/tests/reference/json--6.txt new file mode 100644 index 0000000..ebaf4a6 --- /dev/null +++ b/tests/reference/json--6.txt @@ -0,0 +1,4 @@ +{ "NN": [ + { "prefix": "2001:4:112::\/48", "exact": true }, + { "prefix": "2620:4f:8000::\/48", "exact": true } +] } diff --git a/tests/reference/json--asp.txt b/tests/reference/json--asp.txt new file mode 100644 index 0000000..dfbeb06 --- /dev/null +++ b/tests/reference/json--asp.txt @@ -0,0 +1,3 @@ +{"NN": [ + 112 +]} diff --git a/tests/reference/junos--4.txt b/tests/reference/junos--4.txt new file mode 100644 index 0000000..a3a0ed0 --- /dev/null +++ b/tests/reference/junos--4.txt @@ -0,0 +1,7 @@ +policy-options { +replace: + prefix-list NN { + 192.31.196.0/24; + 192.175.48.0/24; + } +} diff --git a/tests/reference/junos--6.txt b/tests/reference/junos--6.txt new file mode 100644 index 0000000..9c43f18 --- /dev/null +++ b/tests/reference/junos--6.txt @@ -0,0 +1,7 @@ +policy-options { +replace: + prefix-list NN { + 2001:4:112::/48; + 2620:4f:8000::/48; + } +} diff --git a/tests/reference/junos--asp.txt b/tests/reference/junos--asp.txt new file mode 100644 index 0000000..7fa4609 --- /dev/null +++ b/tests/reference/junos--asp.txt @@ -0,0 +1,6 @@ +policy-options { +replace: + as-path-group NN { + as-path a0 "^112(112)*$"; + } +} diff --git a/tests/reference/openbgpd--4.txt b/tests/reference/openbgpd--4.txt new file mode 100644 index 0000000..3bb03f6 --- /dev/null +++ b/tests/reference/openbgpd--4.txt @@ -0,0 +1,4 @@ +prefix { + 192.31.196.0/24 + 192.175.48.0/24 + } diff --git a/tests/reference/openbgpd--6.txt b/tests/reference/openbgpd--6.txt new file mode 100644 index 0000000..9629e42 --- /dev/null +++ b/tests/reference/openbgpd--6.txt @@ -0,0 +1,4 @@ +prefix { + 2001:4:112::/48 + 2620:4f:8000::/48 + } diff --git a/tests/reference/openbgpd--asp.txt b/tests/reference/openbgpd--asp.txt new file mode 100644 index 0000000..3db074c --- /dev/null +++ b/tests/reference/openbgpd--asp.txt @@ -0,0 +1 @@ +allow from AS 112 AS 112 diff --git a/tests/reference/routeros6--4.txt b/tests/reference/routeros6--4.txt new file mode 100644 index 0000000..157a9ff --- /dev/null +++ b/tests/reference/routeros6--4.txt @@ -0,0 +1,2 @@ +/routing filter add action=accept chain="NN-V4" prefix=192.31.196.0/24 +/routing filter add action=accept chain="NN-V4" prefix=192.175.48.0/24 diff --git a/tests/reference/routeros6--6.txt b/tests/reference/routeros6--6.txt new file mode 100644 index 0000000..d4c82c6 --- /dev/null +++ b/tests/reference/routeros6--6.txt @@ -0,0 +1,2 @@ +/routing filter add action=accept chain="NN-V6" prefix=2001:4:112::/48 +/routing filter add action=accept chain="NN-V6" prefix=2620:4f:8000::/48 diff --git a/tests/reference/routeros7--4.txt b/tests/reference/routeros7--4.txt new file mode 100644 index 0000000..003bd6d --- /dev/null +++ b/tests/reference/routeros7--4.txt @@ -0,0 +1,2 @@ +/routing filter rule add chain="NN-V4" rule="if (dst=192.31.196.0/24) {accept}" +/routing filter rule add chain="NN-V4" rule="if (dst=192.175.48.0/24) {accept}" diff --git a/tests/reference/routeros7--6.txt b/tests/reference/routeros7--6.txt new file mode 100644 index 0000000..6bac4f5 --- /dev/null +++ b/tests/reference/routeros7--6.txt @@ -0,0 +1,2 @@ +/routing filter rule add chain="NN-V6" rule="if (dst=2001:4:112::/48) {accept}" +/routing filter rule add chain="NN-V6" rule="if (dst=2620:4f:8000::/48) {accept}" diff --git a/tests/reference/sros--4.txt b/tests/reference/sros--4.txt new file mode 100644 index 0000000..7b2b550 --- /dev/null +++ b/tests/reference/sros--4.txt @@ -0,0 +1,8 @@ +configure router policy-options +begin +no prefix-list "NN" +prefix-list "NN" + prefix 192.31.196.0/24 exact + prefix 192.175.48.0/24 exact +exit +commit diff --git a/tests/reference/sros--6.txt b/tests/reference/sros--6.txt new file mode 100644 index 0000000..8cb3ac6 --- /dev/null +++ b/tests/reference/sros--6.txt @@ -0,0 +1,8 @@ +configure router policy-options +begin +no prefix-list "NN" +prefix-list "NN" + prefix 2001:4:112::/48 exact + prefix 2620:4f:8000::/48 exact +exit +commit diff --git a/tests/reference/sros--asp.txt b/tests/reference/sros--asp.txt new file mode 100644 index 0000000..cdc2486 --- /dev/null +++ b/tests/reference/sros--asp.txt @@ -0,0 +1,7 @@ +configure router policy-options +begin +no as-path-group "NN" +as-path-group "NN" + entry 1 expression "112+" +exit +commit diff --git a/tests/reference/sros-mdcli--4.txt b/tests/reference/sros-mdcli--4.txt new file mode 100644 index 0000000..3749a31 --- /dev/null +++ b/tests/reference/sros-mdcli--4.txt @@ -0,0 +1,8 @@ +/configure policy-options +delete prefix-list "NN" +prefix-list "NN" { + prefix 192.31.196.0/24 type exact { + } + prefix 192.175.48.0/24 type exact { + } +} diff --git a/tests/reference/sros-mdcli--6.txt b/tests/reference/sros-mdcli--6.txt new file mode 100644 index 0000000..5a72613 --- /dev/null +++ b/tests/reference/sros-mdcli--6.txt @@ -0,0 +1,8 @@ +/configure policy-options +delete prefix-list "NN" +prefix-list "NN" { + prefix 2001:4:112::/48 type exact { + } + prefix 2620:4f:8000::/48 type exact { + } +} diff --git a/tests/reference/sros-mdcli--asp.txt b/tests/reference/sros-mdcli--asp.txt new file mode 100644 index 0000000..1bc9e5b --- /dev/null +++ b/tests/reference/sros-mdcli--asp.txt @@ -0,0 +1,7 @@ +/configure policy-options +delete as-path-group "NN" +as-path-group "NN" { + entry 1 { + expression "112+" + } +} From 73bd27929b1739ea2f2642a83a6c87b2dd4a0079 Mon Sep 17 00:00:00 2001 From: James Bensley Date: Thu, 6 Apr 2023 16:33:19 +0100 Subject: [PATCH 2/2] Update README regarding unit tests Update README regarding unit tests --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 6478fc5..820d8c9 100644 --- a/README.md +++ b/README.md @@ -479,6 +479,12 @@ generates access-list to standard output and exits with status == 0. In case of errors they are printed to stderr and the program exits with non-zero status. +# TESTS + +The [tests/](tests/) folder contains reference output data in [text files](tests/reference/). The [generate_outputs.sh](tests/generate_outputs.sh) script is used in the [Github workflow](.github/workflows/unit-tests.yml) to generate the same output data, using the latest commit, and compare the output data to the stored "known-good" reference data, and check there are no changes. + +To update the reference data (i.e. if the bgpq4 output is modified), simply run the script again (`./tests/generate_outputs.sh ./bgpq4 tests/reference`) and commit the changes. + # AUTHORS Alexandre Snarskii, Christian David, Claudio Jeker, Job Snijders,