]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
pluginlib: Add smartalist template unittest.
authorRadosław Korzeniewski <radekk@inteos.pl>
Wed, 23 Dec 2020 11:52:36 +0000 (12:52 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:00 +0000 (09:03 +0100)
bacula/src/plugins/fd/pluginlib/Makefile.in
bacula/src/plugins/fd/pluginlib/pluginlib_test.cpp
bacula/src/plugins/fd/pluginlib/ptcomm.cpp
bacula/src/plugins/fd/pluginlib/smartalist_test.cpp [new file with mode: 0644]

index 891648cfe65149c1a27528b032ffcf49779a33fc..1cc68b6946d38564b8cbba266bce744537f85a15 100644 (file)
@@ -27,15 +27,16 @@ ISO8601SRC = iso8601.cpp iso8601.h
 ISO8601OBJ = $(filter %.lo,$(ISO8601SRC:.cpp=.lo))
 EXECPROGSRC = execprog.cpp execprog.h
 EXECPROGOBJ = $(filter %.lo,$(EXECPROGSRC:.cpp=.lo))
-COMMCTXSRC = commctx.cpp commctx.h
-COMMCTXOBJ = $(filter %.lo,$(COMMCTXSRC:.cpp=.lo))
 PTCOMMSRC = ptcomm.cpp ptcomm.h
 PTCOMMOBJ = $(filter %.lo,$(PTCOMMSRC:.cpp=.lo))
+SMARTALISTSRC = smartalist.h
 
 PLUGINLIBSTEST = pluginlib_test.cpp $(PLUGINLIBSSRC) $(UNITTESTSOBJ)
 PLUGINLIBSTESTOBJ = $(filter %.lo,$(PLUGINLIBSTEST:.cpp=.lo))
 ISO8601TEST = iso8601_test.cpp $(ISO8601SRC) $(UNITTESTSOBJ)
 ISO8601TESTOBJ = $(filter %.lo,$(ISO8601TEST:.cpp=.lo))
+SMARTALISTTEST = smartalist_test.cpp $(SMARTALISTSRC) $(PLUGINLIBSOBJ) $(UNITTESTSOBJ)
+SMARTALISTTESTOBJ = $(filter %.lo,$(SMARTALISTTEST:.cpp=.lo))
 
 TESTMETAPLUGINBACKENDSRC = test_metaplugin_backend.c
 TESTMETAPLUGINBACKENDOBJ = $(TESTMETAPLUGINBACKENDSRC:.c=.lo)
@@ -43,7 +44,7 @@ TESTMETAPLUGINBACKENDOBJ = $(TESTMETAPLUGINBACKENDSRC:.c=.lo)
 # COMMONPLUGINOBJ = $(PLUGINLIBSOBJ) $(ISO8601OBJ) $(EXECPROGOBJ)
 COMMONPLUGINOBJ = $(PLUGINLIBSOBJ) $(PTCOMMOBJ)
 # COMMONPLUGINTESTS = pluginlib_test iso8601_test
-COMMONPLUGINTESTS = pluginlib_test
+COMMONPLUGINTESTS = pluginlib_test smartalist_test
 
 .SUFFIXES:    .c .cpp .lo
 
@@ -74,6 +75,10 @@ pluginlib_test: Makefile $(PLUGINLIBSTESTOBJ) $(PLUGINLIBSSRC)
        @echo "Building $@ ..."
        $(NO_ECHO)$(LIBTOOL_LINK) --silent $(CXX) $(LDFLAGS) $(LIBCURL) $(LIBBAC) $(PLUGINLIBSTESTOBJ) -o $@
 
+smartalist_test: Makefile $(SMARTALISTTESTOBJ) $(SMARTALISTTESTOBJ)
+       @echo "Building $@ ..."
+       $(NO_ECHO)$(LIBTOOL_LINK) --silent $(CXX) $(LDFLAGS) $(LIBCURL) $(LIBBAC) $(SMARTALISTTESTOBJ) -o $@
+
 iso8601_test: Makefile $(ISO8601TESTOBJ) $(ISO8601SRC)
        @echo "Building $@ ..."
        $(NO_ECHO)$(LIBTOOL_LINK) --silent $(CXX) $(LDFLAGS) $(LIBCURL) $(LIBBAC) $(PLUGINLIBSTESTOBJ) -o $@
@@ -83,15 +88,6 @@ install: all
        $(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) bpipe-fd.la $(DESTDIR)$(plugindir)
        $(RMF) $(DESTDIR)$(plugindir)/bpipe-fd.la
 
-install-test-plugin: all
-       $(MKDIR) $(DESTDIR)$(plugindir)
-       $(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) test-plugin-fd.la $(DESTDIR)$(plugindir)
-       $(RMF) $(DESTDIR)$(plugindir)/test-plugin-fd.la
-       $(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) test-deltaseq-fd.la $(DESTDIR)$(plugindir)
-       $(RMF) $(DESTDIR)$(plugindir)/test-deltaseq-fd.la
-       $(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) test-handlexacl-plugin-fd.la $(DESTDIR)$(plugindir)
-       $(RMF) $(DESTDIR)$(plugindir)/test-handlexacl-plugin-fd.la
-
 Makefile: Makefile.in $(topdir)/config.status
        cd $(topdir) \
          && CONFIG_FILES=$(thisdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
index 38eab18291308c51a34dd9963b869ba29059092d..fbcc60c0b8a70bbc95cd14aabf8d2abcd97d0c85 100644 (file)
 
    Bacula® is a registered trademark of Kern Sibbald.
 */
-/*
- *
- * All rights reserved. IP transferred to Bacula Systems according to agreement.
+/**
+ * @file commctx.h
+ * @author Radosław Korzeniewski (radoslaw@korzeniewski.net)
+ * @brief Common definitions and utility functions for Inteos plugins - unittest.
+ * @version 1.1.0
+ * @date 2020-12-23
  *
- * Common definitions and utility functions for Inteos plugins.
- * Functions defines a common framework used in our utilities and plugins.
- * Author: Radosław Korzeniewski, radekk@inteos.pl, Inteos Sp. z o.o.
  */
 
 #include "pluginlib.h"
index c400557615690c752e0075f954b847c17da29402..fb9fb59f4e786d990677fbf94b963b1d716b76d1 100644 (file)
@@ -21,7 +21,7 @@
  * @version 2.0.0
  * @date 2020-11-20
  *
- * @copyright Copyright (c) 2020
+ * @copyright Copyright (c) 2020 All rights reserved. IP transferred to Bacula Systems according to agreement.
  */
 
 #include "ptcomm.h"
diff --git a/bacula/src/plugins/fd/pluginlib/smartalist_test.cpp b/bacula/src/plugins/fd/pluginlib/smartalist_test.cpp
new file mode 100644 (file)
index 0000000..b9d584e
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+   Bacula® - The Network Backup Solution
+
+   Copyright (C) 2007-2017 Bacula Systems SA
+   All rights reserved.
+
+   The main author of Bacula is Kern Sibbald, with contributions from many
+   others, a complete list can be found in the file AUTHORS.
+
+   Licensees holding a valid Bacula Systems SA license may use this file
+   and others of this release in accordance with the proprietary license
+   agreement provided in the LICENSE file.  Redistribution of any part of
+   this release is not permitted.
+
+   Bacula® is a registered trademark of Kern Sibbald.
+*/
+/**
+ * @file smartalist_test.cpp
+ * @author Radosław Korzeniewski (radoslaw@korzeniewski.net)
+ * @brief Common definitions and utility functions for Inteos plugins - unittest.
+ * @version 1.1.0
+ * @date 2020-12-23
+ *
+ * @copyright Copyright (c) 2020 All rights reserved. IP transferred to Bacula Systems according to agreement.
+ */
+
+#include "pluginlib.h"
+#include "smartalist.h"
+#include "unittests.h"
+
+bFuncs *bfuncs;
+bInfo *binfo;
+
+static int referencenumber = 0;
+
+struct testclass
+{
+   testclass() { referencenumber++; };
+   ~testclass() { referencenumber--; };
+};
+
+int main()
+{
+   Unittests pluglib_test("smartalist_test");
+   testclass *ti;
+
+   // Pmsg0(0, "Initialize tests ...\n");
+
+   {
+      smart_alist<testclass> list;
+      ti = new testclass;
+      list.append(ti);
+      ok(referencenumber == 1, "check first insert");
+   }
+
+   ok(referencenumber == 0, "check first smart free");
+
+   constexpr const int refs = 100;
+   referencenumber = 0;
+
+   {
+      smart_alist<testclass> list;
+      for (int a = 0; a < refs; a++)
+      {
+         ti = new testclass;
+         list.append(ti);
+      }
+      ok(referencenumber == refs, "check bulk inserts");
+   }
+
+   ok(referencenumber == 0, "check smart free");
+
+
+   return report();
+}