diff --git a/runtime/core/exec_aten/util/test/tensor_util_test.cpp b/runtime/core/exec_aten/util/test/tensor_util_test.cpp index 842f2341235..4c0d9404234 100644 --- a/runtime/core/exec_aten/util/test/tensor_util_test.cpp +++ b/runtime/core/exec_aten/util/test/tensor_util_test.cpp @@ -65,15 +65,15 @@ TEST_F(TensorUtilTest, SameShapesDifferentDtypes) { ET_CHECK_SAME_SHAPE3(a, b, c); // Not the same dtypes. Check both positions. - ET_EXPECT_DEATH(ET_CHECK_SAME_DTYPE2(a, b), ""); - ET_EXPECT_DEATH(ET_CHECK_SAME_DTYPE2(b, a), ""); - ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE_AND_DTYPE2(a, b), ""); - ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE_AND_DTYPE2(b, a), ""); + ET_EXPECT_DEATH(ET_CHECK_SAME_DTYPE2(a, b), "Tensors do not match"); + ET_EXPECT_DEATH(ET_CHECK_SAME_DTYPE2(b, a), "Tensors do not match"); + ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE_AND_DTYPE2(a, b), "Tensors do not match"); + ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE_AND_DTYPE2(b, a), "Tensors do not match"); // Test with a mismatching tensor in all positions, where the other two agree. - ET_EXPECT_DEATH(ET_CHECK_SAME_DTYPE3(a, b, b), ""); - ET_EXPECT_DEATH(ET_CHECK_SAME_DTYPE3(b, a, b), ""); - ET_EXPECT_DEATH(ET_CHECK_SAME_DTYPE3(b, b, a), ""); + ET_EXPECT_DEATH(ET_CHECK_SAME_DTYPE3(a, b, b), "Tensors do not match"); + ET_EXPECT_DEATH(ET_CHECK_SAME_DTYPE3(b, a, b), "Tensors do not match"); + ET_EXPECT_DEATH(ET_CHECK_SAME_DTYPE3(b, b, a), "Tensors do not match"); ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE_AND_DTYPE3(a, b, b), ""); ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE_AND_DTYPE3(b, a, b), ""); ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE_AND_DTYPE3(b, b, a), ""); @@ -88,13 +88,13 @@ TEST_F(TensorUtilTest, DifferentShapesSameDtypes) { Tensor b2 = tf_int_.ones({2, 2}); // The different tensors are not the same shape. Check both positions. - ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE2(a, b), ""); - ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE2(b, a), ""); + ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE2(a, b), "Tensors do not match"); + ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE2(b, a), "Tensors do not match"); // Test with the different tensor in all positions. - ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE3(a, b, b2), ""); - ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE3(b, a, b2), ""); - ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE3(b, b2, a), ""); + ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE3(a, b, b2), "Tensors do not match"); + ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE3(b, a, b2), "Tensors do not match"); + ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE3(b, b2, a), "Tensors do not match"); // They are the same dtypes. ET_CHECK_SAME_DTYPE2(a, b); @@ -104,11 +104,14 @@ TEST_F(TensorUtilTest, DifferentShapesSameDtypes) { ET_CHECK_SAME_DTYPE3(b, b2, a); // But not the same shape-and-dtype. - ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE_AND_DTYPE2(a, b), ""); - ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE_AND_DTYPE2(b, a), ""); - ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE_AND_DTYPE3(a, b, b2), ""); - ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE_AND_DTYPE3(b, a, b2), ""); - ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE_AND_DTYPE3(b, b2, a), ""); + ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE_AND_DTYPE2(a, b), "Tensors do not match"); + ET_EXPECT_DEATH(ET_CHECK_SAME_SHAPE_AND_DTYPE2(b, a), "Tensors do not match"); + ET_EXPECT_DEATH( + ET_CHECK_SAME_SHAPE_AND_DTYPE3(a, b, b2), "Tensors do not match"); + ET_EXPECT_DEATH( + ET_CHECK_SAME_SHAPE_AND_DTYPE3(b, a, b2), "Tensors do not match"); + ET_EXPECT_DEATH( + ET_CHECK_SAME_SHAPE_AND_DTYPE3(b, b2, a), "Tensors do not match"); } TEST_F(TensorUtilTest, ZeroDimensionalTensor) { @@ -163,9 +166,15 @@ TEST_F(TensorUtilTest, GetLeadingDimsInputOutOfBoundDies) { Tensor t = tf_int_.ones({2, 3, 4}); // dim needs to be in the range [0, t.dim()] - ET_EXPECT_DEATH(executorch::ET_RUNTIME_NAMESPACE::getLeadingDims(t, -2), ""); - ET_EXPECT_DEATH(executorch::ET_RUNTIME_NAMESPACE::getLeadingDims(t, -1), ""); - ET_EXPECT_DEATH(executorch::ET_RUNTIME_NAMESPACE::getLeadingDims(t, 4), ""); + ET_EXPECT_DEATH( + executorch::ET_RUNTIME_NAMESPACE::getLeadingDims(t, -2), + "Ending dimension.*should be in the range"); + ET_EXPECT_DEATH( + executorch::ET_RUNTIME_NAMESPACE::getLeadingDims(t, -1), + "Ending dimension.*should be in the range"); + ET_EXPECT_DEATH( + executorch::ET_RUNTIME_NAMESPACE::getLeadingDims(t, 4), + "Ending dimension.*should be in the range"); } TEST_F(TensorUtilTest, GetTrailingDimsSmokeTest) { @@ -187,9 +196,15 @@ TEST_F(TensorUtilTest, GetTrailingDimsInputOutOfBoundDies) { Tensor t = tf_int_.ones({2, 3, 4}); // dim needs to be in the range [-1, t.dim() - 1) - ET_EXPECT_DEATH(executorch::ET_RUNTIME_NAMESPACE::getTrailingDims(t, -2), ""); - ET_EXPECT_DEATH(executorch::ET_RUNTIME_NAMESPACE::getTrailingDims(t, 3), ""); - ET_EXPECT_DEATH(executorch::ET_RUNTIME_NAMESPACE::getTrailingDims(t, 4), ""); + ET_EXPECT_DEATH( + executorch::ET_RUNTIME_NAMESPACE::getTrailingDims(t, -2), + "Starting dimension.*should be in the range"); + ET_EXPECT_DEATH( + executorch::ET_RUNTIME_NAMESPACE::getTrailingDims(t, 3), + "Starting dimension.*should be in the range"); + ET_EXPECT_DEATH( + executorch::ET_RUNTIME_NAMESPACE::getTrailingDims(t, 4), + "Starting dimension.*should be in the range"); } TEST_F(TensorUtilTest, ContiguousCheckSupported) { diff --git a/runtime/core/test/evalue_test.cpp b/runtime/core/test/evalue_test.cpp index 9e91ad70a0b..edf6a1b12c1 100644 --- a/runtime/core/test/evalue_test.cpp +++ b/runtime/core/test/evalue_test.cpp @@ -89,7 +89,7 @@ TEST_F(EValueTest, TypeMismatchFatals) { auto e = EValue(true); e.toInt(); }, - ""); + "EValue is not an int"); } TEST_F(EValueTest, NoneByDefault) { @@ -279,38 +279,45 @@ TEST_F(EValueTest, ConstructFromTensorWrapper) { TEST_F(EValueTest, ConstructFromNullPtrAborts) { std::unique_ptr null_ptr; - ET_EXPECT_DEATH({ EValue evalue(null_ptr); }, ""); + ET_EXPECT_DEATH({ EValue evalue(null_ptr); }, "Pointer is null"); } TEST_F(EValueTest, StringConstructorNullCheck) { executorch::aten::ArrayRef* null_string_ptr = nullptr; - ET_EXPECT_DEATH({ EValue evalue(null_string_ptr); }, ""); + ET_EXPECT_DEATH( + { EValue evalue(null_string_ptr); }, "pointer cannot be null"); } TEST_F(EValueTest, BoolListConstructorNullCheck) { executorch::aten::ArrayRef* null_bool_list_ptr = nullptr; - ET_EXPECT_DEATH({ EValue evalue(null_bool_list_ptr); }, ""); + ET_EXPECT_DEATH( + { EValue evalue(null_bool_list_ptr); }, "pointer cannot be null"); } TEST_F(EValueTest, DoubleListConstructorNullCheck) { executorch::aten::ArrayRef* null_double_list_ptr = nullptr; - ET_EXPECT_DEATH({ EValue evalue(null_double_list_ptr); }, ""); + ET_EXPECT_DEATH( + { EValue evalue(null_double_list_ptr); }, "pointer cannot be null"); } TEST_F(EValueTest, IntListConstructorNullCheck) { BoxedEvalueList* null_int_list_ptr = nullptr; - ET_EXPECT_DEATH({ EValue evalue(null_int_list_ptr); }, ""); + ET_EXPECT_DEATH( + { EValue evalue(null_int_list_ptr); }, "pointer cannot be null"); } TEST_F(EValueTest, TensorListConstructorNullCheck) { BoxedEvalueList* null_tensor_list_ptr = nullptr; - ET_EXPECT_DEATH({ EValue evalue(null_tensor_list_ptr); }, ""); + ET_EXPECT_DEATH( + { EValue evalue(null_tensor_list_ptr); }, "pointer cannot be null"); } TEST_F(EValueTest, OptionalTensorListConstructorNullCheck) { BoxedEvalueList>* null_optional_tensor_list_ptr = nullptr; - ET_EXPECT_DEATH({ EValue evalue(null_optional_tensor_list_ptr); }, ""); + ET_EXPECT_DEATH( + { EValue evalue(null_optional_tensor_list_ptr); }, + "pointer cannot be null"); } TEST_F(EValueTest, BoxedEvalueListConstructorNullChecks) { @@ -321,16 +328,18 @@ TEST_F(EValueTest, BoxedEvalueListConstructorNullChecks) { // Test null wrapped_vals ET_EXPECT_DEATH( - { BoxedEvalueList list(nullptr, storage.data(), 3); }, ""); + { BoxedEvalueList list(nullptr, storage.data(), 3); }, + "wrapped_vals cannot be null"); // Test null unwrapped_vals ET_EXPECT_DEATH( - { BoxedEvalueList list(values_p.data(), nullptr, 3); }, ""); + { BoxedEvalueList list(values_p.data(), nullptr, 3); }, + "unwrapped_vals cannot be null"); // Test negative size ET_EXPECT_DEATH( { BoxedEvalueList list(values_p.data(), storage.data(), -1); }, - ""); + "size cannot be negative"); } TEST_F(EValueTest, toListOptionalTensorTypeCheck) { @@ -340,7 +349,7 @@ TEST_F(EValueTest, toListOptionalTensorTypeCheck) { EXPECT_FALSE(e.isListOptionalTensor()); // Should fail type check - ET_EXPECT_DEATH({ e.toListOptionalTensor(); }, ""); + ET_EXPECT_DEATH({ e.toListOptionalTensor(); }, "EValue is not a"); } TEST_F(EValueTest, toStringNullPointerCheck) { @@ -351,7 +360,7 @@ TEST_F(EValueTest, toStringNullPointerCheck) { // Should pass isString() check but fail null pointer check EXPECT_TRUE(e.isString()); - ET_EXPECT_DEATH({ e.toString(); }, ""); + ET_EXPECT_DEATH({ e.toString(); }, "string pointer is null"); } TEST_F(EValueTest, toIntListNullPointerCheck) { @@ -362,7 +371,7 @@ TEST_F(EValueTest, toIntListNullPointerCheck) { // Should pass isIntList() check but fail null pointer check EXPECT_TRUE(e.isIntList()); - ET_EXPECT_DEATH({ e.toIntList(); }, ""); + ET_EXPECT_DEATH({ e.toIntList(); }, "int list pointer is null"); } TEST_F(EValueTest, toBoolListNullPointerCheck) { @@ -373,7 +382,7 @@ TEST_F(EValueTest, toBoolListNullPointerCheck) { // Should pass isBoolList() check but fail null pointer check EXPECT_TRUE(e.isBoolList()); - ET_EXPECT_DEATH({ e.toBoolList(); }, ""); + ET_EXPECT_DEATH({ e.toBoolList(); }, "bool list pointer is null"); } TEST_F(EValueTest, toDoubleListNullPointerCheck) { @@ -384,7 +393,7 @@ TEST_F(EValueTest, toDoubleListNullPointerCheck) { // Should pass isDoubleList() check but fail null pointer check EXPECT_TRUE(e.isDoubleList()); - ET_EXPECT_DEATH({ e.toDoubleList(); }, ""); + ET_EXPECT_DEATH({ e.toDoubleList(); }, "double list pointer is null"); } TEST_F(EValueTest, toTensorListNullPointerCheck) { @@ -395,7 +404,7 @@ TEST_F(EValueTest, toTensorListNullPointerCheck) { // Should pass isTensorList() check but fail null pointer check EXPECT_TRUE(e.isTensorList()); - ET_EXPECT_DEATH({ e.toTensorList(); }, ""); + ET_EXPECT_DEATH({ e.toTensorList(); }, "tensor list pointer is null"); } TEST_F(EValueTest, toListOptionalTensorNullPointerCheck) { @@ -406,5 +415,5 @@ TEST_F(EValueTest, toListOptionalTensorNullPointerCheck) { // Should pass isListOptionalTensor() check but fail null pointer check EXPECT_TRUE(e.isListOptionalTensor()); - ET_EXPECT_DEATH({ e.toListOptionalTensor(); }, ""); + ET_EXPECT_DEATH({ e.toListOptionalTensor(); }, "pointer is null"); }