Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4e1e417

Browse files
committed
oauth: Add unit tests for multiplexer handling
To better record the internal behaviors of oauth-curl.c, add a unit testsuite for the socket and timer handling code. This is all based on TAPand driven by our existing Test::More infrastructure.This commit is a replay of1443b6c, which was reverted due tobuildfarm failures. Compared with that, this version protects the buildtargets in the Makefile with a with_libcurl conditional, and it tweaksthe code style in 001_oauth.pl.Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>Reviewed-by: Andrew Dunstan <andrew@dunslane.net>Discussion:https://postgr.es/m/CAOYmi+nDZxJHaWj9_jRSyf8uMToCADAmOfJEggsKW-kY7aUwHA@mail.gmail.comDiscussion:https://postgr.es/m/CAOYmi+m=xY0P_uAzAP_884uF-GhQ3wrineGwc9AEnb6fYxVqVQ@mail.gmail.com
1 parent52ecd05 commit4e1e417

File tree

4 files changed

+618
-4
lines changed

4 files changed

+618
-4
lines changed

‎src/interfaces/libpq-oauth/Makefile‎

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ SHLIB_EXPORTS = exports.txt
5454
# Disable -bundle_loader on macOS.
5555
BE_DLLLIBS =
5656

57-
# By default, a library without an SONAME doesn't get a static library, so we
58-
# add it to the build explicitly.
59-
all: all-lib all-static-lib
60-
6157
# Shared library stuff
6258
include$(top_srcdir)/src/Makefile.shlib
6359

@@ -66,6 +62,28 @@ include $(top_srcdir)/src/Makefile.shlib
6662
%_shlib.o:%.c%.o
6763
$(CC)$(CFLAGS)$(CFLAGS_SL)$(CPPFLAGS)$(CPPFLAGS_SHLIB) -c$< -o$@
6864

65+
.PHONY: all-tests
66+
all-tests: oauth_tests$(X)
67+
68+
oauth_tests$(X): test-oauth-curl.o oauth-utils.o$(WIN32RES) | submake-libpgport submake-libpq
69+
$(CC)$(CFLAGS)$^$(LDFLAGS)$(LDFLAGS_EX)$(SHLIB_LINK) -o$@
70+
71+
#
72+
# Top-Level Targets
73+
#
74+
# The existence of a t/ folder induces the buildfarm to run Make directly on
75+
# this subdirectory, bypassing the recursion skip in src/interfaces/Makefile.
76+
# Wrap the standard build targets in a with_libcurl conditional to avoid
77+
# building OAuth code on platforms that haven't requested it. (The "clean"-style
78+
# targets remain available.)
79+
#
80+
81+
ifeq ($(with_libcurl), yes)
82+
83+
# By default, a library without an SONAME doesn't get a static library, so we
84+
# add it to the build explicitly.
85+
all: all-lib all-static-lib
86+
6987
# Ignore the standard rules for SONAME-less installation; we want both the
7088
# static and shared libraries to go into libdir.
7189
install: all installdirs$(stlib)$(shlib)
@@ -75,9 +93,19 @@ install: all installdirs $(stlib) $(shlib)
7593
installdirs:
7694
$(MKDIR_P)'$(DESTDIR)$(libdir)'
7795

96+
check: all-tests
97+
$(prove_check)
98+
99+
installcheck: all-tests
100+
$(prove_installcheck)
101+
102+
endif# with_libcurl
103+
78104
uninstall:
79105
rm -f'$(DESTDIR)$(libdir)/$(stlib)'
80106
rm -f'$(DESTDIR)$(libdir)/$(shlib)'
81107

82108
cleandistclean: clean-lib
83109
rm -f$(OBJS)$(OBJS_STATIC)$(OBJS_SHLIB)
110+
rm -f test-oauth-curl.o oauth_tests$(X)
111+
rm -rf tmp_check

‎src/interfaces/libpq-oauth/meson.build‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,38 @@ libpq_oauth_so = shared_module(libpq_oauth_name,
4747
link_args: export_fmt.format(export_file.full_path()),
4848
kwargs: default_lib_args,
4949
)
50+
51+
libpq_oauth_test_deps= []
52+
53+
oauth_test_sources=files('test-oauth-curl.c')+ libpq_oauth_so_sources
54+
55+
if host_system=='windows'
56+
oauth_test_sources+= rc_bin_gen.process(win32ver_rc,extra_args: [
57+
'--NAME','oauth_tests',
58+
'--FILEDESC','OAuth unit test program',])
59+
endif
60+
61+
libpq_oauth_test_deps+=executable('oauth_tests',
62+
oauth_test_sources,
63+
dependencies: [frontend_shlib_code, libpq, libpq_oauth_deps],
64+
kwargs: default_bin_args+ {
65+
'c_args': default_bin_args.get('c_args', [])+ libpq_oauth_so_c_args,
66+
'c_pch': pch_postgres_fe_h,
67+
'include_directories': [libpq_inc, postgres_inc],
68+
'install':false,
69+
}
70+
)
71+
72+
testprep_targets+= libpq_oauth_test_deps
73+
74+
tests+= {
75+
'name':'libpq-oauth',
76+
'sd':meson.current_source_dir(),
77+
'bd':meson.current_build_dir(),
78+
'tap': {
79+
'tests': [
80+
't/001_oauth.pl',
81+
],
82+
'deps': libpq_oauth_test_deps,
83+
},
84+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2025, PostgreSQL Global Development Group
2+
use strict;
3+
use warningsFATAL=>'all';
4+
5+
use PostgreSQL::Test::Utils;
6+
use Test::More;
7+
8+
# Defer entirely to the oauth_tests executable. stdout/err is routed through
9+
# Test::More so that our logging infrastructure can handle it correctly. Using
10+
# IPC::Run::new_chunker seems to help interleave the two streams a little better
11+
# than without.
12+
#
13+
# TODO: prove can also deal with native executables itself, which we could
14+
# probably make use of via PROVE_TESTS on the Makefile side. But the Meson setup
15+
# calls Perl directly, which would require more code to work around... and
16+
# there's still the matter of logging.
17+
my$builder = Test::More->builder;
18+
my$out =$builder->output;
19+
my$err =$builder->failure_output;
20+
21+
IPC::Run::run ['oauth_tests'],
22+
'>'=> (IPC::Run::new_chunker,sub {$out->print($_[0]) }),
23+
'2>'=> (IPC::Run::new_chunker,sub {$err->print($_[0]) })
24+
ordie"oauth_tests returned$?";

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp