Blame tests/perf/validation.c

Packit 8fb591
/**
Packit 8fb591
 * @file validation.c
Packit 8fb591
 * @author Radek Krejci <rkrejci@cesnet.cz>
Packit 8fb591
 * @brief performance test - validating data.
Packit 8fb591
 *
Packit 8fb591
 * Copyright (c) 2016 CESNET, z.s.p.o.
Packit 8fb591
 *
Packit 8fb591
 * This source code is licensed under BSD 3-Clause License (the "License").
Packit 8fb591
 * You may not use this file except in compliance with the License.
Packit 8fb591
 * You may obtain a copy of the License at
Packit 8fb591
 * 
Packit 8fb591
 *     https://opensource.org/licenses/BSD-3-Clause
Packit 8fb591
 */
Packit 8fb591
Packit 8fb591
#include <stdio.h>
Packit 8fb591
#include <string.h>
Packit 8fb591
Packit 8fb591
#include <libyang/libyang.h>
Packit 8fb591
Packit 8fb591
int main(int argc, char *argv[])
Packit 8fb591
{
Packit 8fb591
	struct ly_ctx *ctx;
Packit 8fb591
	struct lyd_node *data;
Packit 8fb591
Packit 8fb591
	if (argc < 3) {
Packit 8fb591
		fprintf(stderr, "Usage: %s model.yin data.xml\n", argv[0]);
Packit 8fb591
		return 1;
Packit 8fb591
	}
Packit 8fb591
Packit 8fb591
	/* libyang context */
Packit 8fb591
	ctx = ly_ctx_new(NULL, 0);
Packit 8fb591
	if (!ctx) {
Packit 8fb591
		fprintf(stderr, "Failed to create context.\n");
Packit 8fb591
		return 1;
Packit 8fb591
	}
Packit 8fb591
Packit 8fb591
	/* schema */
Packit 8fb591
        if (!lys_parse_path(ctx, argv[1], LYS_IN_YIN)) {
Packit 8fb591
		fprintf(stderr, "Failed to load data model.\n");
Packit 8fb591
		goto cleanup;
Packit 8fb591
	}
Packit 8fb591
Packit 8fb591
	/* data */
Packit 8fb591
	data = lyd_parse_path(ctx, argv[2], LYD_XML, LYD_OPT_DESTRUCT | LYD_OPT_CONFIG);
Packit 8fb591
	if (!data) {
Packit 8fb591
		fprintf(stderr, "Failed to load data.\n");
Packit 8fb591
	}
Packit 8fb591
	
Packit 8fb591
cleanup:
Packit 8fb591
    	lyd_free_withsiblings(data);
Packit 8fb591
	ly_ctx_destroy(ctx, NULL);
Packit 8fb591
Packit 8fb591
	return 0;
Packit 8fb591
}
Packit 8fb591