github.com/singularityware/singularity@v3.1.1+incompatible/docs/2.x-tests/32-action_options.sh (about)

     1  #!/bin/bash
     2  #
     3  # Copyright (c) 2015-2016, Gregory M. Kurtzer. All rights reserved.
     4  #
     5  # "Singularity" Copyright (c) 2016, The Regents of the University of California,
     6  # through Lawrence Berkeley National Laboratory (subject to receipt of any
     7  # required approvals from the U.S. Dept. of Energy).  All rights reserved.
     8  #
     9  # This software is licensed under a customized 3-clause BSD license.  Please
    10  # consult LICENSE file distributed with the sources of this project regarding
    11  # your rights to use or distribute this software.
    12  #
    13  # NOTICE.  This Software was developed under funding from the U.S. Department of
    14  # Energy and the U.S. Government consequently retains certain rights. As such,
    15  # the U.S. Government has been granted for itself and others acting on its
    16  # behalf a paid-up, nonexclusive, irrevocable, worldwide license in the Software
    17  # to reproduce, distribute copies to the public, prepare derivative works, and
    18  # perform publicly and display publicly, and to permit other to do so.
    19  #
    20  #
    21  
    22  
    23  
    24  . ./functions
    25  
    26  test_init "Testing action options"
    27  
    28  
    29  
    30  CONTAINER="$SINGULARITY_TESTDIR/container.img"
    31  TESTDIR="$SINGULARITY_TESTDIR/home_test"
    32  
    33  # Creating a new container
    34  stest 0 sudo singularity build "$CONTAINER" "../examples/busybox/Singularity"
    35  stest 0 singularity exec "$CONTAINER" true
    36  stest 1 singularity exec "$CONTAINER" false
    37  
    38  # Checking if Singularity properly handles custom shells
    39  stest 0 singularity shell -s /bin/true "$CONTAINER"
    40  stest 1 singularity shell -s /bin/false "$CONTAINER"
    41  
    42  # Testing --workdir
    43  stest 0 touch "$SINGULARITY_TESTDIR/testfile"
    44  stest 0 singularity exec --workdir "$SINGULARITY_TESTDIR" "$CONTAINER" test -f "$SINGULARITY_TESTDIR/testfile"
    45  stest 1 singularity exec --workdir "$SINGULARITY_TESTDIR" --contain "$CONTAINER" test -f "$SINGULARITY_TESTDIR/testfile"
    46  
    47  # Testing --pwd
    48  stest 0 singularity exec --pwd /etc "$CONTAINER" true
    49  stest 1 singularity exec --pwd /non-existent-dir "$CONTAINER" true
    50  stest 0 sh -c "singularity exec --pwd /etc '$CONTAINER' pwd | egrep '^/etc'"
    51  
    52  # Testing --home
    53  stest 0 mkdir -p "$TESTDIR"
    54  stest 0 touch "$TESTDIR/testfile"
    55  stest 0 singularity exec --home "$TESTDIR" "$CONTAINER" test -f "$TESTDIR/testfile"
    56  stest 0 singularity exec --home "$TESTDIR:/home" "$CONTAINER" test -f "/home/testfile"
    57  if [  "x${SINGULARITY_OVERLAY_FS}" = "x1" ]; then
    58      stest 0 singularity exec --contain --home "$TESTDIR:/blah" "$CONTAINER" test -f "/blah/testfile"
    59  fi
    60  stest 0 sh -c "echo 'cd; test -f testfile' | singularity exec --home '$TESTDIR' '$CONTAINER' /bin/sh"
    61  stest 1 singularity exec --home "/tmp" "$CONTAINER" true
    62  stest 1 singularity exec --home "/tmp:/home" "$CONTAINER" true
    63  
    64  
    65  test_cleanup