st_perf: fix duplicate execution
If val is function then val will be called twice because val is
executed for log in printf. If function uses shared variables inside
then return value from it might be differed. So stored function value
to tmp_val and reuse it's value when print log.
@@ -180,29 +180,32 @@ void perf_set_keeprunning(int enable);
* Expect?
*/
-#define ST_EXPECT_EQ(val, exp) \
+#define ST_EXPECT_EQ(exp, val) \
do { \
- if (exp != val) { \
- printf("\t[ERROR] val (%d) exp (%d)\n", val, exp); \
+ uint32_t tmp_val = val; \
+ if (exp != tmp_val) { \
+ printf("\t[ERROR] val (%d) exp (%d)\n", tmp_val, exp); \
printf("\t %s\t%s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
st_res = STRESS_TC_FAIL; \
goto STFUNC_OUT; \
} \
} while (0)
-#define ST_ASSERT_EQ(val, exp) \
+#define ST_ASSERT_EQ(exp, val) \
do { \
- if (exp != val) { \
- printf("\t[ERROR] val (%d) exp (%d)\n", val, exp); \
+ uint32_t tmp_val = val; \
+ if (exp != tmp_val) { \
+ printf("\t[ERROR] val (%d) exp (%d)\n", tmp_val, exp); \
printf("\t %s\t%s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
assert(0); \
} \
} while (0)
-#define ST_ASSERT_NEQ(val, exp) \
+#define ST_ASSERT_NEQ(exp, val) \
do { \
- if (exp == val) { \
- printf("\t[ERROR] val (%d) exp (%d)\n", val, exp); \
+ uint32_t tmp_val = val; \
+ if (exp == tmp_val) { \
+ printf("\t[ERROR] val (%d) exp (%d)\n", tmp_val, exp); \
printf("\t %s\t%s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
assert(0); \
} \
