Mercurial > hg > freeDiameter
annotate tests/testostr.c @ 1277:9860ff6e9497
Make a variable match the extension name. No functional change.
author | Thomas Klausner <tk@giga.or.at> |
---|---|
date | Wed, 06 Aug 2014 15:03:34 +0200 |
parents | 4a9f08d6b6ba |
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:
738
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 * * |
662
2e94ef0515d7
Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
658
diff
changeset
|
5 * Copyright (c) 2011, 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 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
38 #define TEST_STR (os0_t)"This is my test string (with extra unused data)" |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
39 |
707
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
40 /* The following string contains UTF-8 encoded characters (Chinese characters) */ |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
41 #define TEST_IDN_UTF8 "freeDiameter.??????" |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
42 #define TEST_IDN_CONV "freeDiameter.xn--fiqs8s" |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
43 |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
44 /* Main test routine */ |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
45 int main(int argc, char *argv[]) |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
46 { |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
47 /* First, initialize the daemon modules */ |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
48 INIT_FD(); |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
49 |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
50 /* Check the hash function */ |
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 uint8_t buf[30]; |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
53 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
54 uint32_t hash = fd_os_hash(TEST_STR, CONSTSTRLEN(TEST_STR)); /* reference value */ |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
55 |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
56 /* Check that a hash of a substring / surstring is different */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
57 CHECK( 1, hash != fd_os_hash(TEST_STR, CONSTSTRLEN(TEST_STR) - 1) ? 1 : 0 ); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
58 CHECK( 1, hash != fd_os_hash(TEST_STR, CONSTSTRLEN(TEST_STR) + 1) ? 1 : 0 ); |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
59 |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
60 /* Check alignment of the string is not important */ |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
61 memcpy(buf + 4, TEST_STR, CONSTSTRLEN(TEST_STR)); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
62 CHECK( hash, fd_os_hash(buf + 4, CONSTSTRLEN(TEST_STR)) ); |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
63 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
64 memcpy(buf + 3, TEST_STR, CONSTSTRLEN(TEST_STR)); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
65 CHECK( hash, fd_os_hash(buf + 3, CONSTSTRLEN(TEST_STR)) ); |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
66 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
67 memcpy(buf + 2, TEST_STR, CONSTSTRLEN(TEST_STR)); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
68 CHECK( hash, fd_os_hash(buf + 2, CONSTSTRLEN(TEST_STR)) ); |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
69 |
706
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
70 memcpy(buf + 1, TEST_STR, CONSTSTRLEN(TEST_STR)); |
4ffbc9f1e922
Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
662
diff
changeset
|
71 CHECK( hash, fd_os_hash(buf + 1, CONSTSTRLEN(TEST_STR)) ); |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
72 } |
707
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
73 |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
74 /* Check the Diameter Identity functions */ |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
75 { |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
76 char * res; |
717
571b3abaa5df
Support for Diameter Redirects through rt_redirect.fdx extension (EXPERIMENTAL)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
709
diff
changeset
|
77 size_t len=0; |
707
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
78 |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
79 /* A valid ASCII domain name */ |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
80 res = TEST_IDN_CONV; |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
81 CHECK( 0, fd_os_validate_DiameterIdentity(&res, &len, 1) ); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
82 CHECK( 0, strcasecmp(res, TEST_IDN_CONV) ); /* the function does not change a valid DN */ |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
83 CHECK( 0, fd_os_validate_DiameterIdentity(&res, &len, 0) ); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
84 CHECK( 0, strcasecmp(res, TEST_IDN_CONV) ); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
85 CHECK( CONSTSTRLEN(TEST_IDN_CONV), len ); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
86 free(res); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
87 |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
88 /* Now, an invalid string */ |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
89 res = TEST_IDN_UTF8; |
717
571b3abaa5df
Support for Diameter Redirects through rt_redirect.fdx extension (EXPERIMENTAL)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
709
diff
changeset
|
90 len = 0; |
707
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
91 |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
92 #ifdef DIAMID_IDNA_IGNORE |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
93 |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
94 /* The UTF-8 chars are considered valid */ |
709
19a9470de77a
Fix a few compilations errors and warnings
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
707
diff
changeset
|
95 CHECK( 1, fd_os_is_valid_DiameterIdentity((os0_t)TEST_IDN_UTF8, CONSTSTRLEN(TEST_IDN_UTF8) ) ); |
707
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
96 |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
97 /* The string should be passed unmodified */ |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
98 CHECK( 0, fd_os_validate_DiameterIdentity(&res, &len, 1) ); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
99 CHECK( 0, strcasecmp(res, TEST_IDN_UTF8) ); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
100 CHECK( 0, fd_os_cmp(res, len, TEST_IDN_UTF8, CONSTSTRLEN(TEST_IDN_UTF8)) ); |
738
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
101 CHECK( 0, fd_os_almostcasesrch(res, len, TEST_IDN_UTF8, CONSTSTRLEN(TEST_IDN_UTF8), NULL) ); |
707
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
102 CHECK( 0, fd_os_validate_DiameterIdentity(&res, &len, 0) ); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
103 CHECK( 0, strcasecmp(res, TEST_IDN_UTF8) ); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
104 CHECK( CONSTSTRLEN(TEST_IDN_UTF8), len ); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
105 free(res); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
106 |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
107 #else /* DIAMID_IDNA_IGNORE */ |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
108 |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
109 /* The UTF-8 chars are recognized as invalid DiameterIdentity */ |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
110 CHECK( 0, fd_os_is_valid_DiameterIdentity((os0_t)TEST_IDN_UTF8, CONSTSTRLEN(TEST_IDN_UTF8) )); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
111 |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
112 # ifdef DIAMID_IDNA_REJECT |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
113 |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
114 /* The string must be rejected */ |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
115 CHECK( EINVAL, fd_os_validate_DiameterIdentity(&res, &len, 1) ); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
116 |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
117 # else /* DIAMID_IDNA_REJECT */ |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
118 |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
119 /* The string should be transformed into TEST_IDN_CONV */ |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
120 CHECK( 0, fd_os_validate_DiameterIdentity(&res, &len, 1) ); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
121 CHECK( 0, strcasecmp(res, TEST_IDN_CONV) ); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
122 CHECK( CONSTSTRLEN(TEST_IDN_CONV), len ); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
123 free(res); |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
124 |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
125 # endif /* DIAMID_IDNA_REJECT */ |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
126 #endif /* DIAMID_IDNA_IGNORE */ |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
127 |
707
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
128 } |
e387d5c6b6f5
Added support for Internationalized Domain Names (IDNA) using GNU libidn
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
706
diff
changeset
|
129 |
738
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
130 { |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
131 /* test fd_os_cmp and fd_os_almostcasesrch and that they are compatible */ |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
132 char *t1 = "a"; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
133 char *t2 = "b"; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
134 char *t3 = "C"; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
135 char *t4 = "d"; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
136 char *t5 = "aa"; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
137 char *t6 = "aB"; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
138 char *t7 = "Ac"; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
139 char *t8 = "aD"; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
140 char *t9 = "AAA"; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
141 |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
142 char *t5b = "Aa"; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
143 char *t6b = "ab"; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
144 |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
145 /* First, create a list with all the elements in order given by fd_os_cmp */ |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
146 char *t[] = { t1, t2, t3, t4, t5, t6,t7, t8, t9 }; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
147 int i; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
148 struct fd_list *li, l = FD_LIST_INITIALIZER(l); |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
149 for (i = 0; i < sizeof(t) / sizeof(t[0]); i++) { |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
150 /* insert t[i] */ |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
151 struct fd_list *n = malloc(sizeof(struct fd_list)); |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
152 CHECK( 1, n ? 1 : 0 ); |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
153 fd_list_init(n, t[i]); |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
154 for (li = l.next; li != &l; li = li->next) { |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
155 if ( fd_os_cmp(t[i], strlen(t[i]), li->o, strlen(li->o)) < 0 ) |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
156 break; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
157 } |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
158 fd_list_insert_before(li, n); |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
159 } |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
160 /* in principle the result is: [ "C", "a", "b", "d", "Ac", "aB", "aD", "aa", "AAA" ] */ |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
161 |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
162 /* Since there is no equal value in the list (even case-insensitive), check that the order is valid also for the caseinsensitive variant */ |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
163 for (li = l.next; li != l.prev; li = li->next) { |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
164 CHECK( 1, fd_os_almostcasesrch(li->o, strlen(li->o), li->next->o, strlen(li->next->o), NULL) < 0 ? 1 : 0 ); |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
165 } |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
166 |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
167 /* Now check that we can case-insentively find t5b and t6b to be equal to t5 and t6 resp. (this is how we use it in the daemon) */ |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
168 for (li = l.next; li != &l; li = li->next) { |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
169 int cont, cmp; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
170 cmp = fd_os_almostcasesrch(t5b, strlen(t5b), li->o, strlen(li->o), &cont); |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
171 TRACE_DEBUG(FULL, "Comp '%s' : %d, %d", (char *)li->o, cmp, cont); |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
172 if (cmp == 0) |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
173 break; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
174 if (!cont) |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
175 break; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
176 } |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
177 CHECK( li->o, t5 ); |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
178 |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
179 for (li = l.next; li != &l; li = li->next) { |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
180 int cont, cmp; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
181 cmp = fd_os_almostcasesrch(t6b, strlen(t6b), li->o, strlen(li->o), &cont); |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
182 TRACE_DEBUG(FULL, "Comp '%s' : %d, %d", (char *)li->o, cmp, cont); |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
183 if (cmp == 0) |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
184 break; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
185 if (!cont) |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
186 break; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
187 } |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
188 CHECK( li->o, t6 ); |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
189 |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
190 |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
191 /* done */ |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
192 while (!FD_IS_LIST_EMPTY(&l)) { |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
193 li = l.next; |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
194 fd_list_unlink(li); |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
195 free(li); |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
196 } |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
197 } |
d666051658bd
Fix broken 'almostcasecmp' logic
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
717
diff
changeset
|
198 |
3
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
199 /* 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
|
200 PASSTEST(); |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
201 } |
ef303f1078ab
Progress; added session module; testsess to be completed
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
202 |