TPCCLIB
Toggle main menu visibility
Loading...
Searching...
No Matches
libtpcnew
libtpcnew.c
1
/******************************************************************************
2
* This file is not compiled into the library, but it contains main()
3
* which is compiled to an executable, used to test the library functions.
4
*****************************************************************************/
5
6
/*****************************************************************************/
7
#include "tpcclibConfig.h"
8
/*****************************************************************************/
9
#include <unistd.h>
10
/*****************************************************************************/
11
#include "
tpcnew.h
"
12
#include "test_tpcnew.h"
13
/*****************************************************************************/
14
15
/*****************************************************************************/
16
static
char
*info[] = {
17
"Usage: @P [options]"
,
18
" "
,
19
"Options:"
,
20
" -stdoptions"
,
// List standard options like --help, -v, etc
21
" -t, --test"
,
22
" Run all tests for library functions."
,
23
0};
24
/*****************************************************************************/
25
26
/*****************************************************************************/
31
int
main(
33
int
argc,
35
char
*argv[ ]
36
) {
37
int
i, help=0, version=0, verbose=1, error=0, test=0;
38
int
ret;
39
char
*cptr;
40
41
if
(argc==1) {
tpcPrintUsage
(argv[0], info, stdout);
return
(0);}
42
for
(i=1; i<argc; i++) {
43
if
(
tpcProcessStdOptions
(argv[i], &help, &version, &verbose)==0)
continue
;
44
cptr=argv[i];
if
(*cptr==
'-'
) cptr++;
if
(*cptr==
'-'
) cptr++;
45
if
(strncasecmp(cptr,
"TEST"
, 1)==0) {
46
test=1;
continue
;
47
}
else
{
48
error++;
break
;
49
}
50
}
51
if
(error>0) {
52
fprintf(stderr,
"Error: specify --help for usage.\n"
);
53
return
(1);
54
}
55
/* Print help or version? */
56
if
(help) {
tpcPrintUsage
(argv[0], info, stdout);
return
(0);}
57
if
(version) {
tpcPrintBuild
(argv[0], stdout);
return
(0);}
58
59
if
(test==0)
return
(0);
60
61
if
(verbose>0) printf(
"running tests for library functions...\n"
);
62
TPCSTATUS
status;
statusInit
(&status); status.
verbose
=verbose;
63
statusSet
(&status, __func__, __FILE__, __LINE__, 0);
64
i=10;
65
66
/* new */
67
i++;
if
((ret=test_newTemplate(&status))!=0) {
68
fprintf(stderr,
"failed (%d).\n"
, ret);
69
statusPrint
(stderr, &status);
statusFree
(&status);
70
return
(i);
71
}
72
73
if
(verbose>0) printf(
"\nAll tests passed.\n\n"
);
74
statusFree
(&status);
75
return
(0);
76
}
77
/*****************************************************************************/
78
79
/*****************************************************************************/
tpcProcessStdOptions
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
Definition
proginfo.c:47
tpcPrintBuild
void tpcPrintBuild(const char *program, FILE *fp)
Definition
proginfo.c:339
tpcPrintUsage
void tpcPrintUsage(const char *program, char *text[], FILE *fp)
Definition
proginfo.c:114
statusPrint
void statusPrint(FILE *fp, TPCSTATUS *s)
Definition
statusmsg.c:82
statusInit
void statusInit(TPCSTATUS *s)
Definition
statusmsg.c:104
statusSet
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
Definition
statusmsg.c:142
statusFree
void statusFree(TPCSTATUS *s)
Definition
statusmsg.c:126
TPCSTATUS
Definition
tpcextensions.h:241
TPCSTATUS::verbose
int verbose
Verbose level, used by statusPrint() etc.
Definition
tpcextensions.h:242
tpcnew.h
Header file for libtpcnew.
Generated on
for TPCCLIB by
1.17.0