KhronosGroup / OpenCL-ICD-Loader

The OpenCL ICD Loader project.
Apache License 2.0
246 stars 135 forks source link

Improved Unit Testing Feedback #76

Open bashbaug opened 5 years ago

bashbaug commented 5 years ago

I've been experimenting with alternate ways to test the OpenCL ICD loader, with the following goals in mind:

  1. Use a modern unit testing framework.
  2. Test as much as possible without needing to manually setup a stub ICD.
  3. Automatically generate as much test content as possible.

I have something working and I'm looking for feedback before proceeding further, mostly because there is still some manual work needed to setup each test, and I won't spend the time doing this if it looks like things aren't moving in the right direction.

Some details:

What I'm looking for:

Aside: I think we should be able to automatically generate a bunch of the ICD loader code itself, similar to the way I've generated the recorder ICD and test template. I plan to look at this at some point in the near future, but if someone else wants to take a look at it first, the gen_tester.py script could be a helpful place to start from.

Thanks!

Kerilk commented 3 years ago

I like the way you are testing the loader here. I think I have an idea to completely automate the generation of 95% of the test. I have a couple of questions though, and one remark. Questions:

Remark:

bashbaug commented 3 years ago
  • Do you mind if I pick-up where you left it

No, not at all! I'm also happy to help if needed, just let me know what I can do.

  • Using the same framework to generate both the loader and the tests, what is the intrinsic value of the tests? Wouldn't the tests have the same blind spots as the generated loader?

This is a very interesting question now that we're generating most of the loader...

alycm commented 3 years ago

Using the same framework to generate both the loader and the tests, what is the intrinsic value of the tests? Wouldn't the tests have the same blind spots as the generated loader?

One alternative is to test the generator itself, e.g. for input X does it produce expected output Y. The variety of patterns in cl.xml, however, means it would be hard to write tests with good coverage. Also if the bug is in cl.xml itself no test generation approach will catch it.

The current testing is pretty minimal. Pragmatically I think generated testing could still provide more safety than that, even with the risk of blind spots. For hand-written testing there is still the CTS providing more coverage, just with unknown timescales to discover issues because it's not suitable for use in CI here.