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

Improve Storage code coverage #2052

Merged
merged 16 commits into from
Jan 13, 2022
Merged

Improve Storage code coverage #2052

merged 16 commits into from
Jan 13, 2022

Conversation

antkmsft
Copy link
Member

@antkmsft antkmsft commented Dec 15, 2021

Closes #2052

@antkmsft antkmsft self-assigned this Dec 15, 2021
@antkmsft antkmsft changed the base branch from main to feature/storage-blobs December 15, 2021 18:48
@antkmsft antkmsft marked this pull request as ready for review December 17, 2021 00:59
@antkmsft antkmsft requested a review from RickWinter as a code owner December 17, 2021 00:59
@antkmsft antkmsft added this to the [2022] January milestone Dec 17, 2021
@antkmsft antkmsft requested a review from ahsonkhan December 17, 2021 01:02
@antkmsft antkmsft added MQ This issue is part of a "milestone of quality" initiative. Storage Storage Service (Queues, Blobs, Files) labels Dec 17, 2021
@antkmsft antkmsft changed the title Improve storage code coverage Improve Storage code coverage Dec 17, 2021
@antkmsft antkmsft requested review from vhvb1989 and gearama December 17, 2021 22:06
@check-enforcer
Copy link

This repository is protected by Check Enforcer. The check-enforcer check-run will not pass until there is at least one more check-run successfully passing. Check Enforcer supports the following comment commands:

  • /check-enforcer evaluate; tells Check Enforcer to evaluate this pull request.
  • /check-enforcer override; by-pass Check Enforcer (approvals still required).

@antkmsft antkmsft merged commit 5c6fa6e into Azure:feature/storage-blobs Jan 13, 2022
Comment on lines +38 to +39
void test_storage_blobs_init_nonnull_options(void** state);
void test_storage_blobs_init_nonnull_options(void** state)
Copy link
Contributor

@ahsonkhan ahsonkhan Jan 13, 2022

Choose a reason for hiding this comment

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

We do we need to define the function like this first before implementing it?

Doesn't look like we do this elsewhere (in other places like core/json tests or iot hub), unless I am mistaken. And the tests are just static.

Copy link
Member Author

@antkmsft antkmsft Jan 13, 2022

Choose a reason for hiding this comment

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

We do. Could be in other places, but we do. This is to avoid warning on one of the compilers that we define a non-static function without prior declaration.

Comment on lines +426 to +427
#define URL_START "x://"
#define URL_START_LEN (sizeof(URL_START) - 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: rather than defining these macros and then undefining them after, why not use locals within the test function itself?

Copy link
Member Author

@antkmsft antkmsft Jan 13, 2022

Choose a reason for hiding this comment

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

I'd love to do that, - I really only use macros and non-local stuff if I have to, - but you see the size of the url_buf is greater than the size of "x://", so there is no good way of getting the value of URL_START_LEN without repetition, and if we do repetition, then there is always a possibility that you change one thing, but don't update another. So, macros are the most elegant and reliable way to do it.

(void)state;
SETUP_PRECONDITION_CHECK_TESTS();

_az_http_client_set_callback(no_op_transport);
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated question: Is this how we expect customers to set the transport?

Copy link
Member Author

Choose a reason for hiding this comment

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

To pick curl, you specify TRANSPORT_CURL=ON when building the SDK. There isn't any other transport at the moment, but in general the transport should implement the az_http_client_send_request() function. If there was WinHTTP implementation, for example, I'd think there would be some switch like TRANSPORT_WINHTTP=ON, and then in CMakeLists.txt for core we would replace az_curl.c with az_winhttp.c (can't easily have both, although it is possible).

In this specific case, when storage tests are built, they do implement the az_http_client_send_request(), and _az_http_client_set_callback() is really a part of storage tests, not the core API: see https://github.com/Azure/azure-sdk-for-c/blob/feature/storage-blobs/sdk/tests/storage/blobs/_az_test_http_client.h and https://github.com/Azure/azure-sdk-for-c/blob/feature/storage-blobs/sdk/tests/storage/blobs/_az_test_http_client.c . It allows you to provide callback, but our core does not directly offer you that feature, although as you see, if test code can do that, core could add that in the future if needed, or even customers can add that feature themselves if they need to switch between transport (although they'll have to do some linker magic or code patching to rename az_curl's az_http_client_send_request().

_az_http_client_set_callback(NULL);
}

#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Add a comment // AZ_NO_PRECONDITION_CHECKING

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's make clangformat to do that, like it does for C++. With manual comment, it may go out of sync (for instance, if you change the ifdef).

Copy link
Member Author

Choose a reason for hiding this comment

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

It looks like there isn't an option in clang-format to do that. I had an impression it does that, but that's for C++ namespaces, not the preprocessor directives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MQ This issue is part of a "milestone of quality" initiative. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants