-
Notifications
You must be signed in to change notification settings - Fork 6
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
Support argument parsing in L3's core l3_dump.py utility. #31
Conversation
@@ -116,6 +116,9 @@ L3_SRCDIR := $(SRCDIR) | |||
L3_INCDIR := $(INCDIR) | |||
USE_CASES := use-cases | |||
|
|||
# Name of L3 dump utility that unpacks L3 log-entries | |||
L3_DUMP := l3_dump.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No major logic-change. Just use this symbol in this file rather than the hard-coded Python tool's name.
@@ -118,6 +118,8 @@ USE_CASES := use-cases | |||
|
|||
# Name of L3 dump utility that unpacks L3 log-entries | |||
L3_DUMP := l3_dump.py | |||
L3_DUMP_ARG_LOG_FILE := --log-file | |||
L3_DUMP_ARG_BINARY := --binary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify Make-symbols for the required command-line flags.
@@ -636,42 +638,36 @@ run-c-tests: all-c-tests | |||
@echo '---- Run C unit-tests: ----' | |||
./$(C_UNIT_TEST_BIN) | |||
@echo | |||
./$(L3_DUMP) | |||
python3 $(L3_DUMP) $(L3_DUMP_ARG_LOG_FILE) $(L3_C_DATA) $(L3_DUMP_ARG_BINARY) ./$(C_UNIT_TEST_BIN) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace all instances of calls to this tool to now specify the required command-line flags.
Makefile
Outdated
@@ -636,42 +638,36 @@ run-c-tests: all-c-tests | |||
@echo '---- Run C unit-tests: ----' | |||
./$(C_UNIT_TEST_BIN) | |||
@echo | |||
./$(L3_DUMP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines are deleted because with built-in argument parsing, by just running the tool by itself, we will get a usage error and a hard-failure:
Macintosh:[295] $ ./l3_dump.py
usage: l3_dump.py [-h] --log-file <log-file-name> --binary <program-binary> [--verbose] [--debug]
l3_dump.py: error: the following arguments are required: --log-file, --binary
Macintosh:[296] $ echo $?
2
This breaks test-execution, so deleted this call.
, default=False | ||
, help='Show verbose progress messages') | ||
|
||
parser.add_argument('--debug', dest='debug_script' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added args --verbose
and --debug
in anticipation of using them in future. I will add test cases to exercise these in future revisions.
This commit refactors Makefile to replace use of hard-coded `l3_dump.py` with a symbol, L3_DUMP . No other logi changes are done with this commit.
This commit enhances the L3 dumping tool, `l3_dump.py` to support command-line arguments. --- Macintosh:[285] $ ./l3_dump.py usage: l3_dump.py [-h] --log-file <log-file-name> --binary <program-binary> [--verbose] [--debug] l3_dump.py: error: the following arguments are required: --log-file, --binary --- Corresponding changes are made to `Makefile` and test-code to invoke this Python script with required command-line arguments.
a35ea24
to
02412a5
Compare
This PR includes couple of commits to add support for argument parsing to
l3_dump.py
script:Makefile
: Update all references tol3_dump.py
with symbolL3_DUMP
l3_dump.py
: Support command-line argumentsThis commit enhances the L3 dumping tool,
l3_dump.py
to support command-line arguments.Corresponding changes are made to
Makefile
and test-code to invoke this Python script with required command-line arguments.NOTE to reviewer:
Just examine the last 2 commits ( refactoring and parser-support ) in this PR. They build on top of previous 2 commits that are bundled in this PR but will be checked-in separately.
With all the refactoring, pytests-addition and Mac/OSX-support done in previous dev work, the actual task of refactoring the
l3_dump.py
to add--argument-parsing
was very easy!