@@ -0,0 +1,2393 @@
+%22%22%22Testing error handling in the common test utilities.%0A%0AThe module tests the error handling in the utilities we use for writing%0Aexhaustive tests for the sparse codegen.%0A%22%22%22%0A%0Aimport inspect%0Aimport sys%0A%0A# Import MLIR related modules.%0Afrom mlir.dialects import sparse_tensor as st%0Afrom mlir.dialects.linalg.opdsl import lang as dsl%0A%0A# Import common test tools.%0Aimport sparse_codegen_test_common as tc%0A%0A# A test returns 1 when it fails to indicate the number of failing test. This is%0A# to help accumulating the total number of failing tests.%0A_PASS = 0%0A_FAIL = 1%0A%0A%0Adef _pass_test(name: str) -%3E int:%0A  print(f%22%7Bname%7D passed.%22)%0A  return _PASS%0A%0A%0Adef _fail_test(name: str) -%3E int:%0A  print(f%22%7Bname%7D failed.%22)%0A  return _FAIL%0A%0A%0Adef _test_mismatching_ordering_sparsity() -%3E int:%0A  %22%22%22Test for inconsistent input descriptor parameters.%0A%0A  The dimension ordering and the sparsities in this test don't have the same%0A  length.%0A  %22%22%22%0A  name = inspect.currentframe().f_code.co_name%0A  try:%0A    _ = tc.InputDesc(%5B0, 1, 2%5D, %5Bst.DimLevelType.dense, st.DimLevelType.dense%5D,%0A                     0, 0)%0A  except ValueError:%0A    num_failed = _pass_test(name)%0A  else:%0A    num_failed = _fail_test(name)%0A  return num_failed%0A%0A%0Adef _test_invalid_ordering() -%3E int:%0A  %22%22%22Test for invalid dimension orderings.%0A%0A  The dimension ordering in this test is not a permutation of 0..n-1, where%0A  n is the length of the dimension ordering.%0A  %22%22%22%0A  name = inspect.currentframe().f_code.co_name%0A  try:%0A    _ = tc.InputDesc(%5B0, 2%5D, %5Bst.DimLevelType.dense, st.DimLevelType.dense%5D, 0,%0A                     0)%0A  except ValueError:%0A    num_failed = _pass_test(name)%0A  else:%0A    num_failed = _fail_test(name)%0A  return num_failed%0A%0A%0Adef _test_invalid_affine_expression() -%3E int:%0A  %22%22%22Test for invalid affine expressions.%0A%0A  The affine expression in the first input here is not defined in the iteration%0A  space.%0A  %22%22%22%0A  name = inspect.currentframe().f_code.co_name%0A  try:%0A    _ = tc.TestDesc(%5Bdsl.S.M, dsl.S.N%5D, %5B8, 8%5D, %5Bdsl.S.M, dsl.S.X%5D)%0A  except ValueError:%0A    num_failed = _pass_test(name)%0A  else:%0A    num_failed = _fail_test(name)%0A  return num_failed%0A%0A%0Adef run_test():%0A  num_failed = (%0A      _test_mismatching_ordering_sparsity() + _test_invalid_ordering() +%0A      _test_invalid_affine_expression())%0A%0A  if num_failed == 0:%0A    print(%22All test passed.%22)%0A  else:%0A    print(f%22%7Bnum_failed%7D tests failed.%22)%0A    sys.exit(%22FAILURE%22)%0A%0A%0Arun_test()%0A

Add tests for the exhaustive test utilities.