Skip to content

Commit cc65df8

Browse files
committed
FEATURE-ci-remaining-native-captures: Preserve original contexts and failure evidence
1 parent daf1bfa commit cc65df8

7 files changed

Lines changed: 334 additions & 43 deletions

‎examples/host_poll.hpp‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,9 @@ inline void capture_wait_error(const std::vector<slot>& fds, int saved_error) {
7272
std::fprintf(stderr, "WSA_WAIT_ERROR code=%d stop_bits=%u ticks=%lld count=%zu\n",
7373
saved_error, stop_bits.load(), ticks.QuadPart, fds.size());
7474
for (const auto& fd : fds) {
75-
int type = 0, error = 0, length = sizeof(type);
75+
int type = 0, length = sizeof(type);
7676
const int type_rc = ::getsockopt(fd.fd, SOL_SOCKET, SO_TYPE, reinterpret_cast<char*>(&type), &length);
7777
const int type_error = type_rc < 0 ? ::WSAGetLastError() : 0;
78-
length = sizeof(error);
79-
const int error_rc = ::getsockopt(fd.fd, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&error), &length);
80-
const int error_error = error_rc < 0 ? ::WSAGetLastError() : 0;
8178
sockaddr_storage local{}, peer{};
8279
length = sizeof(local);
8380
const int local_rc = ::getsockname(fd.fd, reinterpret_cast<sockaddr*>(&local), &length);
@@ -86,9 +83,9 @@ inline void capture_wait_error(const std::vector<slot>& fds, int saved_error) {
8683
const int peer_rc = ::getpeername(fd.fd, reinterpret_cast<sockaddr*>(&peer), &length);
8784
const int peer_error = peer_rc < 0 ? ::WSAGetLastError() : 0;
8885
std::fprintf(stderr, "WSA_WAIT_SOCKET fd=%zu events=%d revents=%d type=%d type_rc=%d type_error=%d "
89-
"socket_error=%d error_rc=%d error_error=%d local_rc=%d local_error=%d local_family=%d "
86+
"socket_error=unavailable local_rc=%d local_error=%d local_family=%d "
9087
"peer_rc=%d peer_error=%d peer_family=%d\n", static_cast<std::size_t>(fd.fd), fd.events,
91-
fd.revents, type, type_rc, type_error, error, error_rc, error_error, local_rc, local_error,
88+
fd.revents, type, type_rc, type_error, local_rc, local_error,
9289
local.ss_family, peer_rc, peer_error, peer.ss_family);
9390
}
9491
}

