mirror of https://github.com/postgres/postgres
This creates a new test module src/test/modules/test_int128 and moves src/tools/testint128.c into it so that it can be built using the normal build system, allowing the 128-bit integer arithmetic functions in src/include/common/int128.h to be tested automatically. For now, the tests are skipped on platforms that don't have native int128 support. While at it, fix the test128 union in the test code: the "hl" member of test128 was incorrectly defined to be a union instead of a struct, which meant that the tests were only ever setting and checking half of each 128-bit integer value. Author: Dean Rasheed <dean.a.rasheed@gmail.com> Reviewed-by: John Naylor <johncnaylorls@gmail.com> Discussion: https://postgr.es/m/CAEZATCWgBMc9ZwKMYqQpaQz2X6gaamYRB+RnMsUNcdMcL2Mj_w@mail.gmail.compull/239/head
parent
225ebfe30a
commit
8c7445a008
@ -0,0 +1,2 @@ |
||||
/tmp_check/ |
||||
/test_int128 |
||||
@ -0,0 +1,23 @@ |
||||
# src/test/modules/test_int128/Makefile
|
||||
|
||||
PGFILEDESC = "test_int128 - test 128-bit integer arithmetic"
|
||||
|
||||
PROGRAM = test_int128
|
||||
OBJS = $(WIN32RES) test_int128.o
|
||||
|
||||
PG_CPPFLAGS = -I$(libpq_srcdir)
|
||||
PG_LIBS_INTERNAL += $(libpq_pgport)
|
||||
|
||||
NO_INSTALL = 1
|
||||
TAP_TESTS = 1
|
||||
|
||||
ifdef USE_PGXS |
||||
PG_CONFIG = pg_config
|
||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||
include $(PGXS) |
||||
else |
||||
subdir = src/test/modules/test_int128
|
||||
top_builddir = ../../../..
|
||||
include $(top_builddir)/src/Makefile.global |
||||
include $(top_srcdir)/contrib/contrib-global.mk |
||||
endif |
||||
@ -0,0 +1,33 @@ |
||||
# Copyright (c) 2025, PostgreSQL Global Development Group |
||||
|
||||
test_int128_sources = files( |
||||
'test_int128.c', |
||||
) |
||||
|
||||
if host_system == 'windows' |
||||
test_int128_sources += rc_bin_gen.process(win32ver_rc, extra_args: [ |
||||
'--NAME', 'test_int128', |
||||
'--FILEDESC', 'test int128 program',]) |
||||
endif |
||||
|
||||
test_int128 = executable('test_int128', |
||||
test_int128_sources, |
||||
dependencies: [frontend_code, libpq], |
||||
kwargs: default_bin_args + { |
||||
'install': false, |
||||
}, |
||||
) |
||||
testprep_targets += test_int128 |
||||
|
||||
|
||||
tests += { |
||||
'name': 'test_int128', |
||||
'sd': meson.current_source_dir(), |
||||
'bd': meson.current_build_dir(), |
||||
'tap': { |
||||
'tests': [ |
||||
't/001_test_int128.pl', |
||||
], |
||||
'deps': [test_int128], |
||||
}, |
||||
} |
||||
@ -0,0 +1,27 @@ |
||||
# Copyright (c) 2025, PostgreSQL Global Development Group |
||||
|
||||
# Test 128-bit integer arithmetic code in int128.h |
||||
|
||||
use strict; |
||||
use warnings FATAL => 'all'; |
||||
|
||||
use PostgreSQL::Test::Utils; |
||||
use Test::More; |
||||
|
||||
# Run the test program with 1M iterations |
||||
my $exe = "test_int128"; |
||||
my $size = 1_000_000; |
||||
|
||||
note "testing executable $exe"; |
||||
|
||||
my ($stdout, $stderr) = run_command([ $exe, $size ]); |
||||
|
||||
SKIP: |
||||
{ |
||||
skip "no native int128 type", 2 if $stdout =~ /skipping tests/; |
||||
|
||||
is($stdout, "", "test_int128: no stdout"); |
||||
is($stderr, "", "test_int128: no stderr"); |
||||
} |
||||
|
||||
done_testing(); |
||||
Loading…
Reference in new issue