mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 22:45:39 +00:00
[master] Refactor RDATA unit tests
4667. [cleanup] Refactor RDATA unit tests. [RT #45610]
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
@@ -19,6 +21,7 @@
|
||||
#include <isc/entropy.h>
|
||||
#include <isc/file.h>
|
||||
#include <isc/hash.h>
|
||||
#include <isc/hex.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/os.h>
|
||||
#include <isc/print.h>
|
||||
@@ -353,6 +356,29 @@ fromhex(char c) {
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/*
|
||||
* Format contents of given memory region as a hex string, using the buffer
|
||||
* of length 'buflen' pointed to by 'buf'. 'buflen' must be at least three
|
||||
* times 'len'. Always returns 'buf'.
|
||||
*/
|
||||
char *
|
||||
dns_test_tohex(const unsigned char *data, size_t len, char *buf, size_t buflen)
|
||||
{
|
||||
isc_constregion_t source = {
|
||||
.base = data,
|
||||
.length = len
|
||||
};
|
||||
isc_buffer_t target;
|
||||
isc_result_t result;
|
||||
|
||||
memset(buf, 0, buflen);
|
||||
isc_buffer_init(&target, buf, buflen);
|
||||
result = isc_hex_totext((isc_region_t *)&source, 1, " ", &target);
|
||||
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
|
||||
|
||||
return (buf);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_test_getdata(const char *file, unsigned char *buf,
|
||||
size_t bufsiz, size_t *sizep)
|
||||
|
Reference in New Issue
Block a user