Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #217 from marcinslusarz/umask
Browse files Browse the repository at this point in the history
tests: set umask for libpmemfile tests
  • Loading branch information
Sarah Jelinek committed Jun 23, 2017
2 parents e06426f + 860cce3 commit d518fa1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/preload/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ add_cstyle(tests-preload-config ${CMAKE_CURRENT_SOURCE_DIR}/config/config.c)
add_check_whitespace(tests-preload-basic ${CMAKE_CURRENT_SOURCE_DIR}/basic/basic.c)
add_check_whitespace(tests-preload-config ${CMAKE_CURRENT_SOURCE_DIR}/config/config.c)

add_library(setumask SHARED setumask.c)
set_target_properties(setumask PROPERTIES INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/src)

# Configures test ${name}${sub_name} using test dir ${name} and executable ${main_executable}
function(add_test_generic name sub_name main_executable)
add_test(NAME preload_${name}${sub_name}
Expand All @@ -46,7 +49,7 @@ function(add_test_generic name sub_name main_executable)
-DTEST_NAME=${name}${sub_name}
-DSRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${name}${sub_name}
-DBIN_DIR=${CMAKE_CURRENT_BINARY_DIR}/${name}${sub_name}
-DPRELOAD_LIB=$<TARGET_FILE:pmemfile_shared>
-DPRELOAD_LIB=$<TARGET_FILE:pmemfile_shared>:$<TARGET_FILE:setumask>
-DMAIN_EXECUTABLE=${main_executable}
${ARGN}
-P ${CMAKE_CURRENT_SOURCE_DIR}/${name}/${name}.cmake)
Expand Down
41 changes: 41 additions & 0 deletions tests/preload/setumask.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2017, 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 "compiler_utils.h"
#include <sys/stat.h>

/* set umask value to some known value independent of the environment */
pf_constructor void
setumask_init(void)
{
umask(022);
}

0 comments on commit d518fa1

Please sign in to comment.