-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix(trace): fix expected values and unknown address access #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ac39a49 to
e12b9c5
Compare
qtest.c
Outdated
| if (argc != 1) { | ||
| report(1, "%s takes no arguments", argv[0]); | ||
| if (argc != 1 && !(argc == 2 && strcmp(argv[1], "NULL") == 0)) { | ||
| report(1, "%s takes 0 or `NULL` value argument", argv[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't put "`" character here. Simply use quotation mark.
qtest.c
Outdated
| { | ||
| if (argc != 1) { | ||
| report(1, "%s takes no arguments", argv[0]); | ||
| if (argc != 1 && !(argc == 2 && strcmp(argv[1], "NULL") == 0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewrite strcmp(argv[1], "NULL") == 0 into !strcmp(argv[1], "NULL") for consistency.
traces/trace-07-robust.cmd
Outdated
| reverse | ||
| size | ||
| sort | ||
| sort NULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a bit weird to me regarding the use of sort NULL. In my understanding, sort should be as generic as possible. It can accept almost anything including NULL. I don't think it is vital to introduce extra argument for sort since sort always perform the operations within queue. What is your consideration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right.
The reason why I choose to add a new argument is to minimize the effect of other test cases. I think it may always return true if it is a null queue, but I am not really sure about this idea because honestly I am not quite familiar with all test cases.
e12b9c5 to
40e2d4f
Compare
qtest.c
Outdated
| exception_cancel(); | ||
| set_noallocate_mode(false); | ||
|
|
||
| if (q == NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't place check here. Instead, let's move to Line 477:
if (q == NULL)
report(3, "Warning: Calling sort on null queue");
error_check();The function error_check() would collect test information and interact with users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I’m not sure what you mean.
Cause in my point of view error_check()draw a scope of tests. like
error_check(); //reset error_occurred
// test case
return ok && !error_check();So I still need to handle the null queue after q_sort(q) to prevent q->head bad access.
Could you give me more about your opinion? Thx :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can follow the similar flow in function do_size and do_reverse, that just report when NULL pointer is inputed. qtest itself does not need to take care about fatal condition. Instead, qtest only reports to users and each trace file denotes the criteria of test scenario. In this case, do_sort attempts to report the checkpoints without managing to recover.
Consequently, the implementation behind queue would have to couple with the above though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably catch your point. Please review it again. Thanks.
600da5c to
13d38f6
Compare
|
Thank @YuShuanHsieh for contributing to this project! |
Why
do_sortwill access unknown memory address if the queue is null.How