Details
-
Bug
-
Resolution: Duplicate
-
Minor
-
None
-
None
-
None
-
3
-
9223372036854775807
Description
Some tests (for example test_12q and test_24d of sanity-hsm) perform several actions that require cleanup.
Unfortunately, trap does not provide any option to stack traps on top of one another.
Currently, tests handle this situation by including the previous cleanup in the code of the second cleanup:
cleanup_something() { undo_something } cleanup_test_XX() { undo_something else cleanup_something } test_XX() { trap clean_something() EXIT do_something trap cleanup_test_XX EXIT do_something else }
This method, while valid in most cases[1], requires developers to check whether or not, any utility function they use in their test(s) might set up a trap on its own.
[1] in sanity-hsm, copytool_setup() sets up a trap itself; this means that it has to be called before setting another trap such as cleanup_test_XX() (otherwise, cleanup_test_XX() would be overwritten) which is not always correct.