]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
create basis for tpkg test
authorTCY16 <tom@nlnetlabs.nl>
Mon, 23 May 2022 14:05:31 +0000 (16:05 +0200)
committerTCY16 <tom@nlnetlabs.nl>
Mon, 23 May 2022 14:05:31 +0000 (16:05 +0200)
Makefile.in
ldns/ldns.h
test/16-unit-tests-edns.tpkg/16-unit-tests-edns.Makefile.in [new file with mode: 0644]
test/16-unit-tests-edns.tpkg/16-unit-tests-edns.c [new file with mode: 0644]
test/16-unit-tests-edns.tpkg/16-unit-tests-edns.configure.ac [new file with mode: 0644]
test/16-unit-tests-edns.tpkg/16-unit-tests-edns.dsc [new file with mode: 0644]
test/16-unit-tests-edns.tpkg/16-unit-tests-edns.pre [new file with mode: 0644]
test/16-unit-tests-edns.tpkg/16-unit-tests-edns.test [new file with mode: 0644]

index 4cd4c90674ff8a25ac6fe44258c16ded5bc831c9..e634433569fea759e62d99ece6920c2a7a749240 100644 (file)
@@ -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 \
index 74713a211ae812b7e8ddcdc7a583ac48eb3c1698..9b0bc066b0fcf0046795849e3ee6508ad104257e 100644 (file)
@@ -101,6 +101,7 @@ Or you can just use the menu above to browse through the API docs.
 #include <ldns/dnssec_verify.h>
 #include <ldns/dnssec_sign.h>
 #include <ldns/duration.h>
+#include <ldns/edns.h>
 #include <ldns/error.h>
 #include <ldns/higher.h>
 #include <ldns/host2str.h>
@@ -123,7 +124,6 @@ Or you can just use the menu above to browse through the API docs.
 #include <ldns/rbtree.h>
 #include <ldns/sha1.h>
 #include <ldns/sha2.h>
-#include <ldns/edns.h>
 
 #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 (file)
index 0000000..6c69136
--- /dev/null
@@ -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 (file)
index 0000000..dc2e7fc
--- /dev/null
@@ -0,0 +1,47 @@
+
+
+#include "config.h"
+
+#include <ldns/ldns.h>
+
+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 (file)
index 0000000..47a0f33
--- /dev/null
@@ -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 <sys/param.h>
+   #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 <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <assert.h>
+
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+
+#ifdef HAVE_TIME_H
+#include <time.h>
+#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 (file)
index 0000000..a47c52a
--- /dev/null
@@ -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 (file)
index 0000000..ef15d50
--- /dev/null
@@ -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 (file)
index 0000000..ee8620f
--- /dev/null
@@ -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 $?