From b25103be2e46a6f5ad39c20334b4e5fd898ff3bf Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Fri, 8 Sep 2023 16:50:47 +0100 Subject: [PATCH] test script for odhcp6-script --- pkgs/odhcp-script/expected | 26 ++++++++++++++++++++++++++ pkgs/odhcp-script/test.env | 29 +++++++++++++++++++++++++++++ pkgs/odhcp-script/test.sh | 16 ++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 pkgs/odhcp-script/expected create mode 100644 pkgs/odhcp-script/test.env create mode 100755 pkgs/odhcp-script/test.sh diff --git a/pkgs/odhcp-script/expected b/pkgs/odhcp-script/expected new file mode 100644 index 0000000..1acd0d9 --- /dev/null +++ b/pkgs/odhcp-script/expected @@ -0,0 +1,26 @@ +./address/2001-8b0-1111-1111-0-ffff-1234-5678/address:2001:8b0:1111:1111:0:ffff:1234:5678 +./address/2001-8b0-1111-1111-0-ffff-1234-5678/len:128 +./address/2001-8b0-1111-1111-0-ffff-1234-5678/preferred:3600 +./address/2001-8b0-1111-1111-0-ffff-1234-5678/valid:7200 +./addresses:2001:8b0:1111:1111:0:ffff:1234:5678/128,3600,7200 +./ifname:ppp0 +./option_1:000300018cfdf02420eb +./option_2:000300010df0feca0df0 +./passthru:00170020200108b0000000000000000000002020200108b0000000000000000000002021 +./prefix/2001-8b0-de3a-22/address:2001:8b0:de3a:22:: +./prefix/2001-8b0-de3a-22/len:64 +./prefix/2001-8b0-de3a-22/preferred:7200 +./prefix/2001-8b0-de3a-22/valid:7200 +./prefix/2001-8b0-de3a-abcd/address:2001:8b0:de3a:abcd:: +./prefix/2001-8b0-de3a-abcd/len:64 +./prefix/2001-8b0-de3a-abcd/preferred:7200 +./prefix/2001-8b0-de3a-abcd/valid:7200 +./prefixes:2001:8b0:de3a:abcd::/64,7200,7200 2001:8b0:de3a:22::/64,7200,7200 +./ra_hoplimit:64 +./ra_mtu:0 +./ra_reachable:0 +./ra_retransmit:0 +./ra_routes:::/0,fe80::203:97ff:fed6:0,65533,512 +./rdnss:2001:8b0::2020 2001:8b0::2021 +./server:fe80::203:97ff:fed6:0 +./state:bound diff --git a/pkgs/odhcp-script/test.env b/pkgs/odhcp-script/test.env new file mode 100644 index 0000000..8fd88e2 --- /dev/null +++ b/pkgs/odhcp-script/test.env @@ -0,0 +1,29 @@ +RA_ADDRESSES= +RA_REACHABLE=0 +USER=root +CER= +PASSTHRU=00170020200108b0000000000000000000002020200108b0000000000000000000002021 +SHLVL=2 +SERVER=fe80::203:97ff:fed6:0 +HOME=/home/root/ +RA_MTU=0 +RA_ROUTES=::/0,fe80::203:97ff:fed6:0,65533,512 +OPTION_1=000300018cfdf02420eb +NTP_FQDN= +OPTION_2=000300010df0feca0df0 +RA_DOMAINS= +DOMAINS= +LOGNAME=root +AFTR= +SIP_IP= +NTP_IP= +PREFIXES="2001:8b0:de3a:abcd::/64,7200,7200 2001:8b0:de3a:22::/64,7200,7200" +RA_HOPLIMIT=64 +SHELL=/bin/sh +RA_DNS= +RDNSS="2001:8b0::2020 2001:8b0::2021" +SNTP_IP= +RA_RETRANSMIT=0 +SIP_DOMAIN= +PWD=/home/root +ADDRESSES=2001:8b0:1111:1111:0:ffff:1234:5678/128,3600,7200 \ No newline at end of file diff --git a/pkgs/odhcp-script/test.sh b/pkgs/odhcp-script/test.sh new file mode 100755 index 0000000..c6fbbd9 --- /dev/null +++ b/pkgs/odhcp-script/test.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env sh +set -e + +statedir=$(mktemp -d) + +cleanup(){ + test -n "$statedir" && test -d $statedir && rm -rf $statedir +} +trap 'exit 1' INT HUP QUIT TERM ALRM USR1 +trap 'cleanup' EXIT + +(set -a; . ./test.env ; SERVICE_STATE=$statedir fennelrepl odhcp6-script.fnl ppp0 bound) 10>&1 + +(cd $statedir && find . -type f | xargs grep '' | sort) > actual +diff -u expected actual +cmp expected actual