Skip to content

Commit eae7575

Browse files
authored
Fix: add exit 1 for shell UTs (#6122)
1 parent cb8a5ff commit eae7575

23 files changed

+96
-7
lines changed

source/module_base/test_parallel/blacs_connector_test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ do
1010
fi
1111
echo "TEST in parallel, nprocs=$i"
1212
mpirun -np $i ./blacs_connector
13+
if [[ $? -ne 0 ]]; then
14+
echo -e "\e[1;33m [ FAILED ] \e[0m"\
15+
"execute UT with $i cores error."
16+
exit 1
17+
fi
1318
break
1419
done
1520

source/module_base/test_parallel/parallel_2d_test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ for i in 2 3 4; do
99
fi
1010
echo "TEST in parallel, nprocs=$i"
1111
mpirun -np $i ./parallel_2d_test
12+
if [[ $? -ne 0 ]]; then
13+
echo -e "\e[1;33m [ FAILED ] \e[0m"\
14+
"execute UT with $i cores error."
15+
exit 1
16+
fi
1217
done

source/module_base/test_parallel/parallel_common_test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,10 @@ for i in 3;do
99
fi
1010
echo "TEST in parallel, nprocs=$i"
1111
mpirun -np $i ./base_ParaCommon
12+
if [[ $? -ne 0 ]]; then
13+
echo -e "\e[1;33m [ FAILED ] \e[0m"\
14+
"execute UT with $i cores error."
15+
exit 1
16+
fi
1217
break
1318
done

source/module_base/test_parallel/parallel_global_test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,10 @@ for i in 4;do
99
fi
1010
echo "TEST in parallel, nprocs=$i"
1111
mpirun -np $i ./base_ParaGlobal
12+
if [[ $? -ne 0 ]]; then
13+
echo -e "\e[1;33m [ FAILED ] \e[0m"\
14+
"execute UT with $i cores error."
15+
exit 1
16+
fi
1217
break
1318
done

source/module_base/test_parallel/parallel_reduce_test.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ TEST_F(ParaReduce, GatherIntAll)
240240
/// printf("post rank %d array[%d] = %d, min = %d \n",
241241
/// my_rank,i,array[i],min_number);
242242
}
243+
delete[] array;
243244
}
244245

245246
TEST_F(ParaReduce, GatherDoubleAll)
@@ -266,6 +267,7 @@ TEST_F(ParaReduce, GatherDoubleAll)
266267
/// printf("post rank %d array[%d] = %f, min = %f, max = %f \n",
267268
/// my_rank,i,array[i],min_number,max_number);
268269
}
270+
delete[] array;
269271
}
270272

271273
TEST_F(ParaReduce, ReduceIntDiag)
@@ -306,6 +308,7 @@ TEST_F(ParaReduce, ReduceIntDiag)
306308
/// my_rank,mpiContext.dsize,diag_sum_first, diag_sum_second);
307309
EXPECT_EQ(diag_sum_first, diag_sum_second);
308310
delete[] rand_array;
311+
delete[] swap;
309312
MPI_Comm_free(&DIAG_WORLD);
310313
}
311314
}
@@ -595,7 +598,7 @@ TEST_F(ParaReduce, GatherDoublePool)
595598
/// printf("post rank %d, pool rank %d, array[%d] = %f, min = %f, max = %f \n",
596599
/// my_rank,mpiContext.rank_in_pool,i,array[i],min_number,max_number);
597600
}
598-
601+
delete[] array;
599602
MPI_Comm_free(&POOL_WORLD);
600603
}
601604
}

source/module_base/test_parallel/parallel_reduce_test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,10 @@ for i in 4;do
99
fi
1010
echo "TEST in parallel, nprocs=$i"
1111
mpirun -np $i ./base_ParaReduce
12+
if [[ $? -ne 0 ]]; then
13+
echo -e "\e[1;33m [ FAILED ] \e[0m"\
14+
"execute UT with $i cores error."
15+
exit 1
16+
fi
1217
break
1318
done

source/module_basis/module_ao/test/parallel_orbitals_test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ for i in 2 3 4; do
99
fi
1010
echo "TEST in parallel, nprocs=$i"
1111
mpirun -np $i ./parallel_orbitals_test
12+
if [[ $? -ne 0 ]]; then
13+
echo -e "\e[1;33m [ FAILED ] \e[0m"\
14+
"execute UT with $i cores error."
15+
exit 1
16+
fi
1217
done

source/module_cell/test/atom_spec_test.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,15 @@ TEST_F(AtomSpecTest, BcastAtom)
146146
atom.mass = 12.0;
147147
atom.tau.resize(atom.na);
148148
atom.taud.resize(atom.na);
149+
atom.dis.resize(atom.na);
149150
atom.vel.resize(atom.na);
150151
atom.mag.resize(atom.na);
151152
atom.angle1.resize(atom.na);
152153
atom.angle2.resize(atom.na);
153154
atom.m_loc_.resize(atom.na);
154155
atom.mbl.resize(atom.na);
156+
atom.lambda.resize(atom.na);
157+
atom.constrain.resize(atom.na);
155158
atom.tau[0].x = 0.2;
156159
atom.tau[0].y = 0.2;
157160
atom.tau[0].z = 0.2;

source/module_cell/test/bcast_atom_pseudo_test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,10 @@ for i in 4;do
99
fi
1010
echo "TEST in parallel, nprocs=$i"
1111
mpirun -np $i ./cell_atom_pseudo
12+
if [[ $? -ne 0 ]]; then
13+
echo -e "\e[1;33m [ FAILED ] \e[0m"\
14+
"execute UT with $i cores error."
15+
exit 1
16+
fi
1217
break
1318
done

source/module_cell/test/bcast_atom_spec_test.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,10 @@ for i in 4;do
99
fi
1010
echo "TEST in parallel, nprocs=$i"
1111
mpirun -np $i ./cell_atom_spec
12+
if [[ $? -ne 0 ]]; then
13+
echo -e "\e[1;33m [ FAILED ] \e[0m"\
14+
"execute UT with $i cores error."
15+
exit 1
16+
fi
1217
break
1318
done

0 commit comments

Comments
 (0)