update idmap-tests and create self-stack test
authorAndrew Burford <aburford@cs.stonybrook.edu>
Sat, 14 May 2022 15:30:08 +0000 (11:30 -0400)
committerAndrew Burford <aburford@cs.stonybrook.edu>
Sat, 14 May 2022 15:30:08 +0000 (11:30 -0400)
idmap-tests/Makefile [new file with mode: 0644]
idmap-tests/test.sh
tests/self-stack.sh [new file with mode: 0755]

diff --git a/idmap-tests/Makefile b/idmap-tests/Makefile
new file mode 100644 (file)
index 0000000..8227b2a
--- /dev/null
@@ -0,0 +1,4 @@
+mount-idmapped:
+       gcc mount-idmapped.c -o mount-idmapped
+test: mount-idmapped
+       sh test.sh
index 0cd9aae4281285e563888aadc7e3a129516a07e2..3d8eb01393da07b6a7cc5cc4fd0722c50ae54acd 100755 (executable)
@@ -11,22 +11,22 @@ function runcmd
     sleep 0.25
     $@
     ret=$?
-    if test $ret -ne 0 && test "$1" != 'lsof'; then
+    if test $ret -ne 0 && test "$1 $2 $3" != 'mount -t wrapfs'; then
        echo "$0: exit code $ret"
        exit $ret
     fi
 }
 
-if cat /proc/mounts | grep $SCRATCH_DIR; then
-       runcmd umount $SCRATCH_DIR
-fi
-
-if ! id luser &>/dev/null; then
-       runcmd adduser --shell /bin/sh luser
-fi
+dirs="$TMP_DIR $LOWER_DIR $SCRATCH_DIR"
+for d in $dirs; do
+       echo checking dir $d
+       if cat /proc/mounts | grep $d; then
+               runcmd umount $d
+       fi
+done
 
 runcmd mkfs -t $FS_TYPE $SCRATCH_DEV <<< y
-runcmd mount /dev/sdb $SCRATCH_DIR
+runcmd mount $SCRATCH_DEV $SCRATCH_DIR
 runcmd rm -rf $SCRATCH_DIR/*
 runcmd touch $SCRATCH_DIR/root
 runcmd touch $SCRATCH_DIR/ubuntu
@@ -37,7 +37,12 @@ ls1=$(ls -l $SCRATCH_DIR)
 
 runcmd ./mount-idmapped --map-mount b:0:1000:1 --map-mount b:1000:1001:1 --map-mount b:1001:0:1 $SCRATCH_DIR $LOWER_DIR
 runcmd mount -t wrapfs $LOWER_DIR $TMP_DIR
-ls2=$(ls -l $TMP_DIR)
+if test $ret != 32; then
+       echo wrapfs returned unexpected error: $ret
+else
+       echo wrapfs returned correct error attempting to mount on idmapped mount
+fi
 
-echo $ls1
-echo $ls2
+#ls2=$(ls -l $TMP_DIR)
+#echo $ls1
+#echo $ls2
diff --git a/tests/self-stack.sh b/tests/self-stack.sh
new file mode 100755 (executable)
index 0000000..37f741a
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+SCRATCH_DEV=/dev/sdb
+SCRATCH_DIR=/n/scratch
+LOWER_DIR=/n/lower
+TMP_DIR=/n/tmp
+FS_TYPE=ext4
+
+function runcmd
+{
+    echo "CMD: $@"
+    sleep 0.25
+    $@
+    ret=$?
+    if test $ret -ne 0 && test "$1 $2 $3" != 'mount -t wrapfs'; then
+       echo "$0: exit code $ret"
+       exit $ret
+    fi
+}
+
+dirs="$TMP_DIR $LOWER_DIR $SCRATCH_DIR"
+for d in $dirs; do
+       echo checking dir $d
+       if cat /proc/mounts | grep $d; then
+               runcmd umount $d
+       fi
+done
+
+runcmd mkfs -t $FS_TYPE $SCRATCH_DEV <<< y
+runcmd mount $SCRATCH_DEV $SCRATCH_DIR
+runcmd mount -t wrapfs $SCRATCH_DIR $LOWER_DIR
+runcmd mount -t wrapfs $LOWER_DIR $TMP_DIR
+if test $ret != 32; then
+       echo wrapfs returned unexpected error code attempting to mount on top of itself: $ret
+else
+       echo wrapfs returned expected error code
+fi