Commit a053f5cc by lucapegolotti

Split tests from function in linearizability_tester.h

parent 7c9dd335
cmake_minimum_required (VERSION 2.6)
project (Linearizability_tester C CXX)
project (EMBB_linearizability_test C CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lrt")
find_package(Threads REQUIRED)
......@@ -42,7 +42,7 @@ set(PROJECT_LINK_LIBS
)
ENDIF (WIN32)
add_executable(${PROJECT_NAME} lt.cc)
add_executable(${PROJECT_NAME} main.cc)
# target_link_libraries(${PROJECT_NAME} ${CMAKE_THREADS_LIBS_INIT})
target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT} ${PROJECT_LINK_LIBS}) # ${CMAKE_THREADS_LIBS_INIT})
Linearizability tester on EMBB data structures
----------------------------------------------
This README.txt gives information on how to compile the linearizability test
and how to implement tests for other future data structures.
The code in this folder is meant to check the linearizability of the
data structures implemented in the EMBB library. The original linearizability
checker was developed by Alex Horn (Oxford) and the original source code is
freely downloadable from the public github repository:
--> https://github.com/ahorn/linearizability-checker
main.cc is the script that runs the test on the structures currently available.
The src folder contains a large part of the code by Alex Horn.
COMPILE INSTRUCTIONS
* On Linux system
Suppose that the embb library was build in ../build (relative path to the current
folder of the linearizability test).
From within the linearizability_tester folder, cd (or mkdir->cd) into the build directory,
then run "cmake .." and "make". The executable of the test should be placed in the
same folder with the name EMBB_linearizability_test.
* On Windows system
Suppose that the embb library was build in ../build (relative path to the current
folder of the linearizability test).
NOTE: the embb library should be build in Release mode, i.e. by running the command
"cmake --build . --config Release" from inside the correct directory.
From within the linearizability_tester folder, cd (or mkdir->cd) into the build directory,
then run "cmake .." and "cmake --build . --config Release". The Visual Studio prompt should
be used.
The executable of the test should be placed in the folder Release
with the name EMBB_linearizability_test.exe.
HOW TO IMPLEMENT TESTS FOR OTHER DATASTRUCTURES
Data structures that support the following functions:
\ No newline at end of file
#include <linearizability_tester.h>
#include <tests.h>
#include <embb/base/thread.h>
#include <embb/containers/lock_free_stack.h>
......@@ -89,8 +90,6 @@ static void embb_experiment_stack(bool is_linearizable)
constexpr WorkerConfiguration worker_configuration = { '\24', 70000U };
constexpr unsigned log_size = number_of_threads * worker_configuration.number_of_ops;
std::cout << "embb_experiment_stack : " << (is_linearizable ? "" : "!") << "linearizable" << std::endl;
Result<state::Stack<N>> result;
ConcurrentLog<state::Stack<N>> concurrent_log{ 2U * log_size };
S concurrent_stack(N);
......@@ -107,7 +106,6 @@ static void embb_experiment_stack(bool is_linearizable)
const std::size_t number_of_entries{ concurrent_log.number_of_entries() };
const LogInfo<state::Stack<N>> log_info{ concurrent_log.info() };
// std::cout << log_info << std::endl;
auto start = std::chrono::system_clock::now();
auto end = std::chrono::system_clock::now();
......@@ -125,7 +123,7 @@ static void embb_experiment_stack(bool is_linearizable)
end = std::chrono::system_clock::now();
seconds = std::chrono::duration_cast<std::chrono::seconds>(end - start);
std::cout << "History length: " << number_of_entries
<< ", enabled state cache (LRU=on), O(1) hash: "
<< ", elapsed time: "
<< seconds.count() << " s " << std::endl;
}
......@@ -138,7 +136,6 @@ static void embb_experiment_queue(bool is_linearizable)
constexpr WorkerConfiguration worker_configuration = { '\24', 70000U };
constexpr unsigned log_size = number_of_threads * worker_configuration.number_of_ops;
std::cout << "embb_experiment_queue : " << (is_linearizable ? "" : "!") << "linearizable" << std::endl;
Result<state::Queue<N>> result;
ConcurrentLog<state::Queue<N>> concurrent_log{ 2U * log_size };
......@@ -172,7 +169,7 @@ static void embb_experiment_queue(bool is_linearizable)
end = std::chrono::system_clock::now();
seconds = std::chrono::duration_cast<std::chrono::seconds>(end - start);
std::cout << "History length: " << number_of_entries
<< ", enabled state cache (LRU=on), O(1) hash: "
<< ", elapsed time: "
<< seconds.count() << " s " << std::endl;
}
......@@ -180,87 +177,15 @@ static void embb_experiment_queue(bool is_linearizable)
int main()
{
test_lru_cache();
test_atomic_op();
test_stack();
test_state_set();
test_bitset();
test_state_set_op();
test_state_stack();
test_state_stack_op();
test_state_queue();
test_state_queue_op();
test_linearizability_empty_log();
test_raw_single_contains_is_linearizable();
test_raw_single_contains_is_not_linearizable();
test_log_copy();
test_single_contains(true);
test_single_contains(false);
// Consider a sequential insert(x) && contains(x) operation
// && their return values on an initially empty set:
for (bool a : {true, false})
for (bool b : {true, false})
{
test_000(a, b);
test_001(a, b);
test_002(a, b);
test_003(a, b);
test_004(a, b);
test_005(a, b);
test_006(a, b);
test_007(a, b);
test_008(a, b);
}
// semantically deeper tests
test_009();
test_010();
test_011();
test_012();
test_013();
test_014();
test_015();
test_016();
test_017();
test_018();
for (bool a : {true, false})
for (bool b : {true, false})
for (bool c : {true, false})
{
test_019(a, b, c);
test_020(a, b, c);
}
test_021();
test_stack_history_000();
test_stack_history_001();
test_stack_history_002();
test_stack_history_003();
test_slice_000();
test_slice_001();
#ifdef _LT_DEBUG_
// debug();
#endif
concurrent_log();
fuzzy_functional_test();
// Test functions and structures in linearizability_tester.h
run_tests();
embb::base::Thread::SetThreadsMaxCount(255);
std::cout << "Linearizability experiment on LockFreeMPMCQueue" << std::endl;
std::cout << "Linearizability test on LockFreeMPMCQueue" << std::endl;
embb_experiment_queue<embb::containers::LockFreeMPMCQueue<char>>(true);
std::cout << "Linearizability experiment on LockFreeStack" << std::endl;
std::cout << "Linearizability test on LockFreeStack" << std::endl;
embb_experiment_stack<embb::containers::LockFreeStack<char>>(true);
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment