Browse Source

Add initial devufs regression test, fix bug in devufs stats file

Signed-off-by: Graham MacDonald <grahamamacdonald@gmail.com>
Graham MacDonald 6 years ago
parent
commit
0a315ab063
2 changed files with 17 additions and 17 deletions
  1. 13 16
      rc/bin/testufs
  2. 4 1
      sys/src/9/ufs/ufs_harvey_external.c

+ 13 - 16
rc/bin/testufs

@@ -2,12 +2,19 @@
 
 # Regression tests for devufs
 
+fn tidyup {
+	if (test -d /dev/ufs/0) echo unmount > /dev/ufs/0/ctl
+	if (test -f $img) rm $img
+}
+
 fn pass {
+	tidyup
 	echo PASS
 	exit PASS	
 }
 
 fn fail {
+	if (! $2 = notidy) tidyup
 	echo FAIL - $1
 	exit FAIL	
 }
@@ -15,31 +22,21 @@ fn fail {
 
 img=testufsimg
 
-if (test -f $img)
-{
-	fail $img^' already exists'
-}
-
-if (test -d /dev/ufs/0)
-{
-	fail '/dev/ufs/0 already exists'
-}
+if (test -f $img) fail $img^' already exists' notidy
+if (! test -d /dev/ufs) fail '/dev/ufs does not exist' notidy
+if (test -d /dev/ufs/0) fail '/dev/ufs/0 already exists' notidy
 
 
 # Create and mount
 newfs $img
-if (! ~ $status '') {
-	fail 'Could not create img'
-}
+if (! ~ $status '') fail 'Could not create fs image'
+
 echo $img > /dev/ufs/mount
+if (! test -d /dev/ufs/0) fail 'Could not mount'
 
 
 # Tests
 cat /dev/ufs/0/stats
 
 
-# Tidy up
-echo unmount > /dev/ufs/0/ctl
-rm $img
-
 pass

+ 4 - 1
sys/src/9/ufs/ufs_harvey_external.c

@@ -31,6 +31,10 @@
 static int
 countvnodes(vnode* vn)
 {
+	if (vn == nil) {
+		return 0;
+	}
+	
 	check_vnodes_locked(vn->mount);
 	
 	int n = 0;
@@ -44,7 +48,6 @@ newufsmount(Chan *c, int id)
 {
 	MountPoint *mp = mallocz(sizeof(MountPoint), 1);
 	mp->chan = c;
-	mp->free_vnodes = nil;
 	mp->id = id;
 	return mp;
 }