+2
−1
+3
−3
Loading
Since we use errtrace, the ERR trap is inherited and preserved in
each subshell, cmd substitution, etc. that we execute along the
way. This means that each failure inside such subshell triggers
call to print_backtrace(). Depending on the context, this may not
be desired. Consider simple example:
# foo() { return 1; }
# [[ $(foo) == no_output_so_fail_me ]]
This assumes that from the test perspective we don't care if foo(),
internally, fails, we just look for a specific string it should
return. If it doesn't, errexit will be triggered at the [[ level
and fail the test. This is fine, but before this happens, extra
print_backtrace() call will be made from the $() context.
Changing logic above and we may start spamming these calls:
# foo() { return 1; }
# [[ $(foo) -eq 0 ]]
Here failure still triggers the print_backtrace() but logically
the [[ test succeeds so we end up with a useless call in the log
which may be downright confusing.
Cherry on top is the fact that we don't inherit errexit inside
the subshell. So this print_backtrace() call is entirely foobar
as it won't do anything at all.
Best case would be to enable inherit_errexit from autotest_common.sh
across all the test suites. This, however, will require proper
discipline in maintaining the tests as use of subshell environment
would have to be more explicit - in other words the ambiguity from
the first example (i.e. failure != no output) would not be allowed.
For now, refactor code a bit to get rid of these extra calls, next
step would be to test behavior of inherit_errexit.
Change-Id: Ice3f072008162c1713e78a6da99a833919bc716c
Signed-off-by:
Michal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23078
Reviewed-by:
Ben Walker <ben@nvidia.com>
Reviewed-by:
Jim Harris <jim.harris@samsung.com>
Tested-by:
SPDK CI Jenkins <sys_sgci@intel.com>