]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
docker: Remove unused code moved to dkid_test.
authorRadosław Korzeniewski <radoslaw@korzeniewski.net>
Thu, 11 Feb 2021 11:57:36 +0000 (12:57 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:00 +0000 (09:03 +0100)
bacula/src/plugins/fd/docker/dkid.c
bacula/src/plugins/fd/docker/dkid.h

index 21da661d9fa408370070b9350d4a3f7be9fa080e..8d69e28d7a18a7dff1fc35423e17682b6e21a678 100644 (file)
@@ -182,13 +182,7 @@ bool DKID::operator !=(DKID &other)
    return false;
 }
 
-#ifndef TEST_PROGRAM
-#define TEST_PROGRAM_A
-#endif
-
-#ifdef TEST_PROGRAM
-#include "unittests.h"
-
+#ifdef DEBUG
 void DKID::dump()
 {
    printf ("%p::ShortD: %ld\n", this, ShortD);
@@ -196,148 +190,4 @@ void DKID::dump()
    printf ("%p::shortonly: %s\n", this, shortonly?"true":"false");
    printf ("%p::DigestShort: %s\n", this, DigestShort);
 };
-
-const char *dig1     =  "66f45d8601bae26a6b2ffeb46922318534d3b3905377b3a224693bd78601cb3b";
-const char *sdig1    =  "66f45d8601ba";
-const int64_t vdig1 = 0x66f45d8601ba;
-const char *dig2     =  "B546087C43F75A2C1484B4AEE0737499AA69A09067B04237907FCCD4BDE938C7";
-const char *sdig2    =  "B546087C43F7";
-const int64_t vdig2 = 0xb546087c43f7;
-const char *sdig3    =  "0f601bcb1ef5";
-const int64_t vdig3 = 0x0f601bcb1ef5;
-const char *sdig4    =  "00571da76d";
-const int64_t vdig4 = 0x00571da76d;
-const char *dig5     = "sha256:daabf4372f900cb1ad0db17d26abf3acce55224275d1850f02459180e4dacf1d";
-const char *tdig5    = "daabf4372f900cb1ad0db17d26abf3acce55224275d1850f02459180e4dacf1d";
-const char *sdig5    = "daabf4372f90";
-const int64_t vdig5  = 0xdaabf4372f90;
-const char *sinv1 = "Invalid initialization string";
-const char *sinv2 = "brave_edison";
-const char *sinv3 = "0xDEADBEEF";
-const char *sinv4 = "c0a478d317195b…";
-const char *sinv5 = "a478d317195b…";
-const char *sinv6 = "78d317195b…";
-
-int main()
-{
-   Unittests dkid_test("dkid_test");
-   DKID *id;
-   DKID id2(dig2);
-   char *p;
-   int64_t v;
-   POOL_MEM m(PM_FNAME);
-
-   Pmsg0(0, "Initialize tests ...\n");
-
-   id = New(DKID);
-   ok(id && id->id() == DKIDInvalid, "Check default initialization short");
-   ok(id && strlen(id->digest()) == 0, "Check default initialization full");
-   ok(id && strlen(id->digest_short()) == 0, "Check short default initialization full");
-   delete(id);
-
-   id = New(DKID(dig1));
-   ok(id && id->id() == vdig1, "Check param initialization short");
-   ok(id && bstrcmp(id->digest(), dig1), "Check param initialization full");
-   ok(id && bstrcmp(id->digest_short(), sdig1), "Check short param initialization");
-   delete(id);
-
-   id = New(DKID(dig2));
-   ok(id && id->id() == vdig2, "Check param initialization short upper");
-   ok(id && bstrcmp(id->digest(), dig2), "Check param initialization full upper");
-   ok(id && bstrcmp(id->digest_short(), sdig2), "Check short param initialization full upper");
-   delete(id);
-
-   Mmsg(m, "%s", dig1);
-   id = New(DKID(m));
-   ok(id && id->id() == vdig1, "Check pool_mem initialization short");
-   ok(id && bstrcmp(id->digest(), dig1), "Check pool_mem initialization full");
-   ok(id && bstrcmp(id->digest_short(), sdig1), "Check short pool_mem initialization full");
-   delete(id);
-
-   id = New(DKID(sdig3));
-   ok(id && id->id() == vdig3, "Check short digest initialization");
-   Mmsg(m, "%s(...)", sdig3);
-   ok(id && bstrcmp(id->digest(), m.c_str()), "Check short digest initialization full str");
-   ok(id && bstrcmp(id->digest_short(), sdig3), "Check short for short digest initialization");
-   delete(id);
-
-   id = New(DKID(sdig4));
-   ok(id && id->id() == vdig4, "Check shorter digest initialization");
-   Mmsg(m, "%s(...)", sdig4);
-   ok(id && bstrcmp(id->digest(), m.c_str()), "Check shorter digest initialization full str");
-   ok(id && bstrcmp(id->digest_short(), sdig4), "Check short for shorter digest initialization");
-   delete(id);
-
-   id = New(DKID(dig5));
-   ok(id && id->id() == vdig5, "Check param initialization with sha256: prefix");
-   ok(id && bstrcmp(id->digest(), tdig5), "Check param initialization full with sha256: prefix");
-   ok(id && bstrcmp(id->digest_short(), sdig5), "Check short param initialization with sha256: prefix");
-   delete(id);
-
-   Pmsg0(0, "Invalid initialization tests ...\n");
-
-   id = New(DKID(sinv1));
-   ok(id && id->id() < 0, "Checking invalid digest string long");
-   delete(id);
-
-   id = New(DKID(sinv2));
-   ok(id && id->id() < 0, "Checking invalid digest string short");
-   delete(id);
-
-   id = New(DKID(sinv3));
-   ok(id && id->id() < 0, "Checking invalid digest string hex");
-   delete(id);
-
-   id = New(DKID(sinv4));
-   ok(id && id->id() >= 0, "Checking digest string with ellipsis");
-   delete(id);
-
-   id = New(DKID(sinv5));
-   ok(id && id->id() >= 0, "Checking digest string with ellipsis short");
-   delete(id);
-
-   id = New(DKID(sinv6));
-   ok(id && id->id() < 0, "Checking invalid digest string with ellipsis short");
-   delete(id);
-
-   Pmsg0(0, "Operators tests ...\n");
-
-   id = New(DKID(dig1));
-   p = (char*)id;
-   ok(bstrcmp(p, dig1), "Checking operator char* ()");
-   v = *id;
-   ok(v == vdig1, "Checking operator int64_t ()");
-
-   id2 = *id;
-   ok(id2.id() == vdig1, "Checking operator= (DKID&)");
-   ok(id2 == *id, "Checking operator== on the same");
-   nok(id2 != *id, "Checking operator!= on the same");
-
-   *id = (char*)dig2;
-   ok(id->id() == vdig2, "Checking operator= (char*)");
-   nok(id2 == *id, "Checking operator== on different");
-   ok(id2 != *id, "Checking operator!= on different");
-
-   *id = m;
-   ok(id2.id() == vdig1, "Checking operator= (POOL_MEM&)");
-
-   id2 = (char*)dig2;
-   ok(id2.id() == vdig2, "Checking operator= (char*)");
-   delete(id);
-
-   id = New(DKID(sinv1));
-   id2 = *id;
-   nok (id2 == *id, "Checking operator== on invalid digest");
-   nok (id2 != *id, "Checking operator!= on invalid digest");
-   delete(id);
-
-   id = New(DKID(sdig1));
-   id2 = (char*)dig1;
-   ok (id2 == *id, "Checking operator== on full and short digest");
-   nok (id2 != *id, "Checking operator!= on full and short digest");
-   delete(id);
-
-   return report();
-};
-
-#endif   /* TEST_PROGRAM */
+#endif
index f2bcc7eedb3e6d26bb48892d764e5b6cd5f83f40..43b7abe43d58554be8567b9718deed9953d894de 100644 (file)
@@ -62,7 +62,7 @@ public:
    DKID& operator= (POOL_MEM &data);
    bool operator== (DKID &other);
    bool operator!= (DKID &other);
-#ifdef TEST_PROGRAM
+#ifdef DEBUG
    void dump();
 #endif
 
@@ -76,4 +76,4 @@ private:
    void init(const char* d);
 };
 
-#endif   /* _DKID_H_ */
\ No newline at end of file
+#endif   /* _DKID_H_ */