‎scripts/ci_remaining_native_captures.py‎

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,9 @@ def prepare(args, source, directory, env):
557557
build.mkdir()
558558
prefix.mkdir()
559559
provider = args.provider_prefix or directory / 'no-provider'
560-
build_env = dict(env, CXX=args.compiler, CC=args.cc, MAKE=args.make, CXXFLAGS='-O0 -g -DLIBHTTPSERVER_REMAINING_CAPTURE',
560+
optimization = '-O3' if host == 'Linux' else '-O0'
561+
build_env = dict(env, CXX=args.compiler, CC=args.cc, MAKE=args.make,
562+
CXXFLAGS=optimization + ' -g -DLIBHTTPSERVER_REMAINING_CAPTURE',
561563
CPPFLAGS='', LDFLAGS='', PKG_CONFIG_PATH='',
562564
PKG_CONFIG_LIBDIR=os.pathsep.join(args.pkg_config_dir))
563565
if mode == 'yes':
@@ -606,14 +608,35 @@ def prepare(args, source, directory, env):
606608
command([args.make, '-j2', '-C', 'test'] + selected, build, build_env)
607609
if host == 'Darwin':
608610
# A separate TLS-off static lane preserves the original external-H1 linkage.
609-
plain = directory / 'plain-build'
611+
plain, plain_prefix = directory / 'plain-build', directory / 'plain-prefix'
610612
plain.mkdir()
613+
plain_prefix.mkdir()
611614
plain_env = dict(build_env, V3_TLS_CFLAGS='', V3_TLS_LIBS='', LDFLAGS='')
612615
command([bash, configure, '--disable-v3-tls', '--disable-shared', '--enable-static',
613-
'--disable-examples'], plain, plain_env)
616+
'--disable-examples', '--prefix=' + plain_prefix.as_posix()], plain, plain_env)
614617
command([args.make, '-j2', '-C', 'src'], plain, plain_env)
615-
command([args.make, '-j2', '-C', 'test', 'external_http1_e2e'], plain, plain_env)
616-
programs = dict(tls_psk=build / 'test/tls_psk', external_http1_e2e=plain / 'test/external_http1_e2e')
618+
command([args.make, '-C', 'src', 'install'], plain, plain_env)
619+
command([args.make, 'install-pkgconfigDATA'], plain, plain_env)
620+
plain_runtime = dict(runtime, PKG_CONFIG_PATH='', PKG_CONFIG_LIBDIR=os.pathsep.join(
621+
[str(plain_prefix / 'lib/pkgconfig')] + args.pkg_config_dir))
622+
cflags = shlex.split(command(['pkg-config', '--cflags', 'libhttpserver'], plain, plain_runtime).strip())
623+
libraries = shlex.split(command(['pkg-config', '--libs', '--static', 'libhttpserver'], plain, plain_runtime).strip())
624+
# Select the installed archive explicitly, even if another shared package is on the host.
625+
libraries = [str(plain_prefix / 'lib/libhttpserver.a') if item == '-lhttpserver' else item
626+
for item in libraries]
627+
consumer = directory / 'external-build'
628+
consumer.mkdir()
629+
executable = consumer / 'external_http1_e2e'
630+
flags = cflags + ['-DHTTPSERVER_COMPILATION', '-I' + str(source / 'src'), '-I' + str(source / 'test')]
631+
for macro, value in (('TLS_TEST_DIR', source / 'test'),
632+
('PARITY_TRANSCRIPT_DIR', source / 'test/parity/transcripts'),
633+
('PARITY_DATA_ROOT', source / 'test'), ('HTTP2_CORPUS_DIR', source / 'test/conformance/http2')):
634+
flags += ['-D' + macro + '="' + value.as_posix() + '"']
635+
units = [source / 'test' / unit for unit in
636+
package_matrix.load()['suites']['external_http1_e2e']['sources']]
637+
compiles['external_http1_e2e'] = compile_probe(args.compiler, units, flags, libraries, executable,
638+
command, plain_runtime, source, plain, plain_prefix, True)
639+
programs = dict(tls_psk=build / 'test/tls_psk', external_http1_e2e=executable)
617640
for name in ('config.h', 'config.log', 'Makefile', 'test/Makefile'):
618641
shutil.copyfile(plain / name, setup / ('plain-' + name.replace('/', '-')))
619642
else:
@@ -637,6 +660,9 @@ def prepare(args, source, directory, env):
637660
artifacts = [build / 'config.h', build / 'config.log', build / 'Makefile', build / 'test/Makefile']
638661
artifacts += [path for path in (prefix.rglob('*') if host == 'Windows' else (build / 'src/.libs').glob('*'))
639662
if path.is_file() and path.suffix.lower() in ('.dll', '.so', '.dylib', '.a')]
663+
if host == 'Darwin':
664+
artifacts += [path for path in plain_prefix.rglob('*') if path.is_file()]
665+
artifacts += [Path(str(programs['external_http1_e2e']) + '.map')]
640666
if args.toolchain_prefix:
641667
artifacts += [path for path in (args.toolchain_prefix / ('bin' if host == 'Windows' else 'lib/c++')).glob('*')
642668
if path.is_file() and (path.suffix.lower() in ('.dll', '.dylib') and
@@ -726,9 +752,10 @@ def launch(name, case, cap):
726752
argv = [str(programs[name])]
727753
if name == 'wire_cleanup':
728754
argv = [sys.executable, str(source / 'test/integ/native_websocket_client.py'),
729-
str(programs[name]), '--first-wire-cycle-only']
730-
cwd = (source / 'test' if host == 'Windows' and name != 'consumer' else
731-
directory / ('plain-build/test' if name == 'external_http1_e2e' else 'build/test') if host != 'Windows' else case)
755+
str(programs[name]), '--first-wire-cycle-only',
756+
'--fixture-stdout-receipt', str(case / 'fixture-stdout.bin')]
757+
cwd = (source / 'test' if name == 'external_http1_e2e' or (host == 'Windows' and name != 'consumer') else
758+
directory / 'build/test' if host != 'Windows' else case)
732759
# Singles with a 60s original budget keep retirement inside that allowance.
733760
cleanup = min(6, cap / 5)
734761
result = run_program(argv, case, runtime, cap=cap, gate=min(target['gate'], cap),

0 commit comments

Comments
 (0)