Mercurial > hg > waaad
changeset 99:d5fcb2af8c5a
more testing
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Wed, 23 Jul 2008 10:35:16 +0900 |
parents | 7d3d175c3b8d |
children | 50665bb608fd |
files | waaad/tests/testsess.c |
diffstat | 1 files changed, 38 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/waaad/tests/testsess.c Tue Jul 22 18:32:12 2008 +0900 +++ b/waaad/tests/testsess.c Wed Jul 23 10:35:16 2008 +0900 @@ -181,6 +181,44 @@ CHECK( 0, sess_unlink( &session1 ) ); CHECK( 0, sess_unlink( &session2 ) ); CHECK( 0, sess_unlink( &session3 ) ); + CHECK( 0, sess_deregext ( client1 ) ); + CHECK( 0, sess_deregext ( client2 ) ); + + /* Simulate a "real life" situation */ + { + /* Register a client at extension's initialization */ + CHECK( 0, sess_regext ( &client1 ) ); + + /* The extension initiates a session */ + CHECK( 0, sess_new ( &session1, SESSION_NEW_DEFAULT, "more_test" ) ); + + /* It associates some data with this session */ + td[0].hasbeenfreed = 0; + td[0].id = 0xabcd; + CHECK( 0, sess_data_reg( session1, client1, &td[0], cleanup) ); + + /* -- for the purpose of the test, we need to save the name of the session -- */ + CHECK( 0, sess_getsid ( session1, &str) ); + + /* In "real life" situation, the session would then be used to set the Session-Id AVP in a message */ + + /* Then we do not use the session object until we receive a message, or a timer expires, or ... */ + CHECK( 0, sess_unlink( &session1 ) ); + + /* Ok, now let's assume we received a message with a Session-Id AVP set to the same string. retrieve the session */ + CHECK( 0, sess_fromsid ( str, strlen(str), &session3, NULL) ); + + /* Now retrieve any data we would have stored along, like a state machine state */ + CHECK( 0, sess_data_get( session3, client1, (void **)&ptd ) ); + + /* -- for the test: check we retrieved the correct data -- */ + CHECK( 0xabcd, ptd->id ); + CHECK( 0, ptd->hasbeenfreed ); + + /* We're done for this message */ + CHECK( 0, sess_unlink( &session3 ) ); + } + CHECK( 0, sess_fini() ); /* That's all for the tests yet */