Skip to content

Commit

Permalink
Rename cache/test/ to cache/unit_tests/ (#10645)
Browse files Browse the repository at this point in the history
For consistency with other subsystems

* Rename cache/test/ to cache/unit_tests/
* Fix CacheDir test try lock
  • Loading branch information
masaori335 authored Oct 19, 2023
1 parent 8122b6a commit 23e967b
Show file tree
Hide file tree
Showing 27 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,4 @@ tests/gold_tests/chunked_encoding/smuggle-client
tests/gold_tests/tls/ssl-post

src/iocore/cache/test_*
src/iocore/cache/test/var/trafficserver/cache.db
src/iocore/cache/unit_tests/var/trafficserver/cache.db
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ populate_cache(const swoc::file::path &prefix)
swoc::file::path src_path{TS_ABS_TOP_SRCDIR};
std::error_code ec;
ink_assert(cache_vols == 2);
swoc::file::copy(src_path / "src/iocore/cache/test/var/trafficserver/cache.db", prefix / "var/trafficserver/", ec);
swoc::file::copy(src_path / "src/iocore/cache/test/var/trafficserver2/cache.db", prefix / "var/trafficserver2/", ec);
swoc::file::copy(src_path / "src/iocore/cache/unit_tests/var/trafficserver/cache.db", prefix / "var/trafficserver/", ec);
swoc::file::copy(src_path / "src/iocore/cache/unit_tests/var/trafficserver2/cache.db", prefix / "var/trafficserver2/", ec);
}

