From ebac8511929e2268f0b8f21599a0b6a53f33c807 Mon Sep 17 00:00:00 2001 From: Eric Lunderberg Date: Mon, 4 Oct 2021 15:44:30 -0500 Subject: [PATCH] Updated TestTargetAutoParametrization When sorting the tests, the order of parametrizations may change. Therefore, the tests checking for automatic target parametrization shouldn't depend on order. --- .../python/unittest/test_tvm_testing_features.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/python/unittest/test_tvm_testing_features.py b/tests/python/unittest/test_tvm_testing_features.py index cbcdc4356250..c00fc02c4331 100644 --- a/tests/python/unittest/test_tvm_testing_features.py +++ b/tests/python/unittest/test_tvm_testing_features.py @@ -46,8 +46,11 @@ def test_device_parametrization(self, dev): self.devices_used.append(dev) def test_all_targets_used(self): - assert self.targets_used == self.enabled_targets - assert self.devices_used == self.enabled_devices + assert sorted(self.targets_used) == sorted(self.enabled_targets) + + def test_all_devices_used(self): + sort_key = lambda dev: (dev.device_type, dev.device_id) + assert sorted(self.devices_used, key=sort_key) == sorted(self.enabled_devices, key=sort_key) targets_with_explicit_list = [] @@ -70,9 +73,9 @@ def test_exclude_target(self, target): self.targets_with_exclusion.append(target) def test_all_nonexcluded_targets_ran(self): - assert self.targets_with_exclusion == [ - target for target in self.enabled_targets if not target.startswith("llvm") - ] + assert sorted(self.targets_with_exclusion) == sorted( + [target for target in self.enabled_targets if not target.startswith("llvm")] + ) run_targets_with_known_failure = [] @@ -85,7 +88,7 @@ def test_known_failing_target(self, target): assert "llvm" not in target def test_all_targets_ran(self): - assert self.run_targets_with_known_failure == self.enabled_targets + assert sorted(self.run_targets_with_known_failure) == sorted(self.enabled_targets) @tvm.testing.known_failing_targets("llvm") @tvm.testing.parametrize_targets("llvm")