2 xx_start_machine name=main
5 # Create empty file /tmp/img with reasonable size.
6 # We give it 3s for prompt to reappear and no error message to
7 # be printed (cmd checks for standard Bdsh error message by default).
8 xx_cmd "mkfile --size 2m /tmp/img" timeout=10
10 # Check that the created image is of right size.
11 # We issue a more descriptive error message if not. We leave the timeout
12 # here on default since ls ought to be pretty fast.
15 error="Empty image file does not have the right size."
17 # Just for demonstration, we check the file size again, here with zero
18 # timeout as the text is already on the screen anyway.
19 xx_assert "2097152" message="Ooops" timeout=0
21 # Create block device on the file.
22 xx_cmd "file_bd /tmp/img fbd0" \
23 assert="Accepting connections" \
24 error="Failed to start block device layer." \
27 # Create filesystem there. We print a customized message when doing so.
29 "mkfat --type 12 fbd0" \
31 message="Creating FAT on the file-backed block device" \
32 error="Failed to create FAT file system" \
36 # Start the FAT file server
37 # No longer needed as all FS servers are started to
39 false && xx_cmd "fat" \
40 assert="Accepting connections" \
41 error="Failed to start FAT service." \
44 # Create a dedicated mountpoint
45 xx_cmd "mkdir /tmp/mnt" timeout=20
47 # Mount the filesystem.
48 # Error in this command results in the word 'Unable' to appear on the screen.
49 xx_cmd "mount fat /tmp/mnt fbd0" die_on="Unable"
51 # Copy the file to the mounted filesystem.
52 xx_cmd "cp demo.txt /tmp/mnt" error="Copying demo.txt failed"
54 # Check that the file is copied there.
55 # We need to clear the screen as the word demo.txt was used in the previous
58 xx_cmd "ls /tmp/mnt" assert="demo.txt"
61 # Unmount the image, check the file is not there
63 xx_cmd "umount /tmp/mnt"
64 xx_cmd "ls /tmp/mnt" die_on="demo.txt" error="demo.txt is still there."
66 # Remount the image and check the file is still there (cls is needed again).
68 xx_cmd "mount fat /tmp/mnt fbd0" die_on="Unable"
69 xx_cmd "ls /tmp/mnt" assert="demo.txt" error="demo.txt disappeared from the FAT image."
72 # Not necessary, really.
73 xx_cmd "umount /tmp/mnt"