mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
tests: update to renamed envvars
Enhance 'not' so 'should' now shows log trace from command which has failed but should not.
This commit is contained in:
parent
85e833c172
commit
caa9223c85
@ -124,7 +124,7 @@ lvmetad_dump() {
|
||||
|
||||
notify_lvmetad() {
|
||||
if test -e LOCAL_LVMETAD; then
|
||||
pvscan --cache "$@" || true
|
||||
LVM_LOG_FILE_EPOCH= pvscan --cache "$@" || rm -f debug.log
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ RUNNING_DMEVENTD=$(pgrep dmeventd) || true
|
||||
|
||||
export TESTOLDPWD TESTDIR COMMON_PREFIX PREFIX RUNNING_DMEVENTD
|
||||
export LVM_LOG_FILE_EPOCH=DEBUG
|
||||
export LVM_LOG_FILE_UNLINK_STATUS=1
|
||||
export LVM_EXPECTED_EXIT_STATUS=1
|
||||
|
||||
test -n "$BASH" && trap 'set +vx; STACKTRACE; set -vx' ERR
|
||||
trap 'aux teardown' EXIT # don't forget to clean up
|
||||
|
@ -20,12 +20,25 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
static int finished(const char *cmd, int status) {
|
||||
static int _finished(const char *cmd, int status, int pid) {
|
||||
int ret;
|
||||
if (!strcmp(cmd, "not"))
|
||||
return !status;
|
||||
if (!strcmp(cmd, "should")) {
|
||||
if (status)
|
||||
if (status) {
|
||||
fprintf(stderr, "TEST WARNING: Ignoring command failure.\n");
|
||||
/* TODO: avoid using shell here */
|
||||
/* Show log for failing command which should be passing */
|
||||
ret = system("ls debug.log*${LVM_LOG_FILE_EPOCH}* 2>/dev/null");
|
||||
if (WIFEXITED(ret) && WEXITSTATUS(ret) == 0) {
|
||||
printf("## timing off\n<======== Debug log ========>\n"); /* timing off */
|
||||
fflush(stdout);
|
||||
system("sed -e 's,^,## DEBUG: ,' debug.log*${LVM_LOG_FILE_EPOCH}* 2>/dev/null");
|
||||
printf("## timing on\n"); /* timing on */
|
||||
system("rm -f debug.log*${LVM_LOG_FILE_EPOCH}*");
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} else if (!strcmp(cmd, "invalid")) {
|
||||
if (status == 3)
|
||||
@ -56,14 +69,14 @@ int main(int args, char **argv) {
|
||||
return FAILURE;
|
||||
} else if (pid == 0) { /* child */
|
||||
if (!strcmp(argv[0], "not"))
|
||||
val = "!1";
|
||||
val = ">1";
|
||||
else if (!strcmp(argv[0], "invalid"))
|
||||
val = "3";
|
||||
else if (!strcmp(argv[0], "fail"))
|
||||
val = "5";
|
||||
|
||||
if (val)
|
||||
setenv("LVM_LOG_FILE_UNLINK_STATUS", val, 1);
|
||||
setenv("LVM_EXPECTED_EXIT_STATUS", val, 1);
|
||||
|
||||
execvp(argv[1], &argv[1]);
|
||||
/* should not be accessible */
|
||||
@ -79,7 +92,7 @@ int main(int args, char **argv) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
return finished(argv[0], WEXITSTATUS(status));
|
||||
return _finished(argv[0], WEXITSTATUS(status), pid);
|
||||
}
|
||||
/* not accessible */
|
||||
return FAILURE;
|
||||
|
Loading…
Reference in New Issue
Block a user