From 06178df9fe507acd23748d9dd10489678b7d0764 Mon Sep 17 00:00:00 2001 From: Faruk Kasumovic Date: Thu, 16 Jul 2020 13:30:11 +0200 Subject: [PATCH] - Tests for SendSize returning 0 and unpacking resume token --- a_test.go | 3 +++ zfs_test.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/a_test.go b/a_test.go index ca0b1ef..ecef1b8 100644 --- a/a_test.go +++ b/a_test.go @@ -26,7 +26,10 @@ func Test(t *testing.T) { // zfsTestMountPointConcurrency(t) // time.Sleep(15 * time.Second) + zfsTestResumeTokenUnpack(t) + zfsTestDatasetSnapshot(t) + zfsTestSendSize(t) zfsTestDatasetOpenAll(t) zfsTestDatasetSetProperty(t) zfsTestDatasetHoldRelease(t) diff --git a/zfs_test.go b/zfs_test.go index aeef553..99a9de8 100644 --- a/zfs_test.go +++ b/zfs_test.go @@ -188,6 +188,38 @@ func zfsTestDatasetHoldRelease(t *testing.T) { print("PASS\n\n") } +func zfsTestSendSize(t *testing.T) { + var size int64 + println("TEST SendSize(", TSTDatasetPathSnap, ") ... ") + d, err := zfs.DatasetOpen(TSTDatasetPathSnap) + if err != nil { + t.Error(err) + return + } + defer d.Close() + if size, err = d.SendSize("", zfs.SendFlags{Compress: true}); err != nil { + t.Error(err) + return + } + if size <= 0 { + t.Error(fmt.Errorf("Failed to fetch size. size = %d", size)) + return + } + print("PASS\n\n") +} + +func zfsTestResumeTokenUnpack(t *testing.T) { + var resToken zfs.ResumeToken + println("TEST ResumeTokenUnpack ... ") + err := resToken.Unpack("1-2111998041-170-789c636064000310a501c49c50360710a715e5e7a69766a6304001bfd66a579708b10d0a40363b92bafca4acd4e412081f0430e4d3d28a5381f20c0f94f218a1f26c48f2499525a9c540fac6d3fd6cd8f497e4435cb1f891ebba68d955ce3390e439c1f27989b9a90c0c7eae21c121fe41fa29f9b9899979bae646a98966c9166686c9496926262969894606a64966e629a686466946268689fa65f939bac9c996e68646a906e606962926a949e696c989a6a989468926a99666264646e60ec995c939a9ba86c6c98986494666692649294926e6a916c9498929c646c64916408d40d3e1fee666408467727e6e41516a71717e36031c0000cb4c43f4") + if err != nil { + t.Error(err) + return + } + println("ResumeToken:", fmt.Sprintf("%v", resToken)) + return +} + func zfsTestDatasetDestroy(t *testing.T) { println("TEST DATASET Destroy( ", TSTDatasetPath, " ) ... ") d, err := zfs.DatasetOpen(TSTDatasetPath)