Skip to content

Conversation

@YuShuanHsieh
Copy link
Contributor

@YuShuanHsieh YuShuanHsieh commented Jan 26, 2020

Why

  1. The expected values should be changed after the sorting operation.
  2. do_sort will access unknown memory address if the queue is null.

How

  1. Fix the expected values of trace-4, trace-5.
  2. always return true if it is a null queue.

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]);
Copy link
Contributor

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)) {
Copy link
Contributor

@jserv jserv Jan 26, 2020

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.

reverse
size
sort
sort NULL
Copy link
Contributor

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?

Copy link
Contributor Author

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.

qtest.c Outdated
exception_cancel();
set_noallocate_mode(false);

if (q == NULL)
Copy link
Contributor

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.

Copy link
Contributor Author

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 :)

Copy link
Contributor

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.

Copy link
Contributor Author

@YuShuanHsieh YuShuanHsieh Jan 27, 2020

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.

@YuShuanHsieh YuShuanHsieh force-pushed the fix/sorting-trace branch 2 times, most recently from 600da5c to 13d38f6 Compare January 27, 2020 04:28
@jserv jserv merged commit f887827 into sysprog21:master Jan 27, 2020
@jserv
Copy link
Contributor

jserv commented Jan 27, 2020

Thank @YuShuanHsieh for contributing to this project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants