| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
m> |
| 21 |
|
| 22 |
|
| 23 |
#ifdef HAVE_CONFIG_H |
| 24 |
#include <config.h> |
| 25 |
#endif |
| 26 |
|
| 27 |
#include <stdio.h> |
| 28 |
#include <stdlib.h> |
| 29 |
#include "OVAL/public/oval_schema_version.h" |
| 30 |
#include <stddef.h> |
| 31 |
#include <assert.h> |
| 32 |
#include "util.h" |
| 33 |
#include "public/oscap_debug.h" |
| 34 |
|
| 35 |
static const char *cmp_to_cstr(int cmp) |
| 36 |
{ |
| 37 |
if (cmp == 0) { |
| 38 |
return "is same as"; |
| 39 |
} else if (cmp < 0) { |
| 40 |
return "is older than"; |
| 41 |
} |
| 42 |
return "is newer than"; |
| 43 |
} |
| 44 |
|
| 45 |
int main(int argc, char **argv) |
| 46 |
{ |
| 47 |
if (argc != 4) { |
| 48 |
printf("Not enough arguments\n"); |
| 49 |
return 1; |
| 50 |
} |
| 51 |
oscap_set_verbose(NULL, NULL); |
| 52 |
const char *v1_str = argv[1]; |
| 53 |
const char *v2_str = argv[2]; |
| 54 |
int expected_result = atoi(argv[3]); |
| 55 |
oval_schema_version_t v1 = oval_schema_version_from_cstr(v1_str); |
| 56 |
oval_schema_version_t v2 = oval_schema_version_from_cstr(v2_str); |
| 57 |
int cmp = oval_schema_version_cmp(v1, v2); |
| 58 |
int retval; |
| 59 |
if (cmp == expected_result) { |
| 60 |
retval = 0; |
| 61 |
printf("\tPASS\t%s %s %s\n", v1_str, cmp_to_cstr(cmp), v2_str); |
| 62 |
} else { |
| 63 |
retval = 1; |
| 64 |
printf("\tFAIL\t%s %s %s but expected result is '%s'\n", v1_str, |
| 65 |
cmp_to_cstr(cmp), v2_str, cmp_to_cstr(expected_result)); |
| 66 |
} |
| 67 |
return retval; |
| 68 |
} |