From add46cf73d7eb2492a0ff2ae288e6847aaee63bc Mon Sep 17 00:00:00 2001 From: tw-kang Date: Mon, 30 Dec 2024 17:22:46 +0900 Subject: [PATCH] [CUBRIDQA-1242] Add sort option on compare_result_between_files method (#692) * add sort option on compare_result_between_files method http://jira.cubrid.org/browse/CUBRIDQA-1242 Usage: compare_result_between_files file1 file2 [error | sort] --- CTP/shell/init_path/init.sh | 44 ++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/CTP/shell/init_path/init.sh b/CTP/shell/init_path/init.sh index 17043607..f57fd25d 100644 --- a/CTP/shell/init_path/init.sh +++ b/CTP/shell/init_path/init.sh @@ -335,7 +335,7 @@ function diff_ignore_lineno # After comparing two files, This function write the result int result files. # Usage: -# compare_result_between_files file1 file2 [error] +# compare_result_between_files file1 file2 [error|sort] function compare_result_between_files { @@ -374,18 +374,51 @@ function compare_result_between_files dos2unix $right echo "start to compare files: diff $left $right" - if [ "$3" = "error" ] + if [ "$3" = "error" ] && [ "$4" = "sort" ] || [ "$3" = "sort" ] && [ "$4" = "error" ] + then + sorted_left="${left}_sorted" + sorted_right="${right}_sorted" + sort $left > $sorted_left + sort $right > $sorted_right + + if diff_ignore_lineno $sorted_left $sorted_right -b + then + write_nok + echo "diff $sorted_left $sorted_right failed" >> $result_file + diff_ignore_lineno $sorted_left $sorted_right -y |tee -a $result_file + else + write_ok + fi + + rm -f $sorted_left $sorted_right + elif [ "$3" = "error" ] then if diff_ignore_lineno $left $right -b then write_nok echo "diff $left $right failed" >> $result_file - #diff $left $right -y >> $result_file - diff_ignore_lineno $left $right -y |tee -a $result_file + diff_ignore_lineno $left $right -y |tee -a $result_file else write_ok fi let "answer_no = answer_no + 1" + elif [ "$3" = "sort" ] + then + sorted_left="${left}_sorted" + sorted_right="${right}_sorted" + sort $left > $sorted_left + sort $right > $sorted_right + + if diff_ignore_lineno $sorted_left $sorted_right -b + then + write_ok + else + write_nok + echo "diff $sorted_left $sorted_right failed" >> $result_file + diff_ignore_lineno $sorted_left $sorted_right -y |tee -a $result_file + fi + + rm -f $sorted_left $sorted_right else if diff_ignore_lineno $left $right -b then @@ -393,8 +426,7 @@ function compare_result_between_files else write_nok echo "diff $left $right failed" >> $result_file - #diff $left $right -y >> $result_file - diff_ignore_lineno $left $right -y |tee -a $result_file + diff_ignore_lineno $left $right -y |tee -a $result_file fi let "answer_no = answer_no + 1" fi