| 1 | #!/usr/bin/python |
| 2 | |
| 3 | ################################################################################ |
| 4 | # |
| 5 | # Copyright (C) 2018-2023 Advanced Micro Devices, Inc. All rights reserved. |
| 6 | # |
| 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | # of this software and associated documentation files (the "Software"), to deal |
| 9 | # in the Software without restriction, including without limitation the rights |
| 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | # copies of the Software, and to permit persons to whom the Software is |
| 12 | # furnished to do so, subject to the following conditions: |
| 13 | # |
| 14 | # The above copyright notice and this permission notice shall be included in |
| 15 | # all copies or substantial portions of the Software. |
| 16 | # |
| 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | # SOFTWARE. |
| 24 | # |
| 25 | ################################################################################ |
| 26 | |
| 27 | # Create a test_py script for all *.yaml files in specified directory |
| 28 | # usage: create_tests.py TEST_DIR |
| 29 | # Run from the Tensile/Tests directory, output script goes in the TEST_DIR/test_TEST_DIR.py |
| 30 | |
| 31 | # The directory containing the test script can be passed to pytest: |
| 32 | # PYTHONPATH=. py.test-3 --durations=0 -v Tensile/Tests/TEST_DIR/ |
| 33 | from __future__ import print_function |
| 34 | import glob, sys, os |
| 35 | |
| 36 | targetDir = sys.argv[1] if len(sys.argv) > 1 else "." |
| 37 | targetFile = "%s/test_%s.py"%(targetDir,os.path.basename(targetDir)) |
| 38 | print("info: writing test script to %s" % targetFile) |
| 39 | outfile = open(targetFile, "w" ) |
| 40 | outfile.write("import Tensile.Tensile as Tensile\n\n") |
| 41 | for f in glob.glob("%s/*aml"%targetDir): |
| 42 | baseName = os.path.basename(f) |
| 43 | testName = os.path.splitext(baseName)[0] |
| 44 | testName = testName.replace('.','_') |
| 45 | if not testName.startswith("test_"): |
| 46 | testName = "test_" + testName |
| 47 | |
| 48 | outfile.write ("def %s(tmpdir):\n" % (testName)) |
| 49 | outfile.write (' Tensile.Tensile([Tensile.TensileTestPath("%s"), tmpdir.strpath])\n\n' % (f)) |
| 50 |