pax_global_header00006660000000000000000000000064135444401150014513gustar00rootroot0000000000000052 comment=be83577670e9e87914d6ede87bd3fa95b9713cf2 pmdk-convert-1.7/000077500000000000000000000000001354444011500137735ustar00rootroot00000000000000pmdk-convert-1.7/.gitignore000066400000000000000000000001301354444011500157550ustar00rootroot00000000000000/.project /.cproject /build /1.0 /1.1 /1.2.4 /1.3.3 /1.4.3 /1.5.2 /1.6.1 /1.7 /*.tar.gz pmdk-convert-1.7/.travis.yml000077700000000000000000000000001354444011500201322travis.ymlustar00rootroot00000000000000pmdk-convert-1.7/CMakeLists.txt000066400000000000000000001644661354444011500165540ustar00rootroot00000000000000# # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${CMAKE_SOURCE_DIR}/utils/utils.cmake) cmake_minimum_required(VERSION 3.3) project(pmdk-convert C CXX) set(VERSION_MAJOR 1) set(VERSION_MINOR 7) set(VERSION_PATCH 0) #set(VERSION_PRERELEASE rc0) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}) if (VERSION_PATCH GREATER 0) set(VERSION ${VERSION}.${VERSION_PATCH}) endif() if (VERSION_PRERELEASE) set(VERSION ${VERSION}-${VERSION_PRERELEASE}) endif() set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}) include(FindThreads) if(WIN32) set(MIN_VERSION 1.4 CACHE STRING "First supported version (major.minor)") else() set(MIN_VERSION 1.0 CACHE STRING "First supported version (major.minor)") endif() set(MAX_VERSION 1.7) set(MAX_STABLE 1.7) if(MIN_VERSION VERSION_GREATER_EQUAL MAX_VERSION) message(FATAL_ERROR "ERROR: Minimum PMDK version cannot be greater than or equal to maximum PMDK version") endif() STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+" "\\1" MIN_VERSION_MAJOR "${MIN_VERSION}") STRING(REGEX REPLACE "^[0-9]+\\.([0-9]+)" "\\1" MIN_VERSION_MINOR "${MIN_VERSION}") STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+" "\\1" MAX_VERSION_MAJOR "${MAX_VERSION}") STRING(REGEX REPLACE "^[0-9]+\\.([0-9]+)" "\\1" MAX_VERSION_MINOR "${MAX_VERSION}") if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo") endif (NOT CMAKE_BUILD_TYPE) include(CheckCCompilerFlag) include(GNUInstallDirs) if(NOT MSVC) find_package(PkgConfig QUIET) endif() set(CMAKE_C_STANDARD 99) # Checks whether flag is supported by current C compiler and appends # it to the relevant cmake variable. # 1st argument is a flag # 2nd (optional) argument is a build type (debug, release, relwithdebinfo) macro(add_c_flag flag) string(REPLACE - _ flag2 ${flag}) string(REPLACE " " _ flag2 ${flag2}) string(REPLACE = "_" flag2 ${flag2}) set(check_name "C_HAS_${flag2}") check_c_compiler_flag("${flag}" "${check_name}") if (${${check_name}}) if (${ARGC} EQUAL 1) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") else() set(CMAKE_C_FLAGS_${ARGV1} "${CMAKE_C_FLAGS_${ARGV1}} ${flag}") endif() endif() endmacro() if(NOT MSVC) add_c_flag(-fno-common) add_c_flag(-Wall) add_c_flag(-Wconversion) add_c_flag(-Wmissing-field-initializers) add_c_flag(-Wmissing-prototypes) add_c_flag(-Wmissing-variable-declarations) add_c_flag(-Wpointer-arith) add_c_flag(-Wsign-compare) add_c_flag(-Wsign-conversion) add_c_flag(-Wunused-macros) add_c_flag(-Wunreachable-code-return) # Place each function or data item into its own section. Will be used to strip unneeded symbols. add_c_flag(-fdata-sections) add_c_flag(-ffunction-sections) add_c_flag(-ggdb DEBUG) add_c_flag(-DDEBUG DEBUG) add_c_flag(-ggdb RELWITHDEBINFO) add_c_flag(-fno-omit-frame-pointer RELWITHDEBINFO) check_c_compiler_flag(-Wl,-z,relro LINKER_HAS_RELRO) if(LINKER_HAS_RELRO) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,relro") endif() check_c_compiler_flag(-Wl,--warn-common LINKER_HAS_WARN_COMMON) if(LINKER_HAS_WARN_COMMON) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--warn-common") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--warn-common") endif() add_c_flag("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" RELEASE) endif() configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) function(version_supported ver ver_next RESULT) if (${MIN_VERSION} VERSION_GREATER ${ver}) set(${RESULT} 0 PARENT_SCOPE) return() endif() if (${ver_next} VERSION_GREATER ${MAX_VERSION}) set(${RESULT} 0 PARENT_SCOPE) return() endif() set(${RESULT} 1 PARENT_SCOPE) return() endfunction(version_supported) # disabled by default: set(BUILD_13 0) set(BUILD_15 0) if (${MIN_VERSION} EQUAL 1.0) set(BUILD_CONVERT_V1 1) set(BUILD_CONVERT_V2 1) set(BUILD_CONVERT_V3 1) set(BUILD_13 1) set(BUILD_CONVERT_V4 1) set(BUILD_CONVERT_V5 1) set(BUILD_CONVERT_V6 1) set(BUILD_15 1) elseif (${MIN_VERSION} EQUAL 1.1) set(BUILD_CONVERT_V2 1) set(BUILD_CONVERT_V3 1) set(BUILD_13 1) set(BUILD_CONVERT_V4 1) set(BUILD_CONVERT_V5 1) set(BUILD_15 1) elseif (${MIN_VERSION} EQUAL 1.2) set(BUILD_CONVERT_V3 1) set(BUILD_13 1) set(BUILD_CONVERT_V4 1) set(BUILD_CONVERT_V5 1) set(BUILD_15 1) set(BUILD_CONVERT_V6 1) elseif (${MIN_VERSION} EQUAL 1.3) set(BUILD_13 1) set(BUILD_CONVERT_V4 1) set(BUILD_CONVERT_V5 1) set(BUILD_15 1) set(BUILD_CONVERT_V6 1) elseif (${MIN_VERSION} EQUAL 1.4) set(BUILD_CONVERT_V4 1) set(BUILD_CONVERT_V5 1) set(BUILD_15 1) set(BUILD_CONVERT_V6 1) elseif (${MIN_VERSION} EQUAL 1.5) set(BUILD_CONVERT_V5 1) set(BUILD_15 1) set(BUILD_CONVERT_V6 1) elseif (${MIN_VERSION} EQUAL 1.6) set(BUILD_CONVERT_V5 1) set(BUILD_CONVERT_V6 1) elseif (${MIN_VERSION} EQUAL 1.7) set(BUILD_CONVERT_V6 1) endif() add_executable(check_license EXCLUDE_FROM_ALL utils/check_license/check-license.c) # Generates cstyle-$name target and attaches it as a dependency of global # "cstyle" target. This target verifies C style of files in current source dir. # If more arguments are used, then they are used as files to be checked # instead. # ${name} must be unique. function(add_cstyle name) if(${ARGC} EQUAL 1) add_custom_target(cstyle-${name} COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/utils/cstyle ${CMAKE_CURRENT_SOURCE_DIR}/*.c ${CMAKE_CURRENT_SOURCE_DIR}/*.h) else() add_custom_target(cstyle-${name} COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/utils/cstyle ${ARGN}) endif() add_dependencies(cstyle cstyle-${name}) endfunction() # Generates check-whitespace-$name target and attaches it as a dependency # of global "check-whitespace" target. This target verifies C files in current # source dir do not have any whitespace errors. # If more arguments are used, then they are used as files to be checked # instead. # ${name} must be unique. function(add_check_whitespace name) if(${ARGC} EQUAL 1) add_custom_target(check-whitespace-${name} COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/utils/check_whitespace ${CMAKE_CURRENT_SOURCE_DIR}/*.c ${CMAKE_CURRENT_SOURCE_DIR}/*.h) else() add_custom_target(check-whitespace-${name} COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/utils/check_whitespace ${ARGN}) endif() add_dependencies(check-whitespace check-whitespace-${name}) endfunction() add_custom_target(checkers ALL) add_custom_target(cstyle) add_custom_target(check-whitespace) add_custom_target(check-license COMMAND ${CMAKE_SOURCE_DIR}/utils/check_license/check-headers.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}/check_license ${CMAKE_SOURCE_DIR}/LICENSE -a) add_custom_target(md2man COMMAND ${CMAKE_SOURCE_DIR}/utils/md2man/md2man.sh ${CMAKE_SOURCE_DIR}/doc/pmdk-convert/pmdk-convert.1.md ${CMAKE_SOURCE_DIR}/utils/md2man/default.man ${CMAKE_SOURCE_DIR}/doc/generated/pmdk-convert.1 ) if (NOT WIN32) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/doc/generated/pmdk-convert.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) endif() add_dependencies(check-license check_license) add_cstyle(main) add_cstyle(check_license ${CMAKE_SOURCE_DIR}/utils/check_license/*.c) add_check_whitespace(check_license ${CMAKE_SOURCE_DIR}/utils/check_license/*.c) add_check_whitespace(src) add_check_whitespace(other ${CMAKE_SOURCE_DIR}/utils/check_license/*.sh ${CMAKE_SOURCE_DIR}/README.md ${CMAKE_SOURCE_DIR}/CMakeLists.txt ${CMAKE_SOURCE_DIR}/tests/CMakeLists.txt ${CMAKE_SOURCE_DIR}/*.cmake ${CMAKE_SOURCE_DIR}/tests/*.cmake # ${CMAKE_SOURCE_DIR}/utils/*.sh # ${CMAKE_SOURCE_DIR}/*.spec # ${CMAKE_SOURCE_DIR}/debian/* # ${CMAKE_SOURCE_DIR}/debian/*/* # ${CMAKE_SOURCE_DIR}/doc/*.md ) option(DEVELOPER_MODE "enable developer checks" OFF) if(DEVELOPER_MODE) add_dependencies(checkers cstyle) add_dependencies(checkers check-whitespace) add_dependencies(checkers check-license) endif(DEVELOPER_MODE) function(uncompress file) execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ${CMAKE_SOURCE_DIR}/${file} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} RESULT_VARIABLE RET) if(RET) message(FATAL_ERROR "Couldn't uncompress ${file}") endif() endfunction() function(get_pmdk ver hash dstdir) set(pkg ${CMAKE_SOURCE_DIR}/${ver}.tar.gz) if (EXISTS ${pkg}) file(SHA256 ${pkg} pkg_hash) if (NOT ${pkg_hash} STREQUAL ${hash}) message(STATUS "Hash for version ${ver} doesn't match the expected value.") if (EXISTS ${CMAKE_SOURCE_DIR}/${dstdir}) message(STATUS "Removing ${CMAKE_SOURCE_DIR}/${dstdir}.") file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/${dstdir}) endif() message(STATUS "Removing ${pkg}.") file(REMOVE ${pkg}) endif() endif() if (NOT EXISTS ${pkg}) if (EXISTS ${CMAKE_SOURCE_DIR}/${dstdir}) message(STATUS "Removing ${CMAKE_SOURCE_DIR}/${dstdir}.") file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/${dstdir}) endif() message(STATUS "Downloading ${ver}.tar.gz") if (${ver} STREQUAL "1.0" OR ${ver} STREQUAL "1.1") file(DOWNLOAD https://github.com/pmem/pmdk/archive/${ver}.tar.gz ${CMAKE_SOURCE_DIR}/${ver}.tar.gz EXPECTED_HASH SHA256=${hash}) else() file(DOWNLOAD https://github.com/pmem/pmdk/releases/download/${ver}/pmdk-${ver}.tar.gz ${CMAKE_SOURCE_DIR}/${ver}.tar.gz EXPECTED_HASH SHA256=${hash}) endif() message(STATUS "Downloading ${ver}.tar.gz DONE") endif() if(NOT EXISTS ${CMAKE_SOURCE_DIR}/${dstdir}) message(STATUS "Uncompressing ${ver}.tar.gz") uncompress(${ver}.tar.gz) message(STATUS "Uncompressing ${ver}.tar.gz DONE") file(RENAME ${CMAKE_SOURCE_DIR}/pmdk-${ver} ${CMAKE_SOURCE_DIR}/${dstdir}) endif() endfunction() if(BUILD_CONVERT_V6) set(VER17 1.7) get_pmdk(${VER17} 865ce1b422bc83109cb4a63dcff8fd1077eea3617e668faf6a043208d8be03ca ${VER17}) function(build_libpmem_convert) set(LIBPMEM_SOURCES ${MAX_STABLE}/src/common/alloc.c ${MAX_STABLE}/src/common/file.c ${MAX_STABLE}/src/common/mmap.c ${MAX_STABLE}/src/common/out.c ${MAX_STABLE}/src/common/util.c ${MAX_STABLE}/src/libpmem/libpmem.c ${MAX_STABLE}/src/libpmem/memops_generic.c ${MAX_STABLE}/src/libpmem/pmem.c ) if (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL amd64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL AMD64) set(LIBPMEM_SOURCES ${LIBPMEM_SOURCES} ${MAX_STABLE}/src/libpmem/x86_64/init.c ${MAX_STABLE}/src/libpmem/x86_64/cpu.c ) elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) set(LIBPMEM_SOURCES ${LIBPMEM_SOURCES} ${MAX_STABLE}/src/libpmem/aarch64/init.c ) else() message(FATAL_ERROR "Unknown architecture ${CMAKE_SYSTEM_PROCESSOR}") endif() if(WIN32) set(LIBPMEM_SOURCES ${LIBPMEM_SOURCES} ${MAX_STABLE}/src/libpmem/libpmem_main.c ${MAX_STABLE}/src/libpmem/pmem_windows.c ${MAX_STABLE}/src/windows/win_mmap.c ${MAX_STABLE}/src/common/file_windows.c ${MAX_STABLE}/src/common/fs_windows.c ${MAX_STABLE}/src/common/mmap_windows.c ${MAX_STABLE}/src/common/os_auto_flush_windows.c ${MAX_STABLE}/src/common/os_deep_windows.c ${MAX_STABLE}/src/common/os_windows.c ${MAX_STABLE}/src/common/os_thread_windows.c ${MAX_STABLE}/src/common/util_windows.c ) else() set(LIBPMEM_SOURCES ${LIBPMEM_SOURCES} ${MAX_STABLE}/src/libpmem/pmem_posix.c ${MAX_STABLE}/src/common/file_posix.c ${MAX_STABLE}/src/common/fs_posix.c ${MAX_STABLE}/src/common/mmap_posix.c ${MAX_STABLE}/src/common/os_auto_flush_linux.c ${MAX_STABLE}/src/common/os_deep_linux.c ${MAX_STABLE}/src/common/os_posix.c ${MAX_STABLE}/src/common/os_thread_posix.c ${MAX_STABLE}/src/common/util_posix.c ) endif() if(MSVC) FILE(READ ${MAX_STABLE}/src/libpmem/libpmem.def DEFFILE) string(REPLACE "libpmem" "libpmem-convert" DEFFILE "${DEFFILE}") FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/libpmem.def "${DEFFILE}") add_library(libpmem-convert SHARED ${LIBPMEM_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/libpmem.def) target_link_libraries(libpmem-convert PRIVATE ntdll.lib) else() add_library(libpmem-convert SHARED ${LIBPMEM_SOURCES}) FILE(READ ${MAX_STABLE}/src/libpmem/libpmem.link.in LINKFILE) string(REPLACE "fault_injection;" "" LINKFILE "${LINKFILE}") FILE(WRITE ${MAX_STABLE}/src/libpmem/libpmem.link "${LINKFILE}") target_link_libraries(libpmem-convert PRIVATE -Wl,--version-script=${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmem/libpmem.link) endif() # remove lib prefix from library name set_target_properties(libpmem-convert PROPERTIES PREFIX "") target_compile_definitions(libpmem-convert PRIVATE SRCVERSION="${MAX_STABLE}") target_compile_definitions(libpmem-convert PRIVATE PMDK_UTF8_API) target_compile_definitions(libpmem-convert PRIVATE _PMEMOBJ_INTRNL) target_compile_definitions(libpmem-convert PRIVATE SSE2_AVAILABLE=0) target_compile_definitions(libpmem-convert PRIVATE AVX_AVAILABLE=0) target_compile_definitions(libpmem-convert PRIVATE AVX512F_AVAILABLE=0) target_include_directories(libpmem-convert PRIVATE ${MAX_STABLE}/src/include) target_include_directories(libpmem-convert PRIVATE ${MAX_STABLE}/src/common) target_include_directories(libpmem-convert PRIVATE ${MAX_STABLE}/src/libpmem) if(MSVC) target_include_directories(libpmem-convert PRIVATE ${MAX_STABLE}/src/windows/include/) target_include_directories(libpmem-convert PRIVATE include/) target_compile_options(libpmem-convert PRIVATE /FI"${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/windows/include/platform.h") endif() target_link_libraries(libpmem-convert PRIVATE ${CMAKE_THREAD_LIBS_INIT}) endfunction(build_libpmem_convert) build_libpmem_convert() set(PMEM_INCLUDE_DIRS ${MAX_STABLE}/src/include) set(PMEM_LIBRARIES libpmem-convert) install(TARGETS libpmem-convert DESTINATION ${CMAKE_INSTALL_LIBDIR}/pmdk-convert/) function(build_libpmempool_convert) set(LIBPMEMPOOL_SOURCES ${MAX_STABLE}/src/libpmempool/check_backup.c ${MAX_STABLE}/src/libpmempool/check_bad_blocks.c ${MAX_STABLE}/src/libpmempool/check_blk.c ${MAX_STABLE}/src/libpmempool/check_btt_info.c ${MAX_STABLE}/src/libpmempool/check_btt_map_flog.c ${MAX_STABLE}/src/libpmempool/check.c ${MAX_STABLE}/src/libpmempool/check_log.c ${MAX_STABLE}/src/libpmempool/check_pool_hdr.c ${MAX_STABLE}/src/libpmempool/check_sds.c ${MAX_STABLE}/src/libpmempool/check_util.c ${MAX_STABLE}/src/libpmempool/check_write.c ${MAX_STABLE}/src/libpmempool/feature.c ${MAX_STABLE}/src/libpmempool/libpmempool.c ${MAX_STABLE}/src/libpmempool/pool.c ${MAX_STABLE}/src/libpmempool/replica.c ${MAX_STABLE}/src/libpmempool/rm.c ${MAX_STABLE}/src/libpmempool/sync.c ${MAX_STABLE}/src/libpmempool/transform.c ${MAX_STABLE}/src/libpmemblk/btt.c ${MAX_STABLE}/src/common/alloc.c ${MAX_STABLE}/src/common/badblock.c ${MAX_STABLE}/src/common/file.c ${MAX_STABLE}/src/common/mmap.c ${MAX_STABLE}/src/common/pool_hdr.c ${MAX_STABLE}/src/common/out.c ${MAX_STABLE}/src/common/os_dimm_none.c ${MAX_STABLE}/src/common/set.c ${MAX_STABLE}/src/common/shutdown_state.c ${MAX_STABLE}/src/common/util.c ${MAX_STABLE}/src/common/uuid.c ) if(WIN32) set(LIBPMEMPOOL_SOURCES ${LIBPMEMPOOL_SOURCES} ${MAX_STABLE}/src/libpmempool/libpmempool_main.c ${MAX_STABLE}/src/common/badblock_none.c ${MAX_STABLE}/src/common/file_windows.c ${MAX_STABLE}/src/common/fs_windows.c ${MAX_STABLE}/src/common/mmap_windows.c ${MAX_STABLE}/src/common/os_deep_windows.c ${MAX_STABLE}/src/common/os_thread_windows.c ${MAX_STABLE}/src/common/os_windows.c ${MAX_STABLE}/src/common/util_windows.c ${MAX_STABLE}/src/common/uuid_windows.c ) else() set(LIBPMEMPOOL_SOURCES ${LIBPMEMPOOL_SOURCES} ${MAX_STABLE}/src/common/badblock_ndctl.c ${MAX_STABLE}/src/common/extent_linux.c ${MAX_STABLE}/src/common/file_posix.c ${MAX_STABLE}/src/common/fs_posix.c ${MAX_STABLE}/src/common/mmap_posix.c ${MAX_STABLE}/src/common/os_deep_linux.c ${MAX_STABLE}/src/common/os_posix.c ${MAX_STABLE}/src/common/os_thread_posix.c ${MAX_STABLE}/src/common/util_posix.c ${MAX_STABLE}/src/common/uuid_linux.c ) endif() if(MSVC) FILE(READ ${MAX_STABLE}/src/libpmempool/libpmempool.def DEFFILE) string(REPLACE "libpmempool" "libpmempool-convert" DEFFILE "${DEFFILE}") FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/libpmempool.def "${DEFFILE}") add_library(libpmempool-convert SHARED ${LIBPMEMPOOL_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/libpmempool.def) else() FILE(READ ${MAX_STABLE}/src/libpmempool/libpmempool.link.in LINKFILE) string(REPLACE "fault_injection;" "" LINKFILE "${LINKFILE}") FILE(WRITE ${MAX_STABLE}/src/libpmempool/libpmempool.link "${LINKFILE}") add_library(libpmempool-convert SHARED ${LIBPMEMPOOL_SOURCES}) target_link_libraries(libpmempool-convert PRIVATE -Wl,--version-script=${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmempool/libpmempool.link) endif() target_link_libraries(libpmempool-convert PRIVATE libpmem-convert) target_compile_definitions(libpmempool-convert PRIVATE SRCVERSION="${MAX_STABLE}") target_compile_definitions(libpmempool-convert PRIVATE PMDK_UTF8_API) target_include_directories(libpmempool-convert PRIVATE ${MAX_STABLE}/src/include) target_include_directories(libpmempool-convert PRIVATE ${MAX_STABLE}/src/common) target_include_directories(libpmempool-convert PRIVATE ${MAX_STABLE}/src/libpmempool) target_include_directories(libpmempool-convert PRIVATE ${MAX_STABLE}/src/libpmemblk) target_include_directories(libpmempool-convert PRIVATE ${MAX_STABLE}/src/libpmemlog) target_include_directories(libpmempool-convert PRIVATE ${MAX_STABLE}/src/libpmemobj) if(MSVC) target_include_directories(libpmempool-convert PRIVATE ${MAX_STABLE}/src/windows/include/) target_include_directories(libpmempool-convert PRIVATE include/) target_compile_options(libpmempool-convert PRIVATE /FI"${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/windows/include/platform.h") endif() target_link_libraries(libpmempool-convert PRIVATE ${CMAKE_THREAD_LIBS_INIT}) endfunction(build_libpmempool_convert) build_libpmempool_convert() set(LIBPMEMPOOL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/include) set(LIBPMEMPOOL_LIBRARIES libpmempool-convert) set(SOURCES_17 ${VER17}/src/libpmemobj/alloc_class.c ${VER17}/src/libpmemobj/bucket.c ${VER17}/src/libpmemobj/critnib.c ${VER17}/src/libpmemobj/ctl_debug.c ${VER17}/src/libpmemobj/container_ravl.c ${VER17}/src/libpmemobj/container_seglists.c ${VER17}/src/libpmemobj/heap.c ${VER17}/src/libpmemobj/lane.c ${VER17}/src/libpmemobj/libpmemobj.c ${VER17}/src/libpmemobj/list.c ${VER17}/src/libpmemobj/memblock.c ${VER17}/src/libpmemobj/memops.c ${VER17}/src/libpmemobj/obj.c ${VER17}/src/libpmemobj/palloc.c ${VER17}/src/libpmemobj/pmalloc.c ${VER17}/src/libpmemobj/ravl.c ${VER17}/src/libpmemobj/recycler.c ${VER17}/src/libpmemobj/stats.c ${VER17}/src/libpmemobj/sync.c ${VER17}/src/libpmemobj/tx.c ${VER17}/src/libpmemobj/ulog.c ${VER17}/src/common/alloc.c ${VER17}/src/common/badblock.c ${VER17}/src/common/ctl.c ${VER17}/src/common/ctl_cow.c ${VER17}/src/common/ctl_fallocate.c ${VER17}/src/common/ctl_prefault.c ${VER17}/src/common/ctl_sds.c ${VER17}/src/common/file.c ${VER17}/src/common/mmap.c ${VER17}/src/common/os_dimm_none.c ${VER17}/src/common/out.c ${VER17}/src/common/pool_hdr.c ${VER17}/src/common/set.c ${VER17}/src/common/shutdown_state.c ${VER17}/src/common/util.c ${VER17}/src/common/uuid.c ) if(WIN32) set(SOURCES_17 ${SOURCES_17} ${VER17}/src/libpmemobj/libpmemobj_main.c ${VER17}/src/common/badblock_none.c ${VER17}/src/common/file_windows.c ${VER17}/src/common/fs_windows.c ${VER17}/src/common/mmap_windows.c ${VER17}/src/common/os_deep_windows.c ${VER17}/src/common/os_windows.c ${VER17}/src/common/os_thread_windows.c ${VER17}/src/common/util_windows.c ${VER17}/src/common/uuid_windows.c ) else() set(SOURCES_17 ${SOURCES_17} ${VER17}/src/common/badblock_ndctl.c ${VER17}/src/common/extent_linux.c ${VER17}/src/common/file_posix.c ${VER17}/src/common/fs_posix.c ${VER17}/src/common/mmap_posix.c ${VER17}/src/common/os_deep_linux.c ${VER17}/src/common/os_posix.c ${VER17}/src/common/os_thread_posix.c ${VER17}/src/common/util_posix.c ${VER17}/src/common/uuid_linux.c ) endif() function(build_convert_v6) if(WIN32) set(CONVERT_V6_SOURCES ${VER17}/src/windows/getopt/getopt.c) endif() add_library(pmemobj_convert_v6_o OBJECT ${SOURCES_17} ${CONVERT_V6_SOURCES} pmemobj_convert_v6.c ${VER17}/src/libpmemblk/btt.c ${VER17}/src/tools/pmempool/common.c ${VER17}/src/tools/pmempool/output.c) target_compile_definitions(pmemobj_convert_v6_o PRIVATE SRCVERSION="${VER17}") target_compile_definitions(pmemobj_convert_v6_o PRIVATE PMDK_UTF8_API) target_compile_definitions(pmemobj_convert_v6_o PRIVATE _PMEMOBJ_INTRNL) target_include_directories(pmemobj_convert_v6_o PRIVATE ${VER17}/src/include) target_include_directories(pmemobj_convert_v6_o PRIVATE ${VER17}/src/libpmemobj) target_include_directories(pmemobj_convert_v6_o PRIVATE ${VER17}/src/libpmemlog) target_include_directories(pmemobj_convert_v6_o PRIVATE ${VER17}/src/libpmemblk) target_include_directories(pmemobj_convert_v6_o PRIVATE ${VER17}/src/common) target_include_directories(pmemobj_convert_v6_o PRIVATE ${PMEM_INCLUDE_DIRS}) if(MSVC) target_include_directories(pmemobj_convert_v6_o PRIVATE ${VER17}/src/windows/include/) target_include_directories(pmemobj_convert_v6_o PRIVATE ${VER17}/src/windows/getopt/) target_include_directories(pmemobj_convert_v6_o PRIVATE include/) target_compile_options(pmemobj_convert_v6_o PRIVATE /FI"${CMAKE_SOURCE_DIR}/${VER17}/src/windows/include/platform.h") endif() if(MSVC) add_library(pmemobj_convert_v6_shared SHARED $ ${CMAKE_CURRENT_SOURCE_DIR}/pmemobj_convert_v6.def) else() add_library(pmemobj_convert_v6_shared SHARED $) target_link_libraries(pmemobj_convert_v6_shared PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/pmemobj_convert.map) endif() target_link_libraries(pmemobj_convert_v6_shared PRIVATE libpmem-convert) target_link_libraries(pmemobj_convert_v6_shared PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries(pmemobj_convert_v6_shared PRIVATE ${CMAKE_THREAD_LIBS_INIT}) if(NOT MSVC) # strip unneeded symbols, requires -fdata-sections -ffunction-sections target_link_libraries(pmemobj_convert_v6_shared PRIVATE -Wl,--gc-sections) endif() set_target_properties(pmemobj_convert_v6_shared PROPERTIES OUTPUT_NAME pmemobj_convert_v6) # remove lib prefix from library name set_target_properties(pmemobj_convert_v6_shared PROPERTIES PREFIX "") endfunction(build_convert_v6) build_convert_v6() install(TARGETS pmemobj_convert_v6_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}/pmdk-convert/) function(build_libpmemobj_17) if(MSVC) FILE(READ ${VER17}/src/libpmemobj/libpmemobj.def DEFFILE) string(REPLACE "libpmemobj" "pmemobj_17" DEFFILE "${DEFFILE}") FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pmemobj_17.def "${DEFFILE}") add_library(pmemobj_17 SHARED ${SOURCES_17} ${CMAKE_CURRENT_BINARY_DIR}/pmemobj_17.def) target_compile_options(pmemobj_17 PRIVATE /FI"${CMAKE_SOURCE_DIR}/${VER17}/src/windows/include/platform.h") else() add_library(pmemobj_17 SHARED ${SOURCES_17}) disable_optimization(pmemobj_17) endif() target_compile_definitions(pmemobj_17 PRIVATE SRCVERSION="${VER17}") target_compile_definitions(pmemobj_17 PRIVATE PMDK_UTF8_API) target_compile_definitions(pmemobj_17 PRIVATE _PMEMOBJ_INTRNL) target_include_directories(pmemobj_17 PRIVATE ${VER17}/src/include) target_include_directories(pmemobj_17 PRIVATE ${VER17}/src/libpmemobj) target_include_directories(pmemobj_17 PRIVATE ${VER17}/src/common) target_include_directories(pmemobj_17 PRIVATE ${PMEM_INCLUDE_DIRS}) if(WIN32) target_include_directories(pmemobj_17 PRIVATE ${VER17}/src/windows/include/) target_include_directories(pmemobj_17 PRIVATE include/) endif() target_link_libraries(pmemobj_17 PRIVATE libpmem-convert) target_link_libraries(pmemobj_17 PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries(pmemobj_17 PRIVATE ${CMAKE_THREAD_LIBS_INIT}) if(NOT MSVC) FILE(READ ${VER17}/src/libpmemobj/libpmemobj.link.in LINKFILE) string(REPLACE "fault_injection;" "" LINKFILE "${LINKFILE}") FILE(WRITE ${VER17}/src/libpmemobj/libpmemobj.link "${LINKFILE}") target_link_libraries(pmemobj_17 PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/${VER17}/src/libpmemobj/libpmemobj.link) endif() endfunction(build_libpmemobj_17) build_libpmemobj_17() endif(BUILD_CONVERT_V6) # convert V5 and PMDK 1.6 if(BUILD_CONVERT_V5) set(VER16 1.6.1) get_pmdk(${VER16} f263c8301f86ddf8bc5e020909ac52350baedba5c169a1a3a7786df64f129446 ${VER16}) set(SOURCES_16 ${VER16}/src/libpmemobj/alloc_class.c ${VER16}/src/libpmemobj/bucket.c ${VER16}/src/libpmemobj/critnib.c ${VER16}/src/libpmemobj/ctl_debug.c ${VER16}/src/libpmemobj/container_ravl.c ${VER16}/src/libpmemobj/container_seglists.c ${VER16}/src/libpmemobj/heap.c ${VER16}/src/libpmemobj/lane.c ${VER16}/src/libpmemobj/libpmemobj.c ${VER16}/src/libpmemobj/list.c ${VER16}/src/libpmemobj/memblock.c ${VER16}/src/libpmemobj/memops.c ${VER16}/src/libpmemobj/obj.c ${VER16}/src/libpmemobj/palloc.c ${VER16}/src/libpmemobj/pmalloc.c ${VER16}/src/libpmemobj/ravl.c ${VER16}/src/libpmemobj/recycler.c ${VER16}/src/libpmemobj/stats.c ${VER16}/src/libpmemobj/sync.c ${VER16}/src/libpmemobj/tx.c ${VER16}/src/libpmemobj/ulog.c ${VER16}/src/common/alloc.c ${VER16}/src/common/badblock.c ${VER16}/src/common/ctl.c ${VER16}/src/common/ctl_cow.c ${VER16}/src/common/ctl_fallocate.c ${VER16}/src/common/ctl_prefault.c ${VER16}/src/common/ctl_sds.c ${VER16}/src/common/file.c ${VER16}/src/common/mmap.c ${VER16}/src/common/os_dimm_none.c ${VER16}/src/common/out.c ${VER16}/src/common/pool_hdr.c ${VER16}/src/common/set.c ${VER16}/src/common/shutdown_state.c ${VER16}/src/common/util.c ${VER16}/src/common/uuid.c ) if(WIN32) set(SOURCES_16 ${SOURCES_16} ${VER16}/src/libpmemobj/libpmemobj_main.c ${VER16}/src/common/badblock_none.c ${VER16}/src/common/file_windows.c ${VER16}/src/common/fs_windows.c ${VER16}/src/common/mmap_windows.c ${VER16}/src/common/os_deep_windows.c ${VER16}/src/common/os_windows.c ${VER16}/src/common/os_thread_windows.c ${VER16}/src/common/util_windows.c ${VER16}/src/common/uuid_windows.c ) else() set(SOURCES_16 ${SOURCES_16} ${VER16}/src/common/badblock_ndctl.c ${VER16}/src/common/extent_linux.c ${VER16}/src/common/file_posix.c ${VER16}/src/common/fs_posix.c ${VER16}/src/common/mmap_posix.c ${VER16}/src/common/os_deep_linux.c ${VER16}/src/common/os_posix.c ${VER16}/src/common/os_thread_posix.c ${VER16}/src/common/util_posix.c ${VER16}/src/common/uuid_linux.c ) endif() function(build_convert_v5) if(WIN32) set(CONVERT_V5_SOURCES ${VER16}/src/windows/getopt/getopt.c) endif() add_library(pmemobj_convert_v5_o OBJECT ${SOURCES_16} ${CONVERT_V5_SOURCES} pmemobj_convert_v5.c ${VER16}/src/libpmemblk/btt.c ${VER16}/src/tools/pmempool/common.c ${VER16}/src/tools/pmempool/output.c) target_compile_definitions(pmemobj_convert_v5_o PRIVATE SRCVERSION="${VER16}") target_compile_definitions(pmemobj_convert_v5_o PRIVATE PMDK_UTF8_API) target_compile_definitions(pmemobj_convert_v5_o PRIVATE _PMEMOBJ_INTRNL) target_include_directories(pmemobj_convert_v5_o PRIVATE ${VER16}/src/include) target_include_directories(pmemobj_convert_v5_o PRIVATE ${VER16}/src/libpmemobj) target_include_directories(pmemobj_convert_v5_o PRIVATE ${VER16}/src/libpmemlog) target_include_directories(pmemobj_convert_v5_o PRIVATE ${VER16}/src/libpmemblk) target_include_directories(pmemobj_convert_v5_o PRIVATE ${VER16}/src/common) target_include_directories(pmemobj_convert_v5_o PRIVATE ${VER16}/src/tools/pmempool) target_include_directories(pmemobj_convert_v5_o PRIVATE ${PMEM_INCLUDE_DIRS}) if(MSVC) target_include_directories(pmemobj_convert_v5_o PRIVATE ${VER16}/src/windows/include/) target_include_directories(pmemobj_convert_v5_o PRIVATE ${VER16}/src/windows/getopt/) target_include_directories(pmemobj_convert_v5_o PRIVATE include/) target_compile_options(pmemobj_convert_v5_o PRIVATE /FI"${CMAKE_SOURCE_DIR}/${VER16}/src/windows/include/platform.h") endif() if(MSVC) add_library(pmemobj_convert_v5_shared SHARED $ ${CMAKE_CURRENT_SOURCE_DIR}/pmemobj_convert_v5.def) else() add_library(pmemobj_convert_v5_shared SHARED $) target_link_libraries(pmemobj_convert_v5_shared PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/pmemobj_convert.map) endif() target_link_libraries(pmemobj_convert_v5_shared PRIVATE libpmem-convert) target_link_libraries(pmemobj_convert_v5_shared PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries(pmemobj_convert_v5_shared PRIVATE ${CMAKE_THREAD_LIBS_INIT}) if(NOT MSVC) # strip unneeded symbols, requires -fdata-sections -ffunction-sections target_link_libraries(pmemobj_convert_v5_shared PRIVATE -Wl,--gc-sections) endif() set_target_properties(pmemobj_convert_v5_shared PROPERTIES OUTPUT_NAME pmemobj_convert_v5) # remove lib prefix from library name set_target_properties(pmemobj_convert_v5_shared PROPERTIES PREFIX "") endfunction(build_convert_v5) build_convert_v5() install(TARGETS pmemobj_convert_v5_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}/pmdk-convert/) function(build_libpmemobj_16) if(MSVC) FILE(READ ${VER16}/src/libpmemobj/libpmemobj.def DEFFILE) string(REPLACE "libpmemobj" "pmemobj_16" DEFFILE "${DEFFILE}") FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pmemobj_16.def "${DEFFILE}") add_library(pmemobj_16 SHARED ${SOURCES_16} ${CMAKE_CURRENT_BINARY_DIR}/pmemobj_16.def) target_compile_options(pmemobj_16 PRIVATE /FI"${CMAKE_SOURCE_DIR}/${VER16}/src/windows/include/platform.h") else() add_library(pmemobj_16 SHARED ${SOURCES_16}) disable_optimization(pmemobj_16) endif() target_compile_definitions(pmemobj_16 PRIVATE SRCVERSION="${VER16}") target_compile_definitions(pmemobj_16 PRIVATE PMDK_UTF8_API) target_compile_definitions(pmemobj_16 PRIVATE _PMEMOBJ_INTRNL) target_include_directories(pmemobj_16 PRIVATE ${VER16}/src/include) target_include_directories(pmemobj_16 PRIVATE ${VER16}/src/libpmemobj) target_include_directories(pmemobj_16 PRIVATE ${VER16}/src/common) target_include_directories(pmemobj_16 PRIVATE ${PMEM_INCLUDE_DIRS}) if(WIN32) target_include_directories(pmemobj_16 PRIVATE ${VER16}/src/windows/include/) target_include_directories(pmemobj_16 PRIVATE include/) endif() target_link_libraries(pmemobj_16 PRIVATE libpmem-convert) target_link_libraries(pmemobj_16 PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries(pmemobj_16 PRIVATE ${CMAKE_THREAD_LIBS_INIT}) if(NOT MSVC) FILE(READ ${VER16}/src/libpmemobj/libpmemobj.link.in LINKFILE) string(REPLACE "fault_injection;" "" LINKFILE "${LINKFILE}") FILE(WRITE ${VER16}/src/libpmemobj/libpmemobj.link "${LINKFILE}") target_link_libraries(pmemobj_16 PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/${VER16}/src/libpmemobj/libpmemobj.link) endif() endfunction(build_libpmemobj_16) build_libpmemobj_16() endif(BUILD_CONVERT_V5) ###################################################### 1.5 if(BUILD_15) set(VER15 1.5.2) get_pmdk(${VER15} a72691971a98b8472b26271f19d69e6c9b849c1ca42124ea2e2bd8c3fcdff1b1 ${VER15}) set(SOURCES_15 ${VER15}/src/libpmemobj/alloc_class.c ${VER15}/src/libpmemobj/bucket.c ${VER15}/src/libpmemobj/ctl_debug.c ${VER15}/src/libpmemobj/container_ravl.c ${VER15}/src/libpmemobj/container_seglists.c ${VER15}/src/libpmemobj/cuckoo.c ${VER15}/src/libpmemobj/heap.c ${VER15}/src/libpmemobj/lane.c ${VER15}/src/libpmemobj/libpmemobj.c ${VER15}/src/libpmemobj/list.c ${VER15}/src/libpmemobj/memblock.c ${VER15}/src/libpmemobj/memops.c ${VER15}/src/libpmemobj/obj.c ${VER15}/src/libpmemobj/palloc.c ${VER15}/src/libpmemobj/pmalloc.c ${VER15}/src/libpmemobj/ravl.c ${VER15}/src/libpmemobj/recycler.c ${VER15}/src/libpmemobj/stats.c ${VER15}/src/libpmemobj/sync.c ${VER15}/src/libpmemobj/tx.c ${VER15}/src/libpmemobj/ulog.c ${VER15}/src/common/badblock.c ${VER15}/src/common/ctl.c ${VER15}/src/common/ctl_prefault.c ${VER15}/src/common/ctl_sds.c ${VER15}/src/common/file.c ${VER15}/src/common/mmap.c ${VER15}/src/common/os_dimm_none.c ${VER15}/src/common/out.c ${VER15}/src/common/pool_hdr.c ${VER15}/src/common/set.c ${VER15}/src/common/shutdown_state.c ${VER15}/src/common/util.c ${VER15}/src/common/uuid.c ) if(WIN32) set(SOURCES_15 ${SOURCES_15} ${VER15}/src/libpmemobj/libpmemobj_main.c ${VER15}/src/common/badblock_none.c ${VER15}/src/common/file_windows.c ${VER15}/src/common/fs_windows.c ${VER15}/src/common/mmap_windows.c ${VER15}/src/common/os_deep_windows.c ${VER15}/src/common/os_windows.c ${VER15}/src/common/os_thread_windows.c ${VER15}/src/common/util_windows.c ${VER15}/src/common/uuid_windows.c ) else() set(SOURCES_15 ${SOURCES_15} ${VER15}/src/common/badblock_ndctl.c ${VER15}/src/common/extent_linux.c ${VER15}/src/common/file_posix.c ${VER15}/src/common/fs_posix.c ${VER15}/src/common/mmap_posix.c ${VER15}/src/common/os_deep_linux.c ${VER15}/src/common/os_posix.c ${VER15}/src/common/os_thread_posix.c ${VER15}/src/common/util_posix.c ${VER15}/src/common/uuid_linux.c ) endif() function(build_libpmemobj_15) if(MSVC) FILE(READ ${VER15}/src/libpmemobj/libpmemobj.def DEFFILE) string(REPLACE "libpmemobj" "pmemobj_15" DEFFILE "${DEFFILE}") FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pmemobj_15.def "${DEFFILE}") add_library(pmemobj_15 SHARED ${SOURCES_15} ${CMAKE_CURRENT_BINARY_DIR}/pmemobj_15.def) target_compile_options(pmemobj_15 PRIVATE /FI"${CMAKE_SOURCE_DIR}/${VER15}/src/windows/include/platform.h") else() add_library(pmemobj_15 SHARED ${SOURCES_15}) disable_optimization(pmemobj_15) endif() target_compile_definitions(pmemobj_15 PRIVATE SRCVERSION="${VER15}") target_compile_definitions(pmemobj_15 PRIVATE PMDK_UTF8_API) target_compile_definitions(pmemobj_15 PRIVATE _PMEMOBJ_INTRNL) target_include_directories(pmemobj_15 PRIVATE ${VER15}/src/include) target_include_directories(pmemobj_15 PRIVATE ${VER15}/src/libpmemobj) target_include_directories(pmemobj_15 PRIVATE ${VER15}/src/common) target_include_directories(pmemobj_15 PRIVATE ${PMEM_INCLUDE_DIRS}) if(WIN32) target_include_directories(pmemobj_15 PRIVATE ${VER15}/src/windows/include/) target_include_directories(pmemobj_15 PRIVATE include/) endif() target_link_libraries(pmemobj_15 PRIVATE libpmem-convert) target_link_libraries(pmemobj_15 PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries(pmemobj_15 PRIVATE ${CMAKE_THREAD_LIBS_INIT}) if(NOT MSVC) target_link_libraries(pmemobj_15 PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/${VER15}/src/libpmemobj/libpmemobj.map) endif() endfunction(build_libpmemobj_15) build_libpmemobj_15() endif() ###################################################### 1.4 if(BUILD_CONVERT_V4) set(VER14 1.4.3) get_pmdk(${VER14} 93a8ba7383fa02dfd176d50aff56ace6bbac86bbaf26b8b1949ee703a4ec3a31 ${VER14}) set(SOURCES_14 ${VER14}/src/libpmemobj/alloc_class.c ${VER14}/src/libpmemobj/bucket.c ${VER14}/src/libpmemobj/container_ravl.c ${VER14}/src/libpmemobj/container_seglists.c ${VER14}/src/libpmemobj/ctl.c ${VER14}/src/libpmemobj/ctl_global.c ${VER14}/src/libpmemobj/cuckoo.c ${VER14}/src/libpmemobj/heap.c ${VER14}/src/libpmemobj/lane.c ${VER14}/src/libpmemobj/libpmemobj.c ${VER14}/src/libpmemobj/list.c ${VER14}/src/libpmemobj/memblock.c ${VER14}/src/libpmemobj/memops.c ${VER14}/src/libpmemobj/obj.c ${VER14}/src/libpmemobj/palloc.c ${VER14}/src/libpmemobj/pmalloc.c ${VER14}/src/libpmemobj/pvector.c ${VER14}/src/libpmemobj/ravl.c ${VER14}/src/libpmemobj/recycler.c ${VER14}/src/libpmemobj/redo.c ${VER14}/src/libpmemobj/ringbuf.c ${VER14}/src/libpmemobj/stats.c ${VER14}/src/libpmemobj/sync.c ${VER14}/src/libpmemobj/tx.c ${VER14}/src/common/file.c ${VER14}/src/common/mmap.c ${VER14}/src/common/os_dimm_none.c ${VER14}/src/common/out.c ${VER14}/src/common/pool_hdr.c ${VER14}/src/common/set.c ${VER14}/src/common/shutdown_state.c ${VER14}/src/common/util.c ${VER14}/src/common/uuid.c ) if(WIN32) set(SOURCES_14 ${SOURCES_14} ${VER14}/src/libpmemobj/libpmemobj_main.c ${VER14}/src/common/file_windows.c ${VER14}/src/common/fs_windows.c ${VER14}/src/common/mmap_windows.c ${VER14}/src/common/os_deep_windows.c ${VER14}/src/common/os_windows.c ${VER14}/src/common/os_thread_windows.c ${VER14}/src/common/util_windows.c ${VER14}/src/common/uuid_windows.c ) else() set(SOURCES_14 ${SOURCES_14} ${VER14}/src/common/file_posix.c ${VER14}/src/common/fs_posix.c ${VER14}/src/common/mmap_posix.c ${VER14}/src/common/os_deep_linux.c ${VER14}/src/common/os_posix.c ${VER14}/src/common/os_thread_posix.c ${VER14}/src/common/util_posix.c ${VER14}/src/common/uuid_linux.c ) endif() if(WIN32) set(CONVERT_V4_SOURCES ${VER14}/src/windows/getopt/getopt.c) endif() function(build_convert_v4) add_library(pmemobj_convert_v4_o OBJECT ${SOURCES_14} ${CONVERT_V4_SOURCES} pmemobj_convert_v4.c ${VER14}/src/libpmemblk/btt.c ${VER14}/src/tools/pmempool/common.c ${VER14}/src/tools/pmempool/output.c) target_compile_definitions(pmemobj_convert_v4_o PRIVATE SRCVERSION="${VER14}") target_compile_definitions(pmemobj_convert_v4_o PRIVATE PMDK_UTF8_API) target_compile_definitions(pmemobj_convert_v4_o PRIVATE _PMEMOBJ_INTRNL) target_include_directories(pmemobj_convert_v4_o PRIVATE ${VER14}/src/include) target_include_directories(pmemobj_convert_v4_o PRIVATE ${VER14}/src/libpmemobj) target_include_directories(pmemobj_convert_v4_o PRIVATE ${VER14}/src/libpmemlog) target_include_directories(pmemobj_convert_v4_o PRIVATE ${VER14}/src/libpmemblk) target_include_directories(pmemobj_convert_v4_o PRIVATE ${VER14}/src/libpmemcto) target_include_directories(pmemobj_convert_v4_o PRIVATE ${VER14}/src/common) target_include_directories(pmemobj_convert_v4_o PRIVATE ${VER14}/src/tools/pmempool) target_include_directories(pmemobj_convert_v4_o PRIVATE ${PMEM_INCLUDE_DIRS}) if(MSVC) target_include_directories(pmemobj_convert_v4_o PRIVATE ${VER14}/src/windows/include/) target_include_directories(pmemobj_convert_v4_o PRIVATE ${VER14}/src/windows/getopt/) target_include_directories(pmemobj_convert_v4_o PRIVATE include/) target_compile_options(pmemobj_convert_v4_o PRIVATE /FI"${CMAKE_SOURCE_DIR}/${VER14}/src/windows/include/platform.h") endif() if(MSVC) add_library(pmemobj_convert_v4_shared SHARED $ ${CMAKE_CURRENT_SOURCE_DIR}/pmemobj_convert_v4.def) else() add_library(pmemobj_convert_v4_shared SHARED $) target_link_libraries(pmemobj_convert_v4_shared PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/pmemobj_convert.map) endif() target_link_libraries(pmemobj_convert_v4_shared PRIVATE libpmem-convert) target_link_libraries(pmemobj_convert_v4_shared PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries(pmemobj_convert_v4_shared PRIVATE ${CMAKE_THREAD_LIBS_INIT}) if(NOT MSVC) # strip unneeded symbols, requires -fdata-sections -ffunction-sections target_link_libraries(pmemobj_convert_v4_shared PRIVATE -Wl,--gc-sections) endif() set_target_properties(pmemobj_convert_v4_shared PROPERTIES OUTPUT_NAME pmemobj_convert_v4) # remove lib prefix from library name set_target_properties(pmemobj_convert_v4_shared PROPERTIES PREFIX "") endfunction(build_convert_v4) build_convert_v4() install(TARGETS pmemobj_convert_v4_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}/pmdk-convert/) function(build_libpmemobj_14) if(MSVC) FILE(READ ${VER14}/src/libpmemobj/libpmemobj.def DEFFILE) string(REPLACE "libpmemobj" "pmemobj_14" DEFFILE "${DEFFILE}") FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pmemobj_14.def "${DEFFILE}") add_library(pmemobj_14 SHARED ${SOURCES_14} ${CMAKE_CURRENT_BINARY_DIR}/pmemobj_14.def) target_compile_options(pmemobj_14 PRIVATE /FI"${CMAKE_SOURCE_DIR}/${VER14}/src/windows/include/platform.h") else() add_library(pmemobj_14 SHARED ${SOURCES_14}) disable_optimization(pmemobj_14) endif() target_compile_definitions(pmemobj_14 PRIVATE SRCVERSION="${VER14}") target_compile_definitions(pmemobj_14 PRIVATE PMDK_UTF8_API) target_compile_definitions(pmemobj_14 PRIVATE _PMEMOBJ_INTRNL) target_include_directories(pmemobj_14 PRIVATE ${VER14}/src/include) target_include_directories(pmemobj_14 PRIVATE ${VER14}/src/libpmemobj) target_include_directories(pmemobj_14 PRIVATE ${VER14}/src/common) target_include_directories(pmemobj_14 PRIVATE ${PMEM_INCLUDE_DIRS}) if(WIN32) target_include_directories(pmemobj_14 PRIVATE ${VER14}/src/windows/include/) target_include_directories(pmemobj_14 PRIVATE include/) endif() target_link_libraries(pmemobj_14 PRIVATE libpmem-convert) target_link_libraries(pmemobj_14 PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries(pmemobj_14 PRIVATE ${CMAKE_THREAD_LIBS_INIT}) if(NOT MSVC) target_link_libraries(pmemobj_14 PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/${VER14}/src/libpmemobj/libpmemobj.map) endif() endfunction(build_libpmemobj_14) build_libpmemobj_14() endif(BUILD_CONVERT_V4) ###################################################### 1.3 (tests only) if(BUILD_13) set(VER13 1.3.3) get_pmdk(${VER13} 5d46497bb151e6a36e801aed45bfef0d068c55cb2267329053e7489e01742f47 ${VER13}) set(SOURCES_13 ${VER13}/src/libpmemobj/alloc_class.c ${VER13}/src/libpmemobj/bucket.c ${VER13}/src/libpmemobj/container_ctree.c ${VER13}/src/libpmemobj/container_seglists.c ${VER13}/src/libpmemobj/ctl.c ${VER13}/src/libpmemobj/ctl_global.c ${VER13}/src/libpmemobj/ctree.c ${VER13}/src/libpmemobj/cuckoo.c ${VER13}/src/libpmemobj/heap.c ${VER13}/src/libpmemobj/lane.c ${VER13}/src/libpmemobj/libpmemobj.c ${VER13}/src/libpmemobj/list.c ${VER13}/src/libpmemobj/memblock.c ${VER13}/src/libpmemobj/memops.c ${VER13}/src/libpmemobj/obj.c ${VER13}/src/libpmemobj/palloc.c ${VER13}/src/libpmemobj/pmalloc.c ${VER13}/src/libpmemobj/pvector.c ${VER13}/src/libpmemobj/recycler.c ${VER13}/src/libpmemobj/redo.c ${VER13}/src/libpmemobj/ringbuf.c ${VER13}/src/libpmemobj/sync.c ${VER13}/src/libpmemobj/tx.c ${VER13}/src/common/file.c ${VER13}/src/common/mmap.c ${VER13}/src/common/out.c ${VER13}/src/common/pool_hdr.c ${VER13}/src/common/set.c ${VER13}/src/common/util.c ${VER13}/src/common/uuid.c ) if(WIN32) set(SOURCES_13 ${SOURCES_13} ${VER13}/src/libpmemobj/libpmemobj_main.c ${VER13}/src/common/file_windows.c ${VER13}/src/common/mmap_windows.c ${VER13}/src/common/os_windows.c ${VER13}/src/common/os_thread_windows.c ${VER13}/src/common/pool_hdr_windows.c ${VER13}/src/common/util_windows.c ${VER13}/src/common/uuid_windows.c ) else() set(SOURCES_13 ${SOURCES_13} ${VER13}/src/common/file_linux.c ${VER13}/src/common/mmap_linux.c ${VER13}/src/common/os_linux.c ${VER13}/src/common/os_thread_linux.c ${VER13}/src/common/pool_hdr_linux.c ${VER13}/src/common/util_linux.c ${VER13}/src/common/uuid_linux.c ) endif() function(build_libpmemobj_13) if(MSVC) FILE(READ ${VER13}/src/libpmemobj/libpmemobj.def DEFFILE) string(REPLACE "libpmemobj" "pmemobj_13" DEFFILE "${DEFFILE}") FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pmemobj_13.def "${DEFFILE}") add_library(pmemobj_13 SHARED ${SOURCES_13} ${CMAKE_CURRENT_BINARY_DIR}/pmemobj_13.def ${CMAKE_CURRENT_BINARY_DIR}/pmemobj_13.def) target_compile_options(pmemobj_13 PRIVATE /FI"${CMAKE_SOURCE_DIR}/${VER13}/src/windows/include/platform.h") else() add_library(pmemobj_13 SHARED ${SOURCES_13}) disable_optimization(pmemobj_13) endif() target_compile_definitions(pmemobj_13 PRIVATE SRCVERSION="${VER13}") target_compile_definitions(pmemobj_13 PRIVATE NVML_UTF8_API) target_compile_definitions(pmemobj_13 PRIVATE _PMEMOBJ_INTRNL) target_include_directories(pmemobj_13 PRIVATE ${VER13}/src/include) target_include_directories(pmemobj_13 PRIVATE ${VER13}/src/libpmemobj) target_include_directories(pmemobj_13 PRIVATE ${VER13}/src/common) target_include_directories(pmemobj_13 PRIVATE ${PMEM_INCLUDE_DIRS}) if(WIN32) target_include_directories(pmemobj_13 PRIVATE ${VER13}/src/windows/include/) target_include_directories(pmemobj_13 PRIVATE include/) endif() target_link_libraries(pmemobj_13 PRIVATE libpmem-convert) target_link_libraries(pmemobj_13 PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries(pmemobj_13 PRIVATE ${CMAKE_THREAD_LIBS_INIT}) if(NOT MSVC) target_link_libraries(pmemobj_13 PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/${VER13}/src/libpmemobj/libpmemobj.map) endif() endfunction(build_libpmemobj_13) build_libpmemobj_13() endif(BUILD_13) ###################################################### 1.2 if(BUILD_CONVERT_V3) set(VER12 1.2.4) get_pmdk(${VER12} aa57b4d969a7582ad5897b5e979b3f2a4015ace7777388227826a65dbf626edd ${VER12}) set(SOURCES_12 ${VER12}/src/libpmemobj/bucket.c ${VER12}/src/libpmemobj/ctree.c ${VER12}/src/libpmemobj/cuckoo.c ${VER12}/src/libpmemobj/heap.c ${VER12}/src/libpmemobj/lane.c ${VER12}/src/libpmemobj/libpmemobj.c ${VER12}/src/libpmemobj/list.c ${VER12}/src/libpmemobj/memblock.c ${VER12}/src/libpmemobj/memops.c ${VER12}/src/libpmemobj/obj.c ${VER12}/src/libpmemobj/palloc.c ${VER12}/src/libpmemobj/pmalloc.c ${VER12}/src/libpmemobj/pvector.c ${VER12}/src/libpmemobj/redo.c ${VER12}/src/libpmemobj/sync.c ${VER12}/src/libpmemobj/tx.c ${VER12}/src/common/file.c ${VER12}/src/common/file_linux.c ${VER12}/src/common/mmap.c ${VER12}/src/common/mmap_linux.c ${VER12}/src/common/out.c ${VER12}/src/common/pool_hdr.c ${VER12}/src/common/pool_hdr_linux.c ${VER12}/src/common/set.c ${VER12}/src/common/util.c ${VER12}/src/common/uuid.c ${VER12}/src/common/uuid_linux.c ${VER12}/src/common/util_linux.c ) if(WIN32) set(SOURCES_12 ${SOURCES_12} ${VER12}/src/libpmemobj/libpmemobj_main.c) endif() function(build_convert_v3) add_library(pmemobj_convert_v3_o OBJECT ${SOURCES_12} pmemobj_convert_v3.c ${VER12}/src/libpmemblk/btt.c ${VER12}/src/tools/pmempool/common.c) target_compile_definitions(pmemobj_convert_v3_o PRIVATE SRCVERSION="${VER12}") target_include_directories(pmemobj_convert_v3_o PRIVATE ${VER12}/src/include) target_include_directories(pmemobj_convert_v3_o PRIVATE ${VER12}/src/libpmemobj) target_include_directories(pmemobj_convert_v3_o PRIVATE ${VER12}/src/libpmemlog) target_include_directories(pmemobj_convert_v3_o PRIVATE ${VER12}/src/libpmemblk) target_include_directories(pmemobj_convert_v3_o PRIVATE ${VER12}/src/common) target_include_directories(pmemobj_convert_v3_o PRIVATE ${VER12}/src/tools/pmempool) target_include_directories(pmemobj_convert_v3_o PRIVATE ${PMEM_INCLUDE_DIRS}) add_library(pmemobj_convert_v3_shared SHARED $) target_link_libraries(pmemobj_convert_v3_shared PRIVATE libpmem-convert) target_link_libraries(pmemobj_convert_v3_shared PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries(pmemobj_convert_v3_shared PRIVATE ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(pmemobj_convert_v3_shared PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/pmemobj_convert.map) # strip unneeded symbols, requires -fdata-sections -ffunction-sections target_link_libraries(pmemobj_convert_v3_shared PRIVATE -Wl,--gc-sections) set_target_properties(pmemobj_convert_v3_shared PROPERTIES OUTPUT_NAME pmemobj_convert_v3) set_target_properties(pmemobj_convert_v3_shared PROPERTIES PREFIX "") endfunction(build_convert_v3) build_convert_v3() install(TARGETS pmemobj_convert_v3_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}/pmdk-convert/) function(build_libpmemobj_12) add_library(pmemobj_12 SHARED ${SOURCES_12}) disable_optimization(pmemobj_12) target_compile_definitions(pmemobj_12 PRIVATE SRCVERSION="${VER12}") target_include_directories(pmemobj_12 PRIVATE ${VER12}/src/include) target_include_directories(pmemobj_12 PRIVATE ${VER12}/src/libpmemobj) target_include_directories(pmemobj_12 PRIVATE ${VER12}/src/common) target_include_directories(pmemobj_12 PRIVATE ${PMEM_INCLUDE_DIRS}) target_link_libraries(pmemobj_12 PRIVATE libpmem-convert) target_link_libraries(pmemobj_12 PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries(pmemobj_12 PRIVATE ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(pmemobj_12 PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/${VER12}/src/libpmemobj/libpmemobj.map) endfunction(build_libpmemobj_12) build_libpmemobj_12() endif(BUILD_CONVERT_V3) ###################################################### 1.1 if(BUILD_CONVERT_V2) set(VER11 1.1) get_pmdk(${VER11} 2d51a356bf0bd61b0259844894223305d5d825af68d51a07aa1d2bc926b65c43 ${VER11}) set(SOURCES_11 ${VER11}/src/libpmemobj/bucket.c ${VER11}/src/libpmemobj/ctree.c ${VER11}/src/libpmemobj/cuckoo.c ${VER11}/src/libpmemobj/heap.c ${VER11}/src/libpmemobj/lane.c ${VER11}/src/libpmemobj/libpmemobj.c ${VER11}/src/libpmemobj/list.c ${VER11}/src/libpmemobj/memblock.c ${VER11}/src/libpmemobj/memops.c ${VER11}/src/libpmemobj/obj.c ${VER11}/src/libpmemobj/pmalloc.c ${VER11}/src/libpmemobj/pvector.c ${VER11}/src/libpmemobj/redo.c ${VER11}/src/libpmemobj/sync.c ${VER11}/src/libpmemobj/tx.c ${VER11}/src/common/out.c ${VER11}/src/common/set.c ${VER11}/src/common/set_linux.c ${VER11}/src/common/util.c ${VER11}/src/common/util_linux.c ) if(WIN32) set(SOURCES_11 ${SOURCES_11} ${VER11}/src/libpmemobj/libpmemobj_main.c) endif() function(build_convert_v2) add_library(pmemobj_convert_v2_o OBJECT ${SOURCES_11} pmemobj_convert_v2.c ${VER11}/src/libpmemblk/btt.c ${VER11}/src/tools/pmempool/common.c ) target_compile_definitions(pmemobj_convert_v2_o PRIVATE SRCVERSION="${VER11}") target_include_directories(pmemobj_convert_v2_o PRIVATE ${VER11}/src/include) target_include_directories(pmemobj_convert_v2_o PRIVATE ${VER11}/src/libpmemobj) target_include_directories(pmemobj_convert_v2_o PRIVATE ${VER11}/src/libpmemlog) target_include_directories(pmemobj_convert_v2_o PRIVATE ${VER11}/src/libpmemblk) target_include_directories(pmemobj_convert_v2_o PRIVATE ${VER11}/src/common) target_include_directories(pmemobj_convert_v2_o PRIVATE ${VER11}/src/tools/pmempool) target_include_directories(pmemobj_convert_v2_o PRIVATE ${PMEM_INCLUDE_DIRS}) add_library(pmemobj_convert_v2_shared SHARED $) target_link_libraries(pmemobj_convert_v2_shared PRIVATE libpmem-convert) target_link_libraries(pmemobj_convert_v2_shared PRIVATE ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(pmemobj_convert_v2_shared PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/pmemobj_convert.map) # strip unneeded symbols, requires -fdata-sections -ffunction-sections target_link_libraries(pmemobj_convert_v2_shared PRIVATE -Wl,--gc-sections) set_target_properties(pmemobj_convert_v2_shared PROPERTIES OUTPUT_NAME pmemobj_convert_v2) set_target_properties(pmemobj_convert_v2_shared PROPERTIES PREFIX "") endfunction(build_convert_v2) build_convert_v2() install(TARGETS pmemobj_convert_v2_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}/pmdk-convert/) function(build_libpmemobj_11) add_library(pmemobj_11 SHARED ${SOURCES_11}) disable_optimization(pmemobj_11) target_compile_definitions(pmemobj_11 PRIVATE SRCVERSION="${VER11}") target_include_directories(pmemobj_11 PRIVATE ${VER11}/src/include) target_include_directories(pmemobj_11 PRIVATE ${VER11}/src/libpmemobj) target_include_directories(pmemobj_11 PRIVATE ${VER11}/src/common) target_include_directories(pmemobj_11 PRIVATE ${PMEM_INCLUDE_DIRS}) target_link_libraries(pmemobj_11 PRIVATE libpmem-convert) target_link_libraries(pmemobj_11 PRIVATE ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(pmemobj_11 PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/${VER11}/src/libpmemobj/libpmemobj.map) endfunction(build_libpmemobj_11) build_libpmemobj_11() endif(BUILD_CONVERT_V2) ###################################################### 1.0 if(BUILD_CONVERT_V1) set(VER10 1.0) get_pmdk(${VER10} e9c9ed72168047f65fae72808933bfeafd965ed3237ab3fbfb199c362bf5b773 ${VER10}) set(SOURCES_10 ${VER10}/src/libpmemobj/bucket.c ${VER10}/src/libpmemobj/ctree.c ${VER10}/src/libpmemobj/cuckoo.c ${VER10}/src/libpmemobj/heap.c ${VER10}/src/libpmemobj/lane.c ${VER10}/src/libpmemobj/libpmemobj.c ${VER10}/src/libpmemobj/list.c ${VER10}/src/libpmemobj/memops.c ${VER10}/src/libpmemobj/obj.c ${VER10}/src/libpmemobj/pmalloc.c ${VER10}/src/libpmemobj/redo.c ${VER10}/src/libpmemobj/sync.c ${VER10}/src/libpmemobj/tx.c ${VER10}/src/common/out.c ${VER10}/src/common/set.c ${VER10}/src/common/util.c ) function(build_convert_v1) add_library(pmemobj_convert_v1_o OBJECT ${SOURCES_10} pmemobj_convert_v1.c ${VER10}/src/tools/pmempool/common.c) target_compile_definitions(pmemobj_convert_v1_o PRIVATE SRCVERSION="${VER10}") target_include_directories(pmemobj_convert_v1_o PRIVATE ${VER10}/src/include) target_include_directories(pmemobj_convert_v1_o PRIVATE ${VER10}/src/libpmemobj) target_include_directories(pmemobj_convert_v1_o PRIVATE ${VER10}/src/libpmemlog) target_include_directories(pmemobj_convert_v1_o PRIVATE ${VER10}/src/libpmemblk) target_include_directories(pmemobj_convert_v1_o PRIVATE ${VER10}/src/common) target_include_directories(pmemobj_convert_v1_o PRIVATE ${VER10}/src/tools/pmempool) target_include_directories(pmemobj_convert_v1_o PRIVATE ${PMEM_INCLUDE_DIRS}) add_library(pmemobj_convert_v1_shared SHARED $) target_link_libraries(pmemobj_convert_v1_shared PRIVATE libpmem-convert) target_link_libraries(pmemobj_convert_v1_shared PRIVATE ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(pmemobj_convert_v1_shared PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/pmemobj_convert.map) # strip unneeded symbols, requires -fdata-sections -ffunction-sections target_link_libraries(pmemobj_convert_v1_shared PRIVATE -Wl,--gc-sections) set_target_properties(pmemobj_convert_v1_shared PROPERTIES OUTPUT_NAME pmemobj_convert_v1) set_target_properties(pmemobj_convert_v1_shared PROPERTIES PREFIX "") endfunction(build_convert_v1) build_convert_v1() install(TARGETS pmemobj_convert_v1_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}/pmdk-convert/) function(build_libpmemobj_10) add_library(pmemobj_10 SHARED ${SOURCES_10}) disable_optimization(pmemobj_10) target_compile_definitions(pmemobj_10 PRIVATE SRCVERSION="${VER10}") target_include_directories(pmemobj_10 PRIVATE ${VER10}/src/include) target_include_directories(pmemobj_10 PRIVATE ${VER10}/src/libpmemobj) target_include_directories(pmemobj_10 PRIVATE ${VER10}/src/common) target_include_directories(pmemobj_10 PRIVATE ${PMEM_INCLUDE_DIRS}) target_link_libraries(pmemobj_10 PRIVATE libpmem-convert) target_link_libraries(pmemobj_10 PRIVATE ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(pmemobj_10 PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/${VER10}/src/libpmemobj/libpmemobj.map) endfunction(build_libpmemobj_10) build_libpmemobj_10() endif(BUILD_CONVERT_V1) ###################################################### everything else function(build_pmdk_convert) if (WIN32) add_executable(pmdk-convert pmdk-convert.c ${MAX_STABLE}/src/windows/getopt/getopt.c) target_include_directories(pmdk-convert PRIVATE ${MAX_STABLE}/src/windows/getopt/) target_include_directories(pmdk-convert PRIVATE ${MAX_STABLE}/src/windows/include/) else() add_executable(pmdk-convert pmdk-convert.c) endif() target_compile_definitions(pmdk-convert PRIVATE LIBDIR="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") target_compile_definitions(pmdk-convert PRIVATE MIN_VERSION_MAJOR=${MIN_VERSION_MAJOR}) target_compile_definitions(pmdk-convert PRIVATE MIN_VERSION_MINOR=${MIN_VERSION_MINOR}) target_compile_definitions(pmdk-convert PRIVATE MAX_VERSION_MAJOR=${MAX_VERSION_MAJOR}) target_compile_definitions(pmdk-convert PRIVATE MAX_VERSION_MINOR=${MAX_VERSION_MINOR}) target_compile_definitions(pmdk-convert PRIVATE VERSION_MAJOR=${VERSION_MAJOR}) target_compile_definitions(pmdk-convert PRIVATE VERSION_MINOR=${VERSION_MINOR}) target_compile_definitions(pmdk-convert PRIVATE VERSION_PATCH=${VERSION_PATCH}) target_compile_definitions(pmdk-convert PRIVATE VERSION_PRERELEASE="${VERSION_PRERELEASE}") target_link_libraries(pmdk-convert PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries(pmdk-convert PRIVATE ${CMAKE_THREAD_LIBS_INIT}) endfunction() build_pmdk_convert() install(TARGETS pmdk-convert DESTINATION ${CMAKE_INSTALL_BINDIR} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) option(TRACE_TESTS "more verbose test outputs" OFF) enable_testing() add_subdirectory(tests) if(NOT "${CPACK_GENERATOR}" STREQUAL "") include(${CMAKE_SOURCE_DIR}/packages.cmake) endif() pmdk-convert-1.7/ChangeLog000066400000000000000000000014621354444011500155500ustar00rootroot00000000000000Mon Sep 30 2019 Marcin Ślusarz * Version 1.7 This release adds support for PMDK 1.7. Fri Aug 30 2019 Marcin Ślusarz * Version 1.5.2 This release improves compatibility with newer kernels with respect to Device DAX detection. Fri Feb 22 2019 Marcin Ślusarz * Version 1.5.1 This release fixes minor bugs. - conversion should fail if stdin is empty - remote poolset should be detected before layout detection Fri Oct 26 2018 Marcin Ślusarz * Version 1.5 This is the first release of pmdk-convert. It replaces "pmempool convert" from PMDK. It allows conversion of PMDK pools from any version, starting from 1.0, to all later versions, including 1.5. Windows support starts with 1.4. pmdk-convert-1.7/FindPMEM.cmake000066400000000000000000000032461354444011500163410ustar00rootroot00000000000000# # Copyright 2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. find_path(PMEM_INCLUDE_DIRS libpmem.h) find_library(PMEM_LIBRARIES NAMES pmem libpmem) mark_as_advanced(PMEM_LIBRARIES PMEM_INCLUDE_DIRS) pmdk-convert-1.7/LICENSE000066400000000000000000000027431354444011500150060ustar00rootroot00000000000000Copyright 2018, Intel Corporation Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. pmdk-convert-1.7/README.md000066400000000000000000000030361354444011500152540ustar00rootroot00000000000000pmdk-convert: PMDK pool conversion tool ======================================= [![Build Status](https://travis-ci.org/pmem/pmdk-convert.svg?branch=master)](https://travis-ci.org/pmem/pmdk-convert) [![Build status](https://ci.appveyor.com/api/projects/status/github/pmem/pmdk-convert?branch/master?svg=true&pr=false)](https://ci.appveyor.com/project/pmem/pmdk-convert/branch/master) [![Coverage Status](https://codecov.io/github/pmem/pmdk-convert/coverage.svg?branch=master)](https://codecov.io/gh/pmem/pmdk-convert/branch/master) # Building The Source # Requirements: - cmake >= 3.3 On Windows: - [Windows SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk) >= 10.0.16299 In pmdk-convert directory: ```sh $ mkdir build $ cd build ``` And then: ### On RPM-based Linux distros (Fedora, openSUSE, RHEL, SLES) ### ```sh $ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCPACK_GENERATOR=rpm $ make package $ sudo rpm -i pmdk-convert*.rpm ``` ### On DEB-based Linux distros (Debian, Ubuntu) ### ```sh $ cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCPACK_GENERATOR=deb $ make package $ sudo dpkg -i pmdk-convert*.deb ``` ### On other Linux distros ### ```sh $ cmake .. -DCMAKE_INSTALL_PREFIX=/home/user/pmdk-convert-bin $ make $ make install ``` ### On Windows ### ```sh PS> cmake .. -G "Visual Studio 14 2015 Win64" PS> msbuild build/ALL_BUILD.vcxproj ``` To build pmdk-convert on Windows 8 you have to specify your SDK version in the cmake command i.e. ```sh PS> cmake .. -G "Visual Studio 14 2015 Win64" -DCMAKE_SYSTEM_VERSION="10.0.26624" ``` pmdk-convert-1.7/appveyor.yml000066400000000000000000000012331354444011500163620ustar00rootroot00000000000000version: 1.7.{build} os: Visual Studio 2015 platform: x64 environment: GENERATOR: "Visual Studio 14 2015 Win64" configuration: - Debug - Release matrix: fast_finish: true before_build: - cmake . -Bbuild -G "%GENERATOR%" -DCMAKE_INSTALL_PREFIX=c:/install/pmdk-convert -DCMAKE_SYSTEM_VERSION="10.0.26624" -DTESTS_USE_FORCED_PMEM=ON -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DCDB_PATH="c:/Program Files (x86)/Windows Kits/10/Debuggers/x64/" build_script: - msbuild build/ALL_BUILD.vcxproj /property:Configuration=%CONFIGURATION% test_script: - cd build - ctest -C %CONFIGURATION% --output-on-failure - msbuild INSTALL.vcxproj pmdk-convert-1.7/cmake_uninstall.cmake.in000066400000000000000000000020241354444011500205510ustar00rootroot00000000000000# From: https://cmake.org/Wiki/CMake_FAQ if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") foreach(file ${files}) message(STATUS "Uninstalling $ENV{DESTDIR}${file}") if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval ) if(NOT "${rm_retval}" STREQUAL 0) message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") endif(NOT "${rm_retval}" STREQUAL 0) else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") message(STATUS "File $ENV{DESTDIR}${file} does not exist.") endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") endforeach(file) pmdk-convert-1.7/codecov.yml000066400000000000000000000001311354444011500161330ustar00rootroot00000000000000ignore: - tests/ comment: layout: "diff" behavior: default require_changes: yes pmdk-convert-1.7/doc/000077500000000000000000000000001354444011500145405ustar00rootroot00000000000000pmdk-convert-1.7/doc/generated/000077500000000000000000000000001354444011500164765ustar00rootroot00000000000000pmdk-convert-1.7/doc/generated/pmdk-convert.1000066400000000000000000000070631354444011500211770ustar00rootroot00000000000000.\" Automatically generated by Pandoc 2.0.6 .\" .TH "" "" "2019-01-30" "PMDK - pmem Tools version 1.5" "PMDK Programmer's Manual" .hy .\" Copyright 2014-2019, Intel Corporation .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in .\" the documentation and/or other materials provided with the .\" distribution. .\" .\" * Neither the name of the copyright holder nor the names of its .\" contributors may be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .SH NAME .PP \f[B]pmdk\-convert\f[] \- upgrade pool files layout version .SH SYNOPSIS .IP .nf \f[C] $\ pmdk\-convert\ \f[] .fi .SH DESCRIPTION .PP The \f[B]pmdk\-convert\f[] performs a conversion of the specified pool to the newest layout supported by this tool. Currently only \f[B]libpmemobj\f[](7) pools are supported. .PP The conversion process is not fail\-safe \- power interruption may damage the pool. It is advised to have a backup of the pool before conversion. .PP This tool doesn't support remote replicas. Before a conversion all remote replicas have to be removed from the pool by \f[B]pmempool transform\f[] command. .SS Options: .PP \f[C]\-V,\ \-\-version\f[] .PP Display version information and exit. .PP \f[C]\-h,\ \-\-help\f[] .PP Display help and the list of supported layouts and corresponding PMDK versions. .PP \f[C]\-f,\ \-\-from=pmdk\-version\f[] .PP Convert from specified PMDK version. This option is exclusive with \-F option. .PP \f[C]\-F,\ \-\-from\-layout=version\f[] .PP Convert from specified layout version. This option is exclusive with \-f option. .PP \f[C]\-t,\ \-\-to=version\f[] .PP convert to specified PMDK version. This option is exclusive with \-T option. .PP \f[C]\-T,\ \-\-to\-layout=version\f[] .PP Convert to specified layout version. This option is exclusive with \-t option. .PP \f[C]\-X,\ \-\-force\-yes=[question]\f[] reply positively to specified question possible questions: \- fail\-safety \- 1.2\-pmemmutex .SH EXAMPLE .IP .nf \f[C] $\ pmempool\ convert\ pool.obj \f[] .fi .PP Updates pool.obj to the latest layout version. .IP .nf \f[C] $\ pmempool\ convert\ pool.obj\ \-\-from=1.2\ \-\-to=1.4 \f[] .fi .PP Updates pool.obj from PMDK 1.2 to PMDK 1.4 .SH SEE ALSO .PP \f[B]pmempool\f[](1), \f[B]libpmemblk\f[](7), \f[B]libpmemlog\f[](7), \f[B]libpmemobj\f[](7), \f[B]libpmempool\f[](7) and \f[B]\f[] pmdk-convert-1.7/doc/pmdk-convert/000077500000000000000000000000001354444011500171515ustar00rootroot00000000000000pmdk-convert-1.7/doc/pmdk-convert/pmdk-convert.1.md000066400000000000000000000074241354444011500222520ustar00rootroot00000000000000--- layout: manual Content-Style: 'text/css' title: PMDK-CONVERT collection: pmempool header: PMDK date: pmem Tools version 1.5 ... [comment]: <> (Copyright 2016-2017, Intel Corporation) [comment]: <> (Redistribution and use in source and binary forms, with or without) [comment]: <> (modification, are permitted provided that the following conditions) [comment]: <> (are met:) [comment]: <> ( * Redistributions of source code must retain the above copyright) [comment]: <> ( notice, this list of conditions and the following disclaimer.) [comment]: <> ( * Redistributions in binary form must reproduce the above copyright) [comment]: <> ( notice, this list of conditions and the following disclaimer in) [comment]: <> ( the documentation and/or other materials provided with the) [comment]: <> ( distribution.) [comment]: <> ( * Neither the name of the copyright holder nor the names of its) [comment]: <> ( contributors may be used to endorse or promote products derived) [comment]: <> ( from this software without specific prior written permission.) [comment]: <> (THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS) [comment]: <> ("AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT) [comment]: <> (LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR) [comment]: <> (A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT) [comment]: <> (OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,) [comment]: <> (SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT) [comment]: <> (LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,) [comment]: <> (DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY) [comment]: <> (THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT) [comment]: <> ((INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE) [comment]: <> (OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.) [comment]: <> (pmdk-convert.1 -- man page for pmdk-convert) [NAME](#name)
[SYNOPSIS](#synopsis)
[DESCRIPTION](#description)
[EXAMPLE](#example)
[SEE ALSO](#see-also)
# NAME # **pmdk-convert** - upgrade pool files layout version # SYNOPSIS # ``` $ pmdk-convert ``` # DESCRIPTION # The **pmdk-convert** performs a conversion of the specified pool to the newest layout supported by this tool. Currently only **libpmemobj**(7) pools are supported. The conversion process is not fail-safe - power interruption may damage the pool. It is advised to have a backup of the pool before conversion. This tool doesn't support remote replicas. Before a conversion all remote replicas have to be removed from the pool by **pmempool transform** command. ##### Options: ##### `-V, --version` Display version information and exit. `-h, --help` Display help and the list of supported layouts and corresponding PMDK versions. `-f, --from=pmdk-version` Convert from specified PMDK version. This option is exclusive with -F option. `-F, --from-layout=version` Convert from specified layout version. This option is exclusive with -f option. `-t, --to=version` convert to specified PMDK version. This option is exclusive with -T option. `-T, --to-layout=version` Convert to specified layout version. This option is exclusive with -t option. `-X, --force-yes=[question]` reply positively to specified question possible questions: - fail-safety - 1.2-pmemmutex # EXAMPLE # ``` $ pmempool convert pool.obj ``` Updates pool.obj to the latest layout version. ``` $ pmempool convert pool.obj --from=1.2 --to=1.4 ``` Updates pool.obj from PMDK 1.2 to PMDK 1.4 # SEE ALSO # **pmempool**(1), **libpmemblk**(7), **libpmemlog**(7), **libpmemobj**(7), **libpmempool**(7) and **** pmdk-convert-1.7/include/000077500000000000000000000000001354444011500154165ustar00rootroot00000000000000pmdk-convert-1.7/include/srcversion.h000066400000000000000000000030741354444011500177700ustar00rootroot00000000000000/* * Copyright 2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ pmdk-convert-1.7/packages.cmake000066400000000000000000000073561354444011500165660ustar00rootroot00000000000000# # Copyright 2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # packages.cmake - CPack configuration for rpm and deb generation # string(TOUPPER "${CPACK_GENERATOR}" CPACK_GENERATOR) if(NOT ("${CPACK_GENERATOR}" STREQUAL "DEB" OR "${CPACK_GENERATOR}" STREQUAL "RPM")) message(FATAL_ERROR "Wrong CPACK_GENERATOR value, valid generators are: DEB, RPM") endif() set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") set(CMAKE_INSTALL_TMPDIR /tmp CACHE PATH "Output dir for tmp") set(CPACK_COMPONENTS_ALL_IN_ONE) # Filter out some of directories from %dir section, which are expected # to exist in filesystem. Leaving them might lead to conflicts with other # packages (for example with 'filesystem' package on fedora which specify # /usr, /usr/local, etc.) set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION ${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_INCDIR} ${CPACK_PACKAGING_INSTALL_PREFIX}/share ${CPACK_PACKAGING_INSTALL_PREFIX}/share/doc) set(CPACK_PACKAGE_NAME "pmdk-convert") set(CPACK_PACKAGE_VERSION ${VERSION}) set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Conversion tool for pmdk pools") set(CPACK_PACKAGE_VENDOR "Intel") set(CPACK_RPM_PACKAGE_NAME "pmdk-convert") if(EXISTS "/etc/redhat-release") set(CPACK_RPM_PACKAGE_GROUP "System Environment/Base") else() set(CPACK_RPM_PACKAGE_GROUP "System/Base") endif(EXISTS "/etc/redhat-release") set(CPACK_RPM_PACKAGE_LICENSE "BSD") set(CPACK_RPM_PACKAGE_ARCHITECTURE x86_64) set(CPACK_DEBIAN_PACKAGE_NAME "pmdk-convert") set(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64) set(CPACK_DEBIAN_PACKAGE_MAINTAINER "marcin.slusarz@intel.com") if("${CPACK_GENERATOR}" STREQUAL "RPM") set(CPACK_PACKAGE_FILE_NAME ${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${CPACK_RPM_PACKAGE_ARCHITECTURE}) elseif("${CPACK_GENERATOR}" STREQUAL "DEB") set(CPACK_PACKAGE_FILE_NAME ${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}) endif() set(targetDestDir ${CMAKE_INSTALL_TMPDIR}) include(CPack) pmdk-convert-1.7/pmdk-convert.c000066400000000000000000000440651354444011500165610ustar00rootroot00000000000000/* * Copyright 2018-2019, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #ifndef _WIN32 #include #include #include #include #endif #define MINVERSION ((MIN_VERSION_MAJOR) * 10 + (MIN_VERSION_MINOR)) #define MAXVERSION ((MAX_VERSION_MAJOR) * 10 + (MAX_VERSION_MINOR)) #include "pmemobj_convert.h" typedef const char *(*conv)(const char *, unsigned); typedef int (*try_op)(const char *); static char *AppName; enum { NOT_ENOUGH_ARGS = 1, UNKNOWN_FLAG = 2, UNKNOWN_ARG = 3, FROM_EXCLUSIVE = 4, TO_EXCLUSIVE = 5, FROM_INVALID = 6, TO_INVALID = 7, FROM_LAYOUT_INVALID = 8, TO_LAYOUT_INVALID = 9, NO_POOL = 10, POOL_DETECTION = 11, UNSUPPORTED_FROM = 12, UNSUPPORTED_TO = 13, BACKWARD_CONVERSION = 14, CONVERT_FAILED = 15, CREATE_VERSION_STR_FAILED = 16, OPEN_LIB_FAILED = 17, DLSYM_FAILED = 18, FREELIB_FAILED = 19, OPEN_FAILED = 20, STAT_FAILED = 21, MMAP_FAILED = 22, REMOTE = 23, ARG_CONVERSION_FAILED = 24, STDIN_EOF = 25, }; #define ARRAY_LENGTH(array) (sizeof((array)) / sizeof((array)[0])) #define CHECK_VERSION(x) (MINVERSION <= (x)) && ((x) <= MAXVERSION) static const struct { int pmdk_version; int layout; } Layouts[] = { #if CHECK_VERSION(10) {10, 1}, #endif #if CHECK_VERSION(11) {11, 2}, #endif #if CHECK_VERSION(12) {12, 3}, #endif #if CHECK_VERSION(13) {13, 4}, #endif #if CHECK_VERSION(14) {14, 4}, #endif #if CHECK_VERSION(15) {15, 5}, #endif #if CHECK_VERSION(16) {16, 5}, #endif #if CHECK_VERSION(17) {17, 6}, #endif }; #ifndef WIN32 #include #include /* * open_lib -- opens conversion plugin */ static void * open_lib(const char *name) { char *argv0copy = strdup(AppName); char *dir = dirname(argv0copy); char path[2][strlen(dir) + strlen(name) + strlen(LIBDIR) + 100]; char *reason0 = NULL; sprintf(path[0], "%s/%s.so", dir, name); void *lib = dlopen(path[0], RTLD_NOW); if (!lib) { reason0 = strdup(dlerror()); if (reason0 == NULL) { fprintf(stderr, "strdup failed"); exit(OPEN_LIB_FAILED); } sprintf(path[1], "%s/pmdk-convert/%s.so", LIBDIR, name); lib = dlopen(path[1], RTLD_NOW); } if (!lib) fprintf(stderr, "dlopen failed:\n%s: %s\n%s: %s\n", path[0], reason0, path[1], dlerror()); free(argv0copy); free(reason0); if (!lib) exit(OPEN_LIB_FAILED); return lib; } /* * get_fun -- returns function from library */ static void * get_fun(void * library, const char *function) { void *_fun = dlsym(library, function); if (!_fun) { fprintf(stderr, "dlsym failed: %s\n", dlerror()); exit(DLSYM_FAILED); } return _fun; } /* * close_lib -- closes conversion plugin */ static void close_lib(void *lib) { dlclose(lib); } #else #include /* * dirname - windows implementation of dirname function * based on windows/include/unistd.h from pmdk repo */ static char * dirname(char *path) { if (path == NULL) return "."; size_t len = strlen(path); if (len == 0) return "."; char *end = path + len; /* strip trailing forslashes and backslashes */ while ((--end) > path) { if (*end != '\\' && *end != '/') { *(end + 1) = '\0'; break; } } /* strip basename */ while ((--end) > path) { if (*end == '\\' || *end == '/') { *end = '\0'; break; } } if (end != path) return path; /* handle edge cases */ if (*end == '\\' || *end == '/') { *(end + 1) = '\0'; } else { *end++ = '.'; *end = '\0'; } return path; } /* * open_lib -- opens conversion plugin */ static void * open_lib(const char *name) { char *argv0copy = strdup(AppName); char *dir = dirname(argv0copy); char *path = malloc(strlen(dir) + strlen(name) + 100); if (path == NULL) { fprintf(stderr, "malloc failed"); exit(OPEN_LIB_FAILED); } sprintf(path, "%s/%s.dll", dir, name); void *lib = LoadLibrary(path); if (!lib) fprintf(stderr, "LoadLibrary(%s) failed: %d", path, GetLastError()); free(argv0copy); free(path); if (!lib) exit(OPEN_LIB_FAILED); return lib; } /* * get_fun -- returns function from library */ static void * get_fun(void *library, const char *function) { void *_fun = GetProcAddress(library, function); if (!_fun) { fprintf(stderr, "GetProcAddress failed: %d\n", GetLastError()); exit(DLSYM_FAILED); } return _fun; } /* * close_lib -- closes conversion plugin */ static void close_lib(void *lib) { if (!FreeLibrary(lib)) exit(FREELIB_FAILED); } /* * util_toUTF8 -- allocating conversion from wide char string to UTF8 */ static char * util_toUTF8(const wchar_t *wstr) { int size = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, wstr, -1, NULL, 0, NULL, NULL); if (size == 0) goto err; char *str = malloc(size * sizeof(char)); if (str == NULL) goto out; if (WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, wstr, -1, str, size, NULL, NULL) == 0) { free(str); goto err; } out: return str; err: errno = EINVAL; return NULL; } #endif /* * conv_version -- converts version string from major.minor format to number * (major * 10 + minor) */ static int conv_version(const char *strver) { if (strlen(strver) != 3) return -1; if (strver[1] != '.') return -1; if (!isdigit(strver[0])) return -1; if (!isdigit(strver[2])) return -1; return (strver[0] - '0') * 10 + strver[2] - '0'; } /* * conv_layout_version -- converts layout version string to number */ static int conv_layout_version(const char *strver) { char *end; errno = 0; unsigned long long retval = strtoull(strver, &end, 10); if (*end != '\0') return -1; if (errno != 0) return -1; if (retval > INT_MAX) return -1; return (int)retval; } /* * RUN_FUNCTION -- runs function from a given library */ #define RUN_FUNCTION(library, function, type, ret, ...) \ do { \ type _fun = get_fun(library, function); \ \ ret = _fun(__VA_ARGS__); \ } while (0) /* * find_layout_version -- returns a layout version for a given PMDK version */ static int find_layout_version(int version) { for (unsigned i = 0; i < ARRAY_LENGTH(Layouts); i++) { if (Layouts[i].pmdk_version == version) return Layouts[i].layout; } return -1; } /* * verify_layout_version -- checks if a given layout version is supported by * pmdk-convert */ static int verify_layout_version(int layout_version) { for (unsigned i = 0; i < ARRAY_LENGTH(Layouts); i++) { if (Layouts[i].layout == layout_version) return 0; } return -1; } /* * create_pmdk_version_str -- returns string in format: * "v (PMDK ., PMDK .)" * for a given layout version. */ static int create_pmdk_version_str(int layout_version, char *str, size_t len) { *str = '\0'; int ret = snprintf(str, len, "v%d (", layout_version); if (ret <= 0) return -1; str += ret; len -= (unsigned)ret; for (unsigned i = 0; i < ARRAY_LENGTH(Layouts); i++) { if (Layouts[i].layout != layout_version) continue; int major = Layouts[i].pmdk_version / 10; int minor = Layouts[i].pmdk_version % 10; int ret = snprintf(str, len, "PMDK %d.%d, ", major, minor); if (ret <= 0) return -1; str += ret; len -= (unsigned)ret; } if (*(str - 2) != ',' && *(str - 1) != ' ') return -1; /* should never happen */ /* s/ ,/)/ */ *(str - 2) = ')'; *(str - 1) = '\0'; return 0; } /* * detect_layout_version -- detects a layout version for a given pool */ static int detect_layout_version(const char *path) { int from = find_layout_version(MINVERSION); int to = find_layout_version(MAXVERSION); for (int ver = from; ver <= to; ver++) { char lib_name[100]; int ret; sprintf(lib_name, "pmemobj_convert_v%d", ver); void *lib = open_lib(lib_name); RUN_FUNCTION(lib, "pmemobj_convert_try_open", try_op, ret, path); close_lib(lib); if (!ret) return ver; } return -1; } /* * list_supported_pools -- prints supported layouts(and PMDK versions) by * pmdk-convert */ static void list_supported_pools() { char line[256]; int prev = 0; printf("Supported pools layouts (corresponding PMDK versions)\n"); for (unsigned i = 0; i < ARRAY_LENGTH(Layouts); i++) { if (prev == Layouts[i].layout) continue; prev = Layouts[i].layout; if (create_pmdk_version_str(Layouts[i].layout, line, 256)) exit(CREATE_VERSION_STR_FAILED); printf(" %s\n", line); } } /* * print_usage -- prints usage message */ static void print_usage() { printf( "Usage: pmdk-convert [--version] [--help] [--no-warning] --from= --to= \n"); } /* * print_version -- prints version message */ static void print_version() { printf("pmdk-convert %d.%d", VERSION_MAJOR, VERSION_MINOR); if (VERSION_PATCH) printf(".%d", VERSION_PATCH); if (strlen(VERSION_PRERELEASE) > 0) printf("-%s", VERSION_PRERELEASE); printf("\n"); } /* * print_help -- prints help message */ static void print_help() { print_usage(); print_version(); printf("\n"); printf("Options:\n"); printf(" -V, --version display version\n"); printf(" -h, --help display this help and exit\n"); printf( " -f, --from=version convert from specified PMDK version\n"); printf( " -t, --to=version convert to specified PMDK version\n"); printf( " -F, --from-layout=version convert from specified layout version\n"); printf( " -T, --to-layout=version convert to specified layout version\n"); printf( " -X, --force-yes=[question] reply positively to specified question\n"); printf(" possible questions:\n"); printf(" - fail-safety\n"); printf(" - 1.2-pmemmutex\n"); printf("\n"); list_supported_pools(); } #define POOLSET_DESC "PMEMPOOLSET\n" #define REPLICA_DESC "\nREPLICA" static int check_remote(const char *path) { #ifdef _WIN32 return 0; #else int fd = open(path, O_RDONLY); if (fd < 0) { fprintf(stderr, "open failed: %s\n", strerror(errno)); exit(OPEN_FAILED); } struct stat st; if (fstat(fd, &st)) { fprintf(stderr, "fstat failed: %s\n", strerror(errno)); close(fd); exit(STAT_FAILED); } if (S_ISCHR(st.st_mode)) { close(fd); return 0; /* char device(DEVDAX) is not a poolset file */ } size_t map_size = (size_t)st.st_size; const char *poolset = mmap(NULL, map_size, PROT_READ, MAP_PRIVATE | MAP_NORESERVE, fd, 0); if (poolset == MAP_FAILED) { fprintf(stderr, "mmap failed: %s\n", strerror(errno)); close(fd); exit(MMAP_FAILED); } close(fd); if (memcmp(poolset, POOLSET_DESC, sizeof(POOLSET_DESC) - 1) != 0) return 0; /* not a poolset */ for (unsigned long i = 0; i < map_size - sizeof(REPLICA_DESC) - 1; i++) { if (memcmp(poolset + i, REPLICA_DESC, sizeof(REPLICA_DESC) - 1) == 0) { i += sizeof(REPLICA_DESC) - 1; /* check if it is not REPLCA[^\s] */ if (!isblank(poolset[i])) continue; for (; i < map_size; i++) { if (poolset[i] == '\n') break; if (isblank(poolset[i]) == 0 && poolset[i] != '#') return 1; } } } return 0; #endif } int main(int argc, char *argv[]) { #ifdef _WIN32 wchar_t **wargv = CommandLineToArgvW(GetCommandLineW(), &argc); for (int i = 0; i < argc; i++) { argv[i] = util_toUTF8(wargv[i]); if (argv[i] == NULL) { for (i--; i >= 0; i--) free(argv[i]); fprintf(stderr, "Error during arguments conversion %s\n", strerror(errno)); exit(ARG_CONVERSION_FAILED); } } #endif const char *path; int from = 0; int to = 0; int from_layout = 0; int to_layout = 0; unsigned force = 0; AppName = argv[0]; if (argc < 2) { print_usage(); exit(NOT_ENOUGH_ARGS); } /* * long_options -- pmempool command line arguments */ static const struct option long_options[] = { {"version", no_argument, NULL, 'V'}, {"help", no_argument, NULL, 'h'}, {"from", required_argument, NULL, 'f'}, {"to", required_argument, NULL, 't'}, {"from-layout", required_argument, NULL, 'F'}, {"to-layout", required_argument, NULL, 'T'}, {"force-yes", required_argument, NULL, 'X'}, {NULL, 0, NULL, 0 }, }; int opt; int option_index; while ((opt = getopt_long(argc, argv, "Vhf:F:t:T:X:", long_options, &option_index)) != -1) { switch (opt) { case 'V': print_version(); exit(0); case 'h': print_help(); exit(0); case 'f': from = conv_version(optarg); break; case 't': to = conv_version(optarg); break; case 'F': from_layout = conv_layout_version(optarg); break; case 'T': to_layout = conv_layout_version(optarg); break; case 'X': if (strcmp(optarg, "fail-safety") == 0) force |= QUEST_FAIL_SAFETY; else if (strcmp(optarg, "1.2-pmemmutex") == 0) force |= QUEST_12_PMEMMUTEX; else { fprintf(stderr, "unknown parameter %s\n", optarg); exit(UNKNOWN_FLAG); } break; default: print_usage(); exit(UNKNOWN_ARG); } } if (from != 0 && from_layout != 0) { fprintf(stderr, "\"from\" and \"from-layout\" parameters are exclusive.\n"); print_usage(); exit(FROM_EXCLUSIVE); } if (to != 0 && to_layout != 0) { fprintf(stderr, "\"to\" and \"to-layout\" parameters are exclusive.\n"); print_usage(); exit(TO_EXCLUSIVE); } if (from < 0) { fprintf(stderr, "Invalid \"from\" version format [major.minor].\n"); print_usage(); exit(FROM_INVALID); } if (to < 0) { fprintf(stderr, "Invalid \"to\" version format [major.minor].\n"); print_usage(); exit(TO_INVALID); } if (from_layout < 0) { fprintf(stderr, "Invalid \"from-layout\" version.\n"); print_usage(); exit(FROM_LAYOUT_INVALID); } if (to_layout < 0) { fprintf(stderr, "Invalid \"to-layout\" version.\n"); print_usage(); exit(TO_LAYOUT_INVALID); } if (optind >= argc) { fprintf(stderr, "Missing pool argument.\n"); exit(NO_POOL); } path = argv[optind]; if (check_remote(path)) { fprintf(stderr, "Remote replication is not supported.\n" "Please use pmempool transform to remove remote replica and then use pmdk-convert.\n"); exit(REMOTE); } void *pmem_convert = open_lib("libpmem-convert"); if (from == 0) { if (from_layout == 0) { if ((from_layout = detect_layout_version(path)) < 0) { fprintf(stderr, "Cannot detect pool version.\n"); exit(POOL_DETECTION); } } else { if (verify_layout_version(from_layout)) { fprintf(stderr, "Unsupported pool 'from-layout' version\n"); exit(UNSUPPORTED_FROM); } } } else { from_layout = find_layout_version(from); if (from_layout == -1) { fprintf(stderr, "Unsupported pool 'from' version\n"); exit(UNSUPPORTED_FROM); } } if (to == 0) { if (to_layout == 0) { to_layout = find_layout_version(MAXVERSION); } else { if (verify_layout_version(to_layout)) { fprintf(stderr, "Unsupported pool 'to-layout' version\n"); exit(UNSUPPORTED_TO); } } } else { to_layout = find_layout_version(to); if (to_layout == -1) { fprintf(stderr, "Unsupported pool 'to' version\n"); exit(UNSUPPORTED_TO); } } if (to_layout == from_layout) { printf( "The pool is in the requested layout verison, conversion is not needed"); exit(0); } if (from_layout > to_layout) { fprintf(stderr, "Backward conversion is not implemented.\n"); print_usage(); exit(BACKWARD_CONVERSION); } printf( "This tool will update the pool to the specified layout version.\n" "This process is NOT fail-safe.\n" "Proceed only if the pool has been backed up or\n" "the risks are fully understood and acceptable.\n"); if (!(force & QUEST_FAIL_SAFETY)) { printf( "Hit Ctrl-C now if you want to stop or Enter to continue.\n"); if (getchar() == EOF) { fprintf(stderr, "EOF, aborting\n"); exit(STDIN_EOF); } } char to_str[255]; char from_str[255]; if (create_pmdk_version_str(from_layout, from_str, 255)) exit(CREATE_VERSION_STR_FAILED); if (create_pmdk_version_str(to_layout, to_str, 255)) exit(CREATE_VERSION_STR_FAILED); printf("Starting conversion from %s to %s\n", from_str, to_str); for (int ver = from_layout; ver < to_layout; ++ver) { if (create_pmdk_version_str(ver, from_str, 255)) exit(CREATE_VERSION_STR_FAILED); if (create_pmdk_version_str(ver + 1, to_str, 255)) exit(CREATE_VERSION_STR_FAILED); printf("Converting from %s to %s... ", from_str, to_str); fflush(stdout); char lib_name[100]; const char *msg; sprintf(lib_name, "pmemobj_convert_v%d", ver); void *lib = open_lib(lib_name); RUN_FUNCTION(lib, "pmemobj_convert", conv, msg, path, force); if (msg) { fprintf(stderr, "failed: %s (%s)\n", msg, strerror(errno)); close_lib(lib); exit(CONVERT_FAILED); } close_lib(lib); printf("Done\n"); } close_lib(pmem_convert); #ifdef _WIN32 for (int i = argc; i > 0; i--) free(argv[i - 1]); #endif return 0; } pmdk-convert-1.7/pmemobj_convert.h000066400000000000000000000047401354444011500173420ustar00rootroot00000000000000/* * Copyright 2018-2019, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef PMEMOBJ_CONVERT_H #define PMEMOBJ_CONVERT_H #include #include #define QUEST_FAIL_SAFETY (1U << 0) #define QUEST_12_PMEMMUTEX (1U << 1) #ifdef __GNUC__ #define FORMAT_PRINTF(a, b) __attribute__((__format__(__printf__, (a), (b)))) #else #define FORMAT_PRINTF(a, b) #endif /* * get_error -- returns formatted error message, using statically allocated * buffer */ FORMAT_PRINTF(1, 2) static inline const char * get_error(const char *format, ...) { static char errstr[500]; int ret; va_list ap; va_start(ap, format); ret = vsnprintf(errstr, sizeof(errstr), format, ap); va_end(ap); if (ret < 0) sprintf(errstr, "vsnsprintf error %d (%d)", ret, errno); else if (ret >= (int)sizeof(errstr)) sprintf(errstr + sizeof(errstr) - 20, "... (truncated)"); return errstr; } const char *pmemobj_convert(const char *path, unsigned force); int pmemobj_convert_try_open(char *path); #endif pmdk-convert-1.7/pmemobj_convert.map000066400000000000000000000031471354444011500176700ustar00rootroot00000000000000# # Copyright 2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # { global: pmemobj_convert; pmemobj_convert_try_open; local: *; }; pmdk-convert-1.7/pmemobj_convert_v1.c000066400000000000000000000105151354444011500177400ustar00rootroot00000000000000/* * Copyright 2014-2019, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include "libpmem.h" #include "pmemobj_convert.h" #include "libpmemobj.h" #include "common.h" #include "output.h" /* * outv_err_vargs -- print error message */ void outv_err_vargs(const char *fmt, va_list ap) { fprintf(stderr, "error: "); vfprintf(stderr, fmt, ap); if (!strchr(fmt, '\n')) fprintf(stderr, "\n"); } /* * outv_err -- print error message */ void outv_err(const char *fmt, ...) { va_list ap; va_start(ap, fmt); outv_err_vargs(fmt, ap); va_end(ap); } /* * pmemobj_convert - convert a pool to the next layout version */ const char * pmemobj_convert(const char *path, unsigned force) { /* open the pool and perform recovery */ PMEMobjpool *pop = pmemobj_open(path, NULL); if (!pop) return pmemobj_errormsg(); /* now recovery state is clean, so we can zero it out */ struct lane_layout *lanes = (struct lane_layout *)((char *)pop + pop->lanes_offset); memset(lanes, 0, pop->nlanes * sizeof(struct lane_layout)); pmemobj_persist(pop, lanes, pop->nlanes * sizeof(struct lane_layout)); pmemobj_close(pop); const char *ret = NULL; struct pmem_pool_params params; if (pmem_pool_parse_params(path, ¶ms, 1)) return get_error("cannot open pool: %s", strerror(errno)); struct pool_set_file *psf = pool_set_file_open(path, 0, 1); if (psf == NULL) { return get_error("pool_set_file_open failed: %s", strerror(errno)); } void *addr = pool_set_file_map(psf, 0); if (addr == NULL) { ret = "mapping file failed"; goto pool_set_close; } struct pool_hdr *phdr = addr; uint32_t m = le32toh(phdr->major); if (m != OBJ_FORMAT_MAJOR) { /* shouldn't be possible, because pool open succeeded earlier */ ret = get_error("invalid pool version: %d", m); goto pool_set_close; } if (pool_set_file_map_headers(psf, 0, POOL_HDR_SIZE)) { ret = get_error("mapping headers failed: %s", strerror(errno)); goto pool_set_close; } /* need to update every header of every part */ for (unsigned r = 0; r < psf->poolset->nreplicas; ++r) { struct pool_replica *rep = psf->poolset->replica[r]; for (unsigned p = 0; p < rep->nparts; ++p) { struct pool_set_part *part = &rep->part[p]; struct pool_hdr *hdr = part->hdr; assert(hdr->major == OBJ_FORMAT_MAJOR); hdr->major = htole32(OBJ_FORMAT_MAJOR + 1); util_checksum(hdr, sizeof(*hdr), &hdr->checksum, 1); pmem_msync(hdr, sizeof(struct pool_hdr)); } } pool_set_file_unmap_headers(psf); pool_set_close: pool_set_file_close(psf); return ret; } /* * pmemobj_convert_try_open - return if a pool is openable by this pmdk verison */ int pmemobj_convert_try_open(char *path) { PMEMobjpool *pop = pmemobj_open(path, NULL); if (!pop) return 1; pmemobj_close(pop); return 0; } pmdk-convert-1.7/pmemobj_convert_v2.c000066400000000000000000000131111354444011500177340ustar00rootroot00000000000000/* * Copyright 2014-2019, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include "libpmem.h" #include "pmemobj_convert.h" #include "libpmemobj.h" #include "common.h" #include "output.h" /* * outv_err_vargs -- print error message */ void outv_err_vargs(const char *fmt, va_list ap) { fprintf(stderr, "error: "); vfprintf(stderr, fmt, ap); if (!strchr(fmt, '\n')) fprintf(stderr, "\n"); } /* * outv_err -- print error message */ void outv_err(const char *fmt, ...) { va_list ap; va_start(ap, fmt); outv_err_vargs(fmt, ap); va_end(ap); } /* * pool_set_file_unmap_headers -- unmap headers of each pool set part file */ static void pool_set_file_unmap_headers(struct pool_set_file *file) { if (!file->poolset) return; for (unsigned r = 0; r < file->poolset->nreplicas; r++) { struct pool_replica *rep = file->poolset->replica[r]; for (unsigned p = 0; p < rep->nparts; p++) { struct pool_set_part *part = &rep->part[p]; util_unmap_hdr(part); } } } /* * pool_set_file_map_headers -- map headers of each pool set part file */ static int pool_set_file_map_headers(struct pool_set_file *file, int rdonly) { if (!file->poolset) return -1; int flags = rdonly ? MAP_PRIVATE : MAP_SHARED; for (unsigned r = 0; r < file->poolset->nreplicas; r++) { struct pool_replica *rep = file->poolset->replica[r]; for (unsigned p = 0; p < rep->nparts; p++) { struct pool_set_part *part = &rep->part[p]; if (util_map_hdr(part, flags)) { part->hdr = NULL; goto err; } } } return 0; err: pool_set_file_unmap_headers(file); return -1; } /* * pmemobj_convert - convert a pool to the next layout version */ const char * pmemobj_convert(const char *path, unsigned force) { /* open the pool and perform recovery */ PMEMobjpool *pop = pmemobj_open(path, NULL); if (!pop) return pmemobj_errormsg(); pmemobj_close(pop); printf( "\nThe conversion to 1.2 can only be made automatically if the PMEMmutex,\n" "PMEMrwlock and PMEMcond types are not used in the pool or all of the variables\n" "of those three types are aligned to 8 bytes. Proceed only if you are sure that\n" "the above is true for this pool.\n"); if (force & QUEST_12_PMEMMUTEX) { printf("Operation forced by user.\n"); } else { char ans = ask_yN('?', "convert the pool?"); if (ans != 'y') { errno = ECANCELED; return "Operation canceled by user"; } } const char *ret = NULL; struct pmem_pool_params params; if (pmem_pool_parse_params(path, ¶ms, 1)) return get_error("cannot open pool: %s", strerror(errno)); struct pool_set_file *psf = pool_set_file_open(path, 0, 1); if (psf == NULL) { return get_error("pool_set_file_open failed: %s", strerror(errno)); } void *addr = pool_set_file_map(psf, 0); if (addr == NULL) { ret = "mapping file failed"; goto pool_set_close; } struct pool_hdr *phdr = addr; uint32_t m = le32toh(phdr->major); if (m != OBJ_FORMAT_MAJOR) { /* shouldn't be possible, because pool open succeeded earlier */ ret = get_error("invalid pool version: %d", m); goto pool_set_close; } if (pool_set_file_map_headers(psf, 0)) { ret = get_error("mapping headers failed: %s", strerror(errno)); goto pool_set_close; } /* need to update every header of every part */ for (unsigned r = 0; r < psf->poolset->nreplicas; ++r) { struct pool_replica *rep = psf->poolset->replica[r]; for (unsigned p = 0; p < rep->nparts; ++p) { struct pool_set_part *part = &rep->part[p]; struct pool_hdr *hdr = part->hdr; assert(hdr->major == OBJ_FORMAT_MAJOR); hdr->major = htole32(OBJ_FORMAT_MAJOR + 1); util_checksum(hdr, sizeof(*hdr), &hdr->checksum, 1); pmem_msync(hdr, sizeof(struct pool_hdr)); } } pool_set_file_unmap_headers(psf); pool_set_close: pool_set_file_close(psf); return ret; } /* * pmemobj_convert_try_open - return if a pool is openable by this pmdk verison */ int pmemobj_convert_try_open(char *path) { PMEMobjpool *pop = pmemobj_open(path, NULL); if (!pop) return 1; pmemobj_close(pop); return 0; } pmdk-convert-1.7/pmemobj_convert_v3.c000066400000000000000000000171371354444011500177510ustar00rootroot00000000000000/* * Copyright 2014-2019, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include "libpmem.h" #include "pmemobj_convert.h" #include "libpmemobj.h" #include "set.h" #include "common.h" #include "output.h" /* * outv_err_vargs -- print error message */ void outv_err_vargs(const char *fmt, va_list ap) { fprintf(stderr, "error: "); vfprintf(stderr, fmt, ap); if (!strchr(fmt, '\n')) fprintf(stderr, "\n"); } /* * outv_err -- print error message */ void outv_err(const char *fmt, ...) { va_list ap; va_start(ap, fmt); outv_err_vargs(fmt, ap); va_end(ap); } /* * pool_set_file_unmap_headers -- unmap headers of each pool set part file */ static void pool_set_file_unmap_headers(struct pool_set_file *file) { if (!file->poolset) return; for (unsigned r = 0; r < file->poolset->nreplicas; r++) { struct pool_replica *rep = file->poolset->replica[r]; for (unsigned p = 0; p < rep->nparts; p++) { struct pool_set_part *part = &rep->part[p]; util_unmap_hdr(part); } } } /* * pool_set_file_map_headers -- map headers of each pool set part file */ static int pool_set_file_map_headers(struct pool_set_file *file, int rdonly) { if (!file->poolset) return -1; int flags = rdonly ? MAP_PRIVATE : MAP_SHARED; for (unsigned r = 0; r < file->poolset->nreplicas; r++) { struct pool_replica *rep = file->poolset->replica[r]; for (unsigned p = 0; p < rep->nparts; p++) { struct pool_set_part *part = &rep->part[p]; if (util_map_hdr(part, flags, 0)) { part->hdr = NULL; goto err; } } } return 0; err: pool_set_file_unmap_headers(file); return -1; } struct pmemobjpool_13 { struct pool_hdr hdr; /* memory pool header */ /* persistent part of PMEMOBJ pool descriptor (2kB) */ char layout[PMEMOBJ_MAX_LAYOUT]; uint64_t lanes_offset; uint64_t nlanes; uint64_t heap_offset; uint64_t heap_size; unsigned char unused[OBJ_DSC_P_UNUSED]; /* must be zero */ uint64_t checksum; /* checksum of above fields */ uint64_t root_offset; /* unique runID for this program run - persistent but not checksummed */ uint64_t run_id; uint64_t root_size; /* * These flags can be set from a conversion tool and are set only for * the first recovery of the pool. */ uint64_t conversion_flags; char pmem_reserved[512]; /* must be zeroed */ void *addr; /* mapped region */ /* other stuff, not neededed for anything in conversion */ }; static uint64_t obj_get_root_size(struct pmemobjpool *pop) { if (pop->root_offset == 0) return 0; uint64_t off = pop->root_offset - sizeof(struct oob_header); struct oob_header *hdr = (struct oob_header *)((uintptr_t)pop + off); return hdr->size & ~OBJ_INTERNAL_OBJECT_MASK; } static void pmemobj_convert_persist(const void *addr, size_t size) { /* device dax */ pmem_persist(addr, size); /* * fs dax / nonpmem, will fail for ddax, but it doesn't * matter */ pmem_msync(addr, size); } /* * pmemobj_convert - convert a pool to the next layout version */ const char * pmemobj_convert(const char *path, unsigned force) { /* open the pool and perform recovery */ PMEMobjpool *pop = pmemobj_open(path, NULL); if (!pop) return pmemobj_errormsg(); /* now recovery state is clean, so we can zero it out */ struct lane_layout *lanes = (struct lane_layout *)((char *)pop + pop->lanes_offset); memset(lanes, 0, pop->nlanes * sizeof(struct lane_layout)); pmemobj_persist(pop, lanes, pop->nlanes * sizeof(struct lane_layout)); uint64_t root_size = obj_get_root_size(pop); pmemobj_close(pop); const char *ret = NULL; struct pmem_pool_params params; if (pmem_pool_parse_params(path, ¶ms, 1)) return get_error("cannot open pool: %s", strerror(errno)); struct pool_set_file *psf = pool_set_file_open(path, 0, 1); if (psf == NULL) { return get_error("pool_set_file_open failed: %s", strerror(errno)); } if (psf->poolset->remote) { ret = get_error("Conversion of remotely replicated pools is " "currently not supported. Remove the replica first"); goto pool_set_close; } void *addr = pool_set_file_map(psf, 0); if (addr == NULL) { ret = "mapping file failed"; goto pool_set_close; } struct pool_hdr *phdr = addr; uint32_t m = le32toh(phdr->major); if (m != OBJ_FORMAT_MAJOR) { /* shouldn't be possible, because pool open succeeded earlier */ ret = get_error("invalid pool version: %d", m); goto pool_set_close; } if (pool_set_file_map_headers(psf, 0)) { ret = get_error("mapping headers failed: %s", strerror(errno)); goto pool_set_close; } /* need to update every header of every part */ for (unsigned r = 0; r < psf->poolset->nreplicas; ++r) { struct pool_replica *rep = psf->poolset->replica[r]; struct pool_set_part *part0 = &rep->part[0]; struct pmemobjpool_13 *pop13 = (struct pmemobjpool_13 *)part0->addr; assert(memcmp(pop13->hdr.signature, "PMEMOBJ\0", 8) == 0); /* * We don't have to rely on 1.3 recovery, because we already * performed it using 1.2, so we can set conversion flags to 0. */ pop13->conversion_flags = 0; pmemobj_convert_persist(&pop13->conversion_flags, sizeof(pop13->conversion_flags)); /* zero out the pmem reserved part of the header */ memset(pop13->pmem_reserved, 0, sizeof(pop13->pmem_reserved)); pmemobj_convert_persist(pop13->pmem_reserved, sizeof(pop13->pmem_reserved)); pop13->root_size = root_size; pmemobj_convert_persist(&pop13->root_size, sizeof(pop13->root_size)); for (unsigned p = 0; p < rep->nparts; ++p) { struct pool_set_part *part = &rep->part[p]; struct pool_hdr *hdr = part->hdr; assert(hdr->major == OBJ_FORMAT_MAJOR); hdr->major = htole32(OBJ_FORMAT_MAJOR + 1); util_checksum(hdr, sizeof(*hdr), &hdr->checksum, 1); pmemobj_convert_persist(hdr, sizeof(struct pool_hdr)); } } pool_set_file_unmap_headers(psf); pool_set_close: pool_set_file_close(psf); return ret; } /* * pmemobj_convert_try_open - return if a pool is openable by this pmdk verison */ int pmemobj_convert_try_open(char *path) { PMEMobjpool *pop = pmemobj_open(path, NULL); if (!pop) return 1; pmemobj_close(pop); return 0; } pmdk-convert-1.7/pmemobj_convert_v4.c000066400000000000000000000130041354444011500177370ustar00rootroot00000000000000/* * Copyright 2014-2019, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include "libpmem.h" #include "pmemobj_convert.h" #include "libpmemobj.h" #include "set.h" #include "common.h" #include "output.h" /* * pool_set_file_unmap_headers -- unmap headers of each pool set part file */ static void pool_set_file_unmap_headers(struct pool_set_file *file) { if (!file->poolset) return; for (unsigned r = 0; r < file->poolset->nreplicas; r++) { struct pool_replica *rep = file->poolset->replica[r]; for (unsigned p = 0; p < rep->nparts; p++) { struct pool_set_part *part = &rep->part[p]; util_unmap_hdr(part); } } } /* * pool_set_file_map_headers -- map headers of each pool set part file */ static int pool_set_file_map_headers(struct pool_set_file *file, int rdonly) { if (!file->poolset) return -1; int flags = rdonly ? MAP_PRIVATE : MAP_SHARED; for (unsigned r = 0; r < file->poolset->nreplicas; r++) { struct pool_replica *rep = file->poolset->replica[r]; for (unsigned p = 0; p < rep->nparts; p++) { struct pool_set_part *part = &rep->part[p]; if (util_map_hdr(part, flags, 0)) { part->hdr = NULL; goto err; } } } return 0; err: pool_set_file_unmap_headers(file); return -1; } static void pmemobj_convert_persist(const void *addr, size_t size) { /* device dax */ pmem_persist(addr, size); /* * fs dax / nonpmem, will fail for ddax, but it doesn't * matter */ pmem_msync(addr, size); } /* * pmemobj_convert - convert a pool to the next layout version */ const char * pmemobj_convert(const char *path, unsigned force) { /* open the pool and perform recovery */ PMEMobjpool *pop = pmemobj_open(path, NULL); if (!pop) return pmemobj_errormsg(); /* now recovery state is clean, so we can zero it out */ struct lane_layout *lanes = (struct lane_layout *)((char *)pop + pop->lanes_offset); memset(lanes, 0, pop->nlanes * sizeof(struct lane_layout)); pmemobj_persist(pop, lanes, pop->nlanes * sizeof(struct lane_layout)); pmemobj_close(pop); const char *ret = NULL; struct pmem_pool_params params; if (pmem_pool_parse_params(path, ¶ms, 1)) return get_error("cannot open pool: %s", strerror(errno)); struct pool_set_file *psf = pool_set_file_open(path, 0, 1); if (psf == NULL) { return get_error("pool_set_file_open failed: %s", strerror(errno)); } if (psf->poolset->remote) { ret = get_error("Conversion of remotely replicated pools is " "currently not supported. Remove the replica first"); goto pool_set_close; } void *addr = pool_set_file_map(psf, 0); if (addr == NULL) { ret = "mapping file failed"; goto pool_set_close; } struct pool_hdr *phdr = addr; uint32_t m = le32toh(phdr->major); if (m != OBJ_FORMAT_MAJOR) { /* shouldn't be possible, because pool open succeeded earlier */ ret = get_error("invalid pool version: %d", m); goto pool_set_close; } if (pool_set_file_map_headers(psf, 0)) { ret = get_error("mapping headers failed: %s", strerror(errno)); goto pool_set_close; } /* need to update every header of every part */ for (unsigned r = 0; r < psf->poolset->nreplicas; ++r) { struct pool_replica *rep = psf->poolset->replica[r]; for (unsigned p = 0; p < rep->nparts; ++p) { struct pool_set_part *part = &rep->part[p]; struct pool_hdr *hdr = part->hdr; assert(hdr->major == OBJ_FORMAT_MAJOR); hdr->major = htole32(OBJ_FORMAT_MAJOR + 1); util_checksum(hdr, sizeof(*hdr), &hdr->checksum, 1, POOL_HDR_CSUM_END_OFF); pmemobj_convert_persist(hdr, sizeof(struct pool_hdr)); if (le32toh(hdr->incompat_features) & POOL_FEAT_SINGLEHDR) break; } } pool_set_file_unmap_headers(psf); pool_set_close: pool_set_file_close(psf); return ret; } /* * pmemobj_convert_try_open - return if a pool is openable by this pmdk verison */ int pmemobj_convert_try_open(char *path) { PMEMobjpool *pop = pmemobj_open(path, NULL); if (!pop) return 1; pmemobj_close(pop); return 0; } pmdk-convert-1.7/pmemobj_convert_v4.def000066400000000000000000000032611354444011500202570ustar00rootroot00000000000000;;;; Begin Copyright Notice ; ; Copyright 2018, Intel Corporation ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; ; * Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; ; * Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in ; the documentation and/or other materials provided with the ; distribution. ; ; * Neither the name of the copyright holder nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ; ;;;; End Copyright Notice LIBRARY pmemobj_convert_v4 VERSION 1.0 EXPORTS pmemobj_convert pmemobj_convert_try_open pmdk-convert-1.7/pmemobj_convert_v5.c000066400000000000000000000131451354444011500177460ustar00rootroot00000000000000/* * Copyright 2014-2019, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include "libpmem.h" #include "pmemobj_convert.h" #include "libpmemobj.h" #include "set.h" #include "common.h" #include "output.h" /* * pool_set_file_unmap_headers -- unmap headers of each pool set part file */ static void pool_set_file_unmap_headers(struct pool_set_file *file) { if (!file->poolset) return; for (unsigned r = 0; r < file->poolset->nreplicas; r++) { struct pool_replica *rep = file->poolset->replica[r]; for (unsigned p = 0; p < rep->nparts; p++) { struct pool_set_part *part = &rep->part[p]; util_unmap_hdr(part); } } } /* * pool_set_file_map_headers -- map headers of each pool set part file */ static int pool_set_file_map_headers(struct pool_set_file *file, int rdonly) { if (!file->poolset) return -1; int flags = rdonly ? MAP_PRIVATE : MAP_SHARED; for (unsigned r = 0; r < file->poolset->nreplicas; r++) { struct pool_replica *rep = file->poolset->replica[r]; for (unsigned p = 0; p < rep->nparts; p++) { struct pool_set_part *part = &rep->part[p]; if (util_map_hdr(part, flags, 0)) { part->hdr = NULL; goto err; } } } return 0; err: pool_set_file_unmap_headers(file); return -1; } /* * pmemobj_convert_persist - forced persist without checking * if it is pmem or not */ static void pmemobj_convert_persist(const void *addr, size_t size) { /* device dax */ pmem_persist(addr, size); /* * fs dax / nonpmem, will fail for ddax, but it doesn't * matter */ pmem_msync(addr, size); } /* * pmemobj_convert - convert a pool to the next layout version */ const char * pmemobj_convert(const char *path, unsigned force) { /* open the pool and perform recovery */ PMEMobjpool *pop = pmemobj_open(path, NULL); if (!pop) return pmemobj_errormsg(); /* now recovery state is clean, so we can zero it out */ struct lane_layout *lanes = (struct lane_layout *)((char *)pop + pop->lanes_offset); memset(lanes, 0, pop->nlanes * sizeof(struct lane_layout)); pmemobj_persist(pop, lanes, pop->nlanes * sizeof(struct lane_layout)); pmemobj_close(pop); const char *ret = NULL; struct pmem_pool_params params; if (pmem_pool_parse_params(path, ¶ms, 1)) return get_error("cannot open pool: %s", strerror(errno)); struct pool_set_file *psf = pool_set_file_open(path, 0, 1); if (psf == NULL) { return get_error("pool_set_file_open failed: %s", strerror(errno)); } if (psf->poolset->remote) { ret = get_error("Conversion of remotely replicated pools is " "currently not supported. Remove the replica first"); goto pool_set_close; } void *addr = pool_set_file_map(psf, 0); if (addr == NULL) { ret = "mapping file failed"; goto pool_set_close; } struct pool_hdr *phdr = addr; uint32_t m = le32toh(phdr->major); if (m != OBJ_FORMAT_MAJOR) { /* shouldn't be possible, because pool open succeeded earlier */ ret = get_error("invalid pool version: %d", m); goto pool_set_close; } if (pool_set_file_map_headers(psf, 0)) { ret = get_error("mapping headers failed: %s", strerror(errno)); goto pool_set_close; } /* need to update every header of every part */ for (unsigned r = 0; r < psf->poolset->nreplicas; ++r) { struct pool_replica *rep = psf->poolset->replica[r]; for (unsigned p = 0; p < rep->nparts; ++p) { struct pool_set_part *part = &rep->part[p]; struct pool_hdr *hdr = part->hdr; assert(hdr->major == OBJ_FORMAT_MAJOR); hdr->major = htole32(OBJ_FORMAT_MAJOR + 1); util_checksum(hdr, sizeof(*hdr), &hdr->checksum, 1, POOL_HDR_CSUM_END_OFF(hdr)); pmemobj_convert_persist(hdr, sizeof(struct pool_hdr)); if (le32toh(hdr->features.incompat) & POOL_FEAT_SINGLEHDR) break; } } pool_set_file_unmap_headers(psf); pool_set_close: pool_set_file_close(psf); return ret; } /* * pmemobj_convert_try_open - return if a pool is openable by this pmdk verison */ int pmemobj_convert_try_open(char *path) { PMEMobjpool *pop = pmemobj_open(path, NULL); if (!pop) return 1; pmemobj_close(pop); return 0; } pmdk-convert-1.7/pmemobj_convert_v5.def000066400000000000000000000032611354444011500202600ustar00rootroot00000000000000;;;; Begin Copyright Notice ; ; Copyright 2018, Intel Corporation ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; ; * Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; ; * Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in ; the documentation and/or other materials provided with the ; distribution. ; ; * Neither the name of the copyright holder nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ; ;;;; End Copyright Notice LIBRARY pmemobj_convert_v5 VERSION 1.0 EXPORTS pmemobj_convert pmemobj_convert_try_open pmdk-convert-1.7/pmemobj_convert_v6.c000066400000000000000000000041101354444011500177370ustar00rootroot00000000000000/* * Copyright 2019, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include "libpmemobj.h" #include "pmemobj_convert.h" /* * pmemobj_convert - convert a pool to the next layout version */ const char * pmemobj_convert(const char *path, unsigned force) { errno = ENOTSUP; return "Conversion to layout v7 is not implemented yet"; } /* * pmemobj_convert_try_open - return if a pool is openable by this pmdk verison */ int pmemobj_convert_try_open(char *path) { PMEMobjpool *pop = pmemobj_open(path, NULL); if (!pop) return 1; pmemobj_close(pop); return 0; } pmdk-convert-1.7/pmemobj_convert_v6.def000066400000000000000000000032611354444011500202610ustar00rootroot00000000000000;;;; Begin Copyright Notice ; ; Copyright 2019, Intel Corporation ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; ; * Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; ; * Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in ; the documentation and/or other materials provided with the ; distribution. ; ; * Neither the name of the copyright holder nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ; ;;;; End Copyright Notice LIBRARY pmemobj_convert_v6 VERSION 1.0 EXPORTS pmemobj_convert pmemobj_convert_try_open pmdk-convert-1.7/tests/000077500000000000000000000000001354444011500151355ustar00rootroot00000000000000pmdk-convert-1.7/tests/CMakeLists.txt000066400000000000000000000753551354444011500177140ustar00rootroot00000000000000# # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${CMAKE_SOURCE_DIR}/utils/utils.cmake) set(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/test CACHE STRING "working directory for tests") option(TESTS_USE_FORCED_PMEM "let tests force enable or force disable use of optimized flush in libpmemobj (to speed them up)" OFF) set(DEVICE_DAX_PATHS "" CACHE STRING "for tests that require raw dax devices without a file system. Some tests might require two DAX devices. Example: '/dev/dax1.0 /dev/dax2.0'") if(WIN32) set(CDB_PATH "" CACHE PATH "requied for windows tests with cdb debugger") endif() set(GLOBAL_TEST_ARGS -DPARENT_DIR=${TEST_DIR}/ -DTESTS_USE_FORCED_PMEM=${TESTS_USE_FORCED_PMEM} -DDEVICE_DAX_PATHS=${DEVICE_DAX_PATHS} -DCDB_PATH=${CDB_PATH}) # convert the DEVICE_DAX_PATHS list to the array if(DEVICE_DAX_PATHS) string(REPLACE " " ";" DEVICE_DAX_PATHS ${DEVICE_DAX_PATHS}) endif() list(LENGTH DEVICE_DAX_PATHS devdax_num) if(TRACE_TESTS) set(GLOBAL_TEST_ARGS ${GLOBAL_TEST_ARGS} --trace-expand) endif() # Configures test ${name} function(test name file) add_test(NAME ${name} COMMAND ${CMAKE_COMMAND} ${GLOBAL_TEST_ARGS} -DTEST_NAME=${name} -DSRC_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBIN_DIR=${CMAKE_CURRENT_BINARY_DIR}/${file} -DVERSIONS=${VERSIONS} -DCONFIG=$ -P ${CMAKE_CURRENT_SOURCE_DIR}/${file}.cmake) set_tests_properties(${name} PROPERTIES ENVIRONMENT "LC_ALL=C;PATH=$ENV{PATH}") endfunction() # Finding cdb executable debugger file and setting path to it function(set_cdb_executable) if(EXISTS ${CDB_PATH}) find_program(CDB_EXE cdb.exe ${CDB_PATH}) if(NOT CDB_EXE) message(WARNING "CDB Debugger not found!") endif() else() unset(CDB_EXE) endif() endfunction() if(WIN32) set(OPEN_SOURCE openW.c) set(CREATE_SOURCE createW.c) else() set(OPEN_SOURCE open.c) set(CREATE_SOURCE create.c) endif() if(BUILD_CONVERT_V1) set(VERSIONS "${VERSIONS} 1.0") endif() if(BUILD_CONVERT_V2) set(VERSIONS "${VERSIONS} 1.1") endif() if(BUILD_CONVERT_V3) set(VERSIONS "${VERSIONS} 1.2") endif() if(BUILD_13) set(VERSIONS "${VERSIONS} 1.3") endif() if(BUILD_CONVERT_V4) set(VERSIONS "${VERSIONS} 1.4") endif() if(BUILD_15) set(VERSIONS "${VERSIONS} 1.5") endif() if(BUILD_CONVERT_V5) set(VERSIONS "${VERSIONS} 1.6") endif() if(BUILD_CONVERT_V6) set(VERSIONS "${VERSIONS} 1.7") endif() if(BUILD_CONVERT_V1) add_executable(create_10 ${CREATE_SOURCE}) target_include_directories(create_10 PRIVATE ${CMAKE_SOURCE_DIR}/${VER10}/src/include) target_link_libraries(create_10 PRIVATE libpmem-convert) target_link_libraries(create_10 PRIVATE pmemobj_10) add_executable(open_10 open.c) target_include_directories(open_10 PRIVATE ${CMAKE_SOURCE_DIR}/${VER10}/src/include) target_link_libraries(open_10 PRIVATE libpmem-convert) target_link_libraries(open_10 PRIVATE pmemobj_10) test("1.0_pool_conversion" basic10) endif() if(BUILD_CONVERT_V2) add_executable(create_11 ${CREATE_SOURCE}) target_include_directories(create_11 PRIVATE ${CMAKE_SOURCE_DIR}/${VER11}/src/include) target_link_libraries(create_11 PRIVATE libpmem-convert) target_link_libraries(create_11 PRIVATE pmemobj_11) add_executable(open_11 ${OPEN_SOURCE}) target_include_directories(open_11 PRIVATE ${CMAKE_SOURCE_DIR}/${VER11}/src/include) target_link_libraries(open_11 PRIVATE libpmem-convert) target_link_libraries(open_11 PRIVATE pmemobj_11) test("1.1_pool_conversion" basic11) endif() if(BUILD_CONVERT_V3) add_executable(create_12 ${CREATE_SOURCE}) target_include_directories(create_12 PRIVATE ${CMAKE_SOURCE_DIR}/${VER12}/src/include) target_link_libraries(create_12 PRIVATE libpmem-convert) target_link_libraries(create_12 PRIVATE pmemobj_12) add_executable(open_12 ${OPEN_SOURCE}) target_include_directories(open_12 PRIVATE ${CMAKE_SOURCE_DIR}/${VER12}/src/include) target_link_libraries(open_12 PRIVATE libpmem-convert) target_link_libraries(open_12 PRIVATE pmemobj_12) test("1.2_pool_conversion" basic12) endif() if(BUILD_13) add_executable(create_13 ${CREATE_SOURCE}) target_include_directories(create_13 PRIVATE ${CMAKE_SOURCE_DIR}/${VER13}/src/include) target_link_libraries(create_13 PRIVATE libpmem-convert) target_link_libraries(create_13 PRIVATE pmemobj_13) add_executable(open_13 ${OPEN_SOURCE}) target_include_directories(open_13 PRIVATE ${CMAKE_SOURCE_DIR}/${VER13}/src/include) target_link_libraries(open_13 PRIVATE libpmem-convert) target_link_libraries(open_13 PRIVATE pmemobj_13) test("1.3_pool_conversion" basic13) if(WIN32) # on windows dll and executable must be in the same dir add_custom_command(TARGET open_13 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) endif() endif() if(BUILD_CONVERT_V4) add_executable(create_14 ${CREATE_SOURCE}) target_include_directories(create_14 PRIVATE ${CMAKE_SOURCE_DIR}/${VER14}/src/include) target_link_libraries(create_14 PRIVATE libpmem-convert) target_link_libraries(create_14 PRIVATE pmemobj_14) add_executable(open_14 ${OPEN_SOURCE}) target_include_directories(open_14 PRIVATE ${CMAKE_SOURCE_DIR}/${VER14}/src/include) target_link_libraries(open_14 PRIVATE libpmem-convert) target_link_libraries(open_14 PRIVATE pmemobj_14) test("1.4_pool_conversion" basic14) if(WIN32) # on windows dll and executable must be in the same dir add_custom_command(TARGET open_14 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) endif() endif() if(BUILD_15) add_executable(create_15 ${CREATE_SOURCE}) target_include_directories(create_15 PRIVATE ${CMAKE_SOURCE_DIR}/${VER15}/src/include) target_link_libraries(create_15 PRIVATE libpmem-convert) target_link_libraries(create_15 PRIVATE pmemobj_15) add_executable(open_15 ${OPEN_SOURCE}) target_include_directories(open_15 PRIVATE ${CMAKE_SOURCE_DIR}/${VER15}/src/include) target_link_libraries(open_15 PRIVATE libpmem-convert) target_link_libraries(open_15 PRIVATE pmemobj_15) test("1.5_pool_conversion" basic15) if(WIN32) # on windows dll and executable must be in the same dir add_custom_command(TARGET open_15 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) endif() endif() if(BUILD_CONVERT_V5) add_executable(create_16 ${CREATE_SOURCE}) target_include_directories(create_16 PRIVATE ${CMAKE_SOURCE_DIR}/${VER16}/src/include) target_link_libraries(create_16 PRIVATE libpmem-convert) target_link_libraries(create_16 PRIVATE pmemobj_16) add_executable(open_16 ${OPEN_SOURCE}) target_include_directories(open_16 PRIVATE ${CMAKE_SOURCE_DIR}/${VER16}/src/include) target_link_libraries(open_16 PRIVATE libpmem-convert) target_link_libraries(open_16 PRIVATE pmemobj_16) test("1.6_pool_conversion" basic16) if(WIN32) # on windows dll and executable must be in the same dir add_custom_command(TARGET open_16 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) add_custom_command(TARGET open_16 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $/libpmem-convert.dll $) endif() endif() if(BUILD_CONVERT_V6) add_executable(create_17 ${CREATE_SOURCE}) target_include_directories(create_17 PRIVATE ${CMAKE_SOURCE_DIR}/${VER17}/src/include) target_link_libraries(create_17 PRIVATE libpmem-convert) target_link_libraries(create_17 PRIVATE pmemobj_17) add_executable(open_17 ${OPEN_SOURCE}) target_include_directories(open_17 PRIVATE ${CMAKE_SOURCE_DIR}/${VER17}/src/include) target_link_libraries(open_17 PRIVATE libpmem-convert) target_link_libraries(open_17 PRIVATE pmemobj_17) if(WIN32) # on windows dll and executable must be in the same dir add_custom_command(TARGET open_17 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) add_custom_command(TARGET open_17 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $/libpmem-convert.dll $) endif() set(COMMON_SOURCES ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/alloc.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/badblock.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/file.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/mmap.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/pool_hdr.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/out.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/os_dimm_none.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/set.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/shutdown_state.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/util.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/uuid.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/ctl_cow.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/ctl_fallocate.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/ctl_sds.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/ctl.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/ctl_prefault.c ) if(WIN32) set(COMMON_SOURCES ${COMMON_SOURCES} ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/badblock_none.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/file_windows.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/fs_windows.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/mmap_windows.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/os_deep_windows.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/os_thread_windows.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/os_windows.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/util_windows.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/uuid_windows.c ) else() set(COMMON_SOURCES ${COMMON_SOURCES} ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/badblock_ndctl.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/extent_linux.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/file_posix.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/fs_posix.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/mmap_posix.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/os_deep_linux.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/os_posix.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/os_thread_posix.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/util_posix.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common/uuid_linux.c ) endif() function(build_libpmemblk_17) set(BLK_SOURCES ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemblk/blk.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemblk/btt.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemblk/libpmemblk.c ${COMMON_SOURCES} ) if(WIN32) set(BLK_SOURCES ${BLK_SOURCES} ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemblk/libpmemblk_main.c ) endif() if(MSVC) FILE(READ ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemblk/libpmemblk.def DEFFILE) string(REPLACE "libpmemblk" "pmemblk_17" DEFFILE "${DEFFILE}") FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pmemblk_17.def "${DEFFILE}") add_library(pmemblk_17 SHARED ${BLK_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/pmemblk_17.def) target_compile_options(pmemblk_17 PRIVATE /FI"${CMAKE_SOURCE_DIR}/${VER17}/src/windows/include/platform.h") else() add_library(pmemblk_17 SHARED ${BLK_SOURCES}) endif() target_compile_definitions(pmemblk_17 PRIVATE SRCVERSION="${MAX_STABLE}") target_compile_definitions(pmemblk_17 PRIVATE PMDK_UTF8_API) target_compile_definitions(pmemblk_17 PRIVATE _PMEMBLK_INTRNL) target_include_directories(pmemblk_17 PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/include) target_include_directories(pmemblk_17 PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemblk) target_include_directories(pmemblk_17 PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common) target_include_directories(pmemblk_17 PRIVATE ${PMEM_INCLUDE_DIRS}) if(WIN32) target_include_directories(pmemblk_17 PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/windows/include/) target_include_directories(pmemblk_17 PRIVATE ${CMAKE_SOURCE_DIR}/include/) endif() target_link_libraries(pmemblk_17 PRIVATE libpmem-convert) target_link_libraries(pmemblk_17 PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries(pmemblk_17 PRIVATE ${CMAKE_THREAD_LIBS_INIT}) if(NOT MSVC) FILE(READ ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemblk/libpmemblk.link.in LINKFILE) if(DEFINED ENV{FAULT_INJECTION}) string(REPLACE "fault_injection;" "libpmemblk_inject_fault_at;\n\t\tlibpmemblk_fault_injection_enabled;" LINKFILE "${LINKFILE}") else() string(REPLACE "fault_injection;" "" LINKFILE "${LINKFILE}") endif() FILE(WRITE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemblk/libpmemblk.link "${LINKFILE}") target_link_libraries(pmemblk_17 PRIVATE -Wl,--version-script=${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemblk/libpmemblk.link) endif() endfunction(build_libpmemblk_17) build_libpmemblk_17() function(build_libpmemlog_17) set(LOG_SOURCES ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemlog/libpmemlog.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemlog/log.c ${COMMON_SOURCES} ) if(WIN32) set(LOG_SOURCES ${LOG_SOURCES} ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemlog/libpmemlog_main.c ) endif() if(MSVC) FILE(READ ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemlog/libpmemlog.def DEFFILE) string(REPLACE "libpmemlog" "pmemlog_17" DEFFILE "${DEFFILE}") FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pmemlog_17.def "${DEFFILE}") add_library(pmemlog_17 SHARED ${LOG_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/pmemlog_17.def) target_compile_options(pmemlog_17 PRIVATE /FI"${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/windows/include/platform.h") else() add_library(pmemlog_17 SHARED ${LOG_SOURCES}) endif() target_compile_definitions(pmemlog_17 PRIVATE SRCVERSION="${MAX_STABLE}") target_compile_definitions(pmemlog_17 PRIVATE PMDK_UTF8_API) target_compile_definitions(pmemlog_17 PRIVATE _PMEMLOG_INTRNL) target_include_directories(pmemlog_17 PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/include) target_include_directories(pmemlog_17 PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemlog) target_include_directories(pmemlog_17 PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common) target_include_directories(pmemlog_17 PRIVATE ${PMEM_INCLUDE_DIRS}) if(WIN32) target_include_directories(pmemlog_17 PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/windows/include/) target_include_directories(pmemlog_17 PRIVATE ${CMAKE_SOURCE_DIR}/include/) endif() target_link_libraries(pmemlog_17 PRIVATE libpmem-convert) target_link_libraries(pmemlog_17 PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries(pmemlog_17 PRIVATE ${CMAKE_THREAD_LIBS_INIT}) if(NOT MSVC) FILE(READ ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemlog/libpmemlog.link.in LINKFILE) if(DEFINED ENV{FAULT_INJECTION}) string(REPLACE "fault_injection;" "libpmemblk_inject_fault_at;\n\t\tlibpmemblk_fault_injection_enabled;" LINKFILE "${LINKFILE}") else() string(REPLACE "fault_injection;" "" LINKFILE "${LINKFILE}") endif() FILE(WRITE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemlog/libpmemlog.link "${LINKFILE}") target_link_libraries(pmemlog_17 PRIVATE -Wl,--version-script=${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemlog/libpmemlog.link) endif() endfunction(build_libpmemlog_17) build_libpmemlog_17() function(build_pmemspoil) set(PMEMSPOIL_SOURCES ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/test/tools/pmemspoil/spoil.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/common.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemblk/btt.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/output.c ${COMMON_SOURCES} ) if(WIN32) set(PMEMSPOIL_SOURCES ${PMEMSPOIL_SOURCES} ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/windows/getopt/getopt.c ) endif() add_executable(pmemspoil ${PMEMSPOIL_SOURCES}) if(WIN32) target_include_directories(pmemspoil PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/windows/getopt) target_include_directories(pmemspoil PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/windows/include) endif() if(MSVC) target_include_directories(pmemspoil PRIVATE ${CMAKE_SOURCE_DIR}/include/) target_compile_options(pmemspoil PRIVATE /FI"${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/windows/include/platform.h") endif() target_compile_definitions(pmemspoil PRIVATE SRCVERSION="${MAX_STABLE}") target_compile_definitions(pmemspoil PRIVATE PMDK_UTF8_API) target_compile_definitions(pmemspoil PRIVATE LIBDIR="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") target_include_directories(pmemspoil PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/include) target_include_directories(pmemspoil PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common) target_include_directories(pmemspoil PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemobj) target_include_directories(pmemspoil PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemlog) target_include_directories(pmemspoil PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemblk) target_include_directories(pmemspoil PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool) target_link_libraries(pmemspoil PRIVATE ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(pmemspoil PRIVATE libpmem-convert) target_link_libraries(pmemspoil PRIVATE pmemobj_17) if(WIN32) # on windows dll and executable must be in the same dir add_custom_command(TARGET pmemspoil POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) endif() endfunction(build_pmemspoil) build_pmemspoil() test("spoiled_pool_hdr" spoiled_pool_hdr) function(build_pmempool_convert) set(PMEMPOOL_SOURCES ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/pmempool.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/check.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/common.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/convert.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/create.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/dump.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/feature.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/info.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/info_blk.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/info_obj.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/info_log.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/output.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/rm.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/synchronize.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool/transform.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemblk/btt.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemobj/critnib.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemobj/ulog.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemobj/memblock.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemobj/alloc_class.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemobj/memops.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemobj/heap.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemobj/bucket.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemobj/recycler.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemobj/container_seglists.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemobj/container_ravl.c ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemobj/ravl.c ${COMMON_SOURCES} ) if(NOT WIN32) set(PMEMPOOL_SOURCES ${PMEMPOOL_SOURCES} ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/librpmem/rpmem_util.c) endif() if(WIN32) add_executable(pmempool-convert ${PMEMPOOL_SOURCES} ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/windows/getopt/getopt.c) target_include_directories(pmempool-convert PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/windows/getopt/) target_include_directories(pmempool-convert PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/windows/include/) else() add_executable(pmempool-convert ${PMEMPOOL_SOURCES}) endif() if(MSVC) target_include_directories(pmempool-convert PRIVATE ${CMAKE_SOURCE_DIR}/include/) target_compile_options(pmempool-convert PRIVATE /FI"${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/windows/include/platform.h") endif() target_compile_definitions(pmempool-convert PRIVATE SRCVERSION="${MAX_STABLE}") target_compile_definitions(pmempool-convert PRIVATE PMDK_UTF8_API) target_compile_definitions(pmempool-convert PRIVATE LIBDIR="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") target_include_directories(pmempool-convert PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/include) target_include_directories(pmempool-convert PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/common) target_include_directories(pmempool-convert PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemlog) target_include_directories(pmempool-convert PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemblk) target_include_directories(pmempool-convert PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmemobj) target_include_directories(pmempool-convert PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/libpmempool) target_include_directories(pmempool-convert PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/rpmem_common) target_include_directories(pmempool-convert PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/librpmem) target_include_directories(pmempool-convert PRIVATE ${CMAKE_SOURCE_DIR}/${MAX_STABLE}/src/tools/pmempool) target_link_libraries(pmempool-convert PRIVATE ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(pmempool-convert PRIVATE ${CMAKE_DL_LIBS}) target_link_libraries(pmempool-convert PRIVATE libpmem-convert) target_link_libraries(pmempool-convert PRIVATE libpmempool-convert) target_link_libraries(pmempool-convert PRIVATE pmemobj_17) target_link_libraries(pmempool-convert PRIVATE pmemblk_17) target_link_libraries(pmempool-convert PRIVATE pmemlog_17) if(WIN32) # on windows dll and executable must be in the same dir add_custom_command(TARGET pmempool-convert POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) endif() endfunction(build_pmempool_convert) build_pmempool_convert() test("compare_replicas" compare_replicas) endif() if(NOT WIN32) if(BUILD_CONVERT_V1) add_executable(transaction_10 transaction.c) disable_optimization(transaction_10) target_include_directories(transaction_10 PRIVATE ${CMAKE_SOURCE_DIR}/${VER10}/src/include) target_link_libraries(transaction_10 PRIVATE libpmem-convert) target_link_libraries(transaction_10 PRIVATE pmemobj_10) endif() if(BUILD_CONVERT_V2) add_executable(transaction_11 transaction.c) disable_optimization(transaction_11) target_include_directories(transaction_11 PRIVATE ${CMAKE_SOURCE_DIR}/${VER11}/src/include) target_link_libraries(transaction_11 PRIVATE libpmem-convert) target_link_libraries(transaction_11 PRIVATE pmemobj_11) endif() if(BUILD_CONVERT_V3) add_executable(transaction_12 transaction.c) disable_optimization(transaction_12) target_include_directories(transaction_12 PRIVATE ${CMAKE_SOURCE_DIR}/${VER12}/src/include) target_link_libraries(transaction_12 PRIVATE libpmem-convert) target_link_libraries(transaction_12 PRIVATE pmemobj_12) endif() if(BUILD_13) add_executable(transaction_13 transaction.c) disable_optimization(transaction_13) target_include_directories(transaction_13 PRIVATE ${CMAKE_SOURCE_DIR}/${VER13}/src/include) target_link_libraries(transaction_13 PRIVATE libpmem-convert) target_link_libraries(transaction_13 PRIVATE pmemobj_13) endif() endif() if(BUILD_CONVERT_V4) add_executable(transaction_14 transaction.c) disable_optimization(transaction_14) target_include_directories(transaction_14 PRIVATE ${CMAKE_SOURCE_DIR}/${VER14}/src/include) target_link_libraries(transaction_14 PRIVATE libpmem-convert) target_link_libraries(transaction_14 PRIVATE pmemobj_14) endif() if(BUILD_15) add_executable(transaction_15 transaction.c) disable_optimization(transaction_15) target_include_directories(transaction_15 PRIVATE ${CMAKE_SOURCE_DIR}/${VER15}/src/include) target_link_libraries(transaction_15 PRIVATE libpmem-convert) target_link_libraries(transaction_15 PRIVATE pmemobj_15) endif() if(BUILD_CONVERT_V5) add_executable(transaction_16 transaction.c) disable_optimization(transaction_16) target_include_directories(transaction_16 PRIVATE ${CMAKE_SOURCE_DIR}/${VER16}/src/include) target_link_libraries(transaction_16 PRIVATE libpmem-convert) target_link_libraries(transaction_16 PRIVATE pmemobj_16) endif() if(BUILD_CONVERT_V6) add_executable(transaction_17 transaction.c) disable_optimization(transaction_17) target_include_directories(transaction_17 PRIVATE ${CMAKE_SOURCE_DIR}/${VER17}/src/include) target_link_libraries(transaction_17 PRIVATE libpmem-convert) target_link_libraries(transaction_17 PRIVATE pmemobj_17) endif() if(MSVC) if(BUILD_CONVERT_V4) # project has to be compile as c++ project so we need to change the flag SET_SOURCE_FILES_PROPERTIES(transaction.c PROPERTIES LANGUAGE CXX) # on windows dll and executable must be in the same dir add_custom_command(TARGET transaction_14 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) add_custom_command(TARGET transaction_14 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $/libpmem-convert.dll $) endif() if(BUILD_CONVERT_V5) # project has to be compile as c++ project so we need to change the flag SET_SOURCE_FILES_PROPERTIES(transaction.c PROPERTIES LANGUAGE CXX) # on windows dll and executable must be in the same dir add_custom_command(TARGET transaction_16 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) add_custom_command(TARGET transaction_16 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $/libpmem-convert.dll $) endif() if(BUILD_CONVERT_V6) # project has to be compile as c++ project so we need to change the flag SET_SOURCE_FILES_PROPERTIES(transaction.c PROPERTIES LANGUAGE CXX) # on windows dll and executable must be in the same dir add_custom_command(TARGET transaction_17 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) add_custom_command(TARGET transaction_17 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $/libpmem-convert.dll $) endif() endif() test("cli_test" cli) add_executable(clean_pool clean.c) target_include_directories(clean_pool PRIVATE ${LIBPMEMPOOL_INCLUDE_DIRS}) target_link_libraries(clean_pool PRIVATE ${LIBPMEMPOOL_LIBRARIES}) file(WRITE ${TEST_DIR}/../tx_intr.lock "") if(NOT WIN32) if(DEVICE_DAX_PATHS) file(WRITE ${TEST_DIR}/../devdax.lock "") endif() test("tx_intr_pool_regfile" tx_intr_pool_regfile) test("tx_intr_poolset_local_2regfiles" tx_intr_poolset_local_2regfiles) test("tx_intr_poolset_local_regfile" tx_intr_poolset_local_regfile) test("tx_intr_poolset_local_regfile_rep_regfile" tx_intr_poolset_local_regfile_rep_regfile) test("tx_intr_poolset_local_2regfiles_rep_3regfiles" tx_intr_poolset_local_2regfiles_rep_3regfiles) test("poolsets_with_remote_replica" remote) if(NOT DEVICE_DAX_PATHS) test("tx_intr_pool_devdax_SKIP_BECAUSE_OF_NO_DEVDAX_DEFINED" skip_test) test("tx_intr_poolset_local_devdax_devdax_SKIP_BECAUSE_OF_NO_DEVDAX_DEFINED" skip_test) else() test("tx_intr_pool_devdax" tx_intr_pool_devdax) test("tx_intr_poolset_local_devdax" tx_intr_poolset_local_devdax) endif() if(devdax_num LESS 2) test("tx_intr_poolset_local_2devdaxes_SKIP_BECAUSE_OF_NOT_ENOUGH_DEVDAX_DEFINED" skip_test) test("tx_intr_poolset_local_devdax_rep_devdax_SKIP_BECAUSE_OF_NOT_ENOUGH_DEVDAX_DEFINED" skip_test) test("tx_intr_poolset_local_2devdaxes_rep_2regfiles_SKIP_BECAUSE_OF_NOT_ENOUGH_DEVDAX_DEFINED" skip_test) test("tx_intr_poolset_local_2regfiles_rep_2devdaxes_SKIP_BECAUSE_OF_NOT_ENOUGH_DEVDAX_DEFINED" skip_test) else() test("tx_intr_poolset_local_2devdaxes" tx_intr_poolset_local_2devdaxes) test("tx_intr_poolset_local_devdax_rep_devdax" tx_intr_poolset_local_devdax_rep_devdax) test("tx_intr_poolset_local_2devdaxes_rep_2regfiles" tx_intr_poolset_local_2devdaxes_rep_2regfiles) test("tx_intr_poolset_local_2regfiles_rep_2devdaxes" tx_intr_poolset_local_2regfiles_rep_2devdaxes) endif() else() if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) set_cdb_executable() if(CDB_EXE) test("tx_intr_pool_regfile" tx_intr_pool_regfile) test("tx_intr_poolset_local_2regfiles" tx_intr_poolset_local_2regfiles) test("tx_intr_poolset_local_regfile" tx_intr_poolset_local_regfile) test("tx_intr_poolset_local_regfile_rep_regfile" tx_intr_poolset_local_regfile_rep_regfile) else() test("tx_intr_pool_regfile_SKIP_BECAUSE_OF_NO_CDB_DEBUGGER" skip_test) test("tx_intr_poolset_local_2regfiles_SKIP_BECAUSE_OF_NO_CDB_DEBUGGER" skip_test) test("tx_intr_poolset_local_regfile_SKIP_BECAUSE_OF_NO_CDB_DEBUGGER" skip_test) test("tx_intr_poolset_local_regfile_rep_regfile_SKIP_BECAUSE_OF_NO_CDB_DEBUGGER" skip_test) endif() else() test("tx_intr_pool_regfile_SKIP_BECAUSE_OF_NO_DEBUG_BUILD_TYPE" skip_test) test("tx_intr_poolset_local_2regfiles_SKIP_BECAUSE_OF_NO_DEBUG_BUILD_TYPE" skip_test) test("tx_intr_poolset_local_regfile_SKIP_BECAUSE_OF_NO_DEBUG_BUILD_TYPE" skip_test) test("tx_intr_poolset_local_regfile_rep_regfile_SKIP_BECAUSE_OF_NO_DEBUG_BUILD_TYPE" skip_test) endif() endif() pmdk-convert-1.7/tests/basic10.cmake000066400000000000000000000066171354444011500173730ustar00rootroot00000000000000# # Copyright 2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) function(test) check_open(${DIR}/pool10 "1.0") # 1.0 -> 1.1 execute(0 ${EXE_DIR}/pmdk-convert --to=1.1 ${DIR}/pool10 -X fail-safety) check_open(${DIR}/pool10 "1.1") # 1.1 -> 1.2 execute(0 ${EXE_DIR}/pmdk-convert --to=1.2 ${DIR}/pool10 -X fail-safety -X 1.2-pmemmutex) check_open(${DIR}/pool10 "1.2") # 1.2 -> 1.3 execute(0 ${EXE_DIR}/pmdk-convert --to=1.3 ${DIR}/pool10 -X fail-safety) check_open(${DIR}/pool10 "1.3 1.4") # 1.3 -> 1.4 execute(0 ${EXE_DIR}/pmdk-convert --to=1.4 ${DIR}/pool10 -X fail-safety) check_open(${DIR}/pool10 "1.3 1.4") # 1.4 -> 1.5 execute(0 ${EXE_DIR}/pmdk-convert --to=1.5 ${DIR}/pool10 -X fail-safety) check_open(${DIR}/pool10 "1.5 1.6") # 1.5 -> 1.6 execute(0 ${EXE_DIR}/pmdk-convert --to=1.6 ${DIR}/pool10 -X fail-safety) check_open(${DIR}/pool10 "1.5 1.6") # 1.6 -> 1.7 execute(0 ${EXE_DIR}/pmdk-convert --to=1.7 ${DIR}/pool10 -X fail-safety) check_open(${DIR}/pool10 "1.7") endfunction(test) # single file pool setup() execute(0 ${TEST_DIR}/create_10 ${DIR}/pool10 16) test() # single file poolset setup() file(WRITE ${DIR}/pool10 "PMEMPOOLSET\n16M ${DIR}/part10\n") execute(0 ${TEST_DIR}/create_10 ${DIR}/pool10) execute(0 ${TEST_DIR}/open_10 ${DIR}/pool10) test() # multi file poolset setup() file(WRITE ${DIR}/pool10 "PMEMPOOLSET\n16M ${DIR}/part10_1\n16M ${DIR}/part10_2\n") execute(0 ${TEST_DIR}/create_10 ${DIR}/pool10) execute(0 ${TEST_DIR}/open_10 ${DIR}/pool10) test() # poolset with local replica setup() file(WRITE ${DIR}/pool10 "PMEMPOOLSET\n16M ${DIR}/part10_rep1\nREPLICA\n16M ${DIR}/part10_rep2\n") execute(0 ${TEST_DIR}/create_10 ${DIR}/pool10) execute(0 ${TEST_DIR}/open_10 ${DIR}/pool10) test() # invalid pool setup() file(WRITE ${DIR}/not_a_pool "This is not a pool\n") execute(15 ${EXE_DIR}/pmdk-convert ${DIR}/not_a_pool -X fail-safety --from 1.0) # CONVERT_FAILED cleanup() pmdk-convert-1.7/tests/basic11.cmake000066400000000000000000000062001354444011500173600ustar00rootroot00000000000000# # Copyright 2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) function(test) check_open(${DIR}/pool11 "1.1") # 1.1 -> 1.2 execute(0 ${EXE_DIR}/pmdk-convert --to=1.2 ${DIR}/pool11 -X fail-safety -X 1.2-pmemmutex) check_open(${DIR}/pool11 "1.2") # 1.2 -> 1.3 execute(0 ${EXE_DIR}/pmdk-convert --to=1.3 ${DIR}/pool11 -X fail-safety) check_open(${DIR}/pool11 "1.3 1.4") # 1.3 -> 1.4 execute(0 ${EXE_DIR}/pmdk-convert --to=1.4 ${DIR}/pool11 -X fail-safety) check_open(${DIR}/pool11 "1.3 1.4") # 1.4 -> 1.5 execute(0 ${EXE_DIR}/pmdk-convert --to=1.5 ${DIR}/pool11 -X fail-safety) check_open(${DIR}/pool11 "1.5 1.6") # 1.5 -> 1.6 execute(0 ${EXE_DIR}/pmdk-convert --to=1.6 ${DIR}/pool11 -X fail-safety) check_open(${DIR}/pool11 "1.5 1.6") # 1.6 -> 1.7 execute(0 ${EXE_DIR}/pmdk-convert --to=1.7 ${DIR}/pool11 -X fail-safety) check_open(${DIR}/pool11 "1.7") endfunction(test) # single file pool setup() execute(0 ${TEST_DIR}/create_11 ${DIR}/pool11 16) test() # single file poolset setup() file(WRITE ${DIR}/pool11 "PMEMPOOLSET\n16M ${DIR}/part11\n") execute(0 ${TEST_DIR}/create_11 ${DIR}/pool11) test() # multi file poolset setup() file(WRITE ${DIR}/pool11 "PMEMPOOLSET\n16M ${DIR}/part11_1\n16M ${DIR}/part11_2\n") execute(0 ${TEST_DIR}/create_11 ${DIR}/pool11) test() # poolset with local replica setup() file(WRITE ${DIR}/pool11 "PMEMPOOLSET\n16M ${DIR}/part11_rep1\nREPLICA\n16M ${DIR}/part11_rep2\n") execute(0 ${TEST_DIR}/create_11 ${DIR}/pool11) test() setup() file(WRITE ${DIR}/not_a_pool "This is not a pool\n") execute(15 ${EXE_DIR}/pmdk-convert ${DIR}/not_a_pool -X fail-safety --from 1.1) # CONVERT_FAILED cleanup() pmdk-convert-1.7/tests/basic12.cmake000066400000000000000000000060041354444011500173630ustar00rootroot00000000000000# # Copyright 2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) function(test) check_open(${DIR}/pool12 "1.2") # 1.2 -> 1.3 execute(0 ${EXE_DIR}/pmdk-convert --to=1.3 ${DIR}/pool12 -X fail-safety) check_open(${DIR}/pool12 "1.3 1.4") # 1.3 -> 1.4 execute(0 ${EXE_DIR}/pmdk-convert --to=1.4 ${DIR}/pool12 -X fail-safety) check_open(${DIR}/pool12 "1.3 1.4") # 1.4 -> 1.5 execute(0 ${EXE_DIR}/pmdk-convert --to=1.5 ${DIR}/pool12 -X fail-safety) check_open(${DIR}/pool12 "1.5 1.6") # 1.5 -> 1.6 execute(0 ${EXE_DIR}/pmdk-convert --to=1.6 ${DIR}/pool12 -X fail-safety) check_open(${DIR}/pool12 "1.5 1.6") # 1.6 -> 1.7 execute(0 ${EXE_DIR}/pmdk-convert --to=1.7 ${DIR}/pool12 -X fail-safety) check_open(${DIR}/pool12 "1.7") endfunction(test) # single file pool setup() execute(0 ${TEST_DIR}/create_12 ${DIR}/pool12 16) test() # single file poolset setup() file(WRITE ${DIR}/pool12 "PMEMPOOLSET\n16M ${DIR}/part12\n") execute(0 ${TEST_DIR}/create_12 ${DIR}/pool12) test() # multi file poolset setup() file(WRITE ${DIR}/pool12 "PMEMPOOLSET\n16M ${DIR}/part12_1\n16M ${DIR}/part12_2\n") execute(0 ${TEST_DIR}/create_12 ${DIR}/pool12) test() # poolset with local replica setup() file(WRITE ${DIR}/pool12 "PMEMPOOLSET\n16M ${DIR}/part12_rep1\nREPLICA\n16M ${DIR}/part12_rep2\n") execute(0 ${TEST_DIR}/create_12 ${DIR}/pool12) test() # invalid pool setup() file(WRITE ${DIR}/not_a_pool "This is not a pool\n") execute(15 ${EXE_DIR}/pmdk-convert ${DIR}/not_a_pool -X fail-safety --from 1.2) # CONVERT_FAILED cleanup() pmdk-convert-1.7/tests/basic13.cmake000066400000000000000000000056121354444011500173700ustar00rootroot00000000000000# # Copyright 2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) function(test) check_open(${DIR}/pool13 "1.3 1.4") # 1.3 -> 1.4 execute(0 ${EXE_DIR}/pmdk-convert --to=1.4 ${DIR}/pool13 -X fail-safety) check_open(${DIR}/pool13 "1.3 1.4") # 1.4 -> 1.5 execute(0 ${EXE_DIR}/pmdk-convert --to=1.5 ${DIR}/pool13 -X fail-safety) check_open(${DIR}/pool13 "1.5 1.6") # 1.5 -> 1.6 execute(0 ${EXE_DIR}/pmdk-convert --to=1.6 ${DIR}/pool13 -X fail-safety) check_open(${DIR}/pool13 "1.5 1.6") # 1.6 -> 1.7 execute(0 ${EXE_DIR}/pmdk-convert --to=1.7 ${DIR}/pool13 -X fail-safety) check_open(${DIR}/pool13 "1.7") endfunction(test) # single file pool setup() execute(0 ${TEST_DIR}/create_13 ${DIR}/pool13 16) test() # single file poolset setup() file(WRITE ${DIR}/pool13 "PMEMPOOLSET\n16M ${DIR}/part13\n") execute(0 ${TEST_DIR}/create_13 ${DIR}/pool13) test() # multi file poolset setup() file(WRITE ${DIR}/pool13 "PMEMPOOLSET\n16M ${DIR}/part13_1\n16M ${DIR}/part13_2\n") execute(0 ${TEST_DIR}/create_13 ${DIR}/pool13) test() # poolset with local replica setup() file(WRITE ${DIR}/pool13 "PMEMPOOLSET\n16M ${DIR}/part13_rep1\nREPLICA\n16M ${DIR}/part13_rep2\n") execute(0 ${TEST_DIR}/create_13 ${DIR}/pool13) test() # invalid pool setup() file(WRITE ${DIR}/not_a_pool "This is not a pool\n") execute(15 ${EXE_DIR}/pmdk-convert ${DIR}/not_a_pool -X fail-safety --from 1.3) # CONVERT_FAILED cleanup() pmdk-convert-1.7/tests/basic14.cmake000066400000000000000000000061351354444011500173720ustar00rootroot00000000000000# # Copyright 2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) function(test) check_open(${DIR}/pool14 "1.4") # 1.4 -> 1.5 execute(0 ${EXE_DIR}/pmdk-convert --to=1.5 ${DIR}/pool14 -X fail-safety) check_open(${DIR}/pool14 "1.5 1.6") # 1.5 -> 1.6 execute(0 ${EXE_DIR}/pmdk-convert --to=1.6 ${DIR}/pool14 -X fail-safety) check_open(${DIR}/pool14 "1.5 1.6") # 1.6 -> 1.7 execute(0 ${EXE_DIR}/pmdk-convert --to=1.7 ${DIR}/pool14 -X fail-safety) check_open(${DIR}/pool14 "1.7") endfunction(test) # single file pool setup() execute(0 ${TEST_DIR}/create_14 ${DIR}/pool14 16) test() # single file poolset setup() file(WRITE ${DIR}/pool14 "PMEMPOOLSET\n16M ${DIR}/part14\n") execute(0 ${TEST_DIR}/create_14 ${DIR}/pool14) test() # multi file poolset setup() file(WRITE ${DIR}/pool14 "PMEMPOOLSET\n16M ${DIR}/part14_1\n16M ${DIR}/part14_2\n") execute(0 ${TEST_DIR}/create_14 ${DIR}/pool14) test() # poolset with local replica setup() file(WRITE ${DIR}/pool14 "PMEMPOOLSET\n16M ${DIR}/part14_rep1\nREPLICA\n16M ${DIR}/part14_rep2\n") execute(0 ${TEST_DIR}/create_14 ${DIR}/pool14) test() # multi file poolset with local replica and SINGLEHDR option setup() file(WRITE ${DIR}/pool14 "PMEMPOOLSET\n" "OPTION SINGLEHDR\n" "16M ${DIR}/part14_part1_rep1\n" "16M ${DIR}/part14_part2_rep1\n" "REPLICA\n" "16M ${DIR}/part14_part1_rep2\n" "16M ${DIR}/part14_part2_rep2\n") execute(0 ${TEST_DIR}/create_14 ${DIR}/pool14) test() # invalid pool setup() file(WRITE ${DIR}/not_a_pool "This is not a pool\n") execute(15 ${EXE_DIR}/pmdk-convert ${DIR}/not_a_pool -X fail-safety --from 1.4) # CONVERT_FAILED cleanup() pmdk-convert-1.7/tests/basic15.cmake000066400000000000000000000057431354444011500173770ustar00rootroot00000000000000# # Copyright 2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) function(test) check_open(${DIR}/pool15 "1.5 1.6") # 1.5 -> 1.6 execute(0 ${EXE_DIR}/pmdk-convert --to=1.6 ${DIR}/pool15 -X fail-safety) check_open(${DIR}/pool15 "1.5 1.6") # 1.6 -> 1.7 execute(0 ${EXE_DIR}/pmdk-convert --to=1.7 ${DIR}/pool15 -X fail-safety) check_open(${DIR}/pool15 "1.7") endfunction(test) # single file pool setup() execute(0 ${TEST_DIR}/create_15 ${DIR}/pool15 16) test() # single file poolset setup() file(WRITE ${DIR}/pool15 "PMEMPOOLSET\n16M ${DIR}/part15\n") execute(0 ${TEST_DIR}/create_15 ${DIR}/pool15) test() # multi file poolset setup() file(WRITE ${DIR}/pool15 "PMEMPOOLSET\n16M ${DIR}/part15_1\n16M ${DIR}/part15_2\n") execute(0 ${TEST_DIR}/create_15 ${DIR}/pool15) test() # poolset with local replica setup() file(WRITE ${DIR}/pool15 "PMEMPOOLSET\n16M ${DIR}/part15_rep1\nREPLICA\n16M ${DIR}/part15_rep2\n") execute(0 ${TEST_DIR}/create_15 ${DIR}/pool15) test() # multi file poolset with local replica and SINGLEHDR option setup() file(WRITE ${DIR}/pool15 "PMEMPOOLSET\n" "OPTION SINGLEHDR\n" "16M ${DIR}/part15_part1_rep1\n" "16M ${DIR}/part15_part2_rep1\n" "REPLICA\n" "16M ${DIR}/part15_part1_rep2\n" "16M ${DIR}/part15_part2_rep2\n") execute(0 ${TEST_DIR}/create_15 ${DIR}/pool15) test() # invalid pool setup() file(WRITE ${DIR}/not_a_pool "This is not a pool\n") execute(15 ${EXE_DIR}/pmdk-convert ${DIR}/not_a_pool -X fail-safety --from 1.5) # CONVERT_FAILED cleanup() pmdk-convert-1.7/tests/basic16.cmake000066400000000000000000000055451354444011500174000ustar00rootroot00000000000000# # Copyright 2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) function(test) check_open(${DIR}/pool16 "1.5 1.6") # 1.6 -> 1.7 execute(0 ${EXE_DIR}/pmdk-convert --to=1.7 ${DIR}/pool16 -X fail-safety) check_open(${DIR}/pool16 "1.7") endfunction(test) # single file pool setup() execute(0 ${TEST_DIR}/create_16 ${DIR}/pool16 16) test() # single file poolset setup() file(WRITE ${DIR}/pool16 "PMEMPOOLSET\n16M ${DIR}/part16\n") execute(0 ${TEST_DIR}/create_16 ${DIR}/pool16) test() # multi file poolset setup() file(WRITE ${DIR}/pool16 "PMEMPOOLSET\n16M ${DIR}/part16_1\n16M ${DIR}/part16_2\n") execute(0 ${TEST_DIR}/create_16 ${DIR}/pool16) test() # poolset with local replica setup() file(WRITE ${DIR}/pool16 "PMEMPOOLSET\n16M ${DIR}/part16_rep1\nREPLICA\n16M ${DIR}/part16_rep2\n") execute(0 ${TEST_DIR}/create_16 ${DIR}/pool16) test() # multi file poolset with local replica and SINGLEHDR option setup() file(WRITE ${DIR}/pool16 "PMEMPOOLSET\n" "OPTION SINGLEHDR\n" "16M ${DIR}/part16_part1_rep1\n" "16M ${DIR}/part16_part2_rep1\n" "REPLICA\n" "16M ${DIR}/part16_part1_rep2\n" "16M ${DIR}/part16_part2_rep2\n") execute(0 ${TEST_DIR}/create_16 ${DIR}/pool16) test() # invalid pool setup() file(WRITE ${DIR}/not_a_pool "This is not a pool\n") execute(15 ${EXE_DIR}/pmdk-convert ${DIR}/not_a_pool -X fail-safety --from 1.6) # CONVERT_FAILED cleanup() pmdk-convert-1.7/tests/clean.c000066400000000000000000000036451354444011500163730ustar00rootroot00000000000000/* * Copyright 2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr, "Usage: %s pool_file\n", argv[0]); exit(1); } const char *path = argv[1]; int ret = pmempool_rm(path, 0); if (ret) { fprintf(stderr, "pmempool_rm failed: %s\n", pmempool_errormsg()); exit(1); } return 0; } pmdk-convert-1.7/tests/cli.cmake000066400000000000000000000101061354444011500167040ustar00rootroot00000000000000# # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) list(LENGTH VERSIONS NUM_OF_PMDK_VERSIONS) math(EXPR NUM_OF_PMDK_VERSIONS "${NUM_OF_PMDK_VERSIONS} - 1") list(GET VERSIONS 1 OLDEST_VER) list(GET VERSIONS ${NUM_OF_PMDK_VERSIONS} NEWEST_VER) string(REPLACE "." "" BIN_VER ${OLDEST_VER}) # argument parsing setup() execute(0 ${EXE_DIR}/pmdk-convert --help) execute(0 ${EXE_DIR}/pmdk-convert --version) execute(1 ${EXE_DIR}/pmdk-convert) # NOT_ENOUGH_ARGS execute(2 ${EXE_DIR}/pmdk-convert --force-yes xxx) # UNKNOWN_FLAG execute(3 ${EXE_DIR}/pmdk-convert --unknown) # UNKNOWN_ARG execute(4 ${EXE_DIR}/pmdk-convert --from 1.0 --from-layout 1) # FROM_EXCLUSIVE execute(5 ${EXE_DIR}/pmdk-convert --to 1.1 --to-layout 2) # TO_EXCLUSIVE execute(6 ${EXE_DIR}/pmdk-convert --from 1.10) # FROM_INVALID execute(6 ${EXE_DIR}/pmdk-convert --from 110) # FROM_INVALID execute(6 ${EXE_DIR}/pmdk-convert --from 1.a) # FROM_INVALID execute(6 ${EXE_DIR}/pmdk-convert --from a.0) # FROM_INVALID execute(7 ${EXE_DIR}/pmdk-convert --to 1.10) # TO_INVALID execute(8 ${EXE_DIR}/pmdk-convert --from-layout v10) # FROM_LAYOUT_INVALID execute(9 ${EXE_DIR}/pmdk-convert --to-layout v10) # TO_LAYOUT_INVALID execute(10 ${EXE_DIR}/pmdk-convert --from 1.0 --to 1.1) # NO_POOL file(WRITE ${DIR}/not_a_pool "This is not a pool\n") execute(11 ${EXE_DIR}/pmdk-convert ${DIR}/not_a_pool) # POOL_DETECTION execute(15 ${EXE_DIR}/pmdk-convert ${DIR}/not_a_pool --from ${OLDEST_VER} -X fail-safety) # CONVERT_FAILED file(WRITE ${DIR}/pool "PMEMPOOLSET\n16M ${DIR}/part_a\n16M ${DIR}/part_b\n") execute(0 ${TEST_DIR}/create_${BIN_VER} ${DIR}/pool) execute(11 ${EXE_DIR}/pmdk-convert ${DIR}/part_a) # POOL_DETECTION execute(15 ${EXE_DIR}/pmdk-convert ${DIR}/part_b --from ${OLDEST_VER} -X fail-safety) # CONVERT_FAILED execute(12 ${EXE_DIR}/pmdk-convert ${DIR}/pool --from 1.8) # UNSUPPORTED_FROM execute(12 ${EXE_DIR}/pmdk-convert ${DIR}/pool --from-layout 7) # UNSUPPORTED_FROM execute(13 ${EXE_DIR}/pmdk-convert ${DIR}/pool --to 1.8) # UNSUPPORTED_TO execute(13 ${EXE_DIR}/pmdk-convert ${DIR}/pool --to-layout 7) # UNSUPPORTED_TO execute(14 ${EXE_DIR}/pmdk-convert ${DIR}/pool --from ${NEWEST_VER} --to ${OLDEST_VER}) # BACKWARD_CONVERSION execute(14 ${EXE_DIR}/pmdk-convert ${DIR}/pool --from-layout 5 --to-layout 4) # BACKWARD_CONVERSION file(WRITE ${DIR}/empty_file "") execute_arg(${DIR}/empty_file 25 ${EXE_DIR}/pmdk-convert ${DIR}/pool) # STDIN_EOF file(WRITE ${DIR}/yes "Yy\n") execute_arg(${DIR}/yes 0 ${EXE_DIR}/pmdk-convert ${DIR}/pool) execute_arg(${DIR}/yes 0 ${EXE_DIR}/pmdk-convert ${DIR}/pool) # nothing to convert cleanup() pmdk-convert-1.7/tests/compare_replicas.cmake000066400000000000000000000061161354444011500214530ustar00rootroot00000000000000# # Copyright 2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) function(pmempool_info pool_file output) execute_process(COMMAND ${TEST_DIR}/pmempool-convert info -soOaAbd -l -Z -H -C ${DIR}/${pool_file} OUTPUT_VARIABLE out RESULT_VARIABLE ret ERROR_VARIABLE err_msg) if(NOT ret EQUAL 0) message(FATAL_ERROR "pmempool-convert info failed: ${err_msg}") endif() set(${output} ${out} PARENT_SCOPE) endfunction(pmempool_info) setup() list(LENGTH VERSIONS len) math(EXPR len ${len}-1) list(GET VERSIONS ${len} newest_version) math(EXPR len ${len}-1) list(GET VERSIONS ${len} version) string(REPLACE "." "" bin_version ${version}) file(WRITE ${DIR}/pool${bin_version} "PMEMPOOLSET 16M ${DIR}/part${bin_version}_rep1 REPLICA 16M ${DIR}/part${bin_version}_rep2") execute(0 ${TEST_DIR}/create_${bin_version} ${DIR}/pool${bin_version}) execute(0 ${EXE_DIR}/pmdk-convert --to=${newest_version} ${DIR}/pool${bin_version} -X fail-safety) pmempool_info(part${bin_version}_rep1 replica1) pmempool_info(part${bin_version}_rep2 replica2) string(REGEX REPLACE "([\n]path)([^\n]*)" "" replica1 ${replica1}) string(REGEX REPLACE "([\n]path)([^\n]*)" "" replica2 ${replica2}) string(REGEX REPLACE "([\n]size)([^\n]*)" "" replica1 ${replica1}) string(REGEX REPLACE "([\n]size)([^\n]*)" "" replica2 ${replica2}) string(REGEX REPLACE "([\n]UUID).*(Checksum)([^\n]*)" "" replica1 ${replica1}) string(REGEX REPLACE "([\n]UUID).*(Checksum)([^\n]*)" "" replica2 ${replica2}) if(NOT "${replica1}" STREQUAL "${replica2}") message(FATAL_ERROR "Test compare_replicas failed: replicas are not equal") endif() cleanup() pmdk-convert-1.7/tests/create.c000066400000000000000000000040271354444011500165470ustar00rootroot00000000000000/* * Copyright 2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include "libpmemobj.h" int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr, "Usage: %s pool_file [size in MB]\n", argv[0]); exit(1); } size_t sz = 0; if (argc >= 3) sz = (size_t)atoi(argv[2]) * 1024 * 1024; PMEMobjpool *pop = pmemobj_create(argv[1], "test", sz, 0755); if (!pop) { fprintf(stderr, "pmemobj_create failed: %s\n", pmemobj_errormsg()); exit(2); } pmemobj_close(pop); return 0; } pmdk-convert-1.7/tests/createW.c000066400000000000000000000040371354444011500166770ustar00rootroot00000000000000/* * Copyright 2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include "libpmemobj.h" int wmain(int argc, wchar_t *argv[]) { if (argc < 2) { fprintf(stderr, "Usage: %S pool_file [size in MB]\n", argv[0]); exit(1); } size_t sz = 0; if (argc >= 3) sz = (size_t)_wtoi(argv[2]) * 1024 * 1024; PMEMobjpool *pop = pmemobj_createW(argv[1], L"test", sz, 0755); if (!pop) { fprintf(stderr, "pmemobj_create failed: %S\n", pmemobj_errormsgW()); exit(2); } pmemobj_close(pop); return 0; } pmdk-convert-1.7/tests/helpers.cmake000066400000000000000000000211621354444011500176030ustar00rootroot00000000000000# # Copyright 2017-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. cmake_minimum_required(VERSION 3.3) set(DIR ${PARENT_DIR}/😘⠝⠧⠍⠇ɗPMDKӜ⥺🙋${TEST_NAME}) # convert the version list to the array string(REPLACE " " ";" VERSIONS ${VERSIONS}) if(WIN32) set(EXE_DIR ${CMAKE_CURRENT_BINARY_DIR}/../${CONFIG}) set(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/../tests/${CONFIG}) else() set(EXE_DIR ${CMAKE_CURRENT_BINARY_DIR}/../) set(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/../tests/) endif() # tries to open the ${pool} with all PMDK ${VERSIONS} # expect a success when a pmdk version is on the ${correct} list function(check_open pool correct) string(REPLACE " " ";" correct ${correct}) foreach(it ${VERSIONS}) string(REPLACE "." "" app ${it}) if (${it} IN_LIST correct) execute(0 ${TEST_DIR}/open_${app} ${pool}) else() execute(2 ${TEST_DIR}/open_${app} ${pool}) endif() endforeach(it) endfunction(check_open) function(setup) execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${DIR}) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${DIR}) execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${BIN_DIR}) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BIN_DIR}) endfunction() function(cleanup) execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${DIR}) endfunction() # Executes test command ${name} and verifies its status matches ${expectation}. # Optional function arguments are passed as consecutive arguments to # the command. function(execute_arg input expectation name) if(TESTS_USE_FORCED_PMEM) set(ENV{PMEM_IS_PMEM_FORCE} 1) endif() message(STATUS "Executing: ${name} ${ARGN}") if("${input}" STREQUAL "") execute_process(COMMAND ${name} ${ARGN} RESULT_VARIABLE RET OUTPUT_FILE ${BIN_DIR}/out ERROR_FILE ${BIN_DIR}/err) else() execute_process(COMMAND ${name} ${ARGN} RESULT_VARIABLE RET INPUT_FILE ${input} OUTPUT_FILE ${BIN_DIR}/out ERROR_FILE ${BIN_DIR}/err) endif() if(TESTS_USE_FORCED_PMEM) unset(ENV{PMEM_IS_PMEM_FORCE}) endif() message(STATUS "Test ${name}:") file(READ ${BIN_DIR}/out OUT) message(STATUS "Stdout:\n${OUT}") file(READ ${BIN_DIR}/err ERR) message(STATUS "Stderr:\n${ERR}") if(NOT RET EQUAL expectation) message(FATAL_ERROR "${name} ${ARGN} exit code ${RET} doesn't match expectation ${expectation}") endif() endfunction() function(execute expectation name) execute_arg("" ${expectation} ${name} ${ARGN}) endfunction() function(execute_cdb SRC_VERSION SCENARIO) set(CDB_PRE_COMMIT_COMMAND "bm pmemobj_${SRC_VERSION}!tx_pre_commit \" .if ( poi (transaction_${SRC_VERSION}!trap) == 1 ) {} .else {gc}\"\;g\;q") set(CDB_POST_COMMIT_COMMAND "bm pmemobj_${SRC_VERSION}!tx_post_commit \" .if ( poi (transaction_${SRC_VERSION}!trap) == 1 ) {} .else {gc}\"\;g\;q") if(TESTS_USE_FORCED_PMEM) set(ENV{PMEM_IS_PMEM_FORCE} 1) endif() execute_process(COMMAND ${CDB_PATH}/cdb.exe -c ${CDB_PRE_COMMIT_COMMAND} ${TEST_DIR}/transaction_${SRC_VERSION} ${DIR}/pool${SRC_VERSION}a c ${SCENARIO} RESULT_VARIABLE CDB_RET) execute_process(COMMAND ${CDB_PATH}/cdb.exe -c ${CDB_POST_COMMIT_COMMAND} ${TEST_DIR}/transaction_${SRC_VERSION} ${DIR}/pool${SRC_VERSION}c c ${SCENARIO} RESULT_VARIABLE CDB_RET) if(TESTS_USE_FORCED_PMEM) unset(ENV{PMEM_IS_PMEM_FORCE}) endif() endfunction() function(test_intr_tx prepare_files) set(curr_scenario 0) set(last_scenario 9) list(LENGTH VERSIONS num) math(EXPR num "${num} - 1") while(NOT curr_scenario GREATER last_scenario) prepare_files() set(index 1) while(index LESS num) list(GET VERSIONS ${index} curr_version) math(EXPR next "${index} + 1") list(GET VERSIONS ${next} next_version) string(REPLACE "." "" curr_bin_version ${curr_version}) string(REPLACE "." "" next_bin_version ${next_version}) if(next_version EQUAL "1.2") set(mutex "-X;1.2-pmemmutex") else() unset(mutex) endif() lock_tx_intr() if(WIN32) execute_cdb(${curr_bin_version} ${curr_scenario}) execute(0 ${EXE_DIR}/pmdk-convert --to=${next_version} ${DIR}/pool${curr_bin_version}a -X fail-safety) execute(0 ${TEST_DIR}/transaction_${next_bin_version} ${DIR}/pool${curr_bin_version}a va ${curr_scenario}) execute(0 ${EXE_DIR}/pmdk-convert --to=${next_version} ${DIR}/pool${curr_bin_version}c -X fail-safety) execute(0 ${TEST_DIR}/transaction_${next_bin_version} ${DIR}/pool${curr_bin_version}c vc ${curr_scenario}) else() execute(0 gdb --batch --command=${SRC_DIR}/trip_on_pre_commit.gdb --args ${TEST_DIR}/transaction_${curr_bin_version} ${DIR}/pool${curr_bin_version}a c ${curr_scenario}) execute(0 ${EXE_DIR}/pmdk-convert --to=${next_version} ${DIR}/pool${curr_bin_version}a -X fail-safety ${mutex}) execute(0 ${TEST_DIR}/transaction_${next_bin_version} ${DIR}/pool${curr_bin_version}a va ${curr_scenario}) execute(0 gdb --batch --command=${SRC_DIR}/trip_on_post_commit.gdb --args ${TEST_DIR}/transaction_${curr_bin_version} ${DIR}/pool${curr_bin_version}c c ${curr_scenario}) execute(0 ${EXE_DIR}/pmdk-convert --to=${next_version} ${DIR}/pool${curr_bin_version}c -X fail-safety ${mutex}) execute(0 ${TEST_DIR}/transaction_${next_bin_version} ${DIR}/pool${curr_bin_version}c vc ${curr_scenario}) endif() unlock_tx_intr() MATH(EXPR index "${index} + 1") endwhile() MATH(EXPR curr_scenario "${curr_scenario} + 1") endwhile() endfunction() set(DEVDAX_LOCKS "${PARENT_DIR}/../devdax.lock") set(TX_INTR_LOCKS "${PARENT_DIR}/../tx_intr.lock") # acquire a lock on DAX devices function(lock_devdax) file(LOCK ${DEVDAX_LOCKS}) endfunction() # release a lock on DAX devices function(unlock_devdax) file(LOCK ${DEVDAX_LOCKS} RELEASE) endfunction() # acquire a lock on tests with interrupted transactions function(lock_tx_intr) file(LOCK ${TX_INTR_LOCKS}) endfunction() # release a lock on tests with interrupted transactions function(unlock_tx_intr) file(LOCK ${TX_INTR_LOCKS} RELEASE) endfunction() function(test_intr_tx_devdax prepare_files curr_version next_version) set(curr_scenario 0) set(last_scenario 9) while(NOT curr_scenario GREATER last_scenario) string(REPLACE "." "" curr_bin_version ${curr_version}) string(REPLACE "." "" next_bin_version ${next_version}) prepare_files(${curr_bin_version}) lock_tx_intr() execute(0 gdb --batch --command=${SRC_DIR}/trip_on_pre_commit.gdb --args ${TEST_DIR}/transaction_${curr_bin_version} ${pool_file} c ${curr_scenario}) execute(0 ${EXE_DIR}/pmdk-convert --to=${next_version} ${pool_file} -X fail-safety) execute(0 ${TEST_DIR}/transaction_${next_bin_version} ${pool_file} va ${curr_scenario}) prepare_files(${curr_bin_version}) execute(0 gdb --batch --command=${SRC_DIR}/trip_on_post_commit.gdb --args ${TEST_DIR}/transaction_${curr_bin_version} ${pool_file} c ${curr_scenario}) execute(0 ${EXE_DIR}/pmdk-convert --to=${next_version} ${pool_file} -X fail-safety) execute(0 ${TEST_DIR}/transaction_${next_bin_version} ${pool_file} vc ${curr_scenario}) unlock_tx_intr() MATH(EXPR curr_scenario "${curr_scenario} + 1") endwhile() endfunction() pmdk-convert-1.7/tests/open.c000066400000000000000000000036571354444011500162550ustar00rootroot00000000000000/* * Copyright 2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include "libpmemobj.h" int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr, "Usage: %s pool_file\n", argv[0]); exit(1); } PMEMobjpool *pop = pmemobj_open(argv[1], "test"); if (!pop) { fprintf(stderr, "pmemobj_open failed: %s\n", pmemobj_errormsg()); exit(2); } pmemobj_close(pop); return 0; } pmdk-convert-1.7/tests/openW.c000066400000000000000000000036661354444011500164040ustar00rootroot00000000000000/* * Copyright 2018, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include "libpmemobj.h" int wmain(int argc, wchar_t *argv[]) { if (argc < 2) { fprintf(stderr, "Usage: %S pool_file\n", argv[0]); exit(1); } PMEMobjpool *pop = pmemobj_openW(argv[1], L"test"); if (!pop) { fprintf(stderr, "pmemobj_open failed: %S\n", pmemobj_errormsgW()); exit(2); } pmemobj_close(pop); return 0; } pmdk-convert-1.7/tests/remote.cmake000066400000000000000000000047011354444011500174340ustar00rootroot00000000000000# # Copyright 2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) list(GET VERSIONS 1 VER) string(REPLACE "." "" VER ${VER}) setup() file(WRITE ${DIR}/pool "PMEMPOOLSET\n16M ${DIR}/part\nREPLICA user@example.com remote-objpool.set\n") execute(23 ${CMAKE_CURRENT_BINARY_DIR}/../pmdk-convert ${DIR}/pool) setup() file(WRITE ${DIR}/pool "PMEMPOOLSET\n16M ${DIR}/part\nREPLICA user@example.com remote-objpool.set # abcdefgh\n") execute(23 ${CMAKE_CURRENT_BINARY_DIR}/../pmdk-convert ${DIR}/pool --from-layout 4 --to-layout 5) setup() file(WRITE ${DIR}/pool "PMEMPOOLSET\n16M ${DIR}/part\nREPLICA a\n") execute(23 ${CMAKE_CURRENT_BINARY_DIR}/../pmdk-convert ${DIR}/pool --from-layout 4 --to-layout 5) setup() file(WRITE ${DIR}/pool "PMEMPOOLSET\n16M ${DIR}/part\nREPLICA # user@example.com remote-objpool.set\n16M ${DIR}/replica") execute(23 ${CMAKE_CURRENT_BINARY_DIR}/../pmdk-convert ${DIR}/pool --from-layout 4 --to-layout 5 -X fail-safety) cleanup() pmdk-convert-1.7/tests/skip_test.cmake000066400000000000000000000031351354444011500201460ustar00rootroot00000000000000# # Copyright 2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # skip_tests.cmake - cmake script which always succeeds return() pmdk-convert-1.7/tests/spoiled_pool_hdr.cmake000066400000000000000000000073501354444011500214710ustar00rootroot00000000000000# # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # File contains test which verifies converting the pool with major header # field changed to 0 and (expected_major + 1) for every available version include(${SRC_DIR}/helpers.cmake) setup() list(LENGTH VERSIONS num) math(EXPR last_position "${num} - 1") list(GET VERSIONS ${last_position} newest_version) string(REPLACE "." "" last_bin_version ${newest_version}) # first PMDK version with the newest layout set(BEGIN_LATEST_LAYOUT 1.7) execute(0 ${TEST_DIR}/create_${last_bin_version} ${DIR}/poolTest${last_bin_version} 16) execute_process(COMMAND ${TEST_DIR}/pmempool-convert info ${DIR}/poolTest${last_bin_version} OUTPUT_VARIABLE out RESULT_VARIABLE ret ERROR_VARIABLE err_msg) if(NOT ret EQUAL 0) message(FATAL_ERROR "pmempool-convert info failed: ${err_msg}") endif() string(REGEX MATCH "Major +: +[0-9]" out ${out}) string(REGEX REPLACE "[^0-9]+" "" expected_major ${out}) math(EXPR incorrect_version "${expected_major} + 1") set(index 1) list(GET VERSIONS 1 min_version) string(REPLACE "." "" min_version ${min_version}) while(index LESS num) list(GET VERSIONS ${index} curr_version) string(REPLACE "." "" bin_version ${curr_version}) if(NOT(bin_version LESS min_version)) execute(0 ${TEST_DIR}/create_${bin_version} ${DIR}/pool${bin_version} 16) execute(0 ${TEST_DIR}/pmemspoil ${DIR}/pool${bin_version} pool_hdr.major=0) execute(11 ${EXE_DIR}/pmdk-convert ${DIR}/pool${bin_version} -X fail-safety -X 1.2-pmemmutex) execute(2 ${TEST_DIR}/open_${bin_version} ${DIR}/pool${bin_version}) execute(0 ${TEST_DIR}/pmemspoil ${DIR}/pool${bin_version} pool_hdr.major=${incorrect_version}) execute(11 ${EXE_DIR}/pmdk-convert ${DIR}/pool${bin_version} -X fail-safety -X 1.2-pmemmutex) execute(2 ${TEST_DIR}/open_${bin_version} ${DIR}/pool${bin_version}) # pmdk-convert skips all checks when from==to, so there's no point in checking that if(${curr_version} VERSION_LESS ${BEGIN_LATEST_LAYOUT}) execute(15 ${EXE_DIR}/pmdk-convert ${DIR}/pool${bin_version} -X fail-safety -X 1.2-pmemmutex --from ${curr_version}) else() execute(0 ${EXE_DIR}/pmdk-convert ${DIR}/pool${bin_version} -X fail-safety -X 1.2-pmemmutex --from ${curr_version}) endif() endif() MATH(EXPR index "${index} + 1") endwhile() cleanup() pmdk-convert-1.7/tests/transaction.c000066400000000000000000000326251354444011500176360ustar00rootroot00000000000000/* * Copyright 2015-2019, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * transaction.c -- unit test for pool conversion * * This test has dual purpose - to create an old-format pool with the _create * functions and to verify if the conversion happened correctly. * * The creation should happen while linked with the old library version and * the verify step should be run with the new one. */ #include #include #include "libpmemobj.h" POBJ_LAYOUT_BEGIN(convert); POBJ_LAYOUT_ROOT(convert, struct root); POBJ_LAYOUT_TOID(convert, struct foo); POBJ_LAYOUT_TOID(convert, struct bar); POBJ_LAYOUT_END(convert); #define SMALL_ALLOC (64) #define BIG_ALLOC (1024 * 200) /* just big enough to be a huge allocation */ struct bar { char value[BIG_ALLOC]; }; struct foo { unsigned char value[SMALL_ALLOC]; }; #define TEST_VALUE 5 #define TEST_NVALUES 10 #define TEST_RECURSION_NUM 5 struct root { TOID(struct foo) foo; TOID(struct bar) bar; int value[TEST_NVALUES]; }; /* * A global variable used to trigger a breakpoint in the gdb in order to stop * execution of the test after it was used. It's used to simulate a crash in the * tx_commit process. */ static int trap = 0; enum operation { ADD, DRW, SET }; /* * A macro that recursively create a nested transactions and save whole object * or specific FIELD in the undo log. */ #define TEST_GEN(type, x)\ static void \ type ## _tx(PMEMobjpool *pop, TOID(struct type) var, int array_size,\ int recursion, enum operation oper)\ {\ --recursion;\ \ TX_BEGIN(pop) {\ if (oper == ADD) {\ TX_ADD(var);\ oper = DRW;\ }\ \ if (recursion >= 1)\ TEST_CALL(type, pop, var, array_size, recursion,\ oper);\ \ for (int i = 0; i < array_size; ++i) {\ if (oper == SET)\ TX_SET(var, value[i], (x)(TEST_VALUE +\ D_RO(var)->value[i]));\ else if (oper == DRW)\ D_RW(var)->value[i] = (x)(TEST_VALUE +\ D_RO(var)->value[i]);\ }\ } TX_END\ } #define TEST_CALL(type, pop, var, array_size, recursion, oper)\ type ## _tx(pop, var, array_size, recursion, oper) TEST_GEN(foo, unsigned char); TEST_GEN(bar, char); TEST_GEN(root, int); /* * sc0_create -- single large set undo */ static void sc0_create(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); trap = 1; TX_BEGIN(pop) { TX_ADD(rt); D_RW(rt)->value[0] = TEST_VALUE; } TX_END } static void sc0_verify_abort(PMEMobjpool *pop) { if (pmemobj_root_size(pop) != sizeof(struct root)) exit(1); TOID(struct root) rt = POBJ_ROOT(pop, struct root); if (D_RW(rt)->value[0] != 0) exit(2); } static void sc0_verify_commit(PMEMobjpool *pop) { if (pmemobj_root_size(pop) != sizeof(struct root)) exit(3); TOID(struct root) rt = POBJ_ROOT(pop, struct root); if (D_RW(rt)->value[0] != TEST_VALUE) exit(4); } /* * sc1_create -- single small set undo */ static void sc1_create(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); POBJ_ZALLOC(pop, &D_RW(rt)->foo, struct foo, sizeof(struct foo)); trap = 1; TX_BEGIN(pop) { TX_ADD(D_RW(rt)->foo); D_RW(D_RW(rt)->foo)->value[0] = TEST_VALUE; } TX_END } static void sc1_verify_abort(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); if (D_RW(D_RW(rt)->foo)->value[0] != 0) exit(5); } static void sc1_verify_commit(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); if (D_RW(D_RW(rt)->foo)->value[0] != TEST_VALUE) exit(6); } /* * sc2_create -- multiply changes in large set undo (TX_ADD) */ static void sc2_create(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); TX_BEGIN(pop) { TEST_CALL(root, pop, rt, TEST_NVALUES, TEST_RECURSION_NUM, ADD); trap = 1; TEST_CALL(root, pop, rt, TEST_NVALUES, TEST_RECURSION_NUM, ADD); } TX_END } static void sc2_verify_abort(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); for (int i = 0; i < TEST_NVALUES; ++i) if (D_RW(rt)->value[i] != 0) exit(7); } static void sc2_verify_commit(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); for (int i = 0; i < TEST_NVALUES; ++i) if (D_RW(rt)->value[i] != 2 * TEST_RECURSION_NUM * TEST_VALUE) exit(8); } /* * sc3_create -- multiply changes in small set undo (TX_SET) */ static void sc3_create(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); POBJ_ZALLOC(pop, &D_RW(rt)->bar, struct bar, sizeof(struct bar)); TX_BEGIN(pop) { TEST_CALL(bar, pop, D_RW(rt)->bar, BIG_ALLOC, TEST_RECURSION_NUM, SET); trap = 1; TEST_CALL(bar, pop, D_RW(rt)->bar, BIG_ALLOC, TEST_RECURSION_NUM, SET); } TX_END } static void sc3_verify_abort(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); for (int i = 0; i < TEST_NVALUES; ++i) if (D_RW(D_RW(rt)->bar)->value[i] != 0) exit(9); } static void sc3_verify_commit(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); for (int i = 0; i < TEST_NVALUES; ++i) if (D_RW(D_RW(rt)->bar)->value[i] !=\ 2 * TEST_RECURSION_NUM * TEST_VALUE) exit(10); } /* * sc4_create -- multiply changes in small set undo (TX_ADD) */ static void sc4_create(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); POBJ_ZALLOC(pop, &D_RW(rt)->foo, struct foo, sizeof(struct foo)); TX_BEGIN(pop) { TEST_CALL(foo, pop, D_RW(rt)->foo, SMALL_ALLOC, TEST_RECURSION_NUM, ADD); trap = 1; TEST_CALL(foo, pop, D_RW(rt)->foo, SMALL_ALLOC, TEST_RECURSION_NUM, ADD); } TX_END } static void sc4_verify_abort(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); for (int i = 0; i < SMALL_ALLOC; ++i) if (D_RW(D_RW(rt)->foo)->value[i] != 0) exit(11); } static void sc4_verify_commit(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); for (int i = 0; i < SMALL_ALLOC; ++i) if (D_RW(D_RW(rt)->foo)->value[i] !=\ 2 * TEST_RECURSION_NUM * TEST_VALUE) exit(12); } /* * sc5_create -- multiply changes in small set undo (TX_SET) */ static void sc5_create(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); POBJ_ZALLOC(pop, &D_RW(rt)->foo, struct foo, sizeof(struct foo)); TX_BEGIN(pop) { TEST_CALL(foo, pop, D_RW(rt)->foo, SMALL_ALLOC, TEST_RECURSION_NUM, SET); trap = 1; TEST_CALL(foo, pop, D_RW(rt)->foo, SMALL_ALLOC, TEST_RECURSION_NUM, SET); } TX_END } static void sc5_verify_abort(PMEMobjpool *pop) { sc4_verify_abort(pop); } static void sc5_verify_commit(PMEMobjpool *pop) { sc4_verify_commit(pop); } /* * sc6_create -- free undo */ static void sc6_create(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); TX_BEGIN(pop) { TX_SET(rt, foo, TX_NEW(struct foo)); TX_SET(rt, bar, TX_NEW(struct bar)); } TX_ONABORT { exit(0); } TX_END trap = 1; TX_BEGIN(pop) { TX_FREE(D_RO(rt)->foo); TX_FREE(D_RO(rt)->bar); } TX_END } static void sc6_verify_abort(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); TX_BEGIN(pop) { /* * If the free undo log didn't get unrolled then the next * free would fail due to the object being already freed. */ TX_FREE(D_RO(rt)->foo); TX_FREE(D_RO(rt)->bar); } TX_ONABORT { exit(0); } TX_END } static void sc6_verify_commit(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); TOID(struct foo) f; POBJ_FOREACH_TYPE(pop, f) { if (!TOID_EQUALS(f, D_RO(rt)->foo)) exit(13); } TOID(struct bar) b; POBJ_FOREACH_TYPE(pop, b) { if (!TOID_EQUALS(b, D_RO(rt)->bar)) exit(14); } } /* * sc7_create -- small alloc undo */ static void sc7_create(PMEMobjpool *pop) { /* allocate until OOM and count allocs */ int nallocs = 0; TX_BEGIN(pop) { for (;;) { (void) TX_NEW(struct foo); nallocs++; } } TX_END trap = 1; /* allocate all possible objects */ TX_BEGIN(pop) { for (int i = 0; i < nallocs; ++i) { (void) TX_NEW(struct foo); } } TX_ONABORT { exit(0); } TX_END } static void sc7_verify_abort(PMEMobjpool *pop) { int nallocs = 0; TOID(struct foo) f; POBJ_FOREACH_TYPE(pop, f) { nallocs++; } if (nallocs != 0) exit(15); } static void sc7_verify_commit(PMEMobjpool *pop) { int nallocs = 0; TOID(struct foo) f; POBJ_FOREACH_TYPE(pop, f) { nallocs++; } if (nallocs == 0) exit(16); } /* * sc8_create -- large alloc undo */ static void sc8_create(PMEMobjpool *pop) { /* allocate until OOM and count allocs */ int nallocs = 0; TX_BEGIN(pop) { for (;;) { (void) TX_NEW(struct bar); nallocs++; } } TX_END trap = 1; /* allocate all possible objects */ TX_BEGIN(pop) { for (int i = 0; i < nallocs; ++i) { (void) TX_NEW(struct bar); } } TX_ONABORT { exit(0); } TX_END } static void sc8_verify_abort(PMEMobjpool *pop) { TX_BEGIN(pop) { TOID(struct bar) f = TX_NEW(struct bar); (void) f; } TX_ONABORT { exit(0); } TX_END } static void sc8_verify_commit(PMEMobjpool *pop) { int nallocs = 0; TOID(struct bar) f; POBJ_FOREACH_TYPE(pop, f) { nallocs++; } if (nallocs == 0) exit(17); } /* * sc9_create -- multiply small and large set undo */ static void sc9_create(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); POBJ_ZALLOC(pop, &D_RW(rt)->bar, struct bar, sizeof(struct bar)); POBJ_ZALLOC(pop, &D_RW(rt)->foo, struct foo, sizeof(struct foo)); TX_BEGIN(pop) { TEST_CALL(foo, pop, D_RW(rt)->foo, SMALL_ALLOC, TEST_RECURSION_NUM, SET); TEST_CALL(bar, pop, D_RW(rt)->bar, BIG_ALLOC, TEST_RECURSION_NUM, SET); TEST_CALL(root, pop, rt, TEST_NVALUES, TEST_RECURSION_NUM, SET); trap = 1; TEST_CALL(foo, pop, D_RW(rt)->foo, SMALL_ALLOC, TEST_RECURSION_NUM, ADD); TEST_CALL(bar, pop, D_RW(rt)->bar, BIG_ALLOC, TEST_RECURSION_NUM, ADD); TEST_CALL(root, pop, rt, TEST_NVALUES, TEST_RECURSION_NUM, ADD); } TX_END } static void sc9_verify_abort(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); for (int i = 0; i < SMALL_ALLOC; ++i) if (D_RW(D_RW(rt)->foo)->value[i] != 0) exit(18); for (int i = 0; i < BIG_ALLOC; ++i) if (D_RW(D_RW(rt)->bar)->value[i] != 0) exit(19); for (int i = 0; i < TEST_NVALUES; ++i) if (D_RW(rt)->value[i] != 0) exit(20); } static void sc9_verify_commit(PMEMobjpool *pop) { TOID(struct root) rt = POBJ_ROOT(pop, struct root); for (int i = 0; i < SMALL_ALLOC; ++i) if (D_RW(D_RW(rt)->foo)->value[i] != 2 * TEST_RECURSION_NUM *\ TEST_VALUE) exit(21); for (int i = 0; i < BIG_ALLOC; ++i) if (D_RW(D_RW(rt)->bar)->value[i] != 2 * TEST_RECURSION_NUM *\ TEST_VALUE) exit(22); for (int i = 0; i < TEST_NVALUES; ++i) if (D_RW(rt)->value[i] != 2 * TEST_RECURSION_NUM * TEST_VALUE) exit(23); } typedef void (*scenario_func)(PMEMobjpool *pop); static struct { scenario_func create; scenario_func verify_abort; scenario_func verify_commit; } scenarios[] = { {sc0_create, sc0_verify_abort, sc0_verify_commit}, {sc1_create, sc1_verify_abort, sc1_verify_commit}, {sc2_create, sc2_verify_abort, sc2_verify_commit}, {sc3_create, sc3_verify_abort, sc3_verify_commit}, {sc4_create, sc4_verify_abort, sc4_verify_commit}, {sc5_create, sc5_verify_abort, sc5_verify_commit}, {sc6_create, sc6_verify_abort, sc6_verify_commit}, {sc7_create, sc7_verify_abort, sc7_verify_commit}, {sc8_create, sc8_verify_abort, sc8_verify_commit}, {sc9_create, sc9_verify_abort, sc9_verify_commit}, }; int main(int argc, char *argv[]) { if (argc != 4) printf("usage: %s file [c|va|vc] scenario", argv[0]); #ifdef _WIN32 wchar_t **wargv = CommandLineToArgvW(GetCommandLineW(), &argc); #else const char *path = argv[1]; #endif int prepare_pool = argv[2][0] == 'c'; int verify_abort = argv[2][1] == 'a'; int sc = atoi(argv[3]); PMEMobjpool *pop = NULL; #ifdef _WIN32 if ((pop = pmemobj_openW(wargv[1], NULL)) == NULL) { printf("failed to open pool\n"); exit(24); } #else if ((pop = pmemobj_open(path, NULL)) == NULL) { printf("failed to open pool\n"); exit(24); } #endif if (prepare_pool) scenarios[sc].create(pop); else { if (verify_abort) scenarios[sc].verify_abort(pop); else scenarios[sc].verify_commit(pop); } pmemobj_close(pop); return 0; } pmdk-convert-1.7/tests/trip_on_post_commit.gdb000066400000000000000000000001731354444011500217030ustar00rootroot00000000000000set width 0 set height 0 set verbose off set confirm off set breakpoint pending on b tx_post_commit if trap == 1 run quit pmdk-convert-1.7/tests/trip_on_pre_commit.gdb000066400000000000000000000001721354444011500215030ustar00rootroot00000000000000set width 0 set height 0 set verbose off set confirm off set breakpoint pending on b tx_pre_commit if trap == 1 run quit pmdk-convert-1.7/tests/tx_intr_pool_devdax.cmake000066400000000000000000000050171354444011500222150ustar00rootroot00000000000000# # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) # prepare single file pools on DAX device for testing for each version of PMDK function(prepare_files version) execute(0 ${CMAKE_CURRENT_BINARY_DIR}/clean_pool ${devdax}) execute(0 ${CMAKE_CURRENT_BINARY_DIR}/create_${version} ${devdax}) set(pool_file "${devdax}" PARENT_SCOPE) endfunction() function(test_devdax test_intr_tx_devdax) lock_devdax() setup() string(REPLACE " " ";" DEVICE_DAX_PATHS ${DEVICE_DAX_PATHS}) list(GET DEVICE_DAX_PATHS 0 devdax) list(LENGTH VERSIONS num) math(EXPR num "${num} - 1") set(index 1) while(index LESS num) list(GET VERSIONS ${index} curr_version) math(EXPR next "${index} + 1") list(GET VERSIONS ${next} next_version) # DAX devices are supported from PMDK version 1.2 if(curr_version VERSION_GREATER "1.1") test_intr_tx_devdax(prepare_files ${curr_version} ${next_version}) endif() MATH(EXPR index "${index} + 1") endwhile() unlock_devdax() endfunction() test_devdax(test_intr_tx_devdax) cleanup() pmdk-convert-1.7/tests/tx_intr_pool_regfile.cmake000066400000000000000000000037331354444011500223620ustar00rootroot00000000000000# # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) # prepare single file pools for testing for each version of PMDK function(prepare_files) setup() foreach(version ${VERSIONS}) string(REPLACE "." "" bin_version ${version}) execute(0 ${TEST_DIR}/create_${bin_version} ${DIR}/pool${bin_version}a 16) execute(0 ${TEST_DIR}/create_${bin_version} ${DIR}/pool${bin_version}c 32) endforeach() endfunction() test_intr_tx(prepare_files) cleanup() pmdk-convert-1.7/tests/tx_intr_poolset_local_2devdaxes.cmake000066400000000000000000000053441354444011500245200ustar00rootroot00000000000000# # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) # prepare poolset on DAX devices for testing for each version of PMDK function(prepare_files version) file(WRITE ${DIR}/pool${version} "PMEMPOOLSET AUTO ${devdax_1} AUTO ${devdax_2}") execute(0 ${CMAKE_CURRENT_BINARY_DIR}/clean_pool ${devdax_1}) execute(0 ${CMAKE_CURRENT_BINARY_DIR}/clean_pool ${devdax_2}) execute(0 ${CMAKE_CURRENT_BINARY_DIR}/create_${version} ${DIR}/pool${version}) set(pool_file "${DIR}/pool${version}" PARENT_SCOPE) endfunction() function(test_devdax test_intr_tx_devdax) lock_devdax() setup() string(REPLACE " " ";" DEVICE_DAX_PATHS ${DEVICE_DAX_PATHS}) list(GET DEVICE_DAX_PATHS 0 devdax_1) list(GET DEVICE_DAX_PATHS 1 devdax_2) list(LENGTH VERSIONS num) math(EXPR num "${num} - 1") set(index 1) while(index LESS num) list(GET VERSIONS ${index} curr_version) math(EXPR next "${index} + 1") list(GET VERSIONS ${next} next_version) # Multi DAX devices are supported from PMDK version 1.3 if(curr_version VERSION_GREATER "1.2") test_intr_tx_devdax(prepare_files ${curr_version} ${next_version}) endif() MATH(EXPR index "${index} + 1") endwhile() unlock_devdax() endfunction() test_devdax(test_intr_tx_devdax) cleanup() pmdk-convert-1.7/tests/tx_intr_poolset_local_2devdaxes_rep_2regfiles.cmake000066400000000000000000000056141354444011500273300ustar00rootroot00000000000000# # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) # prepare poolset with local replica on DAX devices and on regular files # for testing for each version of PMDK function(prepare_files version) file(WRITE ${DIR}/pool${version} "PMEMPOOLSET AUTO ${devdax_1} AUTO ${devdax_2} REPLICA 16M ${DIR}/part${version}_1 16M ${DIR}/part${version}_2") file(REMOVE ${DIR}/part${version}_1 ${DIR}/part${version}_2) execute(0 ${CMAKE_CURRENT_BINARY_DIR}/clean_pool ${devdax_1}) execute(0 ${CMAKE_CURRENT_BINARY_DIR}/clean_pool ${devdax_2}) execute(0 ${CMAKE_CURRENT_BINARY_DIR}/create_${version} ${DIR}/pool${version}) set(pool_file "${DIR}/pool${version}" PARENT_SCOPE) endfunction() function(test_devdax test_intr_tx_devdax) lock_devdax() setup() string(REPLACE " " ";" DEVICE_DAX_PATHS ${DEVICE_DAX_PATHS}) list(GET DEVICE_DAX_PATHS 0 devdax_1) list(GET DEVICE_DAX_PATHS 1 devdax_2) list(LENGTH VERSIONS num) math(EXPR num "${num} - 1") set(index 1) while(index LESS num) list(GET VERSIONS ${index} curr_version) math(EXPR next "${index} + 1") list(GET VERSIONS ${next} next_version) # Multi DAX devices are supported from PMDK version 1.3 if(curr_version VERSION_GREATER "1.2") test_intr_tx_devdax(prepare_files ${curr_version} ${next_version}) endif() MATH(EXPR index "${index} + 1") endwhile() unlock_devdax() endfunction() test_devdax(test_intr_tx_devdax) cleanup() pmdk-convert-1.7/tests/tx_intr_poolset_local_2regfiles.cmake000066400000000000000000000043261354444011500245140ustar00rootroot00000000000000# # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) # prepare poolsets on regular files for testing for each version of PMDK function(prepare_files) setup() foreach(version ${VERSIONS}) string(REPLACE "." "" bin_version ${version}) file(WRITE ${DIR}/pool${bin_version}a "PMEMPOOLSET 16M ${DIR}/part${bin_version}a_1 16M ${DIR}/part${bin_version}a_2") execute(0 ${TEST_DIR}/create_${bin_version} ${DIR}/pool${bin_version}a) file(WRITE ${DIR}/pool${bin_version}c "PMEMPOOLSET 16M ${DIR}/part${bin_version}c_1 16M ${DIR}/part${bin_version}c_2") execute(0 ${TEST_DIR}/create_${bin_version} ${DIR}/pool${bin_version}c) endforeach() endfunction() test_intr_tx(prepare_files) cleanup() pmdk-convert-1.7/tests/tx_intr_poolset_local_2regfiles_rep_2devdaxes.cmake000066400000000000000000000056141354444011500273300ustar00rootroot00000000000000# # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) # prepare poolset with local replica on DAX devices and on regular files # for testing for each version of PMDK function(prepare_files version) file(WRITE ${DIR}/pool${version} "PMEMPOOLSET 16M ${DIR}/part${version}_1 16M ${DIR}/part${version}_2 REPLICA AUTO ${devdax_1} AUTO ${devdax_2}") file(REMOVE ${DIR}/part${version}_1 ${DIR}/part${version}_2) execute(0 ${CMAKE_CURRENT_BINARY_DIR}/clean_pool ${devdax_1}) execute(0 ${CMAKE_CURRENT_BINARY_DIR}/clean_pool ${devdax_2}) execute(0 ${CMAKE_CURRENT_BINARY_DIR}/create_${version} ${DIR}/pool${version}) set(pool_file "${DIR}/pool${version}" PARENT_SCOPE) endfunction() function(test_devdax test_intr_tx_devdax) lock_devdax() setup() string(REPLACE " " ";" DEVICE_DAX_PATHS ${DEVICE_DAX_PATHS}) list(GET DEVICE_DAX_PATHS 0 devdax_1) list(GET DEVICE_DAX_PATHS 1 devdax_2) list(LENGTH VERSIONS num) math(EXPR num "${num} - 1") set(index 1) while(index LESS num) list(GET VERSIONS ${index} curr_version) math(EXPR next "${index} + 1") list(GET VERSIONS ${next} next_version) # Multi DAX devices are supported from PMDK version 1.3 if(curr_version VERSION_GREATER "1.2") test_intr_tx_devdax(prepare_files ${curr_version} ${next_version}) endif() MATH(EXPR index "${index} + 1") endwhile() unlock_devdax() endfunction() test_devdax(test_intr_tx_devdax) cleanup() pmdk-convert-1.7/tests/tx_intr_poolset_local_2regfiles_rep_3regfiles.cmake000066400000000000000000000047451354444011500273320ustar00rootroot00000000000000# # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) # prepare poolsets with local replica on regular files for testing for # each version of PMDK function(prepare_files) setup() foreach(version ${VERSIONS}) string(REPLACE "." "" bin_version ${version}) file(WRITE ${DIR}/pool${bin_version}a "PMEMPOOLSET 32M ${DIR}/part${bin_version}a_1 16M ${DIR}/part${bin_version}a_2 REPLICA 12M ${DIR}/part${bin_version}a_3 8M ${DIR}/part${bin_version}a_4 40M ${DIR}/part${bin_version}a_5") execute(0 ${CMAKE_CURRENT_BINARY_DIR}/create_${bin_version} ${DIR}/pool${bin_version}a) file(WRITE ${DIR}/pool${bin_version}c "PMEMPOOLSET 128M ${DIR}/part${bin_version}c_1 48M ${DIR}/part${bin_version}c_2 REPLICA 24M ${DIR}/part${bin_version}c_3 16M ${DIR}/part${bin_version}c_4 32M ${DIR}/part${bin_version}c_5") execute(0 ${CMAKE_CURRENT_BINARY_DIR}/create_${bin_version} ${DIR}/pool${bin_version}c) endforeach() endfunction() test_intr_tx(prepare_files) #cleanup() pmdk-convert-1.7/tests/tx_intr_poolset_local_devdax.cmake000066400000000000000000000051401354444011500241000ustar00rootroot00000000000000# # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) # prepare poolset on DAX device for testing for each version of PMDK function(prepare_files version) file(WRITE ${DIR}/pool${version} "PMEMPOOLSET AUTO ${devdax}") execute(0 ${CMAKE_CURRENT_BINARY_DIR}/clean_pool ${devdax}) execute(0 ${CMAKE_CURRENT_BINARY_DIR}/create_${version} ${DIR}/pool${version}) set(pool_file "${DIR}/pool${version}" PARENT_SCOPE) endfunction() function(test_devdax test_intr_tx_devdax) lock_devdax() setup() string(REPLACE " " ";" DEVICE_DAX_PATHS ${DEVICE_DAX_PATHS}) list(GET DEVICE_DAX_PATHS 0 devdax) list(LENGTH VERSIONS num) math(EXPR num "${num} - 1") set(index 1) while(index LESS num) list(GET VERSIONS ${index} curr_version) math(EXPR next "${index} + 1") list(GET VERSIONS ${next} next_version) # DAX devices are supported from PMDK version 1.2 if(curr_version VERSION_GREATER "1.1") test_intr_tx_devdax(prepare_files ${curr_version} ${next_version}) endif() MATH(EXPR index "${index} + 1") endwhile() unlock_devdax() endfunction() test_devdax(test_intr_tx_devdax) cleanup() pmdk-convert-1.7/tests/tx_intr_poolset_local_devdax_rep_devdax.cmake000066400000000000000000000053731354444011500263110ustar00rootroot00000000000000# # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) # prepare poolset with local replica on DAX devices for testing for each # version of PMDK function(prepare_files version) file(WRITE ${DIR}/pool${version} "PMEMPOOLSET AUTO ${devdax_1} REPLICA AUTO ${devdax_2}") execute(0 ${CMAKE_CURRENT_BINARY_DIR}/clean_pool ${devdax_1}) execute(0 ${CMAKE_CURRENT_BINARY_DIR}/clean_pool ${devdax_2}) execute(0 ${CMAKE_CURRENT_BINARY_DIR}/create_${version} ${DIR}/pool${version}) set(pool_file "${DIR}/pool${version}" PARENT_SCOPE) endfunction() function(test_devdax test_intr_tx_devdax) lock_devdax() setup() string(REPLACE " " ";" DEVICE_DAX_PATHS ${DEVICE_DAX_PATHS}) list(GET DEVICE_DAX_PATHS 0 devdax_1) list(GET DEVICE_DAX_PATHS 1 devdax_2) list(LENGTH VERSIONS num) math(EXPR num "${num} - 1") set(index 1) while(index LESS num) list(GET VERSIONS ${index} curr_version) math(EXPR next "${index} + 1") list(GET VERSIONS ${next} next_version) # DAX devices are supported from PMDK version 1.2 if(curr_version VERSION_GREATER "1.1") test_intr_tx_devdax(prepare_files ${curr_version} ${next_version}) endif() MATH(EXPR index "${index} + 1") endwhile() unlock_devdax() endfunction() test_devdax(test_intr_tx_devdax) cleanup() pmdk-convert-1.7/tests/tx_intr_poolset_local_regfile.cmake000066400000000000000000000042211354444011500242410ustar00rootroot00000000000000# # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) # prepare poolsets on regular file for testing for each version of PMDK function(prepare_files) setup() foreach(version ${VERSIONS}) string(REPLACE "." "" bin_version ${version}) file(WRITE ${DIR}/pool${bin_version}a "PMEMPOOLSET 16M ${DIR}/part${bin_version}a") execute(0 ${TEST_DIR}/create_${bin_version} ${DIR}/pool${bin_version}a) file(WRITE ${DIR}/pool${bin_version}c "PMEMPOOLSET 32M ${DIR}/part${bin_version}c") execute(0 ${TEST_DIR}/create_${bin_version} ${DIR}/pool${bin_version}c) endforeach() endfunction() test_intr_tx(prepare_files) cleanup() pmdk-convert-1.7/tests/tx_intr_poolset_local_regfile_rep_regfile.cmake000066400000000000000000000044021354444011500266050ustar00rootroot00000000000000# # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(${SRC_DIR}/helpers.cmake) # prepare poolsets with local replica on regular files for testing for each # version of PMDK function(prepare_files) setup() foreach(version ${VERSIONS}) string(REPLACE "." "" bin_version ${version}) file(WRITE ${DIR}/pool${bin_version}a "PMEMPOOLSET 16M ${DIR}/part${bin_version}a_rep1 REPLICA 16M ${DIR}/part${bin_version}a_rep2") execute(0 ${TEST_DIR}/create_${bin_version} ${DIR}/pool${bin_version}a) file(WRITE ${DIR}/pool${bin_version}c "PMEMPOOLSET 32M ${DIR}/part${bin_version}c_rep1 REPLICA 32M ${DIR}/part${bin_version}c_rep2") execute(0 ${TEST_DIR}/create_${bin_version} ${DIR}/pool${bin_version}c) endforeach() endfunction() test_intr_tx(prepare_files) cleanup() pmdk-convert-1.7/travis.yml000066400000000000000000000023031354444011500160240ustar00rootroot00000000000000dist: trusty sudo: required language: cpp services: - docker env: matrix: - TYPE=normal OS=ubuntu OS_VER=18.04 TEST_BUILD=Debug COVERAGE=1 - TYPE=normal OS=ubuntu OS_VER=18.04 TEST_BUILD=Debug CC=clang - TYPE=normal OS=ubuntu OS_VER=18.04 TEST_BUILD=Debug - TYPE=normal OS=ubuntu OS_VER=18.04 TEST_BUILD=Release CC=clang PUSH_IMAGE=1 - TYPE=normal OS=ubuntu OS_VER=18.04 TEST_BUILD=Release - TYPE=normal OS=fedora OS_VER=28 TEST_BUILD=Debug CC=clang - TYPE=normal OS=fedora OS_VER=28 TEST_BUILD=Debug - TYPE=normal OS=fedora OS_VER=28 TEST_BUILD=Release CC=clang PUSH_IMAGE=1 AUTO_DOC_UPDATE=1 - TYPE=normal OS=fedora OS_VER=28 TEST_BUILD=Release before_install: - echo $TRAVIS_COMMIT_RANGE - export HOST_WORKDIR=`pwd` - export GITHUB_REPO=pmem/pmdk-convert - export DOCKERHUB_REPO=pmem/pmdk-convert - cd utils/docker - ./pull-or-rebuild-image.sh - if [[ -f push_image_to_repo_flag ]]; then PUSH_THE_IMAGE=1; fi - if [[ -f skip_build_package_check ]]; then export SKIP_CHECK=1; fi - rm -f push_image_to_repo_flag skip_build_package_check script: - ./build.sh after_success: - if [[ $PUSH_THE_IMAGE -eq 1 ]]; then images/push-image.sh $OS-$OS_VER; fi pmdk-convert-1.7/utils/000077500000000000000000000000001354444011500151335ustar00rootroot00000000000000pmdk-convert-1.7/utils/check_license/000077500000000000000000000000001354444011500177125ustar00rootroot00000000000000pmdk-convert-1.7/utils/check_license/check-headers.sh000077500000000000000000000143541354444011500227460ustar00rootroot00000000000000#!/usr/bin/env bash # # Copyright 2016-2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # check-headers.sh - check copyright and license in source files SELF=$0 function usage() { echo "Usage: $SELF [-h|-v|-a]" echo " -h, --help this help message" echo " -v, --verbose verbose mode" echo " -a, --all check all files (only modified files are checked by default)" } if [ "$#" -lt 3 ]; then usage >&2 exit 2 fi SOURCE_ROOT=$1 shift CHECK_LICENSE=$1 shift LICENSE=$1 shift PATTERN=`mktemp` TMP=`mktemp` TMP2=`mktemp` TEMPFILE=`mktemp` rm -f $PATTERN $TMP $TMP2 function exit_if_not_exist() { if [ ! -f $1 ]; then echo "Error: file $1 does not exist. Exiting..." >&2 exit 1 fi } if [ "$1" == "-h" -o "$1" == "--help" ]; then usage exit 0 fi exit_if_not_exist $LICENSE exit_if_not_exist $CHECK_LICENSE export GIT="git -C ${SOURCE_ROOT}" $GIT rev-parse || exit 1 if [ -f $SOURCE_ROOT/.git/shallow ]; then SHALLOW_CLONE=1 echo echo "Warning: This is a shallow clone. Checking dates in copyright headers" echo " will be skipped in case of files that have no history." echo else SHALLOW_CLONE=0 fi VERBOSE=0 CHECK_ALL=0 while [ "$1" != "" ]; do case $1 in -v|--verbose) VERBOSE=1 ;; -a|--all) CHECK_ALL=1 ;; esac shift done if [ $CHECK_ALL -eq 0 ]; then CURRENT_COMMIT=$($GIT log --pretty=%H -1) MERGE_BASE=$($GIT merge-base HEAD origin/master 2>/dev/null) [ -z $MERGE_BASE ] && \ MERGE_BASE=$($GIT log --pretty="%cN:%H" | grep GitHub | head -n1 | cut -d: -f2) [ -z $MERGE_BASE -o "$CURRENT_COMMIT" = "$MERGE_BASE" ] && \ CHECK_ALL=1 fi if [ $CHECK_ALL -eq 1 ]; then echo "Checking copyright headers of all files..." GIT_COMMAND="ls-tree -r --name-only HEAD" else echo echo "Warning: will check copyright headers of modified files only," echo " in order to check all files issue the following command:" echo " $ $SELF -a" echo " (e.g.: $ $SELF $SOURCE_ROOT $CHECK_LICENSE $LICENSE -a)" echo echo "Checking copyright headers of modified files only..." GIT_COMMAND="diff --name-only $MERGE_BASE $CURRENT_COMMIT" fi FILES=$($GIT $GIT_COMMAND | ${SOURCE_ROOT}/utils/check_license/file-exceptions.sh | \ grep -E -e '*\.[chs]$' -e '*\.[ch]pp$' -e '*\.sh$' \ -e '*\.py$' -e '*\.map$' -e 'Makefile*' -e 'TEST*' \ -e '/common.inc$' -e '/match$' -e '/check_whitespace$' \ -e 'LICENSE$' -e 'CMakeLists.txt$' -e '*\.cmake$' | \ xargs) # jemalloc.mk has to be checked always, because of the grep rules above FILES="$FILES src/jemalloc/jemalloc.mk" # create a license pattern file $CHECK_LICENSE create $LICENSE $PATTERN [ $? -ne 0 ] && exit 1 RV=0 for file in $FILES ; do # The src_path is a path which should be used in every command except git. # git is called with -C flag so filepaths should be relative to SOURCE_ROOT src_path="${SOURCE_ROOT}/$file" [ ! -f $src_path ] && continue # ensure that file is UTF-8 encoded ENCODING=`file -b --mime-encoding $src_path` iconv -f $ENCODING -t "UTF-8" $src_path > $TEMPFILE YEARS=`$CHECK_LICENSE check-pattern $PATTERN $TEMPFILE $src_path` if [ $? -ne 0 ]; then echo -n $YEARS RV=1 else HEADER_FIRST=`echo $YEARS | cut -d"-" -f1` HEADER_LAST=` echo $YEARS | cut -d"-" -f2` if [ $SHALLOW_CLONE -eq 0 ]; then $GIT log --no-merges --format="%ai %aE" -- $file | sort > $TMP else # mark the grafted commits (commits with no parents) $GIT log --no-merges --format="%ai %aE grafted-%p-commit" -- $file | sort > $TMP fi # skip checking dates for non-Intel commits [[ ! $(tail -n1 $TMP) =~ "@intel.com" ]] && continue # skip checking dates for new files [ $(cat $TMP | wc -l) -le 1 ] && continue # grep out the grafted commits (commits with no parents) # and skip checking dates for non-Intel commits grep -v -e "grafted--commit" $TMP | grep -e "@intel.com" > $TMP2 [ $(cat $TMP2 | wc -l) -eq 0 ] && continue FIRST=`head -n1 $TMP2` LAST=` tail -n1 $TMP2` COMMIT_FIRST=`echo $FIRST | cut -d"-" -f1` COMMIT_LAST=` echo $LAST | cut -d"-" -f1` if [ "$COMMIT_FIRST" != "" -a "$COMMIT_LAST" != "" ]; then if [ $HEADER_LAST -lt $COMMIT_LAST ]; then if [ $HEADER_FIRST -lt $COMMIT_FIRST ]; then COMMIT_FIRST=$HEADER_FIRST fi COMMIT_LAST=`date +%G` if [ $COMMIT_FIRST -eq $COMMIT_LAST ]; then NEW=$COMMIT_LAST else NEW=$COMMIT_FIRST-$COMMIT_LAST fi echo "$file:1: error: wrong copyright date: (is: $YEARS, should be: $NEW)" >&2 RV=1 fi else echo "error: unknown commit dates in file: $file" >&2 RV=1 fi fi done rm -f $TMP $TMP2 $TEMPFILE # check if error found if [ $RV -eq 0 ]; then echo "Copyright headers are OK." else echo "Error(s) in copyright headers found!" >&2 fi exit $RV pmdk-convert-1.7/utils/check_license/check-license.c000066400000000000000000000312661354444011500225630ustar00rootroot00000000000000/* * Copyright 2016-2019, Intel Corporation * Copyright (c) 2016, Microsoft Corporation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * * Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * check-license.c -- check the license in the file */ #include #include #include #include #include #include #include #include #include #include #include #include #define LICENSE_MAX_LEN 2048 #define COPYRIGHT "Copyright " #define COPYRIGHT_LEN 10 #define COPYRIGHT_SYMBOL "(c) " #define COPYRIGHT_SYMBOL_LEN 4 #define YEAR_MIN 1900 #define YEAR_MAX 9999 #define YEAR_INIT_MIN 9999 #define YEAR_INIT_MAX 0 #define YEAR_LEN 4 #define LICENSE_BEG "Redistribution and use" #define LICENSE_END "THE POSSIBILITY OF SUCH DAMAGE." #define DIFF_LEN 50 #define COMMENT_STR_LEN 5 #define STR_MODE_CREATE "create" #define STR_MODE_PATTERN "check-pattern" #define STR_MODE_LICENSE "check-license" #define ERROR(fmt, ...) fprintf(stderr, "error: " fmt "\n", __VA_ARGS__) #define ERROR2(fmt, ...) fprintf(stderr, fmt "\n", __VA_ARGS__) /* * help_str -- string for the help message */ static const char * const help_str = "Usage: %s [filename]\n" "\n" "Modes:\n" " create \n" " - create a license pattern file \n" " from the license text file \n" "\n" " check-pattern \n" " - check if a license in \n" " matches the license pattern in ,\n" " if it does, copyright dates are printed out (see below)\n" "\n" " check-license \n" " - check if a license in \n" " matches the license text in ,\n" " if it does, copyright dates are printed out (see below)\n" "\n" "In case of 'check_pattern' and 'check_license' modes,\n" "if the license is correct, it prints out copyright dates\n" "in the following format: OLDEST_YEAR-NEWEST_YEAR\n" "\n" "Return value: returns 0 on success and -1 on error.\n" "\n"; /* * read_pattern -- read the pattern from the 'path_pattern' file to 'pattern' */ static int read_pattern(const char *path_pattern, char *pattern) { int file_pattern; ssize_t ret; if ((file_pattern = open(path_pattern, O_RDONLY)) == -1) { ERROR("open(): %s: %s", strerror(errno), path_pattern); return -1; } ret = read(file_pattern, pattern, LICENSE_MAX_LEN); close(file_pattern); if (ret == -1) { ERROR("read(): %s: %s", strerror(errno), path_pattern); return -1; } else if (ret != LICENSE_MAX_LEN) { ERROR("read(): incorrect format of the license pattern" " file (%s)", path_pattern); return -1; } return 0; } /* * write_pattern -- write 'pattern' to the 'path_pattern' file */ static int write_pattern(const char *path_pattern, char *pattern) { int file_pattern; ssize_t ret; if ((file_pattern = open(path_pattern, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IRGRP | S_IROTH)) == -1) { ERROR("open(): %s: %s", strerror(errno), path_pattern); return -1; } ret = write(file_pattern, pattern, LICENSE_MAX_LEN); close(file_pattern); if (ret < LICENSE_MAX_LEN) { ERROR("write(): %s: %s", strerror(errno), path_pattern); return -1; } return 0; } /* * strstr2 -- locate two substrings in the string */ static int strstr2(const char *str, const char *sub1, const char *sub2, char **pos1, char **pos2) { *pos1 = strstr(str, sub1); *pos2 = strstr(str, sub2); if (*pos1 == NULL || *pos2 == NULL) return -1; return 0; } /* * format_license -- remove comments and redundant whitespaces from the license */ static void format_license(char *license, size_t length) { char comment_str[COMMENT_STR_LEN]; char *comment = license; size_t comment_len; int was_space; size_t w, r; /* detect a comment string */ while (*comment != '\n') comment--; /* is there any comment? */ if (comment + 1 != license) { /* separate out a comment */ strncpy(comment_str, comment, COMMENT_STR_LEN - 1); comment_str[COMMENT_STR_LEN - 1] = 0; comment = comment_str + 1; while (isspace(*comment)) comment++; while (!isspace(*comment)) comment++; *comment = '\0'; comment_len = strlen(comment_str); /* replace comments with spaces */ if (comment_len > 2) { while ((comment = strstr(license, comment_str)) != NULL) for (w = 1; w < comment_len; w++) comment[w] = ' '; } else { while ((comment = strstr(license, comment_str)) != NULL) comment[1] = ' '; } } /* replace multiple spaces with one space */ was_space = 0; for (r = w = 0; r < length; r++) { if (!isspace(license[r])) { if (was_space) { license[w++] = ' '; was_space = 0; } if (w < r) license[w] = license[r]; w++; } else { if (!was_space) was_space = 1; } } license[w] = '\0'; } /* * analyze_license -- check correctness of the license */ static int analyze_license(const char *name_to_print, char *buffer, char **license) { char *_license; size_t _length; char *beg_str, *end_str; if (strstr2(buffer, LICENSE_BEG, LICENSE_END, &beg_str, &end_str)) { if (!beg_str) ERROR2("%s:1: error: incorrect license" " (license should start with the string '%s')", name_to_print, LICENSE_BEG); else ERROR2("%s:1: error: incorrect license" " (license should end with the string '%s')", name_to_print, LICENSE_END); return -1; } _license = beg_str; assert((uintptr_t)end_str > (uintptr_t)beg_str); _length = (size_t)(end_str - beg_str) + strlen(LICENSE_END); _license[_length] = '\0'; format_license(_license, _length); *license = _license; return 0; } /* * create_pattern -- create 'pattern' from the 'path_license' file */ static int create_pattern(const char *path_license, char *pattern) { char buffer[LICENSE_MAX_LEN]; char *license; ssize_t ret; int file_license; if ((file_license = open(path_license, O_RDONLY)) == -1) { ERROR("open(): %s: %s", strerror(errno), path_license); return -1; } memset(buffer, 0, sizeof(buffer)); ret = read(file_license, buffer, LICENSE_MAX_LEN); close(file_license); if (ret == -1) { ERROR("read(): %s: %s", strerror(errno), path_license); return -1; } if (analyze_license(path_license, buffer, &license) == -1) return -1; strncpy(pattern, license, LICENSE_MAX_LEN); return 0; } /* * print_diff -- print the first difference between 'license' and 'pattern' */ static void print_diff(char *license, char *pattern, size_t len) { size_t i = 0; while (i < len && license[i] == pattern[i]) i++; license[i + 1] = '\0'; pattern[i + 1] = '\0'; i = (i - DIFF_LEN > 0) ? (i - DIFF_LEN) : 0; while (i > 0 && license[i] != ' ') i--; fprintf(stderr, " The first difference is at the end of the line:\n"); fprintf(stderr, " * License: %s\n", license + i); fprintf(stderr, " * Pattern: %s\n", pattern + i); } /* * verify_license -- compare 'license' with 'pattern' and check correctness * of the copyright line */ static int verify_license(const char *path_to_check, char *pattern, const char *filename) { char buffer[LICENSE_MAX_LEN]; char *license, *copyright; int file_to_check; ssize_t ret; int year_first, year_last; int min_year_first = YEAR_INIT_MIN; int max_year_last = YEAR_INIT_MAX; char *err_str = NULL; const char *name_to_print = filename ? filename : path_to_check; if ((file_to_check = open(path_to_check, O_RDONLY)) == -1) { ERROR("open(): %s: %s", strerror(errno), path_to_check); return -1; } memset(buffer, 0, sizeof(buffer)); ret = read(file_to_check, buffer, LICENSE_MAX_LEN); close(file_to_check); if (ret == -1) { ERROR("read(): %s: %s", strerror(errno), name_to_print); return -1; } if (analyze_license(name_to_print, buffer, &license) == -1) return -1; /* check the copyright notice */ copyright = buffer; while ((copyright = strstr(copyright, COPYRIGHT)) != NULL) { copyright += COPYRIGHT_LEN; /* skip the copyright symbol '(c)' if any */ if (strncmp(copyright, COPYRIGHT_SYMBOL, COPYRIGHT_SYMBOL_LEN) == 0) copyright += COPYRIGHT_SYMBOL_LEN; /* look for the first year */ if (!isdigit(*copyright)) { err_str = "no digit just after the 'Copyright ' string"; break; } year_first = atoi(copyright); if (year_first < YEAR_MIN || year_first > YEAR_MAX) { err_str = "the first year is wrong"; break; } copyright += YEAR_LEN; if (year_first < min_year_first) min_year_first = year_first; if (year_first > max_year_last) max_year_last = year_first; /* check if there is the second year */ if (*copyright == ',') continue; else if (*copyright != '-') { err_str = "'-' or ',' expected after the first year"; break; } copyright++; /* look for the second year */ if (!isdigit(*copyright)) { err_str = "no digit after '-'"; break; } year_last = atoi(copyright); if (year_last < YEAR_MIN || year_last > YEAR_MAX) { err_str = "the second year is wrong"; break; } copyright += YEAR_LEN; if (year_last > max_year_last) max_year_last = year_last; if (*copyright != ',') { err_str = "',' expected after the second year"; break; } } if (!err_str && min_year_first == YEAR_INIT_MIN) err_str = "no 'Copyright ' string found"; if (err_str) /* found an error in the copyright notice */ ERROR2("%s:1: error: incorrect copyright notice: %s", name_to_print, err_str); /* now check the license */ if (memcmp(license, pattern, strlen(pattern)) != 0) { ERROR2("%s:1: error: incorrect license", name_to_print); print_diff(license, pattern, strlen(pattern)); return -1; } if (err_str) return -1; /* all checks passed */ if (min_year_first != max_year_last && max_year_last != YEAR_INIT_MAX) { printf("%i-%i\n", min_year_first, max_year_last); } else { printf("%i\n", min_year_first); } return 0; } /* * mode_create_pattern_file -- 'create' mode function */ static int mode_create_pattern_file(const char *path_license, const char *path_pattern) { char pattern[LICENSE_MAX_LEN]; if (create_pattern(path_license, pattern) == -1) return -1; return write_pattern(path_pattern, pattern); } /* * mode_check_pattern -- 'check_pattern' mode function */ static int mode_check_pattern(const char *path_license, const char *path_to_check) { char pattern[LICENSE_MAX_LEN]; if (create_pattern(path_license, pattern) == -1) return -1; return verify_license(path_to_check, pattern, NULL); } /* * mode_check_license -- 'check_license' mode function */ static int mode_check_license(const char *path_pattern, const char *path_to_check, const char *filename) { char pattern[LICENSE_MAX_LEN]; if (read_pattern(path_pattern, pattern) == -1) return -1; return verify_license(path_to_check, pattern, filename); } int main(int argc, char *argv[]) { if (strcmp(argv[1], STR_MODE_CREATE) == 0) { if (argc != 4) goto invalid_args; return mode_create_pattern_file(argv[2], argv[3]); } else if (strcmp(argv[1], STR_MODE_PATTERN) == 0) { if (argc != 5) goto invalid_args; return mode_check_license(argv[2], argv[3], argv[4]); } else if (strcmp(argv[1], STR_MODE_LICENSE) == 0) { if (argc != 4) goto invalid_args; return mode_check_pattern(argv[2], argv[3]); } else { ERROR("wrong mode: %s\n", argv[1]); } invalid_args: printf(help_str, argv[0]); return -1; } pmdk-convert-1.7/utils/check_license/file-exceptions.sh000077500000000000000000000032221354444011500233460ustar00rootroot00000000000000#!/bin/sh -e # # Copyright 2016-2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # file-exceptions.sh - filter out files not checked for copyright and license grep -v -E -e 'XXX' pmdk-convert-1.7/utils/check_whitespace000077500000000000000000000116311354444011500203540ustar00rootroot00000000000000#!/usr/bin/env perl # # Copyright 2015-2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # check_whitespace -- scrub source tree for whitespace errors # use strict; use warnings; use File::Basename; use File::Find; use Encode; use v5.16; my $Me = $0; $Me =~ s,.*/,,; $SIG{HUP} = $SIG{INT} = $SIG{TERM} = $SIG{__DIE__} = sub { die @_ if $^S; my $errstr = shift; die "$Me: ERROR: $errstr"; }; my $Errcount = 0; # # err -- emit error, keep total error count # sub err { warn @_, "\n"; $Errcount++; } # # decode_file_as_string -- slurp an entire file into memory and decode # sub decode_file_as_string { my ($full, $file) = @_; my $fh; open($fh, '<', $full) or die "$full $!\n"; local $/; $_ = <$fh>; close $fh; # check known encodings or die my $decoded; my @encodings = ("UTF-8", "UTF-16", "UTF-16LE", "UTF-16BE"); foreach my $enc (@encodings) { eval { $decoded = decode( $enc, $_, Encode::FB_CROAK ) }; if (!$@) { $decoded =~ s/\R/\n/g; return $decoded; } } die "$Me: ERROR: Unknown file encoding"; } # # check_whitespace -- run the checks on the given file # sub check_whitespace { my ($full, $file) = @_; my $line = 0; my $eol; my $nf = 0; my $fstr = decode_file_as_string($full, $file); for (split /^/, $fstr) { $line++; $eol = /[\n]/s; if (/^\.nf$/) { err("$full:$line: ERROR: nested .nf") if $nf; $nf = 1; } elsif (/^\.fi$/) { $nf = 0; } elsif ($nf == 0) { chomp; err("$full:$line: ERROR: trailing whitespace") if /\s$/; err("$full:$line: ERROR: spaces before tabs") if / \t/; } } err("$full:$line: .nf without .fi") if $nf; err("$full:$line: noeol") unless $eol; } sub check_whitespace_with_exc { my ($full) = @_; $_ = $full; return 0 if /^[.\/]*src\/jemalloc.*/; return 0 if /^[.\/]*src\/common\/queue\.h/; return 0 if /^[.\/]*src\/common\/valgrind\/.*\.h/; $_ = basename($full); return 0 unless /^(README.*|LICENSE.*|Makefile.*|CMakeLists.txt|.gitignore|TEST.*|RUNTESTS|check_whitespace|.*\.([chp13s]|sh|map|cpp|hpp|inc|PS1|ps1|py|md|cmake))$/; return 0 if -z; check_whitespace($full, $_); return 1; } my $verbose = 0; my $force = 0; my $recursive = 0; sub check { my ($file) = @_; my $r; if ($force) { $r = check_whitespace($file, basename($file)); } else { $r = check_whitespace_with_exc($file); } if ($verbose) { if ($r == 0) { printf("skipped $file\n"); } else { printf("checked $file\n"); } } } my @files = (); foreach my $arg (@ARGV) { if ($arg eq '-v') { $verbose = 1; next; } if ($arg eq '-f') { $force = 1; next; } if ($arg eq '-r') { $recursive = 1; next; } if ($arg eq '-g') { @files = `git ls-tree -r --name-only HEAD`; chomp(@files); next; } if ($arg eq '-h') { printf "Options: -g - check all files tracked by git -r dir - recursively check all files in specified directory -v verbose - print whether file was checked or not -f force - disable blacklist\n"; exit 1; } if ($recursive == 1) { find(sub { my $full = $File::Find::name; if (!$force && ($full eq './.git' || $full eq './src/jemalloc' || $full eq './src/debug' || $full eq './src/nondebug' || $full eq './rpmbuild' || $full eq './dpkgbuild')) { $File::Find::prune = 1; return; } return unless -f; push @files, $full; }, $arg); $recursive = 0; next; } push @files, $arg; } if (!@files) { printf "Empty file list!\n"; } foreach (@files) { check($_); } exit $Errcount; pmdk-convert-1.7/utils/cstyle000077500000000000000000000656401354444011500163770ustar00rootroot00000000000000#!/usr/bin/env perl # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # Portions copyright 2017, Intel Corporation. # # @(#)cstyle 1.58 98/09/09 (from shannon) #ident "%Z%%M% %I% %E% SMI" # # cstyle - check for some common stylistic errors. # # cstyle is a sort of "lint" for C coding style. # It attempts to check for the style used in the # kernel, sometimes known as "Bill Joy Normal Form". # # There's a lot this can't check for, like proper indentation # of code blocks. There's also a lot more this could check for. # # A note to the non perl literate: # # perl regular expressions are pretty much like egrep # regular expressions, with the following special symbols # # \s any space character # \S any non-space character # \w any "word" character [a-zA-Z0-9_] # \W any non-word character # \d a digit [0-9] # \D a non-digit # \b word boundary (between \w and \W) # \B non-word boundary # require 5.0; use IO::File; use Getopt::Std; use strict; use warnings; my $usage = "usage: cstyle [-chpvCP] [-o constructs] file ... -c check continuation indentation inside functions -h perform heuristic checks that are sometimes wrong -p perform some of the more picky checks -v verbose -C don't check anything in header block comments -P check for use of non-POSIX types -o constructs allow a comma-seperated list of optional constructs: doxygen allow doxygen-style block comments (/** /*!) splint allow splint-style lint comments (/*@ ... @*/) "; my %opts; if (!getopts("cho:pvCP", \%opts)) { print $usage; exit 2; } my $check_continuation = $opts{'c'}; my $heuristic = $opts{'h'}; my $picky = $opts{'p'}; my $verbose = $opts{'v'}; my $ignore_hdr_comment = $opts{'C'}; my $check_posix_types = $opts{'P'}; my $doxygen_comments = 0; my $splint_comments = 0; if (defined($opts{'o'})) { for my $x (split /,/, $opts{'o'}) { if ($x eq "doxygen") { $doxygen_comments = 1; } elsif ($x eq "splint") { $splint_comments = 1; } else { print "cstyle: unrecognized construct \"$x\"\n"; print $usage; exit 2; } } } my ($filename, $line, $prev); # shared globals my $fmt; my $hdr_comment_start; if ($verbose) { $fmt = "%s:%d: %s\n%s\n"; } else { $fmt = "%s:%d: %s\n"; } if ($doxygen_comments) { # doxygen comments look like "/*!" or "/**"; allow them. $hdr_comment_start = qr/^\s*\/\*[\!\*]?$/; } else { $hdr_comment_start = qr/^\s*\/\*$/; } # Note, following must be in single quotes so that \s and \w work right. my $typename = '(int|char|short|long|unsigned|float|double' . '|\w+_t|struct\s+\w+|union\s+\w+|FILE|BOOL)'; # mapping of old types to POSIX compatible types my %old2posix = ( 'unchar' => 'uchar_t', 'ushort' => 'ushort_t', 'uint' => 'uint_t', 'ulong' => 'ulong_t', 'u_int' => 'uint_t', 'u_short' => 'ushort_t', 'u_long' => 'ulong_t', 'u_char' => 'uchar_t', 'quad' => 'quad_t' ); my $lint_re = qr/\/\*(?: ARGSUSED[0-9]*|NOTREACHED|LINTLIBRARY|VARARGS[0-9]*| CONSTCOND|CONSTANTCOND|CONSTANTCONDITION|EMPTY| FALLTHRU|FALLTHROUGH|LINTED.*?|PRINTFLIKE[0-9]*| PROTOLIB[0-9]*|SCANFLIKE[0-9]*|CSTYLED.*? )\*\//x; my $splint_re = qr/\/\*@.*?@\*\//x; my $warlock_re = qr/\/\*\s*(?: VARIABLES\ PROTECTED\ BY| MEMBERS\ PROTECTED\ BY| ALL\ MEMBERS\ PROTECTED\ BY| READ-ONLY\ VARIABLES:| READ-ONLY\ MEMBERS:| VARIABLES\ READABLE\ WITHOUT\ LOCK:| MEMBERS\ READABLE\ WITHOUT\ LOCK:| LOCKS\ COVERED\ BY| LOCK\ UNNEEDED\ BECAUSE| LOCK\ NEEDED:| LOCK\ HELD\ ON\ ENTRY:| READ\ LOCK\ HELD\ ON\ ENTRY:| WRITE\ LOCK\ HELD\ ON\ ENTRY:| LOCK\ ACQUIRED\ AS\ SIDE\ EFFECT:| READ\ LOCK\ ACQUIRED\ AS\ SIDE\ EFFECT:| WRITE\ LOCK\ ACQUIRED\ AS\ SIDE\ EFFECT:| LOCK\ RELEASED\ AS\ SIDE\ EFFECT:| LOCK\ UPGRADED\ AS\ SIDE\ EFFECT:| LOCK\ DOWNGRADED\ AS\ SIDE\ EFFECT:| FUNCTIONS\ CALLED\ THROUGH\ POINTER| FUNCTIONS\ CALLED\ THROUGH\ MEMBER| LOCK\ ORDER: )/x; my $err_stat = 0; # exit status if ($#ARGV >= 0) { foreach my $arg (@ARGV) { my $fh = new IO::File $arg, "r"; if (!defined($fh)) { printf "%s: can not open\n", $arg; } else { &cstyle($arg, $fh); close $fh; } } } else { &cstyle("", *STDIN); } exit $err_stat; my $no_errs = 0; # set for CSTYLED-protected lines sub err($) { my ($error) = @_; unless ($no_errs) { if ($verbose) { printf $fmt, $filename, $., $error, $line; } else { printf $fmt, $filename, $., $error; } $err_stat = 1; } } sub err_prefix($$) { my ($prevline, $error) = @_; my $out = $prevline."\n".$line; unless ($no_errs) { printf $fmt, $filename, $., $error, $out; $err_stat = 1; } } sub err_prev($) { my ($error) = @_; unless ($no_errs) { printf $fmt, $filename, $. - 1, $error, $prev; $err_stat = 1; } } sub cstyle($$) { my ($fn, $filehandle) = @_; $filename = $fn; # share it globally my $in_cpp = 0; my $next_in_cpp = 0; my $in_comment = 0; my $in_header_comment = 0; my $comment_done = 0; my $in_warlock_comment = 0; my $in_function = 0; my $in_function_header = 0; my $in_declaration = 0; my $note_level = 0; my $nextok = 0; my $nocheck = 0; my $in_string = 0; my ($okmsg, $comment_prefix); $line = ''; $prev = ''; reset_indent(); line: while (<$filehandle>) { s/\r?\n$//; # strip return and newline # save the original line, then remove all text from within # double or single quotes, we do not want to check such text. $line = $_; # # C allows strings to be continued with a backslash at the end of # the line. We translate that into a quoted string on the previous # line followed by an initial quote on the next line. # # (we assume that no-one will use backslash-continuation with character # constants) # $_ = '"' . $_ if ($in_string && !$nocheck && !$in_comment); # # normal strings and characters # s/'([^\\']|\\[^xX0]|\\0[0-9]*|\\[xX][0-9a-fA-F]*)'/''/g; s/"([^\\"]|\\.)*"/\"\"/g; # # detect string continuation # if ($nocheck || $in_comment) { $in_string = 0; } else { # # Now that all full strings are replaced with "", we check # for unfinished strings continuing onto the next line. # $in_string = (s/([^"](?:"")*)"([^\\"]|\\.)*\\$/$1""/ || s/^("")*"([^\\"]|\\.)*\\$/""/); } # # figure out if we are in a cpp directive # $in_cpp = $next_in_cpp || /^\s*#/; # continued or started $next_in_cpp = $in_cpp && /\\$/; # only if continued # strip off trailing backslashes, which appear in long macros s/\s*\\$//; # an /* END CSTYLED */ comment ends a no-check block. if ($nocheck) { if (/\/\* *END *CSTYLED *\*\//) { $nocheck = 0; } else { reset_indent(); next line; } } # a /*CSTYLED*/ comment indicates that the next line is ok. if ($nextok) { if ($okmsg) { err($okmsg); } $nextok = 0; $okmsg = 0; if (/\/\* *CSTYLED.*\*\//) { /^.*\/\* *CSTYLED *(.*) *\*\/.*$/; $okmsg = $1; $nextok = 1; } $no_errs = 1; } elsif ($no_errs) { $no_errs = 0; } # check length of line. # first, a quick check to see if there is any chance of being too long. if (($line =~ tr/\t/\t/) * 7 + length($line) > 80) { # yes, there is a chance. # replace tabs with spaces and check again. my $eline = $line; 1 while $eline =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e; if (length($eline) > 80) { # allow long line if it is user visible string # find if line start from " and ends # with " + 2 optional characters # (these characters can be i.e. '");' '" \' or '",' etc...) if($eline =~ /^ *".*"[^"]{0,2}$/) { # check if entire line is one string literal $eline =~ s/^ *"//; $eline =~ s/"[^"]{0,2}$//; if($eline =~ /[^\\]"|[^\\](\\\\)+"/) { err("line > 80 characters"); } } else { err("line > 80 characters"); } } } # ignore NOTE(...) annotations (assumes NOTE is on lines by itself). if ($note_level || /\b_?NOTE\s*\(/) { # if in NOTE or this is NOTE s/[^()]//g; # eliminate all non-parens $note_level += s/\(//g - length; # update paren nest level next; } # a /* BEGIN CSTYLED */ comment starts a no-check block. if (/\/\* *BEGIN *CSTYLED *\*\//) { $nocheck = 1; } # a /*CSTYLED*/ comment indicates that the next line is ok. if (/\/\* *CSTYLED.*\*\//) { /^.*\/\* *CSTYLED *(.*) *\*\/.*$/; $okmsg = $1; $nextok = 1; } if (/\/\/ *CSTYLED/) { /^.*\/\/ *CSTYLED *(.*)$/; $okmsg = $1; $nextok = 1; } # universal checks; apply to everything if (/\t +\t/) { err("spaces between tabs"); } if (/ \t+ /) { err("tabs between spaces"); } if (/\s$/) { err("space or tab at end of line"); } if (/[^ \t(]\/\*/ && !/\w\(\/\*.*\*\/\);/) { err("comment preceded by non-blank"); } # is this the beginning or ending of a function? # (not if "struct foo\n{\n") if (/^{$/ && $prev =~ /\)\s*(const\s*)?(\/\*.*\*\/\s*)?\\?$/) { $in_function = 1; $in_declaration = 1; $in_function_header = 0; $prev = $line; next line; } if (/^}\s*(\/\*.*\*\/\s*)*$/) { if ($prev =~ /^\s*return\s*;/) { err_prev("unneeded return at end of function"); } $in_function = 0; reset_indent(); # we don't check between functions $prev = $line; next line; } if (/^\w*\($/) { $in_function_header = 1; } if ($in_warlock_comment && /\*\//) { $in_warlock_comment = 0; $prev = $line; next line; } # a blank line terminates the declarations within a function. # XXX - but still a problem in sub-blocks. if ($in_declaration && /^$/) { $in_declaration = 0; } if ($comment_done) { $in_comment = 0; $in_header_comment = 0; $comment_done = 0; } # does this looks like the start of a block comment? if (/$hdr_comment_start/) { if (!/^\t*\/\*/) { err("block comment not indented by tabs"); } $in_comment = 1; /^(\s*)\//; $comment_prefix = $1; if ($comment_prefix eq "") { $in_header_comment = 1; } $prev = $line; next line; } # are we still in the block comment? if ($in_comment) { if (/^$comment_prefix \*\/$/) { $comment_done = 1; } elsif (/\*\//) { $comment_done = 1; err("improper block comment close") unless ($ignore_hdr_comment && $in_header_comment); } elsif (!/^$comment_prefix \*[ \t]/ && !/^$comment_prefix \*$/) { err("improper block comment") unless ($ignore_hdr_comment && $in_header_comment); } } if ($in_header_comment && $ignore_hdr_comment) { $prev = $line; next line; } # check for errors that might occur in comments and in code. # allow spaces to be used to draw pictures in header and block comments. if (/[^ ] / && !/".* .*"/ && !$in_header_comment && !$in_comment) { err("spaces instead of tabs"); } if (/^ / && !/^ \*[ \t\/]/ && !/^ \*$/ && (!/^ \w/ || $in_function != 0)) { err("indent by spaces instead of tabs"); } if (/^\t+ [^ \t\*]/ || /^\t+ \S/ || /^\t+ \S/) { err("continuation line not indented by 4 spaces"); } if (/$warlock_re/ && !/\*\//) { $in_warlock_comment = 1; $prev = $line; next line; } if (/^\s*\/\*./ && !/^\s*\/\*.*\*\// && !/$hdr_comment_start/) { err("improper first line of block comment"); } if ($in_comment) { # still in comment, don't do further checks $prev = $line; next line; } if ((/[^(]\/\*\S/ || /^\/\*\S/) && !(/$lint_re/ || ($splint_comments && /$splint_re/))) { err("missing blank after open comment"); } if (/\S\*\/[^)]|\S\*\/$/ && !(/$lint_re/ || ($splint_comments && /$splint_re/))) { err("missing blank before close comment"); } if (/\/\/\S/) { # C++ comments err("missing blank after start comment"); } # check for unterminated single line comments, but allow them when # they are used to comment out the argument list of a function # declaration. if (/\S.*\/\*/ && !/\S.*\/\*.*\*\// && !/\(\/\*/) { err("unterminated single line comment"); } if (/^(#else|#endif|#include)(.*)$/) { $prev = $line; if ($picky) { my $directive = $1; my $clause = $2; # Enforce ANSI rules for #else and #endif: no noncomment # identifiers are allowed after #endif or #else. Allow # C++ comments since they seem to be a fact of life. if ((($1 eq "#endif") || ($1 eq "#else")) && ($clause ne "") && (!($clause =~ /^\s+\/\*.*\*\/$/)) && (!($clause =~ /^\s+\/\/.*$/))) { err("non-comment text following " . "$directive (or malformed $directive " . "directive)"); } } next line; } # # delete any comments and check everything else. Note that # ".*?" is a non-greedy match, so that we don't get confused by # multiple comments on the same line. # s/\/\*.*?\*\//\x01/g; s/\/\/.*$/\x01/; # C++ comments # delete any trailing whitespace; we have already checked for that. s/\s*$//; # following checks do not apply to text in comments. if (/[^ \t\+]\+[^\+=]/ || /[^\+]\+[^ \+=]/) { err("missing space around + operator"); } if (/[^ \t]\+=/ || /\+=[^ ]/) { err("missing space around += operator"); } if (/[^ \t\-]\-[^\->]/ && !/\(\w+\)\-\w/ && !/[\(\[]\-[\w \t]+[\)\],]/) { err("missing space before - operator"); } if (/[^\-]\-[^ \-=>]/ && !/\(\-\w+\)/ && !/(return|case|=|>|<|\?|:|,|^[ \t]+)[ \t]+\-[\w\(]/ && !/(\([^\)]+\)|\[|\()\-[\w\(\]]/) { err("missing space after - operator"); } if (/(return|case|=|\?|:|,|\[)[ \t]+\-[ \t]/ || /[\(\[]\-[ \t]/) { err("extra space after - operator"); } if (/[^ \t]\-=/ || /\-=[^ ]/) { err("missing space around -= operator"); } if (/[^ \t][\%\/]/ || /[\%\/][^ =]/ || /[\%\/]=[^ ]/) { err("missing space around one of operators: % %= / /="); } if (/[^ \t]\*=/ || /\*=[^ ]/) { err("missing space around *= operator"); } if (/[^ \t\(\)\*\[]\*/) { err("missing space before * operator"); } if (/\*[^ =\*\w\(,]/ && !/\(.+ \*+\)/ && !/\*\[\]/ && !/\*\-\-\w/ && !/\*\+\+\w/ && !/\*\)/) { err("missing space after * operator"); } if (/[^<>\s][!<>=]=/ || /[^<>][!<>=]=[^\s,]/ || (/[^->]>[^,=>\s]/ && !/[^->]>$/) || (/[^<]<[^,=<\s]/ && !/[^<]<$/) || /[^<\s]<[^<]/ || /[^->\s]>[^>]/) { err("missing space around relational operator"); } if (/\S>>=/ || /\S<<=/ || />>=\S/ || /<<=\S/ || /\S[-+*\/&|^%]=/ || (/[^-+*\/&|^%!<>=\s]=[^=]/ && !/[^-+*\/&|^%!<>=\s]=$/) || (/[^!<>=]=[^=\s]/ && !/[^!<>=]=$/)) { # XXX - should only check this for C++ code # XXX - there are probably other forms that should be allowed if (!/\soperator=/) { err("missing space around assignment operator"); } } if (/[,;]\S/ && !/\bfor \(;;\)/) { err("comma or semicolon followed by non-blank"); } # allow "for" statements to have empty "while" clauses if (/\s[,;]/ && !/^[\t]+;$/ && !/^\s*for \([^;]*; ;[^;]*\)/) { err("comma or semicolon preceded by blank"); } if (/^\s*(&&|\|\|)/) { err("improper boolean continuation"); } if (/\S *(&&|\|\|)/ || /(&&|\|\|) *\S/) { err("more than one space around boolean operator"); } if (/\b(for|if|while|switch|return|case)\(/) { err("missing space between keyword and paren"); } if (/(\b(for|if|while|switch|return)\b.*){2,}/ && !/^#define/) { # multiple "case" and "sizeof" allowed err("more than one keyword on line"); } if (/\b(for|if|while|switch|return|case)\s\s+\(/ && !/^#if\s+\(/) { err("extra space between keyword and paren"); } # try to detect "func (x)" but not "if (x)" or # "#define foo (x)" or "int (*func)();" if (/\w\s\(/) { my $s = $_; # strip off all keywords on the line s/\b(for|if|while|switch|return|case)\s\(/XXX(/g; s/\b(sizeof|typeof|__typeof__)\s*\(/XXX(/g; s/#elif\s\(/XXX(/g; s/^#define\s+\w+\s+\(/XXX(/; # do not match things like "void (*f)();" # or "typedef void (func_t)();" s/\w\s\(+\*/XXX(*/g; s/\b($typename|void)\s+\(+/XXX(/og; s/\btypedef\s($typename|void)\s+\(+/XXX(/og; # do not match "__attribute__ ((format (...)))" s/\b__attribute__\s*\(\(format\s*\(/__attribute__((XXX(/g; if (/\w\s\(/) { err("extra space between function name and left paren"); } $_ = $s; } # try to detect "int foo(x)", but not "extern int foo(x);" # XXX - this still trips over too many legitimate things, # like "int foo(x,\n\ty);" # if (/^(\w+(\s|\*)+)+\w+\(/ && !/\)[;,](\s|\x01)*$/ && # !/^(extern|static)\b/) { # err("return type of function not on separate line"); # } # this is a close approximation if (/^(\w+(\s|\*)+)+\w+\(.*\)(\s|\x01)*$/ && !/^(extern|static)\b/) { err("return type of function not on separate line"); } if (/^#define\t/ || /^#ifdef\t/ || /^#ifndef\t/) { err("#define/ifdef/ifndef followed by tab instead of space"); } if (/^#define\s\s+/ || /^#ifdef\s\s+/ || /^#ifndef\s\s+/) { err("#define/ifdef/ifndef followed by more than one space"); } # AON C-style doesn't require this. #if (/^\s*return\W[^;]*;/ && !/^\s*return\s*\(.*\);/) { # err("unparenthesized return expression"); #} if (/\bsizeof\b/ && !/\bsizeof\s*\(.*\)/) { err("unparenthesized sizeof expression"); } if (/\b(sizeof|typeof)\b/ && /\b(sizeof|typeof)\s+\(.*\)/) { err("spaces between sizeof/typeof expression and paren"); } if (/\(\s/) { err("whitespace after left paren"); } # allow "for" statements to have empty "continue" clauses if (/\s\)/ && !/^\s*for \([^;]*;[^;]*; \)/) { err("whitespace before right paren"); } if (/^\s*\(void\)[^ ]/) { err("missing space after (void) cast"); } if (/\S\{/ && !/\{\{/ && !/\(struct \w+\)\{/) { err("missing space before left brace"); } if ($in_function && /^\s+{/ && ($prev =~ /\)\s*$/ || $prev =~ /\bstruct\s+\w+$/)) { err("left brace starting a line"); } if (/}(else|while)/) { err("missing space after right brace"); } if (/}\s\s+(else|while)/) { err("extra space after right brace"); } if (/\b_VOID\b|\bVOID\b|\bSTATIC\b/) { err("obsolete use of VOID or STATIC"); } if (/\b($typename|void)\*/o) { err("missing space between type name and *"); } if (/^\s+#/) { err("preprocessor statement not in column 1"); } if (/^#\s/) { err("blank after preprocessor #"); } if (/!\s*(strcmp|strncmp|bcmp)\s*\(/) { err("don't use boolean ! with comparison functions"); } if (/^\S+\([\S\s]*\)\s*{/) { err("brace of function definition not at beginning of line"); } if (/static\s+\S+\s*=\s*(0|NULL)\s*;/) { err("static variable initialized with 0 or NULL"); } if (/typedef[\S\s]+\*\s*\w+\s*;/) { err("typedefed pointer type"); } if (/unsigned\s+int/) { err("'unsigned int' instead of just 'unsigned'"); } if (/long\s+long\s+int/) { err("'long long int' instead of just 'long long'"); } elsif (/long\s+int/) { err("'long int' instead of just 'long'"); } # # We completely ignore, for purposes of indentation: # * lines outside of functions # * preprocessor lines # if ($check_continuation && $in_function && !$in_cpp) { process_indent($_); } if ($picky) { # try to detect spaces after casts, but allow (e.g.) # "sizeof (int) + 1", "void (*funcptr)(int) = foo;", and # "int foo(int) __NORETURN;" if ((/^\($typename( \*+)?\)\s/o || /\W\($typename( \*+)?\)\s/o) && !/sizeof\($typename( \*)?\)\s/o && !/\($typename( \*+)?\)\s+=[^=]/o) { err("space after cast"); } if (/\b($typename|void)\s*\*\s/o && !/\b($typename|void)\s*\*\s+const\b/o) { err("unary * followed by space"); } } if ($check_posix_types) { # try to detect old non-POSIX types. # POSIX requires all non-standard typedefs to end in _t, # but historically these have been used. if (/\b(unchar|ushort|uint|ulong|u_int|u_short|u_long|u_char|quad)\b/) { err("non-POSIX typedef $1 used: use $old2posix{$1} instead"); } } if ($heuristic) { # cannot check this everywhere due to "struct {\n...\n} foo;" if ($in_function && !$in_declaration && /}./ && !/}\s+=/ && !/{.*}[;,]$/ && !/}(\s|\x01)*$/ && !/} (else|while)/ && !/}}/) { err("possible bad text following right brace"); } # cannot check this because sub-blocks in # the middle of code are ok if ($in_function && /^\s+{/) { err("possible left brace starting a line"); } } if (/^\s*else\W/) { if ($prev =~ /^\s*}$/) { err_prefix($prev, "else and right brace should be on same line"); } } $prev = $line; } if ($prev eq "") { err("last line in file is blank"); } } # # Continuation-line checking # # The rest of this file contains the code for the continuation checking # engine. It's a pretty simple state machine which tracks the expression # depth (unmatched '('s and '['s). # # Keep in mind that the argument to process_indent() has already been heavily # processed; all comments have been replaced by control-A, and the contents of # strings and character constants have been elided. # my $cont_in; # currently inside of a continuation my $cont_off; # skipping an initializer or definition my $cont_noerr; # suppress cascading errors my $cont_start; # the line being continued my $cont_base; # the base indentation my $cont_first; # this is the first line of a statement my $cont_multiseg; # this continuation has multiple segments my $cont_special; # this is a C statement (if, for, etc.) my $cont_macro; # this is a macro my $cont_case; # this is a multi-line case my @cont_paren; # the stack of unmatched ( and [s we've seen sub reset_indent() { $cont_in = 0; $cont_off = 0; } sub delabel($) { # # replace labels with tabs. Note that there may be multiple # labels on a line. # local $_ = $_[0]; while (/^(\t*)( *(?:(?:\w+\s*)|(?:case\b[^:]*)): *)(.*)$/) { my ($pre_tabs, $label, $rest) = ($1, $2, $3); $_ = $pre_tabs; while ($label =~ s/^([^\t]*)(\t+)//) { $_ .= "\t" x (length($2) + length($1) / 8); } $_ .= ("\t" x (length($label) / 8)).$rest; } return ($_); } sub process_indent($) { require strict; local $_ = $_[0]; # preserve the global $_ s/\x01//g; # No comments s/\s+$//; # Strip trailing whitespace return if (/^$/); # skip empty lines # regexps used below; keywords taking (), macros, and continued cases my $special = '(?:(?:\}\s*)?else\s+)?(?:if|for|while|switch)\b'; my $macro = '[A-Z_][A-Z_0-9]*\('; my $case = 'case\b[^:]*$'; # skip over enumerations, array definitions, initializers, etc. if ($cont_off <= 0 && !/^\s*$special/ && (/(?:(?:\b(?:enum|struct|union)\s*[^\{]*)|(?:\s+=\s*))\{/ || (/^\s*{/ && $prev =~ /=\s*(?:\/\*.*\*\/\s*)*$/))) { $cont_in = 0; $cont_off = tr/{/{/ - tr/}/}/; return; } if ($cont_off) { $cont_off += tr/{/{/ - tr/}/}/; return; } if (!$cont_in) { $cont_start = $line; if (/^\t* /) { err("non-continuation indented 4 spaces"); $cont_noerr = 1; # stop reporting } $_ = delabel($_); # replace labels with tabs # check if the statement is complete return if (/^\s*\}?$/); return if (/^\s*\}?\s*else\s*\{?$/); return if (/^\s*do\s*\{?$/); return if (/{$/); return if (/}[,;]?$/); # Allow macros on their own lines return if (/^\s*[A-Z_][A-Z_0-9]*$/); # cases we don't deal with, generally non-kosher if (/{/) { err("stuff after {"); return; } # Get the base line, and set up the state machine /^(\t*)/; $cont_base = $1; $cont_in = 1; @cont_paren = (); $cont_first = 1; $cont_multiseg = 0; # certain things need special processing $cont_special = /^\s*$special/? 1 : 0; $cont_macro = /^\s*$macro/? 1 : 0; $cont_case = /^\s*$case/? 1 : 0; } else { $cont_first = 0; # Strings may be pulled back to an earlier (half-)tabstop unless ($cont_noerr || /^$cont_base / || (/^\t*(?: )?(?:gettext\()?\"/ && !/^$cont_base\t/)) { err_prefix($cont_start, "continuation should be indented 4 spaces"); } } my $rest = $_; # keeps the remainder of the line # # The split matches 0 characters, so that each 'special' character # is processed separately. Parens and brackets are pushed and # popped off the @cont_paren stack. For normal processing, we wait # until a ; or { terminates the statement. "special" processing # (if/for/while/switch) is allowed to stop when the stack empties, # as is macro processing. Case statements are terminated with a : # and an empty paren stack. # foreach $_ (split /[^\(\)\[\]\{\}\;\:]*/) { next if (length($_) == 0); # rest contains the remainder of the line my $rxp = "[^\Q$_\E]*\Q$_\E"; $rest =~ s/^$rxp//; if (/\(/ || /\[/) { push @cont_paren, $_; } elsif (/\)/ || /\]/) { my $cur = $_; tr/\)\]/\(\[/; my $old = (pop @cont_paren); if (!defined($old)) { err("unexpected '$cur'"); $cont_in = 0; last; } elsif ($old ne $_) { err("'$cur' mismatched with '$old'"); $cont_in = 0; last; } # # If the stack is now empty, do special processing # for if/for/while/switch and macro statements. # next if (@cont_paren != 0); if ($cont_special) { if ($rest =~ /^\s*{?$/) { $cont_in = 0; last; } if ($rest =~ /^\s*;$/) { err("empty if/for/while body ". "not on its own line"); $cont_in = 0; last; } if (!$cont_first && $cont_multiseg == 1) { err_prefix($cont_start, "multiple statements continued ". "over multiple lines"); $cont_multiseg = 2; } elsif ($cont_multiseg == 0) { $cont_multiseg = 1; } # We've finished this section, start # processing the next. goto section_ended; } if ($cont_macro) { if ($rest =~ /^$/) { $cont_in = 0; last; } } } elsif (/\;/) { if ($cont_case) { err("unexpected ;"); } elsif (!$cont_special) { err("unexpected ;") if (@cont_paren != 0); if (!$cont_first && $cont_multiseg == 1) { err_prefix($cont_start, "multiple statements continued ". "over multiple lines"); $cont_multiseg = 2; } elsif ($cont_multiseg == 0) { $cont_multiseg = 1; } if ($rest =~ /^$/) { $cont_in = 0; last; } if ($rest =~ /^\s*special/) { err("if/for/while/switch not started ". "on its own line"); } goto section_ended; } } elsif (/\{/) { err("{ while in parens/brackets") if (@cont_paren != 0); err("stuff after {") if ($rest =~ /[^\s}]/); $cont_in = 0; last; } elsif (/\}/) { err("} while in parens/brackets") if (@cont_paren != 0); if (!$cont_special && $rest !~ /^\s*(while|else)\b/) { if ($rest =~ /^$/) { err("unexpected }"); } else { err("stuff after }"); } $cont_in = 0; last; } } elsif (/\:/ && $cont_case && @cont_paren == 0) { err("stuff after multi-line case") if ($rest !~ /$^/); $cont_in = 0; last; } next; section_ended: # End of a statement or if/while/for loop. Reset # cont_special and cont_macro based on the rest of the # line. $cont_special = ($rest =~ /^\s*$special/)? 1 : 0; $cont_macro = ($rest =~ /^\s*$macro/)? 1 : 0; $cont_case = 0; next; } $cont_noerr = 0 if (!$cont_in); } pmdk-convert-1.7/utils/docker/000077500000000000000000000000001354444011500164025ustar00rootroot00000000000000pmdk-convert-1.7/utils/docker/build.sh000077500000000000000000000071451354444011500200470ustar00rootroot00000000000000#!/usr/bin/env bash # # Copyright 2017-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # build.sh - runs a Docker container from a Docker image with environment # prepared for running pmdk-convert tests and run these tests. # # # Notes: # - run this script from its location or set the variable 'HOST_WORKDIR' to # where the root of this project is on the host machine, # - set variables 'OS' and 'OS_VER' properly to a system you want to build this # repo on (for proper values take a look on the list of Dockerfiles at the # utils/docker/images directory), eg. OS=ubuntu, OS_VER=16.04. # set -e if [[ -z "$OS" || -z "$OS_VER" ]]; then echo "ERROR: The variables OS and OS_VER have to be set " \ "(eg. OS=ubuntu, OS_VER=16.04)." exit 1 fi if [[ -z "$HOST_WORKDIR" ]]; then HOST_WORKDIR=$(readlink -f ../..) fi chmod -R a+w $HOST_WORKDIR imageName=${DOCKERHUB_REPO}:${OS}-${OS_VER} containerName=pmdk-convert-${OS}-${OS_VER} if [[ "$command" == "" ]]; then command="./run-build.sh"; fi if [ -n "$DNS_SERVER" ]; then DNS_SETTING=" --dns=$DNS_SERVER "; fi # Only run doc update on pmem/pmdk-convert master branch if [[ "$TRAVIS_BRANCH" != "master" || "$TRAVIS_PULL_REQUEST" != "false" || "$TRAVIS_REPO_SLUG" != "${GITHUB_REPO}" ]]; then AUTO_DOC_UPDATE=0 fi WORKDIR=/pmdk-convert SCRIPTSDIR=$WORKDIR/utils/docker echo Building ${OS}-${OS_VER} ci_env=`bash <(curl -s https://codecov.io/env)` # Run a container with # - environment variables set (--env) # - host directory containing source mounted (-v) # - working directory set (-w) docker run --privileged=true --name=$containerName -ti \ $DNS_SETTING \ ${docker_opts} \ $ci_env \ --env http_proxy=$http_proxy \ --env https_proxy=$https_proxy \ --env AUTO_DOC_UPDATE=$AUTO_DOC_UPDATE \ --env GITHUB_TOKEN=$GITHUB_TOKEN \ --env WORKDIR=$WORKDIR \ --env SCRIPTSDIR=$SCRIPTSDIR \ --env COVERAGE=$COVERAGE \ --env TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \ --env TRAVIS_BRANCH=$TRAVIS_BRANCH \ --env TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \ --env TEST_BUILD=$TEST_BUILD \ --env CC=$CC \ -v $HOST_WORKDIR:$WORKDIR \ -v /etc/localtime:/etc/localtime \ -w $SCRIPTSDIR \ $imageName $command pmdk-convert-1.7/utils/docker/images/000077500000000000000000000000001354444011500176475ustar00rootroot00000000000000pmdk-convert-1.7/utils/docker/images/Dockerfile.fedora-28000066400000000000000000000045131354444011500233320ustar00rootroot00000000000000# # Copyright 2016-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Dockerfile - a 'recipe' for Docker to build an image of fedora-based # environment prepared for running pmdk-convert tests. # # Pull base image FROM fedora:28 MAINTAINER marcin.slusarz@intel.com # Install basic tools RUN dnf update -y \ && dnf install -y \ autoconf \ automake \ clang \ cmake \ gcc \ gdb \ git \ hub \ libunwind-devel \ make \ man \ pandoc \ passwd \ perl-Text-Diff \ rpm-build \ sudo \ tar \ wget \ which \ && dnf clean all # Install pmdk COPY download-pmdk.sh download-pmdk.sh RUN ./download-pmdk.sh rpm # Add user ENV USER user ENV USERPASS pass RUN useradd -m $USER RUN echo $USERPASS | passwd $USER --stdin RUN gpasswd wheel -a $USER USER $USER # Set required environment variables ENV OS fedora ENV OS_VER 28 ENV PACKAGE_MANAGER rpm ENV NOTTY 1 pmdk-convert-1.7/utils/docker/images/Dockerfile.ubuntu-18.04000066400000000000000000000045341354444011500236400ustar00rootroot00000000000000# # Copyright 2016-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Dockerfile - a 'recipe' for Docker to build an image of ubuntu-based # environment prepared for running pmdk-convert tests. # # Pull base image FROM ubuntu:18.04 MAINTAINER marcin.slusarz@intel.com # Update the Apt cache and install basic tools RUN apt-get update \ && apt-get install -y software-properties-common \ autoconf \ clang \ cmake \ curl \ debhelper \ devscripts \ gcc \ gdb \ git \ libunwind8-dev \ libtext-diff-perl \ pkg-config \ sudo \ wget \ whois \ && rm -rf /var/lib/apt/lists/* # Install pmdk COPY download-pmdk.sh download-pmdk.sh RUN ./download-pmdk.sh deb # Add user ENV USER user ENV USERPASS pass RUN useradd -m $USER -g sudo -p `mkpasswd $USERPASS` USER $USER # Set required environment variables ENV OS ubuntu ENV OS_VER 18.04 ENV PACKAGE_MANAGER deb ENV NOTTY 1 pmdk-convert-1.7/utils/docker/images/build-image.sh000077500000000000000000000050071354444011500223670ustar00rootroot00000000000000#!/usr/bin/env bash # # Copyright 2016-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # build-image.sh - prepares a Docker image with -based # environment for testing pmdk-convert, according # to the Dockerfile. file located # in the same directory. # # The script can be run locally. # set -e function usage { echo "Usage:" echo " build-image.sh " echo "where , for example, can be 'ubuntu-16.04', provided " \ "a Dockerfile named 'Dockerfile.ubuntu-16.04' exists in the " \ "current directory." } # Check if the first and second argument is nonempty if [[ -z "$1" || -z "$2" ]]; then usage exit 1 fi # Check if the file Dockerfile.OS-VER exists if [[ ! -f "Dockerfile.$2" ]]; then echo "ERROR: wrong argument." usage exit 1 fi # Build a Docker image tagged with ${DOCKERHUB_REPO}:OS-VER docker build -t $1:$2 \ --build-arg http_proxy=$http_proxy \ --build-arg https_proxy=$https_proxy \ -f Dockerfile.$2 . pmdk-convert-1.7/utils/docker/images/download-pmdk.sh000077500000000000000000000043631354444011500227540ustar00rootroot00000000000000#!/usr/bin/env bash # # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # download-pmdk.sh - download pmdk sources # set -e mkdir /opt/pmdk wget https://github.com/pmem/pmdk/archive/cf5d532da36893334b7ec8db0a2b296151733d0e.tar.gz -O /opt/pmdk/cf5d532da36893334b7ec8db0a2b296151733d0e.tar.gz wget https://github.com/pmem/pmdk/archive/1.5.1.tar.gz -O /opt/pmdk/1.5.1.tar.gz wget https://github.com/pmem/pmdk/archive/1.4.2.tar.gz -O /opt/pmdk/1.4.2.tar.gz wget https://github.com/pmem/pmdk/archive/1.3.1.tar.gz -O /opt/pmdk/1.3.1.tar.gz wget https://github.com/pmem/pmdk/archive/1.2.3.tar.gz -O /opt/pmdk/1.2.3.tar.gz wget https://github.com/pmem/pmdk/archive/1.1.tar.gz -O /opt/pmdk/1.1.tar.gz wget https://github.com/pmem/pmdk/archive/1.0.tar.gz -O /opt/pmdk/1.0.tar.gz pmdk-convert-1.7/utils/docker/images/push-image.sh000077500000000000000000000050441354444011500222500ustar00rootroot00000000000000#!/usr/bin/env bash # # Copyright 2016-2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # push-image.sh - pushes the Docker image tagged with OS-VER # to the Docker Hub. # # The script utilizes $DOCKERHUB_USER and $DOCKERHUB_PASSWORD variables to log in to # Docker Hub. The variables can be set in the Travis project's configuration # for automated builds. # set -e function usage { echo "Usage:" echo " push-image.sh " echo "where , for example, can be 'ubuntu-16.04', provided " \ "a Docker image tagged with ${DOCKERHUB_REPO}:ubuntu-16.04 exists " \ "locally." } # Check if the first argument is nonempty if [[ -z "$1" ]]; then usage exit 1 fi # Check if the image tagged with ${DOCKERHUB_REPO}:OS-VER exists locally if [[ ! $(docker images -a | awk -v pattern="^${DOCKERHUB_REPO}:$1\$" \ '$1":"$2 ~ pattern') ]] then echo "ERROR: wrong argument." usage exit 1 fi # Log in to the Docker Hub docker login -u="$DOCKERHUB_USER" -p="$DOCKERHUB_PASSWORD" # Push the image to the repository docker push ${DOCKERHUB_REPO}:$1 pmdk-convert-1.7/utils/docker/pull-or-rebuild-image.sh000077500000000000000000000123141354444011500230400ustar00rootroot00000000000000#!/usr/bin/env bash # # Copyright 2016-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # pull-or-rebuild-image.sh - rebuilds the Docker image used in the # current Travis build if necessary. # # The script rebuilds the Docker image if the Dockerfile for the current # OS version (Dockerfile.${OS}-${OS_VER}) or any .sh script from the directory # with Dockerfiles were modified and committed. # # If the Travis build is not of the "pull_request" type (i.e. in case of # merge after pull_request) and it succeeds, the Docker image should be pushed # to the Docker Hub repository. An empty file is created to signal that to # further scripts. # # If the Docker image does not have to be rebuilt, it will be pulled from # Docker Hub. # set -e if [[ "$TRAVIS_EVENT_TYPE" != "cron" && "$TRAVIS_BRANCH" != "coverity_scan" \ && "$COVERITY" -eq 1 ]]; then echo "INFO: Skip Coverity scan job if build is triggered neither by " \ "'cron' nor by a push to 'coverity_scan' branch" exit 0 fi if [[ ( "$TRAVIS_EVENT_TYPE" == "cron" || "$TRAVIS_BRANCH" == "coverity_scan" )\ && "$COVERITY" -ne 1 ]]; then echo "INFO: Skip regular jobs if build is triggered either by 'cron'" \ " or by a push to 'coverity_scan' branch" exit 0 fi if [[ -z "$OS" || -z "$OS_VER" ]]; then echo "ERROR: The variables OS and OS_VER have to be set properly " \ "(eg. OS=ubuntu, OS_VER=16.04)." exit 1 fi if [[ -z "$HOST_WORKDIR" ]]; then echo "ERROR: The variable HOST_WORKDIR has to contain a path to " \ "the root of this project on the host machine" exit 1 fi # TRAVIS_COMMIT_RANGE is usually invalid for force pushes - ignore such values # when used with non-upstream repository if [ -n "$TRAVIS_COMMIT_RANGE" -a $TRAVIS_REPO_SLUG != "${GITHUB_REPO}" ]; then if ! git rev-list $TRAVIS_COMMIT_RANGE; then TRAVIS_COMMIT_RANGE= fi fi # Find all the commits for the current build if [[ -n "$TRAVIS_COMMIT_RANGE" ]]; then commits=$(git rev-list $TRAVIS_COMMIT_RANGE) else commits=$TRAVIS_COMMIT fi echo "Commits in the commit range:" for commit in $commits; do echo $commit; done # Get the list of files modified by the commits files=$(for commit in $commits; do git diff-tree --no-commit-id --name-only \ -r $commit; done | sort -u) echo "Files modified within the commit range:" for file in $files; do echo $file; done # Path to directory with Dockerfiles and image building scripts images_dir_name=images base_dir=utils/docker/$images_dir_name # Check if committed file modifications require the Docker image to be rebuilt for file in $files; do # Check if modified files are relevant to the current build if [[ $file =~ ^($base_dir)\/Dockerfile\.($OS)-($OS_VER)$ ]] \ || [[ $file =~ ^($base_dir)\/.*\.sh$ ]] then # Rebuild Docker image for the current OS version echo "Rebuilding the Docker image for the Dockerfile.$OS-$OS_VER" pushd $images_dir_name ./build-image.sh ${DOCKERHUB_REPO} ${OS}-${OS_VER} popd # Check if the image has to be pushed to Docker Hub # (i.e. the build is triggered by commits to the ${GITHUB_REPO} # repository's master branch, and the Travis build is not # of the "pull_request" type). In that case, create the empty # file. if [[ $TRAVIS_REPO_SLUG == "${GITHUB_REPO}" \ && $TRAVIS_BRANCH == "master" \ && $TRAVIS_EVENT_TYPE != "pull_request" && $PUSH_IMAGE == "1" ]] then echo "The image will be pushed to Docker Hub" touch push_image_to_repo_flag else echo "Skip pushing the image to Docker Hub" fi if [[ $PUSH_IMAGE == "1" ]] then echo "Skip build package check if image has to be pushed" touch skip_build_package_check fi exit 0 fi done # Getting here means rebuilding the Docker image is not required. # Pull the image from Docker Hub. docker pull ${DOCKERHUB_REPO}:${OS}-${OS_VER} pmdk-convert-1.7/utils/docker/run-build.sh000077500000000000000000000100661354444011500206450ustar00rootroot00000000000000#!/usr/bin/env bash # # Copyright 2016-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # run-build.sh - is called inside a Docker container; prepares the environment # and starts a build of pmdk-convert. # set -e set -x cd $WORKDIR INSTALL_DIR=/tmp/pmdk-convert mkdir $INSTALL_DIR cp /opt/pmdk/*.tar.gz . if [ -n "$CC" ] then CC=gcc fi # ----------------------------------------- # Coverage if [[ $COVERAGE -eq 1 ]] ; then mkdir build cd build CC=$CC \ cmake .. -DCMAKE_BUILD_TYPE=$TEST_BUILD \ -DTRACE_TESTS=1 \ -DCMAKE_C_FLAGS=-coverage \ -DTESTS_USE_FORCED_PMEM=ON make -j2 ctest --output-on-failure bash <(curl -s https://codecov.io/bash) -c cd .. rm -r build exit 0 fi # ----------------------------------------- # base build mkdir build cd build CC=$CC \ cmake .. -DCMAKE_BUILD_TYPE=$TEST_BUILD \ -DDEVELOPER_MODE=1 \ -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ -DTRACE_TESTS=1 \ -DTESTS_USE_FORCED_PMEM=ON make -j2 ctest --output-on-failure make install make uninstall cd .. rm -r build # ----------------------------------------- # different MINVERSION mkdir build cd build CC=$CC \ cmake .. -DCMAKE_BUILD_TYPE=$TEST_BUILD \ -DDEVELOPER_MODE=1 \ -DMIN_VERSION=1.3 \ -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ -DTRACE_TESTS=1 \ -DTESTS_USE_FORCED_PMEM=ON make -j2 ctest --output-on-failure cd .. rm -r build # ----------------------------------------- # deb & rpm mkdir build cd build CC=$CC \ cmake .. -DCMAKE_INSTALL_PREFIX=/usr \ -DCPACK_GENERATOR=$PACKAGE_MANAGER \ -DCMAKE_BUILD_TYPE=$TEST_BUILD \ -DTRACE_TESTS=1 \ -DTESTS_USE_FORCED_PMEM=ON make -j2 ctest --output-on-failure make package if [ $PACKAGE_MANAGER = "deb" ]; then echo $USERPASS | sudo -S dpkg -i pmdk-convert*.deb elif [ $PACKAGE_MANAGER = "rpm" ]; then echo $USERPASS | sudo -S rpm -i pmdk-convert*.rpm fi cp ./tests/create_10 /tmp cp ./tests/open_17 /tmp cp ./libpmem-convert.so /tmp cp ./libpmemobj_10.so /tmp cp ./libpmemobj_17.so /tmp cd .. rm -rf build # Verify installed package # pmdk-convert ... rm -r $INSTALL_DIR echo "Creating 1.0 pool" LD_LIBRARY_PATH=/tmp:$LD_LIBRARY_PATH /tmp/create_10 /tmp/pool 16 echo "Converting 1.0 pool to the latest version" pmdk-convert -X fail-safety -X 1.2-pmemmutex /tmp/pool echo "Checking pool works with the latest version" LD_LIBRARY_PATH=/tmp:$LD_LIBRARY_PATH /tmp/open_17 /tmp/pool echo "OK" # ----------------------------------------- # doc # Trigger auto doc update on master if [[ "$AUTO_DOC_UPDATE" == "1" ]]; then echo "Running auto doc update" mkdir doc_update cd doc_update $SCRIPTSDIR/run-doc-update.sh cd .. rm -rf doc_update fi pmdk-convert-1.7/utils/docker/run-doc-update.sh000077500000000000000000000057631354444011500216030ustar00rootroot00000000000000#!/usr/bin/env bash # # Copyright 2018-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. set -e ORIGIN="https://${GITHUB_TOKEN}@github.com/pmem-bot/pmdk-convert" UPSTREAM="https://github.com/pmem/pmdk-convert" # Clone repo git clone ${ORIGIN} cd pmdk-convert git remote add upstream ${UPSTREAM} git config --local user.name "pmem-bot" git config --local user.email "pmem-bot@intel.com" git checkout master git remote update git reset --hard upstream/master mkdir build cd build CC=gcc cmake .. -DCMAKE_BUILD_TYPE=Debug cd .. # Build & PR groff make md2man -C ./build git add -A ./doc git commit -m "doc: automatic master docs update" && true git push -f ${ORIGIN} master # Makes pull request. # When there is already an open PR or there are no changes an error is thrown, which we ignore. hub pull-request -f -b pmem:master -h pmem-bot:master -m "doc: automatic master docs update" && true git clean -dfx # Copy man & PR web md mkdir ../web_manpages cp -r ./doc/pmdk-convert/* ../web_manpages/ # Checkout gh-pages and copy docs git checkout -fb gh-pages upstream/gh-pages git clean -dfx cp -r ../web_manpages/* ./manpages/master/ # Add and push changes. # git commit command may fail if there is nothing to commit. # In that case we want to force push anyway (there might be open pull request with # changes which were reverted). git add -A git commit -m "doc: automatic gh-pages docs update" && true git push -f ${ORIGIN} gh-pages hub pull-request -f -b pmem:gh-pages -h pmem-bot:gh-pages -m "doc: automatic gh-pages docs update" && true exit 0 pmdk-convert-1.7/utils/md2man/000077500000000000000000000000001354444011500163115ustar00rootroot00000000000000pmdk-convert-1.7/utils/md2man/default.man000066400000000000000000000041611354444011500204340ustar00rootroot00000000000000$if(has-tables)$ .\"t $endif$ $if(pandoc-version)$ .\" Automatically generated by Pandoc $pandoc-version$ .\" $endif$ $if(adjusting)$ .ad $adjusting$ $endif$ .TH "$title$" "$section$" "$date$" "PMDK - $version$" "PMDK Programmer's Manual" $if(hyphenate)$ .hy $else$ .nh \" Turn off hyphenation by default. $endif$ $for(header-includes)$ $header-includes$ $endfor$ .\" Copyright 2014-$year$, Intel Corporation .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" .\" * Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" .\" * Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in .\" the documentation and/or other materials provided with the .\" distribution. .\" .\" * Neither the name of the copyright holder nor the names of its .\" contributors may be used to endorse or promote products derived .\" from this software without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS .\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR .\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT .\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. $for(include-before)$ $include-before$ $endfor$ $body$ $for(include-after)$ $include-after$ $endfor$ $if(author)$ .SH AUTHORS $for(author)$$author$$sep$; $endfor$. $endif$ pmdk-convert-1.7/utils/md2man/md2man.sh000077500000000000000000000055441354444011500200360ustar00rootroot00000000000000#!/usr/bin/env bash # # Copyright 2016-2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # md2man.sh -- convert markdown to groff man pages # # usage: md2man.sh file template outfile # # This script converts markdown file into groff man page using pandoc. # It performs some pre- and post-processing for better results: # - parse input file for YAML metadata block and read man page title, # section and version # - cut-off metadata block and license # - unindent code blocks # set -e set -o pipefail filename=$1 template=$2 outfile=$3 title=`sed -n 's/^title:\ _MP(*\([A-Za-z_-]*\).*$/\1/p' $filename` section=`sed -n 's/^title:.*\([0-9]\))$/\1/p' $filename` version=`sed -n 's/^date:\ *\(.*\)$/\1/p' $filename` dt=$(date +"%F") cat $filename | sed -n -e '/# NAME #/,$p' |\ pandoc -s -t man -o $outfile.tmp --template=$template \ -V title=$title -V section=$section \ -V date="$dt" -V version="$version" \ -V year=$(date +"%Y") | sed '/^\.IP/{ N /\n\.nf/{ s/IP/PP/ } }' # don't overwrite the output file if the only thing that changed # is modification date (diff output has exactly 4 lines in this case) if [ -e $outfile ] then difflines=`diff $outfile $outfile.tmp | wc -l || true >2` onlydates=`diff $outfile $outfile.tmp | grep "$dt" | wc -l || true` if [ $difflines -eq 4 -a $onlydates -eq 1 ]; then rm $outfile.tmp else mv $outfile.tmp $outfile fi else mv $outfile.tmp $outfile fi pmdk-convert-1.7/utils/utils.cmake000066400000000000000000000037301354444011500173000ustar00rootroot00000000000000# # Copyright 2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # * Neither the name of the copyright holder nor the names of its # contributors may be used to endorse or promote products derived # from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. include(CheckCCompilerFlag) # Disables optimizations for target in release mode function(disable_optimization target) check_c_compiler_flag(-O0 OPTIMIZATION_FLAG) if(${OPTIMIZATION_FLAG}) target_compile_options(${target} PRIVATE "$<$:-O0>") target_compile_options(${target} PRIVATE "$<$:-O0>") target_compile_options(${target} PRIVATE "$<$:-O0>") endif() endfunction()