diff --git a/CMakeLists.txt b/CMakeLists.txt index fd4492b34..81a09b5bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,11 @@ cmake_minimum_required(VERSION 3.11) -project(e VERSION 3.3.0) +project(e VERSION 3.3.2) if(WIN32) - message(FATAL_ERROR "WIN32 target is obsolete. Please use Windows Subsystems for Linux") + message( + FATAL_ERROR + "WIN32 target is obsolete. Please use Windows Subsystems for Linux") endif(WIN32) set(CMAKE_CXX_STANDARD 17) @@ -80,7 +82,6 @@ check_cxx_source_compiles( " HAVE_PRAGMA_PACK) - check_cxx_source_compiles( " #include @@ -88,7 +89,7 @@ check_cxx_source_compiles( #include #include struct aAa {}; - + int main(void) { struct aAa a1; int status = -4; @@ -108,10 +109,9 @@ else() endif() if(HAVE_DEMANGLE) -add_compile_definitions(HAVE_DEMANGLE) + add_compile_definitions(HAVE_DEMANGLE) endif() - # Build E file(GLOB_RECURSE e_SOURCES "src/*.cpp") @@ -123,8 +123,7 @@ find_package(Threads REQUIRED) target_link_libraries(e PUBLIC Threads::Threads) if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") -set_target_properties(e PROPERTIES OSX_ARCHITECTURES - "arm64;x86_64") + set_target_properties(e PROPERTIES OSX_ARCHITECTURES "arm64;x86_64") endif() target_compile_options(e PRIVATE -g -O0 -Wall) @@ -135,12 +134,13 @@ include(FetchContent) FetchContent_Declare( googletest - URL https://github.com/google/googletest/archive/release-1.10.0.zip) + URL https://github.com/google/googletest/archive/b007c54f2944e193ac44fba1bc997cb65826a0b9.zip +) FetchContent_GetProperties(googletest) if(NOT googletest_POPULATED) FetchContent_Populate(googletest) - add_subdirectory(${googletest_SOURCE_DIR}/googletest ${googletest_BINARY_DIR}) + add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) endif() # Find Solution @@ -175,7 +175,6 @@ endfunction() file(GLOB_RECURSE e_solution_CMAKELISTS "${PROJECT_SOURCE_DIR}/solution/*/CMakeLists.txt") - foreach(cmakelists ${e_solution_CMAKELISTS}) get_filename_component(e_solution_DIR ${cmakelists} DIRECTORY) add_subdirectory(${e_solution_DIR}) @@ -185,34 +184,38 @@ endforeach() include(FetchContent) function(get_solution) - set(SOLUTION_REPO "https://anlab-kaist.github.io/KENSv3/solution/${CMAKE_PROJECT_VERSION}") + set(SOLUTION_REPO + "https://anlab-kaist.github.io/KENSv3/solution/${CMAKE_PROJECT_VERSION}") foreach(arg IN LISTS ARGN) # Find Solution if(NOT TARGET ${arg}_solution) - find_library(${arg}_solution_path ${arg}_solution PATH ${SOLUTION_PATH} EXACT) - - - if (NOT ${arg}_solution_path) - # Download Solution - message(STATUS "Donwloading ${arg}_solution") - get_solution_name(${arg}_solution) - - include(FetchContent) - - FetchContent_Declare( - ${arg}_solution URL "${SOLUTION_REPO}/${${arg}_solution_SOLUTION_NAME}") - FetchContent_GetProperties(${arg}_solution) - if(NOT (${arg}_solution_POPULATED)) - FetchContent_Populate(${arg}_solution) - endif() - - find_library(${arg}_solution_path ${arg}_solution PATH ${${arg}_solution_SOURCE_DIR} EXACT) - endif() - add_library(${arg}_solution SHARED IMPORTED GLOBAL) - set_property(TARGET ${arg}_solution PROPERTY IMPORTED_LOCATION ${${arg}_solution_path}) - - target_link_libraries(${arg}_solution INTERFACE e) + find_library(${arg}_solution_path ${arg}_solution PATH ${SOLUTION_PATH} + EXACT) + + if(NOT ${arg}_solution_path) + # Download Solution + message(STATUS "Donwloading ${arg}_solution") + get_solution_name(${arg}_solution) + + include(FetchContent) + + FetchContent_Declare( + ${arg}_solution + URL "${SOLUTION_REPO}/${${arg}_solution_SOLUTION_NAME}") + FetchContent_GetProperties(${arg}_solution) + if(NOT (${arg}_solution_POPULATED)) + FetchContent_Populate(${arg}_solution) + endif() + + find_library(${arg}_solution_path ${arg}_solution PATH + ${${arg}_solution_SOURCE_DIR} EXACT) + endif() + add_library(${arg}_solution SHARED IMPORTED GLOBAL) + set_property(TARGET ${arg}_solution PROPERTY IMPORTED_LOCATION + ${${arg}_solution_path}) + + target_link_libraries(${arg}_solution INTERFACE e) endif() endforeach() endfunction() @@ -220,14 +223,14 @@ endfunction() # Build Apps include(cmake/app-ref.cmake OPTIONAL) -if (e_apps_CMAKELISTS) +if(e_apps_CMAKELISTS) + else() -file(GLOB e_apps_CMAKELISTS "${PROJECT_SOURCE_DIR}/app/*/CMakeLists.txt") + file(GLOB e_apps_CMAKELISTS "${PROJECT_SOURCE_DIR}/app/*/CMakeLists.txt") endif() list(FILTER e_apps_CMAKELISTS EXCLUDE REGEX ".*/scheduling/.*") - foreach(cmakelists ${e_apps_CMAKELISTS}) get_filename_component(e_apps_DIR ${cmakelists} DIRECTORY) add_subdirectory(${e_apps_DIR}) @@ -246,4 +249,4 @@ if(DOXYGEN_FOUND) endif(DOXYGEN_FOUND) -include(cmake/kens-dist.cmake OPTIONAL) \ No newline at end of file +include(cmake/kens-dist.cmake OPTIONAL) diff --git a/app/kens/CMakeLists.txt b/app/kens/CMakeLists.txt index b7b7af599..074d65f4a 100644 --- a/app/kens/CMakeLists.txt +++ b/app/kens/CMakeLists.txt @@ -12,46 +12,68 @@ get_solution(kens) # Tests -set(kens_part1_SOURCES testopen.cpp testbind.cpp) -set(kens_part2_SOURCES testhandshake.cpp testclose.cpp) -set(kens_part3_SOURCES testtransfer.cpp) -set(kens_part4_SOURCES testcongestion.cpp) -set(kens_all_SOURCES ${kens_part1_SOURCES} ${kens_part2_SOURCES} - ${kens_part3_SOURCES} ${kens_part4_SOURCES}) - +set(test_open_SOURCES testopen.cpp) +set(test_bind_SOURCES testbind.cpp) +set(test_handshake_SOURCES testhandshake.cpp) +set(test_close_SOURCES testclose.cpp) +set(test_transfer_SOURCES testtransfer.cpp) +set(test_congestion_SOURCES testcongestion.cpp) +set(test_all_SOURCES testopen.cpp testbind.cpp testhandshake.cpp testclose.cpp + testtransfer.cpp testcongestion.cpp) set(kens-targets kens) -if (TARGET kens-ref) -list(APPEND kens-targets kens-ref) +if(TARGET kens-ref) + list(APPEND kens-targets kens-ref) endif() - foreach(kens-traget ${kens-targets}) - foreach(part part1 part2 part3 part4 all) - add_executable(${kens-traget}-${part} testenv.hpp ${kens_${part}_SOURCES}) - target_link_libraries(${kens-traget}-${part} ${kens-traget} kens_solution gtest_main) - add_executable(${kens-traget}-${part}-unreliable testenv.hpp ${kens_${part}_SOURCES}) - target_link_libraries(${kens-traget}-${part}-unreliable ${kens-traget} kens_solution gtest_main) - add_executable(${kens-traget}-${part}-run-solution testenv.hpp ${kens_${part}_SOURCES}) - target_link_libraries(${kens-traget}-${part}-run-solution ${kens-traget} kens_solution gtest_main) - add_executable(${kens-traget}-${part}-unreliable-run-solution testenv.hpp - ${kens_${part}_SOURCES}) - target_link_libraries(${kens-traget}-${part}-unreliable-run-solution ${kens-traget} kens_solution gtest_main) - - target_compile_definitions(${kens-traget}-${part}-run-solution PRIVATE RUN_SOLUTION) - target_compile_definitions(${kens-traget}-${part}-unreliable-run-solution - PRIVATE RUN_SOLUTION UNRELIABLE) - target_compile_definitions(${kens-traget}-${part}-unreliable PRIVATE UNRELIABLE) + foreach( + part + open + bind + handshake + close + transfer + congestion + all) + + add_executable(test-${kens-traget}-${part} testenv.hpp + ${test_${part}_SOURCES}) + target_link_libraries(test-${kens-traget}-${part} ${kens-traget} + kens_solution gtest_main) + add_executable(test-${kens-traget}-${part}-unreliable + testenv.hpp ${test_${part}_SOURCES}) + target_link_libraries(test-${kens-traget}-${part}-unreliable ${kens-traget} + kens_solution gtest_main) + add_executable(test-${kens-traget}-${part}-run-solution + testenv.hpp ${test_${part}_SOURCES}) + target_link_libraries(test-${kens-traget}-${part}-run-solution + ${kens-traget} kens_solution gtest_main) + add_executable(test-${kens-traget}-${part}-unreliable-run-solution + testenv.hpp ${test_${part}_SOURCES}) + target_link_libraries(test-${kens-traget}-${part}-unreliable-run-solution + ${kens-traget} kens_solution gtest_main) + + target_compile_definitions(test-${kens-traget}-${part}-run-solution + PRIVATE RUN_SOLUTION) + target_compile_definitions( + test-${kens-traget}-${part}-unreliable-run-solution PRIVATE RUN_SOLUTION + UNRELIABLE) + target_compile_definitions(test-${kens-traget}-${part}-unreliable + PRIVATE UNRELIABLE) if(${CMAKE_VERSION} VERSION_GREATER "3.13.0") set_target_properties( - ${kens-traget}-${part} ${kens-traget}-${part}-run-solution ${kens-traget}-${part}-unreliable - ${kens-traget}-${part}-unreliable-run-solution PROPERTIES XCODE_GENERATE_SCHEME ON) + test-${kens-traget}-${part} test-${kens-traget}-${part}-run-solution + test-${kens-traget}-${part}-unreliable + test-${kens-traget}-${part}-unreliable-run-solution + PROPERTIES XCODE_GENERATE_SCHEME ON) set_target_properties( - ${kens-traget}-${part} ${kens-traget}-${part}-run-solution ${kens-traget}-${part}-unreliable - ${kens-traget}-${part}-unreliable-run-solution PROPERTIES XCODE_SCHEME_ENVIRONMENT - "GTEST_COLOR=no") + test-${kens-traget}-${part} test-${kens-traget}-${part}-run-solution + test-${kens-traget}-${part}-unreliable + test-${kens-traget}-${part}-unreliable-run-solution + PROPERTIES XCODE_SCHEME_ENVIRONMENT "GTEST_COLOR=no") endif() endforeach(part) endforeach(kens-traget) diff --git a/entrypoint.sh b/entrypoint.sh index 87ecb12b3..74c47e9c5 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,7 +7,7 @@ fi function grade() { if [ "$#" -lt 2 ]; then - echo "Usage: grade [app_name] [parts ...]" + echo "Usage: grade [app_name] [binaries ...]" exit 1 fi echo "Grading $1: ${*:2}" @@ -25,9 +25,9 @@ function grade() { RANDOM_SEED=${RANDOM_SEED:-0} TIMEOUT=${TIMEOUT:-300} for seed in ${RANDOM_SEED//,/ }; do - for part in "${@:2}"; do - for test in $("./app/$1/$1-$part" --gtest_list_tests | grep '^ *'); do - timeout ${TIMEOUT} GTEST_OUTPUT="xml:/xml/${1}_${part}_${seed}_${test}.xml" RANDOM_SEED=$seed "./app/$1/$1-$part" --gtest_filter="*$test" + for binary in "${@:2}"; do + for test in $("./app/$1/$binary" --gtest_list_tests | grep '^ *'); do + timeout ${TIMEOUT} GTEST_OUTPUT="xml:/xml/${1}_${binary}_${seed}_${test}.xml" RANDOM_SEED=$seed "./app/$1/$binary" --gtest_filter="*$test" done done done diff --git a/src/E/E_System.cpp b/src/E/E_System.cpp index 42e666f41..9b90c67e4 100644 --- a/src/E/E_System.cpp +++ b/src/E/E_System.cpp @@ -170,14 +170,14 @@ Runnable::Runnable() : state(State::CREATED), threadLock(stateMtx, std::defer_lock), schedLock(stateMtx), thread(&Runnable::run, this) {} Runnable::~Runnable() { - assert(std::this_thread::get_id() != thread.get_id()); assert(schedLock.owns_lock()); + assert(std::this_thread::get_id() != thread.get_id()); thread.join(); } void Runnable::run() { - assert(std::this_thread::get_id() == thread.get_id()); threadLock.lock(); + assert(std::this_thread::get_id() == thread.get_id()); cond.wait(threadLock, [&] { return state == State::STARTING; }); pre_main(); state = State::READY; @@ -190,8 +190,8 @@ void Runnable::run() { } void Runnable::wait() { - assert(std::this_thread::get_id() == thread.get_id()); assert(threadLock.owns_lock()); + assert(std::this_thread::get_id() == thread.get_id()); assert(state == State::RUNNING); state = State::WAITING; cond.notify_all(); @@ -199,8 +199,8 @@ void Runnable::wait() { } void Runnable::start() { - assert(std::this_thread::get_id() != thread.get_id()); assert(schedLock.owns_lock()); + assert(std::this_thread::get_id() != thread.get_id()); assert(state == State::CREATED); state = State::STARTING; cond.notify_all(); @@ -208,8 +208,8 @@ void Runnable::start() { assert(schedLock.owns_lock()); } Runnable::State Runnable::wake() { - assert(std::this_thread::get_id() != thread.get_id()); assert(schedLock.owns_lock()); + assert(std::this_thread::get_id() != thread.get_id()); assert(state == State::READY); state = State::RUNNING; cond.notify_all();