]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
tools: Create a cgset library for testing purposes
authorTom Hromatka <tom.hromatka@oracle.com>
Wed, 31 Mar 2021 16:44:11 +0000 (16:44 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Fri, 2 Apr 2021 19:02:52 +0000 (13:02 -0600)
Create libcgset.la so that functions within cgset can be
unit tested.

A functional test would be preferable in this case, but I'm
looking to test a very specific scenario - where there's an
'=' sign in the value of a setting's name/value pair.  To the
best of my knowledge, only the rdma (v1) and io (v2)
controllers have settings that utilize an '=' in such a fashion.
I can't think of an easy way to test rdma across our test fleet,
and our automated systems don't support the v2 io controller
yet.  Thus a unit test for now.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/tools/Makefile.am
src/tools/tools-common.h

index ccf43ab6f4afd0b527bdfb62c40be477c86dc229..690f34ea6038a3ea1cd9643c01c2ca0246f5add1 100644 (file)
@@ -10,6 +10,8 @@ bin_PROGRAMS = cgexec cgclassify cgcreate cgset cgget cgdelete lssubsys\
 
 sbin_PROGRAMS = cgconfigparser cgclear
 
+lib_LTLIBRARIES = libcgset.la
+
 cgexec_SOURCES = cgexec.c tools-common.c tools-common.h
 cgexec_LIBS = $(CODE_COVERAGE_LIBS)
 cgexec_CFLAGS = $(CODE_COVERAGE_CFLAGS)
@@ -22,9 +24,13 @@ cgcreate_SOURCES = cgcreate.c tools-common.c tools-common.h
 cgcreate_LIBS = $(CODE_COVERAGE_LIBS)
 cgcreate_CFLAGS = $(CODE_COVERAGE_CFLAGS)
 
+libcgset_la_SOURCES = cgset.c tools-common.c tools-common.h
+libcgset_la_LIBADD = $(CODE_COVERAGE_LIBS)
+libcgset_la_CFLAGS = $(CODE_COVERAGE_CFLAGS) -DSTATIC= -DUNIT_TEST
+
 cgset_SOURCES = cgset.c tools-common.c tools-common.h
 cgset_LIBS = $(CODE_COVERAGE_LIBS)
-cgset_CFLAGS = $(CODE_COVERAGE_CFLAGS)
+cgset_CFLAGS = $(CODE_COVERAGE_CFLAGS) -DSTATIC=static
 
 cgget_SOURCES = cgget.c tools-common.c tools-common.h
 cgget_LIBS = $(CODE_COVERAGE_LIBS)
index c723eb4ceee4d561e973a75f3845765a56d7337c..7492bbbff78d7bd4c542ae79c41253a4ca4d7557 100644 (file)
@@ -18,6 +18,7 @@
 
 #define __TOOLS_COMMON
 
+__BEGIN_DECLS
 #include "config.h"
 #include <libcgroup.h>
 #include "../libcgroup-internal.h"
@@ -122,4 +123,14 @@ int parse_mode(char *string, mode_t *pmode, const char *program_name);
 int parse_uid_gid(char *string, uid_t *uid, gid_t *gid,
                const char *program_name);
 
+/**
+ * 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 build.
+ */
+#ifdef UNIT_TEST
+#endif /* UNIT_TEST */
+
+__END_DECLS
+
 #endif /* TOOLS_COMMON */