OpenVPN
Macros | Functions
test_argv.c File Reference
#include "config.h"
#include "syshead.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <setjmp.h>
#include <cmocka.h>
#include <assert.h>
#include <stdbool.h>
#include "argv.h"
#include "buffer.h"
#include "test_common.h"
Include dependency graph for test_argv.c:

Go to the source code of this file.

Macros

#define PATH1   "/s p a c e"
 
#define PATH2   "/foo bar/baz"
 
#define PARAM1   "param1"
 
#define PARAM2   "param two"
 
#define SCRIPT_CMD   "\"" PATH1 PATH2 "\"" PARAM1 "\"" PARAM2 "\""
 

Functions

int __wrap_parse_line (const char *line, char **p, const int n, const char *file, const int line_num, int msglevel, struct gc_arena *gc)
 
static void argv_printf__multiple_spaces_in_format__parsed_as_one (void **state)
 
static void argv_printf_cat__multiple_spaces_in_format__parsed_as_one (void **state)
 
static void argv_printf__embedded_format_directive__replaced_in_output (void **state)
 
static void argv_printf__group_sep_in_arg__fail_no_ouput (void **state)
 
static void argv_printf__combined_path_with_spaces__argc_correct (void **state)
 
static void argv_printf__empty_parameter__argc_correct (void **state)
 
static void argv_printf__long_args__data_correct (void **state)
 
static void argv_parse_cmd__command_string__argc_correct (void **state)
 
static void argv_parse_cmd__command_and_extra_options__argc_correct (void **state)
 
static void argv_printf_cat__used_twice__argc_correct (void **state)
 
static void argv_str__empty_argv__empty_output (void **state)
 
static void argv_str__multiple_argv__correct_output (void **state)
 
static void argv_insert_head__empty_argv__head_only (void **state)
 
static void argv_insert_head__non_empty_argv__head_added (void **state)
 
int main (void)
 

Macro Definition Documentation

◆ PARAM1

#define PARAM1   "param1"

Definition at line 20 of file test_argv.c.

◆ PARAM2

#define PARAM2   "param two"

Definition at line 21 of file test_argv.c.

◆ PATH1

#define PATH1   "/s p a c e"

Definition at line 18 of file test_argv.c.

◆ PATH2

#define PATH2   "/foo bar/baz"

Definition at line 19 of file test_argv.c.

◆ SCRIPT_CMD

#define SCRIPT_CMD   "\"" PATH1 PATH2 "\"" PARAM1 "\"" PARAM2 "\""

Definition at line 22 of file test_argv.c.

Function Documentation

◆ __wrap_parse_line()

int __wrap_parse_line ( const char *  line,
char **  p,
const int  n,
const char *  file,
const int  line_num,
int  msglevel,
struct gc_arena gc 
)

Definition at line 25 of file test_argv.c.

References PARAM1, PARAM2, PATH1, and PATH2.

◆ argv_insert_head__empty_argv__head_only()

static void argv_insert_head__empty_argv__head_only ( void **  state)
static

Definition at line 214 of file test_argv.c.

References argv_free(), argv_insert_head(), argv_new(), and PATH1.

Referenced by main().

◆ argv_insert_head__non_empty_argv__head_added()

static void argv_insert_head__non_empty_argv__head_added ( void **  state)
static

Definition at line 228 of file test_argv.c.

References argv::argc, argv::argv, argv_free(), argv_insert_head(), argv_new(), argv_printf(), PATH1, and PATH2.

Referenced by main().

◆ argv_parse_cmd__command_and_extra_options__argc_correct()

static void argv_parse_cmd__command_and_extra_options__argc_correct ( void **  state)
static

Definition at line 154 of file test_argv.c.

References argv::argc, argv_free(), argv_new(), argv_parse_cmd(), argv_printf_cat(), PATH1, and SCRIPT_CMD.

Referenced by main().

◆ argv_parse_cmd__command_string__argc_correct()

static void argv_parse_cmd__command_string__argc_correct ( void **  state)
static

Definition at line 143 of file test_argv.c.

References argv::argc, argv_free(), argv_new(), argv_parse_cmd(), and SCRIPT_CMD.

Referenced by main().

◆ argv_printf__combined_path_with_spaces__argc_correct()

static void argv_printf__combined_path_with_spaces__argc_correct ( void **  state)
static

Definition at line 81 of file test_argv.c.

References argv::argc, argv_free(), argv_new(), argv_printf(), PATH1, and PATH2.

Referenced by main().

◆ argv_printf__embedded_format_directive__replaced_in_output()

static void argv_printf__embedded_format_directive__replaced_in_output ( void **  state)
static

Definition at line 58 of file test_argv.c.

References argv::argc, argv::argv, argv_free(), argv_new(), argv_printf(), and PATH1.

Referenced by main().

◆ argv_printf__empty_parameter__argc_correct()

static void argv_printf__empty_parameter__argc_correct ( void **  state)
static

Definition at line 98 of file test_argv.c.

References argv::argc, argv_free(), argv_new(), argv_printf(), PARAM1, and PATH1.

Referenced by main().

◆ argv_printf__group_sep_in_arg__fail_no_ouput()

static void argv_printf__group_sep_in_arg__fail_no_ouput ( void **  state)
static

Definition at line 70 of file test_argv.c.

References argv::argc, argv_free(), argv_new(), and argv_printf().

Referenced by main().

◆ argv_printf__long_args__data_correct()

static void argv_printf__long_args__data_correct ( void **  state)
static

Definition at line 121 of file test_argv.c.

References argv::argc, argv::argv, argv_free(), argv_new(), and argv_printf().

Referenced by main().

◆ argv_printf__multiple_spaces_in_format__parsed_as_one()

static void argv_printf__multiple_spaces_in_format__parsed_as_one ( void **  state)
static

Definition at line 35 of file test_argv.c.

References argv::argc, argv_free(), argv_new(), argv_printf(), PATH1, and PATH2.

Referenced by main().

◆ argv_printf_cat__multiple_spaces_in_format__parsed_as_one()

static void argv_printf_cat__multiple_spaces_in_format__parsed_as_one ( void **  state)
static

Definition at line 46 of file test_argv.c.

References argv::argc, argv_free(), argv_new(), argv_printf(), argv_printf_cat(), PARAM1, PATH1, and PATH2.

Referenced by main().

◆ argv_printf_cat__used_twice__argc_correct()

static void argv_printf_cat__used_twice__argc_correct ( void **  state)
static

Definition at line 166 of file test_argv.c.

References argv::argc, argv_free(), argv_new(), argv_printf(), argv_printf_cat(), PARAM1, PARAM2, PATH1, and PATH2.

Referenced by main().

◆ argv_str__empty_argv__empty_output()

static void argv_str__empty_argv__empty_output ( void **  state)
static

Definition at line 179 of file test_argv.c.

References argv_free(), argv_new(), argv_str(), gc_free(), gc_new(), and PA_BRACKET.

Referenced by main().

◆ argv_str__multiple_argv__correct_output()

static void argv_str__multiple_argv__correct_output ( void **  state)
static

◆ main()

int main ( void  )