github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/test/system/250-generate-systemd.bats (about)

     1  #!/usr/bin/env bats   -*- bats -*-
     2  #
     3  # Tests generated configurations for systemd.
     4  #
     5  
     6  load helpers
     7  
     8  # Be extra paranoid in naming to avoid collisions.
     9  SERVICE_NAME="podman_test_$(random_string)"
    10  UNIT_DIR="$HOME/.config/systemd/user"
    11  UNIT_FILE="$UNIT_DIR/$SERVICE_NAME.service"
    12  
    13  function setup() {
    14      skip_if_not_systemd
    15      skip_if_remote
    16  
    17      basic_setup
    18  
    19      if [ ! -d "$UNIT_DIR" ]; then
    20          mkdir -p "$UNIT_DIR"
    21          systemctl --user daemon-reload
    22      fi
    23  }
    24  
    25  function teardown() {
    26      rm -f "$UNIT_FILE"
    27      systemctl --user stop "$SERVICE_NAME"
    28      basic_teardown
    29  }
    30  
    31  @test "podman generate - systemd - basic" {
    32      run_podman create $IMAGE echo "I'm alive!"
    33      cid="$output"
    34  
    35      run_podman generate systemd $cid > "$UNIT_FILE"
    36  
    37      run systemctl --user start "$SERVICE_NAME"
    38      if [ $status -ne 0 ]; then
    39          die "The systemd service $SERVICE_NAME did not start correctly, output: $output"
    40      fi
    41  
    42      run_podman logs $cid
    43      is "$output" "I'm alive!" "Container output"
    44  }
    45  
    46  # vim: filetype=sh