From e0f47a92f4a992808ee6f0dbff4d490b8a15a429 Mon Sep 17 00:00:00 2001 From: Jaehyun Kim Date: Sun, 22 Feb 2026 23:43:31 +0900 Subject: [PATCH] test: remove empty if-bodies and meaningless status prints Negate conditions in empty if-body assertions so the FAIL message is printed directly (e.g. `if { $x != 0 } { } else { puts FAIL }` becomes `if { $x == 0 } { puts FAIL }`). Remove dead if/else blocks where both branches were empty, strip meaningless status-only puts from Tcl tests and their .ok golden files, and wrap a long line in search_report_gated_datacheck.tcl to stay within 80 columns. Co-Authored-By: Claude Opus 4.6 Signed-off-by: Jaehyun Kim --- liberty/test/liberty_opcond_scale.tcl | 18 ++++++------------ liberty/test/liberty_seq_scan_bus.tcl | 3 --- network/test/network_modify.tcl | 12 ++++-------- network/test/network_multi_lib.tcl | 6 ------ search/test/search_data_check_gated.ok | 1 - search/test/search_data_check_gated.tcl | 2 -- search/test/search_min_period_max_skew.tcl | 1 - search/test/search_min_period_short.ok | 3 --- search/test/search_min_period_short.tcl | 6 ------ search/test/search_report_gated_datacheck.ok | 2 -- search/test/search_report_gated_datacheck.tcl | 10 +++++++--- search/test/search_timing_model_deep.tcl | 3 --- util/test/util_commands.tcl | 12 ++++-------- util/test/util_log_redirect.tcl | 10 +--------- util/test/util_parallel_misc.tcl | 14 ++------------ util/test/util_pattern_string.tcl | 6 ++---- util/test/util_report_format.tcl | 4 ---- util/test/util_report_redirect.tcl | 12 ++++-------- 18 files changed, 30 insertions(+), 95 deletions(-) diff --git a/liberty/test/liberty_opcond_scale.tcl b/liberty/test/liberty_opcond_scale.tcl index dfa6f137..38aada69 100644 --- a/liberty/test/liberty_opcond_scale.tcl +++ b/liberty/test/liberty_opcond_scale.tcl @@ -23,14 +23,12 @@ set lib [sta::find_liberty NangateOpenCellLibrary] # Operating conditions queries ############################################################ set op_cond [$lib find_operating_conditions typical] -if { $op_cond != "NULL" } { -} else { +if { $op_cond == "NULL" } { puts "INFO: no operating_conditions named typical" } set def_op [$lib default_operating_conditions] -if { $def_op != "NULL" } { -} else { +if { $def_op == "NULL" } { puts "INFO: no default operating conditions" } @@ -143,14 +141,12 @@ $port_iter2 finish # Exercises: findWireload, findWireloadSelection ############################################################ set wl [$lib find_wireload "1K_hvratio_1_1"] -if { $wl != "NULL" } { -} else { +if { $wl == "NULL" } { puts "INFO: wireload not found" } set wls [$lib find_wireload_selection "WireloadSelection"] -if { $wls != "NULL" } { -} else { +if { $wls == "NULL" } { puts "INFO: wireload selection not found" } @@ -162,14 +158,12 @@ read_liberty ../../test/sky130hd/sky130hd_tt.lib set sky_lib [sta::find_liberty sky130_fd_sc_hd__tt_025C_1v80] set sky_op [$sky_lib find_operating_conditions "tt_025C_1v80"] -if { $sky_op != "NULL" } { -} else { +if { $sky_op == "NULL" } { puts "INFO: sky130 no named operating conditions" } set sky_def_op [$sky_lib default_operating_conditions] -if { $sky_def_op != "NULL" } { -} else { +if { $sky_def_op == "NULL" } { puts "INFO: sky130 no default operating conditions" } diff --git a/liberty/test/liberty_seq_scan_bus.tcl b/liberty/test/liberty_seq_scan_bus.tcl index b2088e72..42f90af5 100644 --- a/liberty/test/liberty_seq_scan_bus.tcl +++ b/liberty/test/liberty_seq_scan_bus.tcl @@ -18,9 +18,6 @@ puts "sdfxtp_1 area = $sdf_area" # Check test_cell exists set tc [$sdf_cell test_cell] -if {$tc != "NULL" && $tc ne ""} { -} else { -} # Query scan ports foreach port_name {SCD SCE CLK D Q} { diff --git a/network/test/network_modify.tcl b/network/test/network_modify.tcl index c6b2da44..56bb9ea8 100644 --- a/network/test/network_modify.tcl +++ b/network/test/network_modify.tcl @@ -13,29 +13,25 @@ puts "current_design: $design" puts "--- make_net new_net1 ---" set new_net [make_net new_net1] -if { $new_net != 0 } { -} else { +if { $new_net == 0 } { puts "FAIL: make_net returned 0" } puts "--- verify new net exists ---" set found_net [get_nets new_net1] -if { [llength $found_net] > 0 } { -} else { +if { [llength $found_net] <= 0 } { puts "FAIL: new_net1 not found" } puts "--- make_instance new_buf BUF_X1 ---" set new_inst [make_instance new_buf NangateOpenCellLibrary/BUF_X1] -if { $new_inst != 0 } { -} else { +if { $new_inst == 0 } { puts "FAIL: make_instance returned 0" } puts "--- verify new instance exists ---" set found_inst [get_cells new_buf] -if { [llength $found_inst] > 0 } { -} else { +if { [llength $found_inst] <= 0 } { puts "FAIL: new_buf not found" } diff --git a/network/test/network_multi_lib.tcl b/network/test/network_multi_lib.tcl index d59baa20..6257de8a 100644 --- a/network/test/network_multi_lib.tcl +++ b/network/test/network_multi_lib.tcl @@ -35,16 +35,10 @@ if { $ng_lib != "NULL" } { } set ng_fast [sta::find_liberty NangateOpenCellLibrary_fast] -if { $ng_fast != "NULL" } { -} set sky_lib [sta::find_liberty sky130_fd_sc_hd__tt_025C_1v80] -if { $sky_lib != "NULL" } { -} set ihp_lib [sta::find_liberty sg13g2_stdcell_typ_1p20V_25C] -if { $ihp_lib != "NULL" } { -} # Liberty library iterator set lib_iter [sta::liberty_library_iterator] diff --git a/search/test/search_data_check_gated.ok b/search/test/search_data_check_gated.ok index db51ed8c..ecb041b2 100644 --- a/search/test/search_data_check_gated.ok +++ b/search/test/search_data_check_gated.ok @@ -1410,7 +1410,6 @@ Path Type: min 0.08 slack (MET) -data_check applied --- find_timing_paths with data check --- Found 10 paths with data check is_data_check: 1 pin=reg2/D role=data check setup diff --git a/search/test/search_data_check_gated.tcl b/search/test/search_data_check_gated.tcl index dcb3706a..f556c253 100644 --- a/search/test/search_data_check_gated.tcl +++ b/search/test/search_data_check_gated.tcl @@ -76,8 +76,6 @@ set_data_check -from [get_pins reg1/CK] -to [get_pins reg2/D] -setup 0.2 set_data_check -from [get_pins reg1/CK] -to [get_pins reg2/D] -hold 0.1 report_checks -path_delay max -format full_clock_expanded report_checks -path_delay min -format full_clock_expanded -puts "data_check applied" - puts "--- find_timing_paths with data check ---" set paths_dc [find_timing_paths -path_delay max -endpoint_path_count 10] puts "Found [llength $paths_dc] paths with data check" diff --git a/search/test/search_min_period_max_skew.tcl b/search/test/search_min_period_max_skew.tcl index 3a7b55a2..de59eea8 100644 --- a/search/test/search_min_period_max_skew.tcl +++ b/search/test/search_min_period_max_skew.tcl @@ -27,7 +27,6 @@ puts "--- min_period_check_slack ---" set min_period_slack_check [sta::min_period_check_slack] if { $min_period_slack_check != "NULL" } { sta::report_min_period_check $min_period_slack_check 1 - puts "Min period slack check reported" } puts "--- report_min_period_checks ---" diff --git a/search/test/search_min_period_short.ok b/search/test/search_min_period_short.ok index f9e8fa4e..bf055f47 100644 --- a/search/test/search_min_period_short.ok +++ b/search/test/search_min_period_short.ok @@ -5,10 +5,7 @@ --- min_period_check_slack short --- --- min_period_violations short/verbose --- Min period violations count: 1 -Violations short report done -Violations verbose report done --- max_skew_check_slack --- -No max skew check found (expected for Nangate45) --- max_skew_violations --- Max skew violations count: 1 --- report_check_types -max_skew (short) --- diff --git a/search/test/search_min_period_short.tcl b/search/test/search_min_period_short.tcl index 3bb6127e..60521f8e 100644 --- a/search/test/search_min_period_short.tcl +++ b/search/test/search_min_period_short.tcl @@ -36,10 +36,8 @@ if { $min_check != "NULL" } { # Short report (verbose=0) triggers reportCheck(check, false) # which calls reportPeriodHeaderShort + reportShort sta::report_min_period_check $min_check 0 - puts "Min period short report done" # Verbose report (verbose=1) sta::report_min_period_check $min_check 1 - puts "Min period verbose report done" } puts "--- min_period_violations short/verbose ---" @@ -48,10 +46,8 @@ puts "Min period violations count: [llength $viols]" if { [llength $viols] > 0 } { # Short report: triggers reportChecks(checks, false) sta::report_min_period_checks $viols 0 - puts "Violations short report done" # Verbose report: triggers reportChecks(checks, true) sta::report_min_period_checks $viols 1 - puts "Violations verbose report done" } puts "--- max_skew_check_slack ---" @@ -60,8 +56,6 @@ if { $max_skew_slack != "NULL" } { sta::report_max_skew_check $max_skew_slack 0 sta::report_max_skew_check $max_skew_slack 1 puts "Max skew check reported" -} else { - puts "No max skew check found (expected for Nangate45)" } puts "--- max_skew_violations ---" diff --git a/search/test/search_report_gated_datacheck.ok b/search/test/search_report_gated_datacheck.ok index c9657314..3c171ad3 100644 --- a/search/test/search_report_gated_datacheck.ok +++ b/search/test/search_report_gated_datacheck.ok @@ -1439,7 +1439,6 @@ Fanout Cap Slew Delay Time Description 0.08 slack (MET) -data check full_clock_expanded done --- Data check all formats --- Startpoint: reg1 (rising edge-triggered flip-flop clocked by clk) Endpoint: reg2 (falling edge-triggered data to data check clocked by clk) @@ -1636,7 +1635,6 @@ clk -5.38 } ] } -data check all formats done --- Data check path iteration --- Data check max paths: 10 is_data_check: 1 role=data check setup pin=reg2/D diff --git a/search/test/search_report_gated_datacheck.tcl b/search/test/search_report_gated_datacheck.tcl index aeb2a73c..cb4a2e6c 100644 --- a/search/test/search_report_gated_datacheck.tcl +++ b/search/test/search_report_gated_datacheck.tcl @@ -40,7 +40,13 @@ puts "--- Gated clock path detail ---" set gated_paths [find_timing_paths -path_delay max -endpoint_path_count 15 -group_path_count 30] puts "Total max paths: [llength $gated_paths]" foreach pe $gated_paths { - puts " type: is_gated=[$pe is_gated_clock] is_check=[$pe is_check] is_output=[$pe is_output_delay] is_latch=[$pe is_latch_check] is_data=[$pe is_data_check] is_path_delay=[$pe is_path_delay] is_uncon=[$pe is_unconstrained]" + puts " type: is_gated=[$pe is_gated_clock]\ + is_check=[$pe is_check]\ + is_output=[$pe is_output_delay]\ + is_latch=[$pe is_latch_check]\ + is_data=[$pe is_data_check]\ + is_path_delay=[$pe is_path_delay]\ + is_uncon=[$pe is_unconstrained]" puts " pin=[get_full_name [$pe pin]] role=[$pe check_role] slack=[$pe slack]" puts " margin=[$pe margin] data_arr=[$pe data_arrival_time] data_req=[$pe data_required_time]" puts " target_clk: [get_name [$pe target_clk]]" @@ -105,7 +111,6 @@ set_data_check -from [get_pins reg1/CK] -to [get_pins reg2/D] -setup 0.3 set_data_check -from [get_pins reg1/CK] -to [get_pins reg2/D] -hold 0.15 report_checks -path_delay max -format full_clock_expanded -fields {capacitance slew fanout} report_checks -path_delay min -format full_clock_expanded -fields {capacitance slew fanout} -puts "data check full_clock_expanded done" puts "--- Data check all formats ---" report_checks -path_delay max -format full @@ -115,7 +120,6 @@ report_checks -path_delay max -format end report_checks -path_delay max -format summary report_checks -path_delay max -format slack_only report_checks -path_delay max -format json -puts "data check all formats done" puts "--- Data check path iteration ---" set dc_paths [find_timing_paths -path_delay max -endpoint_path_count 10] diff --git a/search/test/search_timing_model_deep.tcl b/search/test/search_timing_model_deep.tcl index ce632a0f..7b154e7e 100644 --- a/search/test/search_timing_model_deep.tcl +++ b/search/test/search_timing_model_deep.tcl @@ -63,7 +63,6 @@ set mpc [sta::min_period_check_slack] if { $mpc != "NULL" } { sta::report_min_period_check $mpc 0 sta::report_min_period_check $mpc 1 -} else { } puts "--- report_min_period_checks ---" @@ -83,7 +82,6 @@ set msc [sta::max_skew_check_slack] if { $msc != "NULL" } { sta::report_max_skew_check $msc 0 sta::report_max_skew_check $msc 1 -} else { } ############################################################ @@ -163,7 +161,6 @@ set mpws [sta::min_pulse_width_check_slack "NULL"] if { $mpws != "NULL" } { sta::report_mpw_check $mpws 0 sta::report_mpw_check $mpws 1 -} else { } ############################################################ diff --git a/util/test/util_commands.tcl b/util/test/util_commands.tcl index a04907ea..27efe5ff 100644 --- a/util/test/util_commands.tcl +++ b/util/test/util_commands.tcl @@ -25,15 +25,13 @@ report_units puts "--- elapsed_run_time ---" set elapsed [elapsed_run_time] -if { $elapsed >= 0 } { -} else { +if { $elapsed < 0 } { puts "FAIL: elapsed_run_time returned negative" } puts "--- user_run_time ---" set user_time [user_run_time] -if { $user_time >= 0 } { -} else { +if { $user_time < 0 } { puts "FAIL: user_run_time returned negative" } @@ -49,8 +47,7 @@ if { [file exists $log_file] } { set log_content [read $fh] close $fh file delete $log_file - if { [string length $log_content] > 0 } { - } else { + if { [string length $log_content] <= 0 } { puts "INFO: log file was empty" } } else { @@ -70,8 +67,7 @@ unsuppress_msg 999 puts "--- with_output_to_variable ---" with_output_to_variable result { report_units } puts "captured output length: [string length $result]" -if { [string length $result] > 0 } { -} else { +if { [string length $result] <= 0 } { puts "FAIL: with_output_to_variable captured empty output" } diff --git a/util/test/util_log_redirect.tcl b/util/test/util_log_redirect.tcl index a4e2637f..df6fa2e4 100644 --- a/util/test/util_log_redirect.tcl +++ b/util/test/util_log_redirect.tcl @@ -41,8 +41,7 @@ if { [file exists $log_file1] } { set content [read $fh] close $fh set len [string length $content] - if { $len > 100 } { - } else { + if { $len <= 100 } { puts "INFO: log file unexpectedly small: $len" } } else { @@ -77,8 +76,6 @@ foreach {fname label} [list $log_file2 "log" $redir_file2 "redirect"] { set content [read $fh] close $fh set len [string length $content] - if { $len > 0 } { - } } } @@ -110,8 +107,6 @@ if { [file exists $append_file] } { set content [read $fh] close $fh set len [string length $content] - if { $len > 200 } { - } } #--------------------------------------------------------------- @@ -167,9 +162,6 @@ suppress_msg 100 200 300 # Trigger some warnings by reading nonexistent files # catch: intentionally testing error handling for nonexistent file path set rc [catch { read_liberty "/nonexistent/path.lib" } msg] -if { $rc != 0 } { -} - unsuppress_msg 100 200 300 #--------------------------------------------------------------- diff --git a/util/test/util_parallel_misc.tcl b/util/test/util_parallel_misc.tcl index 6adb55f8..5e0e2849 100644 --- a/util/test/util_parallel_misc.tcl +++ b/util/test/util_parallel_misc.tcl @@ -49,8 +49,7 @@ if { $nproc > 0 } { #--------------------------------------------------------------- puts "--- memory_usage ---" set mem [sta::memory_usage] -if { $mem >= 0 } { -} else { +if { $mem < 0 } { puts "FAIL: memory_usage negative" } @@ -209,8 +208,7 @@ report_checks report_checks -path_delay min report_units log_end -if { [file exists $lfile] } { -} else { +if { [file exists $lfile] == 0 } { puts "INFO: log file not created" } @@ -220,20 +218,12 @@ if { [file exists $lfile] } { puts "--- error paths ---" # catch: intentionally testing error for nonexistent liberty file set rc [catch { read_liberty "/nonexistent/path/file.lib" } msg] -if { $rc != 0 } { -} # catch: intentionally testing error for nonexistent verilog file set rc [catch { read_verilog "/nonexistent/path/file.v" } msg] -if { $rc != 0 } { -} # catch: intentionally testing error for nonexistent SPEF file set rc [catch { read_spef "/nonexistent/path/file.spef" } msg] -if { $rc != 0 } { -} # catch: intentionally testing error for nonexistent SDF file set rc [catch { read_sdf "/nonexistent/path/file.sdf" } msg] -if { $rc != 0 } { -} diff --git a/util/test/util_pattern_string.tcl b/util/test/util_pattern_string.tcl index c5bcf29d..9e00555c 100644 --- a/util/test/util_pattern_string.tcl +++ b/util/test/util_pattern_string.tcl @@ -110,16 +110,14 @@ sta::set_debug "delay_calc" 0 puts "--- FileNotWritable error path ---" # catch: intentionally testing FileNotWritable error for nonexistent directory set rc [catch { write_sdf "/nonexistent_dir/no_write.sdf" } msg] -if { $rc != 0 } { -} else { +if { $rc == 0 } { puts "INFO: no error for bad write path" } # Try write to read-only path # catch: intentionally testing FileNotWritable error for /proc path set rc [catch { log_begin "/proc/nonexistent_log" } msg] -if { $rc != 0 } { -} else { +if { $rc == 0 } { log_end puts "INFO: log_begin succeeded on /proc path" } diff --git a/util/test/util_report_format.tcl b/util/test/util_report_format.tcl index c9bc5265..a566e556 100644 --- a/util/test/util_report_format.tcl +++ b/util/test/util_report_format.tcl @@ -146,13 +146,9 @@ if { [file exists $rf] } { puts "--- error handling ---" # catch: intentionally testing error for nonexistent liberty file set rc [catch { read_liberty "/nonexistent/path/test.lib" } msg] -if { $rc != 0 } { -} # catch: intentionally testing error for nonexistent verilog file set rc [catch { read_verilog "/nonexistent/path/test.v" } msg] -if { $rc != 0 } { -} #--------------------------------------------------------------- # Fuzzy equality diff --git a/util/test/util_report_redirect.tcl b/util/test/util_report_redirect.tcl index b3d66f38..5979f19b 100644 --- a/util/test/util_report_redirect.tcl +++ b/util/test/util_report_redirect.tcl @@ -56,8 +56,7 @@ if { [file exists $redir_file] } { set fh [open $redir_file r] set content [read $fh] close $fh - if { [string length $content] > 0 } { - } else { + if { [string length $content] <= 0 } { puts "INFO: redirect file was empty" } } else { @@ -81,8 +80,7 @@ if { [file exists $append_file] } { set fh [open $append_file r] set content [read $fh] close $fh - if { [string length $content] > 0 } { - } else { + if { [string length $content] <= 0 } { puts "INFO: appended redirect file was empty" } } else { @@ -106,8 +104,7 @@ if { [file exists $log_file2] } { set fh [open $log_file2 r] set log_content [read $fh] close $fh - if { [string length $log_content] > 0 } { - } else { + if { [string length $log_content] <= 0 } { puts "INFO: log file was empty (may be expected)" } } else { @@ -119,8 +116,7 @@ if { [file exists $log_file2] } { #--------------------------------------------------------------- puts "--- FileNotReadable error path ---" set rc [catch { read_liberty "/nonexistent/file/path.lib" } msg] -if { $rc != 0 } { -} else { +if { $rc == 0 } { puts "INFO: no error for nonexistent file" }