diff --git a/test-tumbler b/test-tumbler index c393b28dab907f0866a471e80274b9b5bb45cace..1a5431fa33b2714dbe59b347f9c758dcdd57ba62 100755 --- a/test-tumbler +++ b/test-tumbler @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # vim: set sts=4 sw=4 et tw=0 : set -e @@ -43,23 +43,23 @@ _kill_monitor_return() { return $1 } -bash_arrays_to_gvariant_as() { +stringlist_to_gvariant_as() { local i converted="['$1'" shift - for i in "$@"; do - converted+=", '$i'" + for i in $@; do + converted="$converted, '$i'" done - converted+="]" + converted="$converted]" echo "${converted}" } _check_uris_have_thumbnail() { local size=$1 - local uris=$2 - for i in "${uris[@]}"; do + shift + for i in $@; do local thumb="${HOME}/.cache/thumbnails/${size}/$(echo -n "${i}" | md5sum | cut -f1 -d\ ).png" say $thumb - if [[ ! -f "${thumb}" ]]; then + if [ ! -f "${thumb}" ]; then whine "Couldn't find thumbnail $thumb, file $i didn't get thumbnailed!?" ret=1 fi @@ -74,20 +74,22 @@ _generate_thumbnails() { local size="$1" local special_dir="$2" shift 2 - files=("$@") + files=$@ logfile="${WORKDIR}/monitor-tumblerd.log" addr="org.freedesktop.thumbnails.Thumbnailer1" obj_path="/org/freedesktop/thumbnails/Thumbnailer1" method="org.freedesktop.thumbnails.Thumbnailer1.Queue" - uris=() - filetypes=() + uris="" + filetypes="" - for i in "${files[@]}"; do + # FIXME: This doesn't do whitespace/special character escaping, etc + for i in ${files}; do # Tumbler's AppArmor profile doesn't necessarily let it read the # apertis-tests directory if we're running uninstalled. Copy the # file to a more realistic location, which exercises the AppArmor # profile better anyway. - if [ $(( $RANDOM % 2 )) = 0 ] && [ -e "/home/shared/$special_dir" ]; then + _rand=$(od -A n -N 2 -t u2 /dev/urandom) + if [ $(( $_rand % 2 )) = 0 ] && [ -e "/home/shared/$special_dir" ]; then copy="/home/shared/$special_dir/apertis-tests__$(basename "$i")" else copy="$HOME/$special_dir/apertis-tests__$(basename "$i")" @@ -96,9 +98,8 @@ _generate_thumbnails() { cp -v "$i" "$copy" # Need path relative to / - # FIXME: This doesn't do whitespace/special character escaping, etc - uris+=("file://$copy") - filetypes+=($(file --mime-type "$copy" | cut -d ":" -f 2 | tr -d ' ')) + uris="${uris} file://$copy" + filetypes="${filetypes} $(file --mime-type "$copy" | cut -d ":" -f 2 | tr -d ' ')" done # Clear out old thumbnails. @@ -109,8 +110,8 @@ _generate_thumbnails() { # Files to thumbnail ${GDBUS} call --session --dest "${addr}" --object-path "${obj_path}" \ --method "${method}" \ - "$(bash_arrays_to_gvariant_as "${uris[@]}")" \ - "$(bash_arrays_to_gvariant_as "${filetypes[@]}")" \ + "$(stringlist_to_gvariant_as ${uris})" \ + "$(stringlist_to_gvariant_as ${filetypes})" \ "${size}" foreground 0 # Wait for thumbnailing to finish