Skip to content

Commit 0adf144

Browse files
fix(csr): use return value for assertion in test_list_csrs (#967)
Removes dependency on parsing stdout from "list csrs" command Signed-off-by: Ajit Dingankar <[email protected]>
1 parent 1ac5c6e commit 0adf144

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

tools/ruby-gems/udb/lib/udb/cli.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,12 @@ def csrs
272272
gen_path_override: Pathname.new(options[:gen])
273273
)
274274
cfg_arch = resolver.cfg_arch_for(cfg_file.realpath)
275+
count = 0
275276
cfg_arch.csrs.each do |csr|
276277
puts csr.name
278+
count += 1
277279
end
280+
count
278281
end
279282
end
280283
end

tools/ruby-gems/udb/test/test_cli.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,12 @@ def test_disasm
6565
end
6666

6767
def test_list_csrs
68-
out, err = capture_io do
69-
run_cmd("list csrs")
70-
end
71-
assert_empty err
68+
num_listed = run_cmd("list csrs")
69+
7270
repo_top = Udb.repo_root
7371
num_csr_yaml_files = `find #{repo_top}/spec/std/isa/csr/ -name '*.yaml' | wc -l`.to_i
74-
assert_equal num_csr_yaml_files, out.split.length
72+
73+
assert_equal num_csr_yaml_files, num_listed
7574
end
7675

7776
end

0 commit comments

Comments
 (0)