-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blackbox testing and fallback testing #715
Comments
Not a Maintainer but my 2 Cents Test should never depend on internal machinery but only externally visible public API. You get in all sorts of trouble because to access internal machinery you generally need to expose it and once you do all hell breaks loose. You might want to have a look on @tituswinters talks about refactoring and maintainability Technically there is also no reason why any of those tests should not run against a different standard library implementation (modulo the obvious not yet implemented features). It is a standard after all. With fallbacks do you mean unsupported systems such as windows XP? You can always run the test suite manually on your local machine for whatever platform you desire. |
For
The later is for internal use by
So I need at least two machines: 64 bit XP or 2003 and 64 bit Vista or Win7. The first is sort of exotic today. Anyway, actually I'm running these tests by temporary altering the implementation (changing a variable in debugger), so that's not a problem to test these locally. Not having these tests in CI is more of concern. |
As a general rule, we test the Standard interface for Standard semantics. Occasionally we test implementation-specific guarantees, commenting that we’re doing so. In exceptional cases, we directly test internal machinery, usually when doing so provides better correctness validation than would easily be achievable. The Boyer-Moore algorithm tests are one example. At this time, we haven’t attempted to run our tests against other STL implementations, although that is potentially interesting in the future, so remaining disciplined about non-Standard testing (keeping it uncommon and prominently noted) is good for multiple reasons. Also in exceptional cases, we can arrange for test code to trigger fallback paths; there was one such example in our ConcRT adapting layer, although we never used that in automated testing. (Allocation failure fallbacks in stable_sort can be triggered through Standard code.) I think your scenario justifies an exception for using non-Standard machinery in test code. |
It is distinctly an anti-pattern for both your tests and the APIs under test to need to reach into internals / implementation details. If you must do that, it is suggestive that the public APIs in question are at the wrong level of granularity (you have to pierce that abstraction to evaluate the details in question). If you do break that abstraction, you've now tightly coupled the tests and the implementation, which weakens the validity of the test and adds busywork when internals change in ways that are unobservable by the public API. (See Chapter 12 in my recent book.) |
I do not see a completely clean solution, except running XP and Vista on Contniuos Integration server. STL API is defined by C++ Standard, which does not imply anything about operating system. Yet, OS versions are different. It is suboptimal not to take advantage of Win8+ Native API (performance advantage due to more efficient native implementeation), and it is not possible to avoid obligation to support older OS versions. I came up with relatively clean solution: One test that does not call it -- it is standard test. See this commit: f2256d9 |
Everything else aside: If the code is supposed to work on Windows XP, shouldn't testing on a genuine WinXP Machine (Physical or VM) be part of the regular testing process? |
Yep. Of course, WG21 controls the public API, and even when it's at the right level of granularity, piercing the abstraction is sometimes worth it (very rarely). Here's the specific example I mentioned - the Boyer-Moore algorithm in the Standard has a very nice interface for users, but it's also worthwhile to punch through and directly inspect the "delta_2" table within: STL/tests/std/tests/P0220R1_searchers/test.cpp Lines 26 to 44 in 3141965
(We recently discovered in #713 that the Knuth-Morris-Pratt algorithm for constructing the delta_2 table was incorrect - not just the implementation, the published algorithm - and we'll need to add additional test cases here and elsewhere. We should have had randomized testing of the public interface to begin with, but I argue that directly testing the results of this nontrivial internal algorithm provides additional value.) Another potential example would have been directly testing the bignum implementation powering |
Aside XP, I hope that all tests would run on Vista or 7 at least once before shipping. |
The code is no longer supposed to work on Windows XP. The variation between Vista and Win 7 is mutexes ( So in short after XP drop, the variation is too low. |
I notice tests I've seen so far are completely black box, this means they don't use internal function, and potentially can test other STL. Is this a requirement?
If so, this raises question how to test fallback scenarios for
std::call_once
orstd::atomic<T>::wait
. As I understand, CI runs on "normal" machines, not outdated.The text was updated successfully, but these errors were encountered: