From dba8ea7bdfd492c16a0bd76615e6e2dd95e72f85 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sun, 9 Jun 2024 13:13:58 +0700 Subject: [PATCH 1/4] Block building Tests in wrong command prompt --- tests/utils/stl-lit/stl-lit.in | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/utils/stl-lit/stl-lit.in b/tests/utils/stl-lit/stl-lit.in index c9c28dc1fc..18e26b6f9b 100644 --- a/tests/utils/stl-lit/stl-lit.in +++ b/tests/utils/stl-lit/stl-lit.in @@ -29,6 +29,27 @@ sys.path.insert(0, os.path.join("@LLVM_SOURCE_DIR@", 'utils', 'lit')) builtin_parameters= {} builtin_parameters['config_map'] = config_map +def assert_target_arch_and_platform_equal(): + import os + first_lit_cfg = next(iter(builtin_parameters['config_map'].values())) + target_arch = '' + platform = os.environ['Platform'] + # Do nothing if "Platform" is not defined + if platform != '': + with open(first_lit_cfg, 'r') as file: + for line in file: + if 'lit_config.target_arch =' in line: + words = line.split() + target_arch = words[-1].strip('\'') + break + # arm64ec doesn't have an own command prompt with Platformt + if target_arch == 'arm64ec': + target_arch = 'arm64' + if platform != target_arch: + print('The architecture of the compiler and STL does not match') + exit(1) + if __name__=='__main__': + assert_target_arch_and_platform_equal() from lit.main import main main(builtin_parameters) From 7b1763104148f7a889d3ed417c86962ccd37b182 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sun, 9 Jun 2024 13:22:49 +0700 Subject: [PATCH 2/4] typo --- tests/utils/stl-lit/stl-lit.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/utils/stl-lit/stl-lit.in b/tests/utils/stl-lit/stl-lit.in index 18e26b6f9b..0d15283233 100644 --- a/tests/utils/stl-lit/stl-lit.in +++ b/tests/utils/stl-lit/stl-lit.in @@ -34,7 +34,7 @@ def assert_target_arch_and_platform_equal(): first_lit_cfg = next(iter(builtin_parameters['config_map'].values())) target_arch = '' platform = os.environ['Platform'] - # Do nothing if "Platform" is not defined + # Do nothing if "Platform" is not defined. if platform != '': with open(first_lit_cfg, 'r') as file: for line in file: @@ -42,7 +42,7 @@ def assert_target_arch_and_platform_equal(): words = line.split() target_arch = words[-1].strip('\'') break - # arm64ec doesn't have an own command prompt with Platformt + # arm64ec doesn't have its own command prompt with Platform. if target_arch == 'arm64ec': target_arch = 'arm64' if platform != target_arch: From 8dff10222f6be920073db8e65c61ce752f06b0c6 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sun, 9 Jun 2024 13:40:42 +0700 Subject: [PATCH 3/4] os.environ => os.getenv --- tests/utils/stl-lit/stl-lit.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/utils/stl-lit/stl-lit.in b/tests/utils/stl-lit/stl-lit.in index 0d15283233..c990b06ac1 100644 --- a/tests/utils/stl-lit/stl-lit.in +++ b/tests/utils/stl-lit/stl-lit.in @@ -33,7 +33,7 @@ def assert_target_arch_and_platform_equal(): import os first_lit_cfg = next(iter(builtin_parameters['config_map'].values())) target_arch = '' - platform = os.environ['Platform'] + platform = os.getenv('Platform', default='') # Do nothing if "Platform" is not defined. if platform != '': with open(first_lit_cfg, 'r') as file: From a1c1fb5a4c969e35c77acdfe61638fabad84aced Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Thu, 13 Jun 2024 09:43:23 -0700 Subject: [PATCH 4/4] Overhaul: Capture build platform at generation time, print mismatch details. --- tests/utils/stl-lit/stl-lit.in | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/tests/utils/stl-lit/stl-lit.in b/tests/utils/stl-lit/stl-lit.in index c990b06ac1..aa8f832e2f 100644 --- a/tests/utils/stl-lit/stl-lit.in +++ b/tests/utils/stl-lit/stl-lit.in @@ -29,27 +29,13 @@ sys.path.insert(0, os.path.join("@LLVM_SOURCE_DIR@", 'utils', 'lit')) builtin_parameters= {} builtin_parameters['config_map'] = config_map -def assert_target_arch_and_platform_equal(): - import os - first_lit_cfg = next(iter(builtin_parameters['config_map'].values())) - target_arch = '' - platform = os.getenv('Platform', default='') - # Do nothing if "Platform" is not defined. - if platform != '': - with open(first_lit_cfg, 'r') as file: - for line in file: - if 'lit_config.target_arch =' in line: - words = line.split() - target_arch = words[-1].strip('\'') - break - # arm64ec doesn't have its own command prompt with Platform. - if target_arch == 'arm64ec': - target_arch = 'arm64' - if platform != target_arch: - print('The architecture of the compiler and STL does not match') - exit(1) +def assert_same_platform_for_build_and_test(): + build_platform = '$ENV{Platform}' + test_platform = os.getenv('Platform', default='') + if build_platform != '' and test_platform != '' and build_platform != test_platform: + exit(f'Target platform mismatch: the STL was built for {build_platform} but tested for {test_platform}.') if __name__=='__main__': - assert_target_arch_and_platform_equal() + assert_same_platform_for_build_and_test() from lit.main import main main(builtin_parameters)