Kaynağa Gözat

test/core: add case to test cm.popretz

This case is used to check when cm.popretz it should not fail

see https://gito.corp.nucleisys.com/software/devtools/riscv-gnu-toolchain/-/issues/270

Signed-off-by: Huaqi Fang <578567190@qq.com>
Huaqi Fang 1 yıl önce
ebeveyn
işleme
f2adcb1c6f
1 değiştirilmiş dosya ile 28 ekleme ve 0 silme
  1. 28 0
      test/core/test_zc.c

+ 28 - 0
test/core/test_zc.c

@@ -0,0 +1,28 @@
+#include <stdlib.h>
+#include "ctest.h"
+#include "nuclei_sdk_soc.h"
+
+static void test_loop(int loop)
+{
+    for (volatile int i = 0; i < loop; i ++) {
+
+    }
+}
+
+__attribute__((optimize("-Os"))) static int test_cmpopretz(void *a0, int mode, int *addr)
+{
+    if (mode == 2) {
+        test_loop((int)a0);
+    }
+    return 0;
+}
+
+CTEST(arch_zc, zcmp)
+{
+    int ret;
+
+    ret = test_cmpopretz((void *)0x01234567, 3, (int *)0x87654321);
+    ASSERT_EQUAL(ret, 0);
+    ret = test_cmpopretz((void *)0x01234567, 2, (int *)0x87654321);
+    ASSERT_EQUAL(ret, 0);
+}