MCPcopy Create free account
hub / github.com/apache/trafficserver / log_test_handler

Function log_test_handler

src/api/InkAPITest.cc:6396–6477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6394};
6395
6396static int
6397log_test_handler(TSCont contp, TSEvent event, void * /* edata ATS_UNUSED */)
6398{
6399 TSFile filep;
6400 char buf[1024];
6401 bool str_found;
6402 int retVal = 0;
6403
6404 TSAssert(event == TS_EVENT_TIMEOUT);
6405
6406 LogTestData *data = static_cast<LogTestData *>(TSContDataGet(contp));
6407 TSAssert(data->magic == MAGIC_ALIVE);
6408
6409 // Verify content was correctly written into log file
6410
6411 if ((filep = TSfopen(data->fullpath_logname, "r")) == nullptr) {
6412 SDK_RPRINT(data->test, "TSTextLogObject", "TestCase1", TC_FAIL, "can not open log file %s", data->fullpath_logname);
6413 *(data->pstatus) = REGRESSION_TEST_FAILED;
6414 return -1;
6415 } else {
6416 // The logfile is created
6417 str_found = false;
6418 while (TSfgets(filep, buf, 1024) != nullptr) {
6419 if (strstr(buf, LOG_TEST_PATTERN) != nullptr) {
6420 str_found = true;
6421 break;
6422 }
6423 }
6424 TSfclose(filep);
6425 if (str_found == false) {
6426 SDK_RPRINT(data->test, "TSTextLogObject", "TestCase1", TC_FAIL, "can not find pattern %s in log file", LOG_TEST_PATTERN);
6427 *(data->pstatus) = REGRESSION_TEST_FAILED;
6428 return -1;
6429 }
6430 }
6431
6432 retVal = TSTextLogObjectDestroy(data->log);
6433 if (retVal != TS_SUCCESS) {
6434 SDK_RPRINT(data->test, "TSTextLogObjectDestroy", "TestCase1", TC_FAIL, "can not destroy log object");
6435 *(data->pstatus) = REGRESSION_TEST_FAILED;
6436 return -1;
6437 } else {
6438 SDK_RPRINT(data->test, "TSTextLogObjectDestroy", "TestCase1", TC_PASS, "ok");
6439 }
6440
6441 *(data->pstatus) = REGRESSION_TEST_PASSED;
6442 SDK_RPRINT(data->test, "TSTextLogObject", "TestCase1", TC_PASS, "ok");
6443
6444 // figure out the metainfo file for cleanup.
6445 // code from MetaInfo::_build_name(const char *filename)
6446 int i = -1, l = 0;
6447 char c;
6448 while (c = data->fullpath_logname[l], c != 0) {
6449 if (c == '/') {
6450 i = l;
6451 }
6452 ++l;
6453 }

Callers

nothing calls this directly

Calls 10

TSContDataGetFunction · 0.85
TSfopenFunction · 0.85
SDK_RPRINTFunction · 0.85
TSfgetsFunction · 0.85
TSfcloseFunction · 0.85
TSTextLogObjectDestroyFunction · 0.85
ats_mallocFunction · 0.85
TSfreeFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected