1f08c3bdfSopenharmony_ci#!/bin/sh -e
2f08c3bdfSopenharmony_ci# SPDX-License-Identifier: GPL-2.0-or-later
3f08c3bdfSopenharmony_ci# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
4f08c3bdfSopenharmony_ci# Copyright (c) Linux Test Project, 2020-2022
5f08c3bdfSopenharmony_ci#
6f08c3bdfSopenharmony_ci# Generate LTP runfile for LVM tests (runtest/lvm.local)
7f08c3bdfSopenharmony_ci
8f08c3bdfSopenharmony_ciTST_TESTFUNC=generate_runfile
9f08c3bdfSopenharmony_ciTST_NEEDS_ROOT=1
10f08c3bdfSopenharmony_ciTST_NEEDS_CMDS="sed"
11f08c3bdfSopenharmony_ci
12f08c3bdfSopenharmony_ciLVM_DIR="${LVM_DIR:-/tmp}"
13f08c3bdfSopenharmony_ciLVM_TMPDIR="$LVM_DIR/ltp/growfiles"
14f08c3bdfSopenharmony_ci
15f08c3bdfSopenharmony_cigenerate_runfile()
16f08c3bdfSopenharmony_ci{
17f08c3bdfSopenharmony_ci	trap '[ $? -eq 0 ] || tst_brk TBROK "Cannot create LVM runfile"' EXIT
18f08c3bdfSopenharmony_ci	INFILE="$LTPROOT/testcases/data/lvm/runfile.tpl"
19f08c3bdfSopenharmony_ci	OUTFILE="$LTPROOT/runtest/lvm.local"
20f08c3bdfSopenharmony_ci	FS_LIST=$(tst_supported_fs -s tmpfs)
21f08c3bdfSopenharmony_ci	echo -n "" >"$OUTFILE"
22f08c3bdfSopenharmony_ci
23f08c3bdfSopenharmony_ci	for fsname in $FS_LIST; do
24f08c3bdfSopenharmony_ci		# Btrfs needs too much space for reliable stress testing
25f08c3bdfSopenharmony_ci		if [ "x$fsname" != "xbtrfs" ]; then
26f08c3bdfSopenharmony_ci			sed -e "s/{fsname}/$fsname/g; s^{tempdir}^$LVM_TMPDIR^g" "$INFILE" >>"$OUTFILE"
27f08c3bdfSopenharmony_ci		fi
28f08c3bdfSopenharmony_ci	done
29f08c3bdfSopenharmony_ci
30f08c3bdfSopenharmony_ci	tst_res TPASS "Runfile $OUTFILE successfully created"
31f08c3bdfSopenharmony_ci}
32f08c3bdfSopenharmony_ci
33f08c3bdfSopenharmony_ci. tst_test.sh
34f08c3bdfSopenharmony_citst_run
35