Merge "Fix jniThrowException to print correct error message in NativeMultinetworkJni.cpp"
diff --git a/tests/cts/net/jni/NativeMultinetworkJni.cpp b/tests/cts/net/jni/NativeMultinetworkJni.cpp
index 60e31bc..2f95ae1 100644
--- a/tests/cts/net/jni/NativeMultinetworkJni.cpp
+++ b/tests/cts/net/jni/NativeMultinetworkJni.cpp
@@ -40,8 +40,12 @@
#define LOGD(fmt, ...) \
__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, fmt, ##__VA_ARGS__)
-#define EXPECT_GE(env, actual, expected, msg) \
+// Since the tests in this file commonly pass expression statements as parameters to these macros,
+// get the returned value of the statements to avoid statement double-called.
+#define EXPECT_GE(env, actual_stmt, expected_stmt, msg) \
do { \
+ const auto expected = (expected_stmt); \
+ const auto actual = (actual_stmt); \
if (actual < expected) { \
jniThrowExceptionFmt(env, "java/lang/AssertionError", \
"%s:%d: %s EXPECT_GE: expected %d, got %d", \
@@ -49,8 +53,10 @@
} \
} while (0)
-#define EXPECT_GT(env, actual, expected, msg) \
+#define EXPECT_GT(env, actual_stmt, expected_stmt, msg) \
do { \
+ const auto expected = (expected_stmt); \
+ const auto actual = (actual_stmt); \
if (actual <= expected) { \
jniThrowExceptionFmt(env, "java/lang/AssertionError", \
"%s:%d: %s EXPECT_GT: expected %d, got %d", \
@@ -58,8 +64,10 @@
} \
} while (0)
-#define EXPECT_EQ(env, expected, actual, msg) \
+#define EXPECT_EQ(env, expected_stmt, actual_stmt, msg) \
do { \
+ const auto expected = (expected_stmt); \
+ const auto actual = (actual_stmt); \
if (actual != expected) { \
jniThrowExceptionFmt(env, "java/lang/AssertionError", \
"%s:%d: %s EXPECT_EQ: expected %d, got %d", \