• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. I've written a small unit testing framework for SKILL

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 1737
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

I've written a small unit testing framework for SKILL

MatthewLove
MatthewLove over 8 years ago

I've written a small framework based on python's built in unit testing module.

https://github.com/MatthewLoveQUB/SKILL_Tools


This is an example of a testbench to test two functions.

(qtest::runSuites
  (qtest::TestSuite ((f qub:::join_lists))
    (qtest::TestCase join_three_lists
      (qtest::assertEqual (list "X" 2 3 4 5 6)
                           (f (list (list 1 2) (list 3 4) (list 5 6))))))
  (qtest::TestSuite ((f qub::flatten_list))
    (qtest::TestCase normal_use
      (qtest::assertEqual (list 1 2 3 4 5 6 7)
                           (f (list 1 2 (list 3 (list 4 (list 5 6) 7))))))))

When the file is loaded, it would have the following output (I've intentionally edited the first one to fail):

(load "./code/src/std/test_lists.ils")
1 of 2 tests passed (1 failures) (0 skipped) (0 expected failures)
Test: join_three_lists
Result: Fail
 Message: No msg.
 Inputs: (list("X" 2 3 4 5 6) (f list(list(1 2) list(3 4) list(5 6))))
 Evaluated Inputs: (("X" 2 3 4 5 6) (1 2 3 4 5 6))

Each test is represented by the TestCase macro. It creates a list containing the test's name and the test function object. This prevents the test from polluting the global namespace. Using a keyword arg you can also mark tests to be skipped or that you expect them to fail. Each test case must return the output of an assertion function.

The test cases are grouped up into suites which are typically used to evaluate a single object (usually a function). A suite is just a list to group the tests. Each suite is put into the body of a runSuites macro which flattens the the suites into a single list and runs them when the module is loaded. I've also included a function to recursively find and load all modules beginning with a test_ prefix.

The unit tests themselves have an automated test system to make sure that they're working. There are probably a few bugs hiding in there but it works for most common cases.

The code uses two namespaces, qtest and qub. It was written in IC 6.1.6.

If you've any suggestions I'd like to hear them.

  • Cancel
Parents
  • MatthewLove
    MatthewLove over 8 years ago
    I've thrown the code up on github now.

    github.com/.../SKILL_Tools
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • MatthewLove
    MatthewLove over 8 years ago
    I've thrown the code up on github now.

    github.com/.../SKILL_Tools
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information