void
Expand Down Expand Up @@ -157,7 +157,7 @@ struct EventProcessorListener : Catch::TestEventListenerBase {
thread->set_tail_handler(&uring_handler);
#endif

std::string src_dir = std::string(TS_ABS_TOP_SRCDIR) + "/src/iocore/cache/test";
std::string src_dir = std::string(TS_ABS_TOP_SRCDIR) + "/src/iocore/cache/unit_tests";
Layout::get()->sysconfdir = src_dir;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "P_AIO.h"
#include "P_CacheDisk.h"
#include "P_Net.h"
#include "test/CacheTestHandler.h"
#include "CacheTestHandler.h"
#include "P_Cache.h"

#include <queue>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ class CacheDirTest : public CacheInit
Vol *vol = gvol[0];
EThread *thread = this_ethread();
MUTEX_TRY_LOCK(lock, vol->mutex, thread);
ink_release_assert(lock.is_locked());
if (!lock.is_locked()) {
CONT_SCHED_LOCK_RETRY(this);
return;
}

vol_dir_clear(vol);

// coverity[var_decl]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/proxy/http/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ test_HttpTransact_LDADD += \
endif

test_HttpTransact_SOURCES = \
../../iocore/cache/test/stub.cc \
../../iocore/cache/unit_tests/stub.cc \
unit_tests/main.cc \
unit_tests/test_HttpTransact.cc

Expand Down
2 changes: 1 addition & 1 deletion src/proxy/http/unit_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
add_executable(
test_http
main.cc
"${PROJECT_SOURCE_DIR}/src/iocore/cache/test/stub.cc"
"${PROJECT_SOURCE_DIR}/src/iocore/cache/unit_tests/stub.cc"
test_error_page_selection.cc
test_ForwardedConfig.cc
test_HttpTransact.cc
Expand Down
38 changes: 19 additions & 19 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ endif(TS_USE_LINUX_IO_URING)

macro(add_cache_test name)
add_executable(
${name} ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/main.cc ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/stub.cc
${CMAKE_SOURCE_DIR}/src/iocore/cache/test/CacheTestHandler.cc ${ARGN}
${name} ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/main.cc ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/stub.cc
${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/CacheTestHandler.cc ${ARGN}
)
target_link_libraries(${name} PRIVATE ts::inknet ts::proxy ts::tsapicore)
add_test(NAME test_cache_${name} COMMAND $<TARGET_FILE:${name}>)
Expand All @@ -82,37 +82,37 @@ macro(add_net_test name)
endmacro()

macro(add_stubbed_test name)
add_executable(${name} ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/stub.cc ${ARGN})
add_executable(${name} ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/stub.cc ${ARGN})
target_link_libraries(${name} PRIVATE ts::proxy ts::http)
add_test(NAME test_stubbed_${name} COMMAND $<TARGET_FILE:${name}>)
endmacro()

add_cache_test(Cache ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/test_Cache.cc)
add_cache_test(Populated_Cache ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/test_Populated_Cache.cc)
add_cache_test(Cache ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_Cache.cc)
add_cache_test(Populated_Cache ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_Populated_Cache.cc)
if(ENABLE_DISK_FAILURE_TESTS)
foreach(i RANGE 1)
add_cache_test(Disk_Init_Failure_${i} ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/test_Disk_Init_Failure.cc)
add_cache_test(Disk_Init_Failure_${i} ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_Disk_Init_Failure.cc)
target_compile_definitions(Disk_Init_Failure_${i} PUBLIC FAILURE_INDICES={${i}})
endforeach()
foreach(i RANGE 5 20)
add_cache_test(Disk_Failure_${i} ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/test_Disk_Failure.cc)
add_cache_test(Disk_Failure_${i} ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_Disk_Failure.cc)
target_compile_definitions(Disk_Failure_${i} PUBLIC FAILURE_INDICES={${i}})
endforeach()
add_cache_test(
Populated_Cache_Disk_Failure ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/test_Populated_Cache_Disk_Failure.cc
Populated_Cache_Disk_Failure ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_Populated_Cache_Disk_Failure.cc
)
endif()
add_cache_test(CacheDir ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/test_CacheDir.cc)
add_cache_test(RWW ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/test_RWW.cc)
add_cache_test(Alternate_L_to_S ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/test_Alternate_L_to_S.cc)
add_cache_test(Alternate_S_to_L ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/test_Alternate_S_to_L.cc)
add_cache_test(Alternate_L_to_S_remove_L ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/test_Alternate_L_to_S_remove_L.cc)
add_cache_test(Alternate_L_to_S_remove_S ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/test_Alternate_L_to_S_remove_S.cc)
add_cache_test(Alternate_S_to_L_remove_L ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/test_Alternate_S_to_L_remove_L.cc)
add_cache_test(Alternate_S_to_L_remove_S ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/test_Alternate_S_to_L_remove_S.cc)
add_cache_test(Update_L_to_S ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/test_Update_L_to_S.cc)
add_cache_test(Update_S_to_L ${CMAKE_SOURCE_DIR}/src/iocore/cache/test/test_Update_S_to_L.cc)
#add_cache_test(Update_Header ${CMAKE_SOURCE_DIR}/iocore/cache/test/test_Update_Header.cc)
add_cache_test(CacheDir ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_CacheDir.cc)
add_cache_test(RWW ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_RWW.cc)
add_cache_test(Alternate_L_to_S ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_Alternate_L_to_S.cc)
add_cache_test(Alternate_S_to_L ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_Alternate_S_to_L.cc)
add_cache_test(Alternate_L_to_S_remove_L ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_Alternate_L_to_S_remove_L.cc)
add_cache_test(Alternate_L_to_S_remove_S ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_Alternate_L_to_S_remove_S.cc)
add_cache_test(Alternate_S_to_L_remove_L ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_Alternate_S_to_L_remove_L.cc)
add_cache_test(Alternate_S_to_L_remove_S ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_Alternate_S_to_L_remove_S.cc)
add_cache_test(Update_L_to_S ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_Update_L_to_S.cc)
add_cache_test(Update_S_to_L ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_Update_S_to_L.cc)
#add_cache_test(Update_Header ${CMAKE_SOURCE_DIR}/src/iocore/cache/unit_tests/test_Update_Header.cc)

add_executable(test_AIO ${CMAKE_SOURCE_DIR}/src/iocore/aio/test_AIO.cc)
add_test(
Expand Down

0 comments on commit 23e967b

Please sign in to comment.