Json daccor
json daccor is a json-schema validation library that accepts json-c
objects as input, and seems to be designed for openwrt, a system
with very similar requirements to BMCs.
Using this library has several motivations. First, it keeps
libcper as a C application so integrations aren't required to provide
a c++ toolchain to be able to run unit tests.
Next, it means that we avoid an "expensive" conversion in unit tests
from json-c -> nlohmann just so we can use a third library, valijson
In terms of dependency count, it drops one dependency.
(nlohmann+valijson) to (json daccor)
Finally, it means that in the future versions of the library, we
can allow json-schema verification as an option in the library
itself, which would allow us to give a CLI option for verifying
schema on any arbitrary output (helping in debugging).
Testing to see if it will work and what improvements it makes
Change-Id: I1c00bf2ef9b898b2e5decd90b749c784fb4de109
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/tests/test-utils.hpp b/tests/test-utils.hpp
index ec5f064..3b1d061 100644
--- a/tests/test-utils.hpp
+++ b/tests/test-utils.hpp
@@ -1,17 +1,10 @@
#ifndef CPER_IR_TEST_UTILS_H
#define CPER_IR_TEST_UTILS_H
-#include <valijson/adapters/nlohmann_json_adapter.hpp>
-#include <valijson/schema.hpp>
-#include <valijson/schema_parser.hpp>
-#include <valijson/validator.hpp>
-#include <nlohmann/json.hpp>
-
-extern "C" {
#include <stdio.h>
#include <libcper/BaseTypes.h>
#include <libcper/generator/sections/gen-section.h>
-}
+#include <json.h>
// Controls whether required properties are added to the majority of property
// definitions. This is useful for unit tests that are validating JSON where
@@ -23,13 +16,7 @@
int single_section,
GEN_VALID_BITS_TEST_TYPE validBitsType);
-std::unique_ptr<valijson::Schema>
-load_schema(AddRequiredProps add_required_props, int single_section);
-
-int schema_validate_from_file(const valijson::Schema &schema,
- nlohmann::json &jsonData,
- std::string &error_message);
-
-nlohmann::json loadJson(const char *filePath);
+int schema_validate_from_file(json_object *to_test, int single_section,
+ int all_valid_bits);
#endif