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

Add compile-time and runtime checks for feature availability #26

Merged
merged 7 commits into from
Aug 22, 2024

Conversation

pulsastrix
Copy link
Member

This PR adds startup and compile-time checks to libcoap-rs and libcoap-sys that ensure that features enabled by Cargo.toml are actually available.

This is now possible thanks to the changes made in obgm/libcoap#1488, which adds the required defines for compile-time and functions for startup checks.

Closes #20

Copy link

github-actions bot commented Aug 16, 2024

Workflow Status Report

Generated for commit 9cf7cd3 on Thu Aug 22 14:04:26 UTC 2024.

CI Status

Linting Report

Clippy check result: success

Refer to the "Files Changed" tab for identified issues.

Code Coverage Report

Filename                                    Stmts    Miss  Cover    Missing
----------------------------------------  -------  ------  -------  -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
libcoap/tests/dtls_client_server_test.rs       10       0  100.00%
libcoap/src/context.rs                        217     114  47.47%   51, 105, 110-115, 121-122, 127, 132, 134, 136, 138, 140, 142-148, 184-227, 236-244, 261, 297, 380, 385, 401, 409-542, 567-574, 589-599, 612-619, 630-657
libcoap/src/crypto.rs                          31       2  93.55%   109, 183
libcoap/src/error.rs                            4       4  0.00%    87-166
libcoap/src/event.rs                            9       0  100.00%
libcoap/src/mem.rs                            118      49  58.47%   144-158, 192-193, 206-207, 267-293, 315-319, 349-350, 363-365, 377-388, 448-484, 503, 521-523, 526-527
libcoap/src/prng.rs                            18      14  22.22%   67-179
libcoap/src/protocol.rs                       150     110  26.67%   145-146, 152-157, 159-174, 176-177, 184-189, 191-206, 208-209, 266-267, 289, 303-304, 347-352, 361-380, 437-482, 515, 517
libcoap/src/resource.rs                       139      69  50.36%   96-98, 173-208, 216-221, 248, 251, 254, 257, 268-289, 302-304, 329-333, 340-341, 350-352, 358-360, 366-374, 496, 498-509
libcoap/src/transport.rs                       10       3  70.00%   28-33, 54
libcoap/src/types.rs                          237     152  35.86%   77-122, 129-158, 201-276, 286, 350, 424-464, 517-566, 574, 591, 623, 649-699, 753, 768, 798-818, 840-841, 874-958
libcoap/src/message/mod.rs                    245     124  49.39%   107-110, 112-133, 141-147, 149-170, 174, 176, 210, 212, 215-224, 227-245, 247-251, 267-276, 297-303, 400, 443, 449, 480, 488, 490-492, 499-500, 508, 513-526, 531, 551-552, 563-564
libcoap/src/message/request.rs                220     150  31.82%   52, 69-202, 229-257, 265-375, 381, 384-386, 390, 397-401, 412, 416, 431-432, 437, 440-441, 445-446, 450, 453, 456, 459, 462, 473-477
libcoap/src/message/response.rs               143     111  22.38%   33-156, 162, 165, 168, 171, 174, 192-322, 326-330, 356-357
libcoap/tests/common/mod.rs                    43       5  88.37%   66, 91, 93-94, 97
libcoap-sys/src/lib.rs                         91      32  64.84%   115-151, 183, 188, 193, 198, 228, 233, 238, 243, 248, 253, 258, 263, 268, 278, 320-337, 459-460
libcoap/src/session/client.rs                 135      62  54.07%   69-74, 76-84, 88-94, 96, 100, 111, 114, 119, 140, 146, 152-153, 155, 174, 180, 186-187, 189, 211, 213, 215, 217-223, 265-266, 272-282, 293-303, 314-324, 371-376
libcoap/src/session/mod.rs                    154      86  44.16%   61-67, 96-97, 111-225, 236-252, 268-270, 289-291, 301-311, 347, 362, 377-396, 419, 427, 451, 455, 476-480, 558, 564
libcoap/src/session/server.rs                  48      12  75.00%   71-73, 140-141, 149-150, 181-186
TOTAL                                        2022    1099  45.65%

Diff against main

Filename                         Stmts    Miss  Cover
-----------------------------  -------  ------  -------
libcoap/src/context.rs              +1      +2  -0.68%
libcoap/src/mem.rs                   0      +1  -0.85%
libcoap/src/prng.rs                 +2      +2  -2.78%
libcoap/src/resource.rs             +2      +1  -0.01%
libcoap/src/types.rs                +1       0  +0.27%
libcoap/src/message/mod.rs          +1       0  +0.21%
libcoap-sys/src/lib.rs             +30     +14  -5.66%
libcoap/src/session/client.rs       +9      +9  -3.86%
libcoap/src/session/server.rs       +5       0  +2.91%
TOTAL                              +51     +29  -0.06%

badge

Results for commit: 4eb5188

Coverage target is 80%

@pulsastrix pulsastrix marked this pull request as ready for review August 19, 2024 16:28
@pulsastrix pulsastrix requested a review from JKRhb August 19, 2024 16:29
@pulsastrix pulsastrix changed the title WIP: Add compile-time and runtime checks for feature availability Add compile-time and runtime checks for feature availability Aug 20, 2024
Copy link
Member

@JKRhb JKRhb left a comment

Choose a reason for hiding this comment

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

See a couple of comments below, otherwise looks pretty good to me :)

libcoap-sys/Cargo.toml Outdated Show resolved Hide resolved
libcoap-sys/Cargo.toml Show resolved Hide resolved
libcoap-sys/Cargo.toml Outdated Show resolved Hide resolved
libcoap-sys/build.rs Outdated Show resolved Hide resolved
libcoap-sys/build.rs Outdated Show resolved Hide resolved
libcoap-sys/build.rs Show resolved Hide resolved
libcoap-sys/build.rs Outdated Show resolved Hide resolved
libcoap/build.rs Show resolved Hide resolved
libcoap/src/context.rs Show resolved Hide resolved
libcoap/src/types.rs Outdated Show resolved Hide resolved
pulsastrix added a commit that referenced this pull request Aug 22, 2024
Copy link
Member

@JKRhb JKRhb left a comment

Choose a reason for hiding this comment

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

LGTM! :)

@pulsastrix pulsastrix merged commit 1d4c557 into main Aug 22, 2024
13 checks passed
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.

Add feature availability detection to libcoap-rs library initialization
2 participants