tests/pc/test_pc.c
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- CO_set
- PR_set
- CO_to_string
- PR_to_string
- TH_to_string
- SK_close
- SK_puts
- CO_get_whois_suspended
- SK_gets
- SQ_close_connection
- CO_const_to_string
- SQ_free_result
- CO_get_sleep_time
- CO_get_password
- CO_get_database
- SQ_info_to_string
- CO_get_database_port
- CO_get_clear_screen
- TH_get_id
- CO_get_authenticate
- CO_get_prompt
- WQ_to_string
- PR_get_property
- CO_set_const
- CO_get_query
- SQ_result_to_string
- CO_get_welcome
- CO_get_config_logging
- CO_get_config_logfile
- CO_get_user
- SQ_execute_query
- CO_get_host
- SQ_get_connection
- main
/***************************************
$Revision: 1.2 $
Example code: Unit test driver for protocol_config.c
Status: NOT REVIEWED, NOT TESTED
******************/ /******************
Modification History:
ottrey (09/03/1999) Created.
ottrey (09/03/1999) Documented.
******************/ /******************
Copyright (c) 1993, 1994, 1995, 1996, 1997 The TERENA Association
Copyright (c) 1998 RIPE NCC
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of the author not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
***************************************/
#define UNIT_TEST
#include "../test_.c" /* unit test template */
#define TEST1 "1 General test"
#define TEST2 "2 General test"
#define TEST3 "3 General test"
#define TEST4 "4 General test"
/* Global Default to get the input from stdin */
FILE *Infile = stdin;
int Authenticate=0;
int Config_logging=0;
int Sleep_time=0;
int Clear_screen=0;
char *Password="DBgOHZFNyoSog";
char *Logfile="stdout";
char *CO_set() {
/* [<][>][^][v][top][bottom][index][help] */
return "call to CO_set()\n";
} /* CO_set() */
char *PR_set() {
/* [<][>][^][v][top][bottom][index][help] */
return "call to PR_set()\n";
} /* PR_set() */
char *CO_to_string() {
/* [<][>][^][v][top][bottom][index][help] */
return "CO_to_string() -- all the constants.";
} /* CO_to_string() */
char *PR_to_string() {
/* [<][>][^][v][top][bottom][index][help] */
return "PR_to_string() -- all the properties.";
} /* PR_to_string() */
char *TH_to_string() {
/* [<][>][^][v][top][bottom][index][help] */
return "TH_to_string() -- thread info.";
} /* TH_to_string() */
SK_close() {
/* [<][>][^][v][top][bottom][index][help] */
printf("call to SK_close()\n");
} /* SK_close() */
SK_puts(int sock, char *str) {
/* [<][>][^][v][top][bottom][index][help] */
if (str != NULL) {
printf(str);
}
} /* SK_puts() */
int CO_get_whois_suspended() {
/* [<][>][^][v][top][bottom][index][help] */
return 0;
} /* CO_get_whois_suspended() */
int SK_gets(int sock, char *input, int size) {
/* [<][>][^][v][top][bottom][index][help] */
int input_len;
fgets(input, size, Infile);
input_len = strlen(input);
if (input[input_len-1] == '\n') {
input[input_len-1] = '\0';
}
if (Verbose == 1) {
printf("input=%s\n", input);
}
return 1;
} /* SK_gets() */
SQ_close_connection() {
/* [<][>][^][v][top][bottom][index][help] */
printf("call to SQ_close_connection()\n");
} /* SQ_close_connection() */
char *CO_const_to_string(char *name) {
/* [<][>][^][v][top][bottom][index][help] */
return "value";
} /* CO_const_to_string() */
SQ_free_result() {
/* [<][>][^][v][top][bottom][index][help] */
printf("call to SQ_free_result()\n");
} /* SQ_free_result() */
int CO_get_sleep_time() {
/* [<][>][^][v][top][bottom][index][help] */
return Sleep_time;
} /* CO_get_sleep_time() */
char *CO_get_password() {
/* [<][>][^][v][top][bottom][index][help] */
printf("call to CO_get_password()\n");
} /* CO_get_password() */
CO_get_database() {
/* [<][>][^][v][top][bottom][index][help] */
printf("call to CO_get_database()\n");
} /* CO_get_database() */
char *SQ_info_to_string() {
/* [<][>][^][v][top][bottom][index][help] */
return "SQ_info_to_string() -- sql info";
} /* SQ_info_to_string() */
CO_get_database_port() {
/* [<][>][^][v][top][bottom][index][help] */
printf("call to CO_get_database_port()\n");
} /* CO_get_database_port() */
int CO_get_clear_screen() {
/* [<][>][^][v][top][bottom][index][help] */
return Clear_screen;
} /* CO_get_clear_screen() */
TH_get_id() {
/* [<][>][^][v][top][bottom][index][help] */
printf("call to TH_get_id()\n");
} /* TH_get_id() */
int CO_get_authenticate() {
/* [<][>][^][v][top][bottom][index][help] */
printf("CO_get_authenticate()=%d\n", Authenticate);
return Authenticate;
} /* CO_get_authenticate() */
char *CO_get_prompt() {
/* [<][>][^][v][top][bottom][index][help] */
return "CO_get_prompt() -- prompt> ";
} /* CO_get_prompt() */
char *WQ_to_string() {
/* [<][>][^][v][top][bottom][index][help] */
return "WQ_to_string() -- whois query info";
} /* WQ_to_string() */
char *PR_get_property(char *name) {
/* [<][>][^][v][top][bottom][index][help] */
return Password;
} /* PR_get_property() */
CO_set_const() {
/* [<][>][^][v][top][bottom][index][help] */
printf("call to CO_set_const()\n");
} /* CO_set_const() */
CO_get_query() {
/* [<][>][^][v][top][bottom][index][help] */
printf("call to CO_get_query()\n");
} /* CO_get_query() */
char *SQ_result_to_string() {
/* [<][>][^][v][top][bottom][index][help] */
return "SQ_result_to_string() - sql result";
} /* SQ_result_to_string() */
char *CO_get_welcome() {
/* [<][>][^][v][top][bottom][index][help] */
return "CO_get_welcome() -- Hi!\n";
} /* CO_get_welcome() */
int CO_get_config_logging() {
/* [<][>][^][v][top][bottom][index][help] */
return Config_logging;
} /* CO_get_config_logging() */
char *CO_get_config_logfile() {
/* [<][>][^][v][top][bottom][index][help] */
return Logfile;
} /* CO_get_config_logfile() */
CO_get_user() {
/* [<][>][^][v][top][bottom][index][help] */
printf("call to CO_get_user()\n");
} /* CO_get_user() */
SQ_execute_query() {
/* [<][>][^][v][top][bottom][index][help] */
printf("call to SQ_execute_query()\n");
} /* SQ_execute_query() */
CO_get_host() {
/* [<][>][^][v][top][bottom][index][help] */
printf("call to CO_get_host()\n");
} /* CO_get_host() */
SQ_get_connection() {
/* [<][>][^][v][top][bottom][index][help] */
printf("call to SQ_get_connection()\n");
} /* SQ_get_connection() */
int main(int argc, char** argv) {
/* [<][>][^][v][top][bottom][index][help] */
int i;
char input[STR_L];
char *str;
/* Get the options from the command line */
get_options(argc, argv);
/* TEST1 */
if(Test[1] == 1) {
print_title(TEST1);
/* Open Infile */
if (Infile_name != NULL) {
Infile = fopen(Infile_name, "r");
if (Infile == NULL) {
perror("Couldn't load Infile");
return -1;
}
}
PC_interact(1);
close(Infile);
} /* TEST1 */
Authenticate=1;
Config_logging=0;
Sleep_time=0;
Clear_screen=0;
/* TEST2 */
if(Test[2] == 1) {
print_title(TEST2);
/* Open Infile */
if (Infile_name != NULL) {
Infile = fopen(Infile_name, "r");
if (Infile == NULL) {
perror("Couldn't load Infile");
return -1;
}
}
PC_interact(1);
close(Infile);
} /* TEST2 */
Authenticate=0;
Config_logging=1;
Sleep_time=0;
Clear_screen=0;
/* TEST3 */
if(Test[3] == 1) {
print_title(TEST3);
/* Open Infile */
if (Infile_name != NULL) {
Infile = fopen(Infile_name, "r");
if (Infile == NULL) {
perror("Couldn't load Infile");
return -1;
}
}
PC_interact(1);
close(Infile);
} /* TEST3 */
Authenticate=1;
Config_logging=1;
Sleep_time=0;
Clear_screen=0;
/* TEST4 */
if(Test[4] == 1) {
print_title(TEST4);
/* Open Infile */
if (Infile_name != NULL) {
Infile = fopen(Infile_name, "r");
if (Infile == NULL) {
perror("Couldn't load Infile");
return -1;
}
}
PC_interact(1);
close(Infile);
} /* TEST4 */
return(0);
} /* main() */