From 1bc2ab0bcc841e04b515217986ce0935d020abcf Mon Sep 17 00:00:00 2001 From: jumao Date: Mon, 22 Apr 2024 20:31:48 -0400 Subject: [PATCH] Revert "[VOQ][saidump] Add saidump unit test scripts #3079" This reverts commit 132209547a0366762bf044509baadfc216297035. --- tests/saidump_test.py | 56 ------------------------------------------- tests/saidump_test.sh | 41 ------------------------------- 2 files changed, 97 deletions(-) delete mode 100755 tests/saidump_test.py delete mode 100755 tests/saidump_test.sh diff --git a/tests/saidump_test.py b/tests/saidump_test.py deleted file mode 100755 index 2ee6fb2da1..0000000000 --- a/tests/saidump_test.py +++ /dev/null @@ -1,56 +0,0 @@ -import os -import subprocess - -GENERATE_DUMP_FILE = "/tmp/generate_dump_tmp" - -test_path = os.path.dirname(os.path.abspath(__file__)) -modules_path = os.path.dirname(test_path) -scripts_path = os.path.join(modules_path, "scripts") - - -def run_saidump(asic_num, route_num): - result = subprocess.run([". " + test_path + "/saidump_test.sh && test_saidump " + str(asic_num) + - " " + str(route_num)], capture_output=True, text=True, shell=True, executable='/bin/bash') - return result.stdout.strip() - - -# saidump test list format: [ACIS number, ipv4 and ipv6 route table size, expected function save_cmd arguments] -saidump_test_list = [ - [1, 10000, "docker exec syncd saidump saidump"], - [1, 12000, "docker exec syncd saidump saidump"], - [1, 12001, "docker exec syncd saidump.sh saidump"], - [1, 20000, "docker exec syncd saidump.sh saidump"], - [2, 10000, "docker exec syncd0 saidump saidump0\ndocker exec syncd1 saidump saidump1"], - [2, 12000, "docker exec syncd0 saidump saidump0\ndocker exec syncd1 saidump saidump1"], - [2, 12001, "docker exec syncd0 saidump.sh saidump0\ndocker exec syncd1 saidump.sh saidump1"], - [2, 20000, "docker exec syncd0 saidump.sh saidump0\ndocker exec syncd1 saidump.sh saidump1"] -] - - -def shell_pre_process(in_file, out_file): - buf = [] - - with open(in_file, 'r') as file: - lines = file.readlines() - - for line in lines: - if line.strip().startswith("while getopts"): - break - else: - buf.append(line) - - # Write the modified content back to the file - with open(out_file, 'w') as file: - file.writelines(buf) - - -def test_saidump(): - # preprocess the generate_dump to a new script without non-functional codes - shell_pre_process(scripts_path + '/generate_dump', GENERATE_DUMP_FILE) - - for item in saidump_test_list: - output = run_saidump(item[0], item[1]) - assert output == item[2] - - if os.path.exists(GENERATE_DUMP_FILE): - os.remove(GENERATE_DUMP_FILE) diff --git a/tests/saidump_test.sh b/tests/saidump_test.sh deleted file mode 100755 index 429c300279..0000000000 --- a/tests/saidump_test.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -GENERATE_DUMP_FILE="/tmp/generate_dump_tmp" -ROUTE_FILE="/tmp/route_summary.txt" -shopt -s expand_aliases -alias eval="mock_eval" -alias save_cmd="mock_save_cmd" - -source $GENERATE_DUMP_FILE - -mock_route_summary(){ - local routenum=$1 - echo "\ - { - \"routesTotal\":$routenum - }" > $ROUTE_FILE -} - -route_num=0 -save_cmd_arguments="" - -# Mock eval command in function get_route_table_size_by_asic_id_and_ipver -mock_eval(){ - mock_route_summary $route_num -} - -# Mock function save_cmd called in function save_saidump_by_route_size -mock_save_cmd(){ - save_cmd_arguments="$save_cmd_arguments$*\n" -} - -test_saidump(){ - NUM_ASICS=$1 - route_num=$2 - save_saidump_by_route_size > /dev/null - echo -e $save_cmd_arguments - local ret=$save_cmd_arguments - save_cmd_arguments="" - rm $ROUTE_FILE - return $ret -} \ No newline at end of file