New lock tests for litmus (patch included)

Petteri Aimonen jpa at lt.mail.kapsi.fi
Fri Sep 10 03:06:20 EDT 2010


Hi,

Attached are two new tests for litmus:
- Test that parent directory of locked resources cannot be deleted.
- Test that locks are removed when a resource is deleted by lock owner.

--
Petteri Aimonen
-------------- next part --------------
--- litmus-0.12.1.orig/src/locks.c	2008-11-06 11:35:38.000000000 +0200
+++ litmus-0.12.1/src/locks.c	2010-08-26 14:32:48.271456388 +0300
@@ -185,6 +185,20 @@
     return OK;
 }
 
+/* try to delete parent directory when the child is locked. */
+static int delete_parent(void)
+{
+    PRECOND(gotlock);
+    
+    ONN("DELETE of locked resource's parent should fail",
+        ne_delete(i_session2, i_path) != NE_ERROR);
+    
+    if (STATUS2(423) && STATUS2(207))
+        t_warning("DELETE failed with %d not 207 or 423", GETSTATUS2);
+    
+    return OK;
+}
+
 /* take out another shared lock on the resource. */
 static int double_sharedlock(void)
 {
@@ -554,6 +568,54 @@
     return OK;    
 }
 
+/* verify that locks get removed on DELETE */
+static int unlock_on_remove(void)
+{
+    /* Lock collection and then remove it */
+    ne_delete(i_session, coll);
+    CALL(prep_collection());
+    CALL(lock_collection());
+    
+    ONNREQ("owner DELETE collection",
+           ne_delete(i_session, coll));
+    ne_lockstore_remove(store, gotlock);
+    gotlock = NULL;
+           
+    if (prep_collection() || lock_collection())
+    {
+        if (GETSTATUS == 423)
+        {
+            t_context("lock was not removed on delete");
+        }
+        return FAIL;
+    }
+    
+    CALL(unlock());
+    
+    /* And same thing on file inside the collection */
+    res = ne_concat(coll, "lockme.txt", NULL);
+    CALL(upload_foo("lockcoll/lockme.txt"));
+    CALL(lock_excl());
+    
+    ONNREQ("owner DELETE collection",
+           ne_delete(i_session, coll));
+    ne_lockstore_remove(store, gotlock);
+    gotlock = NULL;
+    
+    if (prep_collection() || lock_collection())
+    {
+        if (GETSTATUS == 423)
+        {
+            t_context("lock was not removed on delete");
+        }
+        return FAIL;
+    }
+    
+    CALL(unlock());
+    
+    return OK;
+}
+
 /* lock on unmapped url should return 201 */
 static int unmapped_lock(void)
 {
@@ -590,7 +652,7 @@
     T(discover), T(refresh),
   
     T(notowner_modify), T(notowner_lock),
-    T(owner_modify),
+    T(owner_modify), T(delete_parent),
 
     /* After modifying the resource, check it is still locked (this
      * catches a mod_dav regression when the atomic PUT code is
@@ -615,7 +677,8 @@
     /* now try it all again with a shared lock. */
     T(lock_shared),
 
-    T(notowner_modify), T(notowner_lock), T(owner_modify),
+    T(notowner_modify), T(notowner_lock),
+    T(owner_modify), T(delete_parent),
 
     /* take out a second shared lock */
     T(double_sharedlock),
@@ -633,6 +696,9 @@
     T(indirect_refresh),
     T(unlock),
 
+    /* lock removal on DELETE */
+    T(unlock_on_remove),
+         
     /* lock on a unmapped url */
     T(unmapped_lock),
     T(unlock),


More information about the litmus mailing list