Skip to content
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

uORB_tests: add uORB::SubscriptionMultiArray tests #16093

Merged
merged 1 commit into from
Nov 3, 2020

Conversation

dagar
Copy link
Member

@dagar dagar commented Oct 30, 2020

No description provided.

@dagar
Copy link
Member Author

dagar commented Oct 30, 2020

@bkueng what did you hit in #16092?

@dagar
Copy link
Member Author

dagar commented Oct 30, 2020

This also uncovers a small bug with uORB::DeviceNode::get_initial_generation() and topics that were previously published then unadvertised. @shawnfeng0 FYI

Screenshot from 2020-10-30 10-48-23

Possibly already resolved by #16084.

@shawnfeng0
Copy link
Contributor

shawnfeng0 commented Oct 30, 2020

It may be because test_single() has used orb_test instance 0 to publish data once, but then you subscribe in test_SubscriptionMulti(), orb_test instance 0 has a piece of data waiting to be read, but it has not been read yet, then there is a new publication, resulting in the instance 0 produced two unread data, so the test failed.

@shawnfeng0
Copy link
Contributor

That should be it. I turned off test_single() first and did the test, and it passed.

I see that in order to maintain independence, each unit test basically uses a different message. Maybe a new one should be used here. Or use copy several times in advance to read all the messages before executing the test.

@dagar
Copy link
Member Author

dagar commented Oct 30, 2020

That should be it. I turned off test_single() first and did the test, and it passed.

I see that in order to maintain independence, each unit test basically uses a different message. Maybe a new one should be used here. Or use copy several times in advance to read all the messages before executing the test.

That's all true, but I still don't see why this isn't technically a real bug. The first subscription subscribes and reports the last generation as 1 (should be 2 from the earlier test_single()), then after it does the first copy the generation jumps to 3 (actual generation + 1).

@shawnfeng0
Copy link
Contributor

shawnfeng0 commented Oct 30, 2020

Oh, test_single() was published twice, orb_advertise(ORB_ID(orb_test), &t) and orb_publish(ORB_ID(orb_test), ptopic, &t).

Then test_SubscriptionMulti() was published once and it became 3, and that's it.

The generation is the total number of publishes, but it is used as an index starting from 0 inside the uORB::DeviceNode. When I first saw it, I found it a little strange, this is a small trick. But from the outside, it is the normal total number of releases.

@dagar dagar requested a review from bkueng November 2, 2020 14:55
@shawnfeng0
Copy link
Contributor

The test failed because of this:

unsigned generation = _generation.load() - (_data_valid ? 1 : 0);

If there is valid data before, we will reduce the initial value by 1 to get the latest data. Then it was released again in test_SubscriptionMulti(), our _last_generation = generation-2. In addition, there is no queue for the orb_test topic, so it was skipped twice when copying.

My modification in #16084 cannot fix this problem.

For this problem, we should use a copy before the start of this test case to point _last_generation to the latest data. Or it should be tested on a new topic.

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.

3 participants