- total_file_size=$((total_file_size + $(stat -c %s $file)))
- i=$((i + 1))
- if [ $i -gt $fs_size_in_mb ]; then
- echo "FAIL: filesystem never filled up!"
+
+ # We shouldn't have been able to write more data than we had space for.
+ (( total_file_size += file_size ))
+ if (( total_file_size > fs_size )); then
+ _fail "Wrote $total_file_size bytes but should have only" \
+ "had space for $fs_size bytes at most!"
+ fi
+
+ # Stop if we hit ENOSPC.
+ if grep -q 'No space left on device' $tmp.out; then