From: TCY16 Date: Mon, 23 May 2022 14:05:31 +0000 (+0200) Subject: create basis for tpkg test X-Git-Tag: 1.8.2-rc.1~3^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8097d24a48a99421882ccdf831e5c16ccdd6e25b;p=thirdparty%2Fldns.git create basis for tpkg test --- diff --git a/Makefile.in b/Makefile.in index 4cd4c906..e6344335 100644 --- a/Makefile.in +++ b/Makefile.in @@ -641,6 +641,7 @@ dnssec_zone.lo dnssec_zone.o: $(srcdir)/dnssec_zone.c ldns/config.h $(srcdir)/ld $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h duration.lo duration.o: $(srcdir)/duration.c ldns/config.h $(srcdir)/ldns/duration.h +edns.lo edns.o: $(srcdir)/edns.c $(srcdir)/ldns/ldns.h $(srcdir)/ldns/common.h error.lo error.o: $(srcdir)/error.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \ $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \ $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h $(srcdir)/ldns/zone.h \ diff --git a/ldns/ldns.h b/ldns/ldns.h index 74713a21..9b0bc066 100644 --- a/ldns/ldns.h +++ b/ldns/ldns.h @@ -101,6 +101,7 @@ Or you can just use the menu above to browse through the API docs. #include #include #include +#include #include #include #include @@ -123,7 +124,6 @@ Or you can just use the menu above to browse through the API docs. #include #include #include -#include #ifdef __cplusplus extern "C" { diff --git a/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.Makefile.in b/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.Makefile.in new file mode 100644 index 00000000..6c691362 --- /dev/null +++ b/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.Makefile.in @@ -0,0 +1,45 @@ +# Standard installation pathnames +# See the file LICENSE for the license +SHELL = @SHELL@ +VERSION = @PACKAGE_VERSION@ +basesrcdir = $(shell basename `pwd`) +srcdir = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +mandir = @mandir@ +datarootdir = @datarootdir@ + +CC = @CC@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ @LIBSSL_CPPFLAGS@ -I../.. +LDFLAGS = @LDFLAGS@ @LIBSSL_LDFLAGS@ -L../../.libs +LIBS = @LIBS@ @LIBSSL_SSL_LIBS@ -lldns + +COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) +LINK = $(CC) $(CFLAGS) $(LDFLAGS) + +HEADER = config.h +TESTS = 16-unit-tests-edns + +.PHONY: all clean realclean +%.o: + $(COMPILE) -c $(srcdir)/$*.c + +all: $(TESTS) + +13-unit-tests-base: 16-unit-tests-edns.o + $(LINK) -o $@ $+ $(LIBS) + +clean: + rm -f *.o + rm -f $(TESTS) + rm -f lua-rns + +realclean: clean + rm -rf autom4te.cache/ + rm -f config.log config.status aclocal.m4 config.h.in configure Makefile + rm -f config.h + +confclean: clean + rm -rf config.log config.status config.h Makefile diff --git a/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.c b/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.c new file mode 100644 index 00000000..dc2e7fc7 --- /dev/null +++ b/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.c @@ -0,0 +1,47 @@ + + +#include "config.h" + +#include + +static int +check_option() +{ + ldns_edns_option *edns; + uint8_t *data = LDNS_XMALLOC(uint8_t, 4); + data[0] = 74; + data[1] = 65; + data[2] = 73; + data[3] = 74; + + edns = ldns_edns_new(LDNS_EDNS_EDE, 4, data); + + if (ldns_edns_get_size(edns) != 4) { + printf("Error: EDNS size is incorrect\n"); + return 1; + } + if (ldns_edns_get_code(edns) != LDNS_EDNS_EDE) { + printf("Error: EDNS code is incorrect\n"); + return 1; + } + // if (ldns_edns_get_data(edns)) {} + // if (ldns_edns_get_wireformat_buffer(edns)) {} + + + + // ldns_edns_option *edns2 = ldns_edns_new_from_data(LDNS_EDNS_EDE, size_t size, const void *data); + + return 0; +} + +int main(void) +{ + int result = EXIT_SUCCESS; + + if (!check_option()) { + printf("check_option() failed.\n"); + result = EXIT_FAILURE; + } + + exit(result); +} diff --git a/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.configure.ac b/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.configure.ac new file mode 100644 index 00000000..47a0f337 --- /dev/null +++ b/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.configure.ac @@ -0,0 +1,96 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.57) +AC_INIT(drill, 1.1.0, ldns-team@nlnetlabs.nl, ldns-team) +AC_CONFIG_SRCDIR([13-unit-tests-base.c]) + +AC_AIX +# Checks for programs. +AC_PROG_CC +AC_PROG_MAKE_SET + +# Checks for libraries. +# Checks for header files. +#AC_HEADER_STDC +#AC_HEADER_SYS_WAIT +# do the very minimum - we can always extend this +AC_CHECK_HEADERS([getopt.h stdlib.h stdio.h assert.h netinet/in.hctype.h time.h]) +AC_CHECK_HEADERS(sys/param.h sys/mount.h,,, +[ + [ + #if HAVE_SYS_PARAM_H + # include + #endif + ] +]) + +# ssl dir if needed +AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=PATH], [set ssl library directory]), +[ + CPPFLAGS="$CPPFLAGS -I$withval/include" + LDFLAGS="$LDFLAGS -L$withval -L$withval/lib" +]) + +# check for ldns +AC_ARG_WITH(ldns, + AC_HELP_STRING([--with-ldns=PATH specify prefix of path of ldns library to use]) + , + [ + specialldnsdir="$withval" + CPPFLAGS="$CPPFLAGS -I$withval/include" + LDFLAGS="$LDFLAGS -L$withval/lib" + ] +) + +AC_CHECK_LIB(ldns, ldns_rr_new,, [ + AC_MSG_ERROR([Can't find ldns library]) + ] +) + +AC_CHECK_HEADER(ldns/ldns.h,, [ + AC_MSG_ERROR([Can't find ldns headers]) + ] +) + +AH_BOTTOM([ + +#include +#include +#include +#include + +#if STDC_HEADERS +#include +#include +#endif + +#ifdef HAVE_STDINT_H +#include +#endif + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +#ifdef HAVE_NETINET_IN_H +#include +#endif + +#ifdef HAVE_ARPA_INET_H +#include +#endif + +#ifdef HAVE_TIME_H +#include +#endif +]) + + +#AC_CHECK_FUNCS([mkdir rmdir strchr strrchr strstr]) + +#AC_DEFINE_UNQUOTED(SYSCONFDIR, "$sysconfdir") + +AC_CONFIG_FILES([13-unit-tests-base.Makefile]) +AC_CONFIG_HEADER([config.h]) +AC_OUTPUT diff --git a/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.dsc b/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.dsc new file mode 100644 index 00000000..a47c52a0 --- /dev/null +++ b/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.dsc @@ -0,0 +1,16 @@ +BaseName: 16-unit-tests-edns +Version: 1.0 +Description: Run EDNS unit tests on base 32 / 64 converters and sha1/sha2 functions +CreationDate: Wed Mar 15 10:15:57 CET 2006 +Maintainer: Tom Carpay +Category: +Component: +CmdDepends: +Depends: +Help: +Pre: 16-unit-tests-edns.pre +Post: +Test: 16-unit-tests-edns.test +AuxFiles: 16-unit-tests-edns.Makefile.in 16-unit-tests-edns.configure.ac 16-unit-tests-edns.c +Passed: +Failure: diff --git a/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.pre b/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.pre new file mode 100644 index 00000000..ef15d50f --- /dev/null +++ b/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.pre @@ -0,0 +1,45 @@ +# #-- 16-unit-tests-edns.pre--# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test +# svnserve resets the path, you may need to adjust it, like this: +export PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. + +conf=`which autoconf` ||\ +conf=`which autoconf-2.59` ||\ +conf=`which autoconf-2.61` ||\ +conf=`which autoconf259` + +hdr=`which autoheader` ||\ +hdr=`which autoheader-2.59` ||\ +hdr=`which autoheader-2.61` ||\ +hdr=`which autoheader259` + +mk=`which gmake` ||\ +mk=`which make` + +echo "autoconf: $conf" +echo "autoheader: $hdr" +echo "make: $mk" + +opts=`../../config.status --config` +echo options: $opts + +if [ ! $mk ] || [ ! $conf ] || [ ! $hdr ] ; then + echo "Error, one or more build tools not found, aborting" + exit 1 +fi; + +ssl=`` +if [[ "$OSTYPE" == "darwin"* && -d "/opt/homebrew/Cellar/openssl@1.1" ]]; then + ssl=/opt/homebrew/Cellar/openssl@1.1/1.1.1n/ +fi; + +#$conf 13-unit-tests-base.configure.ac > configure && \ +#chmod +x configure && \ +#$hdr 13-unit-tests-base.configure.ac &&\ +#eval ./configure --with-ldns=../../ with-ssl=$ssl "$opts" && \ +../../config.status --file 16-unit-tests-edns.Makefile +$mk -f 16-unit-tests-edns.Makefile + diff --git a/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.test b/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.test new file mode 100644 index 00000000..ee8620fa --- /dev/null +++ b/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.test @@ -0,0 +1,14 @@ +# #-- 16-unit-tests-edns.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test +# svnserve resets the path, you may need to adjust it, like this: +#PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:. + +export LD_LIBRARY_PATH="../../lib:$LD_LIBRARY_PATH" +export DYLD_LIBRARY_PATH="../../lib:$DYLD_LIBRARY_PATH" + +# run the test +./16-unit-tests-edns +exit $?