<commit_before>#!/bin/sh
#
# Check that small files are copied by small file copiers.

. $(dirname $0)/testsuite-common.sh

setup_test

limit=$((1024*1024))

echo test1 > "${srcdir}/smallfile"

dd bs=$limit count=1 \
    if=/dev/urandom \
    of="${srcdir}/borderfile" > /dev/null 2>&1

dd bs=$((2 * $limit)) count=1 \
    if=/dev/urandom \
    of="${srcdir}/largefile" > /dev/null 2>&1

run_daemon

for good in smallfile largefile borderfile; do
	if [ ! -e "${dstdir}/${good}" ] ; then
		fail "missing: ${dstdir}/${good}"
	elif ! cmp -s "${srcdir}/${good}" "${dstdir}/${good}" ; then
		fail "incorrect: ${dstdir}/${good}"
	fi
done

if egrep -q "Assigning .*/smallfile to copier for files size<$limit" ${logfile}; then
    notice "Correctly assigned smallfile to small file copier."
else
    fail "Did not find copier assignment for smallfile in the log."
fi

if egrep -q 'Assigning .*/borderfile to copier for files size<-1' ${logfile}; then
    notice "Correctly assigned borderfile to large file copier"
else
    fail "Did not find copier assignment for borderfile in the log."
fi

if egrep -q 'Assigning .*/largefile to copier for files size<-1' ${logfile}; then
    notice "Correctly assigned largefile to large file copier"
else
    fail "Did not find copier assignment for largefile in the log."
fi

cleanup_test<commit_msg>Rewrite as a loop which takes an arbitrary number of test cases in the form of a list of file names and sizes.<commit_after>#!/bin/sh
#
# Check that small files are copied by small file copiers.

. $(dirname $0)/testsuite-common.sh

setup_test

limit=$((1024*1024))
size_max=18446744073709551615
casefile="${tstdir}/file-class-cases"

cat >>"${casefile}" <<EOF
small 64
edge-under $((limit-1))
edge $((limit))
edge-over $((limit+1))
large $((limit*2))
EOF

while read name size ; do
	dd bs="${size}" count=1 \
	    if=/dev/urandom \
	    of="${srcdir}/${name}" > /dev/null 2>&1
done < "${casefile}"

run_daemon

while read name size ; do
	if [ ! -e "${dstdir}/${name}" ] ; then
		fail "missing: ${dstdir}/${name}"
	elif ! cmp -s "${srcdir}/${name}" "${dstdir}/${name}" ; then
		fail "incorrect: ${dstdir}/${name}"
	fi
	if [ "${size}" -le "${limit}" ] ; then
		class="${limit}"
	else
		class="${size_max}"
	fi
	if egrep -q "Assigning .*/${name} .* <= ${class}" "${logfile}" ; then
		notice "${name} was assigned to the correct copier"
	elif egrep -q "Assigning .*/${name} .* <= [0-9]+" "${logfile}" ; then
		fail "${name} was assigned to the wrong copier"
	else
		fail "unable to find copier assignment for ${name}"
	fi
done < "${casefile}"

cleanup_test
{'fraction_non_alphanumeric': 0.16950464396284828, 'fraction_numerical': 0.02244582043343653, 'mean_word_length': 3.8958333333333335, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6237611', 'n_tokens_mistral': 944, 'n_tokens_neox': 894, 'n_words': 302}