diff --git a/.travis.yml b/.travis.yml index 187fda8c0947b951c9771d120351ac8687add9be..bb25a1e9569f6bd84ff22291215b92bb069f2382 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,6 +37,8 @@ env: before_install: - echo $TRAVIS_COMMIT_RANGE - export HOST_WORKDIR=`pwd` + - export GITHUB_REPO=pmem/pmdk + - export DOCKERHUB_REPO=pmem/pmdk - cd utils/docker - ./pull-or-rebuild-image.sh - if [[ -f push_image_to_repo_flag ]]; then PUSH_THE_IMAGE=1; fi diff --git a/src/test/obj_tx_lock/TEST0 b/src/test/obj_tx_lock/TEST0 index fada7756b3b2b4addd44eb5028baff824c56cd72..7f90c0ec6cd1b08b968e63d1a4bd7e98b50fc1cd 100755 --- a/src/test/obj_tx_lock/TEST0 +++ b/src/test/obj_tx_lock/TEST0 @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright 2016-2018, Intel Corporation +# Copyright 2016-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -33,6 +33,7 @@ # # src/test/obj_tx_lock/TEST0 -- unit test for pmemobj_tx_lock() +# with DRD disabled # # standard unit test setup @@ -44,6 +45,6 @@ configure_valgrind drd force-disable setup -expect_normal_exit ./obj_tx_lock$EXESUFFIX $DIR/testfile1 +expect_normal_exit ./obj_tx_lock$EXESUFFIX $DIR/testfile1 l n a pass diff --git a/src/test/obj_tx_lock/TEST0.PS1 b/src/test/obj_tx_lock/TEST0.PS1 index 69460b033a12bb8d4d22f87b8225cdd1292fa984..e6ce61d57f9dc9d94f03f8cf12f2069e56396652 100644 --- a/src/test/obj_tx_lock/TEST0.PS1 +++ b/src/test/obj_tx_lock/TEST0.PS1 @@ -1,5 +1,5 @@ # -# Copyright 2016-2018, Intel Corporation +# Copyright 2016-2019, Intel Corporation # Copyright (c) 2016, Microsoft Corporation. All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -42,6 +42,6 @@ require_test_type medium setup -expect_normal_exit $Env:EXE_DIR\obj_tx_lock$Env:EXESUFFIX $DIR\testfile1 +expect_normal_exit $Env:EXE_DIR\obj_tx_lock$Env:EXESUFFIX $DIR\testfile1 l n a t pass diff --git a/src/test/obj_tx_lock/TEST1 b/src/test/obj_tx_lock/TEST1 new file mode 100755 index 0000000000000000000000000000000000000000..8930488e100a29bb243fbb9f8cc731d246dae4b6 --- /dev/null +++ b/src/test/obj_tx_lock/TEST1 @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# +# 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. +# + +# +# src/test/obj_tx_lock/TEST1 -- unit test for pmemobj_tx_lock() with DRD +# and Helgrind disabled +# + +# standard unit test setup +. ../unittest/unittest.sh + +require_test_type medium + +configure_valgrind drd force-disable +configure_valgrind helgrind force-disable + +setup + +expect_normal_exit ./obj_tx_lock$EXESUFFIX $DIR/testfile1 t + +pass diff --git a/src/test/obj_tx_lock/obj_tx_lock.c b/src/test/obj_tx_lock/obj_tx_lock.c index 82f82d137e9ac1286a9f0119ed1006b3462e01b9..ead2484b400c0a18598c8ec3da589b1db88af455 100644 --- a/src/test/obj_tx_lock/obj_tx_lock.c +++ b/src/test/obj_tx_lock/obj_tx_lock.c @@ -170,8 +170,8 @@ main(int argc, char *argv[]) { START(argc, argv, "obj_tx_lock"); - if (argc != 2) - UT_FATAL("usage: %s <file>", argv[0]); + if (argc < 3) + UT_FATAL("usage: %s <file> [l|n|a|t]", argv[0]); if ((Pop = pmemobj_create(argv[1], LAYOUT_NAME, PMEMOBJ_MIN_POOL, S_IWUSR | S_IRUSR)) == NULL) @@ -182,11 +182,31 @@ main(int argc, char *argv[]) struct transaction_data *test_obj = (struct transaction_data *)pmemobj_direct(root); - do_tx_add_locks(test_obj); - do_tx_add_locks_nested(test_obj); - do_tx_add_locks_nested_all(test_obj); - do_tx_add_taken_lock(test_obj); - + /* go through all arguments one by one */ + for (int arg = 2; arg < argc; arg++) { + /* Scan the character of each argument. */ + if (strchr("lnat", argv[arg][0]) == NULL || + argv[arg][1] != '\0') + UT_FATAL("op must be l or n or a or t"); + + switch (argv[arg][0]) { + case 'l': + do_tx_add_locks(test_obj); + break; + + case 'n': + do_tx_add_locks_nested(test_obj); + break; + + case 'a': + do_tx_add_locks_nested_all(test_obj); + break; + + case 't': + do_tx_add_taken_lock(test_obj); + break; + } + } pmemobj_close(Pop); DONE(NULL); diff --git a/utils/check-commit.sh b/utils/check-commit.sh index dc270370075bb7cc42619f89b2878815d7e0ed5c..278687795c7ddde277e23817a7dcc4a03e0d6156 100755 --- a/utils/check-commit.sh +++ b/utils/check-commit.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright 2016-2018, Intel Corporation +# Copyright 2016-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -38,10 +38,10 @@ # usage: ./check-commit.sh # -if [[ $TRAVIS_REPO_SLUG != "pmem/pmdk" \ +if [[ $TRAVIS_REPO_SLUG != "$GITHUB_REPO" \ || $TRAVIS_EVENT_TYPE != "pull_request" ]]; then - echo "SKIP: $0 can only be executed for pull requests to pmem/pmdk" + echo "SKIP: $0 can only be executed for pull requests to $GITHUB_REPO" exit 0 fi diff --git a/utils/check-doc.sh b/utils/check-doc.sh index fe63774831558cde3ad7e8bd2061129596728d14..423654dd003dd9e1cc508e65c075e70c2471335a 100755 --- a/utils/check-doc.sh +++ b/utils/check-doc.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright 2016-2017, Intel Corporation +# Copyright 2016-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -46,10 +46,10 @@ if [[ -z "$TRAVIS" ]]; then exit 1 fi -if [[ $TRAVIS_REPO_SLUG != "pmem/pmdk" \ +if [[ $TRAVIS_REPO_SLUG != "$GITHUB_REPO" \ || $TRAVIS_EVENT_TYPE != "pull_request" ]]; then - echo "SKIP: $0 can only be executed for pull requests to pmem/pmdk" + echo "SKIP: $0 can only be executed for pull requests to ${GITHUB_REPO}" exit 0 fi diff --git a/utils/docker/build-local.sh b/utils/docker/build-local.sh index 867b12a5ca2ebbb1df23f039c85d79ce70775313..93a3db74e1c6103fdae4a37635022189521c8157 100755 --- a/utils/docker/build-local.sh +++ b/utils/docker/build-local.sh @@ -62,7 +62,8 @@ export PMDK_CC=${PMDK_CC:-gcc} export PMDK_CXX=${PMDK_CXX:-g++} export EXPERIMENTAL=${EXPERIMENTAL:-n} export VALGRIND=${VALGRIND:-1} - +export DOCKERHUB_REPO=${DOCKERHUB_REPO:-pmem/pmdk} +export GITHUB_REPO=${GITHUB_REPO:-pmem/pmdk} if [[ -z "$OS" || -z "$OS_VER" ]]; then echo "ERROR: The variables OS and OS_VER have to be set " \ @@ -78,7 +79,7 @@ if [[ "$KEEP_CONTAINER" != "1" ]]; then RM_SETTING=" --rm" fi -imageName=pmem/pmdk:${OS}-${OS_VER} +imageName=${DOCKERHUB_REPO}:${OS}-${OS_VER} containerName=pmdk-${OS}-${OS_VER} if [[ $MAKE_PKG -eq 1 ]] ; then diff --git a/utils/docker/build-travis.sh b/utils/docker/build-travis.sh index 258eb9decb232385924919130823a1b2ad22cabe..cf601b5bf5084fdc985218bd1301b3be075cc250 100755 --- a/utils/docker/build-travis.sh +++ b/utils/docker/build-travis.sh @@ -69,7 +69,7 @@ if [[ -z "$TEST_BUILD" ]]; then TEST_BUILD=all fi -imageName=pmem/pmdk:${OS}-${OS_VER} +imageName=${DOCKERHUB_REPO}:${OS}-${OS_VER} containerName=pmdk-${OS}-${OS_VER} if [[ $MAKE_PKG -eq 0 ]] ; then command="./run-build.sh"; fi @@ -117,6 +117,7 @@ docker run --rm --privileged=true --name=$containerName -ti \ --env COVERITY_SCAN_TOKEN=$COVERITY_SCAN_TOKEN \ --env COVERITY_SCAN_NOTIFICATION_EMAIL=$COVERITY_SCAN_NOTIFICATION_EMAIL \ --env FAULT_INJECTION=$FAULT_INJECTION \ + --env GITHUB_REPO=$GITHUB_REPO \ $ndctl_enable \ -v $HOST_WORKDIR:$WORKDIR \ -v /etc/localtime:/etc/localtime \ diff --git a/utils/docker/images/build-image.sh b/utils/docker/images/build-image.sh index b332c77c8fd38078a40a82d78165ffdc6ca67233..b8aec4929c59e7760fac8806cbdb8f9514b06521 100755 --- a/utils/docker/images/build-image.sh +++ b/utils/docker/images/build-image.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright 2016-2018, Intel Corporation +# Copyright 2016-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -62,8 +62,13 @@ if [[ ! -f "Dockerfile.$1" ]]; then exit 1 fi -# Build a Docker image tagged with pmem/pmdk:OS-VER -tag=pmem/pmdk:$1 +if [[ -z "${DOCKERHUB_REPO}" ]]; then + echo "DOCKERHUB_REPO environment variable is not set" + exit 1 +fi + +# Build a Docker image tagged with ${DOCKERHUB_REPO}:OS-VER +tag=${DOCKERHUB_REPO}:$1 docker build -t $tag \ --build-arg http_proxy=$http_proxy \ --build-arg https_proxy=$https_proxy \ diff --git a/utils/docker/images/push-image.sh b/utils/docker/images/push-image.sh index 45f57a2e43bdbcbb08aa38c2cfd77b3237791db5..04540d067a438f35b3218610c6551434d920ce5a 100755 --- a/utils/docker/images/push-image.sh +++ b/utils/docker/images/push-image.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright 2016-2018, Intel Corporation +# Copyright 2016-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -45,7 +45,7 @@ function usage { echo "Usage:" echo " push-image.sh <OS-VER>" echo "where <OS-VER>, for example, can be 'ubuntu-16.04', provided " \ - "a Docker image tagged with pmem/pmdk:ubuntu-16.04 exists " \ + "a Docker image tagged with ${DOCKERHUB_REPO}:ubuntu-16.04 exists " \ "locally." } @@ -55,8 +55,13 @@ if [[ -z "$1" ]]; then exit 1 fi +if [[ -z "${DOCKERHUB_REPO}" ]]; then + echo "DOCKERHUB_REPO environment variable is not set" + exit 1 +fi + # Check if the image tagged with pmdk/OS-VER exists locally -if [[ ! $(docker images -a | awk -v pattern="^pmem/pmdk:$1\$" \ +if [[ ! $(docker images -a | awk -v pattern="^${DOCKERHUB_REPO}:$1\$" \ '$1":"$2 ~ pattern') ]] then echo "ERROR: wrong argument." @@ -68,4 +73,4 @@ fi docker login -u="$DOCKER_USER" -p="$DOCKER_PASSWORD" # Push the image to the repository -docker push pmem/pmdk:$1 +docker push ${DOCKERHUB_REPO}:$1 diff --git a/utils/docker/pull-or-rebuild-image.sh b/utils/docker/pull-or-rebuild-image.sh index 7ed1e5edf275ebed8ad244e0b0efa92e87b9f343..268db443e4d38bfe2a8230d9b4ad931df8af86ec 100755 --- a/utils/docker/pull-or-rebuild-image.sh +++ b/utils/docker/pull-or-rebuild-image.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Copyright 2016-2018, Intel Corporation +# Copyright 2016-2019, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -77,7 +77,7 @@ 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 != "pmem/pmdk" ]; then +if [ -n "$TRAVIS_COMMIT_RANGE" -a $TRAVIS_REPO_SLUG != "$GITHUB_REPO" ]; then if ! git rev-list $TRAVIS_COMMIT_RANGE; then TRAVIS_COMMIT_RANGE= fi @@ -115,11 +115,11 @@ for file in $files; do popd # Check if the image has to be pushed to Docker Hub - # (i.e. the build is triggered by commits to the pmem/pmdk + # (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 == "pmem/pmdk" \ + if [[ $TRAVIS_REPO_SLUG == "$GITHUB_REPO" \ && $TRAVIS_BRANCH == "master" \ && $TRAVIS_EVENT_TYPE != "pull_request" && $PUSH_IMAGE == "1" ]] @@ -141,4 +141,4 @@ done # Getting here means rebuilding the Docker image is not required. # Pull the image from Docker Hub. -docker pull pmem/pmdk:${OS}-${OS_VER} +docker pull ${DOCKERHUB_REPO}:${OS}-${OS_VER} diff --git a/utils/pmdk.spec.in b/utils/pmdk.spec.in index 4ed02b65da6cb780989a11d6034ddd7f5be262e1..09aabf1f3cc259dc83eda663760980813ff05df3 100644 --- a/utils/pmdk.spec.in +++ b/utils/pmdk.spec.in @@ -50,9 +50,13 @@ BuildRequires: pkgconfig BuildRequires: gdb %if %{with ndctl} +%if %{defined suse_version} +BuildRequires: libndctl-devel >= %{min_ndctl_ver} +%else BuildRequires: ndctl-devel >= %{min_ndctl_ver} BuildRequires: daxctl-devel >= %{min_ndctl_ver} %endif +%endif %if %{with fabric} BuildRequires: libfabric-devel >= %{min_libfabric_ver}