From ee9153666ab9e3900b588d9671f7ff42473a0325 Mon Sep 17 00:00:00 2001 From: Daniel Benusovich Date: Sat, 23 Feb 2019 12:49:45 -0800 Subject: [PATCH] Updating to use assert_eq and assert_ne --- TLB/test/test_cam_entry.py | 17 +++++++++++++---- TestUtil/test_helper.py | 17 +++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/TLB/test/test_cam_entry.py b/TLB/test/test_cam_entry.py index 07c09c48..4ffcb72f 100644 --- a/TLB/test/test_cam_entry.py +++ b/TLB/test/test_cam_entry.py @@ -4,7 +4,7 @@ sys.path.append("../../TestUtil") from nmigen.compat.sim import run_simulation -from test_helper import check +from test_helper import assert_eq, assert_ne from CamEntry import CamEntry # This function allows for the easy setting of values to the Cam Entry @@ -33,7 +33,10 @@ def set_cam_entry(dut, c, k, d): # op (Operation): (0 => ==), (1 => !=) def check_key(dut, k, op): out_k = yield dut.key - check("Key", out_k, k, op) + if op == 0: + assert_eq("Key", out_k, k) + else: + assert_ne("Key", out_k, k) # Checks the data state of the CAM entry # Arguments: @@ -42,7 +45,10 @@ def check_key(dut, k, op): # op (Operation): (0 => ==), (1 => !=) def check_data(dut, d, op): out_d = yield dut.data - check("Data", out_d, d, op) + if op == 0: + assert_eq("Data", out_d, d) + else: + assert_ne("Data", out_d, d) # Checks the match state of the CAM entry # Arguments: @@ -51,7 +57,10 @@ def check_data(dut, d, op): # op (Operation): (0 => ==), (1 => !=) def check_match(dut, m, op): out_m = yield dut.match - check("Match", out_m, m, op) + if op == 0: + assert_eq("Match", out_m, m) + else: + assert_ne("Match", out_m, m) # Checks the state of the CAM entry # Arguments: diff --git a/TestUtil/test_helper.py b/TestUtil/test_helper.py index 0d5329ca..5e60ab98 100644 --- a/TestUtil/test_helper.py +++ b/TestUtil/test_helper.py @@ -1,11 +1,16 @@ -# Verifies the given values via the requested operation +# Verifies the given values are equal # Arguments: # p (Prefix): Appended to the front of the assert statement # e (Expected): The expected value # o (Output): The output result # op (Operation): (0 => ==), (1 => !=) -def check(p, o, e, op): - if(op == 0): - assert o == e, p + " Output " + str(o) + " Expected " + str(e) - else: - assert o != e, p + " Output " + str(o) + " Not Expecting " + str(e) \ No newline at end of file +def assert_eq(p, o, e): + assert o == e, p + " Output " + str(o) + " Expected " + str(e) + +# Verifies the given values are not equal +# Arguments: +# p (Prefix): Appended to the front of the assert statement +# e (Expected): The expected value +# o (Output): The output result +def assert_ne(p, o, e): + assert o != e, p + " Output " + str(o) + " Not Expecting " + str(e) \ No newline at end of file -- 2.30.2