mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-10 13:56:48 +00:00
44 lines
865 B
Bash
Executable File
44 lines
865 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
|
|
set -e
|
|
set -x
|
|
|
|
check_file_size() {
|
|
local file_name="$1"
|
|
local expected_size="$2"
|
|
|
|
if [ ! -f "$file_name" ]; then
|
|
echo "Error: File does not exist."
|
|
return 1
|
|
fi
|
|
|
|
actual_size=$(du -b "$file_name" | cut -f1)
|
|
|
|
if [ "$actual_size" -eq "$expected_size" ]; then
|
|
return 0
|
|
else
|
|
echo "Error: File size is incorrect: expected ${expected_size}, but got ${actual_size}."
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
EXT2_DIR=/ext2
|
|
cd ${EXT2_DIR}
|
|
|
|
echo "Start ext2 fs test......"
|
|
|
|
# Test case for the big file feature
|
|
for i in $(seq 1 10); do
|
|
truncate -s 500M test_file.txt
|
|
check_file_size test_file.txt $((500 * 1024 * 1024))
|
|
truncate -s 2K test_file.txt
|
|
check_file_size test_file.txt $((2 * 1024))
|
|
done
|
|
|
|
# Clean up
|
|
rm -f test_file.txt
|
|
sync
|
|
|
|
echo "All ext2 fs test passed." |