Feature/rdk 60236 file#190
Open
Abhinavpv28 wants to merge 79 commits intodevelopfrom
Open
Conversation
Code Coverage Summary |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for issue type strings that include a dynamic suffix (e.g., identifiers appended after an underscore) by splitting the base issue type from its suffix and incorporating the suffix into the uploaded tar/log name.
Changes:
- Added utilities to split an issue type into base + suffix and persist/retrieve the suffix via a temp file.
- Updated issue event processing to use only the base issue type for JSON lookup/command execution, while using the persisted suffix for upload naming.
- Expanded issue-type sanitization to allow
_and-.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/rrdJsonParser.h |
Exposes new suffix persistence and issue-type splitting helpers. |
src/rrdJsonParser.c |
Implements suffix persistence/readback and uses it when building the upload name. |
src/rrdEventProcess.c |
Splits issue types before processing; persists suffix for later upload; updates sanitization to retain _/-. |
Comment on lines
+82
to
+85
| char base[128] = {0}; | ||
| char local_suffix[128] = {0}; | ||
| split_issue_type(cmdMap[index], base, sizeof(base), local_suffix, sizeof(local_suffix)); | ||
| dataMsgLen = strlen(base) + 1; |
Comment on lines
+641
to
+652
| // Use the persisted suffix from file for upload | ||
| char suffix[128] = {0}; | ||
| read_suffix_from_file_to_buf(suffix, sizeof(suffix)); | ||
| char tarName[512] = {0}; | ||
| if (suffix[0] != '\0') { | ||
| snprintf(tarName, sizeof(tarName), "%s%s", buff->mdata, suffix); | ||
| } else { | ||
| snprintf(tarName, sizeof(tarName), "%s", buff->mdata); | ||
| } | ||
| RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: [INFO] Tar file name for upload: '%s'\n", __FUNCTION__, __LINE__, tarName); | ||
| status = uploadDebugoutput(outdir, tarName); | ||
| persist_suffix_to_file(""); // Clear the suffix file after upload |
Code Coverage Summary |
Code Coverage Summary |
Contributor
Author
|
add gtest testcases for new functions added |
Code Coverage Summary |
Comment on lines
+50
to
+66
|
|
||
| void persist_suffix_to_file(const char *filename, const char *suffix) | ||
| { | ||
| int fd; | ||
| if (!filename) | ||
| { | ||
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: persist_suffix_to_file called with NULL filename\n", __FUNCTION__, __LINE__); | ||
| return; | ||
| } | ||
| fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW, 0600); | ||
| if (fd >= 0) | ||
| { | ||
| FILE *fp = fdopen(fd, "w"); | ||
| if (fp) | ||
| { | ||
| if (fprintf(fp, "%s\n", suffix) > 0) | ||
| { |
Code Coverage Summary |
Comment on lines
+5824
to
+5830
| void SetUp() override { | ||
| struct stat dir_stat = {}; | ||
|
|
||
| if (mkdir("/tmp/rrd", 0777) != 0) { | ||
| ASSERT_EQ(stat("/tmp/rrd", &dir_stat), 0) << "Failed to access /tmp/rrd"; | ||
| ASSERT_TRUE(S_ISDIR(dir_stat.st_mode)) << "/tmp/rrd exists but is not a directory"; | ||
| } |
Code Coverage Summary |
1 similar comment
Code Coverage Summary |
Code Coverage Summary |
| persist_suffix_to_file("/tmp/rrd_suffix.txt","_OldSuffix"); | ||
| persist_suffix_to_file("/tmp/rrd_suffix.txt","_NewSuffix"); | ||
| char buf[64] = {0}; | ||
| read_suffix_from_file_to_buf("/tmp/rrd/rrd_suffix.txt",buf, sizeof(buf)); |
Code Coverage Summary |
| protected: | ||
| void TearDown() override { | ||
| // Remove suffix temp file to avoid state leakage between tests | ||
| remove("/tmp/rrd_suffix.txt"); |
Comment on lines
+85
to
+89
| if (base[0] == '\0') | ||
| { | ||
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: Invalid IssueType [%s] - empty base after split, skipping\n", __FUNCTION__, __LINE__, cmdMap[index]); | ||
| free(cmdBuff); | ||
| cmdBuff = NULL; |
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: persist_suffix_to_file called with NULL filename\n", __FUNCTION__, __LINE__); | ||
| return; | ||
| } | ||
| fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW | O_CLOEXEC, 0600); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.