annotate tests/testsess.c @ 788:cb84f5be889d

Updated copyright information
author Sebastien Decugis <sdecugis@nict.go.jp>
date Tue, 03 Jul 2012 08:14:32 +0200
parents 003df4a9ade2
children 63931db83e96
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1 /*********************************************************************************************************
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
2 * Software License Agreement (BSD License) *
740
4a9f08d6b6ba Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 706
diff changeset
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> *
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
788
cb84f5be889d Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 778
diff changeset
5 * Copyright (c) 2012, WIDE Project and NICT *
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
6 * All rights reserved. *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
7 * *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
8 * Redistribution and use of this software in source and binary forms, with or without modification, are *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
9 * permitted provided that the following conditions are met: *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
10 * *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
11 * * Redistributions of source code must retain the above *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
12 * copyright notice, this list of conditions and the *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
13 * following disclaimer. *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
14 * *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
15 * * Redistributions in binary form must reproduce the above *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
16 * copyright notice, this list of conditions and the *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
17 * following disclaimer in the documentation and/or other *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
18 * materials provided with the distribution. *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
19 * *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
20 * * Neither the name of the WIDE Project or NICT nor the *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
21 * names of its contributors may be used to endorse or *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
22 * promote products derived from this software without *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
23 * specific prior written permission of WIDE Project and *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
24 * NICT. *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
25 * *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
34 *********************************************************************************************************/
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
35
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
36 #include "tests.h"
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
37
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
38 #define TEST_DIAM_ID "testsess.myid"
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
39 #define TEST_OPT_IN "suffix"
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
40 #define TEST_OPT (os0_t)TEST_OPT_IN
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
41 #define TEST_SID_IN TEST_DIAM_ID ";1234;5678;" TEST_OPT_IN
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
42 #define TEST_SID (os0_t)TEST_SID_IN
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
43
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
44 #define TEST_EYEC 0x7e57e1ec
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
45 struct mystate {
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
46 int eyec; /* TEST_EYEC */
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
47 os0_t sid; /* the session with which the data was registered */
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
48 int * freed; /* location where to write the freed status */
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
49 void * opaque; /* if opaque was provided, this is the value we expect */
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
50 };
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
51
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
52 static void mycleanup( struct mystate * data, os0_t sid, void * opaque )
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
53 {
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
54 /* sanity */
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
55 CHECK( 1, sid ? 1 : 0 );
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
56 CHECK( 1, data? 1 : 0 );
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
57 CHECK( TEST_EYEC, data->eyec );
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
58 CHECK( 0, strcmp((char *)sid, (char *)data->sid) );
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
59 if (data->freed)
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
60 *(data->freed) += 1;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
61 if (data->opaque) {
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
62 CHECK( 1, opaque == data->opaque ? 1 : 0 );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
63 }
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
64 /* Now, free the data */
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
65 free(data->sid);
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
66 free(data);
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
67 }
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
68
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
69 static __inline__ struct mystate * new_state(os0_t sid, int *freed)
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
70 {
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
71 struct mystate *new;
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
72 new = malloc(sizeof(struct mystate));
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
73 CHECK( 1, new ? 1 : 0 );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
74 memset(new, 0, sizeof(struct mystate));
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
75 new->eyec = TEST_EYEC;
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
76 new->sid = os0dup(sid, strlen((char *)sid));
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
77 CHECK( 1, new->sid ? 1 : 0 );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
78 new->freed = freed;
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
79 return new;
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
80 }
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
81
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
82 void * g_opaque = (void *)"test";
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
83
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
84 /* Avoid a lot of casts */
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
85 #define strlen(s) strlen((char *)s)
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
86 #define strncmp(s1,s2,l) strncmp((char *)s1, (char *)s2, l)
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
87 #define strcmp(s1,s2) strcmp((char *)s1, (char *)s2)
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
88
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
89
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
90 /* Main test routine */
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
91 int main(int argc, char *argv[])
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
92 {
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
93 struct session_handler * hdl1, *hdl2;
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
94 struct session *sess1, *sess2, *sess3;
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
95 os0_t str1, str2;
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
96 size_t str1len, str2len;
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
97 int new;
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
98
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
99 /* First, initialize the daemon modules */
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
100 INIT_FD();
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
101
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
102 /* Test functions related to handlers (simple situation) */
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
103 {
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
104 void * testptr = NULL;
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
105 CHECK( 0, fd_sess_handler_create ( &hdl1, mycleanup, NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
106 CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, NULL ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
107 CHECK( 0, fd_sess_handler_destroy( &hdl2, &testptr ) );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
108 CHECK( 1, testptr == NULL ? 1 : 0 );
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
109 CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, g_opaque ) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
110 #if 0
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
111 fd_sess_dump_hdl(0, hdl1);
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
112 fd_sess_dump_hdl(0, hdl2);
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
113 #endif
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
114 }
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
115
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
116 /* Test Session Id generation (fd_sess_new) */
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
117 {
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
118 /* DiamId is provided, not opt */
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
119 CHECK( 0, fd_sess_new( &sess1, TEST_DIAM_ID, CONSTSTRLEN(TEST_DIAM_ID), NULL, 0 ) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
120 CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, CONSTSTRLEN(TEST_DIAM_ID), NULL, 0 ) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
121 #if 0
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
122 fd_sess_dump(0, sess1);
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
123 fd_sess_dump(0, sess2);
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
124 #endif
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
125
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
126 /* Check both string start with the diameter Id, but are different */
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
127 CHECK( 0, fd_sess_getsid(sess1, &str1, &str1len) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
128 CHECK( 1, (strlen(str1) == str1len) ? 1 : 0 );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
129 CHECK( 0, strncmp(str1, TEST_DIAM_ID ";", CONSTSTRLEN(TEST_DIAM_ID) + 1) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
130 CHECK( 0, fd_sess_getsid(sess2, &str2, &str2len) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
131 CHECK( 0, strncmp(str2, TEST_DIAM_ID ";", CONSTSTRLEN(TEST_DIAM_ID) + 1) );
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
132 CHECK( 1, strcmp(str1, str2) ? 1 : 0 );
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
133 CHECK( 0, fd_sess_destroy( &sess1 ) );
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
134 CHECK( 0, fd_sess_destroy( &sess2 ) );
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
135
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
136 /* diamId and opt */
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
137 CHECK( 0, fd_sess_new( &sess1, TEST_DIAM_ID, 0, TEST_OPT, 0 ) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
138 CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, CONSTSTRLEN(TEST_DIAM_ID), TEST_OPT, CONSTSTRLEN(TEST_OPT_IN) - 1 ) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
139 #if 0
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
140 fd_sess_dump(0, sess1);
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
141 fd_sess_dump(0, sess2);
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
142 #endif
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
143
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
144 CHECK( 0, fd_sess_getsid(sess1, &str1, &str1len) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
145 CHECK( 0, strncmp(str1, TEST_DIAM_ID ";", CONSTSTRLEN(TEST_DIAM_ID) + 1) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
146 CHECK( 0, strcmp(str1 + str1len - CONSTSTRLEN(TEST_OPT_IN) - 1, ";" TEST_OPT_IN) );
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
147
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
148 CHECK( 0, fd_sess_getsid(sess2, &str2, &str2len) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
149 CHECK( 0, strncmp(str2, TEST_DIAM_ID ";", CONSTSTRLEN(TEST_DIAM_ID) + 1) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
150 CHECK( 0, strncmp(str2 + str2len - CONSTSTRLEN(TEST_OPT_IN), ";" TEST_OPT_IN, CONSTSTRLEN(TEST_OPT_IN)) );
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
151
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
152 CHECK( 1, strcmp(str1, str2) ? 1 : 0 );
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
153 CHECK( 0, fd_sess_destroy( &sess1 ) );
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
154 CHECK( 0, fd_sess_destroy( &sess2 ) );
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
155
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
156 /* Now, only opt is provided */
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
157 CHECK( 0, fd_sess_new( &sess1, NULL, 0, TEST_SID, 0 ) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
158 CHECK( EALREADY, fd_sess_new( &sess2, NULL, 0, TEST_SID, 0 ) );
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
159 CHECK( sess2, sess1 );
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
160 CHECK( EALREADY, fd_sess_new( &sess3, NULL, 0, TEST_SID, CONSTSTRLEN(TEST_SID_IN) ) );
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
161 CHECK( sess3, sess1 );
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
162 CHECK( 0, fd_sess_new( &sess2, NULL, 0, TEST_SID, CONSTSTRLEN(TEST_SID_IN) - 1 ) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
163 #if 0
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
164 fd_sess_dump(0, sess1);
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
165 fd_sess_dump(0, sess2);
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
166 #endif
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
167 CHECK( 0, fd_sess_getsid(sess1, &str1, &str1len) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
168 CHECK( 0, fd_sess_getsid(sess2, &str2, &str2len) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
169 CHECK( 0, strncmp( str1, str2, CONSTSTRLEN(TEST_SID_IN) - 1 ) );
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
170 CHECK( 0, strcmp( str1, TEST_SID ) );
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
171 CHECK( 1, strcmp( str1, str2 ) ? 1 : 0 );
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
172
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
173 CHECK( 0, fd_sess_destroy( &sess2 ) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
174 CHECK( 0, fd_sess_destroy( &sess1 ) );
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
175 }
778
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
176
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
177 /* Test fd_sess_getcount */
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
178 {
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
179 uint32_t cnt;
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
180 CHECK( 0, fd_sess_new( &sess1, TEST_DIAM_ID, CONSTSTRLEN(TEST_DIAM_ID), NULL, 0 ) );
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
181 CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, CONSTSTRLEN(TEST_DIAM_ID), NULL, 0 ) );
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
182 CHECK( 0, fd_sess_getcount(&cnt));
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
183 CHECK( 2, cnt);
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
184 CHECK( 0, fd_sess_destroy( &sess2 ) );
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
185 CHECK( 0, fd_sess_getcount(&cnt));
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
186 CHECK( 1, cnt);
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
187 CHECK( 0, fd_sess_destroy( &sess1 ) );
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
188 CHECK( 0, fd_sess_getcount(&cnt));
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
189 CHECK( 0, cnt);
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
190
003df4a9ade2 Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
191 }
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
192
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
193 /* Test fd_sess_fromsid */
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
194 {
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
195 CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
196 CHECK( 1, new ? 1 : 0 );
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
197
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
198 CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess2, &new ) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
199 CHECK( 0, new );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
200 CHECK( sess1, sess2 );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
201
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
202 CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess3, NULL ) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
203 CHECK( sess1, sess3 );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
204
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
205 CHECK( 0, fd_sess_destroy( &sess1 ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
206 }
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
207
6
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
208 /* Test fd_sess_reclaim */
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
209 {
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
210 struct mystate *tms;
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
211
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
212 CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
6
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
213 CHECK( 1, new ? 1 : 0 );
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
214
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
215 CHECK( 0, fd_sess_reclaim( &sess1 ) );
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
216 CHECK( NULL, sess1 );
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
217
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
218 CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
6
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
219 CHECK( 1, new ? 1 : 0 );
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
220
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
221 tms = new_state(TEST_SID, NULL);
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
222 CHECK( 0, fd_sess_state_store ( hdl1, sess1, &tms ) );
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
223
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
224 CHECK( 0, fd_sess_reclaim( &sess1 ) );
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
225 CHECK( NULL, sess1 );
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
226
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
227 CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
6
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
228 CHECK( 0, new );
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
229
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
230 CHECK( 0, fd_sess_destroy( &sess1 ) );
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
231
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
232 CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
6
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
233 CHECK( 1, new ? 1 : 0 );
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
234
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
235 CHECK( 0, fd_sess_destroy( &sess1 ) );
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
236 }
b0d377c79d80 Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 5
diff changeset
237
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
238 /* Test timeout function */
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
239 {
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
240 struct timespec timeout;
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
241
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
242 CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
243 CHECK( 1, new ? 1 : 0 );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
244
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
245 CHECK( 0, clock_gettime(CLOCK_REALTIME, &timeout) );
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
246 CHECK( 0, fd_sess_settimeout( sess1, &timeout) ); /* expire now */
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
247 timeout.tv_sec = 0;
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
248 timeout.tv_nsec= 50000000; /* 50 ms */
249
6e6ada749a11 Replaced clock_nanosleep since it is missing on FreeBSD platform
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 6
diff changeset
249 CHECK( 0, nanosleep(&timeout, NULL) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
250
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
251 CHECK( 0, fd_sess_fromsid( TEST_SID, CONSTSTRLEN(TEST_SID_IN), &sess1, &new ) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
252 CHECK( 1, new ? 1 : 0 );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
253
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
254 CHECK( 0, clock_gettime(CLOCK_REALTIME, &timeout) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
255 timeout.tv_sec += 2678500; /* longer that SESS_DEFAULT_LIFETIME */
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
256 CHECK( 0, fd_sess_settimeout( sess1, &timeout) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
257
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
258 /* Create a second session */
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
259 CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, 0, NULL, 0 ) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
260
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
261 /* We don't really have a way to verify the expiry list is in proper order automatically here... */
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
262
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
263 CHECK( 0, fd_sess_destroy( &sess2 ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
264 CHECK( 0, fd_sess_destroy( &sess1 ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
265 }
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
266
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
267
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
268 /* Test states operations */
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
269 {
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
270 struct mystate * ms[6], *tms;
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
271 int freed[6];
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
272 struct timespec timeout;
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
273 void * testptr = NULL;
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
274
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
275 /* Create three sessions */
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
276 CHECK( 0, fd_sess_new( &sess1, TEST_DIAM_ID, 0, NULL, 0 ) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
277 CHECK( 0, fd_sess_new( &sess2, TEST_DIAM_ID, 0, NULL, 0 ) );
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
278 CHECK( 0, fd_sess_new( &sess3, TEST_DIAM_ID, 0, NULL, 0 ) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
279
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
280 /* Create 2 states */
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
281 CHECK( 0, fd_sess_getsid(sess1, &str1, &str1len) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
282 freed[0] = 0;
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
283 ms[0] = new_state(str1, &freed[0]);
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
284 ms[1] = new_state(str1, NULL);
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
285
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
286 tms = ms[0]; /* save a copy */
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
287 CHECK( 0, fd_sess_state_store ( hdl1, sess1, &ms[0] ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
288 CHECK( NULL, ms[0] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
289 CHECK( EINVAL, fd_sess_state_store ( hdl1, sess1, NULL ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
290 CHECK( EALREADY, fd_sess_state_store ( hdl1, sess1, &ms[1] ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
291 CHECK( 1, ms[1] ? 1 : 0 );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
292
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
293 #if 0
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
294 fd_sess_dump(0, sess1);
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
295 #endif
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
296
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
297 CHECK( 0, fd_sess_state_retrieve( hdl1, sess1, &ms[0] ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
298 CHECK( tms, ms[0] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
299 CHECK( 0, freed[0] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
300
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
301 CHECK( 0, fd_sess_state_retrieve( hdl1, sess2, &tms ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
302 CHECK( NULL, tms );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
303
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
304 mycleanup(ms[0], str1, NULL);
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
305 mycleanup(ms[1], str1, NULL);
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
306
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
307 /* Now create 6 states */
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
308 memset(&freed[0], 0, sizeof(freed));
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
309 CHECK( 0, fd_sess_getsid(sess1, &str1, &str1len) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
310 ms[0] = new_state(str1, &freed[0]);
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
311 ms[1] = new_state(str1, &freed[1]);
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
312 CHECK( 0, fd_sess_getsid(sess2, &str1, &str1len) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
313 ms[2] = new_state(str1, &freed[2]);
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
314 ms[3] = new_state(str1, &freed[3]);
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
315 CHECK( 0, fd_sess_getsid(sess3, &str1, &str1len) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
316 ms[4] = new_state(str1, &freed[4]);
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
317 ms[5] = new_state(str1, &freed[5]);
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
318 ms[5]->opaque = g_opaque;
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
319 str2 = os0dup(str1, str1len);
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
320 CHECK( 1, str2 ? 1 : 0 );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
321
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
322 /* Store the six states */
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
323 CHECK( 0, fd_sess_state_store ( hdl1, sess1, &ms[0] ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
324 CHECK( 0, fd_sess_state_store ( hdl2, sess1, &ms[1] ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
325 CHECK( 0, fd_sess_state_store ( hdl1, sess2, &ms[2] ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
326 CHECK( 0, fd_sess_state_store ( hdl2, sess2, &ms[3] ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
327 CHECK( 0, fd_sess_state_store ( hdl1, sess3, &ms[4] ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
328 CHECK( 0, fd_sess_state_store ( hdl2, sess3, &ms[5] ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
329
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
330 #if 0
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
331 fd_sess_dump(0, sess1);
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
332 fd_sess_dump(0, sess2);
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
333 fd_sess_dump(0, sess3);
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
334 #endif
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
335
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
336 /* Destroy session 3 */
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
337 CHECK( 0, fd_sess_destroy( &sess3 ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
338 CHECK( 0, freed[0] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
339 CHECK( 0, freed[1] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
340 CHECK( 0, freed[2] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
341 CHECK( 0, freed[3] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
342 CHECK( 1, freed[4] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
343 CHECK( 1, freed[5] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
344
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
345 /* Destroy handler 2 */
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
346 CHECK( 0, fd_sess_handler_destroy( &hdl2, &testptr ) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
347 CHECK( 0, freed[0] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
348 CHECK( 1, freed[1] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
349 CHECK( 0, freed[2] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
350 CHECK( 1, freed[3] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
351 CHECK( 1, freed[4] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
352 CHECK( 1, freed[5] );
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
353 CHECK( 1, testptr == g_opaque ? 1 : 0 );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
354
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
355 #if 1
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
356 fd_sess_dump(0, sess1);
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
357 fd_sess_dump(0, sess2);
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
358 #endif
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
359
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
360 /* Create again session 3, check that no data is associated to it */
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
361 CHECK( 0, fd_sess_fromsid( str2, str1len, &sess3, &new ) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
362 CHECK( 1, new ? 1 : 0 );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
363 CHECK( 0, fd_sess_state_retrieve( hdl1, sess3, &tms ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
364 CHECK( NULL, tms );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
365 CHECK( 0, fd_sess_destroy( &sess3 ) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
366 free(str2);
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
367
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
368 /* Timeout does call cleanups */
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
369 CHECK( 0, clock_gettime(CLOCK_REALTIME, &timeout) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
370 CHECK( 0, fd_sess_settimeout( sess2, &timeout) );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
371 #if 1
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
372 fd_sess_dump(0, sess1);
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
373 fd_sess_dump(0, sess2);
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
374 #endif
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
375 timeout.tv_sec = 0;
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
376 timeout.tv_nsec= 50000000; /* 50 ms */
249
6e6ada749a11 Replaced clock_nanosleep since it is missing on FreeBSD platform
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 6
diff changeset
377 CHECK( 0, nanosleep(&timeout, NULL) );
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
378 CHECK( 0, freed[0] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
379 CHECK( 1, freed[1] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
380 CHECK( 1, freed[2] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
381 CHECK( 1, freed[3] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
382 CHECK( 1, freed[4] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
383 CHECK( 1, freed[5] );
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
384
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
385 /* Check the last data can still be retrieved */
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
386 CHECK( 0, fd_sess_state_retrieve( hdl1, sess1, &tms ) );
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
387 CHECK( 1, tms ? 1 : 0);
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
388 CHECK( 0, fd_sess_getsid(sess1, &str1, &str1len) );
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
389 mycleanup(tms, str1, NULL);
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
390 }
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
391
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 662
diff changeset
392 /* TODO: add tests on messages referencing sessions */
5
c2d2729e3603 Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 3
diff changeset
393
3
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
394 /* That's all for the tests yet */
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
395 PASSTEST();
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
396 }
ef303f1078ab Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
397
"Welcome to our mercurial repository"