You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2026/10/06 22:35:17 UTC
(trafficserver) branch master updated: cache: drop CacheTest.cc and RegressionSM from traffic_server (#13786)
This is an automated email from the ASF dual-hosted git repository.
masaori335 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 71a60004cf cache: drop CacheTest.cc and RegressionSM from traffic_server (#13786)
71a60004cf is described below
commit 71a60004cf5cc49b527367421ec789573e8f4f76
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Wed Oct 7 07:35:11 2026 +0900
cache: drop CacheTest.cc and RegressionSM from traffic_server (#13786)
The level-gated cache tests now run under ctest. The remaining cache
op-sequence test is removed rather than ported: its data checks never
took effect, and its paths are covered elsewhere. SDK_API_TSCache
covers the non-HTTP cache API, and the range autest covers do_io_pread
on cached range hits. The non-HTTP lookup it also exercised has no
callers.
---
ci/asan_leak_suppression/regression.txt | 3 -
src/iocore/cache/CMakeLists.txt | 4 -
src/iocore/cache/Cache.cc | 9 -
src/iocore/cache/CacheTest.cc | 430 ---------------------
src/iocore/cache/P_CacheTest.h | 151 --------
src/iocore/cache/RegressionSM.cc | 280 --------------
src/iocore/cache/RegressionSM.h | 79 ----
.../cache/unit_tests/test_AggregateWriteBuffer.cc | 2 +-
8 files changed, 1 insertion(+), 957 deletions(-)
diff --git a/ci/asan_leak_suppression/regression.txt b/ci/asan_leak_suppression/regression.txt
index 1513f1a6fd..fa3fb5d4d6 100644
--- a/ci/asan_leak_suppression/regression.txt
+++ b/ci/asan_leak_suppression/regression.txt
@@ -2,10 +2,7 @@ leak:RegressionTest_PARENTSELECTION
leak:ParentConfig::reconfigure
leak:RegressionTest_SDK_API_TSHttpConnectIntercept
leak:RegressionTest_SDK_API_TSHttpConnectServerIntercept
-leak:ReRegressionSM::clone
-leak:RegressionTest_ram_cache
leak:RegressionTest_HttpTransact_is_request_valid
-leak:RegressionTest_RegressionSM
leak:MakeTextLogFormat
leak:RegressionTest_HttpTransact_handle_trace_and_options_requests
leak:CRYPTO_malloc
diff --git a/src/iocore/cache/CMakeLists.txt b/src/iocore/cache/CMakeLists.txt
index 00d99cac56..cf9a5badc6 100644
--- a/src/iocore/cache/CMakeLists.txt
+++ b/src/iocore/cache/CMakeLists.txt
@@ -41,10 +41,6 @@ add_library(
)
add_library(ts::inkcache ALIAS inkcache)
-if(BUILD_REGRESSION_TESTING)
- target_sources(inkcache PRIVATE CacheTest.cc RegressionSM.cc)
-endif()
-
# For fastlz includes.
target_include_directories(inkcache PRIVATE ${CMAKE_SOURCE_DIR}/lib)
diff --git a/src/iocore/cache/Cache.cc b/src/iocore/cache/Cache.cc
index bebf8f3744..3d52a1f48e 100644
--- a/src/iocore/cache/Cache.cc
+++ b/src/iocore/cache/Cache.cc
@@ -27,7 +27,6 @@
#include "CacheVC.h"
#include "P_CacheDoc.h"
#include "P_CacheInternal.h"
-#include "P_CacheTest.h"
#include "Stripe.h"
#include "StripeSM.h"
#include "iocore/cache/Cache.h"
@@ -122,14 +121,6 @@ Queue<CacheVol> cp_list;
int cp_list_len = 0;
ConfigVolumes config_volumes;
-#if TS_HAS_TESTS
-void
-force_link_CacheTestCaller()
-{
- force_link_CacheTest();
-}
-#endif
-
static int
validate_rww(int new_value)
{
diff --git a/src/iocore/cache/CacheTest.cc b/src/iocore/cache/CacheTest.cc
deleted file mode 100644
index adc13f2625..0000000000
--- a/src/iocore/cache/CacheTest.cc
+++ /dev/null
@@ -1,430 +0,0 @@
-/** @file
-
- A brief file description
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- */
-
-#include "P_CacheHosting.h"
-#include "P_CacheInternal.h"
-#include "P_CacheTest.h"
-#include "RegressionSM.h"
-#include "StripeSM.h"
-#include "iocore/aio/AIO.h"
-#include <cstdlib>
-
-using namespace std::literals;
-
-CacheTestSM::CacheTestSM(RegressionTest *t, const char *name) : RegressionSM(t), cache_test_name(name)
-{
- SET_HANDLER(&CacheTestSM::event_handler);
-}
-
-CacheTestSM::CacheTestSM(const CacheTestSM &ao) : RegressionSM(ao)
-{
- int o = static_cast<int>((reinterpret_cast<char *>(&start_memcpy_on_clone)) - (reinterpret_cast<char *>(this)));
- int s = static_cast<int>((reinterpret_cast<char *>(&end_memcpy_on_clone)) - (reinterpret_cast<char *>(&start_memcpy_on_clone)));
- memcpy((reinterpret_cast<char *>(this)) + o, (reinterpret_cast<const char *>(&ao)) + o, s);
- SET_HANDLER(&CacheTestSM::event_handler);
-}
-
-// Coverity resolves ink_assert() to the throwing _ink_assert() defined by
-// eventsystem/unit_tests/test_MIOBufferWriter.cc, not the one linked here.
-// coverity[UNCAUGHT_EXCEPT:FALSE]
-CacheTestSM::~CacheTestSM()
-{
- ink_assert(!cache_action);
- ink_assert(!cache_vc);
- if (buffer_reader) {
- buffer->dealloc_reader(buffer_reader);
- }
- if (buffer) {
- free_MIOBuffer(buffer);
- }
-}
-
-int
-CacheTestSM::open_read_callout()
-{
- cvio = cache_vc->do_io_read(this, nbytes, buffer);
- return 1;
-}
-
-int
-CacheTestSM::open_write_callout()
-{
- cvio = cache_vc->do_io_write(this, nbytes, buffer_reader);
- return 1;
-}
-
-int
-CacheTestSM::event_handler(int event, void *data)
-{
- switch (event) {
- case EVENT_INTERVAL:
- case EVENT_IMMEDIATE:
- cancel_timeout();
- if (cache_action) {
- cache_action->cancel();
- cache_action = nullptr;
- }
- if (cache_vc) {
- cache_vc->do_io_close();
- cache_vc = nullptr;
- }
- cvio = nullptr;
- make_request();
- return EVENT_DONE;
-
- case CACHE_EVENT_LOOKUP_FAILED:
- case CACHE_EVENT_LOOKUP:
- goto Lcancel_next;
-
- case CACHE_EVENT_OPEN_READ:
- initial_event = event;
- cancel_timeout();
- cache_action = nullptr;
- cache_vc = static_cast<CacheVConnection *>(data);
- buffer = new_empty_MIOBuffer(BUFFER_SIZE_INDEX_32K);
- buffer_reader = buffer->alloc_reader();
- if (open_read_callout() < 0) {
- goto Lclose_error_next;
- } else {
- return EVENT_DONE;
- }
-
- case CACHE_EVENT_OPEN_READ_FAILED:
- goto Lcancel_next;
-
- case VC_EVENT_READ_READY:
- if (!check_buffer()) {
- goto Lclose_error_next;
- }
- buffer_reader->consume(buffer_reader->read_avail());
- (static_cast<VIO *>(data))->reenable();
- return EVENT_CONT;
-
- case VC_EVENT_READ_COMPLETE:
- if (!check_buffer()) {
- goto Lclose_error_next;
- }
- goto Lclose_next;
-
- case VC_EVENT_ERROR:
- case VC_EVENT_EOS:
- goto Lclose_error_next;
-
- case CACHE_EVENT_OPEN_WRITE:
- initial_event = event;
- cancel_timeout();
- cache_action = nullptr;
- cache_vc = static_cast<CacheVConnection *>(data);
- buffer = new_empty_MIOBuffer(BUFFER_SIZE_INDEX_32K);
- buffer_reader = buffer->alloc_reader();
- if (open_write_callout() < 0) {
- goto Lclose_error_next;
- } else {
- return EVENT_DONE;
- }
-
- case CACHE_EVENT_OPEN_WRITE_FAILED:
- goto Lcancel_next;
-
- case VC_EVENT_WRITE_READY:
- fill_buffer();
- cvio->reenable();
- return EVENT_CONT;
-
- case VC_EVENT_WRITE_COMPLETE:
- if (nbytes != cvio->ndone) {
- goto Lclose_error_next;
- }
- goto Lclose_next;
-
- case CACHE_EVENT_REMOVE:
- case CACHE_EVENT_REMOVE_FAILED:
- goto Lcancel_next;
-
- case CACHE_EVENT_SCAN:
- initial_event = event;
- cache_vc = static_cast<CacheVConnection *>(data);
- return EVENT_CONT;
-
- case CACHE_EVENT_SCAN_OBJECT:
- return CACHE_SCAN_RESULT_CONTINUE;
-
- case CACHE_EVENT_SCAN_OPERATION_FAILED:
- return CACHE_SCAN_RESULT_CONTINUE;
-
- case CACHE_EVENT_SCAN_OPERATION_BLOCKED:
- return CACHE_SCAN_RESULT_CONTINUE;
-
- case CACHE_EVENT_SCAN_DONE:
- return EVENT_CONT;
-
- case CACHE_EVENT_SCAN_FAILED:
- return EVENT_CONT;
-
- case AIO_EVENT_DONE:
- goto Lnext;
-
- default:
- ink_assert(!"case");
- break;
- }
- return EVENT_DONE;
-
-Lcancel_next:
- cancel_timeout();
- cache_action = nullptr;
- goto Lnext;
-Lclose_error_next:
- cache_vc->do_io_close(1);
- goto Lclose_next_internal;
-Lclose_next:
- cache_vc->do_io_close();
-Lclose_next_internal:
- cache_vc = nullptr;
- if (buffer_reader) {
- buffer->dealloc_reader(buffer_reader);
- buffer_reader = nullptr;
- }
- if (buffer) {
- free_MIOBuffer(buffer);
- buffer = nullptr;
- }
-Lnext:
- if (check_result(event) && repeat_count) {
- repeat_count--;
- timeout = eventProcessor.schedule_imm(this);
- return EVENT_DONE;
- } else {
- return complete(event);
- }
-}
-
-void
-CacheTestSM::fill_buffer()
-{
- int64_t avail = buffer->write_avail();
- CacheKey k = key;
- k.b[1] += content_salt;
- int64_t sk = static_cast<int64_t>(sizeof(key));
- while (avail > 0) {
- int64_t l = avail;
- if (l > sk) {
- l = sk;
- }
-
- int64_t pos = cvio->ndone + buffer_reader->read_avail();
- int64_t o = pos % sk;
-
- if (l > sk - o) {
- l = sk - o;
- }
- k.b[0] = pos / sk;
- char *x = (reinterpret_cast<char *>(&k)) + o;
- buffer->write(x, l);
- buffer->fill(l);
- avail -= l;
- }
-}
-
-int
-CacheTestSM::check_buffer()
-{
- int64_t avail = buffer_reader->read_avail();
- CacheKey k = key;
- k.b[1] += content_salt;
- char b[sizeof(key)];
- int64_t sk = static_cast<int64_t>(sizeof(key));
- int64_t pos = cvio->ndone - buffer_reader->read_avail();
- while (avail > 0) {
- int64_t l = avail;
- if (l > sk) {
- l = sk;
- }
- int64_t o = pos % sk;
- if (l > sk - o) {
- l = sk - o;
- }
- k.b[0] = pos / sk;
- char *x = (reinterpret_cast<char *>(&k)) + o;
- buffer_reader->read(&b[0], l);
- if (::memcmp(b, x, l)) {
- return 0;
- }
- buffer_reader->consume(l);
- pos += l;
- avail -= l;
- }
- return 1;
-}
-
-int
-CacheTestSM::check_result(int event)
-{
- return initial_event == expect_initial_event && event == expect_event;
-}
-
-int
-CacheTestSM::complete(int event)
-{
- if (!check_result(event)) {
- done(REGRESSION_TEST_FAILED);
- } else {
- done(REGRESSION_TEST_PASSED);
- }
- delete this;
- return EVENT_DONE;
-}
-
-EXCLUSIVE_REGRESSION_TEST(cache)(RegressionTest *t, int /* atype ATS_UNUSED */, int *pstatus)
-{
- if (cacheProcessor.IsCacheEnabled() != CacheInitState::INITIALIZED) {
- rprintf(t, "cache not initialized");
- *pstatus = REGRESSION_TEST_FAILED;
- return;
- }
-
- CACHE_SM(t, write_test, { cacheProcessor.open_write(this, &key, CACHE_FRAG_TYPE_NONE, 100, CACHE_WRITE_OPT_SYNC); });
- write_test.expect_initial_event = CACHE_EVENT_OPEN_WRITE;
- write_test.expect_event = VC_EVENT_WRITE_COMPLETE;
- write_test.nbytes = 100;
- rand_CacheKey(&write_test.key);
-
- CACHE_SM(t, lookup_test, { cacheProcessor.lookup(this, &key); });
- lookup_test.expect_event = CACHE_EVENT_LOOKUP;
- lookup_test.key = write_test.key;
-
- CACHE_SM(t, read_test, { cacheProcessor.open_read(this, &key); });
- read_test.expect_initial_event = CACHE_EVENT_OPEN_READ;
- read_test.expect_event = VC_EVENT_READ_COMPLETE;
- read_test.nbytes = 100;
- read_test.key = write_test.key;
-
- CACHE_SM(t, remove_test, { cacheProcessor.remove(this, &key); });
- remove_test.expect_event = CACHE_EVENT_REMOVE;
- remove_test.key = write_test.key;
-
- CACHE_SM(t, lookup_fail_test, { cacheProcessor.lookup(this, &key); });
- lookup_fail_test.expect_event = CACHE_EVENT_LOOKUP_FAILED;
- lookup_fail_test.key = write_test.key;
-
- CACHE_SM(t, read_fail_test, { cacheProcessor.open_read(this, &key); });
- read_fail_test.expect_event = CACHE_EVENT_OPEN_READ_FAILED;
- read_fail_test.key = write_test.key;
-
- CACHE_SM(t, remove_fail_test, { cacheProcessor.remove(this, &key); });
- remove_fail_test.expect_event = CACHE_EVENT_REMOVE_FAILED;
- rand_CacheKey(&remove_fail_test.key);
-
- CACHE_SM(
- t, replace_write_test,
- { cacheProcessor.open_write(this, &key, CACHE_FRAG_TYPE_NONE, 100, CACHE_WRITE_OPT_SYNC); } int open_write_callout() override {
- header.serial = 10;
- cache_vc->set_header(&header, sizeof(header));
- cvio = cache_vc->do_io_write(this, nbytes, buffer_reader);
- return 1;
- });
- replace_write_test.expect_initial_event = CACHE_EVENT_OPEN_WRITE;
- replace_write_test.expect_event = VC_EVENT_WRITE_COMPLETE;
- replace_write_test.nbytes = 100;
- rand_CacheKey(&replace_write_test.key);
-
- CACHE_SM(
- t, replace_test,
- { cacheProcessor.open_write(this, &key, CACHE_FRAG_TYPE_NONE, 100, CACHE_WRITE_OPT_OVERWRITE_SYNC); } int open_write_callout()
- override {
- CacheTestHeader *h = nullptr;
- int hlen = 0;
- if (cache_vc->get_header((void **)&h, &hlen) < 0)
- return -1;
- if (h->serial != 10)
- return -1;
- header.serial = 11;
- cache_vc->set_header(&header, sizeof(header));
- cvio = cache_vc->do_io_write(this, nbytes, buffer_reader);
- return 1;
- });
- replace_test.expect_initial_event = CACHE_EVENT_OPEN_WRITE;
- replace_test.expect_event = VC_EVENT_WRITE_COMPLETE;
- replace_test.nbytes = 100;
- replace_test.key = replace_write_test.key;
- replace_test.content_salt = 1;
-
- CACHE_SM(
- t, replace_read_test, { cacheProcessor.open_read(this, &key); } int open_read_callout() override {
- CacheTestHeader *h = nullptr;
- int hlen = 0;
- if (cache_vc->get_header((void **)&h, &hlen) < 0)
- return -1;
- if (h->serial != 11)
- return -1;
- cvio = cache_vc->do_io_read(this, nbytes, buffer);
- return 1;
- });
- replace_read_test.expect_initial_event = CACHE_EVENT_OPEN_READ;
- replace_read_test.expect_event = VC_EVENT_READ_COMPLETE;
- replace_read_test.nbytes = 100;
- replace_read_test.key = replace_test.key;
- replace_read_test.content_salt = 1;
-
- CACHE_SM(t, large_write_test, { cacheProcessor.open_write(this, &key, CACHE_FRAG_TYPE_NONE, 100, CACHE_WRITE_OPT_SYNC); });
- large_write_test.expect_initial_event = CACHE_EVENT_OPEN_WRITE;
- large_write_test.expect_event = VC_EVENT_WRITE_COMPLETE;
- large_write_test.nbytes = 10000000;
- rand_CacheKey(&large_write_test.key);
-
- CACHE_SM(
- t, pread_test, { cacheProcessor.open_read(this, &key); } int open_read_callout() override {
- cvio = cache_vc->do_io_pread(this, nbytes, buffer, 7000000);
- return 1;
- });
- pread_test.expect_initial_event = CACHE_EVENT_OPEN_READ;
- pread_test.expect_event = VC_EVENT_READ_COMPLETE;
- pread_test.nbytes = 100;
- pread_test.key = large_write_test.key;
-
- // clang-format off
- r_sequential(t,
- write_test.clone(),
- lookup_test.clone(),
- r_sequential(t, 10, read_test.clone()) /* run read_test 10 times */,
- remove_test.clone(),
- lookup_fail_test.clone(),
- read_fail_test.clone(),
- remove_fail_test.clone(),
- replace_write_test.clone(),
- replace_test.clone(),
- replace_read_test.clone(),
- large_write_test.clone(),
- pread_test.clone(),
- nullptr)
- ->run(pstatus);
- // clang-format on
-
- return;
-}
-
-void
-force_link_CacheTest()
-{
-}
diff --git a/src/iocore/cache/P_CacheTest.h b/src/iocore/cache/P_CacheTest.h
deleted file mode 100644
index 39c925bd10..0000000000
--- a/src/iocore/cache/P_CacheTest.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/** @file
-
- A brief file description
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#pragma once
-
-#include "RegressionSM.h"
-#include "iocore/cache/Cache.h"
-#include "iocore/cache/CacheDefs.h"
-#include "proxy/hdrs/HTTP.h"
-
-#define MAX_HOSTS_POSSIBLE 256
-#define PINNED_DOC_TABLE_SIZE 16
-#define PINNED_DOC_TABLES 246
-
-struct PinnedDocEntry {
- CacheKey key;
- ink_time_t time;
- LINK(PinnedDocEntry, link);
-};
-
-struct PinnedDocTable : public Continuation {
- Queue<PinnedDocEntry> bucket[PINNED_DOC_TABLE_SIZE];
-
- void insert(CacheKey *key, ink_time_t time, int update);
- int probe(CacheKey *key);
- int remove(CacheKey *key);
- int cleanup(int event, Event *e);
-
- PinnedDocTable() : Continuation(new_ProxyMutex()) { ink_zero(bucket); }
-};
-
-struct CacheTestHost {
- char *name = nullptr;
- unsigned int xlast_cachable_id = 0;
- double xprev_host_prob = 0;
- double xnext_host_prob = 0;
-
- CacheTestHost() {}
-};
-
-struct CacheTestHeader {
- CacheTestHeader() {}
- uint64_t serial = 0;
-};
-
-struct CacheTestSM : public RegressionSM {
- int start_memcpy_on_clone = 0; // place all variables to be copied between these markers
-
- // Cache test instance name. This is a pointer to a string literal, so copying is safe.
- const char *cache_test_name = nullptr;
-
- Action *timeout = nullptr;
- Action *cache_action = nullptr;
- ink_hrtime start_time = 0;
- CacheVConnection *cache_vc = nullptr;
- VIO *cvio = nullptr;
- MIOBuffer *buffer = nullptr;
- IOBufferReader *buffer_reader = nullptr;
- CacheHTTPInfo info;
- char urlstr[1024];
- int64_t total_size = 0;
- int64_t nbytes = -1;
- CacheKey key;
- int repeat_count = 0;
- int expect_event = EVENT_NONE;
- int expect_initial_event = EVENT_NONE;
- int initial_event = EVENT_NONE;
- uint64_t content_salt = 0;
- CacheTestHeader header;
- int end_memcpy_on_clone = 0; // place all variables to be copied between these markers
-
- void fill_buffer();
- int check_buffer();
- int check_result(int event);
- int complete(int event);
- int event_handler(int event, void *edata);
- void
- make_request()
- {
- start_time = ink_get_hrtime();
- make_request_internal();
- }
- virtual void make_request_internal() = 0;
- virtual int open_read_callout();
- virtual int open_write_callout();
-
- void
- cancel_timeout()
- {
- if (timeout) {
- timeout->cancel();
- }
- timeout = nullptr;
- }
-
- // RegressionSM API
- void
- run() override
- {
- rprintf(this->t, "running %s (%p)\n", this->cache_test_name, this);
- SCOPED_MUTEX_LOCK(lock, mutex, this_ethread());
- timeout = eventProcessor.schedule_imm(this);
- }
-
- RegressionSM *clone() override = 0;
-
- CacheTestSM(RegressionTest *t, const char *name);
- CacheTestSM(const CacheTestSM &ao);
- ~CacheTestSM() override;
-};
-
-// It is 2010 and C++ STILL doesn't have closures, a technology of the 1950s, unbelievable
-#define CACHE_SM(_t, _sm, _f) \
- struct CacheTestSM__##_sm : public CacheTestSM { \
- void \
- make_request_internal() override _f \
- \
- CacheTestSM__##_sm(RegressionTest *t) \
- : CacheTestSM(t, #_sm) \
- { \
- } \
- \
- CacheTestSM__##_sm(const CacheTestSM__##_sm &xsm) : CacheTestSM(xsm) {} \
- RegressionSM * \
- clone() override \
- { \
- return new CacheTestSM__##_sm(*this); \
- } \
- } _sm(_t);
-
-void force_link_CacheTest();
diff --git a/src/iocore/cache/RegressionSM.cc b/src/iocore/cache/RegressionSM.cc
deleted file mode 100644
index 3454a2e5fe..0000000000
--- a/src/iocore/cache/RegressionSM.cc
+++ /dev/null
@@ -1,280 +0,0 @@
-/** @file
-
- A brief file description
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#include "RegressionSM.h"
-#include "iocore/eventsystem/EventProcessor.h"
-#include "iocore/eventsystem/EThread.h"
-
-#define REGRESSION_SM_RETRY (100 * HRTIME_MSECOND)
-
-void
-RegressionSM::set_status(int astatus)
-{
- ink_assert(astatus != REGRESSION_TEST_INPROGRESS);
- // INPROGRESS < NOT_RUN < PASSED < FAILED
- if (status != REGRESSION_TEST_FAILED) {
- if (status == REGRESSION_TEST_PASSED) {
- if (astatus != REGRESSION_TEST_NOT_RUN) {
- status = astatus;
- }
- } else {
- // INPROGRESS or NOT_RUN
- status = astatus;
- }
- } // else FAILED is FAILED
-}
-
-void
-RegressionSM::done(int astatus)
-{
- if (pending_action) {
- pending_action->cancel();
- pending_action = nullptr;
- }
- set_status(astatus);
- if (pstatus) {
- *pstatus = status;
- }
- if (parent) {
- parent->child_done(status);
- }
-}
-
-void
-RegressionSM::run(int *apstatus)
-{
- pstatus = apstatus;
- run();
-}
-
-void
-RegressionSM::xrun(RegressionSM *aparent)
-{
- parent = aparent;
- parent->nwaiting++;
- run();
-}
-
-void
-RegressionSM::run_in(int *apstatus, ink_hrtime t)
-{
- pstatus = apstatus;
- SET_HANDLER(&RegressionSM::regression_sm_start);
- eventProcessor.schedule_in(this, t);
-}
-
-void
-RegressionSM::child_done(int astatus)
-{
- SCOPED_MUTEX_LOCK(l, mutex, this_ethread());
- ink_assert(nwaiting > 0);
- --nwaiting;
- set_status(astatus);
-}
-
-int
-RegressionSM::regression_sm_waiting(int /* event ATS_UNUSED */, void *data)
-{
- if (!nwaiting) {
- done(REGRESSION_TEST_NOT_RUN);
- delete this;
- return EVENT_DONE;
- }
- if (parallel || nwaiting > 1) {
- (static_cast<Event *>(data))->schedule_in(REGRESSION_SM_RETRY);
- return EVENT_CONT;
- }
- run();
- return EVENT_DONE;
-}
-
-int
-RegressionSM::regression_sm_start(int /* event ATS_UNUSED */, void * /* data ATS_UNUSED */)
-{
- run();
- return EVENT_CONT;
-}
-
-RegressionSM *
-r_sequential(RegressionTest *t, RegressionSM *sm, ...)
-{
- RegressionSM *new_sm = new RegressionSM(t);
- va_list ap;
- va_start(ap, sm);
- new_sm->parallel = false;
- new_sm->repeat = false;
- new_sm->ichild = 0;
- new_sm->nwaiting = 0;
- while (sm) {
- new_sm->children.push_back(sm);
- sm = va_arg(ap, RegressionSM *);
- }
- new_sm->n = new_sm->children.size();
- va_end(ap);
- return new_sm;
-}
-
-RegressionSM *
-r_sequential(RegressionTest *t, int an, RegressionSM *sm)
-{
- RegressionSM *new_sm = new RegressionSM(t);
- new_sm->parallel = false;
- new_sm->repeat = true;
- new_sm->ichild = 0;
- new_sm->children.push_back(sm);
- new_sm->nwaiting = 0;
- new_sm->n = an;
- return new_sm;
-}
-
-RegressionSM *
-r_parallel(RegressionTest *t, RegressionSM *sm, ...)
-{
- RegressionSM *new_sm = new RegressionSM(t);
- va_list ap;
- va_start(ap, sm);
- new_sm->parallel = true;
- new_sm->repeat = false;
- new_sm->ichild = 0;
- new_sm->nwaiting = 0;
- while (sm) {
- new_sm->children.push_back(sm);
- sm = va_arg(ap, RegressionSM *);
- }
- new_sm->n = new_sm->children.size();
- va_end(ap);
- return new_sm;
-}
-
-RegressionSM *
-r_parallel(RegressionTest *t, int an, RegressionSM *sm)
-{
- RegressionSM *new_sm = new RegressionSM(t);
- new_sm->parallel = true;
- new_sm->repeat = true;
- new_sm->ichild = 0;
- new_sm->children.push_back(sm);
- new_sm->nwaiting = 0;
- new_sm->n = an;
- return new_sm;
-}
-
-void
-RegressionSM::run()
-{
- // TODO: Why introduce another scope here?
- {
- MUTEX_TRY_LOCK(l, mutex, this_ethread());
- if (!l.is_locked() || nwaiting > 1) {
- goto Lretry;
- }
- RegressionSM *x = nullptr;
- while (ichild < n) {
- if (!repeat) {
- x = children[ichild];
- } else {
- if (ichild != n - 1) {
- x = children[static_cast<intptr_t>(0)]->clone();
- } else {
- x = children[static_cast<intptr_t>(0)];
- }
- }
- if (!ichild) {
- nwaiting++;
- }
- x->xrun(this);
- ichild++;
- if (!parallel && nwaiting > 1) {
- goto Lretry;
- }
- }
- }
- nwaiting--;
- if (!nwaiting) {
- done(REGRESSION_TEST_NOT_RUN);
- delete this;
- return;
- }
-Lretry:
- SET_HANDLER(&RegressionSM::regression_sm_waiting);
- pending_action = eventProcessor.schedule_in(this, REGRESSION_SM_RETRY);
-}
-
-RegressionSM::RegressionSM(const RegressionSM &ao) : Continuation(ao)
-{
- RegressionSM &o = *const_cast<RegressionSM *>(&ao);
-
- t = o.t;
- status = o.status;
- pstatus = o.pstatus;
- parent = &o;
- nwaiting = o.nwaiting;
-
- for (auto &i : o.children) {
- children.push_back(i->clone());
- }
-
- n = o.n;
- ichild = o.ichild;
- parallel = o.parallel;
- repeat = o.repeat;
- pending_action = o.pending_action;
-
- ink_assert(status == REGRESSION_TEST_INPROGRESS);
- ink_assert(nwaiting == 0);
- ink_assert(ichild == 0);
-
- mutex = new_ProxyMutex();
-}
-
-struct ReRegressionSM : public RegressionSM {
- void
- run() override
- {
- if (time(nullptr) < 1) { // example test
- rprintf(t, "impossible");
- done(REGRESSION_TEST_FAILED);
- } else {
- done(REGRESSION_TEST_PASSED);
- }
- // A leaf SM owns itself once it is done; composites self-delete in run().
- delete this;
- }
- ReRegressionSM(RegressionTest *at) : RegressionSM(at) {}
- RegressionSM *
- clone() override
- {
- return new ReRegressionSM(*this);
- }
- ReRegressionSM(const ReRegressionSM &o) : RegressionSM(o) { t = o.t; }
-};
-
-REGRESSION_TEST(RegressionSM)(RegressionTest *t, int /* atype ATS_UNUSED */, int *pstatus)
-{
- RegressionSM *top_sm = r_sequential(
- t, r_parallel(t, new ReRegressionSM(t), new ReRegressionSM(t), nullptr),
- r_sequential(t, new ReRegressionSM(t), new ReRegressionSM(t), nullptr), r_parallel(t, 3, new ReRegressionSM(t)),
- r_sequential(t, 3, new ReRegressionSM(t)),
- r_parallel(t, r_sequential(t, 2, new ReRegressionSM(t)), r_parallel(t, 2, new ReRegressionSM(t)), nullptr), nullptr);
- top_sm->run(pstatus);
-}
diff --git a/src/iocore/cache/RegressionSM.h b/src/iocore/cache/RegressionSM.h
deleted file mode 100644
index d648575015..0000000000
--- a/src/iocore/cache/RegressionSM.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/** @file
-
- A brief file description
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#pragma once
-
-#include "iocore/eventsystem/Action.h"
-#include "iocore/eventsystem/Continuation.h"
-#include "tscore/Regression.h"
-
-/*
- Regression Test Composition State Machine
-
- See RegressionSM.cc at the end for an example
-*/
-
-struct RegressionSM : public Continuation {
- RegressionTest *t = nullptr; // for use with rprint
-
- // methods to override
- virtual void run(); // replace with leaf regression
- virtual RegressionSM *
- clone()
- {
- return new RegressionSM(*this);
- } // replace for run_xxx(int n,...);
-
- // public API
- void done(int status = REGRESSION_TEST_NOT_RUN);
- void run(int *pstatus);
- void run_in(int *pstatus, ink_hrtime t);
-
- // internal
- int status = REGRESSION_TEST_INPROGRESS;
- int *pstatus = nullptr;
- RegressionSM *parent = nullptr;
- int nwaiting = 0;
- int nchildren = 0;
- std::vector<RegressionSM *> children;
- intptr_t n = 0;
- intptr_t ichild = 0;
- bool parallel = false;
- bool repeat = false;
- Action *pending_action = nullptr;
-
- int regression_sm_start(int event, void *data);
- int regression_sm_waiting(int event, void *data);
- void set_status(int status);
- void child_done(int status);
- void xrun(RegressionSM *parent);
-
- RegressionSM(RegressionTest *at = nullptr) : t(at) { mutex = new_ProxyMutex(); }
-
- RegressionSM(const RegressionSM &);
-};
-
-RegressionSM *r_sequential(RegressionTest *t, int n, RegressionSM *sm);
-RegressionSM *r_sequential(RegressionTest *t, RegressionSM *sm, ...); // terminate list in NULL
-RegressionSM *r_parallel(RegressionTest *t, int n, RegressionSM *sm);
-RegressionSM *r_parallel(RegressionTest *t, RegressionSM *sm, ...); // terminate list in NULL
diff --git a/src/iocore/cache/unit_tests/test_AggregateWriteBuffer.cc b/src/iocore/cache/unit_tests/test_AggregateWriteBuffer.cc
index 7c97197d53..a37ba427cc 100644
--- a/src/iocore/cache/unit_tests/test_AggregateWriteBuffer.cc
+++ b/src/iocore/cache/unit_tests/test_AggregateWriteBuffer.cc
@@ -26,7 +26,7 @@
int cache_vols = 1;
bool reuse_existing_cache = false;
-// This is a regression test for a bug caught in review. The RegressionSM
+// This is a regression test for a bug caught in review. The traffic_server regression
// suite did not catch it. Issues related to this would manifest only after
// the cache wraps around, because add() is only used by evacuators.
TEST_CASE("Given 10 bytes are pending to the buffer, "