3
A small test and sample program for librecprocess.a
5
@section license License
7
Licensed to the Apache Software Foundation (ASF) under one
8
or more contributor license agreements. See the NOTICE file
9
distributed with this work for additional information
10
regarding copyright ownership. The ASF licenses this file
11
to you under the Apache License, Version 2.0 (the
12
"License"); you may not use this file except in compliance
13
with the License. You may obtain a copy of the License at
15
http://www.apache.org/licenses/LICENSE-2.0
17
Unless required by applicable law or agreed to in writing, software
18
distributed under the License is distributed on an "AS IS" BASIS,
19
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
See the License for the specific language governing permissions and
21
limitations under the License.
24
#include "ink_hrtime.h"
25
#include "P_RecUtils.h"
26
#include "test_RecordsConfig.h"
30
void RecDumpRecordsHt(RecT rec_type);
35
openlog("test_I_RecProcess", LOG_PID | LOG_NDELAY | LOG_NOWAIT, LOG_USER);
38
//-------------------------------------------------------------------------
39
// Test01: Parse Tests
41
// The following test just verifies that we can parse the
42
// 'records.config' file format correctly (e.g can we handle weird
43
// spacing, malformed lines, etc). The test also verifies some of the
44
// basic RecGetRecord functionality.
46
// Run this test with the 'test_records.config' config file. Note
47
// that the configs used by this test are registered in the
48
// 'test_RecordsConfig.cc' file.
49
//-------------------------------------------------------------------------
51
#define PARSE_TEST_UNAVAILABLE(name, failures) \
53
RecString rec_string = 0; \
54
if (RecGetRecordString_Xmalloc("proxy.config.parse_"name, &rec_string) != REC_ERR_FAIL) { \
55
if (rec_string) xfree(rec_string); \
56
printf(" parse_"name": FAIL\n"); \
59
printf(" parse_"name": PASS\n"); \
63
#define PARSE_TEST_COMPARE(name, value, failures) \
65
RecString rec_string = 0; \
66
if (RecGetRecordString_Xmalloc("proxy.config.parse_"name, &rec_string) == REC_ERR_OKAY) { \
67
if (strcmp(rec_string, value) == 0) { \
68
printf(" parse_"name": PASS\n"); \
70
printf(" parse_"name": FAIL\n"); \
75
printf(" parse_"name": FAIL\n"); \
83
printf("[Test01: Parse Tests]\n");
87
PARSE_TEST_UNAVAILABLE("test_1a", failures);
88
PARSE_TEST_UNAVAILABLE("test_1b", failures);
90
// test 2, 2b, 3, 3b, 4, 4b
91
PARSE_TEST_COMPARE("test_2a", "X", failures);
92
PARSE_TEST_COMPARE("test_2b", "X", failures);
93
PARSE_TEST_COMPARE("test_3b", "XXX", failures);
94
PARSE_TEST_COMPARE("test_3b", "XXX", failures);
95
PARSE_TEST_COMPARE("test_4a", "XXX XXX XXX", failures);
96
PARSE_TEST_COMPARE("test_4b", "XXX XXX XXX", failures);
99
printf(" SUMMARY: PASS\n");
101
printf(" SUMMARY: FAIL\n");
106
//-------------------------------------------------------------------------
107
// Test02: Config Tests
109
// The following test stresses some additional config features
110
// (e.g. registration of config update callbacks, config linking, and
111
// config setting). As with Test01, config registration must be done
112
// in 'test_RecordsConfig.cc'.
113
//-------------------------------------------------------------------------
115
bool g_config_update_result = false;
117
RecInt g_link_test_1 = 0;
118
RecFloat g_link_test_2 = 0.0f;
119
RecCounter g_link_test_3 = 0;
122
cb_test_1(const char *name, RecDataT data_type, RecData data, void *cookie)
124
NOWARN_UNUSED(data_type);
125
if ((cookie == (void *) 0x12345678) && (strcmp(data.rec_string, "cb_test_1__changed") == 0)) {
126
printf(" - cb_test_1 (name: %s, data: %s, cookie: 0x%x\n", name, data.rec_string, cookie);
127
g_config_update_result = true;
129
g_config_update_result = false;
135
cb_test_2(const char *name, RecDataT data_type, RecData data, void *cookie)
138
NOWARN_UNUSED(data_type);
140
NOWARN_UNUSED(cookie);
141
g_config_update_result = false;
148
printf("[Test02: Config Tests]\n");
151
printf(" [RecRegisterConfigUpdateCb]\n");
153
// Initialize variables
154
RecSetRecordString("proxy.config.cb_test_1", "cb_test_1__original");
155
RecSetRecordString("proxy.config.cb_test_2", "cb_test_2__original");
156
printf(" - sleep(2*REC_CONFIG_UPDATE_INTERVAL_SEC)\n");
157
ink_sleep(2 * REC_CONFIG_UPDATE_INTERVAL_SEC);
159
// Register config update callbacks
160
RecRegisterConfigUpdateCb("proxy.config.cb_test_1", cb_test_1, (void *) 0x12345678);
161
RecRegisterConfigUpdateCb("proxy.config.cb_test_2", cb_test_2, (void *) 0x87654321);
163
// Change proxy.config.cb_test_1
164
RecSetRecordString("proxy.config.cb_test_1", "cb_test_1__changed");
165
printf(" - sleep(2*REC_CONFIG_UPDATE_INTERVAL_SEC)\n");
166
ink_sleep(2 * REC_CONFIG_UPDATE_INTERVAL_SEC);
168
// Check globals to make sure the right thing happened
169
if (g_config_update_result == true) {
170
printf(" SUMMARY: PASS\n");
172
printf(" SUMMARY: FAIL\n");
175
printf(" [RecLinkConfigXXX]\n");
178
RecSetRecordInt("proxy.config.link_test_1", 1);
179
RecSetRecordFloat("proxy.config.link_test_2", 100.0f);
180
RecSetRecordCounter("proxy.config.link_test_3", 5);
181
printf(" - sleep(2*REC_CONFIG_UPDATE_INTERVAL_SEC)\n");
182
ink_sleep(2 * REC_CONFIG_UPDATE_INTERVAL_SEC);
185
RecLinkConfigInt("proxy.config.link_test_1", &g_link_test_1);
186
RecLinkConfigFloat("proxy.config.link_test_2", &g_link_test_2);
187
RecLinkConfigCounter("proxy.config.link_test_3", &g_link_test_3);
189
// Initial check to make sure link worked
190
printf(" - g_link_test_1 = %d:%d, expect: 1\n", g_link_test_1);
191
printf(" - g_link_test_2 = %f, expect: %f\n", g_link_test_2, 100.0f);
192
printf(" - g_link_test_3 = %d:%d, expect: 5\n", g_link_test_3);
193
if (g_link_test_1 == 1 && g_link_test_2 == 100.0f && g_link_test_3 == 5) {
194
printf(" SUMMARY: PASS\n");
196
printf(" SUMMARY: FAIL\n");
199
printf(" [RecGetRecordXXX]\n");
201
RecString rec_string = 0;
202
const int buf_len = 1024;
205
RecGetRecordString_Xmalloc("proxy.config.cb_test_2", &rec_string);
206
if (!rec_string || (rec_string && strcmp(rec_string, "cb_test_2__original")) != 0) {
207
printf(" RecGetRecordString_Xmalloc: FAIL (expected: 'cb_test_2__original', got: '%s')\n",
208
rec_string ? rec_string : "<nothing>");
210
printf(" RecGetRecordString_Xmalloc: PASS (%s)\n", rec_string);
213
RecGetRecordString("proxy.config.cb_test_2", buf, buf_len);
214
if (strcmp(buf, "cb_test_2__original") != 0) {
215
printf(" RecGetRecordString: FAIL (expected: 'cb_test_2__original', got: '%s')\n", buf);
217
printf(" RecGetRecordString: PASS (%s)\n", buf);
220
// Testing with RecGetRecordInt, RecGetRecordFloat and RecGetRecordCounter
222
RecGetRecordInt("proxy.config.link_test_1", &rec_int);
224
printf(" RecGetRecordInt: FAIL (expected: 1, got %d:%d)\n", rec_int);
226
printf(" RecGetRecordInt: PASS (%d:%d)\n", rec_int);
229
RecFloat rec_float = 0;
230
RecGetRecordFloat("proxy.config.link_test_2", &rec_float);
231
if (rec_float != 100.0f) {
232
printf(" RecGetRecordFloat: FAIL (expected: %f, got %f)\n", 100.0f, rec_float);
234
printf(" RecGetRecordFloat: PASS (%f)\n", rec_float);
237
RecCounter rec_counter = 0;
238
RecGetRecordCounter("proxy.config.link_test_3", &rec_counter);
239
if (rec_counter != 5) {
240
printf(" RecGetRecordCounter: FAIL (expected: 5, got %d:%d)\n", rec_counter);
242
printf(" RecGetRecordCounter: PASS (%d:%d)\n", rec_counter);
245
// Testing RecLinkConfigXXX, after calling RecLinkConfigXXX above, those
246
// variable will automatically be atomically updated when record changes in
248
printf(" [RecLinkConfigXXX]\n");
251
printf(" - RecSetRecordXXX\n");
252
RecSetRecordString("proxy.config.cb_test_1", "cb_test_1_changed");
253
RecSetRecordInt("proxy.config.link_test_1", 2);
254
RecSetRecordFloat("proxy.config.link_test_2", 200.0f);
255
RecSetRecordCounter("proxy.config.link_test_3", 6);
256
printf(" - sleep(2*REC_CONFIG_UPDATE_INTERVAL_SEC)\n");
257
ink_sleep(2 * REC_CONFIG_UPDATE_INTERVAL_SEC);
259
printf(" - g_link_test_1 = %d:%d, expect: 2\n", g_link_test_1);
260
printf(" - g_link_test_2 = %f, expect: %f\n", g_link_test_2, 200.0f);
261
printf(" - g_link_test_3 = %d:%d, expect: 6\n", g_link_test_3);
262
if (g_link_test_1 == 2 && g_link_test_2 == 200.0f && g_link_test_3 == 6) {
263
printf(" SUMMARY: PASS\n");
265
printf(" SUMMARY: FAIL\n");
268
RecSetRecordInt("proxy.config.link_test_1", 1);
269
RecSetRecordFloat("proxy.config.link_test_2", 100.0f);
270
RecSetRecordCounter("proxy.config.link_test_3", 5);
271
printf(" - sleep(2*REC_CONFIG_UPDATE_INTERVAL_SEC)\n");
272
ink_sleep(2 * REC_CONFIG_UPDATE_INTERVAL_SEC);
276
//-------------------------------------------------------------------------
277
// Test03: RawStat Tests
279
// The following test illustrates how one might use the RawStat
280
// interface to librecprocess.a. It also illustrates a custom RawStat
281
// sync function, 'raw_stat_sync_ticks_per_sec' that computes
282
// operations per second (used by AIO module).
283
//-------------------------------------------------------------------------
297
static RecRawStatBlock *g_rsb = NULL;
298
static int g_count = 0;
300
static int g_ticks = 0;
301
static int g_time = 0;
304
raw_stat_sync_ticks_per_sec(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id)
307
NOWARN_UNUSED(data_type);
309
ink64 ticks_old, time_old;
310
ink64 ticks_new, time_new;
312
RecRawStat *rrs = RecGetGlobalRawStatPtr(rsb, id);
313
ink64 *rrs_sum = RecGetGlobalRawStatSumPtr(rsb, id);
314
ink64 *rrs_count = RecGetGlobalRawStatCountPtr(rsb, id);
316
RecGetGlobalRawStatSum(rsb, id, &ticks_old);
317
RecGetGlobalRawStatCount(rsb, id, &time_old);
319
if ((rrs->sum != ticks_old) && (*rrs_sum != ticks_old)) {
320
printf("ERROR: (rrs->sum != ticks_old) && (*rrs_sum != ticks_old)\n");
323
printf("OKAY: GlobalRawStatSum == RecRawStat->sum == && GlobalRawStatSum == GlobalRawStatSumPtr, which is %d:%d\n", ticks_old);
325
if ((rrs->count != time_old) && (*rrs_count != time_old)) {
326
printf("ERROR: (rrs->count != time_old) && (*rrs_sum != ticks_old)\n");
329
printf("OKAY: GlobalRawStatCount == RecRawStat->count && GlobalRawStatCount == GlobalRawStatCountPtr, which is %d:%d\n", time_old);
334
data->rec_float = (float) (ticks_new - ticks_old) / (float) (time_new - time_old);
336
RecSetGlobalRawStatSum(rsb, id, ticks_new);
337
RecSetGlobalRawStatCount(rsb, id, time_new);
343
struct RawStatCont:public Continuation
345
RawStatCont(ProxyMutex * m):Continuation(m)
347
SET_HANDLER(&RawStatCont::dummy_function);
349
int dummy_function(int event, Event * e)
351
NOWARN_UNUSED(event);
353
printf("------------Raw Stat dump-------------\n");
354
ink64 hr_start, hr_finish;
355
// comments out here. Why stat_a is int?
356
RecInt stat_b, stat_c, stat_f, stat_g;
357
RecFloat stat_a, stat_d, stat_e;
360
hr_start = ink_get_hrtime();
362
// test_raw_stat_a should have around 16000 in it (avg of rand())
363
RecIncrRawStat(g_rsb, mutex->thread_holding, (int) MY_STAT_A, rand());
365
// test_raw_stat_b should have g_count plustorial in it
366
RecIncrRawStatSum(g_rsb, mutex->thread_holding, (int) MY_STAT_B, g_count);
368
// test_raw_stat_c should have g_count plustorial in it
369
//RecSetRawStatCount(g_rsb, (int) MY_STAT_C, g_count);
370
RecIncrRawStatCount(g_rsb, mutex->thread_holding, (int) MY_STAT_C, g_count);
372
// test_raw_stat_f should have g_count in it
373
// I have switched this with test_raw_stat_c
374
RecSetRawStatCount(g_rsb, (int) MY_STAT_F, g_count);
376
// test_raw_stat_g should have g_count in it
377
RecSetRawStatSum(g_rsb, (int) MY_STAT_G, g_count);
379
// test_raw_stat_d should have 4 it (e.g. we're run 4 times a second)
380
ink_atomic_increment(&g_ticks, 1);
383
// sleep for a bit to take some time
384
struct timespec rgtp;
386
rgtp.tv_nsec = 10000;
387
nanosleep(&rgtp, NULL);
389
// FIXME: Read values and compare against expected values rather
390
// than just printing out
393
RecGetRecordFloat("proxy.process.test_raw_stat_a", &stat_a);
394
RecGetRecordInt("proxy.process.test_raw_stat_b", &stat_b);
395
RecGetRecordInt("proxy.process.test_raw_stat_c", &stat_c);
396
RecGetRecordFloat("proxy.process.test_raw_stat_d", &stat_d);
397
RecGetRecordFloat("proxy.process.test_raw_stat_e", &stat_e);
398
RecGetRecordInt("proxy.process.test_raw_stat_f", &stat_f);
399
RecGetRecordInt("proxy.process.test_raw_stat_g", &stat_g);
402
printf("-> g_count: %d, thr: 0x%x, stat_a: %d%d, stat_b: %d:%d, stat_c: %d:%d, stat_d: %f\n",
403
g_count, mutex->thread_holding, stat_a, stat_b, stat_c, stat_d);
405
printf("-> g_link_test_1: %d:%d, g_link_test_2: %f\n",
406
g_link_test_1, g_link_test_2);
409
// Compare read value stat_a and expected value test_raw_stat_a
410
RecRawStat test_raw_stat_a;
412
test_raw_stat_a.sum = REC_ATOMIC_READ64(&(g_rsb->global[MY_STAT_A]->sum));
413
test_raw_stat_a.count = REC_ATOMIC_READ64(&(g_rsb->global[MY_STAT_A]->count));
414
if (test_raw_stat_a.count != 0)
415
avg = (float) ((double) test_raw_stat_a.sum / (double) test_raw_stat_a.count);
418
printf("ERROR: stat_a: %f, expect stat_a: %f\n", stat_a, avg);
420
printf("OKAY: stat_a: %f, expect stat_a: %f\n", stat_a, avg);
423
// Compare read value stat_b and expected value test_raw_stat_b
424
RecRawStat test_raw_stat_b;
425
test_raw_stat_b.sum = REC_ATOMIC_READ64(&(g_rsb->global[MY_STAT_B]->sum));
426
if (stat_b != test_raw_stat_b.sum) {
427
printf("ERROR: After RecIncrRawStatSum, stat_b: %d:%d, expect stat_b: %d:%d\n", stat_b, test_raw_stat_b.sum);
429
printf("OKAY: After RecIncrRawStatSum, stat_b: %d:%d, expect stat_b: %d:%d\n", stat_b, test_raw_stat_b.sum);
432
// Compare read value stat_c and expected value test_raw_stat_c
433
RecRawStat test_raw_stat_c;
434
test_raw_stat_c.count = REC_ATOMIC_READ64(&(g_rsb->global[MY_STAT_C]->count));
435
if (stat_c != test_raw_stat_c.count) {
436
printf("ERROR: After RecIncrRawStatCount, stat_c: %d:%d, expect stat_c: %d:%d\n", stat_c, test_raw_stat_c.count);
438
printf("OKAY: After RecIncrRawStatCount, stat_c: %d:%d, expect stat_c: %d:%d\n", stat_c, test_raw_stat_c.count);
441
// Compare read value stat_d and expected value test_raw_stat_d
442
ink64 ticks_old, time_old;
443
RecGetGlobalRawStatSum(g_rsb, MY_STAT_D, &ticks_old);
444
RecGetGlobalRawStatCount(g_rsb, MY_STAT_D, &time_old);
445
RecFloat data = (float) (g_ticks - ticks_old) / (float) (g_time - time_old);
446
if (stat_d != 4.0f) {
447
printf("ERROR: stat_d: %f, expect stat_d: %f or I got data: %f\n", stat_d, 4.0f, data);
449
printf("OKAY: stat_d: %f, expect stat_d: %f or I got data: %f\n", stat_d, 4.0f, data);
452
// Compare read value stat_e and expected value test_raw_stat_e
453
RecRawStat test_raw_stat_e;
455
test_raw_stat_e.sum = REC_ATOMIC_READ64(&(g_rsb->global[MY_STAT_E]->sum));
456
test_raw_stat_e.count = REC_ATOMIC_READ64(&(g_rsb->global[MY_STAT_E]->count));
457
if (test_raw_stat_e.count == 0) {
460
r = (float) ((double) test_raw_stat_e.sum / (double) test_raw_stat_e.count);
461
r = r / (float) (HRTIME_SECOND);
464
printf("ERROR: stat_e: %f, expect stat_e from avg: %f\n", stat_e, r);
466
printf("OKAY: stat_e: %f, expect stat_e from avg: %f\n", stat_e, r);
469
// Compare read value stat_f and expected value test_raw_stat_f
470
// Since RecSet only set g_rsb->global[MY_STAT_F]->count to be g_count value.
471
// It will not set data.rec_int for stat_f until the RecExecRawStatSyncCbs
472
// is called. RecExecRawStatSyncCbs callback RecRawStatSyncCount which set
473
// data.rec_int to be g_rsb->global[MY_STAT_F]->count. The schedule for
474
// RecExecRawStatSyncCbs is REC_RAW_STAT_SYNC_INTERVAL_SEC = 3 secs.
475
// The normal for this dummy_function is 1 sec. There is no way we can
476
// get the right value for this. Let ask Eric for this :)
477
// I have increase the ink_sleep time (about 3 secs) between RecSet and RecGet
478
// for stat_c hoping that we got the RecExecRawStatSyncCbs at the middle of them
479
// so we can get the right value for stat_c. However, this will screw up
480
// stat_d badly as we get NaN for stat_d.
481
RecRawStat test_raw_stat_f;
482
test_raw_stat_f.count = REC_ATOMIC_READ64(&(g_rsb->global[MY_STAT_F]->count));
484
RecGetRawStatCount(g_rsb, (int) MY_STAT_F, &check_stat_f);
485
if (stat_f != test_raw_stat_f.count || stat_f != check_stat_f) {
486
printf("ERROR: After RecSetRawStatCount, stat_f: %d:%d, stat_f by REC_ATOMIC_READ64: %d:%d\n", stat_f,
487
test_raw_stat_f.count);
488
printf(" stat_f by RecGetRawStatCount: %d:%d\n", check_stat_f);
490
printf("OKAY: After RecSetRawStatCount, stat_f: %d:%d, stat_f by REC_ATOMIC_READ64: %d:%d\n", stat_f,
491
test_raw_stat_f.count);
492
printf(" stat_f by RecGetRawStatCount: %d:%d\n", check_stat_f);
495
// Compare read value stat_g and expeced value test_raw_stat_g
496
RecRawStat test_raw_stat_g;
497
test_raw_stat_g.sum = REC_ATOMIC_READ64(&(g_rsb->global[MY_STAT_G]->sum));
499
RecGetRawStatSum(g_rsb, (int) MY_STAT_G, &check_stat_g);
500
if (stat_g != test_raw_stat_g.count || stat_g != check_stat_g) {
501
printf("ERROR: After RecSetRawStatSum, stat_g: %d:%d, stat_g by REC_ATOMIC_READ64: %d:%d\n", stat_g,
502
test_raw_stat_g.sum);
503
printf(" stat_g by RecGetRawStatSum: %d:%d\n", check_stat_g);
505
printf("OKAY: After RecSetRawStatSum, stat_g: %d:%d, stat_g by REC_ATOMIC_READ64: %d:%d\n", stat_g,
506
test_raw_stat_g.sum);
507
printf(" stat_g by RecGetRawStatSum: %d:%d\n", check_stat_g);
509
ink_atomic_increment(&g_count, 1);
511
// test_raw_stat_e should have the time it takes to run this function
512
hr_finish = ink_get_hrtime();
513
RecIncrRawStat(g_rsb, mutex->thread_holding, (int) MY_STAT_E, hr_finish - hr_start);
522
printf("[Test03: RawStat Test]\n");
524
// Register raw statistics
525
g_rsb = RecAllocateRawStatBlock((int) MY_STAT_COUNT);
527
RecRegisterRawStat(g_rsb, RECT_PROCESS, "proxy.process.test_raw_stat_a",
528
RECD_FLOAT, RECP_NULL, (int) MY_STAT_A, RecRawStatSyncAvg);
530
RecRegisterRawStat(g_rsb, RECT_PROCESS, "proxy.process.test_raw_stat_b",
531
RECD_INT, RECP_PERSISTENT, (int) MY_STAT_B, RecRawStatSyncSum);
533
RecRegisterRawStat(g_rsb, RECT_PROCESS, "proxy.process.test_raw_stat_c",
534
RECD_INT, RECP_NULL, (int) MY_STAT_C, RecRawStatSyncCount);
536
RecRegisterRawStat(g_rsb, RECT_PROCESS, "proxy.process.test_raw_stat_d",
537
RECD_FLOAT, RECP_NULL, (int) MY_STAT_D, raw_stat_sync_ticks_per_sec);
539
RecRegisterRawStat(g_rsb, RECT_PROCESS, "proxy.process.test_raw_stat_e",
540
RECD_FLOAT, RECP_NULL, (int) MY_STAT_E, RecRawStatSyncHrTimeAvg);
541
RecRegisterRawStat(g_rsb, RECT_PROCESS, "proxy.process.test_raw_stat_f",
542
RECD_INT, RECP_NULL, (int) MY_STAT_F, RecRawStatSyncCount);
543
// If forget to Register this RawStat, we will have SEGV when checking
544
// g_rsb->global[MY_STAT_G]
545
RecRegisterRawStat(g_rsb, RECT_PROCESS, "proxy.process.test_raw_stat_g",
546
RECD_INT, RECP_NULL, (int) MY_STAT_G, RecRawStatSyncSum);
548
// Schedule a bunch of continuations that will use the stats registered above
549
RawStatCont *sc = new RawStatCont(new_ProxyMutex());
550
eventProcessor.schedule_every(sc, HRTIME_SECONDS(1), ET_CALL, EVENT_INTERVAL, NULL);
551
eventProcessor.schedule_every(sc, HRTIME_SECONDS(1), ET_CALL, EVENT_INTERVAL, NULL);
552
eventProcessor.schedule_every(sc, HRTIME_SECONDS(1), ET_CALL, EVENT_INTERVAL, NULL);
553
eventProcessor.schedule_every(sc, HRTIME_SECONDS(1), ET_CALL, EVENT_INTERVAL, NULL);
557
//-------------------------------------------------------------------------
559
//-------------------------------------------------------------------------
561
struct DumpRecordsHtCont:public Continuation
563
DumpRecordsHtCont(ProxyMutex * m):Continuation(m)
565
SET_HANDLER(&DumpRecordsHtCont::dummy_function);
567
int dummy_function(int event, Event * e)
569
NOWARN_UNUSED(event);
571
RecDumpRecordsHt(RECT_NULL);
576
//-------------------------------------------------------------------------
579
//-------------------------------------------------------------------------
584
char **var_buf = NULL;
586
RecGetRecordList("proxy.config", &var_buf, &buf_len);
587
for (int i = 0; i < buf_len; i++) {
588
ink_debug_assert(var_buf[i]);
589
diags->print(NULL, DL_Note, NULL, NULL, "\tRecTree node: (proxy.config.*) %s", var_buf[i]);
594
diags->print(NULL, DL_Note, NULL, NULL, "\tRecTree Test -- PASS\n");
596
diags->print(NULL, DL_Note, NULL, NULL, "\tRecTree Test -- FAIL\n");
602
//-------------------------------------------------------------------------
605
// This should only run after Test03.
606
// Determine whether proxy.process.* variable are referred by the RecTree
608
//-------------------------------------------------------------------------
613
char **var_buf = NULL;
615
RecGetRecordList("proxy.process", &var_buf, &buf_len);
616
for (int i = 0; i < buf_len; i++) {
617
ink_debug_assert(var_buf[i]);
618
diags->print(NULL, DL_Note, NULL, NULL, "\tRecTree (proxy.process.*) node: %s", var_buf[i]);
623
diags->print(NULL, DL_Note, NULL, NULL, "\tRecTree Test -- PASS\n");
625
diags->print(NULL, DL_Note, NULL, NULL, "\tRecTree Test -- FAIL\n");
630
//-------------------------------------------------------------------------
632
//-------------------------------------------------------------------------
635
main(int argc, char **argv)
638
RecModeT mode_type = RECM_STAND_ALONE;
639
if ((argc == 2) && (strcmp(argv[1], "-M") == 0)) {
640
mode_type = RECM_CLIENT;
642
// Start diags logging
644
if ((log_fp = fopen("recprocess.log", "a+")) != NULL) {
645
int status = setvbuf(log_fp, NULL, _IOLBF, 512);
651
diags = NEW(new Diags("rec", NULL, log_fp));
652
diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
653
diags->print(NULL, DL_Note, NULL, NULL, "Starting '%s'", argv[0]);
655
// System initialization. Note that a pointer to the diags object
656
// is passed into librecprocess.a. If manager isn't running, we
657
// need to register our own configs
658
RecProcessInit(mode_type, diags);
659
RecProcessInitMessage(mode_type);
660
if (mode_type == RECM_STAND_ALONE) {
661
RecordsConfigRegister();
663
ink_event_system_init(EVENT_SYSTEM_MODULE_VERSION);
664
eventProcessor.start(4);
667
RecSignalManager(1, "This is a signal, signaled by RecSignalManager");
669
// See if we're sync'd okay
670
RecDumpRecordsHt(RECT_NULL);
681
// Schedule dump continuation so that we can see what's going on
682
DumpRecordsHtCont *drhc = new DumpRecordsHtCont(new_ProxyMutex());
683
eventProcessor.schedule_every(drhc, HRTIME_SECONDS(10), ET_CALL, EVENT_INTERVAL, NULL);
685
this_thread()->execute();