2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-01-06 00:12:31 +00:00

fix issue #4354 :The XCATTEST_CN in xcattest can not detect HCP as config file (#4355)

This commit is contained in:
Weihua Hu
2017-11-21 16:23:00 +08:00
committed by Bin Xu
parent 323040a944
commit 27dea1a2a9

View File

@@ -251,6 +251,15 @@ if ($setup_env_by_config_file) {
}
}
log_this($running_log_fd, "******************************");
log_this($running_log_fd, "To detect current test environment");
log_this($running_log_fd, "******************************");
$rst = detect_current_env(\%config, \$error);
if ($rst) {
log_this($running_log_fd, "$error");
to_exit(1);
}
log_this($running_log_fd, "******************************");
log_this($running_log_fd, "loading test cases");
log_this($running_log_fd, "******************************");
@@ -1419,9 +1428,27 @@ sub setup_env_by_configure_file {
}
}
return 0;
}
#--------------------------------------------------------
# Fuction name: detect_current_env
# Description: detect some important attribute in current environment, such as os, arch, hcp...
# Atrributes:
# $config_ref (input attribute)
# The reference of global hash %config.
# The structure of %config please refer to the comment of function load_config_file
# $error_ref (output attribe)
# The reference of scalar to save the error message generated during running current function
# Retrun code: 0 Success 1 Failed
#--------------------------------------------------------
sub detect_current_env{
my $config_ref = shift;
my $error_ref = shift;
if (!exists $$config_ref{var}{OS}) {
my @output = runcmd("uname");
$$config_ref{var}{OS} = $output[0];
$$config_ref{var}{OS} = lc($output[0]);
log_this($running_log_fd, "Detecting: OS = $$config_ref{var}{OS}");
} else {
$$config_ref{var}{OS} = lc($$config_ref{var}{OS});
@@ -1433,11 +1460,11 @@ sub setup_env_by_configure_file {
log_this($running_log_fd, "Warning: No compute node defined, can't get ARCH of compute node");
} else {
$$config_ref{var}{ARCH} = getnodeattr($$config_ref{var}{CN}, "arch");
if ($$config_ref{var}{ARCH} =~ /le|el/) {
if ($$config_ref{var}{ARCH} =~ /le|el/i) {
$$config_ref{var}{ARCH} = 'ppc64le';
} elsif ($$config_ref{var}{ARCH} =~ /ppc/) {
} elsif ($$config_ref{var}{ARCH} =~ /ppc/i) {
$$config_ref{var}{ARCH} = 'ppc';
} elsif ($$config_ref{var}{ARCH} =~ /86/) {
} elsif ($$config_ref{var}{ARCH} =~ /86/i) {
$$config_ref{var}{ARCH} = 'x86';
}
log_this($running_log_fd, "Detecting: ARCH = $$config_ref{var}{ARCH}");
@@ -1458,6 +1485,9 @@ sub setup_env_by_configure_file {
return 0;
}
#--------------------------------------------------------
# Fuction name: runcmd
# Description: run a command after 'cmd' label in one case