Mercurial > hg > freeDiameter
annotate tests/testsess.c @ 1293:17e6e6d72c9b
Added tag 1.2.1-rc2 for changeset 13948c684c35
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Thu, 18 Jun 2015 22:58:01 +0800 |
parents | 3322c48c2177 |
children |
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 * * |
1127
1af09cc156d6
Updated copyright information
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1088
diff
changeset
|
5 * Copyright (c) 2013, 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 |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
888
diff
changeset
|
45 struct sess_state { |
3
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 |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
888
diff
changeset
|
52 static void mycleanup( struct sess_state * 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 |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
888
diff
changeset
|
69 static __inline__ struct sess_state * 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 { |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
888
diff
changeset
|
71 struct sess_state *new; |
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
888
diff
changeset
|
72 new = malloc(sizeof(struct sess_state)); |
5
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 ); |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
888
diff
changeset
|
74 memset(new, 0, sizeof(struct sess_state)); |
5
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 */ |
888
63931db83e96
Fix compilation warning
Sebastien Decugis <sdecugis@freediameter.net>
parents:
788
diff
changeset
|
85 #undef strlen |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
86 #define strlen(s) strlen((char *)s) |
888
63931db83e96
Fix compilation warning
Sebastien Decugis <sdecugis@freediameter.net>
parents:
788
diff
changeset
|
87 #undef strncmp |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
88 #define strncmp(s1,s2,l) strncmp((char *)s1, (char *)s2, l) |
888
63931db83e96
Fix compilation warning
Sebastien Decugis <sdecugis@freediameter.net>
parents:
788
diff
changeset
|
89 #undef strcmp |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
90 #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
|
91 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
92 |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
93 /* Main test routine */ |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
94 int main(int argc, char *argv[]) |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
95 { |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
96 struct session_handler * hdl1, *hdl2; |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
97 struct session *sess1, *sess2, *sess3; |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
98 os0_t str1, str2; |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
99 size_t str1len, str2len; |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
100 int new; |
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 /* First, initialize the daemon modules */ |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
103 INIT_FD(); |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
104 |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
105 /* 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
|
106 { |
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
|
107 void * testptr = NULL; |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
888
diff
changeset
|
108 CHECK( 0, fd_sess_handler_create ( &hdl1, mycleanup, NULL, NULL ) ); |
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
888
diff
changeset
|
109 CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, NULL, NULL ) ); |
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
|
110 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
|
111 CHECK( 1, testptr == NULL ? 1 : 0 ); |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
888
diff
changeset
|
112 CHECK( 0, fd_sess_handler_create ( &hdl2, mycleanup, NULL, g_opaque ) ); |
5
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
113 #if 0 |
1162
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
114 fd_log_debug("%s", fd_sess_dump_hdl(FD_DUMP_TEST_PARAMS, hdl1)); |
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
115 fd_log_debug("%s", fd_sess_dump_hdl(FD_DUMP_TEST_PARAMS, hdl2)); |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
116 #endif |
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 |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
119 /* 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
|
120 { |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
121 /* DiamId is provided, not opt */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
122 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
|
123 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
|
124 #if 0 |
1162
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
125 fd_log_debug("%s", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1)); |
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
126 fd_log_debug("%s", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1)); |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
127 #endif |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
128 |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
129 /* 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
|
130 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
|
131 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
|
132 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
|
133 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
|
134 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
|
135 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
|
136 CHECK( 0, fd_sess_destroy( &sess1 ) ); |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
137 CHECK( 0, fd_sess_destroy( &sess2 ) ); |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
138 |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
139 /* diamId and opt */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
140 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
|
141 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
|
142 #if 0 |
1162
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
143 fd_log_debug("%s", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1)); |
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
144 fd_log_debug("%s", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1)); |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
145 #endif |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
146 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
147 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
|
148 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
|
149 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
|
150 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
151 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
|
152 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
|
153 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
|
154 |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
155 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
|
156 CHECK( 0, fd_sess_destroy( &sess1 ) ); |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
157 CHECK( 0, fd_sess_destroy( &sess2 ) ); |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
158 |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
159 /* Now, only opt is provided */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
160 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
|
161 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
|
162 CHECK( sess2, sess1 ); |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
163 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
|
164 CHECK( sess3, sess1 ); |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
165 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
|
166 #if 0 |
1162
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
167 fd_log_debug("%s", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1)); |
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
168 fd_log_debug("%s", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1)); |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
169 #endif |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
170 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
|
171 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
|
172 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
|
173 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
|
174 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
|
175 |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
176 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
|
177 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
|
178 } |
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
|
179 |
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 /* 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
|
181 { |
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 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
|
183 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
|
184 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
|
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( 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
|
187 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
|
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( 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
|
190 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
|
191 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
|
192 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
|
193 |
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
|
194 } |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
195 |
5
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
196 /* Test fd_sess_fromsid */ |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
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), &sess1, &new ) ); |
5
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
199 CHECK( 1, new ? 1 : 0 ); |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
200 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
201 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
|
202 CHECK( 0, new ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
203 CHECK( sess1, sess2 ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
204 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
205 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
|
206 CHECK( sess1, sess3 ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
207 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
208 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
|
209 } |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
210 |
6
b0d377c79d80
Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
5
diff
changeset
|
211 /* 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
|
212 { |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
888
diff
changeset
|
213 struct sess_state *tms; |
6
b0d377c79d80
Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
5
diff
changeset
|
214 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
215 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
|
216 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
|
217 |
b0d377c79d80
Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
5
diff
changeset
|
218 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
|
219 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
|
220 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
221 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
|
222 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
|
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 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
|
225 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
|
226 |
b0d377c79d80
Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
5
diff
changeset
|
227 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
|
228 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
|
229 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
230 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
|
231 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
|
232 |
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( 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
|
234 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
235 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
|
236 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
|
237 |
b0d377c79d80
Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
5
diff
changeset
|
238 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
|
239 } |
b0d377c79d80
Progress on dispatch API spec; added fd_sess_reclaim function and test
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
5
diff
changeset
|
240 |
5
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
241 /* Test timeout function */ |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
242 { |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
243 struct timespec timeout; |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
244 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
245 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
|
246 CHECK( 1, new ? 1 : 0 ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
247 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
248 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
|
249 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
|
250 timeout.tv_sec = 0; |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
251 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
|
252 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
|
253 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
254 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
|
255 CHECK( 1, new ? 1 : 0 ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
256 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
257 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
|
258 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
|
259 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
|
260 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
261 /* Create a second session */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
262 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
|
263 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
264 /* 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
|
265 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
266 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
|
267 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
|
268 } |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
269 |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
270 |
5
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
271 /* Test states operations */ |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
272 { |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
888
diff
changeset
|
273 struct sess_state * ms[6], *tms; |
5
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
274 int freed[6]; |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
275 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
|
276 void * testptr = NULL; |
5
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
277 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
278 /* Create three sessions */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
279 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
|
280 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
|
281 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
|
282 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
283 /* Create 2 states */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
284 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
|
285 freed[0] = 0; |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
286 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
|
287 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
|
288 |
5
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
289 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
|
290 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
|
291 CHECK( NULL, ms[0] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
292 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
|
293 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
|
294 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
|
295 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
296 #if 0 |
1162
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
297 fd_log_debug("%s", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1)); |
5
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
298 #endif |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
299 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
300 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
|
301 CHECK( tms, ms[0] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
302 CHECK( 0, freed[0] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
303 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
304 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
|
305 CHECK( NULL, tms ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
306 |
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
|
307 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
|
308 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
|
309 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
310 /* Now create 6 states */ |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
311 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
|
312 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
|
313 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
|
314 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
|
315 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
|
316 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
|
317 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
|
318 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
|
319 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
|
320 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
|
321 ms[5]->opaque = g_opaque; |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
322 str2 = os0dup(str1, str1len); |
5
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
323 CHECK( 1, str2 ? 1 : 0 ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
324 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
325 /* Store the six states */ |
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 ( hdl1, sess1, &ms[0] ) ); |
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 ( hdl2, sess1, &ms[1] ) ); |
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 ( hdl1, sess2, &ms[2] ) ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
329 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
|
330 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
|
331 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
|
332 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
333 #if 0 |
1162
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
334 fd_log_debug("%s", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1)); |
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
335 fd_log_debug("%s", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1)); |
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
336 fd_log_debug("%s", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess3, 1)); |
5
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
337 #endif |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
338 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
339 /* Destroy session 3 */ |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
340 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
|
341 CHECK( 0, freed[0] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
342 CHECK( 0, freed[1] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
343 CHECK( 0, freed[2] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
344 CHECK( 0, freed[3] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
345 CHECK( 1, freed[4] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
346 CHECK( 1, freed[5] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
347 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
348 /* 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
|
349 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
|
350 CHECK( 0, freed[0] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
351 CHECK( 1, freed[1] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
352 CHECK( 0, freed[2] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
353 CHECK( 1, freed[3] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
354 CHECK( 1, freed[4] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
355 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
|
356 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
|
357 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
358 #if 1 |
1162
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
359 fd_log_debug("%s", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1)); |
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
360 fd_log_debug("%s", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1)); |
5
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
361 #endif |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
362 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
363 /* 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
|
364 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
|
365 CHECK( 1, new ? 1 : 0 ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
366 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
|
367 CHECK( NULL, tms ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
368 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
|
369 free(str2); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
370 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
371 /* Timeout does call cleanups */ |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
372 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
|
373 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
|
374 #if 1 |
1162
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
375 fd_log_debug("%s", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess1, 1)); |
3322c48c2177
Remove \n from fd_log_debug lines.
Thomas Klausner <tk@giga.or.at>
parents:
1127
diff
changeset
|
376 fd_log_debug("%s", fd_sess_dump(FD_DUMP_TEST_PARAMS, sess2, 1)); |
5
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
377 #endif |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
378 timeout.tv_sec = 0; |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
379 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
|
380 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
|
381 CHECK( 0, freed[0] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
382 CHECK( 1, freed[1] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
383 CHECK( 1, freed[2] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
384 CHECK( 1, freed[3] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
385 CHECK( 1, freed[4] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
386 CHECK( 1, freed[5] ); |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
387 |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
388 /* 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
|
389 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
|
390 CHECK( 1, tms ? 1 : 0); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
391 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
|
392 mycleanup(tms, str1, NULL); |
5
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
393 } |
c2d2729e3603
Completed new session module tests; some bugs fixed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
3
diff
changeset
|
394 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
395 /* 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
|
396 |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
397 /* 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
|
398 PASSTEST(); |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
399 } |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
400 |