From 78a74fdb549ca27df3a98b18b059f2adf40080e8 Mon Sep 17 00:00:00 2001 From: "Maxim P. DEMENTIEV" Date: Wed, 30 Oct 2024 20:20:15 +0100 Subject: [PATCH] test cases/linuxlike/14 static dynamic linkage: fixing Cygwin --- .../verify_static.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/test cases/linuxlike/14 static dynamic linkage/verify_static.py b/test cases/linuxlike/14 static dynamic linkage/verify_static.py index 364107da3cc7..1782eb144187 100755 --- a/test cases/linuxlike/14 static dynamic linkage/verify_static.py +++ b/test cases/linuxlike/14 static dynamic linkage/verify_static.py @@ -4,8 +4,8 @@ import sys import argparse -def handle_common(path, is_static): - """Handle the common case.""" +def check_zlib_symbol_common(path, is_static): + """Tests if the binary contains zlibVersion symbol (non-Cygwin version).""" try: sym_opt = '--defined-only' if is_static else '--undefined-only' output = subprocess.check_output(['nm', sym_opt, '-P', '-A', path]).decode('utf-8') @@ -21,13 +21,15 @@ def handle_common(path, is_static): return 0 return 1 -def handle_cygwin(path, is_static): - """Handle the Cygwin case.""" +def check_zlib_symbol_cygwin(path, is_static): + """Tests if the binary contains zlibVersion symbol (Cygwin case).""" output = subprocess.check_output(['nm', path]).decode('utf-8') - # TODO: Dynamic test! - print(f"handle_cygwin(path={path}, is_static={is_static}): {output!r}") - if (('I __imp_zlibVersion' in output) or ('D __imp_zlibVersion' in output)): - return 1 + # No matter static or dynamic, the name must exist in nm output + if ' zlibVersion' not in output: + return 2 + is_dynamic = ('I __imp_zlibVersion' in output) or ('D __imp_zlibVersion' in output) + if is_dynamic == is_static: # expected/got mismatch? + return 3 return 0 def main(): @@ -38,9 +40,9 @@ def main(): parser.add_argument('-s', '--static', action='store_true', default=False) args = parser.parse_args() if args.platform == 'cygwin': - return handle_cygwin(args.path, args.static) + return check_zlib_symbol_cygwin(args.path, args.static) else: - return handle_common(args.path, args.static) + return check_zlib_symbol_common(args.path, args.static) if __name__ == '__main__':