|
| 1 | +############################################################################# |
| 2 | +## |
| 3 | +## Copyright (c) 2024, Precision Innovations Inc. |
| 4 | +## All rights reserved. |
| 5 | +## |
| 6 | +## BSD 3-Clause License |
| 7 | +## |
| 8 | +## Redistribution and use in source and binary forms, with or without |
| 9 | +## modification, are permitted provided that the following conditions are met: |
| 10 | +## |
| 11 | +## * Redistributions of source code must retain the above copyright notice, this |
| 12 | +## list of conditions and the following disclaimer. |
| 13 | +## |
| 14 | +## * Redistributions in binary form must reproduce the above copyright notice, |
| 15 | +## this list of conditions and the following disclaimer in the documentation |
| 16 | +## and/or other materials provided with the distribution. |
| 17 | +## |
| 18 | +## * Neither the name of the copyright holder nor the names of its |
| 19 | +## contributors may be used to endorse or promote products derived from |
| 20 | +## this software without specific prior written permission. |
| 21 | +## |
| 22 | +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 23 | +## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 24 | +## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 25 | +## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 26 | +## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 27 | +## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 28 | +## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 29 | +## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 30 | +## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 31 | +## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 32 | +## POSSIBILITY OF SUCH DAMAGE. |
| 33 | +############################################################################### |
| 34 | + |
| 35 | +import unittest |
| 36 | +import subprocess |
| 37 | +import os |
| 38 | +from .autotuner_test_utils import AutoTunerTestUtils |
| 39 | + |
| 40 | +cur_dir = os.path.dirname(os.path.abspath(__file__)) |
| 41 | + |
| 42 | + |
| 43 | +class FastSmokeTest(unittest.TestCase): |
| 44 | + platform = "asap7" |
| 45 | + design = "gcd" |
| 46 | + |
| 47 | + def setUp(self): |
| 48 | + self.tune_config = os.path.join( |
| 49 | + cur_dir, |
| 50 | + f"../../../flow/designs/{self.platform}/{self.design}/autotuner.json", |
| 51 | + ) |
| 52 | + self.sweep_config = os.path.join( |
| 53 | + cur_dir, |
| 54 | + "./files/fast-at-sweep.json", |
| 55 | + ) |
| 56 | + self.exec = AutoTunerTestUtils.get_exec_cmd() |
| 57 | + self.tune_command = ( |
| 58 | + f"{self.exec}" |
| 59 | + f" --design {self.design}" |
| 60 | + f" --platform {self.platform}" |
| 61 | + f" --experiment fast-smoke-test-tune" |
| 62 | + f" --config {self.tune_config}" |
| 63 | + f" tune --samples 1" |
| 64 | + ) |
| 65 | + self.sweep_command = ( |
| 66 | + f"{self.exec}" |
| 67 | + f" --design {self.design}" |
| 68 | + f" --platform {self.platform}" |
| 69 | + f" --experiment fast-smke-test-sweep" |
| 70 | + f" --config {self.sweep_config}" |
| 71 | + f" sweep" |
| 72 | + ) |
| 73 | + |
| 74 | + def test(self): |
| 75 | + if not (self.platform and self.design): |
| 76 | + raise unittest.SkipTest("Platform and design have to be defined") |
| 77 | + |
| 78 | + tune_process = subprocess.Popen(self.tune_command, shell=True) |
| 79 | + sweep_process = subprocess.Popen(self.sweep_command, shell=True) |
| 80 | + |
| 81 | + tune_returncode = tune_process.wait() |
| 82 | + sweep_returncode = sweep_process.wait() |
| 83 | + |
| 84 | + self.assertEqual(tune_returncode, 0, "Tune command failed") |
| 85 | + self.assertEqual(sweep_returncode, 0, "Sweep command failed") |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | +if __name__ == "__main__": |
| 90 | + unittest.main() |
0 commit comments