Skip to content
Snippets Groups Projects
Commit 8958ccf6 authored by John Shawger's avatar John Shawger
Browse files

create and mount disk images in /tmp

parent d9848674
No related branches found
No related tags found
No related merge requests found
...@@ -16,9 +16,14 @@ ...@@ -16,9 +16,14 @@
(write-test-files (apply testgen config) counter) (write-test-files (apply testgen config) counter)
(setq counter (1+ counter))))))) (setq counter (1+ counter)))))))
(defun disk-path (img)
"Generate path for disk image."
(format "/tmp/$(whoami)/%s" img))
(defun gen-disks (numdisks) (defun gen-disks (numdisks)
"Generate string with list of disks for testing." "Generate string with list of disks for testing."
(mapcar (lambda (n) (format "test-disk%d" n)) (mapcar (lambda (n)
(disk-path (format "test-disk%d" n)))
(number-sequence 1 numdisks))) (number-sequence 1 numdisks)))
(defun create-disk-cmd (numdisks size) (defun create-disk-cmd (numdisks size)
...@@ -212,7 +217,7 @@ FS-STATE the state of the filesystem." ...@@ -212,7 +217,7 @@ FS-STATE the state of the filesystem."
It creates disks, runs mkfs on them, and mounts with FUSE." It creates disks, runs mkfs on them, and mounts with FUSE."
(string-join (string-join
(list (list
"mkdir -p mnt" "mkdir -p mnt; mkdir -p /tmp/$(whoami)"
(create-disk-cmd numdisks "1M") (create-disk-cmd numdisks "1M")
(concat "../solution/mkfs " (default-fs-mkfs-args raid numdisks)) (concat "../solution/mkfs " (default-fs-mkfs-args raid numdisks))
(mount-cmd numdisks "mnt")) (mount-cmd numdisks "mnt"))
...@@ -222,8 +227,8 @@ It creates disks, runs mkfs on them, and mounts with FUSE." ...@@ -222,8 +227,8 @@ It creates disks, runs mkfs on them, and mounts with FUSE."
"This is always the post command for filesystem tests. "This is always the post command for filesystem tests.
It removes the test disks." It removes the test disks."
(format "%s; rm -f test-disk*" (format "fusermount -uq mnt; rm -f %s"
"fusermount -uq mnt")) (disk-path "test-disk*")))
(defun mount-cmd (numdisks dir) (defun mount-cmd (numdisks dir)
"Mount wfs using NUMDISKS disks in single-threaded mode on DIR. "Mount wfs using NUMDISKS disks in single-threaded mode on DIR.
...@@ -256,10 +261,12 @@ RUN-RC return code of run command (metadata verifier)" ...@@ -256,10 +261,12 @@ RUN-RC return code of run command (metadata verifier)"
(define-test (define-test
(concat "mkfs: " desc) (concat "mkfs: " desc)
(string-join (string-join
(list (create-disk-cmd numdisks "1M") (list
(concat "../solution/mkfs " (make-mkfs-args raid numdisks inodes blocks))) "mkdir -p /tmp/$(whoami)"
(create-disk-cmd numdisks "1M")
(concat "../solution/mkfs " (make-mkfs-args raid numdisks inodes blocks)))
"; ") "; ")
(format "%s" "rm -f test-disk*") (format "rm -f %s" (disk-path "test-disk*"))
(format "./wfs-check-metadata.py --mode mkfs --inodes %d --blocks %d --disks %s" (format "./wfs-check-metadata.py --mode mkfs --inodes %d --blocks %d --disks %s"
(roundup inodes 32) (roundup inodes 32)
(roundup blocks 32) (roundup blocks 32)
...@@ -468,17 +475,21 @@ POST-BLOCKS additional blocks we should expect (e.g. no cleaning dir blocks)" ...@@ -468,17 +475,21 @@ POST-BLOCKS additional blocks we should expect (e.g. no cleaning dir blocks)"
((testcase . ,#'filesystem-init-and-workload) ((testcase . ,#'filesystem-init-and-workload)
;; (desc fs-state op post-state post-extra-blocks raid numdisks output rc) ;; (desc fs-state op post-state post-extra-blocks raid numdisks output rc)
(configs . (("raid1 -- mount disks in other order" ,'() (configs . (("raid1 -- mount disks in other order" ,'()
"fusermount -u mnt; ../solution/wfs test-disk4 test-disk3 test-disk2 test-disk1 -s mnt" ,(format "fusermount -u mnt; ../solution/wfs %s %s %s %s -s mnt"
(disk-path "test-disk4") (disk-path "test-disk3")
(disk-path "test-disk2") (disk-path "test-disk1"))
,'() 0 "1" 4 "Correct\nCorrect" 0) ,'() 0 "1" 4 "Correct\nCorrect" 0)
("raid0 -- mount disks in other order" ,'() ("raid0 -- mount disks in other order" ,'()
"fusermount -u mnt; ../solution/wfs test-disk3 test-disk2 test-disk1 -s mnt" ,(format "fusermount -u mnt; ../solution/wfs %s %s %s -s mnt"
(disk-path "test-disk3") (disk-path "test-disk2") (disk-path "test-disk1"))
,'() 0 "0" 3 "Correct\nCorrect" 0) ,'() 0 "0" 3 "Correct\nCorrect" 0)
("raid0 -- mount in other order with readback" ,'() ("raid0 -- mount in other order with readback" ,'()
,(string-join ,(string-join
(list "./read-write.py 1 50" ; create a 5000-byte file (list "./read-write.py 1 50" ; create a 5000-byte file
"cat mnt/file1 > file1.test" ; save the file "cat mnt/file1 > file1.test" ; save the file
"fusermount -u mnt" ; unmount "fusermount -u mnt" ; unmount
"../solution/wfs test-disk3 test-disk2 test-disk1 -s mnt" ; remount different order (format "../solution/wfs %s %s %s -s mnt"
(disk-path "test-disk3") (disk-path "test-disk2") (disk-path "test-disk1"))
"diff mnt/file1 file1.test") ; should be identical "diff mnt/file1 file1.test") ; should be identical
"; ") "; ")
,'(("file1" . 5000)) 0 "0" 3 "Correct\nCorrect\nCorrect" 0) ,'(("file1" . 5000)) 0 "0" 3 "Correct\nCorrect\nCorrect" 0)
...@@ -487,7 +498,8 @@ POST-BLOCKS additional blocks we should expect (e.g. no cleaning dir blocks)" ...@@ -487,7 +498,8 @@ POST-BLOCKS additional blocks we should expect (e.g. no cleaning dir blocks)"
(list "./read-write.py 1 10" (list "./read-write.py 1 10"
"cat mnt/file1 > file1.test" "cat mnt/file1 > file1.test"
"fusermount -u mnt" "fusermount -u mnt"
"./corrupt-disk.py --disks test-disk1" (format "./corrupt-disk.py --disks %s"
(disk-path "test-disk1"))
(mount-cmd 3 "mnt") (mount-cmd 3 "mnt")
"diff mnt/file1 file1.test") "diff mnt/file1 file1.test")
"; ") "; ")
......
rm -f test-disk* rm -f /tmp/$(whoami)/test-disk*
truncate -s 1M test-disk1; truncate -s 1M test-disk2; ../solution/mkfs -r 1 -d test-disk1 -d test-disk2 -i 32 -b 224 mkdir -p /tmp/$(whoami); truncate -s 1M /tmp/$(whoami)/test-disk1; truncate -s 1M /tmp/$(whoami)/test-disk2; ../solution/mkfs -r 1 -d /tmp/$(whoami)/test-disk1 -d /tmp/$(whoami)/test-disk2 -i 32 -b 224
./wfs-check-metadata.py --mode mkfs --inodes 32 --blocks 224 --disks test-disk1 test-disk2 ./wfs-check-metadata.py --mode mkfs --inodes 32 --blocks 224 --disks /tmp/$(whoami)/test-disk1 /tmp/$(whoami)/test-disk2
fusermount -uq mnt; rm -f test-disk* fusermount -uq mnt; rm -f /tmp/$(whoami)/test-disk*
mkdir -p mnt && truncate -s 1M test-disk1; truncate -s 1M test-disk2 && ../solution/mkfs -r 1 -d test-disk1 -d test-disk2 -i 32 -b 200 && ../solution/wfs test-disk1 test-disk2 -s mnt mkdir -p mnt; mkdir -p /tmp/$(whoami) && truncate -s 1M /tmp/$(whoami)/test-disk1; truncate -s 1M /tmp/$(whoami)/test-disk2 && ../solution/mkfs -r 1 -d /tmp/$(whoami)/test-disk1 -d /tmp/$(whoami)/test-disk2 -i 32 -b 200 && ../solution/wfs /tmp/$(whoami)/test-disk1 /tmp/$(whoami)/test-disk2 -s mnt
...@@ -20,4 +20,4 @@ except Exception as e: ...@@ -20,4 +20,4 @@ except Exception as e:
exit(1) exit(1)
print("Correct")' \ print("Correct")' \
&& fusermount -u mnt && ./wfs-check-metadata.py --mode raid1 --blocks 1 --altblocks 1 --dirs 2 --files 0 --disks test-disk1 test-disk2 && fusermount -u mnt && ./wfs-check-metadata.py --mode raid1 --blocks 1 --altblocks 1 --dirs 2 --files 0 --disks /tmp/$(whoami)/test-disk1 /tmp/$(whoami)/test-disk2
fusermount -uq mnt; rm -f test-disk* fusermount -uq mnt; rm -f /tmp/$(whoami)/test-disk*
mkdir -p mnt && truncate -s 1M test-disk1; truncate -s 1M test-disk2 && ../solution/mkfs -r 1 -d test-disk1 -d test-disk2 -i 32 -b 200 && ../solution/wfs test-disk1 test-disk2 -s mnt mkdir -p mnt; mkdir -p /tmp/$(whoami) && truncate -s 1M /tmp/$(whoami)/test-disk1; truncate -s 1M /tmp/$(whoami)/test-disk2 && ../solution/mkfs -r 1 -d /tmp/$(whoami)/test-disk1 -d /tmp/$(whoami)/test-disk2 -i 32 -b 200 && ../solution/wfs /tmp/$(whoami)/test-disk1 /tmp/$(whoami)/test-disk2 -s mnt
...@@ -44,4 +44,4 @@ except Exception as e: ...@@ -44,4 +44,4 @@ except Exception as e:
exit(1) exit(1)
print("Correct")' \ print("Correct")' \
&& fusermount -u mnt && ./wfs-check-metadata.py --mode raid1 --blocks 2 --altblocks 2 --dirs 4 --files 0 --disks test-disk1 test-disk2 && fusermount -u mnt && ./wfs-check-metadata.py --mode raid1 --blocks 2 --altblocks 2 --dirs 4 --files 0 --disks /tmp/$(whoami)/test-disk1 /tmp/$(whoami)/test-disk2
fusermount -uq mnt; rm -f test-disk* fusermount -uq mnt; rm -f /tmp/$(whoami)/test-disk*
mkdir -p mnt && truncate -s 1M test-disk1; truncate -s 1M test-disk2 && ../solution/mkfs -r 1 -d test-disk1 -d test-disk2 -i 32 -b 200 && ../solution/wfs test-disk1 test-disk2 -s mnt mkdir -p mnt; mkdir -p /tmp/$(whoami) && truncate -s 1M /tmp/$(whoami)/test-disk1; truncate -s 1M /tmp/$(whoami)/test-disk2 && ../solution/mkfs -r 1 -d /tmp/$(whoami)/test-disk1 -d /tmp/$(whoami)/test-disk2 -i 32 -b 200 && ../solution/wfs /tmp/$(whoami)/test-disk1 /tmp/$(whoami)/test-disk2 -s mnt
...@@ -20,4 +20,4 @@ except Exception as e: ...@@ -20,4 +20,4 @@ except Exception as e:
exit(1) exit(1)
print("Correct")' \ print("Correct")' \
&& fusermount -u mnt && ./wfs-check-metadata.py --mode raid1 --blocks 1 --altblocks 1 --dirs 1 --files 1 --disks test-disk1 test-disk2 && fusermount -u mnt && ./wfs-check-metadata.py --mode raid1 --blocks 1 --altblocks 1 --dirs 1 --files 1 --disks /tmp/$(whoami)/test-disk1 /tmp/$(whoami)/test-disk2
fusermount -uq mnt; rm -f test-disk* fusermount -uq mnt; rm -f /tmp/$(whoami)/test-disk*
mkdir -p mnt && truncate -s 1M test-disk1; truncate -s 1M test-disk2 && ../solution/mkfs -r 1 -d test-disk1 -d test-disk2 -i 32 -b 200 && ../solution/wfs test-disk1 test-disk2 -s mnt mkdir -p mnt; mkdir -p /tmp/$(whoami) && truncate -s 1M /tmp/$(whoami)/test-disk1; truncate -s 1M /tmp/$(whoami)/test-disk2 && ../solution/mkfs -r 1 -d /tmp/$(whoami)/test-disk1 -d /tmp/$(whoami)/test-disk2 -i 32 -b 200 && ../solution/wfs /tmp/$(whoami)/test-disk1 /tmp/$(whoami)/test-disk2 -s mnt
...@@ -92,4 +92,4 @@ except Exception as e: ...@@ -92,4 +92,4 @@ except Exception as e:
exit(1) exit(1)
print("Correct")' \ print("Correct")' \
&& fusermount -u mnt && ./wfs-check-metadata.py --mode raid1 --blocks 2 --altblocks 2 --dirs 4 --files 4 --disks test-disk1 test-disk2 && fusermount -u mnt && ./wfs-check-metadata.py --mode raid1 --blocks 2 --altblocks 2 --dirs 4 --files 4 --disks /tmp/$(whoami)/test-disk1 /tmp/$(whoami)/test-disk2
fusermount -uq mnt; rm -f test-disk* fusermount -uq mnt; rm -f /tmp/$(whoami)/test-disk*
mkdir -p mnt && truncate -s 1M test-disk1; truncate -s 1M test-disk2 && ../solution/mkfs -r 1 -d test-disk1 -d test-disk2 -i 32 -b 200 && ../solution/wfs test-disk1 test-disk2 -s mnt mkdir -p mnt; mkdir -p /tmp/$(whoami) && truncate -s 1M /tmp/$(whoami)/test-disk1; truncate -s 1M /tmp/$(whoami)/test-disk2 && ../solution/mkfs -r 1 -d /tmp/$(whoami)/test-disk1 -d /tmp/$(whoami)/test-disk2 -i 32 -b 200 && ../solution/wfs /tmp/$(whoami)/test-disk1 /tmp/$(whoami)/test-disk2 -s mnt
...@@ -224,4 +224,4 @@ except Exception as e: ...@@ -224,4 +224,4 @@ except Exception as e:
exit(1) exit(1)
print("Correct")' \ print("Correct")' \
&& fusermount -u mnt && ./wfs-check-metadata.py --mode raid1 --blocks 2 --altblocks 2 --dirs 1 --files 18 --disks test-disk1 test-disk2 && fusermount -u mnt && ./wfs-check-metadata.py --mode raid1 --blocks 2 --altblocks 2 --dirs 1 --files 18 --disks /tmp/$(whoami)/test-disk1 /tmp/$(whoami)/test-disk2
fusermount -uq mnt; rm -f test-disk* fusermount -uq mnt; rm -f /tmp/$(whoami)/test-disk*
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment