-
Notifications
You must be signed in to change notification settings - Fork 46
Add state machine Tester friend #753
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
Conversation
bocchino
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good start, but I think a bit more design is required. It looks like this approach uses the unqualified name of the state machine implementation class to create a friend for the state machine base class, and there's no friend for the derived implementation class. Instead, I suggest that we do the following:
- Use two friends, one for the base class and one for the derived implementation class. The base class friend should be inserted here, and the derived class friend should be inserted in the code that instantiates a state machine in a component. See here for an example: .
fpp/compiler/tools/fpp-to-cpp/test/component/base/SmInitialActiveComponentAc.ref.hpp
Lines 63 to 64 in ccdfc4e
class FppTest_SmInitial_Basic : public FppTest::SmInitial::BasicStateMachineBase - Use the fully-qualified names for the friends, as the code generator does for the class names in the example above. In the example above, the names of the friends could be
FppTest::SmInitial::BasicStateMachineBaseTesterfor the base class andFppTest_SmInitial_BasicTesterfor the derived class. It's a little more verbose, but it is more structured and less likely to create name collisions. Also, it's consistent with the existing code gen strategy.
|
Another approach would be to use the same friend name for both the base class and derived class. Maybe that would be simpler on the testing side, since one tester class could access both the base class and the derived class in the implementation under test. If we do that, then we can use the fully-qualified name of the derived class (e.g., |
|
Yet another option would be to make the component tester class a friend of the state machine implementation class inside the component. Maybe that is the best for testing the component. So in the example above we could use (1) |
Or maybe it's better to use |
|
So after all that, my suggestion is to do the following:
|
|
It seems that when you declare a friend namespace N {
class C {
friend class F;
private:
int x = 0;
};
}
namespace N {
class F {
public:
int getX(const N::C& c) { return c.x; }
};
}So I think what I am suggesting reduces to the second item above, i.e., add the component tester and tester base as friends of the state machine implementation in the component generated code. |
…g component friends
|
I think I have addressed the requested updates, so using the example above now in file Let me know if this addresses the requested changes, happy to iterate further if needed. |
Revise comments Update test harness to comply with changes to F Prime
bocchino
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks! I revised the comments in the generated code, and I updated the test harness for fpp-check.
In support of nasa-fprime#3446 Similar to components, add a default
<X>Testerto state machine classes, in order to support white-box testing