-
Notifications
You must be signed in to change notification settings - Fork 59
case-lib: hijack.sh use trap to hijack exit command #229
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
Conversation
|
@Bin-QA Once we use this version of exit, we need to clean up old exit calls in test case, right? |
|
@aiChaoSONG current without more old exit |
|
@Bin-QA , Yes, you are right. when use trap, the func_hijack_exit will be automatically called. Now got the idea |
case-lib/hijack.sh
Outdated
| ;; | ||
| esac | ||
|
|
||
| trap '' EXIT |
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 don't think you need this.
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 missed all the processing done on the exit code, sorry. I don't think you don't have access to the exit code in trap EXIT, so I don't think this can work. How did you test it?
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.
yes, you are right, I already test it without this line, it can be worked without recursive call the trap function
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.
@Bin-QA I don't understand your last comment, I don't understand how this can work and I would like to know with what failure and non-zero exit you tested this change because I really don't understand how this can report failures. Try this:
trap 'func_exit_handler' EXIT
func_exit_handler()
{
printf '$1 = |%s|\n' "$1"
local exit_status=${1:-0}
printf '(wrong) exit status = |%s|\n' "${exit_status}"
}
exit 5This prints:
$1 = ||
(wrong) exit status = |0|
Cc: @xiulipan
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.
Sorry for miss your point
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.
@marc-hb let's track it at gitlab
use 'trap' command hijack exit command instead of function 'exit' which perpare for 'set -e' Signed-off-by: Wu, BinX <binx.wu@intel.com>
xiulipan
left a comment
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.
LGTM, let's track the test status to see if this will bring any regression.
|
I still don't understand sorry. Which failure and non-zero exit_status was #229 tested with? |
|
There are still a number of |
In case test verify and simple step, it is not effect in current script, |
use 'trap' command hijack exit command instead of function
'exit' which perpare for 'set -e'
Signed-off-by: Wu, BinX binx.wu@intel.com