-
Notifications
You must be signed in to change notification settings - Fork 1
test(zowex): Add system tests for zowex data-set commands #622
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
base: main
Are you sure you want to change the base?
Changes from 9 commits
8554220
f8ec810
e93e7b3
be0a7b4
222f7f8
ffe5209
606b129
4c9f112
d534517
569a312
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /** | ||
| * This program and the accompanying materials are made available under the terms of the | ||
| * Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-v20.html | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Copyright Contributors to the Zowe Project. | ||
| * | ||
| */ | ||
|
|
||
| #ifndef ZOWEX_DS_TEST_HPP | ||
| #define ZOWEX_DS_TEST_HPP | ||
| void zowex_ds_tests(); | ||
| #endif |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,105 @@ | ||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * This program and the accompanying materials are made available under the terms of the | ||||||||||||||||||||||||||
| * Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||||||||||||||||||||||||||
| * https://www.eclipse.org/legal/epl-v20.html | ||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||
| * SPDX-License-Identifier: EPL-2.0 | ||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||
| * Copyright Contributors to the Zowe Project. | ||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| #ifndef ZTEST_UTILS_HPP | ||||||||||||||||||||||||||
| #define ZTEST_UTILS_HPP | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| #include "ztest.hpp" | ||||||||||||||||||||||||||
| #include <iostream> | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| using namespace std; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Helper function to convert string to hex format | ||||||||||||||||||||||||||
| // TODO(Kelosky): move to zut.hpp if additional use is found | ||||||||||||||||||||||||||
| string string_to_hex(const string &input) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| string hex_output; | ||||||||||||||||||||||||||
| for (char c : input) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| char hex_byte[3]; | ||||||||||||||||||||||||||
| sprintf(hex_byte, "%02x", static_cast<unsigned char>(c)); | ||||||||||||||||||||||||||
| hex_output += hex_byte; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| return hex_output; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // NOTE(Kelosky): consolidate this into ztest.hpp if additional use is found | ||||||||||||||||||||||||||
| int execute_command_with_output(const string &command, string &output) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| output = ""; | ||||||||||||||||||||||||||
| // TestLog("Running: " + command); | ||||||||||||||||||||||||||
Check noticeCode scanning / CodeQL Commented-out code Note test
This comment appears to contain commented-out code.
Copilot AutofixAI 1 day ago The best way to fix this problem is to remove the commented-out code, as retaining commented-out code leads to code rot and confusion. If the logging functionality is still desired or needed, the author should add a properly enabled logging statement, perhaps with a guard or modern logging mechanism. If it was left for future use or as a suggestion, it should be transformed into a regular code comment, not a commented-out code line. For minimum intervention and to avoid changing behavior, the fix should be to delete line 38 entirely from
Suggested changeset
1
native/c/test/ztest.utils.hpp
Copilot is powered by AI and may make mistakes. Always verify output.
Positive FeedbackNegative Feedback
Refresh and try again.
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| FILE *pipe = popen((command + " 2>&1").c_str(), "r"); | ||||||||||||||||||||||||||
| if (!pipe) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| throw runtime_error("Failed to open pipe"); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| char buffer[256]; | ||||||||||||||||||||||||||
| while (fgets(buffer, sizeof(buffer), pipe) != nullptr) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| output += buffer; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| int exit_code = pclose(pipe); | ||||||||||||||||||||||||||
| return WEXITSTATUS(exit_code); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| string get_random_string(const int length = 7, const bool allNumbers = true) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| static bool seeded = false; | ||||||||||||||||||||||||||
| if (!seeded) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| srand(static_cast<unsigned int>(time(NULL))); | ||||||||||||||||||||||||||
| seeded = true; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| string ret = ""; | ||||||||||||||||||||||||||
| for (int i = 0; i < length; ++i) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| ret += to_string(rand() % 10); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| return ret; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| string get_random_ds(const int qualifier_count = 4, const string hlq = "") | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| string q = hlq; | ||||||||||||||||||||||||||
| if (q.length() == 0) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| string user; | ||||||||||||||||||||||||||
| execute_command_with_output("whoami", user); | ||||||||||||||||||||||||||
| q = ztst::TrimChars(user); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| string ret = q + ".ZNP#TEST"; | ||||||||||||||||||||||||||
| for (int i = 0; i < qualifier_count - 2; ++i) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| ret += ".Z" + get_random_string(); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| return ret; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| vector<string> split_rfc_response(const string input, const char *delim) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| vector<string> ret; | ||||||||||||||||||||||||||
| char *cstr = new char[input.length() + 1]; | ||||||||||||||||||||||||||
| strcpy(cstr, input.c_str()); | ||||||||||||||||||||||||||
| char *token_ptr = strtok(cstr, delim); | ||||||||||||||||||||||||||
| while (token_ptr != NULL) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| string token = token_ptr; | ||||||||||||||||||||||||||
| ret.push_back(ztst::TrimChars(token)); | ||||||||||||||||||||||||||
| token_ptr = strtok(NULL, delim); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| delete[] cstr; | ||||||||||||||||||||||||||
| return ret; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||
Check warning
Code scanning / CodeQL
Expression has no effect Warning test
Copilot Autofix
AI 1 day ago
The recommended fix for this issue, per static analysis guidance, is to explicitly cast the function call expression to
void, using(void)pad_nesting(get_nesting());. This documents that it is executed for its side effect only, and clarifies to reviewers and tools that the function’s return value (void) is intentionally ignored. The only change required is to line 414 ofnative/c/test/ztest.hpp, within the body oftest_log, replacing the plain call topad_nesting(get_nesting());with(void)pad_nesting(get_nesting());. No imports or other changes are necessary.