|
| 1 | +// Make selected privates visible for unit testing |
| 2 | +#define private public |
| 3 | +#include "directory.h" |
| 4 | +#undef private |
| 5 | + |
| 6 | +#define protected public |
| 7 | +#include "orch.h" |
| 8 | +#undef protected |
| 9 | + |
| 10 | +#define private public |
| 11 | +#include "switchorch.h" |
| 12 | +#undef private |
| 13 | + |
| 14 | +#include "portsorch.h" |
| 15 | +#define private public |
| 16 | +#include "mirrororch.h" |
| 17 | +#undef private |
| 18 | +#include "mock_orch_test.h" |
| 19 | + |
| 20 | +namespace mirrororch_test |
| 21 | +{ |
| 22 | + using namespace mock_orch_test; |
| 23 | + |
| 24 | + class MirrorOrchTest : public MockOrchTest |
| 25 | + { |
| 26 | + }; |
| 27 | + |
| 28 | + TEST_F(MirrorOrchTest, RejectsIngressWhenUnsupported) |
| 29 | + { |
| 30 | + // Ensure environment initialized by MockOrchTest |
| 31 | + ASSERT_NE(gSwitchOrch, nullptr); |
| 32 | + ASSERT_NE(gMirrorOrch, nullptr); |
| 33 | + |
| 34 | + // Force ingress unsupported and egress supported |
| 35 | + gSwitchOrch->m_portIngressMirrorSupported = false; |
| 36 | + gSwitchOrch->m_portEgressMirrorSupported = true; |
| 37 | + |
| 38 | + Port dummyPort; // Unused due to early return |
| 39 | + auto ret = gMirrorOrch->setUnsetPortMirror(dummyPort, /*ingress*/ true, /*set*/ true, /*sessionId*/ SAI_NULL_OBJECT_ID); |
| 40 | + ASSERT_FALSE(ret); |
| 41 | + } |
| 42 | + |
| 43 | + TEST_F(MirrorOrchTest, RejectsEgressWhenUnsupported) |
| 44 | + { |
| 45 | + ASSERT_NE(gSwitchOrch, nullptr); |
| 46 | + ASSERT_NE(gMirrorOrch, nullptr); |
| 47 | + |
| 48 | + // Force egress unsupported and ingress supported |
| 49 | + gSwitchOrch->m_portIngressMirrorSupported = true; |
| 50 | + gSwitchOrch->m_portEgressMirrorSupported = false; |
| 51 | + |
| 52 | + Port dummyPort; // Unused due to early return |
| 53 | + auto ret = gMirrorOrch->setUnsetPortMirror(dummyPort, /*ingress*/ false, /*set*/ true, /*sessionId*/ SAI_NULL_OBJECT_ID); |
| 54 | + ASSERT_FALSE(ret); |
| 55 | + } |
| 56 | +} |
| 57 | + |
0 commit comments