microsoft/onnxruntime-extensions
Publicmirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable
test/test_cmake_helper.py
29lines · modecode
| 1 | import os |
| 2 | import unittest |
| 3 | from pathlib import Path |
| 4 | from onnxruntime_extensions import cmake_helper |
| 5 | |
| 6 | |
| 7 | def _get_test_data_file(*sub_dirs): |
| 8 | test_dir = Path(__file__).parent |
| 9 | return str(test_dir.joinpath(*sub_dirs)) |
| 10 | |
| 11 | |
| 12 | class TestCMakeHelper(unittest.TestCase): |
| 13 | def test_cmake_file_gen(self): |
| 14 | cfgfile = _get_test_data_file('data', 'test.op.config') |
| 15 | cfile = '_selectedoplist.cmake' |
| 16 | cmake_helper.gen_cmake_oplist(cfgfile, cfile) |
| 17 | found = False |
| 18 | with open(cfile, 'r') as f: |
| 19 | for _ln in f: |
| 20 | if _ln.strip() == "set(OCOS_ENABLE_GPT2_TOKENIZER ON CACHE INTERNAL \"\")": |
| 21 | found = True |
| 22 | break |
| 23 | |
| 24 | os.remove(cfile) |
| 25 | self.assertTrue(found) |
| 26 | |
| 27 | |
| 28 | if __name__ == "__main__": |
| 29 | unittest.main() |
| 30 | |