diff options
author | Balbir Singh <balbir@linux.vnet.ibm.com> | 2008-12-17 15:17:57 +0000 |
---|---|---|
committer | Balbir Singh <balbir@linux.vnet.ibm.com> | 2008-12-17 15:17:57 +0000 |
commit | def5595456cbf96de855ba8d69c8e46e16f2f9c4 (patch) | |
tree | c8a1d281dc7c883e055622f9edbb5db9c69fe06d /tests/libcgrouptest.h | |
parent | 1a61c6f7fb1fb2b9f0092408e024dce34cc49900 (diff) | |
download | libcg-def5595456cbf96de855ba8d69c8e46e16f2f9c4.tar.gz libcg-def5595456cbf96de855ba8d69c8e46e16f2f9c4.tar.xz libcg-def5595456cbf96de855ba8d69c8e46e16f2f9c4.zip |
libcgroup Test: libcgroup-add-static-array-for-testcase-info-messages
This patch removes all the strncpy() calls that were made before each api
call to print the info messages. This patch creates an array of such info
messages, initialize them, and then frees them with the help of two functions
set_info_msgs(), called at start and free_info_msgs() called at end. The
main motto has been to avoid the global variables due to thread safety reasons.
Signed-off-by: Sudhir Kumar <skumar@linux.vnet.ibm.com>
git-svn-id: https://libcg.svn.sourceforge.net/svnroot/libcg/trunk@266 4f4bb910-9a46-0410-90c8-c897d4f1cd53
Diffstat (limited to 'tests/libcgrouptest.h')
-rw-r--r-- | tests/libcgrouptest.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/libcgrouptest.h b/tests/libcgrouptest.h index 644e176..70f565c 100644 --- a/tests/libcgrouptest.h +++ b/tests/libcgrouptest.h @@ -30,6 +30,7 @@ #include <libcgroup.h> #define SIZE 100 /* Max size of a message to be printed */ +#define NUM_MSGS 10 /* Number of such messsages */ #define PASS 1 /* test passed */ #define FAIL 0 /* test failed */ @@ -55,6 +56,9 @@ enum cgroup_control_val_t { STRING, }; +/* Create a matrix of possible info messages */ +char **info; + int64_t val_int64; u_int64_t val_uint64; bool val_bool; @@ -83,6 +87,11 @@ static inline void message(int num, int pass, char *api, int ret, char *extra); static inline void build_path(char *target, char *mountpoint, char *group, char *file); +/* Allocate memory and populate info messages */ +void set_info_msgs(); +/* Free the allocated memory for info messages */ +void free_info_msgs(); + static inline pid_t cgrouptest_gettid() { return syscall(__NR_gettid); |