diff --git a/nemu/tests/expr_test.c b/nemu/tests/expr_test.c index efb89d0..bb91ae2 100644 --- a/nemu/tests/expr_test.c +++ b/nemu/tests/expr_test.c @@ -79,6 +79,10 @@ START_TEST(test_expr_random_100) { fclose(fp); int ret = system("gcc /tmp/.code.c -Werror=div-by-zero -o /tmp/.expr"); + if(ret == -1) { + // Probably devide by zero. Skip + goto clean_up; + } ck_assert_msg(!ret, "system ret: %d, error: %s", ret, strerror(ret)); fp = popen("/tmp/.expr", "r"); @@ -97,6 +101,7 @@ START_TEST(test_expr_random_100) { ck_assert_msg(addr == reference, "\n\tbuf = %s\n\taddr = %u, reference = %u\n", buf, addr, reference); +clean_up: while(buf_ptr != buf + buf_start_pos) { *(--buf_ptr) = '\0'; }