diff --git a/nemu/src/monitor/sdb/addrexp.l b/nemu/src/monitor/sdb/addrexp.l index 2ba6302..24fd7bd 100644 --- a/nemu/src/monitor/sdb/addrexp.l +++ b/nemu/src/monitor/sdb/addrexp.l @@ -12,5 +12,5 @@ $$?[a-zA-Z]{2,3} { yylval = isa_reg_str2val(yytext + 1, &success); if(!success) [0-9]+ { yylval = strtoul(yytext, NULL, 10); return NUMBER; } [+\-*/()] { return *yytext; } [ \t] { } -. { printf("Unexpected character: %s\n", yytext); } +. { fprintf(stderr, "Unexpected character: %s\n", yytext); return YYerror; } %% diff --git a/nemu/tests/expr_test.c b/nemu/tests/expr_test.c index 427a59e..4399584 100644 --- a/nemu/tests/expr_test.c +++ b/nemu/tests/expr_test.c @@ -181,17 +181,17 @@ START_TEST(test_expr_plain_register) { } END_TEST -// START_TEST(test_expr_register) { -// yy_scan_string(reg_exprs[_i].expr); -// uint32_t value; -// ck_assert(!yyparse(&value)); -// yylex_destroy(); +START_TEST(test_expr_register) { + yy_scan_string(reg_exprs[_i].expr); + uint32_t value; + ck_assert(!yyparse(&value)); + yylex_destroy(); -// ck_assert_msg(value == reg_exprs[_i].reference, -// "\n\texpr = %s\n\t(addr = %u) != (reference = %u)\n", reg_exprs[_i].expr, -// value, reg_exprs[_i].reference); -// } -// END_TEST + ck_assert_msg(value == reg_exprs[_i].reference, + "\n\texpr = %s\n\t(addr = %u) != (reference = %u)\n", reg_exprs[_i].expr, + value, reg_exprs[_i].reference); +} +END_TEST Suite *expr_suite(void) { Suite *s; @@ -203,8 +203,8 @@ Suite *expr_suite(void) { tcase_add_loop_test(tc_core, test_expr_random_100, 0, 20); tcase_add_loop_test(tc_core, test_expr_negative_operand, 0, sizeof(exprs) / sizeof(exprs[0])); - // tcase_add_loop_test(tc_core, test_expr_register, 0, - // sizeof(reg_exprs) / sizeof(reg_exprs[0])); + tcase_add_loop_test(tc_core, test_expr_register, 0, + sizeof(reg_exprs) / sizeof(reg_exprs[0])); tcase_add_test(tc_core, test_expr_plain_register); suite_add_tcase(s, tc_core);