mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
libdm: add DM_ABORT_ON_INTERNAL_ERRORS
Support tests with abort when libdm encounters internal error - i.e. for dmsetup tool. Code execution will be aborted when env var DM_ABORT_ON_INTERNAL_ERRORS is set to 1
This commit is contained in:
parent
4a722c5c8b
commit
5d9628475e
@ -1,5 +1,6 @@
|
||||
Version 1.02.79 -
|
||||
================================
|
||||
Add DM_ABORT_ON_INTERNAL_ERRORS env var support to abort on internal errors.
|
||||
|
||||
Version 1.02.78 - 24th July 2013
|
||||
================================
|
||||
|
@ -57,6 +57,7 @@ extern "C" {
|
||||
* Use dm_log_with_errno_init(NULL) to restore the default log fn.
|
||||
* Error messages may have a non-zero errno.
|
||||
* Debug messages may have a non-zero class.
|
||||
* Aborts on internal error when env DM_ABORT_ON_INTERNAL_ERRORS is 1
|
||||
*/
|
||||
|
||||
typedef void (*dm_log_with_errno_fn) (int level, const char *file, int line,
|
||||
|
@ -114,22 +114,26 @@ static void _default_log_line(int level,
|
||||
int line __attribute__((unused)), int dm_errno_or_class,
|
||||
const char *f, va_list ap)
|
||||
{
|
||||
int use_stderr = level & _LOG_STDERR;
|
||||
static int _abort_on_internal_errors = -1;
|
||||
FILE *out = (level & _LOG_STDERR) ? stderr : stdout;
|
||||
|
||||
level &= ~_LOG_STDERR;
|
||||
|
||||
if (level > _LOG_WARN && !_verbose)
|
||||
return;
|
||||
|
||||
if (level <= _LOG_WARN || _verbose) {
|
||||
if (level < _LOG_WARN)
|
||||
vfprintf(stderr, f, ap);
|
||||
else
|
||||
vfprintf(use_stderr ? stderr : stdout, f, ap);
|
||||
out = stderr;
|
||||
vfprintf(out, f, ap);
|
||||
fputc('\n', out);
|
||||
}
|
||||
|
||||
if (level < _LOG_WARN)
|
||||
fprintf(stderr, "\n");
|
||||
else
|
||||
fprintf(use_stderr ? stderr : stdout, "\n");
|
||||
if (_abort_on_internal_errors < 0)
|
||||
/* Set when env DM_ABORT_ON_INTERNAL_ERRORS is 1 */
|
||||
_abort_on_internal_errors =
|
||||
!strcmp(getenv("DM_ABORT_ON_INTERNAL_ERRORS") ? : "0", "1");
|
||||
|
||||
if (_abort_on_internal_errors &&
|
||||
!strncmp(f, INTERNAL_ERROR, sizeof(INTERNAL_ERROR) - 1))
|
||||
abort();
|
||||
}
|
||||
|
||||
__attribute__((format(printf, 5, 6)))
|
||||
|
@ -50,7 +50,10 @@ else
|
||||
mkdir "$DM_DEV_DIR/mapper"
|
||||
fi
|
||||
|
||||
export DM_DEV_DIR LVM_SYSTEM_DIR
|
||||
# abort on the internal dm errors in the tests (allowing test user override)
|
||||
DM_ABORT_ON_INTERNAL_ERRORS=${DM_ABORT_ON_INTERNAL_ERRORS:-1}
|
||||
|
||||
export DM_DEV_DIR LVM_SYSTEM_DIR DM_ABORT_ON_INTERNAL_ERRORS
|
||||
|
||||
cd "$TESTDIR"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user