tests: Call openpty (if available) without using dlsym

Simon McVittie requested to merge wip/smcv/simplify-openpty-linking into main

The SONAME of libutil varies between architectures, so the logic to find the SONAME of libutil was only correct for native builds (Linux on Linux), not for cross-builds. The regular expression was also not sufficiently broad to match the SONAME used on the alpha architecture, which is apparently libutil.so.1.1.

Instead of screen-scraping the output of ldconfig and using that to dlopen the library that contains openpty, it seems more reliable to emit a link-time reference to openpty and let the linker do its job. It's also less code.

Bug-Debian: https://bugs.debian.org/1007946

Merge request reports