Refactor path arguments to tosa-tools

tosa_verif_conformance_generator
- Move to using ref-model-path instead of ref-model-dir
- Add schema-path and flatc-path
- Add model_files module to locate default places for files
convert2conformance
- Remove default paths
verifier
- Switch to using exact path of verifier library
tosa_verif_run_tests
- Use conformance model_files to locate defaults

Change-Id: Ieca3b164670e2a7dcb047743667cc4e8317daa97
Signed-off-by: Josef Malmström <josef.malmstrom@arm.com>
Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com>
diff --git a/verif/runner/tosa_refmodel_sut_run.py b/verif/runner/tosa_refmodel_sut_run.py
index 7b129da..419f87b 100644
--- a/verif/runner/tosa_refmodel_sut_run.py
+++ b/verif/runner/tosa_refmodel_sut_run.py
@@ -1,5 +1,5 @@
 """TOSA test runner module for the Reference Model."""
-# Copyright (c) 2020-2022, ARM Limited.
+# Copyright (c) 2020-2023, ARM Limited.
 # SPDX-License-Identifier: Apache-2.0
 from enum import IntEnum
 from enum import unique
@@ -33,10 +33,10 @@
 
         # Call Reference model with description file to provide all file details
         cmd = [
-            args.ref_model_path,
-            "--tosa_level={}".format(args.tosa_level),
-            "--operator_fbs={}".format(args.operator_fbs),
-            "--test_desc={}".format(self.descFile),
+            str(args.ref_model_path),
+            f"--tosa_level={args.tosa_level}",
+            f"--operator_fbs={str(args.schema_path)}",
+            f"--test_desc={self.descFile}",
         ]
 
         # Specific debug options for reference model
diff --git a/verif/runner/tosa_test_runner.py b/verif/runner/tosa_test_runner.py
index d8c2a87..579dd60 100644
--- a/verif/runner/tosa_test_runner.py
+++ b/verif/runner/tosa_test_runner.py
@@ -1,9 +1,8 @@
 """Template test runner class for running TOSA tests."""
-# Copyright (c) 2020-2022, ARM Limited.
+# Copyright (c) 2020-2023, ARM Limited.
 # SPDX-License-Identifier: Apache-2.0
 import json
 from enum import IntEnum
-from pathlib import Path
 
 from checker.tosa_result_checker import LogColors
 from checker.tosa_result_checker import print_color
@@ -62,8 +61,8 @@
         if args.binary and tosaFilePath.suffix == ".json":
             # Convert tosa JSON to binary
             json2fbbin.json_to_fbbin(
-                Path(args.flatc_path),
-                Path(args.operator_fbs),
+                args.flatc_path,
+                args.schema_path,
                 tosaFilePath,
                 testDirPath,
             )
diff --git a/verif/runner/tosa_verif_run_tests.py b/verif/runner/tosa_verif_run_tests.py
index 814c864..722c0e7 100644
--- a/verif/runner/tosa_verif_run_tests.py
+++ b/verif/runner/tosa_verif_run_tests.py
@@ -1,5 +1,5 @@
 """TOSA verification runner script."""
-# Copyright (c) 2020-2022, ARM Limited.
+# Copyright (c) 2020-2023, ARM Limited.
 # SPDX-License-Identifier: Apache-2.0
 import argparse
 import importlib
@@ -10,6 +10,7 @@
 from datetime import datetime
 from pathlib import Path
 
+import conformance.model_files as cmf
 from json2numpy import json2numpy
 from runner.tosa_test_runner import TosaTestInvalid
 from runner.tosa_test_runner import TosaTestRunner
@@ -46,25 +47,29 @@
         help="Recursively search for tests",
     )
     parser.add_argument(
-        "--operator-fbs",
-        dest="operator_fbs",
-        default="conformance_tests/third_party/serialization_lib/schema/tosa.fbs",
-        type=str,
-        help="flat buffer syntax file",
-    )
-    parser.add_argument(
         "--ref-model-path",
         dest="ref_model_path",
-        default="reference_model/build/reference_model/tosa_reference_model",
-        type=str,
-        help="Path to reference model executable",
+        type=Path,
+        help="Path to TOSA reference model executable",
+    )
+    parser.add_argument(
+        "--operator-fbs",
+        "--schema-path",
+        dest="schema_path",
+        type=Path,
+        help=(
+            "Path to TOSA reference model flat buffer schema. Defaults to "
+            f"`{cmf.DEFAULT_REF_MODEL_SCHEMA_PATH}` in parents parent directory of `ref-model-path`"
+        ),
     )
     parser.add_argument(
         "--flatc-path",
         dest="flatc_path",
-        default="reference_model/build/thirdparty/serialization_lib/third_party/flatbuffers/flatc",
-        type=str,
-        help="Path to flatc compiler executable",
+        type=Path,
+        help=(
+            "Path to flatc executable. Defaults to "
+            f"`{cmf.DEFAULT_REF_MODEL_BUILD_FLATC_PATH}` in parent directory of `ref-model-path`"
+        ),
     )
     parser.add_argument(
         "--ref-debug",
@@ -339,13 +344,22 @@
     """Start worker threads to do the testing and outputs the results."""
     args = parseArgs(argv)
 
-    if (
-        TOSA_REFMODEL_RUNNER in args.sut_module
-        and not Path(args.ref_model_path).is_file()
-    ):
-        print(
-            "Argument error: Reference Model not found ({})".format(args.ref_model_path)
+    # Set up some defaults
+    if args.ref_model_path is None:
+        args.ref_model_path = cmf.find_tosa_file(
+            cmf.TosaFileType.REF_MODEL, Path("reference_model"), False
         )
+    if args.flatc_path is None:
+        args.flatc_path = cmf.find_tosa_file(
+            cmf.TosaFileType.FLATC, args.ref_model_path
+        )
+    if args.schema_path is None:
+        args.schema_path = cmf.find_tosa_file(
+            cmf.TosaFileType.SCHEMA, args.ref_model_path
+        )
+
+    if TOSA_REFMODEL_RUNNER in args.sut_module and not args.ref_model_path.is_file():
+        print(f"Argument error: Reference Model not found - {str(args.ref_model_path)}")
         exit(2)
 
     if args.test_list_file: