diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/NOTICE.txt b/NOTICE.txt new file mode 100644 index 0000000..6ec9714 --- /dev/null +++ b/NOTICE.txt @@ -0,0 +1,185 @@ +========================================================================= +== NOTICE file corresponding to section 4(d) of the Apache License, == +== Version 2.0, in this case for the Apache Geronimo distribution. == +========================================================================= + +========================================================================= +== UVM AMD Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +AMD. + +Copyright 2010-2022 AMD. +All rights reserved. + +========================================================================= +== UVM Accellera Systems Initiative Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +Accellera Systems Initiative. + +Copyright 2012 Accellera Systems Initiative. +All rights reserved. + +========================================================================= +== UVM Aldec Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +Aldec. + +Copyright 2012 Aldec. +All rights reserved. + +========================================================================= +== UVM Analog Devices, Inc Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +Analog Devices, Inc. + +Copyright 2015 Analog Devices, Inc. +All rights reserved. + +========================================================================= +== UVM Cadence Design Systems, Inc Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +Cadence Design Systems, Inc. + +Copyright 2007-2023 Cadence Design Systems, Inc. +All rights reserved. + +========================================================================= +== UVM Cisco Systems, Inc Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +Cisco Systems, Inc. + +Copyright 2012-2019 Cisco Systems, Inc. +All rights reserved. + +========================================================================= +== UVM Cypress Semiconductor Corp Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +Cypress Semiconductor Corp. + +Copyright 2011-2012 Cypress Semiconductor Corp. +All rights reserved. + +========================================================================= +== UVM Intel Corporation Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +Intel Corporation. + +Copyright 2014-2022 Intel Corporation. +All rights reserved. + +========================================================================= +== UVM Marvell International Ltd Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +Marvell International Ltd. + +Copyright 2019-2023 Marvell International Ltd. +All rights reserved. + +========================================================================= +== UVM Mentor Graphics Corporation Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +Mentor Graphics Corporation. + +Copyright 2007-2023 Mentor Graphics Corporation. +All rights reserved. + +========================================================================= +== UVM NVIDIA Corporation Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +NVIDIA Corporation. + +Copyright 2012-2022 NVIDIA Corporation. +All rights reserved. + +========================================================================= +== UVM NXP Semiconductors Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +NXP Semiconductors. + +Copyright 2021 NXP Semiconductors. +All rights reserved. + +========================================================================= +== UVM Paradigm Works Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +Paradigm Works. + +Copyright 2010-2012 Paradigm Works. +All rights reserved. + +========================================================================= +== UVM Qualcomm, Inc Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +Qualcomm, Inc. + +Copyright 2018 Qualcomm, Inc. +All rights reserved. + +========================================================================= +== UVM Semifore Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +Semifore. + +Copyright 2011-2022 Semifore. +All rights reserved. + +========================================================================= +== UVM Synopsys, Inc Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +Synopsys, Inc. + +Copyright 2004-2022 Synopsys, Inc. +All rights reserved. + +========================================================================= +== UVM Verific Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +Verific. + +Copyright 2017-2021 Verific. +All rights reserved. + +========================================================================= +== UVM Verilab Notice +========================================================================= + +Portions of the UVM Reference Library were developed by +Verilab. + +Copyright 2013 Verilab. +All rights reserved. + diff --git a/README.md b/README.md index 5fe3b13..c4bed18 100644 --- a/README.md +++ b/README.md @@ -1 +1,248 @@ -# uvm-test \ No newline at end of file +# Accellera Universal Verification Methodology Tests + +# Scope + +This repository is provided as means of contributing tests for the verification of UVM errata, as described by [uvm-core/DEVELOPMENT.md](https://github.com/accellera-official/uvm-core/blob/main/DEVELOPMENT.md). + + +# License + +This repository is licensed under the Apache-2.0 license. The full text of +the Apache license is provided in this kit in the file [LICENSE.txt](./LICENSE.txt). + +# Copyright + +All copyright owners for this kit are listed in [NOTICE.txt](./NOTICE.txt). + +All Rights Reserved Worldwide + +# Contacts and Support + +If you have questions about this repository and/or its application, please visit the +[Accellera UVM (IEEE 1800.2) - Methodology and BCL Forum](https://forums.accellera.org/forum/43-uvm-ieee-18002-methodology-and-bcl-forum/) or +contact the Accellera UVM Working Group (uvm-wg@lists.accellera.org). + +# Git details + +The following information may be used for tracking the version of this file. Please see +[DEVELOPMENT.md](./DEVELOPMENT.md) for more details. + +``` +$File$ +$Rev$ +$Hash$ +``` + +# Usage + +## Recommendations + +Please follow the following recommendations when you create tests +so that they easily work across all tool chains, with changing versions of UVM, .. + +- prefer test.sv based tests over test.pl or makefile based tests + +- prefer self checking tests over gold file based tests + +- only have ONE test per test directory. + +- Avoid tests which run in a directory other than the current test directory + +- avoid copying post_test.pl to the test run directory and make a link instead + +- prefer `uvm_report_catcher` to `UVM TEST EXPECT ...` report checking. + +## Prerequisites + +- The runner is a perl based script so it requires a 5.8+ perl. + +- The runner requires a backend for the choosen tool chain. + +- The runner may utilize make in order to start makefile based tests + +- The runner needs a uvm-core library installation and a set of tests, a test hierarchy or a file pointing to tests. + +- test.sv based tests pass a `+UVM_TESTNAME=test` to the test and therefore require that there is a test named "test" deriving from "uvm_test". + +## Document terminology + +The following syntax is used throughout the document + +- `${UVM_CORE}` is the absolute path to the uvm installation. + +- `${UVM_TESTS}` is the location of the uvm tests installation + +- `${TOOL}` refers to the tool chain. currently the supported tool chains are `clean|echo|ius|questa|vcs|vcsi|xcelium` + +**Note:** These are _not_ environment variables, they exist as a shorthand for the documentation. + +## Locations + +The test runner is located here `${UVM_TESTS}/admin/bin/run_tests` while the tool chain +support scripts are stored in `${UVM_TESTS}/tools/${TOOL}/run_tests.pl` + +## Simple Usage + +The minimal arguments are the location of the uvm installation, the tool chain to use and at least one test. + +``` +cd ${UVM_TESTS} && admin/bin/run_tests -u ${UVM_CORE} ${TOOL} tests +``` + +**Note:** `admin/bin/run_tests -h` provides a complete breakdown of the supported arguments. + + +## Test selection + +Tests are directories supplied on the command line or via a file using the `-f` option of +the runner. Each directory is considered a test and the runner will launch a simulation +within that directory given that one of the following applies: + +1. a file `test.sv` is present or +2. a file `test.pl` is present + +in that directory. + +Subdirectories of the supplied tests are scanned recursively and added to the test set ONLY +if they match the `^[0-9][0-9]` file name pattern. + + +## Referencing the UVM install from scripts/tests + +Processes forked from the test runner will have the env variable `UVM_HOME` set pointing to +the UVM installation being used. + +## Execution flow for a single test + +The test runner executes the test unless a file `all.skip` or `${TOOL}.skip` is present in the test directory. +The skip will be reported. Then the test is executed through the following methods. + +### Flow for a test.sv based test + +1. The test is compiled and run. This step utilizes the contents of the following files + - ${TOOL}.comp.args + - test.defines + - ${TOOL}.run.args + - test.plusargs + +Its is upto the tool chain to use these arguments and perform the steps in a single +step or using multiple steps. + +2. the test is checked. see [Determining test status](#determining-test-status) + +3. cleanup is performed: In this step the tool chain removes all created files. It is upto + the tool chain to define the set of files to remove. + +### Flow for a test.pl based test + +In this flow the runner executes the provided test.pl and uses the return status as test execution +status. It is upto the user to perform compile+run as necessary. + +## Determining test status + +Test status is determined differently for `test.sv` tests vs. `test.pl` tests. Additionally, test status may be affected by the presence of a `post_test.pl` script. + +### Determining test status in test.sv mode + +1. if no compile log is present the test is considered fail + +2. if compile errors are present the test fails unless they are expected. + If a compile time error is expected the log or error message must provide the "UVM TEST COMPILE-TIME FAILURE" as part of the log. + +3. if the test directory contains a post_test.pl file it will be executed to determine pass/fail alone. The builtin + pass failure algorithm in the next step is NOT applied. + +4. The log is scanned for the following patterns + + - The presence of `UVM TEST FAILED` makes the test fail + - The absence of `UVM TEST PASS` makes the test fail + - The absence of `UVM Report Summary` without a corresponding `UVM TEST EXPECT NO SUMMARY` makes the test fail + + If `UVM Report Summary` is present in the log, then the number of `UVM_ERROR` and `UVM_FATAL` messages is checked. + - By default, any number above zero makes the test fail. + - A test can specify that it expects some number of these messages using `UVM TEST EXPECT \d+ UVM_ERROR` and `UVM TEST EXPECT \d+ UVM_FATAL`. The test will fail if the number seen does not match the number of expected. + +5. a `${TOOL}` runtime error leads to a failing simulation unless the log/message produces the magic pattern "UVM TEST RUN-TIME FAILURE" as part of the message or log. + +### Running makefile based simulations through test.pl + +The test.pl method can be used to start makefile based tests by using something like + +```perl +return &make_example("${uvm_home}/examples/simple/registers/vertical_reuse"); +``` + +This requires the `Makefile.${TOOL}` is present in the chosen directory. + +### Gold file based tests using post_test.pl + +The provided [post test script](admin/bin/post_test.pl) can be used to check gold file based tests. +In order to utilize it you should make a link to the `post_test.pl` in the test directory pointing back to `admin/bin/post_test.pl`. + +The script makes the following assumptions + +1. gold files are stored in `*.au` or `*.au.${TOOL}` files +2. the filter will strip certain patterns from the gold and the logfile. this includes changing patterns or special `${TOOL}` specific information. +3. a gold file `` is compared to `.au` or `.au.${TOOL}` +4. if a gold file `.au` or `.au.${TOOL}` is present then the + file `` must also exist and there must be gold files for the other `${TOOL}`s too. + +The combination of a logfile `` and gold file `.au` or `.au.${TOOL}` is first processed +into a file `.post` and `.au.post` (or `.au.${TOOL}.post`). Once processed the two resulting files are diffed using the system "diff" +command and the difference is stored in a `.df` file. The script reports an eventual difference between the post files as failure. + +--------------------------------------------------------------------- +## Writing a test.sv UVM test +--------------------------------------------------------------------- + +1. create a directory in the `${UVM_TESTS}/tests` hierarchy. The directory name must start with at least two digits to be recognised automatically. +2. create your test in `test.sv` +3. ensure the test class inherits from uvm_test and is named `test` +4. place additional switches and arguments in the menitoned configuration files +5. emit failures using the standard UVM `` `uvm_error`` and `` `uvm_fatal`` macros or the `uvm_report_error` and `uvm_report_fatal` functions. +6. encode specific pass/fail logic in the `uvm_test::report` method + +For example: + +```SystemVerilog +import uvm_pkg::*; +`include "uvm_macros.svh" + + +module top; + initial + run_test(); + +endmodule + +class test extends uvm_component; + `uvm_component_utils(test) + + function new(string name, uvm_component parent); + super.new(name, parent); + endfunction + + task run_phase(uvm_phase phase); + phase.raise_objection(this); + + // start your test + + phase.drop_objection(this); + endtask + + function void report_phase(uvm_phase phase); + uvm_report_server rs = uvm_report_server::get_server(); + super.report_phase(phase); + if(rs.get_severity_count(UVM_ERROR) > 0) + $display("** UVM TEST FAIL **"); + else + $display("** UVM TEST PASSED **"); + endfunction +endclass +``` +--------------------------------------------------------------------- +## Known test runner limitations +--------------------------------------------------------------------- + +- pass/fail logic: in some situation multiple contradicting status information can be obtained from log or exit status +(or other contributing places). As such, any fail status will cause the test to fail, regardless of the presence of a PASS token. diff --git a/admin/bin/post_test.pl b/admin/bin/post_test.pl new file mode 100644 index 0000000..b652cf9 --- /dev/null +++ b/admin/bin/post_test.pl @@ -0,0 +1,183 @@ +##---------------------------------------------------------------------- +## Copyright 2011-2018 Cadence Design Systems, Inc. +## Copyright 2013 Mentor Graphics Corporation +## Copyright 2018 NVIDIA Corporation +## Copyright 2013 Synopsys, Inc. +## All Rights Reserved Worldwide +## +## Licensed under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of +## the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in +## writing, software distributed under the License is +## distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +## CONDITIONS OF ANY KIND, either express or implied. See +## the License for the specific language governing +## permissions and limitations under the License. +##---------------------------------------------------------------------- +use File::Glob ':glob'; +use Data::Dumper; +use File::Basename; + +# the script compares a set of goldfiles +# +# goldfiles are all files in the local directory matching *.au.($tool)? +# each goldfile is compared to a produced file $file by chopping \.au(.$tool)$ from the goldfile name +# if the produced file $file doesnt exist its assumed that the goldfile shall be compared to the simulator default log +# +# 1. each produced file is filtered and saved as $file.post +# 2. then a diff is performed between $file.post and $file.au(.$tool)? and saved as $file.df +# 3. the script returns showing the set mismatches, missing files (or not) +# +# +# the script filters a set of variying patterns such as +# filenames, message locations, seeds, handles + + +# consider all *.au and *.au.$tool files +#my $tool="ius"; +#my $log="./bla"; +my $dir=dirname($log); +my @sources = bsd_glob("$dir/*.{au,au.$tool}",GLOB_CSH); +my @diffs=(); +my %lookup=(); +my %known_logs= ("xcelium" => "$dir/xrun.log", "ius" => "$dir/irun.log", "vcs" => "$dir/simv.log", "questa" => "$dir/run.log"); + +if (! scalar(@sources)) { + push @diffs,"no gold files present"; +} + +sub cleanFileAndWrite { + my($text,$file) = @_; + local(*O); + + scrub(\$text); + open(O,">$file") || push @diffs,"cannot write post file $file - $!"; + print O $text; + close O; +} + +sub scrub { + my($logfile)=@_; + + # This must be the first filter for Questa. Do not put anything before it, please. + $$logfile =~ s/^# //mg; + + # Questa-specific? + $$logfile =~ s/__\d+\@\d+/__X\@X/sg; + if ($dir eq "00basic/25typename" && $tool eq "questa") { + $$logfile =~ s/,88 /, 88/mg; + } + + $$logfile =~ s/\@[\d_]+[^\S\r\n]*/\@X/sg; + + # strip header + $$logfile =~ s/.*\nGOLD-FILE-START\n//sx; + $$logfile =~ s/\nGOLD-FILE-END.*/\n/sx; + + $$logfile =~ s/^ncsim>.*$//mg; + $$logfile =~ s/^(UVM_(INFO|WARNING|ERROR|FATAL))\s+\S+\(\d+\)/\1 FILE-LINE/mg; + $$logfile =~ s/\S+\.svh//mg; + $$logfile =~ s/\n+\n/\n/sxg; + $$logfile =~ s/^UVM-\S+\s+\(\S+\)$/UVM-VERSION/mg; + $$logfile =~ s/^\(C\).*$/COPYRIGHT/mg; + $$logfile =~ s/COPYRIGHT(.COPYRIGHT)+/COPYRIGHT/sg; + $$logfile =~ s/^SVSEED.*\n//sg; + $$logfile =~ s/\$unit_0x[0-9a-f]+::/SCOPE::/mg; + $$logfile =~ s/(\s+m_inst_(id|count)):\d+/\1:X/mg; + + # if this is a factory dump, then deal with the count + $$logfile =~ s/All types registered with the factory: \d+ total/UVM TEST FACTORY COUNT/mg; + + # if this is a recorder dump then handle the TXH as handles + if($$logfile =~ /\s+CREATE_STREAM/) { + $$logfile =~ s/([\{ ]TXH\d*:)(\d+)/\1\@H/mg; + $$logfile =~ s/STREAM:\d+/STREAM:\@H/mg; + $$logfile =~ s/NAME:inst_id VALUE:(\d+)/NAME:inst_id VALUE:\@H/mg; + } + +} + +sub diffLogs { + my($gold,$post)=@_; + + if (system("diff $post.post $gold > $post.df")) { + return "$post.df"; + } else { + return (); + } +} + +sub ReadFileAsText { + my($FILENAME)=@_; + my($TEXT); + local(*INFILE); + + $TEXT=""; + open(INFILE,$FILENAME) || push @diffs,"can't open file [$FILE][$!]"; + undef $/; + $TEXT .= ; + $/ = "\n"; + close(INFILE); + return ($TEXT); +} + +#print "alive"; +#print Dumper(@sources); +my($vendorspecial)=(); +LOOP: foreach my $goldfile (@sources) { + my $current = $goldfile; + $current =~ s/\.au(\.$tool)?$//g; + + # if its a vendor specific gold file then all vendors should have at least a goldfile + if(defined $1) { + foreach $v (keys %known_logs) { + my @sources = bsd_glob("$dir/*.au.$v",GLOB_CSH); + if(!scalar(@sources)) { + push @diffs,"no vendor specific log avail but vendor $v has one"; + } + } + } + + if(!(-e $current)) { + if(!(-e $known_logs{$tool})) { + push @diffs,"neither vendor special log present nor default log present for vendor ($tool)"; + next LOOP; + } else { + $current=$known_logs{$tool}; + } + } + + if(! (-r $goldfile)) { + push @diffs,"goldfile ($goldfile) not readable"; + next LOOP; + } + if(! (-r $current)) { + push @diffs,"vendor log ($current) not readable"; + next LOOP; + } + + my $c = ReadFileAsText($current); + cleanFileAndWrite($c,"$current.post"); + push @diffs,diffLogs($goldfile,$current); + + if (exists $lookup{$current}) { + push @diffs,"fatal: generic goldfile and simulator specific goldfile exists"; + } + $lookup{$current}=1; +} +#print Dumper(@diffs); + +if (@diffs) { + my $d=join(",",@diffs); + $post_test="diffs in: $d"; + return 1; +} else { + my $d=@sources; + $post_test="$d goldfile(s) match"; + return 0; +} diff --git a/admin/bin/run_tests b/admin/bin/run_tests new file mode 100755 index 0000000..978cb18 --- /dev/null +++ b/admin/bin/run_tests @@ -0,0 +1,1114 @@ +eval 'exec perl -S $0 ${1+"$@"}' +if 0; +package run_tests; + +##---------------------------------------------------------------------- +## Copyright 2010-2018 Cadence Design Systems, Inc. +## Copyright 2010-2011 Mentor Graphics Corporation +## Copyright 2010 AMD +## Copyright 2017 NVIDIA Corporation +## Copyright 2010-2013 Synopsys, Inc. +## All Rights Reserved Worldwide +## +## Licensed under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of +## the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in +## writing, software distributed under the License is +## distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +## CONDITIONS OF ANY KIND, either express or implied. See +## the License for the specific language governing +## permissions and limitations under the License. +##---------------------------------------------------------------------- + +use Getopt::Long qw(:config no_ignore_case); +use Cwd qw(abs_path chdir); +use File::Spec::Functions qw(catfile path); +use File::Path qw(mkpath rmtree); +use File::Basename; +use File::Copy qw(move); +use Fcntl qw(:flock :mode); +use File::Temp qw(tempdir); +use Digest::MD5 qw(md5_hex); +my $script = abs_path(__FILE__); +my $script_name = basename($script); +my @myargv = @ARGV; + + +sub usage { + +print STDERR < Directory to create lock files in order to prevent file + contention when jobs are running in parallel. + If -t is specified this option is ignored + -M opts Add the specified options to makefile command line + (applies to makefile-based tests) + -q Use queue to submit jobs in parallel. All input and + output files located in the .jobs subdirectory. + stdout and stderr are included in the output log + -Qx name Name of the executable for submitting queues (default=bsub) + -Q opts Add the specified options to the command that submits + the jobs to the queue + -R opts Add the specified options to the simulation command + -S Do not skip tests + -t Run tests out of a temp directory. + Directory is removed when test is complete unless + -d is specified or test fails and -nokeep_fails is + not specificed. + -tests_per_job Runs tests into a single job instead of 1 test + per job + -u dir Use the UVM distribution in the specified directory + -v Display the output of the testcase on stdout + +USAGE + exit(1); +} + +# +# Run and summarize a set of tests +# +sub run() { + &GetOptions ("0" , + "c" , + "C=s", + "d" , + "f=s", + "F=s", + "Ff=s", + "Fs=s", + "P" , + "h" , + "R=s", + "S" , + "u=s", + "M=s", + "q" , + "Qx=s", + "Q=s", + "t" , + "l=s", + "L=s", + "tests_per_job=i" => \$opt_tests_per_job, + 'nokeep_fails' => \$opt_nokeep_fails, + 'compat_pkgdir=s' => \$opt_compat_pkgdir, + "v" + ); + &usage if $opt_h || $#ARGV < 0; + + if ($opt_l) { + if (!open(STDOUT, "> $opt_l")) { + print STDERR "Cannot open \"$opt_l\" for writing: $!\n"; + exit(1); + } + *STDERR = *STDOUT; + } + $tool = shift(@ARGV); + + if (!$opt_u) { + # Find "distrib" directory + $opt_u = "distrib"; + for($_ = 0; $_ < 10; $_++) { + last if -e $opt_u; + $opt_u = "../$opt_u"; + } + if (!-e $opt_u) { + print STDERR "ERROR: Cannot locate UVM distribution. Use the -u option to specify its location.\n"; + exit(1); + } + } + if (! -e "$opt_u/src/uvm_pkg.sv") { + print STDERR "ERROR: \"$opt_u\" does not appear to contain a valid UVM distribution.\n"; + exit(1); + } + $uvm_home = abs_path($opt_u); + + if ($opt_compat_pkgdir) { + $compat_home = abs_path($opt_compat_pkgdir); + } else { + $compat_home = $uvm_home; + } + + $libdir = abs_path(dirname($script) . '/../../tools/' . $tool); + if (! -e $libdir) { + print STDERR "Tool-specific library \"$libdir\" does not exists.\n"; + exit(1); + } + push(@INC, $libdir); + + require "run_test.pl"; + $dev_tests_base=abs_path(dirname($script) . "/../../tests"); + + # + # Always keep a list of failed tests + # + die "-F and -Ff/-Fs are mutually exclusive!" if ($opt_F && ($opt_Ff || $opt_Fs)); + if ($opt_F) { + $opt_Ff = $opt_F; + $opt_Fs = $opt_F; + undef $opt_F; + } + + my $fails_out; + my $skips_out; + + $opt_Ff = "$tool.fails" unless $opt_Ff; + + if (!open($fails_out, "> $opt_Ff")) { + print STDERR "Cannot open \"$opt_Ff\" for writing: $!\n"; + exit(1); + } + + # + # If the -Ff is provided, but not -Fs, skips will not be output. + # + if ($opt_Fs) { + if ($opt_Ff eq $opt_Fs) { + $skips_out = $fails_out; + } else { + if (!open($skips_out, "> $opt_Fs")) { + print STDERR "Cannot open \"$opt_Fs\" for writing: $!\n"; + exit(1); + } + } + } + + # + # The '-c' option is redundent for the "clean" pseudo-tool + # + $opt_c = 0 if $tool eq "clean"; + + # + # Find all of the test directories in the supplied arguments + # + + if ($opt_f) { + + if (!open(F, "< $opt_f")) { + print STDERR "Cannot open \"$opt_f\" for reading: $!\n"; + exit(1); + } + while ($_ = ) { + chomp($_); + push(@dirs, $_); + } + close(F); + } else { + if ($#ARGV == -1) { + @ARGV = <[0-9][0-9]*>; + } + foreach $dir (@ARGV) { + if (! -d $dir) { + print STDERR "test directory \"$dir\" does not exist.\n"; + exit(1); + } + $dir =~ s|/$||; + push(@dirs, &get_testdirs($dir)); + } + } + + + + $| = 1; + + # + # Run the individual tests + # + $failures = 0; + + if ($opt_q) { + # use function pointer to allow users to override + # the function called to submit jobs to the queue. + # set to 'queue_jobs' if not defined. + $submit_jobs = \&queue_jobs unless defined $submit_jobs; + $job_dir = ".jobs"; + if (-e $job_dir) { + rmtree($job_dir, {keep_root => 1}); + } + else { + mkpath $job_dir; + } + $job_dir = abs_path($job_dir); + $job_info_ref = &get_job_info(\@dirs, $job_dir); + $submit_jobs->(@{$job_info_ref->{'commands'}}); + &get_job_result(\@dirs, $job_info_ref->{'logs'}, $skips_out, $fails_out); + } + else { + foreach $dir (@dirs) { + # trailing '/'s confuse this script + $dir =~ s|/$||; + $returnCode = &run_one_test($dir); + if ($returnCode != 0) { + $failures++; + if ($skips_out && ($returnCode == 2)) { + print $skips_out "$dir\n"; + } else { + print $fails_out "$dir\n"; + } + } + } + } + print "-----------------------------------------------------------------\n"; + $txt = sprintf("Total of %d tests ", $#dirs+1); + $dots = substr("............................................", 0, 46-length($txt)); + print $txt, $dots; + $failures -= $skipped; + if ($failures > 0) { + printf " FAILED %d of %d tests (%d skipped)", $failures, $#dirs+1, $skipped; + } elsif ($skipped > 0) { + printf " PASSED %d of %d tests (%d skipped)", $#dirs+1-$skipped, $#dirs+1, $skipped; + } else { + print " PASSED all tests"; + } + print "\n"; + + if ($skips_out != $fails_out) { + close($skips_out); + unlink($opt_Fs) unless $skipped; + } + close($fails_out); + unlink($opt_Ff) unless $failures; + exit($failures); +} + +# +# Recursively find all test directories +# +sub get_testdirs { + local($dir, $_, @subs, @dirs) = @_; + + @dirs = (); + if (-e "$dir/test.sv" || -e "$dir/test.pl") { + push(@dirs, $dir); + } + @subs = <$dir/[0-9][0-9]*>; + return @dirs if $#subs == -1; + + foreach $_ (@subs) { + push(@dirs, &get_testdirs($_)); + } + return @dirs; +} + +# +# Run one test in the specified directory +# +# Return non-zero if the test fails. +# +sub run_one_test { + $comp_args = ""; + local($testdir, $_) = @_; + + local($dir) = $testdir; + if (length($dir) > 43) { + $dir = substr($dir, 0, 43) . "*"; + } + $dots = substr("............................................", 0, 45-length($dir)); + print "$dir $dots "; + + if (! -d $testdir) { + print "**FAIL** ($testdir not exist)"; + print "\n"; + return 1; + } + + if (-e "$testdir/compat_lib.use") { + $compat_lib_home = abs_path($compat_home . '/compat'); + $compat_args = '+incdir+' . $compat_lib_home . " " . $compat_lib_home . '/uvm_compat_pkg.sv'; + } + + if (!$opt_S && !$opt_c && (-e "$testdir/$tool.skip" || -e "$testdir/all.skip")) { + undef @skippers; + if (-e "$testdir/all.skip") { + push(@skippers, "all simulators"); + } + elsif ( -e "$testdir/$tool.skip") { + foreach $skipper (<$testdir/*.skip>) { + $skipper =~ s|$testdir/(.*)\.skip|$1|; + push(@skippers, $skipper) unless $skipper eq $tool; + } + } + print "SKIP "; + print "(", join(", ", @skippers), ")" if @skippers; + print "($tool only)" unless @skippers; + print " (-S to force)\n"; + $skipped++; + return 2; # return value of 2 to indicate a skip to caller + } + + # + $ENV{'UVM_HOME'}=$uvm_home; + $ENV{'DEV_TESTS_BASE'}=$dev_tests_base; + + local($sv) = ("$testdir/test.sv"); + local($rundir) = abs_path($testdir); + local($failed); + + if (!$opt_c & $opt_t) { + $rundir = &setup_tempdir($rundir); + } + + if (! -e $sv) { + # Maybe it is a script instead of an SV file? + local($pl) = ("$rundir/test.pl"); + if (-e $pl) { + $post_test = 0; + print "\n" if ($opt_v || $opt_P); + local($cwd) = $ENV{'PWD'}; + chdir $rundir; + $failed = do "test.pl"; + chdir $cwd; + print "$testdir $dots " if ($opt_v || $opt_P); + + if (!defined($failed) || $@) { + print "**FAIL** (Invalid test.pl)"; + print "\n"; + $failed = 1; + } + elsif ($failed ne "0") { + $post_test = "test.pl" unless $post_test; + print "**FAIL** ($post_test)"; + print "\n"; + } else { + $post_test = "from test.pl" unless $post_test; + if ($opt_c) { + &clean_tempdirs($testdir); + print "clean ($post_test)\n"; + } else { + print "pass ($post_test)"; + print "\n"; + } + } + + } + else { + print "**FAIL** (Neither $sv nor $pl exist)"; + print "\n"; + $failed = 1; + } + } + else { + + if (!$opt_c) { + print "\n" if ($opt_v || $opt_P); + + if (-e "$rundir/$tool.comp.args") { + if (!open(ARGS, "< $rundir/$tool.comp.args")) { + print "**FAIL** (Cannot read $tool.comp.args)"; + print "\n"; + } + while ($_ = ) { + chomp; + $comp_args .= " $_"; + } + close(ARGS); + } + + $defs = ""; + if (-e "$rundir/test.defines") { + if (!open(ARGS, "< $rundir/test.defines")) { + print "**FAIL** (Cannot read test.defines)"; + print "\n"; + } + while ($_ = ) { + chomp; + $defs .= " $_"; + } + close(ARGS); + } + + $run_args = ""; + if (-e "$rundir/$tool.run.args") { + if (!open(ARGS, "< $rundir/$tool.run.args")) { + print "**FAIL** (Cannot read $tool.run.args)"; + print "\n"; + } + while ($_ = ) { + chomp; + $run_args .= " $_"; + } + close(ARGS); + } + + $plusargs = ""; + if (-e "$rundir/test.plusargs") { + &run_the_test($rundir, "$comp_args $opt_C $defs", + "$run_args $opt_R -f $rundir/test.plusargs","$compat_args"); + } else { + &run_the_test($rundir, "$comp_args $opt_C $defs", + "$run_args $opt_R","$compat_args"); + } + + # if (!open(ARGS, "< $rundir/test.plusargs")) { + # print "**FAIL** (Cannot read test.plusargs)"; + # print "\n"; + # } + # close(ARGS); + # + # $plusargs = ""; + # while ($_ = ) { + # chomp; + # $plusargs .= " $_"; + # } + # close(ARGS); + # } + + # &run_the_test($rundir, "$comp_args $opt_C $defs", + # "$run_args $opt_R -f $plusargs"); + + print "$testdir $dots " if ($opt_v || $opt_P); + + } + + # + # Clean up all temporary files, except the log file + # + if (!$opt_d || $opt_c) { + &cleanup_test($rundir); + if ($opt_c) { + &clean_tempdirs($testdir); + print "$tool clean.\n"; + return 0; + } + } + + # + # Check if the test was succesful + # + $failed = &check_test($rundir); + + } + if ($opt_t) { + if ($opt_d | (!$opt_nokeep_fails & ($failed != 0))) { + &relocate_tempdir($rundir,$testdir); + } + } + + return $failed; + +} + + +# +# Check if the test passed or failed. +# +# Display on STDOUT the status of the test and +# return non-zero if it failed. +# +sub check_test { + local($testdir, $_) = @_; + + local($log, @errs); + $log = "$testdir/" . &runtime_log_fname(); + + # Special "clean" logfile + if ($log =~ m|/!$|) { + print "clean.\n"; + return 0; + } + + # If there is no run-time logfile, it could be an expected compile-time + # failure... + if ((! -e $log) ||(&runtime_log_fname() eq &comptime_log_fname())) { + $log = "$testdir/" . &comptime_log_fname(); + if (! -e $log) { + print "**FAIL** (No compile-time log files)"; + print "\n"; + return 1; + } + + @errs = &get_compiletime_errors($testdir); + +# if ($#errs == -1) { +# print "**FAIL** (No compile-time log file)\n"; +# return 1; +# } + + foreach $err (@errs) { + $err =~ m/^(.*)#(\d+)$/; + if (&check_comptime_error($testdir, $1, $2)) { + print "**FAIL** (Compile-time error)"; + print "\n"; + return 1; + } + } + + if((!-e $log)) { + print "pass (with syntax error(s))"; + print "\n"; + return 0; + } + if(scalar(@errs) > 0) { + print "pass (with compile error(s))"; + print "\n"; + return 0; + } + } + + # If the file "post_test.pl" exists, run it to determine success + # or failure. Required when the testcase produces some external + # output whose presence and format is part of the test's success + if (-e "$testdir/post_test.pl") { + $post_test = 0; + $failed = do "$testdir/post_test.pl"; + if (!defined($failed) || $@) { + print "**FAIL** (Invalid post_test.pl)"; + print "\n"; + return 1; + } + if ($failed ne "0") { + $post_test = "post_test: $failed" unless $post_test; + print "**FAIL** ($post_test)"; + print "\n"; + } else { + $post_test = "from post_test.pl" unless $post_test; + print "pass ($post_test)"; + print "\n"; + } + return $failed; + } + + if (!open(LOG, "<$log")) { + print "**FAIL** (cannot read $log)"; + print "\n";; + return 1; + } + + my ($fail, @status_array, $pass_token, $fail_token, $expect_summary, $complete_summary, $unexpected_error); + $fail = 0; + @status_info = (); + $pass_token = 0; + $fail_token = 0; + $expect_summary = 1; + $complete_summary = 0; + $unexpected_error = 0; + + $exp_errs = 0; # No errors expected by default + $exp_fatals = 0; # No fatals expected by default + $in_summary = 0; + undef($n_errs); + undef($n_fatals); + while ($_ = ) { + if (m/UVM TEST FAILED/) { + $fail_token = 1; + next; + } + if (m/UVM TEST PASSED/) { + $pass_token = 1; + next; + } + if (m/UVM TEST EXPECT (\d+) UVM_ERROR/) { + $exp_errs = $1; + next; + } + if (m/UVM TEST EXPECT (\d+) UVM_FATAL/) { + $exp_fatals = $1; + next; + } + if (m/UVM TEST EXPECT NO SUMMARY/) { + $expect_summary = 0; + next; + } + if (m/UVM Report Summary/) { + $in_summary = 1; + next; + } + if ($in_summary && m/^(\# )?UVM_ERROR :\s+(\d+)\s*$/) { + $n_errs = $2; + next; + } + if ($in_summary && m/^(\# )?UVM_FATAL :\s+(\d+)\s*$/) { + $n_fatals = $2; + next; + } + } + close(LOG); + + # Explicit failure + if ($fail_token) { + $fail = 1; + push(@status_array, "explicit FAIL"); + } + + if ($expect_summary) { + if (!$in_summary) { + $fail = 1; + push(@status_array, "missing summary"); + } else { + if (!defined($n_errs)) { + $fail = 1; + push(@status_array, "missing UVM_ERROR summary"); + } + if (!defined($n_fatals)) { + $fail = 1; + push(@status_array, "missing UVM_FATAL summary"); + } + } + } else { + if ($in_summary) { + $fail = 1; + push(@status_array, "unexpected summary"); + } + } + + if (defined($n_errs)) { + if ($n_errs != $exp_errs) { + $fail = 1; + if ($exp_errs > 0) { + push(@status_array, "$n_errs vs $exp_errs UVM_ERRORs"); + } else { + push(@status_array, "UVM_ERRORs"); + } + } else { + if ($exp_errs > 0) { + push(@status_array, "with $exp_errs expected UVM_ERRORs"); + } + } + } + + if (defined($n_fatals)) { + if ($n_fatals != $exp_fatals) { + $fail = 1; + if ($exp_fatals > 0) { + push(@status_array, "$n_fatals vs $exp_fatals UVM_FATALs"); + } else { + push(@status_array, "UVM_FATALs"); + } + } else { + if ($exp_fatals > 0) { + push(@status_array, "with $exp_fatals expected UVM_FATALs"); + } + } + } + + # Maybe the run-time errors were expected... + @errs = &get_runtime_errors($testdir); + foreach $err (@errs) { + local(@s)=split('#',$err); + if (&check_runtime_error($testdir, $s[0], $s[1])) { + $unexpected_error = 1; + } + } + + if ($unexpected_error) { + $fail = 1; + push(@status_array, "runtime error"); + } else { + if (scalar(@errs)) { + push(@status_array, "with expected runtime error(s)"); + } + } + + if (!$pass_token) { + $fail = 1; + push(@status_array, "missing PASS token"); + } + + if ($fail) { + print "**FAIL**"; + } else { + print "pass"; + } + + if (scalar(@status_array)) { + print " (" . join(", ", @status_array) . ")"; + } + print "\n"; + + return $fail; + +} + + +# +# Check that a compile-time error was expected on the +# specified line in the specified file +# +# returns non-zero if the error was NOT expected +# +sub check_comptime_error { + local($testdir, $fname, $line, $_) = @_; + + $fname = "$testdir/$fname"; + if (!open(SV, "< $fname")) { + return 1; + } + + $_ = ""; + while ($line > 0) { + $_ = ; + $line--; + } + + # OK if magic comment found on line in question + return 0 if m/UVM TEST COMPILE-TIME FAILURE/; + + close(SV); + + return 1; +} + + +# +# Check that a run-time error was expected on the +# specified line in the specified file +# +# returns non-zero if the error was NOT expected +# +sub check_runtime_error { + local($testdir, $fname, $line, $_) = @_; + + $fname = "$testdir/$fname"; + if (!open(SV, "< $fname")) { + return 1; + } + + $_ = ""; + while ($line > 0) { + $_ = ; + $line--; + } + + # OK if magic comment found on line in question + return 0 if m/UVM TEST RUN-TIME FAILURE/; + + close(SV); + + return 1; +} + +sub maketool { + local($make)=which("gmake"); + if($make eq "") { + $make="make"; + } + $make; +} + +sub which { +my $name = shift; + +grep { -e } map { my $file = $_; +map { catfile $_, $file } path +} map { $name . lc $_ } (q{}, split /;/); +} + +# +# Execute a Makefile-based example +# +sub make_example { + local($dir, $opts, $result, $_) = @_; + local($make) = maketool(); + local($LOCK_FH) = undef; + local($comp_args) = $opt_C; + return 0 if ($tool eq "clean"); + + $result = 0; + $cmd_redirect = q{}; + if (!$opt_v) { + $cmd_redirect = " > /dev/null 2>&1"; # redirect stdout and stderr to dev/null and not verbose + } + elsif ($opt_l) { + $cmd_redirect = " 2>&1"; # if verbose and loggin, redirect stderr to stdout so that it will be in log file + } + $dir = abs_path($dir); + local($rundir) = $dir; + if (!$opt_c) { + # run test in temp directory. Directory needs to be 'sibling' of directory passed + # in to ensure relative file paths in the makefiles are resolved + if ($opt_t) { + $rundir = &setup_tempdir($rundir) + } + elsif ($opt_L) { + # user md5 to create unique, reproducable, shorter and legal lock file name + # based off the directory the test will run in. + $lockfile = $opt_L . "/" . md5_hex($rundir); + open($LOCK_FH, ">$lockfile") or die "$lockfile: $!"; + flock($LOCK_FH, LOCK_EX) or die "flock() failed to lock $lockfile: $!"; + } + + $cmd = "cd $rundir && $make -f Makefile.$tool $opts $opt_M OPT_C=\"$comp_args\" OPT_R=\"$opt_R\" DEV_TESTS_BASE=\"$dev_tests_base\" UVM_HOME=\"$uvm_home\" all"; + $cmd .= $cmd_redirect; + $result = system($cmd); + + } + if (!$opt_d || $opt_c) { + $cmd = "cd $rundir && $make -f Makefile.$tool $opts clean DEV_TESTS_BASE=\"$dev_tests_base\" UVM_HOME=\"$uvm_home\""; + $cmd .= $cmd_redirect; + system($cmd); + + if ($opt_c) + { + &clean_tempdirs($dir); + return 0; + } + } + + if ($opt_t) { + if ($opt_d | (!$opt_nokeep_fails & ($result != 0))) { + &relocate_tempdir($rundir,$dir); + } + } + + # release the lock if one was created. + if ($LOCK_FH) { + flock($LOCK_FH, LOCK_UN) or die "flock() failed to unlock $lockfile: $!"; + close($LOCK_FH); + } + + return $result; +} + +sub setup_tempdir { + local($rundir, $_) = @_; + local($tempdir); + $rundir = abs_path($rundir); + $tempdir = tempdir( TEMPLATE => 'temp_' . $tool . '_' . basename($testdir) . '_XXXX', + DIR => dirname($rundir), + CLEANUP => !$opt_d); + foreach $file (<$rundir/*>) { + symlink($file,$tempdir . '/' . basename($file)); + } + return $tempdir; +} + +sub relocate_tempdir { + local($rundir, $dest_dir, $_) = @_; + # if not cleaning up tool-generated files + # and a temp dir was created, relocate it under the directory passed in + # before relocating, if there is already a directory with the same name + # then remove it before relocate the temp directory + $dest_dir = $dest_dir . '/' . basename($rundir); + if( -e $dest_dir) { + rmtree($dest_dir); + } + move($rundir,$dest_dir); +} + +sub clean_tempdirs { + local($cleandir, $_) = @_; + # find all tool specific temp dirs and remove them. + $cleandir = $cleandir . '/temp_' . $tool . '_' . basename($testdir); + foreach $cleandir (<$cleandir*>) { + rmtree($cleandir); + } +} + +# +# Generates commands to run and what logs will +# produced when the comands are executed +# +# returns a hash with two entires : +# 'commands' : array of commands to run each test individually +# 'logs' : array of log files that will be created by +# running each command in the commands array. +sub get_job_info { + local($dirs_ref, $job_dir) = @_; + + #remove all arguments after the tool argument + while($myargv[$#myargv] ne $tool) + { + pop @myargv; + } + + # to avoid duplicate arguments when submitting a job + # to the queue use getopts to remove the arguements that + # are always passed to queued jobs as well as arguments + # the are only intended to be used to submit jobs to the queue + Getopt::Long::Configure('pass_through'); + my %h = (); + *ARGV = \@myargv; + GetOptions(\%h, + "f=s", + "F=s", + "Ff=s", + "Fs=s", + "q" , + "Q=s", + "l=s", + "L=s", + "tests_per_job=i"); + # if argument has a space in it, make sure to put it in + # quotes in order to preserve it as one cmdline argument + # on recursive calls to run_tests when submitting + # the job to the queue. + foreach (@myargv) { + if (/\s/o ) { + $_ = q{"} . $_ . q{"}; + } + } + + + # create temp locks directory tell each job where the lock directory is. + unless ($opt_t) { + unless ($opt_L) { + $opt_L = tempdir( TEMPLATE => 'tempLocksXXXX', + DIR => $job_dir, + CLEANUP => 1); + } + $opt_L = abs_path($opt_L); + unshift(@myargv,"-L $opt_L"); + } + $cmdline = join(" ",@myargv); + $job_index = 0; + $job_log_base = $job_dir . '/job.log.'; + $opt_tests_per_job = 1 unless defined $opt_tests_per_job; + + $num_tests=0; + foreach $dir (@{$dirs_ref}) { + $job_index++; + # trailing '/'s confuse this script + $dir =~ s|/$||; + $job_log = $job_log_base . $job_index; + #use testfile so that subdirectories are not searched + $testfile = $job_dir . '/testfile.' . $job_index; + push @test_commands, $script . " -l $job_log -f $testfile -Ff $job_dir/$tool.fails.$job_index -Fs $job_dir/$tool.fails.$job_index $cmdline"; + if (!open(TESTFILE, "> $testfile")) { + print STDERR "Cannot open \"$testfile\" for writing: $!\n"; + exit(1); + } + print TESTFILE $dir; + close(TESTFILE); + $logs{$dir} = $job_log; + $num_tests++; + if ($num_tests == $opt_tests_per_job) { + push @commands, join("\n",@test_commands); + $num_tests = 0; + @test_commands = (); + } + + } + if (scalar @test_commands > 0) { + push @commands, join("\n",@test_commands); + } + $job_info_ref->{'commands'} = \@commands; + $job_info_ref->{'logs'} = \%logs; + return $job_info_ref; +} + +# +# Submit the commands to LSF +# +sub queue_jobs { + local(@commands) = @_; + $ENV{'LSB_JOB_REPORT_MAIL'}="N"; + $job_file_base = $job_dir . '/job.file.'; + $job_name_base = "run_tests.$$"; + + + $job_index = 0; + foreach $cmd (@commands) { + $job_index++; + $job_file = $job_file_base . $job_index; + if (!open(JOBFILE, "> $job_file")) { + print STDERR "Cannot open \"$job_file\" for writing: $!\n"; + exit(1); + } + print JOBFILE $cmd; + close(JOBFILE); + chmod S_IRWXU, $job_file; + } + $opt_Qx = q{bsub} unless defined $opt_Qx; + $opt_Q = q{} unless defined $opt_Q; + + $cmd_redirect = q{}; + if (!$opt_v) { + $cmd_redirect = " > /dev/null 2>&1"; + } + elsif ($opt_l) { + $cmd_redirect = " 2>&1"; + } + + $cmd = $opt_Qx .' '. $opt_Q . ' -J "' . $job_name_base . '[1-' . $job_index . ']" ' . $job_file_base . '\$LSB_JOBINDEX'; + $cmd .= $cmd_redirect; + $cmd .= '; ' . $opt_Qx . ' ' . $opt_Q . ' -K -w "ended(' . $job_name_base . ')" -J "' . $job_name_base . '.ended" date'; + $cmd .= $cmd_redirect; + system($cmd); +} +# +# Parse output logs to determine pass/fail/skip results +# +# Display on STDOUT the log output except +# for the results summary portion of the log +# +sub get_job_result { + local($dirs_ref, $logs_ref, $skips_out, $fails_out) = @_; + foreach $dir (@{$dirs_ref}) { + $log = $logs_ref->{$dir}; + $pass_fail_skip = 'INCOMPLETE'; + if (open(JOBOUTPUT, "< $log")) { + while ($_ = ) { + # Total of %d tests ............................. PASSED all tests + # Total of %d tests ............................. PASSED %d of %d tests (%d skipped) + # Total of %d tests ............................. FAILED %d of %d tests (%d skipped) + if (/Total of \d+ tests \.+ (.*)/) { + $pass_fail_skip = $1; + $test_failed_or_skipped = 0; + pop @output; # remove dashes on line that preceeds pass/fail result + if($pass_fail_skip =~ /(PASSED|FAILED) (\d+) of (\d+) tests \((\d+) skipped\)/) { + $test_failed_or_skipped = 1; + if ($1 eq 'FAILED') { + $failures+=$2; + } + $failures+=$4; #skips increment failures and are later removed from the overall fail count + $skipped+=$4; + if ($skips_out && ($4 != 0)) { + print $skips_out "$dir\n"; + } else { + print $fails_out "$dir\n"; + } + } + last; + } + chomp($_); + push(@output, $_); + } + close(JOBOUTPUT); + } + if ($pass_fail_skip eq 'INCOMPLETE') { + if (length($dir) > 43) { + $dir = "*" . substr($dir, length($dir)-43, length($dir)); + } + $dots = substr("............................................", 0, 45-length($dir)); + push(@output, "$dir $dots INCOMPLETE"); + $failures++; + if ($opt_F) { + print Fout "$dir\n"; + } + } + } + print join("\n",@output) . "\n"; +} + + +# Makes the script a "modulino": http://www.drdobbs.com/scripts-as-modules/184416165 +# i.e. a script which can behave like a module when imported or a module which can behave like a script when executed +__PACKAGE__->run() unless caller; diff --git a/admin/docs/UVM-TEST-HARNESS.md b/admin/docs/UVM-TEST-HARNESS.md new file mode 100644 index 0000000..7df0bce --- /dev/null +++ b/admin/docs/UVM-TEST-HARNESS.md @@ -0,0 +1,237 @@ +# UVM test harness documentation +=========================================================== +v0.1, * January 2017 + +*An HTML-rendered copy of this document can be found at:* + . + + +This document outlines the capabilities of the test runner used for UVM test development and +illustrates how tests can utilize the capabilities of the runner. + +--------------------------------------------------------------------- +# Recommendations +--------------------------------------------------------------------- + +Please follow the following recommendations when you create tests +so that they easily work across all tool chains, with changing versions of UVM, .. + +- prefer test.sv based tests over test.pl or makefile based tests + +- prefer self checking tests over gold file based tests + +- only have ONE test per test directory. + +- Avoid tests which run in a directory other than the current test directory + +- avoid copying post_test.pl to the test run directory and make a link instead + +- avoid marking tests explicitly with 'PASS' rather mark failing tests with 'FAIL'. + This avoids problem when multiple contradicting conditions such as PASS and FAIL + messages occur within a single test. + +--------------------------------------------------------------------- +# Prerequisites +--------------------------------------------------------------------- + +- The runner is a perl based script so it requires a 5.8+ perl. + +- The runner requires a backend for the choosen tool chain. + +- The runner may utilize make in order to start makefile based tests + +- The runner needs a uvm-core library installation and a set of tests, a test hierarchy or a file pointing to tests. + +- test.sv based tests pass a `+UVM_TESTNAME=test` to the test and therefore require that there is a test named "test" deriving from "uvm_test". + +--------------------------------------------------------------------- +# Document terminology +--------------------------------------------------------------------- + +The following syntax is used throughout the document + +- $UVM-CORE is the absolute path to the uvm installation. + +- $UVM-TESTS is the location of the uvm tests installation + +- $CHAIN refers to the tool chain. currently the supported tool chains are `ius|questa|vcs|vcsi` + +These are not environment variables. + +--------------------------------------------------------------------- +# Simple Usage +--------------------------------------------------------------------- + +The minimal arguments are the location of the uvm installation, the tool chain to use and at least one test. + +``` +cd && admin/bin/run_tests -u ius tests +``` + +--------------------------------------------------------------------- +# Locations +--------------------------------------------------------------------- + +The test runner is located here `$UVM-TESTS/admin/bin/run_tests` while the tool chain +support scripts are stored in `$UVM-TESTS/tools/$CHAIN/run_tests.pl` + + +--------------------------------------------------------------------- +# Test selection +--------------------------------------------------------------------- + +Tests are directories supplied on the command line or via a file using the `-f` option of +the runner. Each directory is considered a test and the runner will launch a simulation +within that directory given that one of the following applies: + +1. a file test.sv is present or +2. a file test.pl is present + +in that directory. + +Subdirectories of the supplied tests are scanned recursively and added to the test set ONLY +if they match the `^[0-9][0-9]` file name pattern. + + +--------------------------------------------------------------------- +# Referencing the UVM install from scripts/tests +--------------------------------------------------------------------- + +Processes forked from the test runner will have the env variable UVM_HOME set pointing to +the UVM installation being used. + +--------------------------------------------------------------------- +# Execution flow for a single test +--------------------------------------------------------------------- + +The test runner executes the test unless a file $CHAIN$.skip is present in the test directory. +The skip will be reported. Then the test is executed through the following methods + +## Flow for a test.sv based test + +1. The test is compiled and run. This step utilizes the contents of the following files + - $CHAIN.comp.args + - test.defines + - $CHAIN.run.args + - test.plusargs + +Its is upto the tool chain to use these arguments and perform the steps in a single +step or using multiple steps. + +2. the test is checked. see + +3. cleanup is performed: In this step the tool chain removes all created files. It is upto + the tool chain to define the set of files to remove. + +## Flow for a test.pl based test + +In this flow the runner executes the provided test.pl and uses the return status as test execution +status. It is upto the user to perform compile+run as necessary. + +--------------------------------------------------------------------- +# Determining test pass/fail in test.sv mode +--------------------------------------------------------------------- + +1. if no compile log is present the test is considered fail + +2. if compile errors are present the test fails unless they are expected. + If a compile time error is expected the log or error message must provide the "UVM TEST COMPILE-TIME FAILURE" as part of the log. + +3. if the test directory contains a post_test.pl file it will be executed to determine pass/fail alone. The buildin + pass failure algorithm in the next step is NOT applied. + +4. The log is scanned for the following patterns + + `UVM TEST FAILED` makes the test fail unconditionally + `UVM TEST PASS` makes the test pass unconditionally + `UVM TEST EXPECT \d+ UVM_ERROR` the test expects n UVM_ERRORS. failing to produce the errors makes the test fail. + `UVM Report Summary` missing this pattern (which is produced by UVM's summary report) makes the test fail. + +5. a $CHAIN runtime error leads to a failing simulation unless the log/message produces the magic pattern "UVM TEST RUN-TIME FAILURE" as part of the message or log. + +--------------------------------------------------------------------- +# Running makefile based simulations through test.pl +--------------------------------------------------------------------- + +The test.pl method can be used to start makefile based tests by using something like + +return &make_example("$uvm_home/examples/simple/registers/vertical_reuse"); + +This requires the Makefile.$CHAIN$ is present in the chosen directory. + +--------------------------------------------------------------------- +# Gold file based tests using post_test.pl +--------------------------------------------------------------------- + +The provided script can be used to check gold file based tests. +In order to utilize it you should make a link to the post_test.pl in the test directory pointing back to admin/bin/post_test.pl. + +The script makes the following assumptions + +1. gold files are stored in *.au or *.au.$CHAIN$ files +2. the filter will strip certain patterns from the gold and the logfile. this includes changing patterns or special $CHAIN$ specific information. +3. a gold file is compared to .au or .au.$CHAIN$ +4. if a gold file .au or .au.$CHAIN$ is present then the + file must also exist and there must be gold files for the other $CHAIN$s too. + +The combination of a logfile and gold file .au or .au.$CHAIN$ is first processed +into a file .post and .au.post (or .au.$CHAIN.post). Once processed the two resulting files are diffed using the system "diff" +command and the difference is stored in a .df file. The script reports an eventual difference between the post files as failure. + +--------------------------------------------------------------------- +# Writing a test.sv UVM test +--------------------------------------------------------------------- + +1. create a directory in the `$UVM-TESTS/tests` hierarchy. The directory name must start with at least two digits to be recognised automatically. +2. create your test in `test.sv` +3. ensure the test class inherits from uvm_test and is named "test" +4. place additional switches and arguments in the menitoned configuration files +5. emit failures using the standard UVM uvm_error and uvm_fatal macros or the uvm_report_error and uvm_report_fatal functions. +6. encode specific pass/fail logic in the `uvm_test::report method` + +?? i believe a test will pass if all required messages appear and no failure has been detected - verify ?? + + +``` +import uvm_pkg::*; +`include "uvm_macros.svh" + + +module top; + initial + run_test(); + +endmodule + +class test extends uvm_component; + `uvm_component_utils(test) + + function new(string name, uvm_component parent); + super.new(name, parent); + endfunction + + task run_phase(uvm_phase phase); + phase.raise_objection(this); + + // start your test + + phase.drop_objection(this); + endtask + + function void report_phase(uvm_phase phase); + uvm_report_server rs = uvm_report_server::get_server(); + super.report_phase(phase); + if(rs.get_severity_count(UVM_ERROR) > 0) + $display("** UVM TEST FAIL **"); + else + $display("** UVM TEST PASSED **"); + endfunction +endclass +``` +--------------------------------------------------------------------- +# Known test runner limitations +--------------------------------------------------------------------- + +- pass/fail logic: in some situation multiple contradicting status information can be obtained from log or exit status +(or other contributing places). This may lead to incorrect pass/fail status. As a safe measure you should only make tests +explicitly failed but never explicitly pass. diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..2ac01cc --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,11 @@ +*.log +*.fails +transcript +*.swp +irun.history +indago.history +cov_work +ida.db +.dvt + + diff --git a/tests/00basic/00hello/test.sv b/tests/00basic/00hello/test.sv new file mode 100644 index 0000000..2497518 --- /dev/null +++ b/tests/00basic/00hello/test.sv @@ -0,0 +1,49 @@ +//---------------------------------------------------------------------- +// Copyright 2011-2018 Cadence Design Systems, Inc. +// Copyright 2010-2011 Mentor Graphics Corporation +// Copyright 2017 NVIDIA Corporation +// Copyright 2010-2011 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +`include "uvm_macros.svh" +import uvm_pkg::*; + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual function void report_phase(uvm_phase phase); + super.report_phase(phase); + $write("** UVM TEST PASSED **\n"); + endfunction +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/00basic/01compfail/test.sv b/tests/00basic/01compfail/test.sv new file mode 100644 index 0000000..e5be91d --- /dev/null +++ b/tests/00basic/01compfail/test.sv @@ -0,0 +1,36 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +// +// This test is an example of an expected compile-time failure +// + +program top; + +import uvm_pkg::*; + +initial +begin + uvm_component comp; + comp = UVM_NONE; // UVM TEST COMPILE-TIME FAILURE +end + +endprogram diff --git a/tests/00basic/02runfail/test.sv b/tests/00basic/02runfail/test.sv new file mode 100644 index 0000000..89bbaa4 --- /dev/null +++ b/tests/00basic/02runfail/test.sv @@ -0,0 +1,50 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2017 NVIDIA Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +// +// This test is an example of an expected run-time failure +// + +program top; + +import uvm_pkg::*; + +class objA extends uvm_object; +endclass + +class objB extends uvm_object; +endclass + +initial +begin + objA a; + objB b; + uvm_object obj; + + a = new; + obj = a; + $display("** UVM TEST PASSED **"); + $display("** UVM TEST EXPECT NO SUMMARY **"); + $cast(b, obj); // UVM TEST RUN-TIME FAILURE +end + +endprogram diff --git a/tests/00basic/03error/test.sv b/tests/00basic/03error/test.sv new file mode 100644 index 0000000..fc41065 --- /dev/null +++ b/tests/00basic/03error/test.sv @@ -0,0 +1,57 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2012 AMD +// Copyright 2010 Mentor Graphics Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; +`include "uvm_macros.svh" + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + phase.raise_objection(this); + `uvm_error("Test", "Error 1..."); + `uvm_error("Test", "Error 2..."); + `uvm_error("Test", "Error 3..."); + $write("UVM TEST EXPECT 3 UVM_ERROR\n"); + phase.drop_objection(this); + endtask + + virtual function void report_phase(uvm_phase phase); + $write("** UVM TEST PASSED **\n"); + endfunction +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/00basic/06plusargs/test.defines b/tests/00basic/06plusargs/test.defines new file mode 100644 index 0000000..bdaf201 --- /dev/null +++ b/tests/00basic/06plusargs/test.defines @@ -0,0 +1 @@ ++define+BAR diff --git a/tests/00basic/06plusargs/test.plusargs b/tests/00basic/06plusargs/test.plusargs new file mode 100644 index 0000000..f88fb0e --- /dev/null +++ b/tests/00basic/06plusargs/test.plusargs @@ -0,0 +1,3 @@ ++foo ++OK ++bar diff --git a/tests/00basic/06plusargs/test.sv b/tests/00basic/06plusargs/test.sv new file mode 100644 index 0000000..717991d --- /dev/null +++ b/tests/00basic/06plusargs/test.sv @@ -0,0 +1,55 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2012 AMD +// Copyright 2010 Mentor Graphics Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; +`include "uvm_macros.svh" + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + endtask + + virtual function void report_phase(uvm_phase phase); +`ifdef BAR + if ($test$plusargs("OK")) $write("** UVM TEST PASSED **\n"); + else +`endif + $write("** UVM TEST FAILED **\n"); + endfunction +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/00basic/07toolargs/ius.comp.args b/tests/00basic/07toolargs/ius.comp.args new file mode 100644 index 0000000..574714c --- /dev/null +++ b/tests/00basic/07toolargs/ius.comp.args @@ -0,0 +1,2 @@ ++define+FOO + diff --git a/tests/00basic/07toolargs/ius.run.args b/tests/00basic/07toolargs/ius.run.args new file mode 100644 index 0000000..729a260 --- /dev/null +++ b/tests/00basic/07toolargs/ius.run.args @@ -0,0 +1 @@ ++Good diff --git a/tests/00basic/07toolargs/questa.comp.args b/tests/00basic/07toolargs/questa.comp.args new file mode 100644 index 0000000..574714c --- /dev/null +++ b/tests/00basic/07toolargs/questa.comp.args @@ -0,0 +1,2 @@ ++define+FOO + diff --git a/tests/00basic/07toolargs/questa.run.args b/tests/00basic/07toolargs/questa.run.args new file mode 100644 index 0000000..729a260 --- /dev/null +++ b/tests/00basic/07toolargs/questa.run.args @@ -0,0 +1 @@ ++Good diff --git a/tests/00basic/07toolargs/test.defines b/tests/00basic/07toolargs/test.defines new file mode 100644 index 0000000..bdaf201 --- /dev/null +++ b/tests/00basic/07toolargs/test.defines @@ -0,0 +1 @@ ++define+BAR diff --git a/tests/00basic/07toolargs/test.plusargs b/tests/00basic/07toolargs/test.plusargs new file mode 100644 index 0000000..f88fb0e --- /dev/null +++ b/tests/00basic/07toolargs/test.plusargs @@ -0,0 +1,3 @@ ++foo ++OK ++bar diff --git a/tests/00basic/07toolargs/test.sv b/tests/00basic/07toolargs/test.sv new file mode 100644 index 0000000..9872940 --- /dev/null +++ b/tests/00basic/07toolargs/test.sv @@ -0,0 +1,59 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2012 AMD +// Copyright 2010 Mentor Graphics Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; +`include "uvm_macros.svh" + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + endtask + + virtual function void report_phase(uvm_phase phase); +`ifdef FOO +`ifdef BAR + if ($test$plusargs("OK") && + $test$plusargs("Good")) + $write("** UVM TEST PASSED **\n"); + else +`endif +`endif + $write("** UVM TEST FAILED **\n"); + endfunction +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/00basic/07toolargs/vcs.comp.args b/tests/00basic/07toolargs/vcs.comp.args new file mode 100644 index 0000000..574714c --- /dev/null +++ b/tests/00basic/07toolargs/vcs.comp.args @@ -0,0 +1,2 @@ ++define+FOO + diff --git a/tests/00basic/07toolargs/vcs.run.args b/tests/00basic/07toolargs/vcs.run.args new file mode 100644 index 0000000..729a260 --- /dev/null +++ b/tests/00basic/07toolargs/vcs.run.args @@ -0,0 +1 @@ ++Good diff --git a/tests/00basic/07toolargs/xcelium.comp.args b/tests/00basic/07toolargs/xcelium.comp.args new file mode 100644 index 0000000..574714c --- /dev/null +++ b/tests/00basic/07toolargs/xcelium.comp.args @@ -0,0 +1,2 @@ ++define+FOO + diff --git a/tests/00basic/07toolargs/xcelium.run.args b/tests/00basic/07toolargs/xcelium.run.args new file mode 100644 index 0000000..729a260 --- /dev/null +++ b/tests/00basic/07toolargs/xcelium.run.args @@ -0,0 +1 @@ ++Good diff --git a/tests/00basic/10post_test/post_test.pl b/tests/00basic/10post_test/post_test.pl new file mode 100644 index 0000000..64304c7 --- /dev/null +++ b/tests/00basic/10post_test/post_test.pl @@ -0,0 +1,39 @@ +##---------------------------------------------------------------------- +## Copyright 2018 Cadence Design Systems, Inc. +## Copyright 2010 Synopsys, Inc. +## All Rights Reserved Worldwide +## +## Licensed under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of +## the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in +## writing, software distributed under the License is +## distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +## CONDITIONS OF ANY KIND, either express or implied. See +## the License for the specific language governing +## permissions and limitations under the License. +##---------------------------------------------------------------------- + + +# +# Available variables: +# +# $log Path and name of run-time log file +# $testdir Path to test directory +# +# Return: +# +# $post_test Reason for success (or failure) +# 1 If test passes +# 0 If test fails + +if (! -e $log) { + $post_test = "No logfile"; + return 1; +} + +return 0; diff --git a/tests/00basic/10post_test/test.sv b/tests/00basic/10post_test/test.sv new file mode 100644 index 0000000..6458549 --- /dev/null +++ b/tests/00basic/10post_test/test.sv @@ -0,0 +1,51 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2012 AMD +// Copyright 2010 Mentor Graphics Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; +`include "uvm_macros.svh" + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + endtask + + virtual function void report_phase(uvm_phase phase); + $write("** UVM TEST FAILED **\n"); + endfunction +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/00basic/20subgroup/10subsub/10subsubsub/test.sv b/tests/00basic/20subgroup/10subsub/10subsubsub/test.sv new file mode 100644 index 0000000..82da545 --- /dev/null +++ b/tests/00basic/20subgroup/10subsub/10subsubsub/test.sv @@ -0,0 +1,51 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2012 AMD +// Copyright 2010 Mentor Graphics Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; +`include "uvm_macros.svh" + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + endtask + + virtual function void report_phase(uvm_phase phase); + $write("** UVM TEST PASSED **\n"); + endfunction +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/00basic/20subgroup/10subsub/test.sv b/tests/00basic/20subgroup/10subsub/test.sv new file mode 100644 index 0000000..82da545 --- /dev/null +++ b/tests/00basic/20subgroup/10subsub/test.sv @@ -0,0 +1,51 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2012 AMD +// Copyright 2010 Mentor Graphics Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; +`include "uvm_macros.svh" + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + endtask + + virtual function void report_phase(uvm_phase phase); + $write("** UVM TEST PASSED **\n"); + endfunction +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/00basic/20subgroup/20subsub/10subsubsub/test.sv b/tests/00basic/20subgroup/20subsub/10subsubsub/test.sv new file mode 100644 index 0000000..82da545 --- /dev/null +++ b/tests/00basic/20subgroup/20subsub/10subsubsub/test.sv @@ -0,0 +1,51 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2012 AMD +// Copyright 2010 Mentor Graphics Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; +`include "uvm_macros.svh" + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + endtask + + virtual function void report_phase(uvm_phase phase); + $write("** UVM TEST PASSED **\n"); + endfunction +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/00basic/20subgroup/test.sv b/tests/00basic/20subgroup/test.sv new file mode 100644 index 0000000..82da545 --- /dev/null +++ b/tests/00basic/20subgroup/test.sv @@ -0,0 +1,51 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2012 AMD +// Copyright 2010 Mentor Graphics Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; +`include "uvm_macros.svh" + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + endtask + + virtual function void report_phase(uvm_phase phase); + $write("** UVM TEST PASSED **\n"); + endfunction +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/00basic/25typename/irun.log.au.ius b/tests/00basic/25typename/irun.log.au.ius new file mode 100644 index 0000000..4f42848 --- /dev/null +++ b/tests/00basic/25typename/irun.log.au.ius @@ -0,0 +1 @@ +SCOPE::foo#(SCOPE::bar#(SCOPE::xyz),88) extends SCOPE::bar#(SCOPE::xyz) diff --git a/tests/00basic/25typename/irun.log.au.xcelium b/tests/00basic/25typename/irun.log.au.xcelium new file mode 100644 index 0000000..4f42848 --- /dev/null +++ b/tests/00basic/25typename/irun.log.au.xcelium @@ -0,0 +1 @@ +SCOPE::foo#(SCOPE::bar#(SCOPE::xyz),88) extends SCOPE::bar#(SCOPE::xyz) diff --git a/tests/00basic/25typename/post_test.pl b/tests/00basic/25typename/post_test.pl new file mode 120000 index 0000000..4f76883 --- /dev/null +++ b/tests/00basic/25typename/post_test.pl @@ -0,0 +1 @@ +../../../admin/bin/post_test.pl \ No newline at end of file diff --git a/tests/00basic/25typename/run.log.au.questa b/tests/00basic/25typename/run.log.au.questa new file mode 100644 index 0000000..adc5a3e --- /dev/null +++ b/tests/00basic/25typename/run.log.au.questa @@ -0,0 +1 @@ +class foo #(class bar #(class xyz), 88) diff --git a/tests/00basic/25typename/simv.log.au.vcs b/tests/00basic/25typename/simv.log.au.vcs new file mode 100644 index 0000000..e8fd020 --- /dev/null +++ b/tests/00basic/25typename/simv.log.au.vcs @@ -0,0 +1 @@ +class $unit::foo#(class $unit::bar#(class $unit::xyz),88) diff --git a/tests/00basic/25typename/test.sv b/tests/00basic/25typename/test.sv new file mode 100644 index 0000000..5bb02a8 --- /dev/null +++ b/tests/00basic/25typename/test.sv @@ -0,0 +1,37 @@ + +`include "uvm_macros.svh" +import uvm_pkg::*; + + +class xyz; endclass + +class bar #(type T=int); endclass + +class foo #(type T=int, int W=24) extends T; endclass + +class test extends uvm_test; + `uvm_component_utils(test) + test list[2]; + + function new(string name, uvm_component parent=null); + string typename,exp_typename; + foo #(bar#(xyz),88) f; + bar #(xyz) b; + + super.new(name,parent); + + f = new; + b = f; + + + typename = `uvm_typename(f); + + $display("\nGOLD-FILE-START\n",typename,"\nGOLD-FILE-END\n"); + endfunction +endclass + +module top; + initial + run_test(); +endmodule + diff --git a/tests/00basic/30static_init/test.sv b/tests/00basic/30static_init/test.sv new file mode 100644 index 0000000..645543e --- /dev/null +++ b/tests/00basic/30static_init/test.sv @@ -0,0 +1,141 @@ +//---------------------------------------------------------------------- +// Copyright 2011-2018 Cadence Design Systems, Inc. +// Copyright 2010-2011 Mentor Graphics Corporation +// Copyright 2017 NVIDIA Corporation +// Copyright 2010-2011 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +`include "uvm_macros.svh" +import uvm_pkg::*; + +class test extends uvm_component; + `uvm_component_utils(test) + function new(string name, uvm_component parent); + super.new(name, parent); + endfunction : new + + function void final_phase(uvm_phase phase); + super.final_phase(phase); + `uvm_info("PASS", "** UVM TEST PASSED **", UVM_NONE) + endfunction : final_phase +endclass : test + + // Need to extend root so it can be arbitrarily instanced +class my_root extends uvm_root; + function new(); + super.new(); + endfunction : new + +endclass : my_root + + // this coreservice type initializes everything inside of + // its constructor (instead of deferring to the get() calls) +class my_coreservice_t extends uvm_default_coreservice_t; + // Variables for storing the core types + uvm_root r_inst; + uvm_factory f_inst; + uvm_report_server rs_inst; + uvm_tr_database trdb_inst; + uvm_visitor#(uvm_component) vis_inst; + uvm_printer prt_inst; + uvm_packer pkr_inst; + uvm_comparer cmp_inst; + uvm_copier cpy_inst; + uvm_resource_pool rp_inst; + + function new(); + my_root r; + super.new(); + + begin my_root r =new(); r_inst =r; end + begin uvm_default_factory r = new(); f_inst=r; end + begin uvm_default_report_server r = new(); rs_inst = r; end + begin uvm_text_tr_database r = new(); trdb_inst=r; end + begin uvm_component_name_check_visitor r = new(); vis_inst=r; end + begin uvm_table_printer r =new(); prt_inst =r; end + pkr_inst = new(); + cmp_inst = new(); + cpy_inst = new(); + rp_inst = new(); + endfunction : new + + virtual function uvm_root get_root(); + return r_inst; + endfunction : get_root + + virtual function uvm_factory get_factory(); + return f_inst; + endfunction : get_factory + + virtual function uvm_report_server get_report_server(); + return rs_inst; + endfunction : get_report_server + + virtual function uvm_tr_database get_default_tr_database(); + return trdb_inst; + endfunction : get_default_tr_database + + virtual function uvm_visitor#(uvm_component) get_component_visitor(); + return vis_inst; + endfunction : get_component_visitor + + virtual function uvm_printer get_default_printer(); + return prt_inst; + endfunction : get_default_printer + + virtual function uvm_packer get_default_packer(); + return pkr_inst; + endfunction : get_default_packer + + virtual function uvm_comparer get_default_comparer(); + return cmp_inst; + endfunction : get_default_comparer + + virtual function uvm_copier get_default_copier(); + return cpy_inst; + endfunction : get_default_copier + + virtual function uvm_resource_pool get_resource_pool(); + return rp_inst; + endfunction : get_resource_pool + +endclass : my_coreservice_t + + + // The coreservice is instanced during static init, but + // uvm_init isn't called until later. + my_coreservice_t my_cs = new(); + +initial + begin + // if any of the creations in my_coreservice_t resulted in + // a uvm_coreservice_t::get() call, then the next uvm_init + // will be ignored. As such, the if statement would fail + // the test. + uvm_init(my_cs); + if (uvm_coreservice_t::get() != my_cs) + `uvm_fatal("FAIL", "Not the right core service!") + + run_test(); + + end + +endprogram diff --git a/tests/00basic/40split_string/test.sv b/tests/00basic/40split_string/test.sv new file mode 100644 index 0000000..a71939e --- /dev/null +++ b/tests/00basic/40split_string/test.sv @@ -0,0 +1,39 @@ +module test(); + import uvm_pkg::*; + + `include "uvm_macros.svh" + + function bit check(string src, dest[$]); + string tmp[$]; + uvm_string_split(src, ",", tmp); + if (tmp != dest) begin + `uvm_error("FAIL", $sformatf("'%s' yielded '%p', but expected '%p'", + src, + tmp, + dest)) + return 0; + end + else begin + `uvm_info("GOOD", $sformatf("'%s' successfully produced '%p'", + src, + dest), UVM_NONE) + return 1; + end + endfunction : check + + initial begin + bit pass; + $display("** UVM TEST EXPECT NO SUMMARY **"); + pass = 1; + pass &= check(",", '{"",""}); + pass &= check("1,,2", '{"1","","2"}); + pass &= check("", '{""}); + pass &= check(",foo,,", '{"","foo","",""}); + if (!pass) + $display("** UVM TEST FAILED **"); + else + $display("** UVM TEST PASSED **"); + end // initial begin + +endmodule // test + diff --git a/tests/00basic/99compat/7455/test.sv b/tests/00basic/99compat/7455/test.sv new file mode 100644 index 0000000..61dcfbc --- /dev/null +++ b/tests/00basic/99compat/7455/test.sv @@ -0,0 +1,73 @@ +package test_pkg; + +import uvm_pkg::*; +`include "uvm_macros.svh" + +class test extends uvm_component; + +`uvm_component_utils(test) + +int check_count; +int error_count; + +function new(string name = "test", uvm_component parent = null); + super.new(name, parent); + check_count = 0; + error_count = 0; +endfunction + +task run_phase(uvm_phase phase); + `define to_string(x) `"x`" + if(`to_string(`UVM_NAME) != "UVM") error_count++; + if(`UVM_MAJOR_REV != 2020) error_count++; + if(`UVM_MINOR_REV != 2.0) error_count++; + if(`to_string(`UVM_VERSION_STRING) != "uvm_pkg::UVM_VERSION_STRING") error_count++; + $display("define: %s variable %s", `to_string(`UVM_VERSION_STRING), uvm_pkg::UVM_VERSION_STRING); + $display("define: %s variable %s", `to_string(`UVM_VERSION_STRING), uvm_revision_string()); + `ifdef UVM_POST_VERSION_1_1 + check_count++; + `endif + `ifdef UVM_POST_VERSION_1_2 + check_count++; + `endif + `ifdef UVM_VERSION_POST_2017_1_0 + check_count++; + `endif + `ifdef UVM_VERSION_POST_2017_1_1 + check_count++; + `endif + `ifdef UVM_VERSION_POST_2020_1_0 + check_count++; + `endif + `ifdef UVM_VERSION_POST_2020_1_1 + check_count++; + `endif + `ifdef UVM_VERSION_POST_2017 + check_count++; + `endif +endtask + +function void report_phase(uvm_phase phase); + if((error_count == 0) && (check_count == 7)) begin + `uvm_info("UVM TEST PASSED", "Back compat macro version ladder checks out OK", UVM_MEDIUM) + end + else begin + `uvm_error("UVM TEST FAILED", "Error in back compat macro version ladder") + $display("errors:%0d checks:%0d", error_count, check_count); + end +endfunction + +endclass + +endpackage + +module test; + +import uvm_pkg::*; +import test_pkg::*; + +initial begin + run_test("test"); +end + +endmodule diff --git a/tests/00basic/99compat/7528_split_string/test.sv b/tests/00basic/99compat/7528_split_string/test.sv new file mode 100644 index 0000000..c695547 --- /dev/null +++ b/tests/00basic/99compat/7528_split_string/test.sv @@ -0,0 +1,39 @@ +module test(); + import uvm_pkg::*; + + `include "uvm_macros.svh" + + function bit check(string src, dest[$]); + string tmp[$]; + uvm_split_string(src, ",", tmp); + if (tmp != dest) begin + `uvm_error("FAIL", $sformatf("'%s' yielded '%p', but expected '%p'", + src, + tmp, + dest)) + return 0; + end + else begin + `uvm_info("GOOD", $sformatf("'%s' successfully produced '%p'", + src, + dest), UVM_NONE) + return 1; + end + endfunction : check + + initial begin + bit pass; + $display("** UVM TEST EXPECT NO SUMMARY **"); + pass = 1; + pass &= check(",", '{}); + pass &= check("1,,2", '{"1","2"}); + pass &= check("", '{}); + pass &= check(",foo,,", '{"foo"}); + if (!pass) + $display("** UVM TEST FAILED **"); + else + $display("** UVM TEST PASSED **"); + end // initial begin + +endmodule // test + diff --git a/tests/95issues/README.md b/tests/95issues/README.md new file mode 100644 index 0000000..cd90148 --- /dev/null +++ b/tests/95issues/README.md @@ -0,0 +1,7 @@ +This directory is provided as a base for any tests used to verify issues posted on the GitHub [Issue Tracker](https://github.com/accellera-official/uvm-core/issues). + +Please create a directory for each issue, starting with the issue ## and using a short unique identifier. For example, [accellera-official#6](https://github.com/accellera-official/uvm-core/issues/6) would be in `${UVM_TESTS}/tests/95issues/06static_races/`. + +**Note:** A directory name MUST start with 2 or more numerals for the run_test script to see it, a directory name of `6static_races` would note be seen. + +If multiple tests are required for a single issue, then each test should be in a separate `##test_name` directory below the `##short_uid` directory. E.g. `${UVM_TESTS}/tests/95issues/06static_races/00test_foo` diff --git a/tests/XXfail/00nopass/test.sv b/tests/XXfail/00nopass/test.sv new file mode 100644 index 0000000..9f3ad5d --- /dev/null +++ b/tests/XXfail/00nopass/test.sv @@ -0,0 +1,47 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2017 NVIDIA Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + uvm_top.stop_request(); + endtask + +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/XXfail/01fatal/test.sv b/tests/XXfail/01fatal/test.sv new file mode 100644 index 0000000..93d72d2 --- /dev/null +++ b/tests/XXfail/01fatal/test.sv @@ -0,0 +1,51 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2017 NVIDIA Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + `uvm_fatal("Test", "Fatal error..."); + uvm_top.stop_request(); + endtask + + virtual function void report(); + $write("** UVM TEST PASSED **\n"); + endfunction +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/XXfail/02error/test.sv b/tests/XXfail/02error/test.sv new file mode 100644 index 0000000..8760da3 --- /dev/null +++ b/tests/XXfail/02error/test.sv @@ -0,0 +1,51 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2017 NVIDIA Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + `uvm_error("Test", "Error..."); + uvm_top.stop_request(); + endtask + + virtual function void report(); + $write("** UVM TEST PASSED **\n"); + endfunction +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/XXfail/03error/test.sv b/tests/XXfail/03error/test.sv new file mode 100644 index 0000000..c0ede86 --- /dev/null +++ b/tests/XXfail/03error/test.sv @@ -0,0 +1,54 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2017 NVIDIA Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + `uvm_error("Test", "Error 1..."); + `uvm_error("Test", "Error 2..."); + `uvm_error("Test", "Error 3..."); + $write("UVM TEST EXPECT 5 UVM_ERROR\n"); + uvm_top.stop_request(); + endtask + + virtual function void report(); + $write("** UVM TEST PASSED **\n"); + endfunction +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/XXfail/05failed/test.sv b/tests/XXfail/05failed/test.sv new file mode 100644 index 0000000..df85c37 --- /dev/null +++ b/tests/XXfail/05failed/test.sv @@ -0,0 +1,49 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2017 NVIDIA Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + $write("UVM TEST PASSED\n"); + $write("UVM TEST FAILED\n"); + uvm_top.stop_request(); + endtask + +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/XXfail/10comfail/test.sv b/tests/XXfail/10comfail/test.sv new file mode 100644 index 0000000..3130361 --- /dev/null +++ b/tests/XXfail/10comfail/test.sv @@ -0,0 +1,32 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; + +initial +begin + uvm_component comp; + comp = UVM_NONE; +end + +endprogram diff --git a/tests/XXfail/20runfail/test.sv b/tests/XXfail/20runfail/test.sv new file mode 100644 index 0000000..3d149a5 --- /dev/null +++ b/tests/XXfail/20runfail/test.sv @@ -0,0 +1,47 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +// +// This test is an example of an expected run-time failure +// + +program top; + +import uvm_pkg::*; + +class objA extends uvm_object; +endclass + +class objB extends uvm_object; +endclass + +initial +begin + objA a; + objB b; + uvm_object obj; + + a = new; + obj = a; + $cast(b, obj); +end + +endprogram diff --git a/tests/XXfail/30postcompfail/post_test.pl b/tests/XXfail/30postcompfail/post_test.pl new file mode 100644 index 0000000..fc19a8b --- /dev/null +++ b/tests/XXfail/30postcompfail/post_test.pl @@ -0,0 +1,34 @@ +##---------------------------------------------------------------------- +## Copyright 2018 Cadence Design Systems, Inc. +## Copyright 2010 Synopsys, Inc. +## All Rights Reserved Worldwide +## +## Licensed under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of +## the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in +## writing, software distributed under the License is +## distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +## CONDITIONS OF ANY KIND, either express or implied. See +## the License for the specific language governing +## permissions and limitations under the License. +##---------------------------------------------------------------------- + + +# +# Available variables: +# +# $log Path and name of run-time log file +# $testdir Path to test directory +# +# Return: +# +# $post_test Reason for success (or failure) +# 1 If test passes +# 0 If test fails + +0; diff --git a/tests/XXfail/30postcompfail/test.sv b/tests/XXfail/30postcompfail/test.sv new file mode 100644 index 0000000..3130361 --- /dev/null +++ b/tests/XXfail/30postcompfail/test.sv @@ -0,0 +1,32 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; + +initial +begin + uvm_component comp; + comp = UVM_NONE; +end + +endprogram diff --git a/tests/XXfail/31postfail/post_test.pl b/tests/XXfail/31postfail/post_test.pl new file mode 100644 index 0000000..ba7ccb9 --- /dev/null +++ b/tests/XXfail/31postfail/post_test.pl @@ -0,0 +1,35 @@ +##---------------------------------------------------------------------- +## Copyright 2018 Cadence Design Systems, Inc. +## Copyright 2010 Synopsys, Inc. +## All Rights Reserved Worldwide +## +## Licensed under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of +## the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in +## writing, software distributed under the License is +## distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +## CONDITIONS OF ANY KIND, either express or implied. See +## the License for the specific language governing +## permissions and limitations under the License. +##---------------------------------------------------------------------- + + +# +# Available variables: +# +# $log Path and name of run-time log file +# $testdir Path to test directory +# +# Return: +# +# $post_test Reason for success (or failure) +# 1 If test passes +# 0 If test fails + +$post_test = "Forced post-failure"; +1; diff --git a/tests/XXfail/31postfail/test.sv b/tests/XXfail/31postfail/test.sv new file mode 100644 index 0000000..9478498 --- /dev/null +++ b/tests/XXfail/31postfail/test.sv @@ -0,0 +1,50 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2017 NVIDIA Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + uvm_top.stop_request(); + endtask + + virtual function void report(); + $write("** UVM TEST PASSED **\n"); + endfunction +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/XXfail/32postbad/post_test.pl b/tests/XXfail/32postbad/post_test.pl new file mode 100644 index 0000000..fb1b5ed --- /dev/null +++ b/tests/XXfail/32postbad/post_test.pl @@ -0,0 +1,22 @@ +##---------------------------------------------------------------------- +## Copyright 2018 Cadence Design Systems, Inc. +## Copyright 2010 Synopsys, Inc. +## All Rights Reserved Worldwide +## +## Licensed under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of +## the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in +## writing, software distributed under the License is +## distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +## CONDITIONS OF ANY KIND, either express or implied. See +## the License for the specific language governing +## permissions and limitations under the License. +##---------------------------------------------------------------------- + + +$if SYNTAX ERROR; diff --git a/tests/XXfail/32postbad/test.sv b/tests/XXfail/32postbad/test.sv new file mode 100644 index 0000000..9478498 --- /dev/null +++ b/tests/XXfail/32postbad/test.sv @@ -0,0 +1,50 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2017 NVIDIA Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + uvm_top.stop_request(); + endtask + + virtual function void report(); + $write("** UVM TEST PASSED **\n"); + endfunction +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tests/XXfail/33postpoor/post_test.pl b/tests/XXfail/33postpoor/post_test.pl new file mode 100644 index 0000000..afa8bf2 --- /dev/null +++ b/tests/XXfail/33postpoor/post_test.pl @@ -0,0 +1,21 @@ +##---------------------------------------------------------------------- +## Copyright 2018 Cadence Design Systems, Inc. +## Copyright 2010 Synopsys, Inc. +## All Rights Reserved Worldwide +## +## Licensed under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of +## the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in +## writing, software distributed under the License is +## distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +## CONDITIONS OF ANY KIND, either express or implied. See +## the License for the specific language governing +## permissions and limitations under the License. +##---------------------------------------------------------------------- + + diff --git a/tests/XXfail/33postpoor/test.sv b/tests/XXfail/33postpoor/test.sv new file mode 100644 index 0000000..9478498 --- /dev/null +++ b/tests/XXfail/33postpoor/test.sv @@ -0,0 +1,50 @@ +//---------------------------------------------------------------------- +// Copyright 2018 Cadence Design Systems, Inc. +// Copyright 2017 NVIDIA Corporation +// Copyright 2010 Synopsys, Inc. +// All Rights Reserved Worldwide +// +// Licensed under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of +// the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in +// writing, software distributed under the License is +// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See +// the License for the specific language governing +// permissions and limitations under the License. +//---------------------------------------------------------------------- + + +program top; + +import uvm_pkg::*; + +class test extends uvm_test; + + `uvm_component_utils(test) + + function new(string name, uvm_component parent = null); + super.new(name, parent); + endfunction + + virtual task run_phase(uvm_phase phase); + uvm_top.stop_request(); + endtask + + virtual function void report(); + $write("** UVM TEST PASSED **\n"); + endfunction +endclass + + +initial + begin + run_test(); + end + +endprogram diff --git a/tools/README.txt b/tools/README.txt new file mode 100644 index 0000000..7af10a3 --- /dev/null +++ b/tools/README.txt @@ -0,0 +1,12 @@ +This directory contains tool-specific implementations, script, code, +etc... + +It is not part of the UVM standard and none of its content is +distributed by Accellera. + +Vendors are responsible for the content of their respective tool-specific +sub-directory. + +Refer to the README.txt file in each of the tool-specific directory for +any tool-specific setup instructions. + diff --git a/tools/clean/run_test.pl b/tools/clean/run_test.pl new file mode 100644 index 0000000..09e3cca --- /dev/null +++ b/tools/clean/run_test.pl @@ -0,0 +1,99 @@ +##---------------------------------------------------------------------- +## Copyright 2018 Cadence Design Systems, Inc. +## Copyright 2010 Synopsys, Inc. +## All Rights Reserved Worldwide +## +## Licensed under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of +## the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in +## writing, software distributed under the License is +## distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +## CONDITIONS OF ANY KIND, either express or implied. See +## the License for the specific language governing +## permissions and limitations under the License. +##---------------------------------------------------------------------- + +# +# Simulator-Specific test running script +# +# Dummy "CLEAN" simulator that cleans up all log files +# + +# +# Run the test implemented by the file named "test.sv" located +# in the specified directory, using the specified compile-time +# and run-time command-line options +# +# The specified directory must also be used as the CWD for the +# simulation run. +# +# Run silently, unless $opt_v is specified. +# +sub run_the_test { + local($testdir, $comptime, $runtime, $_) = @_; + + system("cd $testdir; rm -f *.log *~ *.bak #*#"); +} + + +# +# Return the name of the compile-time logfile +# +sub comptime_log_fname { + return "!"; +} + + +# +# Return the name of the run-time logfile +# +sub runtime_log_fname { + return "!"; +} + + +# +# Return a list of filename & line numbers with compile-time errors +# for the test in the specified directory as an array, where each element +# is of the format "fname#lineno" +# +# e.g. ("test.sv#25" "test.sv#30") +# +sub get_compiletime_errors { + local($testdir, $_) = @_; + return (); +} + + +# +# Return a list of filename & line numbers with run-time errors +# for the test in the specified directory as an array, where each element +# is of the format "fname#lineno" +# +# e.g. ("test.sv#25" "test.sv#30") +# +# Run-time errors here refers to errors identified and reported by the +# simulator, not UVM run-time reports. +# +sub get_runtime_errors { + local($testdir, $_) = @_; + return (); +} + + +# +# Clean-up all files created by the simulation, +# except the log files +# +sub cleanup_test { + local($testdir, $_) = @_; + + &run_the_test($testdir); +} + +1; diff --git a/tools/echo/run_test.pl b/tools/echo/run_test.pl new file mode 100644 index 0000000..c0c3aaf --- /dev/null +++ b/tools/echo/run_test.pl @@ -0,0 +1,107 @@ +##---------------------------------------------------------------------- +## Copyright 2018 Cadence Design Systems, Inc. +## Copyright 2010 Synopsys, Inc. +## All Rights Reserved Worldwide +## +## Licensed under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of +## the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in +## writing, software distributed under the License is +## distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +## CONDITIONS OF ANY KIND, either express or implied. See +## the License for the specific language governing +## permissions and limitations under the License. +##---------------------------------------------------------------------- + +# +# Simulator-Specific test running script +# +# Dummy "ECHO" simulator that forces a "pass" +# + +# +# Run the test implemented by the file named "test.sv" located +# in the specified directory, using the specified compile-time +# and run-time command-line options +# +# The specified directory must also be used as the CWD for the +# simulation run. +# +# Run silently, unless $opt_v is specified. +# +sub run_the_test { + local($testdir, $comptime, $runtime, $_) = @_; + + $echo = "echo \'** UVM TEST PASSED **\'"; + + print $echo,"\n" if $opt_v; + system("cd $testdir; $echo > echo.log"); + system("cd $testdir; echo \'Cargs: \"$comptime\"\' >> echo.log"); + system("cd $testdir; echo \'Rargs: \"$runtime\"\' >> echo.log"); + system("cd $testdir; echo '--- UVM Report Summary ---' >> echo.log"); + system("cd $testdir; echo 'UVM_ERROR : 0' >> echo.log"); + system("cd $testdir; echo 'UVM_FATAL : 0' >> echo.log"); +} + + +# +# Return the name of the compile-time logfile +# +sub comptime_log_fname { + return "echo.log"; +} + + +# +# Return the name of the run-time logfile +# +sub runtime_log_fname { + return "echo.log"; +} + + +# +# Return a list of filename & line numbers with compile-time errors +# for the test in the specified directory as an array, where each element +# is of the format "fname#lineno" +# +# e.g. ("test.sv#25" "test.sv#30") +# +sub get_compiletime_errors { + local($testdir, $_) = @_; + return (); +} + + +# +# Return a list of filename & line numbers with run-time errors +# for the test in the specified directory as an array, where each element +# is of the format "fname#lineno" +# +# e.g. ("test.sv#25" "test.sv#30") +# +# Run-time errors here refers to errors identified and reported by the +# simulator, not UVM run-time reports. +# +sub get_runtime_errors { + local($testdir, $_) = @_; + return (); +} + + +# +# Clean-up all files created by the simulation, +# except the log files +# +sub cleanup_test { + local($testdir, $_) = @_; + + system("cd $testdir;"); +} + +1; diff --git a/tools/ius/README.txt b/tools/ius/README.txt new file mode 100644 index 0000000..d3c350e --- /dev/null +++ b/tools/ius/README.txt @@ -0,0 +1,6 @@ +Copyright 2010-2011 Cadence Design Systems, Inc. + + IUS-specific installation instructions for UVM + + +1. Nothing specific is required by IUS diff --git a/tools/ius/run_test.pl b/tools/ius/run_test.pl new file mode 100644 index 0000000..da692c8 --- /dev/null +++ b/tools/ius/run_test.pl @@ -0,0 +1,197 @@ +##---------------------------------------------------------------------- +## Copyright 2010-2018 Cadence Design Systems, Inc. +## Copyright 2010 AMD +## Copyright 2010-2011 Synopsys, Inc. +## All Rights Reserved Worldwide +## +## Licensed under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of +## the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in +## writing, software distributed under the License is +## distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +## CONDITIONS OF ANY KIND, either express or implied. See +## the License for the specific language governing +## permissions and limitations under the License. +##---------------------------------------------------------------------- +use Cwd 'realpath'; +use Data::Dumper; + +# +# IUS-Specific test running script +# + +# +# Make sure the version of IUS can run these tests +# +@ius_min_version_required=(10,20,100); +$ius = `irun -version`; +chomp $ius; +if ($ius !~ /TOOL:\s+\S+\s+(\d+)\.(\d+)-([A-z])(\d+)/) { + print STDERR "Unable to run IUS: $ius"; + exit(1); +} else { + @ius_version = ($1,$2,$4); + &ius_compare_version($3,$ius,\@ius_version, \@ius_min_version_required); +} + +sub ius_too_old { + local($v, @min) = @_; + print STDERR "IUS $v cannot run the UVM library.\n"; + print STDERR "Version $min[0].$min[1]s$min[2] or later is required.\n"; + exit(1); +} + +sub ius_compare_version { + my($stream,$id,$cv,$rv)=@_; + my(@c,@r); + @c=@{$cv}; + @r=@{$rv}; + + if ($stream !~ /[ps]/) { + print STDERR "running a nonstd build version [$ius] assuming its at least equiv. to IUS".ius_version_string(@r)."\n"; + } elsif (!&ius_is_at_least($cv,$rv)) { + &ius_too_old($id,@r); + } +} + +sub ius_is_at_least { + my($cv,$rv)=@_; + +#print Dumper($cv); +#print Dumper($rv); + + my(@numbers)=map {[$$cv[$_],$$rv[$_]]} (0 ..$#$cv); + @numbers=map { $$_[0] - $$_[1]} @numbers; + @numbers=grep { $_ != 0} @numbers; + +# print Dumper(@numbers); + + return $numbers[0] >= 0; +} + +print Dumper(@c); +print Dumper(@r); + +sub ius_version_string { + my(@v)=@_; + return "$v[0].$v[1]s$v[2]"; +} + +# +# Run the test implemented by the file named "test.sv" located +# in the specified directory, using the specified compile-time +# and run-time command-line options +# +# The specified directory must also be used as the CWD for the +# simulation run. +# +# Run silently, unless $opt_v is specified. +# +sub run_the_test { + local($testdir, $ius_comp_opts, $ius_sim_opts, $_) = @_; + + $ius = "irun -uvmhome $uvm_home -nocopyright test.sv +UVM_TESTNAME=test $ius_comp_opts $ius_sim_opts"; + $ius .= " -nostdout" unless $opt_v; + + print "$ius\n" if $opt_v; + return system("cd $testdir; rm -rf INCA_libs irun.log; $ius"); +} + +# +# Return the name of the compile-time logfile +# +sub comptime_log_fname { + return runtime_log_fname(); +} + + +# +# Return the name of the run-time logfile +# +sub runtime_log_fname { + return "irun.log"; +} + + +# +# Return a list of filename & line numbers with compile-time errors +# for the test in the specified directory as an array, where each element +# is of the format "fname#lineno" +# +# e.g. ("test.sv#25" "test.sv#30") +# +sub get_compiletime_errors { + local($testdir) = @_; + + local($log)= "$testdir/" . comptime_log_fname(); + + open(LOG,$log) or die("couldnt open log [$log] [$!]"); + + local(@errs)=(); + + while ($_ = ) { + if (/^(ncvlog|ncelab|irun): \*[EF],\w+ \(([^,]+),(\d+)\|(\d+)\):/,){ + push(@errs, "$2#$3"); + } + } + + close(LOG); + +# print join(":",@errs),"\n"; + + return @errs; +} + + +# +# Return a list of filename & line numbers with run-time errors +# for the test in the specified directory as an array, where each element +# is of the format "fname#lineno" +# +# e.g. ("test.sv#25" "test.sv#30") +# +# Run-time errors here refers to errors identified and reported by the +# simulator, not UVM run-time reports. +# +sub get_runtime_errors { + local($testdir) = @_; + local($log) = &realpath("$testdir/" . runtime_log_fname()); + + open(LOG, $log) or die("couldnt open [$log] [$!]"); + + local(@errs)=(); + + while () { + if (/^(ncsim): \*[FE],\w+ \(([^,]+),(\d+)\|(\d+)\):/) { + push(@errs, "$2#$3"); + } elsif (/^(ncsim): \*[FE],\w+:/) { + push(@errs, "$2#0"); + } + + if (/^ERROR:/) { + push(@errs, "fname#2"); + } + } + + close(LOG); + + return @errs; +} + + +# +# Clean-up all files created by the simulation, +# except the log files +# +sub cleanup_test { + local($testdir, $_) = @_; + + system("cd $testdir; rm -rf INCA_libs waves.shm"); +} + +1; diff --git a/tools/questa/run_test.pl b/tools/questa/run_test.pl new file mode 100755 index 0000000..ef353d9 --- /dev/null +++ b/tools/questa/run_test.pl @@ -0,0 +1,201 @@ +##---------------------------------------------------------------------- +## Copyright 2018 Cadence Design Systems, Inc. +## Copyright 2010-2014 Mentor Graphics Corporation +## Copyright 2010 AMD +## Copyright 2010-2011 Synopsys, Inc. +## All Rights Reserved Worldwide +## +## Licensed under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of +## the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in +## writing, software distributed under the License is +## distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +## CONDITIONS OF ANY KIND, either express or implied. See +## the License for the specific language governing +## permissions and limitations under the License. +##---------------------------------------------------------------------- + + +# +# Questa-Specific test running script +# + + +# +# Make sure the version of Questa can run these tests +# + +sub questa_support($$$) { + my ($series,$letter,$beta) = @_; + if (!(($series eq "6.6" && $letter ge "d") || ($series > 6.6))) { + print "Questa version \"$series$letter$beta\" does not fully support UVM.\n". + "- required version 6.6d or later\n"; + } + return 1; +} + +sub questa_checkversion() { + my $vlog_version = `vlog -version`; + chomp $vlog_version; + if ($vlog_version !~ m/((\d+\.\d+)([a-z])?)/) { + die "Unable to get Questa version from 'vlog -version': $vlog_version\n"; + } + my $version = $1; + my ($series,$letter,$beta) = ($version =~ m/^(\d+\.\d+)([a-z])?\s*([Bb]eta\s+([0-9])?\d?)?$/i); + die "Unrecognised Questa version number: \"$version\"\n" unless (defined $series); + &questa_support($series,$letter,$beta); + print "# Questa version $version ($vlog_version)\n" if ($opt_v); +} + + +# +# Standard way to run commands for debug +# + +sub questa_run($) { + my ($cmd) = @_; + print STDOUT "# $cmd\n" if ($opt_v); + system($cmd); +} + + +# +# Run the test implemented by the file named "test.sv" located +# in the specified directory, using the specified compile-time +# and run-time command-line options +# +# The specified directory must also be used as the CWD for the +# simulation run. +# +# Run silently, unless $opt_v is specified. +# +sub run_the_test($$$) { + my ($testdir,$compile_opts,$run_opts,$compat_opts) = @_; + &questa_checkversion(); + my $uvm_opts = "+incdir+$uvm_home/src $uvm_home/src/uvm.sv $compat_opts"; + + # how to direct output - verbose/silent + my $redirect = ($opt_v) ? "| tee -a" : ">>"; + + # prepare by making sure log files and QA stamp are removed + &questa_run("cd $testdir && rm -f qa ".&comptime_log_fname()." ".&runtime_log_fname()); + + # compile commands + # +acc=rb needed for DPI backdoor access + my $QCFLAG = "-DQUESTA"; + my $vlog; + if ($compile_opts !~ /UVM_NO_DPI/) { + $vlog = ("vlog -writetoplevels work/top_levels -lint -suppress 2218,2181 $compile_opts $uvm_opts $compat_opts -timescale 1ns/1ns test.sv -ccflags $QCFLAG -ccwarn off $uvm_home/src/dpi/uvm_dpi.cc"); + } + else { + $vlog = ("vlog -writetoplevels work/top_levels -lint -suppress 2218,2181 $compile_opts $uvm_opts $compat_opts -timescale 1ns/1ns test.sv "); + } + &questa_run("cd $testdir && ( $vlog ) $redirect ".&comptime_log_fname()." 2>&1"); + + # only run if the compile succeeded in reaching QA + if (-e "$testdir/work/top_levels") { + my $vopt = ("vopt -quiet -f $testdir/work/top_levels -o opt -access=rw+/. -access=rw+uvm_polling_pkg -suppress 2108"); + my $vsim = ("vsim opt -quiet -c +UVM_TESTNAME=test $run_opts -do 'run -all;quit -f' "); + + &questa_run("cd $testdir && $vopt"); + &questa_run("cd $testdir && $vsim $redirect ".&runtime_log_fname()." 2>&1"); + + } + return(0); +} + + +# +# Return the name of the compile-time logfile +# +sub comptime_log_fname() { return "compile.log"; } + + +# +# Return the name of the run-time logfile +# +sub runtime_log_fname() { return "run.log"; } + + +# +# Return a list of filename & line numbers with compile-time errors +# for the test in the specified directory as an array, where each element +# is of the format "fname#lineno" +# +# e.g. ("test.sv#25" "test.sv#30") +# +sub get_compiletime_errors($) { + my ($testdir) = @_; + my $log = "$testdir/".&comptime_log_fname(); + if (!open(LOG, "<$log")) { return (); } + my @errs; + while (my $line = ) { + if ($line =~ m/^\#?\s*\**\s*Error:/) { + if ($line =~ m/^\#?\s*\**\s*Error:\s*([^\(]+)\(([^\)]+)\):\s(.*)/) { + my ($fname,$lineno,$err) = ($1,$2,$3); + push(@errs, "$fname#$lineno"); + } else { + print STDERR "\n# get_compiletime_error(): unknown error ($line)\n" if ($opt_v); + push(@errs, "unknown#1"); + } + } + } + close(LOG); + return @errs; +} + + +# +# Return a list of filename & line numbers with run-time errors +# for the test in the specified directory as an array, where each element +# is of the format "fname#lineno" +# +# e.g. ("test.sv#25" "test.sv#30") +# +# Run-time errors here refers to errors identified and reported by the +# simulator, not UVM run-time reports. +# +sub get_runtime_errors($) { + my ($testdir) = @_; + my $log = "$testdir/".&runtime_log_fname(); + if (!open(LOG, "<$log")) { return (); } + my @errs; + while (my $line = ) { + if ($line =~ m/^\#?\s*\**\s*Error:/) { + # ** Error: test.sv(62): message + if ($line =~ m/^\#?\s*\**\s*Error:\s*([^\(]+)\(([^\)]+)\):\s(.*)/) { + my ($fname,$lineno,$err) = ($1,$2,$3); + push(@errs, "$fname#$lineno"); + # ** Error: (vsim-XXXX) test.sv(62): message + } elsif ($line =~ m/^\#?\s*\**\s*Error:\s*\(([^\)]+)\)\s*([^\(]+)\(([^\)]+)\):\s(.*)/) { + my ($fname,$lineno,$err) = ($2,$3,$4); + push(@errs, "$fname#$lineno"); + } elsif ($line =~ m/^\#?\s*\**\s*Error:\s*(.*) in file (.*) at line\s*([0-9]+)\./) { + my ($fname,$lineno,$err) = ($2,$3,$1); + push(@errs, "$fname#$lineno"); + } else { + print STDERR "\n# get_runtime_error(): unknown error ($line)\n" if ($opt_v); + push(@errs, "unknown#1"); + } + } + } + close(LOG); + return @errs; +} + + +# +# Clean-up all files created by the simulation, +# except the log files +# +sub cleanup_test($) { + my ($testdir) = @_; + system("cd $testdir && rm -rf qa work/ lib/ vsim.wlf debug.log"); +} + +1; diff --git a/tools/vcs/README.txt b/tools/vcs/README.txt new file mode 100644 index 0000000..5101829 --- /dev/null +++ b/tools/vcs/README.txt @@ -0,0 +1,6 @@ + + + VCS-specific installation instructions for UVM + + +1. Nothing specific is required by VCS diff --git a/tools/vcs/run_test.pl b/tools/vcs/run_test.pl new file mode 100755 index 0000000..5cf3d5a --- /dev/null +++ b/tools/vcs/run_test.pl @@ -0,0 +1,216 @@ +##---------------------------------------------------------------------- +## Copyright 2010-2018 Cadence Design Systems, Inc. +## Copyright 2010 Verilab +## Copyright 2010-2011 Synopsys, Inc. +## All Rights Reserved Worldwide +## +## Licensed under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of +## the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in +## writing, software distributed under the License is +## distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +## CONDITIONS OF ANY KIND, either express or implied. See +## the License for the specific language governing +## permissions and limitations under the License. +##---------------------------------------------------------------------- + +# +# VCS-Specific test running script +# + +# If $vcs_bin has already been defined (say, to VCSi) then use the +# specified binary name instead. Otherwise, default to "vcs". +$vcs_bin = "vcs" unless $vcs_bin; + +# +# Make sure the version of VCS can run these tests +# + +$vcs = `$vcs_bin -id`; +if ($vcs !~ m/Compiler version = VCS\S* (\S+)/) { + print STDERR "Unable to run VCS: $vcs"; + exit(1); +} +$vcs_version = $1; +if ($vcs_version !~ m/(\d\d\d\d)\.(\d\d)(-(.+))?$/) { + print stderr "Unknown VCS version number \"$vcs_version\".\n"; + exit(1); +} +$vcs_yr = $1; +$vcs_mo = $2; +$vcs_rl = $4; + +$vcs_acc = "+acc +vpi"; +if ($vcs_yr < 2010) { &vcs_too_old($vcs_version); } +if ($vcs_yr == 2010 && $vcs_mo == 6) { + if ($vcs_rl !~ "^SP1" && $vcs_rl < "3") { &vcs_too_old($vcs_version); } +} +if ($vcs_yr > 2014) { + $vcs_acc = "-debug_access+r+w+nomemcbk"; +} +if ($vcs_yr == 2014 && $vcs_mo == 12) { + $vcs_acc = "-debug_access+r+w"; +} + +sub vcs_too_old { + local($v, $_) = @_; + print STDERR "VCS $v cannot run the full UVM library.\n"; + print STDERR "Version 2010.06-3 or later is required.\n"; + exit(1); +} + + +# +# Run the test implemented by the file named "test.sv" located +# in the specified directory, using the specified compile-time +# and run-time command-line options +# +# The specified directory must also be used as the CWD for the +# simulation run. +# +# Run silently, unless $opt_v is specified. +# +sub run_the_test { + local($testdir, $vcs_opts, $simv_opts, $compat_opts, $_) = @_; + local $uvm_opts = "+incdir+$uvm_home/src $uvm_home/src/uvm.sv $compat_opts $uvm_home/src/dpi/uvm_dpi.cc -CFLAGS -DVCSMX"; + + $vcs = "$vcs_bin -sverilog $vcs_acc -timescale=1ns/1ns $vcs_opts $uvm_opts test.sv -l vcs.log +lint=all"; + $vcs .= " > /dev/null 2>&1" unless $opt_v; + + system("cd $testdir; rm -f simv vcs.log simv.log; $vcs"); + + if (-e "$testdir/simv") { + $simv = "simv -l simv.log +UVM_TESTNAME=test $simv_opts"; + $simv .= " > /dev/null 2>&1" unless $opt_v; + + print "$simv\n" if $opt_v; + system("cd $testdir; ./$simv"); + } + + return 0; +} + + +# +# Return the name of the compile-time logfile +# +sub comptime_log_fname { + return "vcs.log"; +} + + +# +# Return the name of the run-time logfile +# +sub runtime_log_fname { + return "simv.log"; +} + + +# +# Return a list of filename & line numbers with compile-time errors +# for the test in the specified directory as an array, where each element +# is of the format "fname#lineno" +# +# e.g. ("test.sv#25" "test.sv#30") +# +sub get_compiletime_errors { + local($testdir, $_) = @_; + + local($log); + $log = "$testdir/vcs.log"; + if (!open(LOG, "<$log")) { + return (); + } + + local(@errs); + + while ($_ = ) { + if (m/^Error-\[/) { + while ($lf = ) { + if ($lf =~ m/^\s+"(\S+)", (\d+)\s/) { + $fname = $1; $line = $2; + last; + } + if ($lf =~ m/^(\S+), (\d+)$/) { + $fname = $1; $line = $2; + last; + } + } + if ($lf) { + push(@errs, "$fname#$line"); + } else { + print STDERR "Invalid VCS compile-time error: \n$_$lf"; + } + } + } + + close(LOG); + + return @errs; +} + + +# +# Return a list of filename & line numbers with run-time errors +# for the test in the specified directory as an array, where each element +# is of the format "fname#lineno" +# +# e.g. ("test.sv#25" "test.sv#30") +# +# Run-time errors here refers to errors identified and reported by the +# simulator, not UVM run-time reports. +# +sub get_runtime_errors { + local($testdir, $_) = @_; + + local($log); + $log = "$testdir/simv.log"; + if (!open(LOG, "<$log")) { + return (); + } + + local(@errs); + + while ($_ = ) { + if (m/^Error-\[/) { + while ($lf = ) { + if ($lf =~ m/^\s+"(\S+)", (\d+)\s/) { + $fname = $1; $line = $2; + last; + } + if ($lf =~ m/^(\S+), (\d+)$/) { + $fname = $1; $line = $2; + last; + } + } + if ($lf) { + push(@errs, "$fname#$line"); + } else { + print STDERR "Invalid VCS run-time error: \n$_$lf"; + } + } + } + + close(LOG); + + return @errs; +} + + +# +# Clean-up all files created by the simulation, +# except the log files +# +sub cleanup_test { + local($testdir, $_) = @_; + + system("cd $testdir; rm -rf simv simv.daidir simv.vdb csrc ucli.* vc_hdrs.h .vcs*"); +} + +1; diff --git a/tools/vcsi/README.txt b/tools/vcsi/README.txt new file mode 100644 index 0000000..5f467f4 --- /dev/null +++ b/tools/vcsi/README.txt @@ -0,0 +1,6 @@ + + + VCSi-specific installation instructions for UVM + + +1. Nothing specific is required by VCSi diff --git a/tools/vcsi/run_test.pl b/tools/vcsi/run_test.pl new file mode 100644 index 0000000..21078c1 --- /dev/null +++ b/tools/vcsi/run_test.pl @@ -0,0 +1,45 @@ +##---------------------------------------------------------------------- +## Copyright 2018 Cadence Design Systems, Inc. +## Copyright 2010 Verilab +## Copyright 2010 Synopsys, Inc. +## All Rights Reserved Worldwide +## +## Licensed under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of +## the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in +## writing, software distributed under the License is +## distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +## CONDITIONS OF ANY KIND, either express or implied. See +## the License for the specific language governing +## permissions and limitations under the License. +##---------------------------------------------------------------------- + +# +# VCSi-Specific test running script +# + +# +# Make sure the version of VCSi can run these tests +# +$vcs_bin = "vcsi"; + +# Redefine $tool so it points to VCS so as not to break things like +# file names for compile arguments (vcs.comp.args) used in the main +# body of run_tests. +$tool = "vcs"; + +$libdir =~ s|/tools/vcsi/|/tools/vcs/|; +if (! -e $libdir) { + print STDERR "Tool-specific library \"$libdir\" does not exists.\n"; + exit(1); +} +unshift(@INC, $libdir); + +require "run_test.pl"; + +1; diff --git a/tools/xcelium/run_test.pl b/tools/xcelium/run_test.pl new file mode 100644 index 0000000..77cbafa --- /dev/null +++ b/tools/xcelium/run_test.pl @@ -0,0 +1,136 @@ +##---------------------------------------------------------------------- +## Copyright 2017-2018 Cadence Design Systems, Inc. +## Copyright 2010 Synopsys, Inc. +## All Rights Reserved Worldwide +## +## Licensed under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of +## the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in +## writing, software distributed under the License is +## distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +## CONDITIONS OF ANY KIND, either express or implied. See +## the License for the specific language governing +## permissions and limitations under the License. +##---------------------------------------------------------------------- +use Cwd 'realpath'; +use Data::Dumper; + +# +# Run the test implemented by the file named "test.sv" located +# in the specified directory, using the specified compile-time +# and run-time command-line options +# +# The specified directory must also be used as the CWD for the +# simulation run. +# +# Run silently, unless $opt_v is specified. +# +sub run_the_test { + local($testdir, $xcelium_comp_opts, $xcelium_sim_opts, $compat_opts, $_) = @_; + + $xcelium = "xrun -clean $xcelium_comp_opts -uvmhome $uvm_home -nocopyright $compat_opts test.sv +UVM_TESTNAME=test $xcelium_sim_opts -uvmnocdnsextra -access rw"; + # $xcelium .= " -nostdout" unless $opt_v; + + print "$xcelium\n" if $opt_v; + return system("cd $testdir; $xcelium"); +} + +# +# Return the name of the compile-time logfile +# +sub comptime_log_fname { + return runtime_log_fname(); +} + + +# +# Return the name of the run-time logfile +# +sub runtime_log_fname { + return "xrun.log"; +} + + +# +# Return a list of filename & line numbers with compile-time errors +# for the test in the specified directory as an array, where each element +# is of the format "fname#lineno" +# +# e.g. ("test.sv#25" "test.sv#30") +# +sub get_compiletime_errors { + local($testdir) = @_; + + local($log)= "$testdir/" . comptime_log_fname(); + + open(LOG,$log) or die("couldnt open log [$log] [$!]"); + + local(@errs)=(); + + while ($_ = ) { + if (/^(xmvlog|xmelab|irun): \*[EF],\w+ \(([^,]+),(\d+)\|(\d+)\):/,){ + push(@errs, "$2#$3"); + } + } + + close(LOG); + +# print join(":",@errs),"\n"; + + return @errs; +} + + +# +# Return a list of filename & line numbers with run-time errors +# for the test in the specified directory as an array, where each element +# is of the format "fname#lineno" +# +# e.g. ("test.sv#25" "test.sv#30") +# +# Run-time errors here refers to errors identified and reported by the +# simulator, not UVM run-time reports. +# +sub get_runtime_errors { + local($testdir) = @_; + local($log) = &realpath("$testdir/" . runtime_log_fname()); + + open(LOG, $log) or die("couldnt open [$log] [$!]"); + + local(@errs)=(); + + while () { + if (/^(xmsim): \*[FE],\w+ \(([^,]+),(\d+)\|(\d+)\):/) { + push(@errs, "$2#$3"); + } elsif (/^(\S+): \*[FE],\w+:/) { + push(@errs, "$2#0"); + } + + if (/^ERROR:/) { + push(@errs, "fname#2"); + } + } + + close(LOG); +# print join(":",@errs),"\n"; + + return @errs; +} + + +# +# Clean-up all files created by the simulation, +# except the log files +# +sub cleanup_test { + local($testdir, $_) = @_; + + system("cd $testdir; rm -rf xcelium.d waves.shm"); +} + +1;