def test_hardware_predicate_comparison(): a = HardwarePredicate.FromISA((9, 0, 0)) b = HardwarePredicate.FromISA((9, 0, 6)) c = HardwarePredicate("TruePred") d = HardwarePredicate.FromHardware((9, 0, 8), 60) e = HardwarePredicate.FromHardware((9, 0, 8), 64) assert a < b assert a < c assert b < c assert d < a assert d < b assert d < c assert e < a assert e < b assert e < c assert e < d assert not b < a assert not c < a assert not c < b assert not a < e assert not b < e assert not c < e assert not d < e assert not a < a assert not b < b assert not c < c assert not d < d assert not e < e
def hardware_library_objects_dups(): objs = [ PredicateLibrary('Hardware', [{ 'predicate': HardwarePredicate.FromISA((9, 0, 0)), 'library': PredicateLibrary() }]), PredicateLibrary('Hardware', [{ 'predicate': HardwarePredicate.FromISA((9, 0, 6)), 'library': PredicateLibrary() }]), PredicateLibrary('Hardware', [{ 'predicate': HardwarePredicate.FromISA((9, 0, 6)), 'library': PredicateLibrary() }]), PredicateLibrary('Hardware', [{ 'predicate': HardwarePredicate.FromISA((9, 0, 8)), 'library': PredicateLibrary() }]), PredicateLibrary('Hardware', [{ 'predicate': HardwarePredicate('TruePred'), 'library': PredicateLibrary() }]) ] return [copy.deepcopy(libs) for libs in itertools.permutations(objs)]
def test_predicate_library_merge(libraries): lib = libraries[0] for lib2 in libraries[1:]: lib.merge(lib2) assert lib.rows[-1]['predicate'] == HardwarePredicate('TruePred') for r in lib.rows[:-1]: assert r['predicate'] != HardwarePredicate('TruePred')
def test_hardware_library_merge_order(libraries): lib = libraries[0] for lib2 in libraries[1:]: lib.merge(lib2) assert lib.rows[-1]['predicate'] == HardwarePredicate('TruePred') assert lib.rows[0]['predicate'] == HardwarePredicate.FromHardware( (9, 0, 8), 64) assert lib.rows[1]['predicate'] == HardwarePredicate.FromHardware( (9, 0, 8), 60) for r in lib.rows[:-1]: assert r['predicate'] != HardwarePredicate('TruePred')
def test_hardware_predicate_comparison(): a = HardwarePredicate.FromISA((9, 0, 0)) b = HardwarePredicate.FromISA((9, 0, 6)) c = HardwarePredicate("TruePred") assert a < b assert a < c assert b < c assert not b < a assert not c < a assert not c < b assert not a < a assert not b < b assert not c < c
def test_hardware_library_merge_dups(libraries): lib = libraries[0] for lib2 in libraries[1:]: lib.merge(lib2) assert len(lib.rows) == 4 def getPred(row): return row['predicate'] rowPreds = map(getPred, lib.rows) assert HardwarePredicate.FromISA((9, 0, 0)) in rowPreds assert HardwarePredicate.FromISA((9, 0, 6)) in rowPreds assert HardwarePredicate.FromISA((9, 0, 8)) in rowPreds assert HardwarePredicate('TruePred') in rowPreds
def hardware_library_objects_order(): objs = [ PredicateLibrary('Hardware', [{ 'predicate': HardwarePredicate.FromISA((9, 0, 0)) }]), PredicateLibrary('Hardware', [{ 'predicate': HardwarePredicate.FromISA((9, 0, 6)) }]), PredicateLibrary('Hardware', [{ 'predicate': HardwarePredicate.FromISA((9, 0, 8)) }]), PredicateLibrary('Hardware', [{ 'predicate': HardwarePredicate.FromISA((9, 0, 10)) }]), PredicateLibrary( 'Hardware', [{ 'predicate': HardwarePredicate.FromHardware((9, 0, 8), 60) }]), PredicateLibrary( 'Hardware', [{ 'predicate': HardwarePredicate.FromHardware((9, 0, 8), 64) }]), PredicateLibrary('Hardware', [{ 'predicate': HardwarePredicate('TruePred') }]) ] return [copy.deepcopy(libs) for libs in itertools.permutations(objs)]