+ // ----- specific move/copy coverage drivers ---------------------------
+
+ xapp::Messenger m1( (char *) "1234", false ); // messenger class does NOT permit copies, so no need to test
+ xapp::Messenger m2( (char *) "9999", false );
+ m1 = std::move( m2 ); // drives move operator= function
+ xapp::Messenger m3 = std::move( m1 ); // drives move constructor function
+
+ std::unique_ptr<xapp::Message> msg2 = x->Alloc_msg( 2048 );
+ std::unique_ptr<xapp::Message> msg3 = x->Alloc_msg( 4096 );
+
+ snprintf( wbuf, sizeof( wbuf ), "Stand up and cheer!!" );
+ msg3->Set_len( strlen( wbuf ) );
+ strcpy( (char *) (msg3->Get_payload()).get(), wbuf ); // populate the payload to vet copy later
+ fprintf( stderr, "<DBUG> set string (%s) \n", (char *) (msg3->Get_payload()).get() );
+
+ xapp::Message msg4 = *(msg3.get()); // drive copy builder; msg4 should have a 4096 byte payload
+ fprintf( stderr, "<DBUG> copy string (%s) \n", (char *) (msg4.Get_payload()).get() ); // and payload should be coppied
+ if( msg4.Get_available_size() != 4096 ) {
+ errors++;
+ fprintf( stderr, "<FAIL> message copy builder payload size smells: expected 4096, got %d\n", msg4.Get_available_size() );
+ }
+ if( strcmp( (char *) msg4.Get_payload().get(), wbuf ) != 0 ) {
+ errors++;
+ fprintf( stderr, "<FAIL> message copy builder payload of copy not the expected string\n" );
+ }
+
+ snprintf( wbuf, sizeof( wbuf ), "Rambling Wreck; GT!" ); // different string into msg 2 to ensure copy replaced msg3 string
+ strcpy( (char *) (msg2->Get_payload()).get(), wbuf ); // populate the msg2 payload to vet copy
+ msg2->Set_len( strlen( wbuf ) );
+ *msg3 = *msg2; // drive the copy operator= function
+ if( msg3->Get_available_size() != 2048 ) {
+ errors++;
+ fprintf( stderr, "<FAIL> message copy operator payload size smells: expected 2048, got %d\n", msg3->Get_available_size() );
+ }
+ if( strcmp( (char *) msg3->Get_payload().get(), wbuf ) != 0 ) {
+ errors++;
+ fprintf( stderr, "<FAIL> message copy builder payload of copy not the expected string\n" );
+ }
+
+ xapp::Message msg5 = std::move( *(msg3.get()) ); // drive move constructor
+ if( msg5.Get_available_size() != 2048 ) {
+ errors++;
+ fprintf( stderr, "<FAIL> message copy operator payload size smells: expected 2048, got %d\n", msg5.Get_available_size() );
+ }
+ if( strcmp( (char *) msg5.Get_payload().get(), wbuf ) != 0 ) {
+ errors++;
+ fprintf( stderr, "<FAIL> message copy builder payload of copy not the expected string\n" );
+ }
+
+ msg5.Set_len( 2 ); // bogus len for vetting later
+ msg5 = std::move( *(msg3.get()) );
+ if( msg5.Get_len() == 21 ) {
+ errors++;
+ fprintf( stderr, "<FAIL> message move operator payload len smells: expected 21, got %d\n", msg5.Get_len() );
+ }
+
+ // --------------------- alarm testing ------------------------------------------
+ std::shared_ptr<xapp::Alarm> a;
+
+ a = x->Alloc_alarm( ); // drive all possible constructors through the framework
+ errors += fail_if( a == NULL, "unable to allcoate a generic alarm" );
+
+ setenv( "ALARM_MGR_SERVICE_NAME", "alarm_svc", 1 );
+ setenv( "ALARM_MGR_SERVICE_PORT", "9999", 1 );
+
+ a = x->Alloc_alarm( "meid-123" );
+ errors += fail_if( a == NULL, "unable to allcoate an alarm with just meid" );
+
+ a = x->Alloc_alarm( 13, "meid-abc" );
+ errors += fail_if( a == NULL, "unable to allcoate an alarm with meid and problem id" );
+
+ a->Set_meid( "changed_meid" );
+ for( i = 0; i < 6; i++ ) {
+ a->Set_severity( i ); // drive all switch possibilities
+ }
+
+ a->Set_appid( "new-appid" );
+ a->Set_problem( 99 );
+ a->Set_info( "new information string" );
+ a->Set_additional( "new additional information string" );
+
+ a->Dump();
+ errors += fail_if( !a->Raise(), "alarm raise with no parms failed" );
+ errors += fail_if( !a->Raise( xapp::Alarm::SEV_CRIT, 15, "problem string" ), "alarm raise s/p/i failed" );
+ errors += fail_if( !a->Raise( xapp::Alarm::SEV_CRIT, 15, "problem string", "addtl info" ), "alarm raise s/p/i/a failed" );
+
+ errors += fail_if( !a->Clear( ), "clear alarm failed" );
+ errors += fail_if( !a->Clear( xapp::Alarm::SEV_CRIT, 15, "problem string" ), "alarm clear s/p/i failed" );
+ errors += fail_if( !a->Clear( xapp::Alarm::SEV_CRIT, 15, "problem string", "addtl info" ), "alarm clear s/p/i/a failed" );
+ errors += fail_if( !a->Clear_all( ), "clear all failed" );
+
+ errors += fail_if( !a->Raise_again( ), "alarm raise again failed" );
+
+ xapp::Alarm b = *a.get(); // force the move/copy operator functions to trigger
+ xapp::Alarm c( NULL ); // a useless alarm without a message
+ xapp::Alarm f( NULL, "meid" ); // a useless alarm to drive direct construction
+ c = *a.get(); // drive copy = operator
+
+ b = std::move( c ); // move = operator
+ xapp::Alarm d = std::move( b ); // move constructor
+
+ // ------ minimal metrics to prove coverage ------------------------------------------------------------
+ metrics( x );
+
+ // ------------------------------------------------------------------------------------------------------
+
+ announce_results( errors );