libsepol/test Include policydb.h header for policydb_t declaration
PATCH 1/5 libsepol/test Include policydb.h header for policydb_t declaration
Since test-linker-cond-map.h and test-linker-types.h references policydb_t, include the policydb header file.
--- libsepol/tests/test-linker-cond-map.h | 2 ++ libsepol/tests/test-linker-types.h | 2 ++ 2 files changed, 4 insertions(+)
libsepol/tests/test-linker-cond-map.h +2 -0
@@ -21,6 +21,8 @@#ifndef __TEST_LINKER_COND_MAP_H__#define __TEST_LINKER_COND_MAP_H__ +#include <sepol/policydb/policydb.h> +extern void base_cond_tests (policydb_t * base);extern void module_cond_tests (policydb_t * base);
libsepol/tests/test-linker-types.h +2 -0
@@ -21,6 +21,8 @@#ifndef __TEST_LINKER_TYPES_H__#define __TEST_LINKER_TYPES_H__ +#include <sepol/policydb/policydb.h> +extern void base_type_tests (policydb_t * base);extern void module_type_tests (policydb_t * base);
Signature · 1 line
2.34.1
PATCH 2/5 libsepol/test: Include paired headers for prototypes
This is needed to use "-Wmissing-prototypes".
--- libsepol/tests/test-common.c | 1 + libsepol/tests/test-linker-cond-map.c | 1 + libsepol/tests/test-linker-roles.c | 1 + libsepol/tests/test-linker-types.c | 1 + 4 files changed, 4 insertions(+)
libsepol/tests/test-common.c +1 -0
@@ -26,6 +26,7 @@#include <CUnit/Basic.h> +#include "test-common.h" #include "helpers.h" void test_sym_presence (policydb_t * p,const char *id,int sym_type,unsigned int scope_type,unsigned int *decls,unsigned int len)
libsepol/tests/test-linker-cond-map.c +1 -0
@@ -18,6 +18,7 @@* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "test-linker-cond-map.h" #include "parse_util.h" #include "helpers.h" #include "test-common.h"
libsepol/tests/test-linker-roles.c +1 -0
@@ -18,6 +18,7 @@* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "test-linker-roles.h" #include "parse_util.h" #include "helpers.h" #include "test-common.h"
libsepol/tests/test-linker-types.c +1 -0
@@ -19,6 +19,7 @@* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "test-linker-types.h" #include "parse_util.h" #include "helpers.h" #include "test-common.h"
Signature · 1 line
2.34.1
PATCH 3/5 libsepol/test: Declare file local functions as static
In reply to James CarterThis is needed to use "-Wmissing-prototypes".
--- libsepol/tests/test-expander.c | 2 +- libsepol/tests/test-linker-cond-map.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
libsepol/tests/test-expander.c +1 -1
@@ -67,7 +67,7 @@ extern int mls;/* Takes base, some number of modules, links them, and expands them reads source from myfiles array, which has the base string followed by each module string */ -int expander_policy_init (policydb_t * mybase,int num_modules,policydb_t ** mymodules,policydb_t * myexpanded,const char *const *myfiles) +static int expander_policy_init (policydb_t * mybase,int num_modules,policydb_t ** mymodules,policydb_t * myexpanded,const char *const *myfiles) {char *filename[num_modules +1 ];int i;
libsepol/tests/test-linker-cond-map.c +2 -2
@@ -55,7 +55,7 @@ typedef struct test_cond_expr {uint32_t expr_type; } test_cond_expr_t; -void test_cond_expr_mapping (policydb_t * p,avrule_decl_t * d,test_cond_expr_t * bools,int len) +static void test_cond_expr_mapping (policydb_t * p,avrule_decl_t * d,test_cond_expr_t * bools,int len) {int i;cond_expr_t *expr;
@@ -76,7 +76,7 @@ void test_cond_expr_mapping(policydb_t * p, avrule_decl_t * d, test_cond_expr_t } } -void test_bool_state (policydb_t * p,const char *bool,int state) +static void test_bool_state (policydb_t * p,const char *bool,int state) {cond_bool_datum_t *b;
Signature · 1 line
2.34.1
PATCH 4/5 libsemanage/tests: Declare file local functions as static
In reply to James CarterThis is needed to use "-Wmissing-prototypes".
--- libsemanage/tests/test_bool.c | 118 +++++++++++++-------------- libsemanage/tests/test_fcontext.c | 126 ++++++++++++++--------------- libsemanage/tests/test_handle.c | 54 ++++++------- libsemanage/tests/test_ibendport.c | 60 +++++++------- libsemanage/tests/test_iface.c | 88 ++++++++++---------- libsemanage/tests/test_node.c | 104 ++++++++++++------------ libsemanage/tests/test_port.c | 114 +++++++++++++------------- libsemanage/tests/test_user.c | 96 +++++++++++----------- libsemanage/tests/test_utilities.c | 41 +++++----- libsemanage/tests/utilities.c | 2 +- 10 files changed, 402 insertions(+), 401 deletions(-)
libsemanage/tests/test_bool.c +59 -59
@@ -31,29 +31,29 @@#define BOOL_NONEXISTENT "asdf"/* boolean_record.h */ -void test_bool_key_create (void ); -void test_bool_key_extract (void ); -void test_bool_compare (void ); -void test_bool_compare2 (void ); -void test_bool_get_set_name (void ); -void test_bool_get_set_value (void ); -void test_bool_create (void ); -void test_bool_clone (void ); +static void test_bool_key_create (void ); +static void test_bool_key_extract (void ); +static void test_bool_compare (void ); +static void test_bool_compare2 (void ); +static void test_bool_get_set_name (void ); +static void test_bool_get_set_value (void ); +static void test_bool_create (void ); +static void test_bool_clone (void );/* booleans_policy.h */ -void test_bool_query (void ); -void test_bool_exists (void ); -void test_bool_count (void ); -void test_bool_iterate (void ); -void test_bool_list (void ); +static void test_bool_query (void ); +static void test_bool_exists (void ); +static void test_bool_count (void ); +static void test_bool_iterate (void ); +static void test_bool_list (void );/* booleans_local.h */ -void test_bool_modify_del_local (void ); -void test_bool_query_local (void ); -void test_bool_exists_local (void ); -void test_bool_count_local (void ); -void test_bool_iterate_local (void ); -void test_bool_list_local (void ); +static void test_bool_modify_del_local (void ); +static void test_bool_query_local (void ); +static void test_bool_exists_local (void ); +static void test_bool_count_local (void ); +static void test_bool_iterate_local (void ); +static void test_bool_list_local (void );extern semanage_handle_t *sh;
@@ -111,7 +111,7 @@ int bool_add_tests(CU_pSuite suite)/* Helpers */ -semanage_bool_t *get_bool_nth (int idx) +static semanage_bool_t *get_bool_nth (int idx) {int res;semanage_bool_t **records;
@@ -137,7 +137,7 @@ semanage_bool_t *get_bool_nth(int idx)return boolean; } -semanage_bool_t *get_bool_new (void ) +static semanage_bool_t *get_bool_new (void ) {int res;semanage_bool_t *boolean;
@@ -149,7 +149,7 @@ semanage_bool_t *get_bool_new(void)return boolean; } -semanage_bool_key_t *get_bool_key_nth (int idx) +static semanage_bool_key_t *get_bool_key_nth (int idx) {semanage_bool_key_t *key;semanage_bool_t *boolean;
@@ -170,7 +170,7 @@ semanage_bool_key_t *get_bool_key_nth(int idx)return key; } -semanage_bool_key_t *get_bool_key_from_str (const char *str) +static semanage_bool_key_t *get_bool_key_from_str (const char *str) {semanage_bool_key_t *key;int res;
@@ -186,7 +186,7 @@ semanage_bool_key_t *get_bool_key_from_str(const char *str)return key; } -void add_local_bool (const char *name) +static void add_local_bool (const char *name) {semanage_bool_t *boolean;semanage_bool_key_t *key =NULL ;
@@ -205,7 +205,7 @@ void add_local_bool(const char *name)semanage_bool_free (boolean); } -void delete_local_bool (const char *name) +static void delete_local_bool (const char *name) {semanage_bool_key_t *key =NULL ;
@@ -221,7 +221,7 @@ void delete_local_bool(const char *name)/* Function bool_key_create */ -void helper_bool_key_create (level_t level) +static void helper_bool_key_create (level_t level) {semanage_bool_key_t *key =NULL ;
@@ -253,7 +253,7 @@ void test_bool_key_create(void)#define SK_NEW 2#define SK_INDEX 3#define SK_KEY_NULL 4 -void helper_bool_key_extract (level_t level,int mode) +static void helper_bool_key_extract (level_t level,int mode) {semanage_bool_t *boolean =NULL ;semanage_bool_key_t *key =NULL ;
@@ -306,7 +306,7 @@ void test_bool_key_extract(void)#undef SK_KEY_NULL/* Function bool_compare */ -void helper_bool_compare (level_t level,int bool_idx1,int bool_idx2) +static void helper_bool_compare (level_t level,int bool_idx1,int bool_idx2) {semanage_bool_t *boolean;semanage_bool_key_t *key;
@@ -330,7 +330,7 @@ void helper_bool_compare(level_t level, int bool_idx1, int bool_idx2)cleanup_handle (level); } -void test_bool_compare (void ) +static void test_bool_compare (void ) {helper_bool_compare (SH_CONNECT ,I_FIRST ,I_FIRST );helper_bool_compare (SH_CONNECT ,I_FIRST ,I_SECOND );
@@ -344,7 +344,7 @@ void test_bool_compare(void) }/* Function bool_compare2 */ -void helper_bool_compare2 (level_t level,int bool_idx1,int bool_idx2) +static void helper_bool_compare2 (level_t level,int bool_idx1,int bool_idx2) {semanage_bool_t *bool1;semanage_bool_t *bool2;
@@ -368,7 +368,7 @@ void helper_bool_compare2(level_t level, int bool_idx1, int bool_idx2)cleanup_handle (level); } -void test_bool_compare2 (void ) +static void test_bool_compare2 (void ) {helper_bool_compare2 (SH_CONNECT ,I_FIRST ,I_FIRST );helper_bool_compare2 (SH_CONNECT ,I_FIRST ,I_SECOND );
@@ -382,7 +382,7 @@ void test_bool_compare2(void) }/* Function bool_get_name, bool_set_name */ -void helper_bool_get_set_name (level_t level,int bool_idx,const char *name) +static void helper_bool_get_set_name (level_t level,int bool_idx,const char *name) {semanage_bool_t *boolean;const char *new_name =NULL ;
@@ -404,7 +404,7 @@ void helper_bool_get_set_name(level_t level, int bool_idx, const char *name)cleanup_handle (level); } -void test_bool_get_set_name (void ) +static void test_bool_get_set_name (void ) {helper_bool_get_set_name (SH_CONNECT ,I_FIRST ,"testbool" );helper_bool_get_set_name (SH_CONNECT ,I_FIRST ,"" );
@@ -418,7 +418,7 @@ void test_bool_get_set_name(void) }/* Function bool_get_value, bool_set_value */ -void helper_bool_get_set_value (int bool_idx,int val) +static void helper_bool_get_set_value (int bool_idx,int val) {semanage_bool_t *boolean;int new_val =0 ;
@@ -436,7 +436,7 @@ void helper_bool_get_set_value(int bool_idx, int val)semanage_bool_free (boolean); } -void test_bool_get_set_value (void ) +static void test_bool_get_set_value (void ) {helper_bool_get_set_value (I_FIRST ,1 );helper_bool_get_set_value (I_FIRST ,0 );
@@ -445,7 +445,7 @@ void test_bool_get_set_value(void) }/* Function bool_create */ -void helper_bool_create (level_t level) +static void helper_bool_create (level_t level) {semanage_bool_t *boolean;
@@ -461,7 +461,7 @@ void helper_bool_create(level_t level)cleanup_handle (level); } -void test_bool_create (void ) +static void test_bool_create (void ) {helper_bool_create (SH_HANDLE );helper_bool_create (SH_CONNECT );
@@ -469,7 +469,7 @@ void test_bool_create(void) }/* Function bool_clone */ -void helper_bool_clone (level_t level,int bool_idx) +static void helper_bool_clone (level_t level,int bool_idx) {semanage_bool_t *boolean;semanage_bool_t *boolean_clone;
@@ -500,7 +500,7 @@ void helper_bool_clone(level_t level, int bool_idx)cleanup_handle (level); } -void test_bool_clone (void ) +static void test_bool_clone (void ) {helper_bool_clone (SH_CONNECT ,I_FIRST );helper_bool_clone (SH_CONNECT ,I_SECOND );
@@ -510,7 +510,7 @@ void test_bool_clone(void) }/* Function bool_query */ -void helper_bool_query (level_t level,const char *bool_str,int exp_res) +static void helper_bool_query (level_t level,const char *bool_str,int exp_res) {semanage_bool_key_t *key;semanage_bool_t *resp = (void *)42 ;
@@ -534,7 +534,7 @@ void helper_bool_query(level_t level, const char *bool_str, int exp_res)cleanup_handle (level); } -void test_bool_query (void ) +static void test_bool_query (void ) {helper_bool_query (SH_CONNECT ,BOOL1_NAME ,1 );helper_bool_query (SH_CONNECT ,BOOL2_NAME ,1 );
@@ -546,7 +546,7 @@ void test_bool_query(void) }/* Function bool_exists */ -void helper_bool_exists (level_t level,const char *bool_str,int exp_resp) +static void helper_bool_exists (level_t level,const char *bool_str,int exp_resp) {semanage_bool_key_t *key;int resp;
@@ -563,7 +563,7 @@ void helper_bool_exists(level_t level, const char *bool_str, int exp_resp)cleanup_handle (level); } -void test_bool_exists (void ) +static void test_bool_exists (void ) {helper_bool_exists (SH_CONNECT ,BOOL1_NAME ,1 );helper_bool_exists (SH_CONNECT ,BOOL2_NAME ,1 );
@@ -575,7 +575,7 @@ void test_bool_exists(void) }/* Function bool_count */ -void test_bool_count (void ) +static void test_bool_count (void ) {unsigned int resp;
@@ -603,13 +603,13 @@ void test_bool_count(void)/* Function bool_iterate */ unsigned int counter_bool_iterate =0 ; -int handler_bool_iterate (const semanage_bool_t *record,void *varg) +static int handler_bool_iterate (const semanage_bool_t *record,void *varg) { counter_bool_iterate++;return 0 ; } -void helper_bool_iterate_invalid (void ) +static void helper_bool_iterate_invalid (void ) {setup_handle (SH_HANDLE );CU_ASSERT (semanage_bool_iterate (sh, &handler_bool_iterate,NULL ) <0 );
@@ -617,7 +617,7 @@ void helper_bool_iterate_invalid(void)cleanup_handle (SH_HANDLE ); } -void helper_bool_iterate (level_t level) +static void helper_bool_iterate (level_t level) {setup_handle (level); counter_bool_iterate =0 ;
@@ -626,7 +626,7 @@ void helper_bool_iterate(level_t level)cleanup_handle (level); } -void test_bool_iterate (void ) +static void test_bool_iterate (void ) {helper_bool_iterate_invalid ();helper_bool_iterate (SH_CONNECT );
@@ -634,7 +634,7 @@ void test_bool_iterate(void) }/* Function bool_list */ -void helper_bool_list_invalid (void ) +static void helper_bool_list_invalid (void ) {semanage_bool_t **records;unsigned int count;
@@ -648,7 +648,7 @@ void helper_bool_list_invalid(void)cleanup_handle (SH_HANDLE ); } -void helper_bool_list (level_t level) +static void helper_bool_list (level_t level) {semanage_bool_t **records;unsigned int count;
@@ -669,7 +669,7 @@ void helper_bool_list(level_t level)cleanup_handle (level); } -void test_bool_list (void ) +static void test_bool_list (void ) {helper_bool_list_invalid ();helper_bool_list (SH_CONNECT );
@@ -677,7 +677,7 @@ void test_bool_list(void) }/* Function bool_modify_local, bool_del_local */ -void helper_bool_modify_del_local (level_t level,const char *name, +static void helper_bool_modify_del_local (level_t level,const char *name,int old_val,int exp_res) {semanage_bool_t *boolean;
@@ -729,7 +729,7 @@ void helper_bool_modify_del_local(level_t level, const char *name,cleanup_handle (level); } -void test_bool_modify_del_local (void ) +static void test_bool_modify_del_local (void ) {helper_bool_modify_del_local (SH_CONNECT ,BOOL1_NAME ,BOOL1_VALUE ,-1 );helper_bool_modify_del_local (SH_CONNECT ,BOOL2_NAME ,BOOL2_VALUE ,-1 );
@@ -738,7 +738,7 @@ void test_bool_modify_del_local(void) }/* Function bool_query_local */ -void test_bool_query_local (void ) +static void test_bool_query_local (void ) {semanage_bool_key_t *key =NULL ;semanage_bool_t *resp =NULL ;
@@ -785,7 +785,7 @@ void test_bool_query_local(void) }/* Function bool_exists_local */ -void test_bool_exists_local (void ) +static void test_bool_exists_local (void ) {int resp =-1 ;semanage_bool_key_t *key;
@@ -815,7 +815,7 @@ void test_bool_exists_local(void) }/* Function bool_count_local */ -void test_bool_count_local (void ) +static void test_bool_count_local (void ) {unsigned int resp;unsigned int init_count;
@@ -859,13 +859,13 @@ void test_bool_count_local(void)/* Function bool_iterate_local */ unsigned int counter_bool_iterate_local =0 ; -int handler_bool_iterate_local (const semanage_bool_t *record,void *varg) +static int handler_bool_iterate_local (const semanage_bool_t *record,void *varg) { counter_bool_iterate_local++;return 0 ; } -void test_bool_iterate_local (void ) +static void test_bool_iterate_local (void ) {unsigned int init_count;
@@ -912,7 +912,7 @@ void test_bool_iterate_local(void) }/* Function bool_list_local */ -void test_bool_list_local (void ) +static void test_bool_list_local (void ) {semanage_bool_t **records;unsigned int count;
libsemanage/tests/test_fcontext.c +63 -63
383 lines not on this page · raw message
libsemanage/tests/test_handle.c +27 -27
149 lines not on this page · raw message
libsemanage/tests/test_ibendport.c +30 -30
188 lines not on this page · raw message
libsemanage/tests/test_iface.c +44 -44
246 lines not on this page · raw message
libsemanage/tests/test_node.c +52 -52
286 lines not on this page · raw message
libsemanage/tests/test_port.c +57 -57
334 lines not on this page · raw message
libsemanage/tests/test_user.c +48 -48
266 lines not on this page · raw message
libsemanage/tests/test_utilities.c +21 -20
105 lines not on this page · raw message
libsemanage/tests/utilities.c +1 -1
@@ -76,7 +76,7 @@ void enable_test_store(void) { test_store_enabled =1 ; } -int write_test_policy (char *data,size_t data_len) { +static int write_test_policy (char *data,size_t data_len) {FILE *fptr =fopen ("test-policy/store/active/policy.kern" ,"wb+" );if (!fptr) {
Signature · 1 line
2.34.1
PATCH 5/5 libsemanage/tests: Remove unused functions
In reply to James CarterThe functions helper_port_validate_local_proto(), get_type(), and get_fcontext_new() are not used, so remove them.
--- libsemanage/tests/test_fcontext.c | 31 ---------------- libsemanage/tests/test_port.c | 62 ------------------------------- 2 files changed, 93 deletions(-)
libsemanage/tests/test_fcontext.c +0 -31
@@ -73,28 +73,6 @@ static void test_fcontext_list_local(void);extern semanage_handle_t *sh; -static int get_type (char *t) -{ -if (strcmp (t,"--" ) ==0 ) -return SEMANAGE_FCONTEXT_ALL ; -else if (strcmp (t,"-f" ) ==0 ) -return SEMANAGE_FCONTEXT_REG ; -else if (strcmp (t,"-d" ) ==0 ) -return SEMANAGE_FCONTEXT_DIR ; -else if (strcmp (t,"-c" ) ==0 ) -return SEMANAGE_FCONTEXT_CHAR ; -else if (strcmp (t,"-b" ) ==0 ) -return SEMANAGE_FCONTEXT_BLOCK ; -else if (strcmp (t,"-s" ) ==0 ) -return SEMANAGE_FCONTEXT_SOCK ; -else if (strcmp (t,"-l" ) ==0 ) -return SEMANAGE_FCONTEXT_LINK ; -else if (strcmp (t,"-p" ) ==0 ) -return SEMANAGE_FCONTEXT_PIPE ; -else -return -1 ; -} -static int write_file_contexts (const char *data,unsigned int data_len) {FILE *fptr =fopen ("test-policy/store/active/file_contexts" ,"w+" );
@@ -187,15 +165,6 @@ int fcontext_add_tests(CU_pSuite suite)/* Helpers */ -static semanage_fcontext_t *get_fcontext_new (void ) -{ -semanage_fcontext_t *fcontext; - -CU_ASSERT_FATAL (semanage_fcontext_create (sh, &fcontext) >=0 ); - -return fcontext; -} -static semanage_fcontext_t *get_fcontext_nth (int idx) {semanage_fcontext_t **records;
libsemanage/tests/test_port.c +0 -62
68 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 4 lines · James Carter
Since
test-linker-cond-map.handtest-linker-types.hreferencespolicydb_t, include the policydb header file.Signed-off-by James Carter <[email protected]>
For all 5 patches:
Quoted 33 lines
--- libsepol/tests/test-linker-cond-map.h | 2 ++ libsepol/tests/test-linker-types.h | 2 ++ 2 files changed, 4 insertions(+)libsepol/tests/test-linker-cond-map.h +2
-0@@ -21,6 +21,8 @@#ifndef __TEST_LINKER_COND_MAP_H__#define __TEST_LINKER_COND_MAP_H__ +#include <sepol/policydb/policydb.h> +extern void base_cond_tests (policydb_t * base);extern void module_cond_tests (policydb_t * base);libsepol/tests/test-linker-types.h +2
-0@@ -21,6 +21,8 @@#ifndef __TEST_LINKER_TYPES_H__#define __TEST_LINKER_TYPES_H__ +#include <sepol/policydb/policydb.h> +extern void base_type_tests (policydb_t * base);extern void module_type_tests (policydb_t * base);Signature · 1 line
2.34.1
Quoted 12 lines · Petr Lautrbach
Quoted 4 lines · James Carter
Since
test-linker-cond-map.handtest-linker-types.hreferencespolicydb_t, include the policydb header file.Signed-off-by James Carter <[email protected]>For all 5 patches:
Acked-by Petr Lautrbach <[email protected]>
These patches have been merged.
Thanks,
Jim
Quoted 34 lines
Quoted 33 lines
--- libsepol/tests/test-linker-cond-map.h | 2 ++ libsepol/tests/test-linker-types.h | 2 ++ 2 files changed, 4 insertions(+)libsepol/tests/test-linker-cond-map.h +2
-0@@ -21,6 +21,8 @@#ifndef __TEST_LINKER_COND_MAP_H__#define __TEST_LINKER_COND_MAP_H__ +#include <sepol/policydb/policydb.h> +extern void base_cond_tests (policydb_t * base);extern void module_cond_tests (policydb_t * base);libsepol/tests/test-linker-types.h +2
-1@@ -21,6 +21,8 @@#ifndef __TEST_LINKER_TYPES_H__#define __TEST_LINKER_TYPES_H__ +#include <sepol/policydb/policydb.h> +extern void base_type_tests (policydb_t * base);extern void module_type_tests (policydb_t * base); --2.34.1