name: PMEM test procedure
description: PMDK testing procedure for self-hosted runners equipped with PMEM
inputs:
  test_script:
    description: |
      'sh' for RUNTESTS.sh, 'py' for RUNTESTS.py. The default is 'both'.
    required: false
    default: 'both'
  build:
    description: Build type to be tested.
    required: true
  test_type:
    description: Test type to be run. Supported values are short, medium, long, check (short+medium), all (short+medium+long).
    required: false
    default: 'all'
  test_label:
    description: Limit testing to tests that have the given label assigned.
    required: false
    default: ''
  force_enable:
    description: Force the use of a specific Valgrind tool.
    required: false
    default: ''
runs:
  using: composite
  steps:
    # Run tests employing the Bash-based test framework.
    - if: inputs.test_script != 'py' # run for 'sh' and 'both'
      working-directory: src/test
      env:
        TEST_LABEL: ${{ inputs.test_label }}
        # TEST_BUILD and TEST_TYPE environment variables are overwritten by
        # testconfig.sh hence the respective values have to be provided as
        # command parameters (-b and -t respectively).
      run: |
        echo '::group::Tests Bash'
        cmd="./RUNTESTS.sh -b ${{ inputs.build }} -t ${{ inputs.test_type }}"
        [ "${{ inputs.force_enable }}" != '' ] &&
          cmd="$cmd --force-enable ${{ inputs.force_enable }}"
        bash -c "$cmd"
        echo '::endgroup::'
      shell: bash

    # Run tests employing the Python-based test framework.
    - if: inputs.test_script != 'sh' # run for 'py' and 'both'
      working-directory: src/test
      run: |
        echo '::group::Tests Python'
        cmd="./RUNTESTS.py -b ${{ inputs.build }} -t ${{ inputs.test_type }}"
        [ "${{ inputs.test_label }}" != '' ] &&
          cmd="$cmd --test-label ${{ inputs.test_label }}"
        [ "${{ inputs.force_enable }}" != '' ] &&
          cmd="$cmd --force-enable ${{ inputs.force_enable }}"
        bash -c "$cmd"
        echo '::endgroup::'
      shell: bash
