libpoldiff-tests.h

Go to the documentation of this file.
00001 /**
00002  *  @file
00003  *
00004  *  Header for for CUnit testing framework of libpoldiff's correctness.
00005  *
00006  *  @author Paul Rosenfeld prosenfeld@tresys.com
00007  *
00008  *  Copyright (C) 2007 Tresys Technology, LLC
00009  *
00010  *  This library is free software; you can redistribute it and/or
00011  *  modify it under the terms of the GNU Lesser General Public
00012  *  License as published by the Free Software Foundation; either
00013  *  version 2.1 of the License, or (at your option) any later version.
00014  *
00015  *  This library is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *  Lesser General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU Lesser General Public
00021  *  License along with this library; if not, write to the Free Software
00022  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00023  */
00024 
00025 #ifndef LIBPOLDIFF_TESTS
00026 #define LIBPOLDIFF_TESTS
00027 
00028 #include <poldiff/poldiff.h>
00029 #include <apol/vector.h>
00030 
00031 typedef const apol_vector_t *(*poldiff_get_diff_vector) (const poldiff_t *);
00032 typedef const char *(*poldiff_get_name) (const void *);
00033 typedef poldiff_form_e(*poldiff_get_form) (const void *);
00034 typedef const apol_vector_t *(*poldiff_get_added) (const void *);
00035 typedef const apol_vector_t *(*poldiff_get_removed) (const void *);
00036 
00037 typedef struct _test_answers
00038 {
00039         apol_vector_t *correct_added_v;
00040         apol_vector_t *correct_removed_v;
00041         apol_vector_t *correct_unchanged_v;
00042         apol_vector_t *correct_modified_v;
00043 } poldiff_test_answers_t;
00044 
00045 typedef struct _component_funcs
00046 {
00047         poldiff_get_diff_vector get_diff_vector;
00048         poldiff_get_name get_name;
00049         poldiff_get_form get_form;
00050         poldiff_get_added get_added;
00051         poldiff_get_removed get_removed;
00052 } component_funcs_t;
00053 
00054 typedef enum _test_numbers
00055 {
00056         COMPONENT = 0, RULES_AVRULE, RULES_TERULE, RULES_ROLEALLOW, RULES_ROLETRANS,
00057         MLS_CATEGORY, MLS_LEVEL, MLS_RANGETRANS, MLS_USER
00058 } test_numbers_e;
00059 
00060 poldiff_t *init_poldiff(char *orig_base_path, char *mod_base_path);
00061 component_funcs_t *init_test_funcs(poldiff_get_diff_vector, poldiff_get_name, poldiff_get_form, poldiff_get_added,
00062                                    poldiff_get_removed);
00063 void run_test(component_funcs_t *, poldiff_test_answers_t *, test_numbers_e);
00064 
00065 apol_vector_t *string_array_to_vector(char *[]);
00066 void cleanup_test(poldiff_test_answers_t *);
00067 char *vector_to_string(const apol_vector_t *, const char *, const char *);
00068 
00069 int compare_str(const void *s1, const void *s2, void *debug);
00070 poldiff_test_answers_t *init_answer_vectors(char *[], char *[], char *[], char *[]);
00071 void print_test_failure(apol_vector_t *, apol_vector_t *, size_t, const char *);
00072 
00073 apol_vector_t *shallow_copy_str_vec_and_sort(const apol_vector_t * v);
00074 
00075 poldiff_t *diff;
00076 
00077 apol_policy_t *orig_policy;
00078 apol_policy_t *mod_policy;
00079 
00080 apol_vector_t *added_v;
00081 apol_vector_t *removed_v;
00082 apol_vector_t *modified_v;
00083 apol_vector_t *modified_name_only_v;
00084 
00085 #endif