Blame libopeniscsiusr/tests/test_context.c

Packit eace71
/*
Packit eace71
 * Copyright (C) 2017 Red Hat, Inc.
Packit eace71
 *
Packit eace71
 * This program is free software: you can redistribute it and/or modify
Packit eace71
 * it under the terms of the GNU General Public License as published by
Packit eace71
 * the Free Software Foundation, either version 3 of the License, or
Packit eace71
 * (at your option) any later version.
Packit eace71
 *
Packit eace71
 * This program is distributed in the hope that it will be useful,
Packit eace71
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit eace71
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit eace71
 * GNU General Public License for more details.
Packit eace71
 *
Packit eace71
 * You should have received a copy of the GNU General Public License
Packit eace71
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit eace71
 *
Packit eace71
 * Author: Gris Ge <fge@redhat.com>
Packit eace71
 */
Packit eace71
Packit eace71
#include <stdint.h>
Packit eace71
#include <stdio.h>
Packit eace71
#include <stdlib.h>
Packit eace71
#include <string.h>
Packit eace71
#include <assert.h>
Packit eace71
Packit eace71
#include <libopeniscsiusr/libopeniscsiusr.h>
Packit eace71
Packit eace71
int main(void)
Packit eace71
{
Packit eace71
	struct iscsi_context *ctx = NULL;
Packit eace71
	int rc = EXIT_SUCCESS;
Packit eace71
	int i = 0;
Packit eace71
Packit eace71
	ctx = iscsi_context_new();
Packit eace71
	assert(ctx != NULL);
Packit eace71
	iscsi_context_log_priority_set(ctx, LIBISCSI_LOG_PRIORITY_DEBUG);
Packit eace71
	assert(iscsi_context_log_priority_get(ctx) ==
Packit eace71
	       LIBISCSI_LOG_PRIORITY_DEBUG);
Packit eace71
	iscsi_context_log_func_set(ctx, NULL);
Packit eace71
	iscsi_context_userdata_set(ctx, (void *) &i);
Packit eace71
	assert(* (int *) iscsi_context_userdata_get(ctx) == 0);
Packit eace71
Packit eace71
	iscsi_context_free(ctx);
Packit eace71
	exit(rc);
Packit eace71
}