From 861eba2bab4465ffc3dc5e6309e89519594f0ea1 Mon Sep 17 00:00:00 2001 From: ng0 Date: Mon, 25 Nov 2019 22:13:05 +0000 Subject: test_gnunet_gns.sh: use shlib --- src/gns/Makefile.am | 16 ++++++++++++--- src/gns/test_gnunet_gns.sh | 46 ------------------------------------------- src/gns/test_gnunet_gns.sh.in | 43 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 49 deletions(-) delete mode 100755 src/gns/test_gnunet_gns.sh create mode 100755 src/gns/test_gnunet_gns.sh.in (limited to 'src') diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am index 253f67d29..d0a9f07cb 100644 --- a/src/gns/Makefile.am +++ b/src/gns/Makefile.am @@ -10,6 +10,8 @@ SUBDIRS = . $(NSS_SUBDIR) pkgdata_DATA = \ gnunet-gns-proxy-ca.template + + EXTRA_DIST = \ test_gns_defaults.conf \ test_gns_lookup.conf \ @@ -21,7 +23,8 @@ EXTRA_DIST = \ zonefiles/OEFL7A4VEF1B40QLEMTG5D8G1CN6EN16QUSG5R2DT71GRJN34LSG.zkey \ zonefiles/test_zonekey \ $(check_SCRIPTS) \ - $(pkgdata_DATA) + $(pkgdata_DATA) \ + test_gnunet_gns.sh.in USE_VPN = $(top_builddir)/src/vpn/libgnunetvpn.la @@ -91,12 +94,19 @@ bin_SCRIPTS = \ gnunet-gns-proxy-setup-ca # See: https://www.gnu.org/software/automake/manual/html_node/Scripts.html#Scripts -do_subst = sed -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' +do_subst = $(SED) -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' gnunet-gns-proxy-setup-ca: gnunet-gns-proxy-setup-ca.in Makefile $(do_subst) < $(srcdir)/gnunet-gns-proxy-setup-ca.in > gnunet-gns-proxy-setup-ca - chmod +x gnunet-gns-proxy-setup-ca + @chmod +x gnunet-gns-proxy-setup-ca + +do_subst_pkgdatadir = $(SED) -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' + +test_gnunet_gns.sh: test_gnunet_gns.sh.in Makefile + $(do_subst_pkgdatadir) < $(srcdir)/test_gnunet_gns.sh.in > test_gnunet_gns.sh + @chmod +x test_gnunet_gns.sh +CLEANFILES += test_gnunet_gns.sh libgnunet_plugin_rest_gns_la_SOURCES = \ plugin_rest_gns.c diff --git a/src/gns/test_gnunet_gns.sh b/src/gns/test_gnunet_gns.sh deleted file mode 100755 index 74c49c537..000000000 --- a/src/gns/test_gnunet_gns.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -# This file is in the public domain. -# test -z being correct was a false assumption here. -# I have no executable 'fooble', but this will -# return 1: -# if test -z "`which fooble`"; then echo 1; fi -# The command builtin might not work with busybox's ash -# but this works for now. -existence() -{ - command -v "$1" >/dev/null 2>&1 -} - -LOCATION=`existence gnunet-config` -if test -z $LOCATION; then - LOCATION="gnunet-config" -fi -$LOCATION --version -if test $? != 0 -then - echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" - exit 77 -fi - -trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT -ME=`whoami` -if [ "$ME" != "root" ] -then - echo "This test only works if run as root. Skipping." - exit 77 -fi -export PATH=".:$PATH" -gnunet-service-gns -c gns.conf & -sleep 1 -LO=`nslookup alice.gnu | grep Address | tail -n1` -if [ "$LO" != "Address: 1.2.3.4" ] -then - echo "Fail: $LO" -fi -LO=`nslookup www.bob.gnu | grep Address | tail -n1` -if [ "$LO" != "Address: 4.5.6.7" ] -then - echo "Fail: $LO" -fi -# XXX: jobs. a builtin by bash, netbsd sh, maybe leave it be for now. -kill `jobs -p` diff --git a/src/gns/test_gnunet_gns.sh.in b/src/gns/test_gnunet_gns.sh.in new file mode 100755 index 000000000..1c149b141 --- /dev/null +++ b/src/gns/test_gnunet_gns.sh.in @@ -0,0 +1,43 @@ +#!/bin/sh +# This file is in the public domain. +# test -z being correct was a false assumption here. +# I have no executable 'fooble', but this will +# return 1: +# if test -z "`which fooble`"; then echo 1; fi +# The command builtin might not work with busybox's ash +# but this works for now. +. @pkgdatadir@/existence.sh + +LOCATION=`existence gnunet-config` +if test -z $LOCATION; then + LOCATION="gnunet-config" +fi +$LOCATION --version +if test $? != 0 +then + echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" + exit 77 +fi + +trap "gnunet-arm -e -c test_gns_lookup.conf" SIGINT +ME=`whoami` +if [ "$ME" != "root" ] +then + echo "This test only works if run as root. Skipping." + exit 77 +fi +export PATH=".:$PATH" +gnunet-service-gns -c gns.conf & +sleep 1 +LO=`nslookup alice.gnu | grep Address | tail -n1` +if [ "$LO" != "Address: 1.2.3.4" ] +then + echo "Fail: $LO" +fi +LO=`nslookup www.bob.gnu | grep Address | tail -n1` +if [ "$LO" != "Address: 4.5.6.7" ] +then + echo "Fail: $LO" +fi +# XXX: jobs. a builtin by bash, netbsd sh, maybe leave it be for now. +kill `jobs -p` -- cgit v1.2.3