Add schema validator, make schemas root relative.
diff --git a/testing/cper-test.c b/testing/cper-test.c
index 99a85c1..ca698b3 100644
--- a/testing/cper-test.c
+++ b/testing/cper-test.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include "../cper-parse.h"
#include "json.h"
+#include "../json-schema.h"
int main(int argc, char* argv[]) {
@@ -14,5 +15,21 @@
json_object* ir = cper_to_ir(cper_file);
fclose(cper_file);
- printf("\n%s\n", json_object_to_json_string(ir));
+ const char* json_output = json_object_to_json_string(ir);
+ printf("\n%s\n", json_output);
+
+ //Test JSON validator.
+ if (argc >= 3)
+ {
+ printf("Validating output with specification %s...\n", argv[2]);
+ char* error_message = malloc(300);
+ if (!validate_schema_from_file(argv[2], ir, error_message))
+ {
+ printf("Validation failed: %s\n", error_message);
+ }
+ else
+ {
+ printf("Validation passed!\n");
+ }
+ }
}
\ No newline at end of file