eid-viewer
eid-viewer library
Loading...
Searching...
No Matches
gmain.h
1#pragma once
2#include "win32.h"
3#pragma pack(push, cryptoki, 1)
4#include "pkcs11.h"
5#pragma pack(pop, cryptoki)
6
7#include <time.h>
8
9#include "stdafx.h"
10#include <stdio.h>
11#include "../testlib2.h"
12#include "logtest.h"
13#include <test\testlib.c>
14
15typedef struct {
16 int result;
17 bool doTest;
18 char* testDescription;
19 int (*test_function_ptr)(void);
20} eIDTest;
21
22int gmain(int argc, _TCHAR* argv[] , eIDTest eIDTests[]) {
23 clock_t startTime = clock();
24 clock_t duration = 0;
25 int msecDuration = 0;
26
27 int i = 0;
28 int nrofTests = 0;
29 errno_t error;
30 nrofTests = (sizeof(eIDTests) / sizeof(eIDTest));
31
32 if (argc >= 2)
33 eid_robot_style = argv[1];
34
35 if (argc >= 3)
36 eid_dialogs_style = argv[2];
37
38 if (argc >= 4)
39 eid_builtin_reader = argv[3];
40
41 if (argc >= 5) {
42 for (i = 0; i < nrofTests; i++) {
43 eIDTests[i].doTest = false;
44 for (int j = 4; j < argc; j++) {
45 if (strcmp(argv[j], eIDTests[i].testDescription) == 0) {
46 eIDTests[i].doTest = true;
47 j = argc;
48 }
49 }
50 }
51 }
52
53 error = initLog();
54 if (error != 0)
55 {
56 printf("Can't open logfile");
57 return -1;
58 }
59 for (i = 0; i < nrofTests; i++)
60 {
61 if (!eIDTests[i].doTest)
62 continue;
63 printf("test %d: %s\n", i, eIDTests[i].testDescription);
64 eIDTests[i].result = eIDTests[i].test_function_ptr();
65 }
66
67 int success = 0;
68 int failed = 0;
69 int skipped = 0;
70
71 //testlog(LVL_NOLEVEL,"\n\n_______________________________________________\n");
72 for (i = 0; i < nrofTests; i++)
73 {
74 if (!eIDTests[i].doTest)
75 continue;
76 if (eIDTests[i].testDescription != NULL)
77 {
78 testlog(LVL_NOLEVEL, "_______________________________________________\n");
79 testlog(LVL_NOLEVEL, "Test %d %s \n", i, eIDTests[i].testDescription);
80 }
81 switch (eIDTests[i].result) {
82 case TEST_RV_OK:
83 success++;
84 testlog(LVL_NOLEVEL, "OK\n");
85 break;
86 case TEST_RV_SKIP:
87 skipped++;
88 testlog(LVL_NOLEVEL, "SKIPPED\n");
89 break;
90 case TEST_RV_FAIL:
91 failed++;
92 testlog(LVL_NOLEVEL, "FAILED\n");
93 break;
94 }
95 /*
96 else
97 {
98 switch(eIDTests[i].result.basetestrv)
99 {
100 case TEST_PASSED:
101 testlog(LVL_NOLEVEL,"PASSED\n");
102 break;
103 case TEST_SKIPPED:
104 testlog(LVL_NOLEVEL,"SKIPPED\n");
105 break;
106 case TEST_WARNING:
107 testlog(LVL_NOLEVEL,"WARNING\n");
108 break;
109 case TEST_ERROR:
110 case TEST_FAILED:
111 testlog(LVL_NOLEVEL,"FAILED : Result = 0x%.8x \n", eIDTests[i].result.pkcs11rv);
112 break;
113 default:
114 testlog(LVL_NOLEVEL,"UNKNOWN : Result = 0x%.8x \n", eIDTests[i].result.pkcs11rv);
115 break;
116 };
117 }*/
118 //testlog(LVL_NOLEVEL,"\n_______________________________________________\n");
119 }
120
121 printf("Totals: successful %d, skipped %d, failed %d\n", success, skipped, failed);
122 duration = clock() - startTime;
123
124 msecDuration = (duration * 1000) / CLOCKS_PER_SEC;
125 printf("Duration: %d,%d seconds", msecDuration / 1000, msecDuration % 1000);
126
127 testlog(LVL_NOLEVEL, "\n===============================================\n");
128
129 //short summary
130 /*for (i = 0; i < nrofTests; i++)
131 {
132 if(eIDTests[i].result.pkcs11rv != CKR_OK)
133 {
134 testlog(LVL_NOLEVEL," F ");
135 }
136 else
137 {
138 switch(eIDTests[i].result.basetestrv)
139 {
140 case TEST_PASSED:
141 testlog(LVL_NOLEVEL,"P");
142 break;
143 case TEST_SKIPPED:
144 testlog(LVL_NOLEVEL," S ");
145 break;
146 case TEST_WARNING:
147 testlog(LVL_NOLEVEL," W ");
148 break;
149 case TEST_ERROR:
150 case TEST_FAILED:
151 testlog(LVL_NOLEVEL," F ");
152 break;
153 default:
154 testlog(LVL_NOLEVEL," X ");
155 break;
156 };
157 }
158 }*/
159 testlog(LVL_NOLEVEL, "\n===============================================\n");
160
161 endLog();
162 return failed;
163}
Definition gmain.h:15