1 /* Copyright © 2012 Brandon L Black <blblack@gmail.com> 2 * 3 * This file is part of gdnsd. 4 * 5 * gdnsd-plugin-geoip is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * gdnsd-plugin-geoip is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with gdnsd. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 #ifndef GDMAPS_TEST_H 21 #define GDMAPS_TEST_H 22 23 #include <gdmaps.h> 24 25 #include <stdbool.h> 26 27 // initialize test environment. cfg_data is a string containing 28 // the ",,," from "plugins => { geoip => { maps => { ... } }} 29 // cfg_dir is where to look for referenced nets/geoip files. 30 // these two must be called in sequence. 31 F_NONNULL 32 void gdmaps_test_init(const char* cfg_dir); 33 F_NONNULL 34 gdmaps_t* gdmaps_test_load(const char* cfg_data); 35 36 // A complete results-checker. 37 F_NONNULL 38 void gdmaps_test_lookup_check(const gdmaps_t* gdmaps, const char* map_name, const char* addr_txt, const char* dclist_cmp, const unsigned scope_cmp); 39 40 // This variant only validates that we can complete the lookup operation 41 // without crashing, it doesn't care about the data in the results 42 F_NONNULL 43 void gdmaps_test_lookup_noop(const gdmaps_t* gdmaps, const char* map_name, const char* addr_txt); 44 45 // boolean for whether a given file exists in the geoip config dir 46 F_NONNULL 47 bool gdmaps_test_db_exists(const char* dbfile); 48 49 // number of actual libtap tests for each invocation above 50 #define LOOKUP_CHECK_NTESTS 2 51 #define LOOKUP_NOOP_NTESTS 1 52 53 // handy for config blocks 54 #define QUOTE(...) #__VA_ARGS__ 55 56 #endif // GDMAPS_TEST_H 57