Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

t_tc_path.c File Reference


Detailed Description

For internal use only.

This test program is used to test the operation of the tc_path() function.

Definition in file t_tc_path.c.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "test-harness.h"
#include "treeconf_int.h"

Include dependency graph for t_tc_path.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  test
 Describe a test. More...
struct  test_elem
 Test "file" information. More...

Defines

#define TEST_ACCESS
 Can access file.
#define TEST_XSEARCHED
 Search expected.
#define TEST_XCALLED
 Callback expected.
#define TEST_SEARCHED
 File searched.
#define TEST_CALLED
 Callback called.
#define TEST_EXPECTED
 Expected mask.
#define TEST_ACTUAL
 Actual mask.
#define TEST_ELEM(name, flags, ret)
 Initialize test file element.
#define TEST_PATH(test, path, default, flags, xret, cnt, elems, s_cnt, subs)
 Initialize test.
#define TEST_ELEMS(elems)
 Count elements in a struct test_elem array.
#define NUM_SUBSTS
 Test substitutions count.
#define NUM_TESTS
 Number of tests.

Functions

int access (const char *pathname, int mode)
 Overridden access() function.
unsigned int callback (const char *file, void *data)
 Test callback function.
void do_test (struct test *test)
 Execute a test case.
int main (int argc, char **argv)
 Test program for tc_path().

Variables

testcurr_test
 Current test.
test_elem basic_elems []
 Basic test file elements.
test_elem all_elems []
 Test file elements for all test.
treeconf_subst_t substs []
 Test substitutions.
test_elem subst_elems []
 Test file elements for substitution tests.
test_elem secure_elems []
 Test file elements for secure substitution tests.
test tests []
 Tests.


Define Documentation

#define NUM_SUBSTS
 

For internal use only.

This macro is defined to the number of substitutions in the substs array.

Definition at line 338 of file t_tc_path.c.

#define NUM_TESTS
 

For internal use only.

This macro contains the count of the number of tests to be performed.

Definition at line 391 of file t_tc_path.c.

#define TEST_ACCESS
 

For internal use only.

This flag, if set, indicates that our overridden access() function should return true.

Definition at line 81 of file t_tc_path.c.

Referenced by access().

#define TEST_ACTUAL
 

For internal use only.

This mask returns the actual results of the test for the "file".

Definition at line 127 of file t_tc_path.c.

#define TEST_CALLED
 

For internal use only.

This flag, if set, indicates that the callback function was called on this file.

Definition at line 113 of file t_tc_path.c.

#define TEST_ELEM name,
flags,
ret   ) 
 

For internal use only.

This macro initializes one member of a test file element array.

Parameters:
name The name of the file.
flags The flags controlling the test file.
ret The desired return value for the callback function.

Definition at line 138 of file t_tc_path.c.

#define TEST_ELEMS elems   ) 
 

For internal use only.

This macro simply returns the number of elements in the struct test_elem array elems.

Parameters:
elems A struct test_elem array.

Definition at line 168 of file t_tc_path.c.

#define TEST_EXPECTED
 

For internal use only.

This mask returns the expectation flags for the "file".

Definition at line 120 of file t_tc_path.c.

#define TEST_PATH test,
path,
default,
flags,
xret,
cnt,
elems,
s_cnt,
subs   ) 
 

For internal use only.

This macro initializes one member of the test array.

Parameters:
test The name of the test (as a bare word).
path The path to pass to tc_path().
default The default path to pass to tc_path().
flags The control flags to pass to tc_path().
xret The expected return value from tc_path().
cnt The number of elements in elems array.
elems An array of test "files".
s_cnt The number of substitutions passed to tc_path().
subs The array of substitutions to pass to tc_path().

Definition at line 156 of file t_tc_path.c.

#define TEST_SEARCHED
 

For internal use only.

This flag, if set, indicates that access() was called for this function.

Definition at line 105 of file t_tc_path.c.

#define TEST_XCALLED
 

For internal use only.

This flag, if set, indicates that we expect the callback function to be called on this file.

Definition at line 97 of file t_tc_path.c.

#define TEST_XSEARCHED
 

For internal use only.

This flag, if set, indicates that we expect access() to be called on this file name.

Definition at line 89 of file t_tc_path.c.


Function Documentation

int access const char *  pathname,
int  mode
 

For internal use only.

This is an override of the C library's access() function. Since it's not ANSI, we're supposed to be able to do so. We need to do this since the files we want to check for don't actually exist, and we want to know if tc_path() calls access() anyway.

Parameters:
pathname The file name to check.
mode The access mode to evaluate.
Return values:
0 The file can be accessed with the specified mode.
-1 The file cannot be accessed with the specified mode.

Definition at line 194 of file t_tc_path.c.

References curr_test, test::elem_cnt, test::elem_loc, test::elems, test::test, TEST_ACCESS, and test_elem::test_flags.

Referenced by _subst().

unsigned int callback const char *  file,
void *  data
[static]
 

For internal use only.

This is a treeconf_file_t callback function for testing tc_path().

Parameters:
file A pointer to char with the name of a file found by tc_path().
data A pointer to void with application-specific data passed as the call_data parameter of tc_path().
Returns:
Non-zero to abort tc_path(); zero otherwise.

Definition at line 226 of file t_tc_path.c.

References curr_test, test::elem_cnt, test::elem_loc, test::elems, test_elem::ret_val, test::test, and test_elem::test_flags.

Referenced by do_test(), and main().

void do_test struct test test  )  [static]
 

For internal use only.

This function executes the test case designated by the test parameter.

Parameters:
test A test to execute.

Definition at line 255 of file t_tc_path.c.

References callback(), curr_test, test::def, test::elem_cnt, test::elems, test_elem::filename, test::flags, test::path, test::subst_cnt, test::substs, tc_path(), test::test, test_elem::test_flags, and test::xret.

Referenced by main().

Here is the call graph for this function:

int main int  argc,
char **  argv
 

For internal use only.

This program is used for testing the treeconf library's tc_path() utility routine.

Definition at line 400 of file t_tc_path.c.

References callback(), do_test(), tc_path(), and tests.

Here is the call graph for this function:


Variable Documentation

struct test_elem all_elems[] [static]
 

For internal use only.

This array contains the file elements for a test of tc_path() with the TC_PATH_ALL flag.

Definition at line 312 of file t_tc_path.c.

struct test_elem basic_elems[] [static]
 

For internal use only.

This array contains the file elements for a basic test of tc_path().

Definition at line 297 of file t_tc_path.c.

struct test* curr_test [static]
 

For internal use only.

This is a pointer to the current test being executed, for the convenience of access() and callback().

Definition at line 176 of file t_tc_path.c.

Referenced by access(), callback(), and do_test().

struct test_elem secure_elems[] [static]
 

For internal use only.

This array contains the file elements for verifying that tc_path() performs substitutions properly under security conditions.

Definition at line 364 of file t_tc_path.c.

struct test_elem subst_elems[] [static]
 

For internal use only.

This array contains the file elements for verifying that tc_path() performs substitutions properly.

Definition at line 349 of file t_tc_path.c.

treeconf_subst_t substs[]
 

For internal use only.

This array contains substitutions for testing the substitution machinery of tc_path().

Definition at line 325 of file t_tc_path.c.

Referenced by _subst(), and tc_path().

struct test tests[] [static]
 

For internal use only.

This array contains the tests to perform on tc_path().

Definition at line 374 of file t_tc_path.c.

Referenced by main().


Generated on Wed Jun 8 09:18:31 2005 for treeconf by  doxygen 1.3.9.1