1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-21 02:05:16 +03:00
aports/community/miniupnpd/missing-test-scripts.patch
Natanael Copa bcce51aa23 community/miniupnpd: upgrade to 2.2.2 and refactor
- remove the sed stuff
- pass configure opts instead of sed config.h
- don't leak aports' git ref into miniupnpd binary
- add missing test scripts
- refactor init.d script
- generate uuid from post-install
- improve error message when external/internal interface is missing
2021-07-15 10:32:19 +00:00

100 lines
2.6 KiB
Diff

Those test scripts are in git but not in the release tarball.
https://github.com/miniupnp/miniupnp/tree/master/miniupnpd
diff --git a/testgetifaddr.sh b/testgetifaddr.sh
new file mode 100644
index 0000000..7ad56d9
--- /dev/null
+++ b/testgetifaddr.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+# $Id: testgetifaddr.sh,v 1.2 2015/09/22 14:48:09 nanard Exp $
+
+OS=`uname -s`
+case $OS in
+ *BSD | Darwin | SunOS)
+ NS="`which netstat`" || exit 1
+ IFCONFIG="`which ifconfig`" || exit 1
+ EXTIF="`$NS -r -f inet | grep 'default' | awk '{ print $NF }' `" || exit 1
+ EXTIP="`$IFCONFIG $EXTIF | awk '/inet / { print $2 }' `"
+ ;;
+ *)
+ IP="`which ip`" || exit 1
+ EXTIF="`LC_ALL=C $IP -4 route | grep 'default' | sed -e 's/.*dev[[:space:]]*//' -e 's/[[:space:]].*//'`" || exit 1
+ EXTIP="`LC_ALL=C $IP -4 addr show $EXTIF | awk '/inet/ { print $2 }' | cut -d "/" -f 1`"
+ ;;
+esac
+
+#echo "Interface : $EXTIF IP address : $EXTIP"
+RES=`./testgetifaddr $EXTIF | head -n1 | sed 's/Interface .* has IP address \(.*\)\./\1/'` || exit 1
+
+
+if [ "$RES" = "$EXTIP" ] ; then
+ echo "testgetifaddr test OK"
+ exit 0
+else
+ echo "testgetifaddr test FAILED : $EXTIP != $RES"
+ exit 1
+fi
diff --git a/testupnppermissions.sh b/testupnppermissions.sh
new file mode 100644
index 0000000..b7bee35
--- /dev/null
+++ b/testupnppermissions.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+# $Id: testupnppermissions.sh,v 1.2 2015/09/22 15:12:14 nanard Exp $
+
+RULE_1="allow 1-20000 11.12.13.14/22 1234"
+RULEA_1="allow 1-20000 0b0c0d0e/fffffc00 1234-1234"
+RULEB_1="allow 1-20000 11.12.13.14/255.255.252.0 1234-1234"
+RULE_2="deny 55 21.22.23.24/17 555-559"
+RULEA_2="deny 55-55 15161718/ffff8000 555-559"
+RULEB_2="deny 55-55 21.22.23.24/255.255.128.0 555-559"
+
+i=1
+s=1
+./testupnppermissions "$RULE_1" "$RULE_2" | while read l;
+do
+ if [ -z "$l" ]; then i=$(($i+1)); s=1; else
+ #echo "$i $s : checking '$l'"
+ case $s in
+ 1)
+ val=$(eval echo "\${RULE_$i}")
+ if [ "$i '$val'" != "$l" ] ; then
+ exit $s
+ fi;;
+ 2)
+ val=$(eval echo "\${RULEA_$i}")
+ if [ "Permission read successfully" = "$l" ] ; then
+ s=$(($s+1))
+ elif [ "perm rule added : $val" != "$l" ] ; then
+ exit $s
+ fi;;
+ 3)
+ if [ "Permission read successfully" != "$l" ] ; then
+ exit $s
+ fi;;
+ 4)
+ val=$(eval echo "\${RULEB_$i}")
+ if [ "$val" != "$l" ] ; then
+ exit $s
+ fi;;
+ *)
+ echo "$i $s : $l"
+ exit $s
+ ;;
+ esac
+ s=$(($s+1))
+ fi
+done
+
+# retrieve return status from subshell
+r=$?
+
+if [ $r -eq 0 ] ; then
+ echo "testupnppermissions tests OK"
+else
+ echo "testupnppermissions tests FAILED"
+fi
+exit $r