Mercurial > hg > freeDiameter
annotate extensions/test_app/test_app.c @ 1214:c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
author | Sebastien Decugis <sdecugis@freediameter.net> |
---|---|
date | Tue, 18 Jun 2013 16:27:45 +0800 |
parents | 2c62bba0ef4b |
children |
rev | line source |
---|---|
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
1 /********************************************************************************************************* |
3910804c84db
Ported the app_test application
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:
575
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> * |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
4 * * |
1127
1af09cc156d6
Updated copyright information
Sebastien Decugis <sdecugis@freediameter.net>
parents:
974
diff
changeset
|
5 * Copyright (c) 2013, WIDE Project and NICT * |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
6 * All rights reserved. * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
7 * * |
3910804c84db
Ported the app_test application
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 * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
9 * permitted provided that the following conditions are met: * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
10 * * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
11 * * Redistributions of source code must retain the above * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
12 * copyright notice, this list of conditions and the * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
13 * following disclaimer. * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
14 * * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
15 * * Redistributions in binary form must reproduce the above * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
16 * copyright notice, this list of conditions and the * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
17 * following disclaimer in the documentation and/or other * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
18 * materials provided with the distribution. * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
19 * * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
20 * * Neither the name of the WIDE Project or NICT nor the * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
21 * names of its contributors may be used to endorse or * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
22 * promote products derived from this software without * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
23 * specific prior written permission of WIDE Project and * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
24 * NICT. * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
25 * * |
3910804c84db
Ported the app_test application
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 * |
3910804c84db
Ported the app_test application
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 * |
3910804c84db
Ported the app_test application
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 * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
3910804c84db
Ported the app_test application
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 * |
3910804c84db
Ported the app_test application
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 * |
3910804c84db
Ported the app_test application
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 * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
34 *********************************************************************************************************/ |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
35 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
36 /* |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
37 * Test application for freeDiameter. |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
38 */ |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
39 |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
40 #include "test_app.h" |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
41 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
42 /* Initialize the configuration */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
43 struct ta_conf * ta_conf = NULL; |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
44 static struct ta_conf _conf; |
572
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
45 static pthread_t ta_stats_th = (pthread_t)NULL; |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
46 |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
47 static int ta_conf_init(void) |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
48 { |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
49 ta_conf = &_conf; |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
50 memset(ta_conf, 0, sizeof(struct ta_conf)); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
51 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
52 /* Set the default values */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
53 ta_conf->vendor_id = 999999; /* Dummy value */ |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
54 ta_conf->appli_id = 0xffffff; /* dummy value */ |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
55 ta_conf->cmd_id = 0xfffffe; /* Experimental */ |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
56 ta_conf->avp_id = 0xffffff; /* dummy value */ |
1214
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1199
diff
changeset
|
57 ta_conf->long_avp_len = 5000; |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
58 ta_conf->mode = MODE_SERV | MODE_CLI; |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
59 ta_conf->dest_realm = strdup(fd_g_config->cnf_diamrlm); |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
60 ta_conf->dest_host = NULL; |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
61 ta_conf->signal = TEST_APP_DEFAULT_SIGNAL; |
575
66f188b3ca84
Configurable parameters for the benchmark mode
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
572
diff
changeset
|
62 ta_conf->bench_concur = 100; |
66f188b3ca84
Configurable parameters for the benchmark mode
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
572
diff
changeset
|
63 ta_conf->bench_duration = 10; |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
64 |
572
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
65 /* Initialize the mutex */ |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
66 CHECK_POSIX( pthread_mutex_init(&ta_conf->stats_lock, NULL) ); |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
67 |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
68 return 0; |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
69 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
70 |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
71 static void ta_conf_dump(void) |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
72 { |
98 | 73 if (!TRACE_BOOL(INFO)) |
74 return; | |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
75 fd_log_debug( "------- app_test configuration dump: ---------"); |
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
76 fd_log_debug( " Vendor Id .......... : %u", ta_conf->vendor_id); |
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
77 fd_log_debug( " Application Id ..... : %u", ta_conf->appli_id); |
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
78 fd_log_debug( " Command Id ......... : %u", ta_conf->cmd_id); |
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
79 fd_log_debug( " AVP Id ............. : %u", ta_conf->avp_id); |
1214
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1199
diff
changeset
|
80 fd_log_debug( " Long AVP Id ........ : %u", ta_conf->long_avp_id); |
c2fbaf2985f4
New options to test_app extension to generate long Diameter messages
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1199
diff
changeset
|
81 fd_log_debug( " Long AVP len ....... : %zu", ta_conf->long_avp_len); |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
82 fd_log_debug( " Mode ............... : %s%s%s", ta_conf->mode & MODE_SERV ? "Serv" : "", ta_conf->mode & MODE_CLI ? "Cli" : "", ta_conf->mode & MODE_BENCH ? " (Benchmark)" : ""); |
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
83 fd_log_debug( " Destination Realm .. : %s", ta_conf->dest_realm ?: "- none -"); |
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
84 fd_log_debug( " Destination Host ... : %s", ta_conf->dest_host ?: "- none -"); |
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
85 fd_log_debug( " Signal ............. : %i", ta_conf->signal); |
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
86 fd_log_debug( "------- /app_test configuration dump ---------"); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
87 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
88 |
575
66f188b3ca84
Configurable parameters for the benchmark mode
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
572
diff
changeset
|
89 /* Function to display statistics periodically */ |
572
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
90 static void * ta_stats(void * arg) { |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
91 |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
92 struct timespec start, now; |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
93 struct ta_stats copy; |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
94 |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
95 /* Get the start time */ |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
96 CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &start), ); |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
97 |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
98 /* Now, loop until canceled */ |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
99 while (1) { |
575
66f188b3ca84
Configurable parameters for the benchmark mode
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
572
diff
changeset
|
100 /* Display statistics every XX seconds */ |
1195
16f2d2f15e5b
Allow better usage in benchmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1127
diff
changeset
|
101 sleep(ta_conf->bench_duration + 3); |
572
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
102 |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
103 /* Now, get the current stats */ |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
104 CHECK_POSIX_DO( pthread_mutex_lock(&ta_conf->stats_lock), ); |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
105 memcpy(©, &ta_conf->stats, sizeof(struct ta_stats)); |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
106 CHECK_POSIX_DO( pthread_mutex_unlock(&ta_conf->stats_lock), ); |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
107 |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
108 /* Get the current execution time */ |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
109 CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &now), ); |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
110 |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
111 /* Now, display everything */ |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
112 fd_log_debug( "------- app_test statistics ---------"); |
572
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
113 if (now.tv_nsec >= start.tv_nsec) { |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
114 fd_log_debug( " Executing for: %d.%06ld sec", |
572
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
115 (int)(now.tv_sec - start.tv_sec), |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
116 (long)(now.tv_nsec - start.tv_nsec) / 1000); |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
117 } else { |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
118 fd_log_debug( " Executing for: %d.%06ld sec", |
572
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
119 (int)(now.tv_sec - 1 - start.tv_sec), |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
120 (long)(now.tv_nsec + 1000000000 - start.tv_nsec) / 1000); |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
121 } |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
122 |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
123 if (ta_conf->mode & MODE_SERV) { |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
124 fd_log_debug( " Server: %llu message(s) echoed", copy.nb_echoed); |
572
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
125 } |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
126 if (ta_conf->mode & MODE_CLI) { |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
127 fd_log_debug( " Client:"); |
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
128 fd_log_debug( " %llu message(s) sent", copy.nb_sent); |
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
129 fd_log_debug( " %llu error(s) received", copy.nb_errs); |
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
130 fd_log_debug( " %llu answer(s) received", copy.nb_recv); |
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
131 fd_log_debug( " fastest: %ld.%06ld sec.", copy.shortest / 1000000, copy.shortest % 1000000); |
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
132 fd_log_debug( " slowest: %ld.%06ld sec.", copy.longest / 1000000, copy.longest % 1000000); |
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
133 fd_log_debug( " Average: %ld.%06ld sec.", copy.avg / 1000000, copy.avg % 1000000); |
572
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
134 } |
974
2091bf698fb1
Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents:
741
diff
changeset
|
135 fd_log_debug( "-------------------------------------"); |
572
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
136 } |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
137 |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
138 return NULL; /* never called */ |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
139 } |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
140 |
1199
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
141 static struct fd_hook_hdl * hookhdl[2] = { NULL, NULL }; |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
142 static void ta_hook_cb_silent(enum fd_hook_type type, struct msg * msg, struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, void * regdata) { |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
143 } |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
144 static void ta_hook_cb_oneline(enum fd_hook_type type, struct msg * msg, struct peer_hdr * peer, void * other, struct fd_hook_permsgdata *pmd, void * regdata) { |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
145 char * buf = NULL; |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
146 size_t len; |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
147 |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
148 CHECK_MALLOC_DO( fd_msg_dump_summary(&buf, &len, NULL, msg, NULL, 0, 0), |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
149 { LOG_E("Error while dumping a message"); return; } ); |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
150 |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
151 LOG_N("{%d} %s: %s", type, (char *)other ?:"<nil>", buf ?:"<nil>"); |
1195
16f2d2f15e5b
Allow better usage in benchmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1127
diff
changeset
|
152 |
1199
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
153 free(buf); |
1195
16f2d2f15e5b
Allow better usage in benchmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1127
diff
changeset
|
154 } |
16f2d2f15e5b
Allow better usage in benchmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1127
diff
changeset
|
155 |
16f2d2f15e5b
Allow better usage in benchmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1127
diff
changeset
|
156 |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
157 /* entry point */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
158 static int ta_entry(char * conffile) |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
159 { |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
160 TRACE_ENTRY("%p", conffile); |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
161 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
162 /* Initialize configuration */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
163 CHECK_FCT( ta_conf_init() ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
164 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
165 /* Parse configuration file */ |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
166 if (conffile != NULL) { |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
167 CHECK_FCT( ta_conf_handle(conffile) ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
168 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
169 |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
170 TRACE_DEBUG(INFO, "Extension Test_App initialized with configuration: '%s'", conffile); |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
171 ta_conf_dump(); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
172 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
173 /* Install objects definitions for this test application */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
174 CHECK_FCT( ta_dict_init() ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
175 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
176 /* Install the handlers for incoming messages */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
177 if (ta_conf->mode & MODE_SERV) { |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
178 CHECK_FCT( ta_serv_init() ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
179 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
180 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
181 /* Start the signal handler thread */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
182 if (ta_conf->mode & MODE_CLI) { |
572
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
183 if (ta_conf->mode & MODE_BENCH) { |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
184 CHECK_FCT( ta_bench_init() ); |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
185 } else { |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
186 CHECK_FCT( ta_cli_init() ); |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
187 } |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
188 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
189 |
101
c16e97f91c59
Added advertisement of the test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
98
diff
changeset
|
190 /* Advertise the support for the test application in the peer */ |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
191 CHECK_FCT( fd_disp_app_support ( ta_appli, ta_vendor, 1, 0 ) ); |
101
c16e97f91c59
Added advertisement of the test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
98
diff
changeset
|
192 |
1195
16f2d2f15e5b
Allow better usage in benchmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1127
diff
changeset
|
193 if (ta_conf->mode & MODE_BENCH) { |
16f2d2f15e5b
Allow better usage in benchmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1127
diff
changeset
|
194 /* Register an empty hook to disable the default handling */ |
1199
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
195 CHECK_FCT( fd_hook_register( HOOK_MASK( HOOK_DATA_RECEIVED, HOOK_MESSAGE_RECEIVED, HOOK_MESSAGE_LOCAL, HOOK_MESSAGE_SENT, HOOK_MESSAGE_ROUTING_FORWARD, HOOK_MESSAGE_ROUTING_LOCAL ), |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
196 ta_hook_cb_silent, NULL, NULL, &hookhdl[0]) ); |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
197 CHECK_FCT( fd_hook_register( HOOK_MASK( HOOK_MESSAGE_ROUTING_ERROR, HOOK_MESSAGE_DROPPED ), |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
198 ta_hook_cb_oneline, NULL, NULL, &hookhdl[1]) ); |
1195
16f2d2f15e5b
Allow better usage in benchmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1127
diff
changeset
|
199 |
16f2d2f15e5b
Allow better usage in benchmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1127
diff
changeset
|
200 } |
16f2d2f15e5b
Allow better usage in benchmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1127
diff
changeset
|
201 |
572
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
202 /* Start the statistics thread */ |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
203 CHECK_POSIX( pthread_create(&ta_stats_th, NULL, ta_stats, NULL) ); |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
204 |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
205 return 0; |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
206 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
207 |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
208 /* Unload */ |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
209 void fd_ext_fini(void) |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
210 { |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
211 if (ta_conf->mode & MODE_CLI) |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
212 ta_cli_fini(); |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
213 if (ta_conf->mode & MODE_SERV) |
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
214 ta_serv_fini(); |
1199
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
215 if (hookhdl[0]) |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
216 fd_hook_unregister( hookhdl[0] ); |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
217 if (hookhdl[1]) |
2c62bba0ef4b
Add some hooks in test_app in becnhmark mode
Sebastien Decugis <sdecugis@freediameter.net>
parents:
1198
diff
changeset
|
218 fd_hook_unregister( hookhdl[1] ); |
572
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
219 CHECK_FCT_DO( fd_thr_term(&ta_stats_th), ); |
b1b56d4682d0
Added benchmark mode in test_app
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
258
diff
changeset
|
220 CHECK_POSIX_DO( pthread_mutex_destroy(&ta_conf->stats_lock), ); |
93
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
221 } |
3910804c84db
Ported the app_test application
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
222 |
120
d7acdc46134d
Renamed several extensions
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
108
diff
changeset
|
223 EXTENSION_ENTRY("test_app", ta_entry); |