Skip to content
This repository has been archived by the owner on Jan 28, 2023. It is now read-only.

Commit

Permalink
checktool: Update check tool command options
Browse files Browse the repository at this point in the history
Update the command options and corresponding output descriptions for
check tool.

* Use '-v' option to show version information, replacing the previous
  trivial function
* Update README document

Signed-off-by: Wenchao Wang <[email protected]>
  • Loading branch information
wcwang committed Jan 20, 2023
1 parent cc86e90 commit 6664225
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 30 deletions.
6 changes: 3 additions & 3 deletions CheckTool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ available [here][checktool-release].
### Usage

1. `cd X:\path\to\CheckTool`
1. `checktool.exe --verbose`
1. `checktool.exe`

The output will be as below.

Expand Down Expand Up @@ -98,7 +98,7 @@ be omitted.
### Usage

1. `cd /path/to/CheckTool`
1. `./checktool --verbose`
1. `./checktool`

### Build

Expand Down Expand Up @@ -126,7 +126,7 @@ below.
| `cmake -DCMAKE_BUILD_TYPE=Release -B build/Release`
| `make -C build/Release`

[checktool-release]: https://github.com/intel/haxm/releases/tag/checktool-v1.0.0
[checktool-release]: https://github.com/intel/haxm/releases/tag/checktool-v1.1.0
[cmake]: https://cmake.org/download/
[install-on-macos]:
https://github.com/intel/haxm/wiki/Installation-Instructions-on-macOS
Expand Down
36 changes: 19 additions & 17 deletions CheckTool/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,37 @@
namespace haxm {
namespace check_util {

CheckResult ParseArguments(int &argc, char* argv[], bool &is_verbose) {
haxm::check_util::ArgParser arg_parser(argc, argv, {"-h", "--help", "-v",
"--verbose"});
CheckResult ParseArguments(int &argc, char* argv[]) {
CheckResult res = kPass;
ArgParser arg_parser(argc, argv, {"-h", "--help", "-v", "--version"});

if (!arg_parser.Verify()) {
std::cout << "checktool unknown option: " << arg_parser.error()
<< std::endl;
std::cout << "Usage: checktool [-h | --help] [-v | --verbose]"
std::cout << "Usage: checktool [-h | --help] [-v | --version]"
<< std::endl;
return haxm::check_util::kError;
return kError;
}

if (arg_parser.Test("-h") || arg_parser.Test("--help")) {
std::cout << "CheckTool version " << APP_VERSION << std::endl;
std::cout << "-v, --verbose Show detailed system information"
<< std::endl;
return haxm::check_util::kFail;
if (arg_parser.Test("-v") || arg_parser.Test("--version")) {
std::cout << "checktool " << APP_VERSION << std::endl;
std::cout << APP_COPYRIGHT << std::endl;

res = kFail;
}

if (arg_parser.Test("-v") || arg_parser.Test("--verbose")) {
is_verbose = true;
if (arg_parser.Test("-h") || arg_parser.Test("--help")) {
std::cout << "Usage: checktool [-v | --version]" << std::endl;
std::cout << "Check system environment for HAXM." << std::endl;
std::cout << "'*' means passed, while '-' means failed." << std::endl;

res = kFail;
}

return haxm::check_util::kPass;
return res;
}

int Check(bool is_verbose) {
int Check() {
int ret = 0;

haxm::check_util::FeatureDetector fd;
Expand All @@ -75,9 +79,7 @@ int Check(bool is_verbose) {
ret = 1;
}

if (is_verbose) {
fd.Print();
}
fd.Print();

return ret;
}
Expand Down
7 changes: 4 additions & 3 deletions CheckTool/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
namespace haxm {
namespace check_util {

#define APP_VERSION "1.0.0"
#define APP_VERSION "1.1.0"
#define APP_COPYRIGHT "Copyright (C) 2020 Intel Corporation"

enum CheckResult {
kUnknown = 0,
Expand All @@ -52,8 +53,8 @@ inline static bool IsBitSet(uint32_t reg, int bit) {
return (reg >> bit) & 0x1;
}

CheckResult ParseArguments(int &argc, char* argv[], bool &is_verbose);
int Check(bool is_verbose);
CheckResult ParseArguments(int &argc, char* argv[]);
int Check();

} // namespace check_util
} // namespace haxm
Expand Down
10 changes: 3 additions & 7 deletions CheckTool/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,14 @@

int main(int argc, char* argv[]) {
int ret = 0;
haxm::check_util::CheckResult result;
bool is_verbose = false;

result = haxm::check_util::ParseArguments(argc, argv, is_verbose);

switch (result) {
switch (haxm::check_util::ParseArguments(argc, argv)) {
case haxm::check_util::kPass: {
ret = haxm::check_util::Check(is_verbose);
ret = haxm::check_util::Check();
break;
}
case haxm::check_util::kError: {
ret = -1;
ret = 1;
break;
}
default: {
Expand Down

0 comments on commit 6664225

Please sign in to comment.