1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

tests: add profileconf fn to generate profiles

profileconf <profile_name> <config> ...
This commit is contained in:
Peter Rajnoha 2013-07-30 15:44:15 +02:00
parent b6bfddcd0a
commit ba1a8878d0

View File

@ -476,15 +476,24 @@ unhide_dev() {
lvmconf "$filter" lvmconf "$filter"
} }
lvmconf() { generate_config() {
if test -n "$profile_name"; then
config_values=PROFILE_VALUES_$profile_name
config=PROFILE_$profile_name
touch $config_values
else
config_values=CONFIG_VALUES
config=CONFIG
fi
LVM_TEST_LOCKING=${LVM_TEST_LOCKING:-1} LVM_TEST_LOCKING=${LVM_TEST_LOCKING:-1}
if test "$DM_DEV_DIR" = "/dev"; then if test "$DM_DEV_DIR" = "/dev"; then
LVM_VERIFY_UDEV=${LVM_VERIFY_UDEV:-0} LVM_VERIFY_UDEV=${LVM_VERIFY_UDEV:-0}
else else
LVM_VERIFY_UDEV=${LVM_VERIFY_UDEV:-1} LVM_VERIFY_UDEV=${LVM_VERIFY_UDEV:-1}
fi fi
test -f CONFIG_VALUES || { test -f $config_values || {
cat > CONFIG_VALUES <<-EOF cat > $config_values <<-EOF
devices/dir = "$DM_DEV_DIR" devices/dir = "$DM_DEV_DIR"
devices/scan = "$DM_DEV_DIR" devices/scan = "$DM_DEV_DIR"
devices/filter = "a|.*|" devices/filter = "a|.*|"
@ -523,23 +532,36 @@ EOF
local v local v
for v in "$@"; do for v in "$@"; do
echo "$v" >> CONFIG_VALUES echo "$v" >> $config_values
done done
rm -f CONFIG rm -f $config
local s local s
for s in $(cat CONFIG_VALUES | cut -f1 -d/ | sort | uniq); do for s in $(cat $config_values | cut -f1 -d/ | sort | uniq); do
echo "$s {" >> CONFIG echo "$s {" >> $config
local k local k
for k in $(grep ^"$s"/ CONFIG_VALUES | cut -f1 -d= | sed -e 's, *$,,' | sort | uniq); do for k in $(grep ^"$s"/ $config_values | cut -f1 -d= | sed -e 's, *$,,' | sort | uniq); do
grep "^$k" CONFIG_VALUES | tail -n 1 | sed -e "s,^$s/, ," >> CONFIG grep "^$k" $config_values | tail -n 1 | sed -e "s,^$s/, ," >> $config
done done
echo "}" >> CONFIG echo "}" >> $config
echo >> CONFIG echo >> $config
done done
}
lvmconf() {
unset profile_name
generate_config "$@"
mv -f CONFIG etc/lvm.conf mv -f CONFIG etc/lvm.conf
} }
profileconf() {
profile_name="$1"
shift
generate_config "$@"
test -d etc/profile || mkdir etc/profile
mv -f PROFILE_$profile_name etc/profile/$profile_name.profile
}
apitest() { apitest() {
local t=$1 local t=$1
shift shift