diff --git a/source/module_base/test/global_function_test.cpp b/source/module_base/test/global_function_test.cpp index f79bad0ce6..63fef746c2 100644 --- a/source/module_base/test/global_function_test.cpp +++ b/source/module_base/test/global_function_test.cpp @@ -417,8 +417,10 @@ TEST_F(GlobalFunctionTest, MakeDir) { GlobalV::MY_RANK = 0; ModuleBase::GlobalFunc::MAKE_DIR("scf"); - std::system("test -d "); - std::system("rm -r scf "); + auto error1 = std::system("test -d "); + EXPECT_EQ(error1, 0); + auto error2 = std::system("rm -r scf "); + EXPECT_EQ(error2, 0); SUCCEED(); } diff --git a/source/module_base/test/tool_threading_test.cpp b/source/module_base/test/tool_threading_test.cpp index ac2fc552c5..1624235b99 100644 --- a/source/module_base/test/tool_threading_test.cpp +++ b/source/module_base/test/tool_threading_test.cpp @@ -129,7 +129,9 @@ TEST(ToolThreadingTEST, OmpParalle) EXPECT_THAT(output1,testing::HasSubstr("1")); EXPECT_THAT(output1,testing::HasSubstr("0")); } +#ifndef _OPENMP #define _OPENMP +#endif TEST(ToolThreadingTEST, OmpParalleOpenmp) { std::string output2; diff --git a/source/module_cell/test/unitcell_test_para.cpp b/source/module_cell/test/unitcell_test_para.cpp index 20c90d26ac..11e1949a52 100644 --- a/source/module_cell/test/unitcell_test_para.cpp +++ b/source/module_cell/test/unitcell_test_para.cpp @@ -155,8 +155,10 @@ TEST_F(UcellTest,ReadPseudo) ifs.close(); std::string command1 = "test -d C && rm -rf C"; std::string command2 = "test -d H && rm -rf H"; - std::system( command1.c_str() ); - std::system( command2.c_str() ); + auto error1 = std::system( command1.c_str() ); + EXPECT_EQ(error1,0); + auto error2 = std::system( command2.c_str() ); + EXPECT_EQ(error2,0); } //read_cell_pseudopots //bcast_unitcell2 diff --git a/source/module_hamilt_general/module_xc/xc_functional_vxc.cpp b/source/module_hamilt_general/module_xc/xc_functional_vxc.cpp index 62096bfc03..44cb1751a7 100644 --- a/source/module_hamilt_general/module_xc/xc_functional_vxc.cpp +++ b/source/module_hamilt_general/module_xc/xc_functional_vxc.cpp @@ -454,6 +454,11 @@ std::tuple XC_Functional::v_xc_libxc( // Peiz ModuleBase::timer::tick("XC_Functional","v_xc_libxc"); return std::make_tuple( etxc, vtxc, std::move(v_nspin4) ); } // end if(4==GlobalV::NSPIN) + else//NSPIN != 1,2,4 is not supported + { + throw std::domain_error("GlobalV::NSPIN ="+std::to_string(GlobalV::NSPIN) + +" unfinished in "+std::string(__FILE__)+" line "+std::to_string(__LINE__)); + } } //the interface to libxc xc_mgga_exc_vxc(xc_func,n,rho,grho,laplrho,tau,e,v1,v2,v3,v4) diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.cpp index 63fccc47eb..3fc5d3a082 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.cpp @@ -173,6 +173,11 @@ void OperatorLCAO::init(const int ik_in) break; } + default: + { + ModuleBase::WARNING_QUIT("OperatorLCAO::init", "unknown cal_type"); + break; + } } if(this->next_op != nullptr) {//it is not the last node, loop next init() function diff --git a/source/module_io/restart.cpp b/source/module_io/restart.cpp index 0b60f4d8a0..cd54e11ed2 100644 --- a/source/module_io/restart.cpp +++ b/source/module_io/restart.cpp @@ -24,7 +24,8 @@ void Restart::write_file2(const std::string &file_name, const void*const ptr, co { const int file = open(file_name.c_str(), O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR); if(-1==file) throw std::runtime_error("can't open restart save file. \nerrno="+ModuleBase::GlobalFunc::TO_STRING(errno)+".\n"+ModuleBase::GlobalFunc::TO_STRING(__FILE__)+" line "+ModuleBase::GlobalFunc::TO_STRING(__LINE__)); - write(file, ptr, size); + auto error = write(file, ptr, size); + if(-1==error) throw std::runtime_error("can't write restart save file. \nerrno="+ModuleBase::GlobalFunc::TO_STRING(errno)+".\n"+ModuleBase::GlobalFunc::TO_STRING(__FILE__)+" line "+ModuleBase::GlobalFunc::TO_STRING(__LINE__) ); close(file); } @@ -32,7 +33,8 @@ void Restart::read_file2(const std::string &file_name, void*const ptr, const siz { const int file = open(file_name.c_str(), O_RDONLY); if(-1==file) throw std::runtime_error("can't open restart load file. \nerrno="+ModuleBase::GlobalFunc::TO_STRING(errno)+".\n"+ModuleBase::GlobalFunc::TO_STRING(__FILE__)+" line "+ModuleBase::GlobalFunc::TO_STRING(__LINE__)); - read(file, ptr, size); + auto error = read(file, ptr, size); + if(-1==error) throw std::runtime_error("can't read restart load file. \nerrno="+ModuleBase::GlobalFunc::TO_STRING(errno)+".\n"+ModuleBase::GlobalFunc::TO_STRING(__FILE__)+" line "+ModuleBase::GlobalFunc::TO_STRING(__LINE__)); close(file); } diff --git a/source/module_io/test/input_test.cpp b/source/module_io/test/input_test.cpp index 2bb481257c..24361d6f66 100644 --- a/source/module_io/test/input_test.cpp +++ b/source/module_io/test/input_test.cpp @@ -1456,7 +1456,7 @@ TEST_F(InputTest, Check) class ReadKSpacingTest : public ::testing::Test { protected: - void SetUp() + void SetUp() override { // create a temporary file for testing char tmpname[] = "tmpfile.tmp";