tests/dbcheck: Add a test for two live objects, with a dangling forward link
[sfrench/samba-autobuild/.git] / testprogs / blackbox / dbcheck-links.sh
index 11592f0a3a482d9d8d3fbda67fcbc86a3e908d0f..2a1bfbace02b85bbbf7102fa2103e1c3db2d9af1 100755 (executable)
@@ -91,6 +91,41 @@ dbcheck_clean() {
     fi
 }
 
+add_dangling_link() {
+    ldif=$release_dir/add-dangling-forwardlink-user.ldif
+    TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+    if [ "$?" != "0" ]; then
+       return 1
+    fi
+
+    ldif=$release_dir/add-initially-normal-link.ldif
+    TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+    if [ "$?" != "0" ]; then
+       return 1
+    fi
+    sleep 6
+
+    ldif=$release_dir/delete-only-backlink.ldif
+    TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+    if [ "$?" != "0" ]; then
+       return 1
+    fi
+}
+
+add_dangling_backlink() {
+    ldif=$release_dir/add-dangling-backlink-user.ldif
+    TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+    if [ "$?" != "0" ]; then
+       return 1
+    fi
+
+    ldif=$release_dir/add-dangling-backlink.ldif
+    TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
+    if [ "$?" != "0" ]; then
+       return 1
+    fi
+}
+
 add_two_more_users() {
     ldif=$release_dir/add-two-more-users.ldif
     TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
@@ -157,6 +192,14 @@ check_expected_after_objects() {
     fi
 }
 
+dangling_one_way() {
+    ldif=$release_dir/dangling-one-way-link.ldif
+    TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
+    if [ "$?" != "0" ]; then
+        return 1
+    fi
+}
+
 if [ -d $release_dir ]; then
     testit $RELEASE undump
     testit "add_two_more_users" add_two_more_users
@@ -164,11 +207,15 @@ if [ -d $release_dir ]; then
     testit "remove_one_link" remove_one_link
     testit "remove_one_user" remove_one_user
     testit "move_one_user" move_one_user
+    testit "add_dangling_link" add_dangling_link
+    testit "add_dangling_backlink" add_dangling_backlink
     testit "dbcheck" dbcheck
     testit "dbcheck_clean" dbcheck_clean
     testit "check_expected_after_deleted_links" check_expected_after_deleted_links
     testit "check_expected_after_links" check_expected_after_links
     testit "check_expected_after_objects" check_expected_after_objects
+    testit "dangling_one_way" dangling_one_way
+    testit "dbcheck_clean" dbcheck_clean
 else
     subunit_start_test $RELEASE
     subunit_skip_test $RELEASE <<EOF