mirror of
https://github.com/ceph/ceph
synced 2025-04-01 14:51:13 +00:00
test/encoding: refactor to avoid escaping shell magic
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
This commit is contained in:
parent
e9be29c6aa
commit
46c25abd1c
@ -1733,13 +1733,19 @@ function test_display_logs() {
|
||||
#
|
||||
function run_in_background() {
|
||||
local pid_variable=$1
|
||||
shift;
|
||||
shift
|
||||
# Execute the command and prepend the output with its pid
|
||||
# We enforce to return the exit status of the command and not the awk one.
|
||||
("$@" |& awk '{ a[i++] = $0 }END{for (i = 0; i in a; ++i) { print "'$$': " a[i]} }'; return ${PIPESTATUS[0]}) >&2 &
|
||||
("$@" |& sed 's/^/'$$': /'; return "${PIPESTATUS[0]}") >&2 &
|
||||
eval "$pid_variable+=\" $!\""
|
||||
}
|
||||
|
||||
function save_stdout {
|
||||
local out="$1"
|
||||
shift
|
||||
"$@" > "$out"
|
||||
}
|
||||
|
||||
function test_run_in_background() {
|
||||
local pids
|
||||
run_in_background pids sleep 1
|
||||
|
@ -15,21 +15,16 @@ failed=0
|
||||
numtests=0
|
||||
echo "checking ceph-dencoder generated test instances..."
|
||||
echo "numgen type"
|
||||
for type in `ceph-dencoder list_types`; do
|
||||
ceph-dencoder list_types | while read type; do
|
||||
num=`ceph-dencoder type $type count_tests`
|
||||
echo "$num $type"
|
||||
for n in `seq 1 1 $num 2>/dev/null`; do
|
||||
safe_type=$type
|
||||
# BitVector<2> needs some escaping to avoid bash issues with <>
|
||||
if [ "$type" = "BitVector<2>" ]; then
|
||||
safe_type="BitVector\<2\>"
|
||||
fi
|
||||
|
||||
pids=""
|
||||
run_in_background pids bash -c "ceph-dencoder type $safe_type select_test $n dump_json > $tmp1"
|
||||
run_in_background pids bash -c "ceph-dencoder type $safe_type select_test $n encode decode dump_json > $tmp2"
|
||||
run_in_background pids bash -c "ceph-dencoder type $safe_type select_test $n copy dump_json > $tmp3"
|
||||
run_in_background pids bash -c "ceph-dencoder type $safe_type select_test $n copy_ctor dump_json > $tmp4"
|
||||
run_in_background pids save_stdout "$tmp1" ceph-dencoder type "$type" select_test "$n" dump_json
|
||||
run_in_background pids save_stdout "$tmp2" ceph-dencoder type "$type" select_test "$n" encode decode dump_json
|
||||
run_in_background pids save_stdout "$tmp3" ceph-dencoder type "$type" select_test "$n" copy dump_json
|
||||
run_in_background pids save_stdout "$tmp4" ceph-dencoder type "$type" select_test "$n" copy_ctor dump_json
|
||||
wait_background pids
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
@ -43,7 +38,7 @@ for type in `ceph-dencoder list_types`; do
|
||||
# the sorted json output. this is a weaker test, but is better
|
||||
# than nothing.
|
||||
deterministic=0
|
||||
if ceph-dencoder type $type is_deterministic; then
|
||||
if ceph-dencoder type "$type" is_deterministic; then
|
||||
deterministic=1
|
||||
fi
|
||||
|
||||
@ -80,8 +75,8 @@ for type in `ceph-dencoder list_types`; do
|
||||
fi
|
||||
|
||||
if [ $deterministic -ne 0 ]; then
|
||||
run_in_background pids bash -c "ceph-dencoder type $safe_type select_test $n encode export $tmp1"
|
||||
run_in_background pids bash -c "ceph-dencoder type $safe_type select_test $n encode decode encode export $tmp2"
|
||||
run_in_background pids ceph-dencoder type "$type" select_test $n encode export "$tmp1"
|
||||
run_in_background pids ceph-dencoder type "$type" select_test $n encode decode encode export "$tmp2"
|
||||
wait_background pids
|
||||
|
||||
if ! cmp $tmp1 $tmp2; then
|
||||
|
Loading…
Reference in New Issue
Block a user