Skip to content

Commit

Permalink
Set feature test macro for tests in one spot
Browse files Browse the repository at this point in the history
  • Loading branch information
horgh committed Aug 8, 2023
1 parent e2c8463 commit 5b22e0f
Show file tree
Hide file tree
Showing 19 changed files with 7 additions and 71 deletions.
3 changes: 0 additions & 3 deletions t/bad_databases_t.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// This test currently does not work on Windows as nftw is
// not available.
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif
#define _XOPEN_SOURCE 500
#include <ftw.h>

Expand Down
4 changes: 0 additions & 4 deletions t/bad_pointers_t.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "maxminddb_test_helper.h"

void run_tests(int mode, const char *mode_desc) {
Expand Down
4 changes: 0 additions & 4 deletions t/basic_lookup_t.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "maxminddb_test_helper.h"

static void test_big_lookup(void);
Expand Down
4 changes: 0 additions & 4 deletions t/data-pool-t.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "libtap/tap.h"
#include "maxminddb_test_helper.h"
#include <assert.h>
Expand Down
4 changes: 0 additions & 4 deletions t/data_entry_list_t.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "maxminddb_test_helper.h"

MMDB_entry_data_list_s *
Expand Down
4 changes: 0 additions & 4 deletions t/data_types_t.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "maxminddb_test_helper.h"

void test_all_data_types(MMDB_lookup_result_s *result,
Expand Down
3 changes: 0 additions & 3 deletions t/dump_t.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif
#define _XOPEN_SOURCE 700

#include "maxminddb_test_helper.h"
Expand Down
4 changes: 0 additions & 4 deletions t/get_value_pointer_bug_t.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "maxminddb_test_helper.h"

/* This test exercises a bug found in MMDB_get_value for certain types of
Expand Down
4 changes: 0 additions & 4 deletions t/get_value_t.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "maxminddb_test_helper.h"

void test_array_0_result(int status,
Expand Down
4 changes: 0 additions & 4 deletions t/ipv4_start_cache_t.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "maxminddb_test_helper.h"

void test_one_ip(MMDB_s *mmdb,
Expand Down
4 changes: 0 additions & 4 deletions t/ipv6_lookup_in_ipv4_t.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "maxminddb_test_helper.h"

void run_tests(int mode, const char *mode_desc) {
Expand Down
4 changes: 2 additions & 2 deletions t/maxminddb_test_helper.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "maxminddb_test_helper.h"

#if HAVE_CONFIG_H
#include <config.h>
#endif

#define _POSIX_C_SOURCE 200112L
#include <assert.h>
#include <stdarg.h>
#include <sys/types.h>

#include "maxminddb.h"
#include "maxminddb_test_helper.h"

#ifdef _WIN32
#include <io.h>
Expand Down
8 changes: 5 additions & 3 deletions t/maxminddb_test_helper.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* Some test files may require something newer */
#if !defined(_GNU_SOURCE) && !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 200112L
// The spec says this should be set prior to including any headers, but since
// this is test code, it should be fine to set it here. Setting it here avoids
// setting it in every test program.
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#if HAVE_CONFIG_H
Expand Down
4 changes: 0 additions & 4 deletions t/metadata_pointers_t.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "maxminddb_test_helper.h"

void run_tests(int mode, const char *mode_desc) {
Expand Down
4 changes: 0 additions & 4 deletions t/metadata_t.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "maxminddb_test_helper.h"

void test_metadata(MMDB_s *mmdb, const char *mode_desc) {
Expand Down
4 changes: 0 additions & 4 deletions t/no_map_get_value_t.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "maxminddb_test_helper.h"

void run_tests(int mode, const char *mode_desc) {
Expand Down
4 changes: 0 additions & 4 deletions t/read_node_t.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "maxminddb_test_helper.h"

void test_entry_data(MMDB_s *mmdb,
Expand Down
4 changes: 0 additions & 4 deletions t/threads_t.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "maxminddb_test_helper.h"
#include <pthread.h>

Expand Down
4 changes: 0 additions & 4 deletions t/version_t.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif

#include "maxminddb_test_helper.h"

int main(void) {
Expand Down

0 comments on commit 5b22e0f

Please sign in to comment.