Skip to content

Commit 0709bf8

Browse files
committed
Test: Add a unit test for of_ml_gene_data, and update Autotest.sh
1 parent 5b0cc49 commit 0709bf8

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

source/source_io/module_parameter/read_input_item_ofdft.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ Note: Even dimensions may cause slight errors in FFT. It should be ignorable in
389389
ModuleBase::WARNING_QUIT(
390390
"ReadInput",
391391
"of_ml_gene_data is only available for KSDFT with PW basis on a single MPI rank (NPROC = 1)");
392+
}
392393
};
393394
read_sync_bool(input.of_ml_gene_data);
394395
this->add_item(item);

source/source_io/test_serial/read_input_item_test.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,36 @@ TEST_F(InputTest, Item_test2)
15281528
it->second.reset_value(it->second, param);
15291529
EXPECT_EQ(param.input.of_read_kernel, false);
15301530
}
1531+
{ // of_ml_gene_data
1532+
auto it = find_label("of_ml_gene_data", readinput.input_lists);
1533+
1534+
param.input.of_ml_gene_data = true;
1535+
param.input.esolver_type = "ofdft";
1536+
param.input.basis_type = "pw";
1537+
GlobalV::NPROC = 1;
1538+
testing::internal::CaptureStdout();
1539+
EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(1), "");
1540+
output = testing::internal::GetCapturedStdout();
1541+
EXPECT_THAT(output, testing::HasSubstr("NOTICE"));
1542+
1543+
param.input.of_ml_gene_data = true;
1544+
param.input.esolver_type = "ksdft";
1545+
param.input.basis_type = "lcao";
1546+
GlobalV::NPROC = 1;
1547+
testing::internal::CaptureStdout();
1548+
EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(1), "");
1549+
output = testing::internal::GetCapturedStdout();
1550+
EXPECT_THAT(output, testing::HasSubstr("NOTICE"));
1551+
1552+
param.input.of_ml_gene_data = true;
1553+
param.input.esolver_type = "ksdft";
1554+
param.input.basis_type = "pw";
1555+
GlobalV::NPROC = 2;
1556+
testing::internal::CaptureStdout();
1557+
EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(1), "");
1558+
output = testing::internal::GetCapturedStdout();
1559+
EXPECT_THAT(output, testing::HasSubstr("NOTICE"));
1560+
}
15311561
{ // dft_plus_u
15321562
auto it = find_label("dft_plus_u", readinput.input_lists);
15331563
param.input.dft_plus_u = 1;

tests/integrate/Autotest.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ get_threshold()
211211
default_value=$3
212212
if [ -e $threshold_f ]; then
213213
threshold_value=$(awk -v tn="$threshold_name" '$1==tn {print $2}' "$threshold_f")
214-
if [ -n "$threshold_value" ]; then
214+
if [ -n "$threshold_value" ]; then
215215
echo $threshold_value
216216
else
217217
echo $default_value
@@ -291,7 +291,8 @@ for dir in $testdir; do
291291
my_force_threshold=$(get_threshold $threshold_file "force_threshold" $force_threshold)
292292
my_stress_threshold=$(get_threshold $threshold_file "stress_threshold" $stress_threshold)
293293
my_fatal_threshold=$(get_threshold $threshold_file "fatal_threshold" $fatal_threshold)
294-
check_out result.out $my_threshold $my_force_threshold $my_stress_threshold $my_fatal_threshold $descriptor_threshold
294+
my_descriptor_threshold=$(get_threshold $threshold_file "descriptor_threshold" $descriptor_threshold)
295+
check_out result.out $my_threshold $my_force_threshold $my_stress_threshold $my_fatal_threshold $my_descriptor_threshold
295296
fi
296297
else
297298
bash -e ../../integrate/tools/catch_properties.sh result.ref

0 commit comments

Comments
 (0)