Skip to content

RDKEMW-12350: Add unit tests for timeZoneDST fallback path in getTimezone()#329

Open
Copilot wants to merge 6 commits intocopilot/improve-zone-null-checksfrom
copilot/sub-pr-324
Open

RDKEMW-12350: Add unit tests for timeZoneDST fallback path in getTimezone()#329
Copilot wants to merge 6 commits intocopilot/improve-zone-null-checksfrom
copilot/sub-pr-324

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

  • Remove the spurious .WillOnce(Return(EOF)) from SetupReachTimeZoneDSTFallback in xconfclientTest.cppgetBuildType breaks out of the fscanf loop as soon as it finds "BUILD_TYPE", so fscanf is only called once, not twice

Copilot AI changed the title [WIP] Fix uninitialized missing error checks in timeZoneDST fallback path RDKEMW-12350: Add unit tests for timeZoneDST fallback path in getTimezone() Apr 14, 2026
Copilot AI requested a review from yogeswaransky April 14, 2026 16:18
@yogeswaransky yogeswaransky marked this pull request as ready for review April 14, 2026 17:01
@yogeswaransky yogeswaransky requested a review from a team as a code owner April 14, 2026 17:01
Copilot AI review requested due to automatic review settings April 14, 2026 17:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Google Test coverage for the getTimezone() fallback path that reads /opt/persistent/timeZoneDST (reached after the JSON retry loop), exercised indirectly via appendRequestParams().

Changes:

  • Add 5 new unit tests covering timeZoneDST fallback failure modes and a success case.
  • Add a shared test helper to drive execution into the fallback path.
  • Adjust GitHub Actions PR branch filters for L1/L2 workflows.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.

File Description
source/test/xconf-client/xconfclientTest.cpp Adds tests and a helper to force getTimezone() into the /opt/persistent/timeZoneDST fallback path.
.github/workflows/L1-tests.yml Updates which target branches trigger the L1 workflow on pull requests.
.github/workflows/L2-tests.yml Updates which target branches trigger the L2 workflow on pull requests.

curl_url_set(requestURL, CURLUPART_URL,
"https://mockxconf:50050/loguploader/getT2DCMSettings", 0);
EXPECT_EQ(T2ERROR_FAILURE, appendRequestParams(requestURL));
curl_free(requestURL);
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

requestURL is a CURLU* created by curl_url(), which should be released with curl_url_cleanup(). Using curl_free() on a CURLU* is not the documented cleanup API and can lead to leaks or undefined behavior.

Copilot uses AI. Check for mistakes.
curl_url_set(requestURL, CURLUPART_URL,
"https://mockxconf:50050/loguploader/getT2DCMSettings", 0);
EXPECT_EQ(T2ERROR_FAILURE, appendRequestParams(requestURL));
curl_free(requestURL);
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

requestURL is a CURLU* created by curl_url(), which should be released with curl_url_cleanup(). Using curl_free() on a CURLU* is not the documented cleanup API and can lead to leaks or undefined behavior.

Copilot uses AI. Check for mistakes.
curl_url_set(requestURL, CURLUPART_URL,
"https://mockxconf:50050/loguploader/getT2DCMSettings", 0);
EXPECT_EQ(T2ERROR_SUCCESS, appendRequestParams(requestURL));
curl_free(requestURL);
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

requestURL is a CURLU* created by curl_url(), which should be released with curl_url_cleanup(). Using curl_free() on a CURLU* is not the documented cleanup API and can lead to leaks or undefined behavior.

Suggested change
curl_free(requestURL);
curl_url_cleanup(requestURL);

Copilot uses AI. Check for mistakes.
buf[10] = '\0';
return 1;
}))
.WillOnce(Return(0));
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

The comment says the second fscanf call "signals end-of-file", but the mock returns 0. In getTimezone() the loop condition is fscanf(...) == 1, so returning EOF would better reflect end-of-file and keep the comment accurate (or update the comment to match the 0 return).

Suggested change
.WillOnce(Return(0));
.WillOnce(Return(EOF));

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/L1-tests.yml
Comment on lines +803 to +811
EXPECT_CALL(*g_fileIOMock, fscanf(devicePropsHandle, _, _))
.WillOnce(Invoke([](FILE*, const char*, va_list args) -> int {
char* buf = va_arg(args, char*);
strncpy(buf, "BUILD_TYPE=PROD", 254);
buf[254] = '\0';
return 1;
}))
.WillOnce(Return(EOF));

Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

SetupReachTimeZoneDSTFallback configures fscanf(devicePropsHandle, ...) to be called twice (second call returns EOF). In getBuildType() the loop breaks as soon as "BUILD_TYPE" is found, so with the mocked buffer containing "BUILD_TYPE=PROD" it will typically call fscanf only once. This makes the expectation overspecified and can cause these tests to fail; adjust the expectation to match a single call or allow additional calls only when the loop continues (e.g., by using a repeated EOF fallback instead of requiring a second call).

Copilot uses AI. Check for mistakes.
curl_url_set(requestURL, CURLUPART_URL,
"https://mockxconf:50050/loguploader/getT2DCMSettings", 0);
EXPECT_EQ(T2ERROR_FAILURE, appendRequestParams(requestURL));
curl_free(requestURL);
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

requestURL is a CURLU* created by curl_url(), which should be released with curl_url_cleanup(). Using curl_free() on a CURLU* is not the documented cleanup API and can lead to leaks or undefined behavior.

Copilot uses AI. Check for mistakes.
curl_url_set(requestURL, CURLUPART_URL,
"https://mockxconf:50050/loguploader/getT2DCMSettings", 0);
EXPECT_EQ(T2ERROR_FAILURE, appendRequestParams(requestURL));
curl_free(requestURL);
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

requestURL is a CURLU* created by curl_url(), which should be released with curl_url_cleanup(). Using curl_free() on a CURLU* is not the documented cleanup API and can lead to leaks or undefined behavior.

Copilot uses AI. Check for mistakes.
on:
pull_request:
branches: [ develop, support/1.8 ]
branches: [ develop ]
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

Changing the pull_request.branches filter from [ develop, support/1.8 ] to only [ develop ] means L2 integration tests will no longer run for PRs targeting support/1.8. If support/1.8 PRs are still expected to be validated by L2 in this repo, this should be kept (or replaced with the desired set).

Suggested change
branches: [ develop ]
branches: [ develop, support/1.8 ]

Copilot uses AI. Check for mistakes.
…o break in getBuildType

Agent-Logs-Url: https://github.com/rdkcentral/telemetry/sessions/d94df585-444b-4056-a136-bc1f7415c614

Co-authored-by: yogeswaransky <166126056+yogeswaransky@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 16, 2026 08:56
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