Mercurial > hg > freeDiameter
annotate tests/testpeers.c @ 1258:97caad40b665
Cast enum to int to allow comparison with picky compiler(flag)s.
author | Thomas Klausner <tk@giga.or.at> |
---|---|
date | Tue, 11 Feb 2014 14:47:02 +0100 |
parents | 1af09cc156d6 |
children |
rev | line source |
---|---|
748
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
1 /********************************************************************************************************* |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
2 * Software License Agreement (BSD License) * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * |
1f721af3cac3
New test to try and reproduce a reported problem
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 * |
748
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
6 * All rights reserved. * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
7 * * |
1f721af3cac3
New test to try and reproduce a reported problem
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 * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
9 * permitted provided that the following conditions are met: * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
10 * * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
11 * * Redistributions of source code must retain the above * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
12 * copyright notice, this list of conditions and the * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
13 * following disclaimer. * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
14 * * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
15 * * Redistributions in binary form must reproduce the above * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
16 * copyright notice, this list of conditions and the * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
17 * following disclaimer in the documentation and/or other * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
18 * materials provided with the distribution. * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
19 * * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
20 * * Neither the name of the WIDE Project or NICT nor the * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
21 * names of its contributors may be used to endorse or * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
22 * promote products derived from this software without * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
23 * specific prior written permission of WIDE Project and * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
24 * NICT. * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
25 * * |
1f721af3cac3
New test to try and reproduce a reported problem
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 * |
1f721af3cac3
New test to try and reproduce a reported problem
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 * |
1f721af3cac3
New test to try and reproduce a reported problem
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 * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
1f721af3cac3
New test to try and reproduce a reported problem
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 * |
1f721af3cac3
New test to try and reproduce a reported problem
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 * |
1f721af3cac3
New test to try and reproduce a reported problem
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 * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
34 *********************************************************************************************************/ |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
35 |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
36 #include "tests.h" |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
37 |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
38 const char * ids[] = { "b11", "b14", "b1", "b4" }; |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
39 #define DomainName "localdomain" |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
40 |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
41 /* Main test routine */ |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
42 int main(int argc, char *argv[]) |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
43 { |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
44 /* First, initialize the daemon modules */ |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
45 INIT_FD(); |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
46 |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
47 /* Create 4 peers with these ids */ |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
48 { |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
49 int i; |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
50 struct peer_info inf; |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
51 char locid[255]; |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
52 memset(&inf, 0, sizeof(inf)); |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
53 inf.pi_diamid = (char *)locid; |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
54 for (i=0; i < sizeof(ids) / sizeof(ids[0]); i++) { |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
55 snprintf(locid, sizeof(locid), "%s." DomainName, ids[i]); |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
56 CHECK( 0, fd_peer_add(&inf, __FILE__, NULL, NULL)); |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
57 } |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
58 } |
1088
1d1a20a0779d
Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents:
748
diff
changeset
|
59 fd_log_debug("%s", fd_peer_dump_list(FD_DUMP_TEST_PARAMS, 0)); |
748
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
60 /* Check we are able to find again any of these */ |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
61 { |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
62 int i; |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
63 char locid[255]; |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
64 struct peer_hdr *p; |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
65 for (i=0; i < sizeof(ids) / sizeof(ids[0]); i++) { |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
66 snprintf(locid, sizeof(locid), "%s." DomainName, ids[i]); |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
67 CHECK( 0, fd_peer_getbyid((DiamId_t)locid, strlen((char *)locid), 0, &p)); |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
68 CHECK( 0, strcmp((char *)locid, p->info.pi_diamid)); |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
69 CHECK( 0, fd_peer_getbyid((DiamId_t)locid, strlen((char *)locid), 1, &p)); |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
70 CHECK( 0, strcmp((char *)locid, p->info.pi_diamid)); |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
71 } |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
72 } |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
73 |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
74 |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
75 /* That's all for the tests yet */ |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
76 PASSTEST(); |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
77 } |
1f721af3cac3
New test to try and reproduce a reported problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
78 |