geoip2_c 0.3.4 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +23 -0
- data/.github/workflows/ubuntu.yml +17 -8
- data/.github/workflows/windows.yml +18 -8
- data/.gitmodules +0 -3
- data/ext/geoip2/extconf.rb +9 -25
- data/ext/geoip2/geoip2.c +82 -32
- data/geoip2_c.gemspec +1 -0
- data/lib/geoip2/version.rb +1 -1
- metadata +18 -182
- data/ext/geoip2/libmaxminddb/.gitignore +0 -38
- data/ext/geoip2/libmaxminddb/.gitmodules +0 -9
- data/ext/geoip2/libmaxminddb/.perltidyrc +0 -11
- data/ext/geoip2/libmaxminddb/.travis.yml +0 -70
- data/ext/geoip2/libmaxminddb/.uncrustify.cfg +0 -78
- data/ext/geoip2/libmaxminddb/AUTHORS +0 -0
- data/ext/geoip2/libmaxminddb/Changes.md +0 -277
- data/ext/geoip2/libmaxminddb/LICENSE +0 -202
- data/ext/geoip2/libmaxminddb/Makefile.am +0 -41
- data/ext/geoip2/libmaxminddb/NOTICE +0 -13
- data/ext/geoip2/libmaxminddb/README.dev.md +0 -69
- data/ext/geoip2/libmaxminddb/README.md +0 -122
- data/ext/geoip2/libmaxminddb/appveyor.yml +0 -33
- data/ext/geoip2/libmaxminddb/bin/Makefile.am +0 -10
- data/ext/geoip2/libmaxminddb/bin/mmdblookup.c +0 -715
- data/ext/geoip2/libmaxminddb/bootstrap +0 -21
- data/ext/geoip2/libmaxminddb/common.mk +0 -7
- data/ext/geoip2/libmaxminddb/configure.ac +0 -132
- data/ext/geoip2/libmaxminddb/dev-bin/make-man-pages.pl +0 -76
- data/ext/geoip2/libmaxminddb/dev-bin/ppa-release.sh +0 -53
- data/ext/geoip2/libmaxminddb/dev-bin/regen-prototypes.pl +0 -136
- data/ext/geoip2/libmaxminddb/dev-bin/regen-win32-test-projs.pl +0 -54
- data/ext/geoip2/libmaxminddb/dev-bin/release.sh +0 -113
- data/ext/geoip2/libmaxminddb/dev-bin/uncrustify-all.sh +0 -21
- data/ext/geoip2/libmaxminddb/dev-bin/valgrind-all.pl +0 -53
- data/ext/geoip2/libmaxminddb/doc/libmaxminddb.md +0 -889
- data/ext/geoip2/libmaxminddb/doc/mmdblookup.md +0 -103
- data/ext/geoip2/libmaxminddb/include/maxminddb.h +0 -241
- data/ext/geoip2/libmaxminddb/include/maxminddb_config.h.in +0 -14
- data/ext/geoip2/libmaxminddb/projects/VS12/README.md +0 -59
- data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb-release.props +0 -32
- data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb-x64.props +0 -14
- data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.props +0 -32
- data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.sln +0 -150
- data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.vcxproj +0 -143
- data/ext/geoip2/libmaxminddb/projects/VS12/libmaxminddb.vcxproj.filters +0 -32
- data/ext/geoip2/libmaxminddb/projects/VS12/maxminddb_config.h +0 -14
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/bad_pointers.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/basic_lookup.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/data_entry_list.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/data_types.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/dump.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/get_value.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/get_value_pointer_bug.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/ipv4_start_cache.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/ipv6_lookup_in_ipv4.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/libtap.vcxproj +0 -85
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/maxminddb_test_helper.vcxproj +0 -107
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/metadata.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/metadata_pointers.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/no_map_get_value.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/read_node.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/shared.vcxproj +0 -104
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/threads.vcxproj +0 -103
- data/ext/geoip2/libmaxminddb/projects/VS12-tests/version.vcxproj +0 -105
- data/ext/geoip2/libmaxminddb/projects/test.vcxproj.template +0 -105
- data/ext/geoip2/libmaxminddb/src/Makefile.am +0 -25
- data/ext/geoip2/libmaxminddb/src/data-pool.c +0 -180
- data/ext/geoip2/libmaxminddb/src/data-pool.h +0 -52
- data/ext/geoip2/libmaxminddb/src/libmaxminddb.pc.in +0 -11
- data/ext/geoip2/libmaxminddb/src/maxminddb-compat-util.h +0 -167
- data/ext/geoip2/libmaxminddb/src/maxminddb.c +0 -2181
- data/ext/geoip2/libmaxminddb/t/Makefile.am +0 -27
- data/ext/geoip2/libmaxminddb/t/bad_databases_t.c +0 -67
- data/ext/geoip2/libmaxminddb/t/bad_pointers_t.c +0 -53
- data/ext/geoip2/libmaxminddb/t/basic_lookup_t.c +0 -207
- data/ext/geoip2/libmaxminddb/t/compile_c++_t.pl +0 -107
- data/ext/geoip2/libmaxminddb/t/data-pool-t.c +0 -374
- data/ext/geoip2/libmaxminddb/t/data_entry_list_t.c +0 -353
- data/ext/geoip2/libmaxminddb/t/data_types_t.c +0 -439
- data/ext/geoip2/libmaxminddb/t/dump_t.c +0 -103
- data/ext/geoip2/libmaxminddb/t/external_symbols_t.pl +0 -106
- data/ext/geoip2/libmaxminddb/t/get_value_pointer_bug_t.c +0 -66
- data/ext/geoip2/libmaxminddb/t/get_value_t.c +0 -249
- data/ext/geoip2/libmaxminddb/t/ipv4_start_cache_t.c +0 -36
- data/ext/geoip2/libmaxminddb/t/ipv6_lookup_in_ipv4_t.c +0 -48
- data/ext/geoip2/libmaxminddb/t/libtap/.gitignore +0 -13
- data/ext/geoip2/libmaxminddb/t/libtap/.travis.yml +0 -13
- data/ext/geoip2/libmaxminddb/t/libtap/COPYING +0 -165
- data/ext/geoip2/libmaxminddb/t/libtap/INSTALL +0 -41
- data/ext/geoip2/libmaxminddb/t/libtap/Makefile +0 -72
- data/ext/geoip2/libmaxminddb/t/libtap/Makefile.win +0 -37
- data/ext/geoip2/libmaxminddb/t/libtap/README.md +0 -268
- data/ext/geoip2/libmaxminddb/t/libtap/t/cmp_mem.c +0 -20
- data/ext/geoip2/libmaxminddb/t/libtap/t/cmp_mem.expected +0 -28
- data/ext/geoip2/libmaxminddb/t/libtap/t/cmpok.c +0 -16
- data/ext/geoip2/libmaxminddb/t/libtap/t/cmpok.expected +0 -37
- data/ext/geoip2/libmaxminddb/t/libtap/t/diag.c +0 -10
- data/ext/geoip2/libmaxminddb/t/libtap/t/diag.expected +0 -2
- data/ext/geoip2/libmaxminddb/t/libtap/t/diesok.c +0 -14
- data/ext/geoip2/libmaxminddb/t/libtap/t/diesok.expected +0 -6
- data/ext/geoip2/libmaxminddb/t/libtap/t/is.c +0 -24
- data/ext/geoip2/libmaxminddb/t/libtap/t/is.expected +0 -58
- data/ext/geoip2/libmaxminddb/t/libtap/t/like.c +0 -10
- data/ext/geoip2/libmaxminddb/t/libtap/t/like.expected +0 -4
- data/ext/geoip2/libmaxminddb/t/libtap/t/simple.c +0 -31
- data/ext/geoip2/libmaxminddb/t/libtap/t/simple.expected +0 -32
- data/ext/geoip2/libmaxminddb/t/libtap/t/skip.c +0 -23
- data/ext/geoip2/libmaxminddb/t/libtap/t/skip.expected +0 -9
- data/ext/geoip2/libmaxminddb/t/libtap/t/synopsis.c +0 -13
- data/ext/geoip2/libmaxminddb/t/libtap/t/synopsis.expected +0 -9
- data/ext/geoip2/libmaxminddb/t/libtap/t/test.c +0 -28
- data/ext/geoip2/libmaxminddb/t/libtap/t/todo.c +0 -17
- data/ext/geoip2/libmaxminddb/t/libtap/t/todo.expected +0 -11
- data/ext/geoip2/libmaxminddb/t/libtap/tap.c +0 -354
- data/ext/geoip2/libmaxminddb/t/libtap/tap.h +0 -115
- data/ext/geoip2/libmaxminddb/t/maxmind-db/.gitattributes +0 -1
- data/ext/geoip2/libmaxminddb/t/maxmind-db/.gitconfig +0 -2
- data/ext/geoip2/libmaxminddb/t/maxmind-db/.gitignore +0 -2
- data/ext/geoip2/libmaxminddb/t/maxmind-db/.perltidyallrc +0 -11
- data/ext/geoip2/libmaxminddb/t/maxmind-db/.tidyallrc +0 -7
- data/ext/geoip2/libmaxminddb/t/maxmind-db/LICENSE +0 -4
- data/ext/geoip2/libmaxminddb/t/maxmind-db/MaxMind-DB-spec.md +0 -558
- data/ext/geoip2/libmaxminddb/t/maxmind-db/README.md +0 -4
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/README.md +0 -7
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/libmaxminddb/libmaxminddb-offset-integer-overflow.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/cyclic-data-structure.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/invalid-bytes-length.mmdb +0 -1
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/invalid-data-record-offset.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/invalid-map-key-length.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/invalid-string-length.mmdb +0 -1
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/metadata-is-an-uint128.mmdb +0 -1
- data/ext/geoip2/libmaxminddb/t/maxmind-db/bad-data/maxminddb-golang/unexpected-bytes.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/perltidyrc +0 -12
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Anonymous-IP-Test.json +0 -32
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-City-Test.json +0 -12616
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Connection-Type-Test.json +0 -102
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Country-Test.json +0 -10975
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-DensityIncome-Test.json +0 -14
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Domain-Test.json +0 -452
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Enterprise-Test.json +0 -666
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-ISP-Test.json +0 -12585
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoIP2-Precision-Enterprise-Test.json +0 -1035
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/GeoLite2-ASN-Test.json +0 -37
- data/ext/geoip2/libmaxminddb/t/maxmind-db/source-data/README +0 -13
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Anonymous-IP-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-City-Test-Broken-Double-Format.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-City-Test-Invalid-Node-Count.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-City-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Connection-Type-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Country-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-DensityIncome-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Domain-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Enterprise-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-ISP-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoIP2-Precision-Enterprise-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/GeoLite2-ASN-Test.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-string-value-entries.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-broken-pointers-24.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-decoder.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv4-24.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv4-28.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv4-32.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv6-24.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv6-28.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-ipv6-32.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-metadata-pointers.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-mixed-24.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-mixed-28.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-mixed-32.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/MaxMind-DB-test-nested.mmdb +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/README.md +0 -26
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/maps-with-pointers.raw +0 -0
- data/ext/geoip2/libmaxminddb/t/maxmind-db/test-data/write-test-data.pl +0 -614
- data/ext/geoip2/libmaxminddb/t/maxmind-db/tidyall.ini +0 -5
- data/ext/geoip2/libmaxminddb/t/maxminddb_test_helper.c +0 -255
- data/ext/geoip2/libmaxminddb/t/maxminddb_test_helper.h +0 -69
- data/ext/geoip2/libmaxminddb/t/metadata_pointers_t.c +0 -32
- data/ext/geoip2/libmaxminddb/t/metadata_t.c +0 -226
- data/ext/geoip2/libmaxminddb/t/mmdblookup_t.pl +0 -158
- data/ext/geoip2/libmaxminddb/t/no_map_get_value_t.c +0 -32
- data/ext/geoip2/libmaxminddb/t/read_node_t.c +0 -157
- data/ext/geoip2/libmaxminddb/t/threads_t.c +0 -196
- data/ext/geoip2/libmaxminddb/t/version_t.c +0 -10
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
#if HAVE_CONFIG_H
|
|
2
|
-
#include <config.h>
|
|
3
|
-
#endif
|
|
4
|
-
|
|
5
|
-
#define _POSIX_C_SOURCE 200112L
|
|
6
|
-
#include <assert.h>
|
|
7
|
-
#include <stdarg.h>
|
|
8
|
-
#include <sys/types.h>
|
|
9
|
-
|
|
10
|
-
#include "maxminddb.h"
|
|
11
|
-
#include "maxminddb_test_helper.h"
|
|
12
|
-
|
|
13
|
-
#ifdef _WIN32
|
|
14
|
-
#include <io.h>
|
|
15
|
-
#else
|
|
16
|
-
#include <libgen.h>
|
|
17
|
-
#include <unistd.h>
|
|
18
|
-
#endif
|
|
19
|
-
|
|
20
|
-
#define NO_PROTO
|
|
21
|
-
|
|
22
|
-
#ifndef strndup
|
|
23
|
-
/* *INDENT-OFF* */
|
|
24
|
-
/* Copied from the libiberty strndup.c, which is LPGPL 2+ */
|
|
25
|
-
NO_PROTO char *strndup (const char *s, size_t n)
|
|
26
|
-
{
|
|
27
|
-
char *result;
|
|
28
|
-
size_t len = strlen (s);
|
|
29
|
-
|
|
30
|
-
if (n < len)
|
|
31
|
-
len = n;
|
|
32
|
-
|
|
33
|
-
result = (char *) malloc (len + 1);
|
|
34
|
-
if (!result)
|
|
35
|
-
return 0;
|
|
36
|
-
|
|
37
|
-
result[len] = '\0';
|
|
38
|
-
return (char *) memcpy (result, s, len);
|
|
39
|
-
}
|
|
40
|
-
/* *INDENT-ON* */
|
|
41
|
-
#endif
|
|
42
|
-
|
|
43
|
-
void for_all_record_sizes(const char *filename_fmt,
|
|
44
|
-
void (*tests)(int record_size, const char *filename,
|
|
45
|
-
const char *description))
|
|
46
|
-
{
|
|
47
|
-
int sizes[] = { 24, 28, 32 };
|
|
48
|
-
for (int i = 0; i < 3; i++) {
|
|
49
|
-
int size = sizes[i];
|
|
50
|
-
|
|
51
|
-
char filename[500];
|
|
52
|
-
snprintf(filename, 500, filename_fmt, size);
|
|
53
|
-
|
|
54
|
-
char description[14];
|
|
55
|
-
snprintf(description, 14, "%i bit record", size);
|
|
56
|
-
|
|
57
|
-
tests(size, filename, description);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
void for_all_modes(void (*tests)(int mode, const char *description))
|
|
62
|
-
{
|
|
63
|
-
tests(MMDB_MODE_MMAP, "mmap mode");
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const char *test_database_path(const char *filename)
|
|
67
|
-
{
|
|
68
|
-
char cwd[500];
|
|
69
|
-
char *UNUSED(tmp) = getcwd(cwd, 500);
|
|
70
|
-
|
|
71
|
-
char *test_db_dir;
|
|
72
|
-
#ifdef _WIN32
|
|
73
|
-
test_db_dir = "./t/maxmind-db/test-data";
|
|
74
|
-
#else
|
|
75
|
-
if (strcmp(basename(cwd), "t") == 0) {
|
|
76
|
-
test_db_dir = "./maxmind-db/test-data";
|
|
77
|
-
} else {
|
|
78
|
-
test_db_dir = "./t/maxmind-db/test-data";
|
|
79
|
-
}
|
|
80
|
-
#endif
|
|
81
|
-
|
|
82
|
-
char *path = malloc(500);
|
|
83
|
-
assert(NULL != path);
|
|
84
|
-
|
|
85
|
-
snprintf(path, 500, "%s/%s", test_db_dir, filename);
|
|
86
|
-
|
|
87
|
-
return (const char *)path;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const char *dup_entry_string_or_bail(MMDB_entry_data_s entry_data)
|
|
91
|
-
{
|
|
92
|
-
const char *string = strndup(entry_data.utf8_string, entry_data.data_size);
|
|
93
|
-
if (NULL == string) {
|
|
94
|
-
BAIL_OUT("strndup failed");
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return string;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
MMDB_s *open_ok(const char *db_file, int mode, const char *mode_desc)
|
|
101
|
-
{
|
|
102
|
-
if (0 != access(db_file, R_OK)) {
|
|
103
|
-
BAIL_OUT(
|
|
104
|
-
"could not read the specified file - %s\nIf you are in a git checkout try running 'git submodule update --init'",
|
|
105
|
-
db_file);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
MMDB_s *mmdb = (MMDB_s *)calloc(1, sizeof(MMDB_s));
|
|
109
|
-
|
|
110
|
-
if (NULL == mmdb) {
|
|
111
|
-
BAIL_OUT("could not allocate memory for our MMDB_s struct");
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
int status = MMDB_open(db_file, mode, mmdb);
|
|
115
|
-
|
|
116
|
-
int is_ok = ok(MMDB_SUCCESS == status, "open %s status is success - %s",
|
|
117
|
-
db_file, mode_desc);
|
|
118
|
-
|
|
119
|
-
if (!is_ok) {
|
|
120
|
-
diag("open status code = %d (%s)", status, MMDB_strerror(status));
|
|
121
|
-
free(mmdb);
|
|
122
|
-
return NULL;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
is_ok = ok(mmdb->file_size > 0,
|
|
126
|
-
"mmdb struct has been set for %s - %s",
|
|
127
|
-
db_file, mode_desc);
|
|
128
|
-
|
|
129
|
-
if (!is_ok) {
|
|
130
|
-
free(mmdb);
|
|
131
|
-
return NULL;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return mmdb;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
MMDB_lookup_result_s lookup_string_ok(MMDB_s *mmdb, const char *ip,
|
|
138
|
-
const char *file, const char *mode_desc)
|
|
139
|
-
{
|
|
140
|
-
int gai_error, mmdb_error;
|
|
141
|
-
MMDB_lookup_result_s result =
|
|
142
|
-
MMDB_lookup_string(mmdb, ip, &gai_error, &mmdb_error);
|
|
143
|
-
|
|
144
|
-
test_lookup_errors(gai_error, mmdb_error, "MMDB_lookup_string", ip, file,
|
|
145
|
-
mode_desc);
|
|
146
|
-
|
|
147
|
-
return result;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
MMDB_lookup_result_s lookup_sockaddr_ok(MMDB_s *mmdb, const char *ip,
|
|
151
|
-
const char *file, const char *mode_desc)
|
|
152
|
-
{
|
|
153
|
-
int ai_flags = AI_NUMERICHOST;
|
|
154
|
-
struct addrinfo hints = {
|
|
155
|
-
.ai_socktype = SOCK_STREAM
|
|
156
|
-
};
|
|
157
|
-
struct addrinfo *addresses = NULL;
|
|
158
|
-
|
|
159
|
-
if (ip[0] == ':') {
|
|
160
|
-
hints.ai_flags = ai_flags;
|
|
161
|
-
#if defined AI_V4MAPPED && !defined __FreeBSD__
|
|
162
|
-
hints.ai_flags |= AI_V4MAPPED;
|
|
163
|
-
#endif
|
|
164
|
-
hints.ai_family = AF_INET6;
|
|
165
|
-
} else {
|
|
166
|
-
hints.ai_flags = ai_flags;
|
|
167
|
-
hints.ai_family = AF_INET;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
int gai_error = getaddrinfo(ip, NULL, &hints, &addresses);
|
|
171
|
-
|
|
172
|
-
int mmdb_error = 0;
|
|
173
|
-
MMDB_lookup_result_s result = { .found_entry = false };
|
|
174
|
-
if (gai_error == 0) {
|
|
175
|
-
result = MMDB_lookup_sockaddr(mmdb, addresses->ai_addr, &mmdb_error);
|
|
176
|
-
}
|
|
177
|
-
if (NULL != addresses) {
|
|
178
|
-
freeaddrinfo(addresses);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
test_lookup_errors(gai_error, mmdb_error, "MMDB_lookup_sockaddr", ip, file,
|
|
182
|
-
mode_desc);
|
|
183
|
-
|
|
184
|
-
return result;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
void test_lookup_errors(int gai_error, int mmdb_error,
|
|
188
|
-
const char *function, const char *ip,
|
|
189
|
-
const char *file, const char *mode_desc)
|
|
190
|
-
{
|
|
191
|
-
|
|
192
|
-
int is_ok = ok(0 == gai_error,
|
|
193
|
-
"no getaddrinfo error in call to %s for %s - %s - %s",
|
|
194
|
-
function, ip, file, mode_desc);
|
|
195
|
-
|
|
196
|
-
if (!is_ok) {
|
|
197
|
-
diag("error from call to getaddrinfo for %s - %s",
|
|
198
|
-
ip, gai_strerror(gai_error));
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
is_ok = ok(0 == mmdb_error,
|
|
202
|
-
"no MMDB error in call to %s for %s - %s - %s",
|
|
203
|
-
function, ip, file, mode_desc);
|
|
204
|
-
|
|
205
|
-
if (!is_ok) {
|
|
206
|
-
diag("MMDB error - %s", MMDB_strerror(mmdb_error));
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
MMDB_entry_data_s data_ok(MMDB_lookup_result_s *result, uint32_t expect_type,
|
|
211
|
-
const char *description, ...)
|
|
212
|
-
{
|
|
213
|
-
va_list keys;
|
|
214
|
-
va_start(keys, description);
|
|
215
|
-
|
|
216
|
-
MMDB_entry_data_s data;
|
|
217
|
-
int status = MMDB_vget_value(&result->entry, &data, keys);
|
|
218
|
-
|
|
219
|
-
va_end(keys);
|
|
220
|
-
|
|
221
|
-
if (cmp_ok(status, "==", MMDB_SUCCESS,
|
|
222
|
-
"no error from call to MMDB_vget_value - %s", description)) {
|
|
223
|
-
|
|
224
|
-
if (!cmp_ok(data.type, "==", expect_type,
|
|
225
|
-
"got the expected data type - %s", description)) {
|
|
226
|
-
|
|
227
|
-
diag(" data type value is %i but expected %i", data.type,
|
|
228
|
-
expect_type);
|
|
229
|
-
}
|
|
230
|
-
} else {
|
|
231
|
-
diag(" error from MMDB_vget_value - %s", MMDB_strerror(status));
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return data;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
void compare_double(double got, double expect)
|
|
238
|
-
{
|
|
239
|
-
double diff = fabs(got - expect);
|
|
240
|
-
int is_ok = ok(diff < 0.01, "double value was approximately %2.6f", expect);
|
|
241
|
-
if (!is_ok) {
|
|
242
|
-
diag(" got %2.6f but expected %2.6f (diff = %2.6f)",
|
|
243
|
-
got, expect, diff);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
void compare_float(float got, float expect)
|
|
248
|
-
{
|
|
249
|
-
float diff = fabsf(got - expect);
|
|
250
|
-
int is_ok = ok(diff < 0.01, "float value was approximately %2.1f", expect);
|
|
251
|
-
if (!is_ok) {
|
|
252
|
-
diag(" got %2.4f but expected %2.1f (diff = %2.1f)",
|
|
253
|
-
got, expect, diff);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/* Some test files may require something newer */
|
|
2
|
-
#if !defined(_GNU_SOURCE) && !defined(_POSIX_C_SOURCE)
|
|
3
|
-
#define _POSIX_C_SOURCE 200112L
|
|
4
|
-
#endif
|
|
5
|
-
|
|
6
|
-
#if HAVE_CONFIG_H
|
|
7
|
-
#include <config.h>
|
|
8
|
-
#endif
|
|
9
|
-
#include <math.h>
|
|
10
|
-
#include <stdio.h>
|
|
11
|
-
#include <string.h>
|
|
12
|
-
#include "maxminddb.h"
|
|
13
|
-
#include "libtap/tap.h"
|
|
14
|
-
|
|
15
|
-
#ifdef _WIN32
|
|
16
|
-
#include <Winsock2.h>
|
|
17
|
-
#include <ws2tcpip.h>
|
|
18
|
-
|
|
19
|
-
#define R_OK 4
|
|
20
|
-
|
|
21
|
-
#else
|
|
22
|
-
#include <netdb.h>
|
|
23
|
-
#endif
|
|
24
|
-
|
|
25
|
-
#if (_MSC_VER && _MSC_VER < 1900)
|
|
26
|
-
/* _snprintf has security issues, but I don't think it is worth
|
|
27
|
-
worrying about for the unit tests. */
|
|
28
|
-
#define snprintf _snprintf
|
|
29
|
-
#endif
|
|
30
|
-
|
|
31
|
-
#ifndef MMDB_TEST_HELPER_C
|
|
32
|
-
#define MMDB_TEST_HELPER_C (1)
|
|
33
|
-
|
|
34
|
-
#ifdef __GNUC__
|
|
35
|
-
# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
|
|
36
|
-
#else
|
|
37
|
-
# define UNUSED
|
|
38
|
-
#endif
|
|
39
|
-
|
|
40
|
-
#define MAX_DESCRIPTION_LENGTH 500
|
|
41
|
-
|
|
42
|
-
#ifndef strndup
|
|
43
|
-
extern char *strndup(const char *s, size_t n);
|
|
44
|
-
#endif
|
|
45
|
-
|
|
46
|
-
/* *INDENT-OFF* */
|
|
47
|
-
/* --prototypes automatically generated by dev-bin/regen-prototypes.pl - don't remove this comment */
|
|
48
|
-
extern void for_all_record_sizes(const char *filename_fmt,
|
|
49
|
-
void (*tests)(int record_size, const char *filename,
|
|
50
|
-
const char *description));
|
|
51
|
-
extern void for_all_modes(void (*tests)(int mode, const char *description));
|
|
52
|
-
extern const char *test_database_path(const char *filename);
|
|
53
|
-
extern const char *dup_entry_string_or_bail(MMDB_entry_data_s entry_data);
|
|
54
|
-
extern MMDB_s *open_ok(const char *db_file, int mode, const char *mode_desc);
|
|
55
|
-
extern MMDB_lookup_result_s lookup_string_ok(MMDB_s *mmdb, const char *ip,
|
|
56
|
-
const char *file, const char *mode_desc);
|
|
57
|
-
extern MMDB_lookup_result_s lookup_sockaddr_ok(MMDB_s *mmdb, const char *ip,
|
|
58
|
-
const char *file, const char *mode_desc);
|
|
59
|
-
extern void test_lookup_errors(int gai_error, int mmdb_error,
|
|
60
|
-
const char *function, const char *ip,
|
|
61
|
-
const char *file, const char *mode_desc);
|
|
62
|
-
extern MMDB_entry_data_s data_ok(MMDB_lookup_result_s *result, uint32_t expect_type,
|
|
63
|
-
const char *description, ...);
|
|
64
|
-
extern void compare_double(double got, double expect);
|
|
65
|
-
extern void compare_float(float got, float expect);
|
|
66
|
-
/* --prototypes end - don't remove this comment-- */
|
|
67
|
-
/* *INDENT-ON* */
|
|
68
|
-
|
|
69
|
-
#endif
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#include "maxminddb_test_helper.h"
|
|
2
|
-
|
|
3
|
-
void run_tests(int mode, const char *mode_desc)
|
|
4
|
-
{
|
|
5
|
-
const char *filename = "MaxMind-DB-test-metadata-pointers.mmdb";
|
|
6
|
-
const char *path = test_database_path(filename);
|
|
7
|
-
MMDB_s *mmdb = open_ok(path, mode, mode_desc);
|
|
8
|
-
free((void *)path);
|
|
9
|
-
|
|
10
|
-
char *repeated_string = "Lots of pointers in metadata";
|
|
11
|
-
|
|
12
|
-
is(mmdb->metadata.database_type, repeated_string,
|
|
13
|
-
"decoded pointer database_type");
|
|
14
|
-
|
|
15
|
-
for (uint16_t i = 0; i < mmdb->metadata.description.count; i++) {
|
|
16
|
-
const char *language =
|
|
17
|
-
mmdb->metadata.description.descriptions[i]->language;
|
|
18
|
-
const char *description =
|
|
19
|
-
mmdb->metadata.description.descriptions[i]->description;
|
|
20
|
-
is(description, repeated_string, "%s description", language);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
MMDB_close(mmdb);
|
|
24
|
-
free(mmdb);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
int main(void)
|
|
28
|
-
{
|
|
29
|
-
plan(NO_PLAN);
|
|
30
|
-
for_all_modes(&run_tests);
|
|
31
|
-
done_testing();
|
|
32
|
-
}
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
#include "maxminddb_test_helper.h"
|
|
2
|
-
|
|
3
|
-
void test_metadata(MMDB_s *mmdb, const char *mode_desc)
|
|
4
|
-
{
|
|
5
|
-
cmp_ok(mmdb->metadata.node_count, "==", 37, "node_count is 37 - %s",
|
|
6
|
-
mode_desc);
|
|
7
|
-
cmp_ok(mmdb->metadata.record_size, "==", 24, "record_size is 24 - %s",
|
|
8
|
-
mode_desc);
|
|
9
|
-
cmp_ok(mmdb->metadata.ip_version, "==", 4, "ip_version is 4 - %s",
|
|
10
|
-
mode_desc);
|
|
11
|
-
is(mmdb->metadata.database_type, "Test", "database_type is Test - %s",
|
|
12
|
-
mode_desc);
|
|
13
|
-
// 2013-07-01T00:00:00Z
|
|
14
|
-
uint64_t expect_epoch = 1372636800;
|
|
15
|
-
int is_ok =
|
|
16
|
-
cmp_ok(mmdb->metadata.build_epoch, ">=", expect_epoch,
|
|
17
|
-
"build_epoch > %lli", expect_epoch);
|
|
18
|
-
if (!is_ok) {
|
|
19
|
-
diag(" epoch is %lli", mmdb->metadata.build_epoch);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
cmp_ok(mmdb->metadata.binary_format_major_version, "==", 2,
|
|
23
|
-
"binary_format_major_version is 2 - %s", mode_desc);
|
|
24
|
-
cmp_ok(mmdb->metadata.binary_format_minor_version, "==", 0,
|
|
25
|
-
"binary_format_minor_version is 0 - %s", mode_desc);
|
|
26
|
-
|
|
27
|
-
cmp_ok(mmdb->metadata.languages.count, "==", 2, "found 2 languages - %s",
|
|
28
|
-
mode_desc);
|
|
29
|
-
is(mmdb->metadata.languages.names[0], "en", "first language is en - %s",
|
|
30
|
-
mode_desc);
|
|
31
|
-
is(mmdb->metadata.languages.names[1], "zh", "second language is zh - %s",
|
|
32
|
-
mode_desc);
|
|
33
|
-
|
|
34
|
-
cmp_ok(mmdb->metadata.description.count, "==", 2,
|
|
35
|
-
"found 2 descriptions - %s", mode_desc);
|
|
36
|
-
for (uint16_t i = 0; i < mmdb->metadata.description.count; i++) {
|
|
37
|
-
const char *language =
|
|
38
|
-
mmdb->metadata.description.descriptions[i]->language;
|
|
39
|
-
const char *description =
|
|
40
|
-
mmdb->metadata.description.descriptions[i]->description;
|
|
41
|
-
if (strncmp(language, "en", 2) == 0) {
|
|
42
|
-
ok(1, "found en description");
|
|
43
|
-
is(description, "Test Database", "en description");
|
|
44
|
-
} else if (strncmp(language, "zh", 2) == 0) {
|
|
45
|
-
ok(1, "found zh description");
|
|
46
|
-
is(description, "Test Database Chinese", "zh description");
|
|
47
|
-
} else {
|
|
48
|
-
ok(0, "found unknown description in unexpected language - %s",
|
|
49
|
-
language);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
cmp_ok(mmdb->full_record_byte_size, "==", 6,
|
|
54
|
-
"full_record_byte_size is 6 - %s", mode_desc);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
MMDB_entry_data_list_s *test_languages_value(MMDB_entry_data_list_s
|
|
58
|
-
*entry_data_list)
|
|
59
|
-
{
|
|
60
|
-
MMDB_entry_data_list_s *languages = entry_data_list = entry_data_list->next;
|
|
61
|
-
|
|
62
|
-
cmp_ok(languages->entry_data.type, "==", MMDB_DATA_TYPE_ARRAY,
|
|
63
|
-
"'languages' key's value is an array");
|
|
64
|
-
cmp_ok(languages->entry_data.data_size, "==", 2,
|
|
65
|
-
"'languages' key's value has 2 elements");
|
|
66
|
-
|
|
67
|
-
MMDB_entry_data_list_s *idx0 = entry_data_list = entry_data_list->next;
|
|
68
|
-
cmp_ok(idx0->entry_data.type, "==", MMDB_DATA_TYPE_UTF8_STRING,
|
|
69
|
-
"first array entry is a UTF8_STRING");
|
|
70
|
-
const char *lang0 = dup_entry_string_or_bail(idx0->entry_data);
|
|
71
|
-
is(lang0, "en", "first language is en");
|
|
72
|
-
free((void *)lang0);
|
|
73
|
-
|
|
74
|
-
MMDB_entry_data_list_s *idx1 = entry_data_list = entry_data_list->next;
|
|
75
|
-
cmp_ok(idx1->entry_data.type, "==", MMDB_DATA_TYPE_UTF8_STRING,
|
|
76
|
-
"second array entry is a UTF8_STRING");
|
|
77
|
-
const char *lang1 = dup_entry_string_or_bail(idx1->entry_data);
|
|
78
|
-
is(lang1, "zh", "second language is zh");
|
|
79
|
-
free((void *)lang1);
|
|
80
|
-
|
|
81
|
-
return entry_data_list;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
MMDB_entry_data_list_s *test_description_value(
|
|
85
|
-
MMDB_entry_data_list_s *entry_data_list)
|
|
86
|
-
{
|
|
87
|
-
MMDB_entry_data_list_s *description = entry_data_list =
|
|
88
|
-
entry_data_list->next;
|
|
89
|
-
cmp_ok(description->entry_data.type, "==", MMDB_DATA_TYPE_MAP,
|
|
90
|
-
"'description' key's value is a map");
|
|
91
|
-
cmp_ok(description->entry_data.data_size, "==", 2,
|
|
92
|
-
"'description' key's value has 2 key/value pairs");
|
|
93
|
-
|
|
94
|
-
for (int i = 0; i < 2; i++) {
|
|
95
|
-
MMDB_entry_data_list_s *key = entry_data_list =
|
|
96
|
-
entry_data_list->next;
|
|
97
|
-
cmp_ok(key->entry_data.type, "==",
|
|
98
|
-
MMDB_DATA_TYPE_UTF8_STRING,
|
|
99
|
-
"found a map key in 'map'");
|
|
100
|
-
const char *key_name = dup_entry_string_or_bail(key->entry_data);
|
|
101
|
-
|
|
102
|
-
MMDB_entry_data_list_s *value = entry_data_list =
|
|
103
|
-
entry_data_list->next;
|
|
104
|
-
cmp_ok(value->entry_data.type, "==", MMDB_DATA_TYPE_UTF8_STRING,
|
|
105
|
-
"map value is a UTF8_STRING");
|
|
106
|
-
const char *description =
|
|
107
|
-
dup_entry_string_or_bail(value->entry_data);
|
|
108
|
-
|
|
109
|
-
if (strcmp(key_name, "en") == 0) {
|
|
110
|
-
is(description, "Test Database",
|
|
111
|
-
"en description == 'Test Database'");
|
|
112
|
-
} else if (strcmp(key_name, "zh") == 0) {
|
|
113
|
-
is(description, "Test Database Chinese",
|
|
114
|
-
"zh description == 'Test Database Chinese'");
|
|
115
|
-
} else {
|
|
116
|
-
ok(0, "unknown key found in description map - %s", key_name);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
free((void *)key_name);
|
|
120
|
-
free((void *)description);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return entry_data_list;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
void test_metadata_as_data_entry_list(MMDB_s * mmdb,
|
|
127
|
-
const char *mode_desc)
|
|
128
|
-
{
|
|
129
|
-
MMDB_entry_data_list_s *entry_data_list, *first;
|
|
130
|
-
int status =
|
|
131
|
-
MMDB_get_metadata_as_entry_data_list(mmdb, &entry_data_list);
|
|
132
|
-
|
|
133
|
-
first = entry_data_list;
|
|
134
|
-
|
|
135
|
-
cmp_ok(status, "==", MMDB_SUCCESS, "get metadata as data_entry_list - %s",
|
|
136
|
-
mode_desc);
|
|
137
|
-
|
|
138
|
-
cmp_ok(first->entry_data.data_size, "==", 9,
|
|
139
|
-
"metadata map has 9 key/value pairs");
|
|
140
|
-
|
|
141
|
-
while (1) {
|
|
142
|
-
MMDB_entry_data_list_s *key = entry_data_list =
|
|
143
|
-
entry_data_list->next;
|
|
144
|
-
|
|
145
|
-
if (!key) {
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
cmp_ok(key->entry_data.type, "==", MMDB_DATA_TYPE_UTF8_STRING,
|
|
150
|
-
"found a map key");
|
|
151
|
-
|
|
152
|
-
const char *key_name = dup_entry_string_or_bail(key->entry_data);
|
|
153
|
-
if (strcmp(key_name, "node_count") == 0) {
|
|
154
|
-
MMDB_entry_data_list_s *value
|
|
155
|
-
= entry_data_list = entry_data_list->next;
|
|
156
|
-
cmp_ok(value->entry_data.uint32, "==", 37, "node_count == 37");
|
|
157
|
-
} else if (strcmp(key_name, "record_size") == 0) {
|
|
158
|
-
MMDB_entry_data_list_s *value
|
|
159
|
-
= entry_data_list = entry_data_list->next;
|
|
160
|
-
cmp_ok(value->entry_data.uint16, "==", 24, "record_size == 24");
|
|
161
|
-
} else if (strcmp(key_name, "ip_version") == 0) {
|
|
162
|
-
MMDB_entry_data_list_s *value
|
|
163
|
-
= entry_data_list = entry_data_list->next;
|
|
164
|
-
cmp_ok(value->entry_data.uint16, "==", 4, "ip_version == 4");
|
|
165
|
-
} else if (strcmp(key_name, "binary_format_major_version") == 0) {
|
|
166
|
-
MMDB_entry_data_list_s *value
|
|
167
|
-
= entry_data_list = entry_data_list->next;
|
|
168
|
-
cmp_ok(value->entry_data.uint16, "==", 2,
|
|
169
|
-
"binary_format_major_version == 2");
|
|
170
|
-
} else if (strcmp(key_name, "binary_format_minor_version") == 0) {
|
|
171
|
-
MMDB_entry_data_list_s *value
|
|
172
|
-
= entry_data_list = entry_data_list->next;
|
|
173
|
-
cmp_ok(value->entry_data.uint16, "==", 0,
|
|
174
|
-
"binary_format_minor_version == 0");
|
|
175
|
-
} else if (strcmp(key_name, "build_epoch") == 0) {
|
|
176
|
-
MMDB_entry_data_list_s *value
|
|
177
|
-
= entry_data_list = entry_data_list->next;
|
|
178
|
-
ok(value->entry_data.uint64 > 1373571901,
|
|
179
|
-
"build_epoch > 1373571901");
|
|
180
|
-
} else if (strcmp(key_name, "database_type") == 0) {
|
|
181
|
-
MMDB_entry_data_list_s *value
|
|
182
|
-
= entry_data_list = entry_data_list->next;
|
|
183
|
-
const char *type = dup_entry_string_or_bail(value->entry_data);
|
|
184
|
-
is(type, "Test", "type == Test");
|
|
185
|
-
free((void *)type);
|
|
186
|
-
} else if (strcmp(key_name, "languages") == 0) {
|
|
187
|
-
entry_data_list = test_languages_value(entry_data_list);
|
|
188
|
-
} else if (strcmp(key_name, "description") == 0) {
|
|
189
|
-
entry_data_list = test_description_value(entry_data_list);
|
|
190
|
-
} else {
|
|
191
|
-
ok(0, "unknown key found in metadata map - %s",
|
|
192
|
-
key_name);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
free((void *)key_name);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
MMDB_free_entry_data_list(first);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
void run_tests(int mode, const char *mode_desc)
|
|
202
|
-
{
|
|
203
|
-
const char *file = "MaxMind-DB-test-ipv4-24.mmdb";
|
|
204
|
-
const char *path = test_database_path(file);
|
|
205
|
-
MMDB_s *mmdb = open_ok(path, mode, mode_desc);
|
|
206
|
-
|
|
207
|
-
// All of the remaining tests require an open mmdb
|
|
208
|
-
if (NULL == mmdb) {
|
|
209
|
-
diag("could not open %s - skipping remaining tests", path);
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
free((void *)path);
|
|
213
|
-
|
|
214
|
-
test_metadata(mmdb, mode_desc);
|
|
215
|
-
test_metadata_as_data_entry_list(mmdb, mode_desc);
|
|
216
|
-
|
|
217
|
-
MMDB_close(mmdb);
|
|
218
|
-
free(mmdb);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
int main(void)
|
|
222
|
-
{
|
|
223
|
-
plan(NO_PLAN);
|
|
224
|
-
for_all_modes(&run_tests);
|
|
225
|
-
done_testing();
|
|
226
|
-
}
|