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

Commit1443b6c

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.Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>Discussion:https://postgr.es/m/CAOYmi+nDZxJHaWj9_jRSyf8uMToCADAmOfJEggsKW-kY7aUwHA@mail.gmail.com
1 parent3e31166 commit1443b6c

File tree

4 files changed

+600
-0
lines changed

4 files changed

+600
-0
lines changed

‎src/interfaces/libpq-oauth/Makefile‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,19 @@ uninstall:
7979
rm -f'$(DESTDIR)$(libdir)/$(stlib)'
8080
rm -f'$(DESTDIR)$(libdir)/$(shlib)'
8181

82+
.PHONY: all-tests
83+
all-tests: oauth_tests$(X)
84+
85+
oauth_tests$(X): test-oauth-curl.o oauth-utils.o$(WIN32RES) | submake-libpgport submake-libpq
86+
$(CC)$(CFLAGS)$^$(LDFLAGS)$(LDFLAGS_EX)$(SHLIB_LINK) -o$@
87+
88+
check: all-tests
89+
$(prove_check)
90+
91+
installcheck: all-tests
92+
$(prove_installcheck)
93+
8294
cleandistclean: clean-lib
8395
rm -f$(OBJS)$(OBJS_STATIC)$(OBJS_SHLIB)
96+
rm -f test-oauth-curl.o oauth_tests$(X)
97+
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