Add tests for mount bind
This commit is contained in:
parent
0a80d55c95
commit
a9dfc98c63
|
|
@ -53,6 +53,39 @@ test_fdatasync() {
|
|||
rm -f /exfat/test_fdatasync.txt
|
||||
}
|
||||
|
||||
test_mount_bind_file() {
|
||||
local file_a="/file_a.txt"
|
||||
local file_b="/file_b.txt"
|
||||
local content_a="initial content for file A"
|
||||
local content_b_new="new content written to file B"
|
||||
|
||||
echo "$content_a" > "$file_a"
|
||||
touch "$file_b"
|
||||
|
||||
mount --bind "$file_a" "$file_b"
|
||||
|
||||
# Read from file_b and check if it matches file_a's content
|
||||
if [ "$(cat "$file_b")" != "$content_a" ]; then
|
||||
echo "Error: Read from bind-mounted file failed. Content mismatch."
|
||||
umount "$file_b"
|
||||
rm -f "$file_a" "$file_b"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "$content_b_new" > "$file_b"
|
||||
|
||||
# Check if file_a's content is updated
|
||||
if [ "$(cat "$file_a")" != "$content_b_new" ]; then
|
||||
echo "Error: Write to bind-mounted file did not affect the source file."
|
||||
umount "$file_b"
|
||||
rm -f "$file_a" "$file_b"
|
||||
return 1
|
||||
fi
|
||||
|
||||
umount "$file_b"
|
||||
rm -f "$file_a" "$file_b"
|
||||
}
|
||||
|
||||
echo "Start ext2 fs test......"
|
||||
test_ext2 "/ext2" "test_file.txt"
|
||||
echo "All ext2 fs test passed."
|
||||
|
|
@ -61,6 +94,10 @@ echo "Start fdatasync test......"
|
|||
test_fdatasync
|
||||
echo "All fdatasync test passed."
|
||||
|
||||
echo "Start mount bind file test......"
|
||||
test_mount_bind_file
|
||||
echo "All mount bind file test passed."
|
||||
|
||||
pipe/pipe_err
|
||||
pipe/short_rw
|
||||
epoll/epoll_err
|
||||
|
|
|
|||
Loading…
Reference in New Issue