@@ -42,7 +42,26 @@ using namespace syncd;
42
42
if ((status)!=SAI_STATUS_SUCCESS) \
43
43
SWSS_LOG_THROW (format " : %s" , ##__VA_ARGS__, sai_serialize_status(status).c_str());
44
44
45
+ #define SAI_FAILURE_DUMP_SCRIPT " /usr/bin/sai_failure_dump.sh"
46
+
47
+ #define CHECK_STATUS (x ) \
48
+ if (status != SAI_STATUS_SUCCESS) { exit (1 ); }
49
+
50
+
45
51
using namespace saimeta ;
52
+
53
+ std::string mockCallArg;
54
+
55
+ namespace swss {
56
+ int exec (const std::string &cmd, std::string &stdout)
57
+ {
58
+ SWSS_LOG_ENTER ();
59
+
60
+ mockCallArg=cmd;
61
+ return 0 ;
62
+ }
63
+ }
64
+
46
65
static std::shared_ptr<swss::DBConnector> g_db1;
47
66
48
67
static sai_next_hop_group_api_t test_next_hop_group_api;
@@ -652,9 +671,6 @@ void test_bulk_route_set()
652
671
ASSERT_SUCCESS (" Failed to bulk remove route entry" );
653
672
}
654
673
655
- #define CHECK_STATUS (x ) \
656
- if (status != SAI_STATUS_SUCCESS) { exit (1 ); }
657
-
658
674
void syncdThread ()
659
675
{
660
676
SWSS_LOG_ENTER ();
@@ -678,6 +694,31 @@ void syncdThread()
678
694
syncd->run ();
679
695
}
680
696
697
+ void test_invoke_dump ()
698
+ {
699
+ SWSS_LOG_ENTER ();
700
+ clearDB ();
701
+
702
+ auto syncd = std::make_shared<std::thread>(syncdThread);
703
+ syncd->detach ();
704
+
705
+ sai_attribute_t attr;
706
+ attr.id = SAI_REDIS_SWITCH_ATTR_NOTIFY_SYNCD;
707
+ attr.value .s32 = SAI_REDIS_NOTIFY_SYNCD_INVOKE_DUMP;
708
+
709
+ auto sairedis = std::make_shared<sairedis::Sai>();
710
+
711
+ sai_status_t status = sairedis->initialize (0 , &test_services);
712
+
713
+ CHECK_STATUS (status);
714
+
715
+ status = sairedis->set (SAI_OBJECT_TYPE_SWITCH, SAI_NULL_OBJECT_ID, &attr);
716
+
717
+ ASSERT_SUCCESS (" Failed to invoke dump" );
718
+ assert (mockCallArg == SAI_FAILURE_DUMP_SCRIPT);
719
+ }
720
+
721
+
681
722
void test_bulk_route_create ()
682
723
{
683
724
SWSS_LOG_ENTER ();
@@ -869,6 +910,8 @@ int main()
869
910
printf (" \n [ %s ]\n\n " , sai_serialize_status (SAI_STATUS_SUCCESS).c_str ());
870
911
871
912
test_watchdog_timer_clock_rollback ();
913
+
914
+ test_invoke_dump ();
872
915
}
873
916
catch (const std::exception &e)
874
917
{
0 commit comments