summaryrefslogtreecommitdiff
path: root/usertests.c
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2011-08-19 13:30:57 -0400
committerRobert Morris <[email protected]>2011-08-19 13:30:57 -0400
commit327cc21fba38359c5b7fd4c9f39b1dc00fb4f182 (patch)
treebf9bfb4240d32dd4725b774e39ac7d270e2ab905 /usertests.c
parentcd3d739e6f3d4d356ac8c34b25f16df82a5f2789 (diff)
downloadxv6-labs-327cc21fba38359c5b7fd4c9f39b1dc00fb4f182.tar.gz
xv6-labs-327cc21fba38359c5b7fd4c9f39b1dc00fb4f182.tar.bz2
xv6-labs-327cc21fba38359c5b7fd4c9f39b1dc00fb4f182.zip
make dirlookup and dirlink more similar
Diffstat (limited to 'usertests.c')
-rw-r--r--usertests.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/usertests.c b/usertests.c
index 8db8385..455e68a 100644
--- a/usertests.c
+++ b/usertests.c
@@ -1529,6 +1529,59 @@ bigargtest(void)
wait();
}
+// what happens when the file system runs out of blocks?
+// answer: balloc panics, so this test is not useful.
+void
+fsfull()
+{
+ int nfiles;
+ int fsblocks = 0;
+
+ printf(1, "fsfull test\n");
+
+ for(nfiles = 0; ; nfiles++){
+ char name[64];
+ name[0] = 'f';
+ name[1] = '0' + nfiles / 1000;
+ name[2] = '0' + (nfiles % 1000) / 100;
+ name[3] = '0' + (nfiles % 100) / 10;
+ name[4] = '0' + (nfiles % 10);
+ name[5] = '\0';
+ printf(1, "writing %s\n", name);
+ int fd = open(name, O_CREATE|O_RDWR);
+ if(fd < 0){
+ printf(1, "open %s failed\n", name);
+ break;
+ }
+ int total = 0;
+ while(1){
+ int cc = write(fd, buf, 512);
+ if(cc < 512)
+ break;
+ total += cc;
+ fsblocks++;
+ }
+ printf(1, "wrote %d bytes\n", total);
+ close(fd);
+ if(total == 0)
+ break;
+ }
+
+ while(nfiles >= 0){
+ char name[64];
+ name[0] = 'f';
+ name[1] = '0' + nfiles / 1000;
+ name[2] = '0' + (nfiles % 1000) / 100;
+ name[3] = '0' + (nfiles % 100) / 10;
+ name[4] = '0' + (nfiles % 10);
+ name[5] = '\0';
+ unlink(name);
+ nfiles--;
+ }
+
+ printf(1, "fsfull test finished\n");
+}
+
int
main(int argc, char *argv[])
{