Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

test(kmod): add kunit test for receive_msg #498

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

Koichi98
Copy link
Contributor

@Koichi98 Koichi98 commented Mar 9, 2025

Description

Added receive_msg kunit tests:

  • test_case_no_topic_when_receive
    check error handling when topic_wrapper is not found.

  • test_case_no_subscriber_when_receive
    check error handling when sub_info is not found.

  • test_case_no_publish_no_receive
    check that receive_msg will return without any error and without getting any message

  • test_case_receive_one
    simple test for receiving one message

  • test_case_receive_msg_sub_qos_depth_smaller_than_publish_num_smaller_than_pub_qos_depth
    check for correct behavior when sub_qos_depth < publish_num < pub_qos_depth

  • test_case_receive_msg_publish_num_smaller_than_sub_qos_depth_smaller_than_pub_qos_depth
    check for correct behavior when publish_num < sub_qos_depth < pub_qos_depth

  • test_case_receive_msg_sub_qos_depth_smaller_than_pub_qos_depth_smaller_than_publish_num
    check for correct behavior when sub_qos_depth < pub_qos_depth = MAX_QOS_DEPTH < publish_num

  • test_case_receive_msg_publish_num_and_sub_qos_depth_and_pub_qos_depth_are_all_max_qos_depth
    check for correct behavior when sub_qos_depth = pub_qos_depth = publish_num = MAX_QOS_DEPTH

  • test_case_too_many_rc
    check error handling when the number of pub/sub entities referencing to the message exceeds MAX_REFERENCING_PUBSUB_NUM_PER_ENTRY

  • test_case_one_new_pub
    check that receive_msg gets the information of the publisher correctly, when the new publisher appears

  • test_case_pubsub_in_same_process
    check that receive_msg doesn't get the information of the publisher, when the new publisher appears is the same process as the subscriber

  • test_case_2pub_in_same_process
    check that receive_msg get the information of the publisher only once, when the new publisher appears is the same process as the other publisher.

  • test_case_2sub_in_same_process
    check that receive_msg doesn't get the information of the publisher, if the other subscriber in the same process has already mapped the memory of the publisher process.

  • test_case_subscriber_too_many_mapping_processes
    add many subscribers to reach MAX_PROCESS_NUM_PER_MEMPOOL. This is a complex test and will be implemented later.

Related links

How was this PR tested?

  • Autoware (required)
  • bash scripts/e2e_test_1to1_with_ros2sub (required)
  • bash scripts/e2e_test_2to2 (required)
  • sample application

Notes for reviewers

Koichi98 added 2 commits March 9, 2025 19:33
Signed-off-by: Koichi98 <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi98 <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
@Koichi98 Koichi98 changed the title feat(kmod): add kunit test for receive_msg test(kmod): add kunit test for receive_msg Mar 10, 2025
Koichi98 and others added 10 commits March 10, 2025 20:34
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
@Koichi98 Koichi98 marked this pull request as ready for review March 12, 2025 07:02
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
@Koichi98 Koichi98 marked this pull request as draft March 12, 2025 08:36
KUNIT_EXPECT_EQ(test, ioctl_receive_msg_ret.ret_pub_shm_info.publisher_num, 0);
}

void test_case_receive_msg_sub_qos_depth_smaller_than_publish_num_smaller_than_pub_qos_depth(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

実装を見てパッとわかりにくい(何番目の引数が qos かわからん)ので、
subscriber_add の書き方を真似るのは微妙ですか?個人的にはわかりやすいと思っており

// publisher_qos_depth > entries_num > subscriber_qos_depth

// publisher_qos_depth > entries_num > subscriber_qos_depth
void test_case_subscriber_add_normal_with_many_entries_and_transient_local_1(struct kunit * test) {
  ...
  const uint32_t publisher_qos_depth = 7;
  const uint32_t subscriber_qos_depth = 3;
  const uint32_t entries_num = 5;
  ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

関数が見た目的にでかくなることを避けたのですがさすがに提案してもらった方法の方がわかりやすそうですね。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正します!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正しました!

Signed-off-by: Koichi Imai <koichi.imai.2@tier4.jp>
@Koichi98 Koichi98 marked this pull request as ready for review March 12, 2025 12:42
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants