]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
tests: Add STATIC and UNIT_TEST definitions to automake files
authorTom Hromatka <tom.hromatka@oracle.com>
Mon, 4 Nov 2019 23:14:16 +0000 (23:14 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Thu, 12 Dec 2019 22:10:28 +0000 (15:10 -0700)
This commit adds two new definitions to the automake Makefile.am
files.  This change has no effect on the deliverable binaries.

STATIC - For a standard libcgroup library build, STATIC is equal
         to the "static" keyword and behaves exactly the same.
         For a unit test build, STATIC is mapped to an empty
         string.  This allows the unit tests to invoke static
         functions that would otherwise be unavailable to the
         test suite.

UNIT_TEST - This define is used in libcgroup-internal.h to
         wrap the function prototypes of STATIC functions.
         In a standard libcgroup library build, UNIT_TEST
         is _not_ defined, and thus the prototypes are not
         available.  In a unit test build, UNIT_TEST is
         defined and the function prototypes are available
         for the unit tests to use.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/Makefile.am
src/libcgroup-internal.h
tests/gunit/Makefile.am

index 4a7b974d0a1b4adb67041a2238dcbaf58497dbfc..9fc965ba5ed71523747ff021b5d8ae5729aa0b77 100644 (file)
@@ -15,12 +15,12 @@ INCLUDES = -I$(top_srcdir)/include
 lib_LTLIBRARIES = libcgroup.la libcgroupfortesting.la
 libcgroup_la_SOURCES = parse.h parse.y lex.l api.c config.c libcgroup-internal.h libcgroup.map wrapper.c log.c
 libcgroup_la_LIBADD = -lpthread $(CODE_COVERAGE_LIBS)
-libcgroup_la_CFLAGS = $(CODE_COVERAGE_CFLAGS)
+libcgroup_la_CFLAGS = $(CODE_COVERAGE_CFLAGS) -DSTATIC=static
 libcgroup_la_LDFLAGS = -Wl,--version-script,$(srcdir)/libcgroup.map \
        -version-number $(LIBRARY_VERSION_MAJOR):$(LIBRARY_VERSION_MINOR):$(LIBRARY_VERSION_RELEASE)
 
 libcgroupfortesting_la_SOURCES = $(libcgroup_la_SOURCES)
 libcgroupfortesting_la_LIBADD = -lpthread $(CODE_COVERAGE_LIBS)
-libcgroupfortesting_la_CFLAGS = $(CODE_COVERAGE_CFLAGS)
+libcgroupfortesting_la_CFLAGS = $(CODE_COVERAGE_CFLAGS) -DSTATIC= -DUNIT_TEST
 libcgroupfortesting_la_LDFLAGS = -Wl,--version-script,$(top_srcdir)/tests/gunit/libcgroup_unittest.map \
        -version-number $(LIBRARY_VERSION_MAJOR):$(LIBRARY_VERSION_MINOR):$(LIBRARY_VERSION_RELEASE)
index 9875dd9a73969d35d03ee867b258195da13202f5..37c1f4592865c39ec902783ba66b896056ad3d50 100644 (file)
@@ -283,6 +283,15 @@ extern void cgroup_dictionary_iterator_end(void **handle);
  */
 int cg_chmod_path(const char *path, mode_t mode, int owner_is_umask);
 
+/**
+ * Functions that are defined as STATIC can be placed within the UNIT_TEST
+ * ifdef.  This will allow them to be included in the unit tests while
+ * remaining static in a normal libcgroup library build.
+ */
+#ifdef UNIT_TEST
+
+#endif /* UNIT_TEST */
+
 __END_DECLS
 
 #endif
index 1f54ad9377f5de081acbe48c6b04edb114b48bb6..79f9f7ee08b98a8c868e88e99bc5e0824d2fb6bf 100644 (file)
@@ -23,7 +23,9 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \
              -I$(top_srcdir)/src \
              -I$(top_builddir)/googletest/googletest/include \
              -I$(top_builddir)/googletest/googletest \
-             -std=c++11
+             -std=c++11 \
+             -DSTATIC= \
+             -DUNIT_TEST
 LDADD = ../../src/.libs/libcgroupfortesting.la \
        libgtest.la