107 lines
3.3 KiB
Diff
107 lines
3.3 KiB
Diff
|
From ea62ae820b0fa71e5f582f844db21a79db268c1e Mon Sep 17 00:00:00 2001
|
||
|
From: Ken Gaillot <kgaillot@redhat.com>
|
||
|
Date: Mon, 9 Apr 2018 17:50:23 -0500
|
||
|
Subject: [PATCH 10/17] Test: cts-cli,cts-pengine: avoid sed -i
|
||
|
|
||
|
"sed -i" isn't POSIX, and its usage differs in GNU sed and BSD sed,
|
||
|
so avoid it in regression tests.
|
||
|
|
||
|
It should be handled similarly in other places where it remains, but this will
|
||
|
help get the BSD build working.
|
||
|
---
|
||
|
cts/cts-cli.in | 25 +++++++++----------------
|
||
|
cts/cts-pengine.in | 13 ++++++++++++-
|
||
|
2 files changed, 21 insertions(+), 17 deletions(-)
|
||
|
|
||
|
diff --git a/cts/cts-cli.in b/cts/cts-cli.in
|
||
|
index 365f4b10b..38045b944 100755
|
||
|
--- a/cts/cts-cli.in
|
||
|
+++ b/cts/cts-cli.in
|
||
|
@@ -433,18 +433,6 @@ function test_dates() {
|
||
|
test_assert $CRM_EX_OK 0
|
||
|
}
|
||
|
|
||
|
-function get_epoch() {
|
||
|
- CIB_user=root CIB_file=$1 CIB_shadow="" cibadmin -Q | head -n 1 | sed -e 's/.* epoch=\"\([0-9]*\).*/\1/'
|
||
|
-}
|
||
|
-
|
||
|
-function restore_epoch() {
|
||
|
- infile=$1; shift
|
||
|
- old=$1; shift
|
||
|
- new=$(get_epoch $infile)
|
||
|
-
|
||
|
- sed -i 's/epoch=.$old/epoch=\"$new/g' $infile
|
||
|
-}
|
||
|
-
|
||
|
function test_acl_loop() {
|
||
|
local TMPXML="$1"
|
||
|
|
||
|
@@ -693,8 +681,11 @@ EOF
|
||
|
test_assert $CRM_EX_OK
|
||
|
|
||
|
SHADOWPATH="$(crm_shadow --file)"
|
||
|
- sed -i 's/epoch=.2/epoch=\"6/g' "$SHADOWPATH"
|
||
|
- sed -i 's/admin_epoch=.1/admin_epoch=\"0/g' "$SHADOWPATH"
|
||
|
+ # sed -i isn't portable :-(
|
||
|
+ cp -p "$SHADOWPATH" "${SHADOWPATH}.$$" # to keep permissions
|
||
|
+ sed -e 's/epoch=.2/epoch=\"6/g' -e 's/admin_epoch=.1/admin_epoch=\"0/g' \
|
||
|
+ "$SHADOWPATH" > "${SHADOWPATH}.$$"
|
||
|
+ mv -- "${SHADOWPATH}.$$" "$SHADOWPATH"
|
||
|
|
||
|
test_acl_loop "$TMPXML"
|
||
|
|
||
|
@@ -845,7 +836,8 @@ for t in $tests; do
|
||
|
eval TMPFILE_$t="$TMPFILE"
|
||
|
test_$t > "$TMPFILE"
|
||
|
|
||
|
- sed -i -e 's/cib-last-written.*>/>/'\
|
||
|
+ # sed -i isn't portable :-(
|
||
|
+ sed -e 's/cib-last-written.*>/>/'\
|
||
|
-e 's/ last-run=\"[0-9]*\"//'\
|
||
|
-e 's/crm_feature_set="[^"]*" //'\
|
||
|
-e 's/validate-with="[^"]*" //'\
|
||
|
@@ -859,7 +851,8 @@ for t in $tests; do
|
||
|
-e 's/schemas\.c:\([0-9][0-9]*\)/schemas.c:NNN/' \
|
||
|
-e 's/constraints\.:\([0-9][0-9]*\)/constraints.:NNN/' \
|
||
|
-e 's/\(validation ([0-9][0-9]* of \)[0-9][0-9]*\().*\)/\1X\2/' \
|
||
|
- "$TMPFILE"
|
||
|
+ "$TMPFILE" > "${TMPFILE}.$$"
|
||
|
+ mv -- "${TMPFILE}.$$" "$TMPFILE"
|
||
|
|
||
|
if [ $do_save -eq 1 ]; then
|
||
|
cp "$TMPFILE" $test_home/cli/regression.$t.exp
|
||
|
diff --git a/cts/cts-pengine.in b/cts/cts-pengine.in
|
||
|
index fb0952580..060708439 100644
|
||
|
--- a/cts/cts-pengine.in
|
||
|
+++ b/cts/cts-pengine.in
|
||
|
@@ -84,6 +84,17 @@ function show_test() {
|
||
|
printf " Test %-25s $*\n" "$name:"
|
||
|
}
|
||
|
|
||
|
+# Normalize policy engine output for comparison
|
||
|
+normalize() {
|
||
|
+ for NORMALIZE_FILE in "$@"; do
|
||
|
+ # sed -i is not portable :-(
|
||
|
+ sed -e 's/crm_feature_set="[^"]*"//' \
|
||
|
+ -e 's/batch-limit="[0-9]*"//' \
|
||
|
+ "$NORMALIZE_FILE" > "${NORMALIZE_FILE}.$$"
|
||
|
+ mv -- "${NORMALIZE_FILE}.$$" "$NORMALIZE_FILE"
|
||
|
+ done
|
||
|
+}
|
||
|
+
|
||
|
info "Test home is:\t$test_home"
|
||
|
|
||
|
create_mode="false"
|
||
|
@@ -332,7 +343,7 @@ do_test() {
|
||
|
rm -f $dot_output
|
||
|
fi
|
||
|
|
||
|
- sed -i -e 's/crm_feature_set="[^"]*"//' -e 's/batch-limit="[0-9]*"//' $expected $output
|
||
|
+ normalize "$expected" "$output"
|
||
|
diff $diff_opts $expected $output >/dev/null
|
||
|
rc2=$?
|
||
|
if [ $rc2 -ne 0 ]; then
|
||
|
--
|
||
|
2.17.0
|
||
|
|