From 673f8605ce1dd9c8ad36a274f0d5b9f4a01bc86e Mon Sep 17 00:00:00 2001 From: Yanyan Jiang Date: Tue, 11 Aug 2020 17:40:29 +0000 Subject: [PATCH] rename nemu_assert to check --- cpu-tests/include/trap.h | 2 +- cpu-tests/tests/add-longlong.c | 2 +- cpu-tests/tests/add.c | 6 +++--- cpu-tests/tests/bit.c | 18 +++++++++--------- cpu-tests/tests/bubble-sort.c | 8 ++++---- cpu-tests/tests/div.c | 2 +- cpu-tests/tests/fact.c | 2 +- cpu-tests/tests/fib.c | 4 ++-- cpu-tests/tests/goldbach.c | 2 +- cpu-tests/tests/hello-str.c | 6 +++--- cpu-tests/tests/if-else.c | 4 ++-- cpu-tests/tests/leap-year.c | 2 +- cpu-tests/tests/load-store.c | 8 ++++---- cpu-tests/tests/matrix-mul.c | 8 ++++---- cpu-tests/tests/max.c | 6 +++--- cpu-tests/tests/min3.c | 8 ++++---- cpu-tests/tests/mov-c.c | 14 +++++++------- cpu-tests/tests/movsx.c | 22 +++++++++++----------- cpu-tests/tests/mul-longlong.c | 6 +++--- cpu-tests/tests/pascal.c | 4 ++-- cpu-tests/tests/prime.c | 4 ++-- cpu-tests/tests/quick-sort.c | 8 ++++---- cpu-tests/tests/recursion.c | 6 +++--- cpu-tests/tests/select-sort.c | 8 ++++---- cpu-tests/tests/shift.c | 6 +++--- cpu-tests/tests/shuixianhua.c | 4 ++-- cpu-tests/tests/string.c | 14 +++++++------- cpu-tests/tests/sub-longlong.c | 2 +- cpu-tests/tests/sum.c | 2 +- cpu-tests/tests/switch.c | 4 ++-- cpu-tests/tests/to-lower-case.c | 2 +- cpu-tests/tests/unalign.c | 2 +- cpu-tests/tests/wanshu.c | 4 ++-- 33 files changed, 100 insertions(+), 100 deletions(-) diff --git a/cpu-tests/include/trap.h b/cpu-tests/include/trap.h index ed23ab7..e1036aa 100644 --- a/cpu-tests/include/trap.h +++ b/cpu-tests/include/trap.h @@ -6,7 +6,7 @@ #include __attribute__((noinline)) -void nemu_assert(bool cond) { +void check(bool cond) { if (!cond) halt(1); } diff --git a/cpu-tests/tests/add-longlong.c b/cpu-tests/tests/add-longlong.c index e3d354a..f41e82c 100644 --- a/cpu-tests/tests/add-longlong.c +++ b/cpu-tests/tests/add-longlong.c @@ -14,7 +14,7 @@ int main() { int i, j, ans_idx = 0; for(i = 0; i < NR_DATA; i ++) { for(j = 0; j < NR_DATA; j ++) { - nemu_assert(add(test_data[i], test_data[j]) == ans[ans_idx ++]); + check(add(test_data[i], test_data[j]) == ans[ans_idx ++]); } } diff --git a/cpu-tests/tests/add.c b/cpu-tests/tests/add.c index b44af56..493490c 100644 --- a/cpu-tests/tests/add.c +++ b/cpu-tests/tests/add.c @@ -14,12 +14,12 @@ int main() { int i, j, ans_idx = 0; for(i = 0; i < NR_DATA; i ++) { for(j = 0; j < NR_DATA; j ++) { - nemu_assert(add(test_data[i], test_data[j]) == ans[ans_idx ++]); + check(add(test_data[i], test_data[j]) == ans[ans_idx ++]); } - nemu_assert(j == NR_DATA); + check(j == NR_DATA); } - nemu_assert(i == NR_DATA); + check(i == NR_DATA); return 0; } diff --git a/cpu-tests/tests/bit.c b/cpu-tests/tests/bit.c index bfa5f94..e186e59 100644 --- a/cpu-tests/tests/bit.c +++ b/cpu-tests/tests/bit.c @@ -23,14 +23,14 @@ int main() { buf[0] = 0xaa; buf[1] = 0x0; - nemu_assert(getbit(buf, 0) == 0); - nemu_assert(getbit(buf, 1) == 1); - nemu_assert(getbit(buf, 2) == 0); - nemu_assert(getbit(buf, 3) == 1); - nemu_assert(getbit(buf, 4) == 0); - nemu_assert(getbit(buf, 5) == 1); - nemu_assert(getbit(buf, 6) == 0); - nemu_assert(getbit(buf, 7) == 1); + check(getbit(buf, 0) == 0); + check(getbit(buf, 1) == 1); + check(getbit(buf, 2) == 0); + check(getbit(buf, 3) == 1); + check(getbit(buf, 4) == 0); + check(getbit(buf, 5) == 1); + check(getbit(buf, 6) == 0); + check(getbit(buf, 7) == 1); setbit(buf, 8, 1); setbit(buf, 9, 0); @@ -40,7 +40,7 @@ int main() { setbit(buf, 13, 0); setbit(buf, 14, 1); setbit(buf, 15, 0); - nemu_assert(buf[1] == 0x55); + check(buf[1] == 0x55); return 0; } diff --git a/cpu-tests/tests/bubble-sort.c b/cpu-tests/tests/bubble-sort.c index 2cf712e..7685be5 100644 --- a/cpu-tests/tests/bubble-sort.c +++ b/cpu-tests/tests/bubble-sort.c @@ -22,18 +22,18 @@ int main() { int i; for(i = 0; i < N; i ++) { - nemu_assert(a[i] == i); + check(a[i] == i); } - nemu_assert(i == N); + check(i == N); bubble_sort(); for(i = 0; i < N; i ++) { - nemu_assert(a[i] == i); + check(a[i] == i); } - nemu_assert(i == N); + check(i == N); return 0; } diff --git a/cpu-tests/tests/div.c b/cpu-tests/tests/div.c index cf05b9c..9e256ef 100644 --- a/cpu-tests/tests/div.c +++ b/cpu-tests/tests/div.c @@ -15,7 +15,7 @@ int main() { a[i] /= j; for(i = 0; i < N; i ++) - nemu_assert(a[i] == i); + check(a[i] == i); return 0; } diff --git a/cpu-tests/tests/fact.c b/cpu-tests/tests/fact.c index 2ea6c1e..db06460 100644 --- a/cpu-tests/tests/fact.c +++ b/cpu-tests/tests/fact.c @@ -12,7 +12,7 @@ int main() { int i; for(i = 0; i < 13; i ++) { f[i] = fact(i); - nemu_assert(f[i] == ans[i]); + check(f[i] == ans[i]); } return 0; diff --git a/cpu-tests/tests/fib.c b/cpu-tests/tests/fib.c index 4670b8a..75f1a31 100644 --- a/cpu-tests/tests/fib.c +++ b/cpu-tests/tests/fib.c @@ -7,10 +7,10 @@ int main() { int i; for(i = 2; i < 40; i ++) { fib[i] = fib[i - 1] + fib[i - 2]; - nemu_assert(fib[i] == ans[i]); + check(fib[i] == ans[i]); } - nemu_assert(i == 40); + check(i == 40); return 0; } diff --git a/cpu-tests/tests/goldbach.c b/cpu-tests/tests/goldbach.c index ee2ae5f..c7f0d2e 100644 --- a/cpu-tests/tests/goldbach.c +++ b/cpu-tests/tests/goldbach.c @@ -27,7 +27,7 @@ int goldbach(int n) { int main() { int n; for(n = 4; n <= 30; n += 2) { - nemu_assert(goldbach(n) == 1); + check(goldbach(n) == 1); } return 0; diff --git a/cpu-tests/tests/hello-str.c b/cpu-tests/tests/hello-str.c index bf80972..90e5b1a 100644 --- a/cpu-tests/tests/hello-str.c +++ b/cpu-tests/tests/hello-str.c @@ -4,13 +4,13 @@ char buf[128]; int main() { sprintf(buf, "%s", "Hello world!\n"); - nemu_assert(strcmp(buf, "Hello world!\n") == 0); + check(strcmp(buf, "Hello world!\n") == 0); sprintf(buf, "%d + %d = %d\n", 1, 1, 2); - nemu_assert(strcmp(buf, "1 + 1 = 2\n") == 0); + check(strcmp(buf, "1 + 1 = 2\n") == 0); sprintf(buf, "%d + %d = %d\n", 2, 10, 12); - nemu_assert(strcmp(buf, "2 + 10 = 12\n") == 0); + check(strcmp(buf, "2 + 10 = 12\n") == 0); return 0; } diff --git a/cpu-tests/tests/if-else.c b/cpu-tests/tests/if-else.c index 3733034..e91fad4 100644 --- a/cpu-tests/tests/if-else.c +++ b/cpu-tests/tests/if-else.c @@ -19,10 +19,10 @@ int ans[] = {0, 0, 0, 0, 50, 50, 50, 75, 75, 75, 100, 100, 100, 150}; int main() { int i, ans_idx = 0; for(i = 0; i < NR_DATA; i ++) { - nemu_assert(if_else(test_data[i]) == ans[ans_idx ++]); + check(if_else(test_data[i]) == ans[ans_idx ++]); } - nemu_assert(i == NR_DATA); + check(i == NR_DATA); return 0; } diff --git a/cpu-tests/tests/leap-year.c b/cpu-tests/tests/leap-year.c index dfcffd6..7a1aa49 100644 --- a/cpu-tests/tests/leap-year.c +++ b/cpu-tests/tests/leap-year.c @@ -9,7 +9,7 @@ int ans[] = {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1 int main() { int i; for(i = 0; i < 125; i ++) { - nemu_assert(is_leap_year(i + 1890) == ans[i]); + check(is_leap_year(i + 1890) == ans[i]); } return 0; diff --git a/cpu-tests/tests/load-store.c b/cpu-tests/tests/load-store.c index 1a8f9c1..343a9bc 100644 --- a/cpu-tests/tests/load-store.c +++ b/cpu-tests/tests/load-store.c @@ -24,21 +24,21 @@ int main() { unsigned i; for(i = 0; i < LENGTH(mem); i ++) { - nemu_assert((short)mem[i] == lh_ans[i]); + check((short)mem[i] == lh_ans[i]); } for(i = 0; i < LENGTH(mem); i ++) { - nemu_assert(mem[i] == lhu_ans[i]); + check(mem[i] == lhu_ans[i]); } for(i = 0; i < ((LENGTH(mem) / 2) - 1); i ++) { unsigned x = ((unsigned*)((void*)mem + 1))[i]; - nemu_assert(x == lwlr_ans[i]); + check(x == lwlr_ans[i]); } for(i = 0; i < LENGTH(mem); i ++) { mem[i] = ~(1 << (2 * i + 1)); - nemu_assert(mem[i] == sh_ans[i]); + check(mem[i] == sh_ans[i]); } return 0; diff --git a/cpu-tests/tests/matrix-mul.c b/cpu-tests/tests/matrix-mul.c index 6ae34bd..723ac47 100644 --- a/cpu-tests/tests/matrix-mul.c +++ b/cpu-tests/tests/matrix-mul.c @@ -48,13 +48,13 @@ int main() { for(k = 0; k < N; k ++) { c[i][j] += a[i][k] * b[k][j]; } - nemu_assert(c[i][j] == ans[i][j]); - nemu_assert(k == N); + check(c[i][j] == ans[i][j]); + check(k == N); } - nemu_assert(j == N); + check(j == N); } - nemu_assert(i == N); + check(i == N); return 0; } diff --git a/cpu-tests/tests/max.c b/cpu-tests/tests/max.c index 9649481..893c4d8 100644 --- a/cpu-tests/tests/max.c +++ b/cpu-tests/tests/max.c @@ -16,12 +16,12 @@ int main() { int i, j, ans_idx = 0; for(i = 0; i < NR_DATA; i ++) { for(j = 0; j < NR_DATA; j ++) { - nemu_assert(max(test_data[i], test_data[j]) == ans[ans_idx ++]); + check(max(test_data[i], test_data[j]) == ans[ans_idx ++]); } - nemu_assert(j == NR_DATA); + check(j == NR_DATA); } - nemu_assert(i == NR_DATA); + check(i == NR_DATA); return 0; } diff --git a/cpu-tests/tests/min3.c b/cpu-tests/tests/min3.c index 0c8b885..e8aa7c6 100644 --- a/cpu-tests/tests/min3.c +++ b/cpu-tests/tests/min3.c @@ -18,14 +18,14 @@ int main() { for(i = 0; i < NR_DATA; i ++) { for(j = 0; j < NR_DATA; j ++) { for(k = 0; k < NR_DATA; k ++) { - nemu_assert(min3(test_data[i], test_data[j], test_data[k]) == ans[ans_idx ++]); + check(min3(test_data[i], test_data[j], test_data[k]) == ans[ans_idx ++]); } - nemu_assert(k == NR_DATA); + check(k == NR_DATA); } - nemu_assert(j == NR_DATA); + check(j == NR_DATA); } - nemu_assert(i == NR_DATA); + check(i == NR_DATA); return 0; } diff --git a/cpu-tests/tests/mov-c.c b/cpu-tests/tests/mov-c.c index 9b984b0..f9fa23a 100644 --- a/cpu-tests/tests/mov-c.c +++ b/cpu-tests/tests/mov-c.c @@ -13,13 +13,13 @@ int main() { b = A[3]; A[5] = b; - nemu_assert(A[0] == 0); - nemu_assert(A[1] == 1); - nemu_assert(A[2] == 2); - nemu_assert(A[3] == 3); - nemu_assert(A[4] == 4); - nemu_assert(b == 3); - nemu_assert(A[5] == 3); + check(A[0] == 0); + check(A[1] == 1); + check(A[2] == 2); + check(A[3] == 3); + check(A[4] == 4); + check(b == 3); + check(A[5] == 3); return 0; } diff --git a/cpu-tests/tests/movsx.c b/cpu-tests/tests/movsx.c index 93fd142..b033ef3 100644 --- a/cpu-tests/tests/movsx.c +++ b/cpu-tests/tests/movsx.c @@ -13,21 +13,21 @@ int main() { b = A[3]; A[5] = b; C[0] = 'a'; - nemu_assert(C[0] == 'a'); + check(C[0] == 'a'); C[1] = C[0]; - nemu_assert(C[1] == 'a'); + check(C[1] == 'a'); A[0] = (int)C[0]; - nemu_assert(A[0] == 'a'); + check(A[0] == 'a'); C[1] = 0x80; A[0] = (int)C[1]; - nemu_assert(A[1] == 1); - nemu_assert(A[2] == 2); - nemu_assert(A[3] == 3); - nemu_assert(A[4] == 4); - nemu_assert(b == 3); - nemu_assert(A[5] == 3); - nemu_assert(C[1] == 0xffffff80); - nemu_assert(A[0] == 0xffffff80); + check(A[1] == 1); + check(A[2] == 2); + check(A[3] == 3); + check(A[4] == 4); + check(b == 3); + check(A[5] == 3); + check(C[1] == 0xffffff80); + check(A[0] == 0xffffff80); return 0; } diff --git a/cpu-tests/tests/mul-longlong.c b/cpu-tests/tests/mul-longlong.c index a65ba04..16a3dc7 100644 --- a/cpu-tests/tests/mul-longlong.c +++ b/cpu-tests/tests/mul-longlong.c @@ -14,12 +14,12 @@ int main() { int i,j,ans_idx = 0; for (i = 0;i < NR_DATA;i++) { for (j = i;j < NR_DATA;j++) { - nemu_assert(ans[ans_idx++] == mul(test_data[i],test_data[j])); + check(ans[ans_idx++] == mul(test_data[i],test_data[j])); } - nemu_assert(j == NR_DATA); + check(j == NR_DATA); } - nemu_assert(i == NR_DATA); + check(i == NR_DATA); return 0; } diff --git a/cpu-tests/tests/pascal.c b/cpu-tests/tests/pascal.c index cbc8420..02bf57a 100644 --- a/cpu-tests/tests/pascal.c +++ b/cpu-tests/tests/pascal.c @@ -21,10 +21,10 @@ int main() { } for(j = 0; j < N; j ++) { - nemu_assert(a[j] == ans[j]); + check(a[j] == ans[j]); } - nemu_assert(j == N); + check(j == N); return 0; } diff --git a/cpu-tests/tests/prime.c b/cpu-tests/tests/prime.c index 7b9d022..8cd26bb 100644 --- a/cpu-tests/tests/prime.c +++ b/cpu-tests/tests/prime.c @@ -14,12 +14,12 @@ int main() { } } if(prime) { - nemu_assert(i == ans[n]); + check(i == ans[n]); n ++; } } - nemu_assert(n == 10); + check(n == 10); return 0; } diff --git a/cpu-tests/tests/quick-sort.c b/cpu-tests/tests/quick-sort.c index d528b7c..dedbe5c 100644 --- a/cpu-tests/tests/quick-sort.c +++ b/cpu-tests/tests/quick-sort.c @@ -32,18 +32,18 @@ int main() { int i; for(i = 0; i < N; i ++) { - nemu_assert(a[i] == i); + check(a[i] == i); } - nemu_assert(i == N); + check(i == N); quick_sort(a, 0, N - 1); for(i = 0; i < N; i ++) { - nemu_assert(a[i] == i); + check(a[i] == i); } - nemu_assert(i == N); + check(i == N); return 0; } diff --git a/cpu-tests/tests/recursion.c b/cpu-tests/tests/recursion.c index 39a5c89..9c3cb2a 100644 --- a/cpu-tests/tests/recursion.c +++ b/cpu-tests/tests/recursion.c @@ -39,8 +39,8 @@ int ans[] = {38270, 218, 20}; int main() { int x = func[0](14371, 0); - nemu_assert(x == ans[0]); // answer - nemu_assert(rec == ans[1]); // # recursions - nemu_assert(lvl == ans[2]); // max depth + check(x == ans[0]); // answer + check(rec == ans[1]); // # recursions + check(lvl == ans[2]); // max depth return 0; } diff --git a/cpu-tests/tests/select-sort.c b/cpu-tests/tests/select-sort.c index 72b1a27..9d370c3 100644 --- a/cpu-tests/tests/select-sort.c +++ b/cpu-tests/tests/select-sort.c @@ -25,18 +25,18 @@ int main() { int i; for(i = 0; i < N; i ++) { - nemu_assert(a[i] == i); + check(a[i] == i); } - nemu_assert(i == N); + check(i == N); select_sort(); for(i = 0; i < N; i ++) { - nemu_assert(a[i] == i); + check(a[i] == i); } - nemu_assert(i == N); + check(i == N); return 0; } diff --git a/cpu-tests/tests/shift.c b/cpu-tests/tests/shift.c index c180aec..1581e70 100644 --- a/cpu-tests/tests/shift.c +++ b/cpu-tests/tests/shift.c @@ -21,15 +21,15 @@ int main() { unsigned i; for(i = 0; i < LENGTH(test); i ++) { - nemu_assert((test[i] >> 7) == srl_ans[i]); + check((test[i] >> 7) == srl_ans[i]); } for(i = 0; i < LENGTH(test); i ++) { - nemu_assert((unsigned)((int)test[i] >> (i + 4)) == srav_ans[i]); + check((unsigned)((int)test[i] >> (i + 4)) == srav_ans[i]); } for(i = 0; i < LENGTH(test); i ++) { - nemu_assert((test[i] >> (i + 4)) == srlv_ans[i]); + check((test[i] >> (i + 4)) == srlv_ans[i]); } return 0; diff --git a/cpu-tests/tests/shuixianhua.c b/cpu-tests/tests/shuixianhua.c index 510ce0a..046674e 100644 --- a/cpu-tests/tests/shuixianhua.c +++ b/cpu-tests/tests/shuixianhua.c @@ -15,12 +15,12 @@ int main() { n0 = n % 10; if(n == cube(n2) + cube(n1) + cube(n0)) { - nemu_assert(n == ans[k]); + check(n == ans[k]); k ++; } } - nemu_assert(k == 4); + check(k == 4); return 0; } diff --git a/cpu-tests/tests/string.c b/cpu-tests/tests/string.c index 912af66..6170268 100644 --- a/cpu-tests/tests/string.c +++ b/cpu-tests/tests/string.c @@ -13,15 +13,15 @@ char str1[] = "Hello"; char str[20]; int main() { - nemu_assert(strcmp(s[0], s[2]) == 0); - nemu_assert(strcmp(s[0], s[1]) == -1); - nemu_assert(strcmp(s[0] + 1, s[1] + 1) == -1); - nemu_assert(strcmp(s[0] + 2, s[1] + 2) == -1); - nemu_assert(strcmp(s[0] + 3, s[1] + 3) == -1); + check(strcmp(s[0], s[2]) == 0); + check(strcmp(s[0], s[1]) == -1); + check(strcmp(s[0] + 1, s[1] + 1) == -1); + check(strcmp(s[0] + 2, s[1] + 2) == -1); + check(strcmp(s[0] + 3, s[1] + 3) == -1); - nemu_assert(strcmp( strcat(strcpy(str, str1), s[3]), s[4]) == 0); + check(strcmp( strcat(strcpy(str, str1), s[3]), s[4]) == 0); - nemu_assert(memcmp(memset(str, '#', 5), s[5], 5) == 0); + check(memcmp(memset(str, '#', 5), s[5], 5) == 0); return 0; } diff --git a/cpu-tests/tests/sub-longlong.c b/cpu-tests/tests/sub-longlong.c index 2b86fae..4e40270 100644 --- a/cpu-tests/tests/sub-longlong.c +++ b/cpu-tests/tests/sub-longlong.c @@ -14,7 +14,7 @@ int main() { int i, j, ans_idx = 0; for(i = 0; i < NR_DATA; i ++) { for(j = 0; j < NR_DATA; j ++) { - nemu_assert(sub(test_data[i], test_data[j]) == ans[ans_idx ++]); + check(sub(test_data[i], test_data[j]) == ans[ans_idx ++]); } } diff --git a/cpu-tests/tests/sum.c b/cpu-tests/tests/sum.c index 64b2e20..e0301a2 100644 --- a/cpu-tests/tests/sum.c +++ b/cpu-tests/tests/sum.c @@ -8,7 +8,7 @@ int main() { i ++; } - nemu_assert(sum == 5050); + check(sum == 5050); return 0; } diff --git a/cpu-tests/tests/switch.c b/cpu-tests/tests/switch.c index 9455328..c29c916 100644 --- a/cpu-tests/tests/switch.c +++ b/cpu-tests/tests/switch.c @@ -20,10 +20,10 @@ int ans[] = {-1, 0, 2, 5, 5, 8, 8, 8, 8, 10, 10, 10, 10, 15, -1}; int main() { int i; for(i = 0; i < 15; i ++) { - nemu_assert(switch_case(i - 1) == ans[i]); + check(switch_case(i - 1) == ans[i]); } - nemu_assert(i == 15); + check(i == 15); return 0; } diff --git a/cpu-tests/tests/to-lower-case.c b/cpu-tests/tests/to-lower-case.c index edc6ed8..83a0cc0 100644 --- a/cpu-tests/tests/to-lower-case.c +++ b/cpu-tests/tests/to-lower-case.c @@ -11,7 +11,7 @@ volatile char ans [] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 int main() { int i; for(i = 0; i < 128; i ++) { - nemu_assert(to_lower_case(i) == ans[i]); + check(to_lower_case(i) == ans[i]); } return 0; diff --git a/cpu-tests/tests/unalign.c b/cpu-tests/tests/unalign.c index 48d7326..92c2203 100644 --- a/cpu-tests/tests/unalign.c +++ b/cpu-tests/tests/unalign.c @@ -9,7 +9,7 @@ int main() { *((volatile unsigned*)(buf + 3)) = 0xaabbccdd; x = *((volatile unsigned*)(buf + 3)); - nemu_assert(x == 0xaabbccdd); + check(x == 0xaabbccdd); buf[0] = buf[1] = 0; } diff --git a/cpu-tests/tests/wanshu.c b/cpu-tests/tests/wanshu.c index 9c384f0..ba9fdef 100644 --- a/cpu-tests/tests/wanshu.c +++ b/cpu-tests/tests/wanshu.c @@ -13,12 +13,12 @@ int main() { } if(sum == n) { - nemu_assert(n == ans[k]); + check(n == ans[k]); k ++; } } - nemu_assert(k == 2); + check(k == 2); return 0; }